summaryrefslogtreecommitdiffstats
path: root/nsframework
diff options
context:
space:
mode:
Diffstat (limited to 'nsframework')
-rw-r--r--nsframework/backup_manager/LICENSE177
-rw-r--r--nsframework/backup_manager/Makefile.client19
-rw-r--r--nsframework/backup_manager/Makefile.server19
-rw-r--r--nsframework/backup_manager/client/Makefile53
-rw-r--r--nsframework/backup_manager/client/include/bkup_api.h60
-rw-r--r--nsframework/backup_manager/client/include/native_service/backup_manager.h42
-rw-r--r--nsframework/backup_manager/client/include/native_service/ns_backup.h498
-rw-r--r--nsframework/backup_manager/client/libns_backup.ver34
-rw-r--r--nsframework/backup_manager/client/src/bkup_api.cpp343
-rw-r--r--nsframework/backup_manager/config/Makefile42
-rw-r--r--nsframework/backup_manager/config/backup.rng123
-rw-r--r--nsframework/backup_manager/config/conf/backup/ALL_.xml1216
-rw-r--r--nsframework/backup_manager/config/conf/backup/backup_AREA1_L.xml248
-rw-r--r--nsframework/backup_manager/config/conf/backup/backup_AREA1_TE.xml248
-rw-r--r--nsframework/backup_manager/config/conf/backup/backup_AREA2_T.xml287
-rw-r--r--nsframework/backup_manager/config/conf/backup/backup_AREA2_TE.xml289
-rwxr-xr-xnsframework/backup_manager/config/createhdr.pl84
-rw-r--r--nsframework/backup_manager/config/sample.xml23
-rwxr-xr-xnsframework/backup_manager/config/uniqcheck.pl46
-rw-r--r--nsframework/backup_manager/server/Makefile67
-rw-r--r--nsframework/backup_manager/server/include/bkup_backupmanagerlog.h80
-rw-r--r--nsframework/backup_manager/server/include/bkup_crc32.h22
-rw-r--r--nsframework/backup_manager/server/include/bkup_param.h39
-rw-r--r--nsframework/backup_manager/server/include/bkup_process.h31
-rw-r--r--nsframework/backup_manager/server/include/bkup_util.h53
-rw-r--r--nsframework/backup_manager/server/src/backupmanager_application.cpp277
-rw-r--r--nsframework/backup_manager/server/src/backupmanager_main.cpp61
-rw-r--r--nsframework/backup_manager/server/src/bkup_crc32.cpp62
-rw-r--r--nsframework/backup_manager/server/src/bkup_param.cpp447
-rw-r--r--nsframework/backup_manager/server/src/bkup_process.cpp2497
-rw-r--r--nsframework/common_library/LICENSE177
-rw-r--r--nsframework/common_library/Makefile.client19
-rw-r--r--nsframework/common_library/client/Makefile30
-rw-r--r--nsframework/common_library/client/include/cl_cgroup.h35
-rw-r--r--nsframework/common_library/client/include/cl_error.h44
-rw-r--r--nsframework/common_library/client/include/cl_lock_internal.h55
-rw-r--r--nsframework/common_library/client/include/cl_monitor_internal.h30
-rw-r--r--nsframework/common_library/client/include/cl_process_internal.h53
-rw-r--r--nsframework/common_library/client/include/native_service/cl_lock.h259
-rw-r--r--nsframework/common_library/client/include/native_service/cl_lockid.h180
-rw-r--r--nsframework/common_library/client/include/native_service/cl_monitor.h269
-rw-r--r--nsframework/common_library/client/include/native_service/cl_process.h1288
-rw-r--r--nsframework/common_library/client/include/native_service/cl_region.h257
-rw-r--r--nsframework/common_library/client/include/native_service/cl_sem.h73
-rw-r--r--nsframework/common_library/client/include/native_service/common_library.h48
-rw-r--r--nsframework/common_library/client/libcommon.ver30
-rw-r--r--nsframework/common_library/client/src/cl_cgroup.c260
-rw-r--r--nsframework/common_library/client/src/cl_lock.c221
-rw-r--r--nsframework/common_library/client/src/cl_monitor.c442
-rw-r--r--nsframework/common_library/client/src/cl_process.c1198
-rw-r--r--nsframework/common_library/client/src/cl_region.c295
-rw-r--r--nsframework/common_library/client/src/cl_sem.c67
-rw-r--r--nsframework/framework_unified/LICENSE177
-rw-r--r--nsframework/framework_unified/Makefile.client19
-rw-r--r--nsframework/framework_unified/client/Makefile269
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_internal.h54
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_parser.h148
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_reader.h133
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_writer.h146
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/include/ns_config_parser_frameworkunifiedlog.h88
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/makefile_PosixBasedOS001207
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_parser.cpp365
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_reader.cpp117
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_writer.cpp135
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader.cpp346
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader_writer.cpp74
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_writer.cpp227
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_reader.cpp36
-rw-r--r--nsframework/framework_unified/client/NS_ConfigParser/src/ns_writer.cpp36
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h676
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp43
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h675
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h41
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h148
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h97
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h89
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h30
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp2382
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp983
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp130
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp575
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp502
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp867
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp1357
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp439
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp77
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp210
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp531
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp128
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp156
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp67
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001214
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp32
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp371
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp152
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp79
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp240
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp225
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp79
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp485
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp41
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp148
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp529
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp1419
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp78
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp84
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp211
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp337
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp74
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp634
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp57
-rw-r--r--nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile99
-rw-r--r--nsframework/framework_unified/client/NS_Logger/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_Logger/include/frameworkunified_stub.h111
-rw-r--r--nsframework/framework_unified/client/NS_Logger/include/ns_logger_internal.h44
-rw-r--r--nsframework/framework_unified/client/NS_Logger/src/makefile_PosixBasedOS001223
-rw-r--r--nsframework/framework_unified/client/NS_Logger/src/ns_logger.cpp2260
-rw-r--r--nsframework/framework_unified/client/NS_Logger/tool/nslogsw.cpp114
-rw-r--r--nsframework/framework_unified/client/NS_MessageCenter/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_MessageCenter/include/ns_mc_internal.h93
-rw-r--r--nsframework/framework_unified/client/NS_MessageCenter/include/ns_message_center_internal.h185
-rw-r--r--nsframework/framework_unified/client/NS_MessageCenter/src/makefile_PosixBasedOS001214
-rw-r--r--nsframework/framework_unified/client/NS_MessageCenter/src/ns_message_center.c1269
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_anomaly.h35
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_internal.h58
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/include/ns_msg_queue.h295
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/src/makefile_PosixBasedOS001207
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/src/ns_mq_string.c60
-rw-r--r--nsframework/framework_unified/client/NS_MessageQueue/src/ns_msg_queue.c596
-rw-r--r--nsframework/framework_unified/client/NS_NPServiceIf/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_NPServiceIf/include/ns_np_service_internal.h75
-rw-r--r--nsframework/framework_unified/client/NS_NPServiceIf/src/makefile_PosixBasedOS001208
-rw-r--r--nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_api.c1001
-rw-r--r--nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_nor_persistence.cpp498
-rw-r--r--nsframework/framework_unified/client/NS_ResourceControler/src/ns_resource_controler.cpp168
-rw-r--r--nsframework/framework_unified/client/NS_RingBuffer/src/ns_ringbuffer.cpp1029
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/api/nsapi_sharedmem.cpp431
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/src/makefile_PosixBasedOS001190
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/src/ns_shared_mem_if.cpp254
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem.cpp697
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_reader.cpp169
-rw-r--r--nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_writer.cpp137
-rw-r--r--nsframework/framework_unified/client/NS_Timer/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_Timer/include/ns_timer_handle.h48
-rw-r--r--nsframework/framework_unified/client/NS_Timer/include/ns_timer_internal.h28
-rw-r--r--nsframework/framework_unified/client/NS_Timer/src/makefile_PosixBasedOS001206
-rw-r--r--nsframework/framework_unified/client/NS_Timer/src/mod_version.c51
-rw-r--r--nsframework/framework_unified/client/NS_Timer/src/ns_timer.c514
-rw-r--r--nsframework/framework_unified/client/NS_Timer/src/ns_timer_class.cpp177
-rw-r--r--nsframework/framework_unified/client/NS_Utility/Makefile19
-rw-r--r--nsframework/framework_unified/client/NS_Utility/buildversioncheck/Makefile21
-rw-r--r--nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/Makefile62
-rw-r--r--nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/src/NS_BuildVersionCheck.cpp85
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_if_internal.h193
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_sys_internal.hpp353
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/src/frameworkunified_version.cpp236
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/src/makefile_PosixBasedOS001194
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/src/ns_endianess.cpp52
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_crc.cpp125
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_directory.cpp145
-rw-r--r--nsframework/framework_unified/client/NS_UtilityCenter/src/ns_utility.cpp144
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/Makefile20
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/Makefile19
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_XML.h113
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_cfg.h104
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_internal.h60
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_xmlconfig_parser_frameworkunifiedlog.h88
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/Makefile57
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/makefile_PosixBasedOS001208
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_reader.cpp522
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_writer.cpp338
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser.cpp354
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_attributes.cpp55
-rw-r--r--nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_node.cpp658
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/cfg/depends.mk25
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__service_if.cpp367
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__session_if.cpp325
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified_stub.h20
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/makefile_PosixBasedOS001208
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__common_internal.h51
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_internal.h64
-rw-r--r--nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_table.cpp538
-rw-r--r--nsframework/framework_unified/client/NativeServices/Makefile29
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_arm.mk88
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_armv7.mk96
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_x86.mk89
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/analysis.mk73
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/common.mk175
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/config.mk115
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/depends.mk115
-rw-r--r--nsframework/framework_unified/client/NativeServices/cfg/nativeserviceslibraries.mk54
-rw-r--r--nsframework/framework_unified/client/NativeServices/makefile_PosixBasedOS00155
-rw-r--r--nsframework/framework_unified/client/NativeServices/scfg/ns_filestorage.sql9
-rw-r--r--nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog.cfg278
-rw-r--r--nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog__CWORD84_.cfg427
-rw-r--r--nsframework/framework_unified/client/include/native_service/XMLParser.h289
-rw-r--r--nsframework/framework_unified/client/include/native_service/framework_unified.h130
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__service_if.h554
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__session_if.h495
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_application.h376
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_dispatcher.h803
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_framework_error.hpp77
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_framework_if.h6007
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_framework_sync.h370
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_framework_system_if.h110
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_framework_types.h173
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_multithreading.h745
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_service_if.h267
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_service_protocol.h116
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_action.h150
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_compositestate.h434
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_conditionconnector.h203
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_deephistorystate.h141
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_dispatcher.h338
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventdata.h83
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventfactory.h114
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_externaltransition.h268
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_dispatch.h1054
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_if.h486
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_types.h494
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_guard.h145
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_historystate.h253
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsm.h798
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsmframework.h873
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_internaltransition.h111
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_leafstate.h252
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_localtransition.h163
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_multithreading.h227
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_orthogonalstate.h513
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_reaction.h184
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_shallowhistorystate.h163
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_state.h872
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_sm_transition.h150
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_thread_priority.h235
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_timer.h143
-rw-r--r--nsframework/framework_unified/client/include/native_service/frameworkunified_types.h268
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns__CWORD77__common.h129
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_if.h183
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_key.h53
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_table.h1217
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns__CWORD77__notifications.h53
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns__CWORD77__types.h68
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_buildversioncheck.hpp227
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_config_parser_if.h1038
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_endianess.h192
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_eventlogger.h103
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_logger_if.h1646
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_mc_system_info.h103
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_message_center_if.h1536
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_msgs.h64
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_service.h271
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_service_if.h2482
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence.h151
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence_internal.h131
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_service_notification.h50
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_service_protocol.h116
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_np_types.h47
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_plogger_if.h288
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_rcs_data_handler.hpp1159
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_rcs_logger_types.h104
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_rcs_plugin.hpp328
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_reader.h207
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_resource_controler.h216
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_ringbuffer.h523
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_shared_mem.h100
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_shared_mem_if.h196
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_sharedmem.h486
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_sharedmem_reader.h340
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_sharedmem_writer.h283
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_system_mode.h67
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_timer_if.h317
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_timer_if.hpp393
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_transmit_log.h256
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_util_crc.h111
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_util_directory.h160
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_utility.hpp572
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_utility_if.h76
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_utility_sys.hpp321
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_version.h48
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_version_if.h510
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_writer.h229
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_xml_reader.h291
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_xml_writer.h336
-rw-r--r--nsframework/framework_unified/client/include/native_service/ns_xmlparser_if.h1150
-rw-r--r--nsframework/framework_unified/client/include/native_service/nsfw_message.h65
-rw-r--r--nsframework/framework_unified/client/include/native_service/nslogutil_cmd_if.h86
-rw-r--r--nsframework/framework_unified/client/include/native_service/wpf_legacy.h152
-rw-r--r--nsframework/framework_unified/client/include/ns__CWORD77__template.h60
-rw-r--r--nsframework/framework_unified/client/include/ns_logger_additional_if.h40
-rw-r--r--nsframework/framework_unified/client/include/nsverutil_cmd_if.h25
-rw-r--r--nsframework/framework_unified/client/libNS_FrameworkUnified.ver144
-rw-r--r--nsframework/log_library/LICENSE177
-rw-r--r--nsframework/log_library/Makefile.client19
-rw-r--r--nsframework/log_library/client/Makefile32
-rw-r--r--nsframework/log_library/client/include/loglibrarylog_internal.h26
-rw-r--r--nsframework/log_library/client/include/native_service/loglibrarylog_if.h79
-rw-r--r--nsframework/log_library/client/include/native_service/loglibrarylog_library.h42
-rw-r--r--nsframework/log_library/client/src/loglibrarylog.c60
-rw-r--r--nsframework/native_service.mk44
-rw-r--r--nsframework/notification_persistent_service/LICENSE177
-rw-r--r--nsframework/notification_persistent_service/Makefile.server19
-rw-r--r--nsframework/notification_persistent_service/server/Makefile87
-rw-r--r--nsframework/notification_persistent_service/server/include/app_states.h187
-rw-r--r--nsframework/notification_persistent_service/server/include/native_service/notification_persistent_service.h40
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp.h296
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_binary_accesser.h230
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_copy_worker.h558
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_fs_directory.h111
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_handlelist.h145
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_nor_persistence_worker_thread.h218
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_notification.h323
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_notification_manager.h496
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_notification_receiver.h68
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_notificationpersistentservicelog.h94
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_persist_file.h121
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_persist_folder.h122
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_persistence.h365
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_persistence_manager.h536
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_persistent_accesser.h119
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_persistent_data.h165
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_personality.h75
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_personalization_manager.h132
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_profiling_protocols_internal.h34
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_registry_entry.h330
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_regular_notification.h109
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_state_nor_persistence_notification.h177
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_state_notification.h221
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_notification.h104
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_user_notification.h73
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_threads.h46
-rw-r--r--nsframework/notification_persistent_service/server/include/ns_npp_types.h212
-rw-r--r--nsframework/notification_persistent_service/server/src/app_states.cpp2684
-rw-r--r--nsframework/notification_persistent_service/server/src/notificationpersistentservice_application.cpp258
-rw-r--r--nsframework/notification_persistent_service/server/src/notificationpersistentservice_main.cpp131
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp.cpp1149
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_archive.cpp846
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_binary_accesser.cpp649
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_copy_worker.cpp1153
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_fs_directory.cpp232
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_handlelist.cpp149
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_nor_persistence_worker_thread.cpp747
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_notification.cpp485
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_notification_manager.cpp1558
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_notification_receiver.cpp50
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_persist_file.cpp100
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_persist_folder.cpp96
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_persistence.cpp743
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_persistence_manager.cpp1132
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_persistent_data.cpp58
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_personalization_manager.cpp181
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_registry_entry.cpp333
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_regular_notification.cpp158
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_state_nor_persistence_notification.cpp305
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_state_notification.cpp402
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_notification.cpp87
-rw-r--r--nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_user_notification.cpp61
362 files changed, 109848 insertions, 0 deletions
diff --git a/nsframework/backup_manager/LICENSE b/nsframework/backup_manager/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/nsframework/backup_manager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/nsframework/backup_manager/Makefile.client b/nsframework/backup_manager/Makefile.client
new file mode 100644
index 00000000..07bada3d
--- /dev/null
+++ b/nsframework/backup_manager/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := config client
+
+include ../native_service.mk
diff --git a/nsframework/backup_manager/Makefile.server b/nsframework/backup_manager/Makefile.server
new file mode 100644
index 00000000..62bd0d6a
--- /dev/null
+++ b/nsframework/backup_manager/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := server
+
+include ../native_service.mk
diff --git a/nsframework/backup_manager/client/Makefile b/nsframework/backup_manager/client/Makefile
new file mode 100644
index 00000000..41d2bf79
--- /dev/null
+++ b/nsframework/backup_manager/client/Makefile
@@ -0,0 +1,53 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### libraries to be installed(*.so)#############
+INST_SHLIBS := libns_backup
+
+######### headers to be installed(*.h) #############
+INST_HEADERS := backup_manager.h ns_backup.h
+
+######### sources to be compiled #############
+libns_backup_SRCS := bkup_api.cpp
+
+######### search paths #############
+VPATH += ./src ./include/$(COMPONENT_NAME) ../server/include
+
+######### include paths #############
+CPPFLAGS += -I./include
+CPPFLAGS += -I../server/include
+
+######### frameworkunifiedlog options #############
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+
+LDFLAGS += -Wl,--no-as-needed
+LDFLAGS += -Wl,--no-undefined
+
+######### libraries to be linked(dynamic)#############
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+
+######### other unit specific options #############
+LINK_CXX=Y
+
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+include ../../native_service.mk
diff --git a/nsframework/backup_manager/client/include/bkup_api.h b/nsframework/backup_manager/client/include/bkup_api.h
new file mode 100644
index 00000000..d5b0d2bc
--- /dev/null
+++ b/nsframework/backup_manager/client/include/bkup_api.h
@@ -0,0 +1,60 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BACKUP_MANAGER_CLIENT_INCLUDE_BKUP_API_H_
+#define BACKUP_MANAGER_CLIENT_INCLUDE_BKUP_API_H_
+
+#define BACKUP_CID 0xBACC1D00
+
+#define BKUP_MAX_ITEM_NAME 64
+
+/**
+ * media
+ */
+#include <nv_hal.h>
+
+/**
+ * command
+ */
+typedef enum {
+ BKUP_CMD_READ = 0,
+ BKUP_CMD_WRITE,
+ BKUP_CMD_FILL,
+ BKUP_CMD_SIZE,
+ BKUP_CMD_READ_NUM,
+ BKUP_CMD_SIZE_NUM,
+ BKUP_CMD_CHECK,
+ BKUP_CMD_DELETE,
+ BKUP_CMD_COPY_INNER,
+ BKUP_CMD_MAX,
+} bkup_protocol_command_t;
+
+/**
+ * api/process protocol
+ */
+typedef struct {
+ bkup_protocol_command_t command;
+ char item_name[64];
+ uint32_t num_id;
+ uint32_t offset;
+ uint32_t size;
+ char fill_patern;
+ enum NvHalMedia src_media;
+} bkup_protocol_header_t;
+
+#define SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD "bkupmanagerthr"
+
+#endif // BACKUP_MANAGER_CLIENT_INCLUDE_BKUP_API_H_
diff --git a/nsframework/backup_manager/client/include/native_service/backup_manager.h b/nsframework/backup_manager/client/include/native_service/backup_manager.h
new file mode 100644
index 00000000..636c38c3
--- /dev/null
+++ b/nsframework/backup_manager/client/include/native_service/backup_manager.h
@@ -0,0 +1,42 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file backup_manager.h
+ * @brief backup_manager unit common header file.
+ */
+
+#ifndef NATIVESERVICE_BACKUPMANAGER_H_ // NOLINT(build/header_guard)
+#define NATIVESERVICE_BACKUPMANAGER_H_
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup backup_manager
+ * @ingroup native_service
+ * @{
+ */
+
+#include <native_service/ns_backup.h>
+
+/**@}*/ // end of backup_manager
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
+
+#endif // NATIVESERVICE_BACKUPMANAGER_H_
diff --git a/nsframework/backup_manager/client/include/native_service/ns_backup.h b/nsframework/backup_manager/client/include/native_service/ns_backup.h
new file mode 100644
index 00000000..5655ae35
--- /dev/null
+++ b/nsframework/backup_manager/client/include/native_service/ns_backup.h
@@ -0,0 +1,498 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ns_backup.h
+ * @brief backup_manager function header file
+ */
+
+#ifndef BACKUP_MANAGER_CLIENT_INCLUDE_NATIVE_SERVICE_NS_BACKUP_H_
+#define BACKUP_MANAGER_CLIENT_INCLUDE_NATIVE_SERVICE_NS_BACKUP_H_
+
+#include <native_service/frameworkunified_types.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup backup_manager
+ * @ingroup native_service
+ * @{
+ */
+
+/**
+ * \~english Service availability notify
+ */
+#define NTFY_BackupMgr_Availability "NS_BackupMgr/Availability"
+
+/**
+ * \~english Return value: terminated normally
+ */
+#define BKUP_RET_NORMAL 0
+
+/**
+ * \~english Return value: abnormal termination(content not specified)
+ */
+#define BKUP_RET_ERROR -1
+
+/**
+ * \~english Return value: parameter error
+ */
+#define BKUP_RET_ERRPARAM -2
+
+/**
+ * \~english Return value: initializing
+ */
+#define BKUP_RET_ERRINIT -3
+
+/**
+ * \~english Return value: terminating
+ */
+#define BKUP_RET_ERRTERM -4
+
+/**
+ * \~english Return value: data does not exist
+ */
+#define BKUP_RET_ERRNOENT -5
+
+/**
+ * \~english Return value: data size error
+ */
+#define BKUP_RET_ERRSIZE -6
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup Backup_DataRd
+ * \~english @par Brief
+ * Read data from backup area
+ * \~english @param [in] tagID
+ * PCSTR - Area ID(character string of less than 64 bytes)
+ * \~english @param [in] uiOffset
+ * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID)
+ * \~english @param [out] pvBuf
+ * void * - A pointer which point to buffer used to storage read data
+ * \~english @param [in] uiSize
+ * uint32_t - Read data size(0~size of backup area identified by area ID)
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If the buffer point(pvBuf) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ Judge the type and access destination according to specified area ID and then read data.
+ * - If appointed size is less than registered size, read data of appointed size. [BKUP_RET_NORMAL]
+ * - If the backup data does not exist, buffer is filled 0. [BKUP_RET_NORMAL]
+ *
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * Backup_DataWt
+ */
+int32_t Backup_DataRd(PCSTR tag_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size);
+/**
+ * \ingroup Backup_DataWt
+ * \~english @par Brief
+ * Write data to backup area
+ * \~english @param [in] tagID
+ * PCSTR - Area ID(character string of less than 64 bytes)
+ * \~english @param [in] pvBuf
+ * void * - A pointer which point to buffer used to storage write data
+ * \~english @param [in] uiOffset
+ * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID)
+ * \~english @param [in] uiSize
+ * uint32_t - Write data size(0~size of backup area identified by area ID)
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If the buffer point(pvBuf) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If system call(mmap()) is error [BKUP_RET_ERROR]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the storage media type and access destination according to specified area ID and then write data.
+ * Calling @ref Backup_DataWt more than once for the same ID when writing data separately.
+ * Data integrity can not be guaranteed at power interruption.
+ * Data should be written at one time to guarantee data consistency.
+ * The work life of writing times depends on how the user writes,NS_BackupMgr doesn't guaranteed.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * Backup_DataRd
+ */
+int32_t Backup_DataWt(PCSTR tag_id, void *pv_buf, uint32_t ui_offset, uint32_t ui_size);
+
+
+/**
+ * \ingroup Backup_DataFil
+ * \~english @par Brief
+ * Write data to backup area with the specified pattern
+ * \~english @param [in] tagID
+ * PCSTR - Area ID(character string of less than 64 bytes)
+ * \~english @param [in] uiOffset
+ * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID)
+ * \~english @param [in] ucPat
+ * uint8_t - Write pattern data(0x00~0xff)
+ * \~english @param [in] uiSize
+ * uint32_t - Write data size(0~size of backup area identified by area ID)
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the type and access destination according to specified area ID and then fill it with the specified pattern.
+ * The work life of writing times depends on how the usrs writes,NS_BackupMgr doesn't guaranteed.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * none
+ */
+int32_t Backup_DataFil(PCSTR tag_id, uint32_t ui_offset, uint8_t uc_pat, uint32_t ui_size);
+
+
+/**
+ * \ingroup Backup_DataSz
+ * \~english @par Brief
+ * Get the size of the backup area.
+ * \~english @param [in] tagID
+ * PCSTR - Area ID(character string of less than 64 bytes)
+ * \~english @param [out] puiSize
+ * uint32_t * - A pointer which point to storage size
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If the pointer(puiSize) that stores the size specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the type and access destination according to specified area ID and acquire the size of the target data.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * none
+ */
+int32_t Backup_DataSz(PCSTR tag_id, uint32_t *pui_size);
+
+/**
+ * \ingroup Backup_DataRdByNumID
+ * \~english @par Brief
+ * Read data from backup area
+ * \~english @param [in] numID
+ * uint32_t - Area ID specified by number
+ * \~english @param [in] uiOffset
+ * uint32_t - Offset from the beginning of the area(0~size of backup area identified by area ID)
+ * \~english @param [out] pvBuf
+ * void * - A pointer which point to buffer used to storage read data
+ * \~english @param [in] uiSize
+ * uint32_t - Read data size(0~size of backup area identified by area ID)
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If the buffer point(pvBuf) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the type and access destination according to specified area ID and then read data.
+ * Backup Non-volatile Data Read API for DIAG
+ * Use from the module other than DIAG is prohibited.
+ *
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * Backup_DataRd
+ */
+int32_t Backup_DataRdByNumID(uint32_t num_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size);
+
+
+/**
+ * \ingroup Backup_DataSzByNumID
+ * \~english @par Brief
+ * Get the size of the backup area.
+ * \~english @param [in] numID
+ * uint32_t - Area ID specified by number
+ * \~english @param [out] puiSize
+ * uint32_t * - A pointer which point to storage size
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If the pointer(puiSize) that stores the size specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the type and access destination according to specified area ID and acquire the size of the target data.
+ * Get Non-volatile backup data size API for DIAG
+ * Use from the module other than DIAG is prohibited.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * Backup_DataSz
+ */
+int32_t Backup_DataSzByNumID(uint32_t num_id, uint32_t *pui_size);
+
+/**
+ * \ingroup Backup_DataChk
+ * \~english @par Brief
+ * Check backup data.
+ * \~english @param [in] tagID
+ * PCSTR - Area ID(character string of less than 64 bytes)
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRNOENT Data dose not exist(Sync message transmission or reception(@ref McInvokeSync) fails [eFrameworkunifiedStatusFileLoadError])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusFileLoadError [BKUP_RET_ERRNOENT]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * - If the size specified by the argument does not match the actual read size [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the type and access destination according to specified area ID and check the target data.
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * none
+ */
+int32_t Backup_DataChk(PCSTR tag_id);
+
+/**
+ * \ingroup Backup_DataDel
+ * \~english @par Brief
+ * Delete backup data.
+ * \~english @param [in] tag_id
+ * PCSTR - Area ID(character string of less than 64 bytes)
+ * \~english @retval BKUP_RET_NORMAL Terminated normally
+ * \~english @retval BKUP_RET_ERRPARAM Parameter error(Sync message transmission or reception(@ref McInvokeSync) error[eFrameworkunifiedStatusInvldParam])
+ * \~english @retval BKUP_RET_ERRINIT Initializing(Sync message send or receive(@ref McInvokeSync) error [eFrameworkunifiedStatusErrOther])
+ * \~english @retval BKUP_RET_ERRTERM Terminating(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusExit])
+ * \~english @retval BKUP_RET_ERRSIZE Data size error(Sync message transmission or reception(@ref McInvokeSync) error [eFrameworkunifiedStatusAccessError])
+ * \~english @retval BKUP_RET_ERROR Abnormal termination(@ref McOpenSender failed, or sync message transmission or reception(@ref McInvokeSync) error other than the above)
+ * \~english @par Prerequisite
+ * - None.
+ * \~english @par Change of internal state
+ * - Change of internal state according to the API does not occur.
+ * \~english @par Conditions of processing failure
+ * - If the area ID(tagID) specified by the argument is NULL [BKUP_RET_ERRPARAM]
+ * - If the area ID(tagID) specified by the argument is 64 bytes or more than 64 bytes [BKUP_RET_ERRPARAM]
+ * - If system call(pctrl(PR_GET_NAME)) is error [BKUP_RET_ERROR]
+ * - If failed to open the message queue for transmission [BKUP_RET_ERROR]
+ * - If failed to genarate message queue name for synchronous communication [BKUP_RET_ERROR]
+ * - If failed to open the reception message queue for synchronous communication [BKUP_RET_ERROR]
+ * - Sync message transmission or reception(@ref McInvokeSync) error
+ * - If the return value is eFrameworkunifiedStatusInvldParam [BKUP_RET_ERRPARAM]
+ * - If the return value is eFrameworkunifiedStatusErrOther [BKUP_RET_ERRINIT]
+ * - If the return value is eFrameworkunifiedStatusExit [BKUP_RET_ERRTERM]
+ * - If the return value is eFrameworkunifiedStatusAccessError [BKUP_RET_ERRSIZE]
+ * - If the return value is eFrameworkunifiedStatusFail, it call will synchronization message transmission(@ref McInvokeSync) again after 100 milliseconds later
+ * If the return value is eFrameworkunifiedStatusFail, it will retry BKUP_RETRY_MAX(10) times
+ * - If the return value is other value [BKUP_RET_ERROR]
+ * \~english @par Detail
+ * Judge the type and access destination according to specified area ID and delete the target data.
+ * - If the target data does not exist, return value is terminated normally. [BKUP_RET_NORMAL]
+ * \~english @par Classification
+ * Public
+ * \~english @par Type
+ * Sync
+ * \~english @see
+ * none
+ */
+int32_t Backup_DataDel(PCSTR tag_id);
+
+#ifdef __cplusplus
+}
+#endif /*__cplusplus */
+
+/**@}*/ // end of backup_manager
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
+
+#endif // BACKUP_MANAGER_CLIENT_INCLUDE_NATIVE_SERVICE_NS_BACKUP_H_
diff --git a/nsframework/backup_manager/client/libns_backup.ver b/nsframework/backup_manager/client/libns_backup.ver
new file mode 100644
index 00000000..55003a88
--- /dev/null
+++ b/nsframework/backup_manager/client/libns_backup.ver
@@ -0,0 +1,34 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#
+# backup version script
+#
+{
+ global:
+ ### .text section ###
+ Backup_DataRd;
+ Backup_DataWt;
+ Backup_DataFil;
+ Backup_DataSz;
+ Backup_DataRdByNumID;
+ Backup_DataSzByNumID;
+ Backup_DataChk;
+ Backup_DataDel;
+ ### .data section ###
+ local:
+ *;
+};
diff --git a/nsframework/backup_manager/client/src/bkup_api.cpp b/nsframework/backup_manager/client/src/bkup_api.cpp
new file mode 100644
index 00000000..2c085c05
--- /dev/null
+++ b/nsframework/backup_manager/client/src/bkup_api.cpp
@@ -0,0 +1,343 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/prctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <native_service/ns_backup.h>
+#include <native_service/ns_message_center_if.h>
+#include <agl_thread.h>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include "bkup_api.h"
+#include "bkup_backupmanagerlog.h"
+#include "bkup_util.h"
+
+#define BKUP_RETRY_MAX (10)
+#define BKUP_RETRY_TIMER (100 * 1000)
+
+static __thread HANDLE g_bkup_msg_handle;
+static __thread HANDLE g_bkup_response_handle;
+
+static int32_t BkupApiCheckTagid(PCSTR tag_id) {
+ if (tag_id == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "tag_id is NULL");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ return BKUP_RET_ERRPARAM;
+ }
+ if (strlen(tag_id) >= BKUP_MAX_ITEM_NAME) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "tag_id is long:%zd", strlen(tag_id));
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ return BKUP_RET_ERRPARAM;
+ }
+ return BKUP_RET_NORMAL;
+}
+
+static int32_t BkupApiCall(void *snd_buf, size_t snd_size, void *rcv_buf, uint32_t rcv_size) {
+ int32_t ret = BKUP_RET_ERROR;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusFail;
+ uint32_t real_rcvlen = 0;
+ static __thread char thread_name[16];
+
+ if (g_bkup_msg_handle == NULL) {
+ char invoker_name[24];
+
+ if (prctl(PR_GET_NAME, thread_name) < 0) { // LCOV_EXCL_BR_LINE 5:prctl's error case.
+ // LCOV_EXCL_START 5:prctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "prctl(PR_GET_NAME):%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5:prctl's error case.
+ }
+
+ g_bkup_msg_handle = McOpenSender(SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD);
+ if (g_bkup_msg_handle == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McOpenSender");
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = McCreateInvokerName(thread_name, 0, invoker_name, sizeof(invoker_name))) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McCreateInvokerName:%d", e_status);
+ McClose(g_bkup_msg_handle);
+ g_bkup_msg_handle = NULL;
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ g_bkup_response_handle = McOpenSyncReceiver(invoker_name);
+ if (g_bkup_response_handle == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McOpenSyncReceiver");
+ McClose(g_bkup_msg_handle);
+ g_bkup_msg_handle = NULL;
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+ }
+
+ for (int retry_cnt = 0; retry_cnt < BKUP_RETRY_MAX; retry_cnt++) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ e_status = McInvokeSync(g_bkup_msg_handle, thread_name, BACKUP_CID, static_cast<UI_32>(snd_size), snd_buf, 0,
+ g_bkup_response_handle, rcv_size, rcv_buf, &real_rcvlen);
+ if (e_status != eFrameworkunifiedStatusFail) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ break;
+ }
+ usleep(BKUP_RETRY_TIMER);
+ }
+
+ if (e_status != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "McInvokeSync:%d", e_status);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ if (e_status == eFrameworkunifiedStatusInvldParam) {
+ ret = BKUP_RET_ERRPARAM;
+ } else if (e_status == eFrameworkunifiedStatusErrOther) {
+ ret = BKUP_RET_ERRINIT;
+ } else if (e_status == eFrameworkunifiedStatusExit) {
+ ret = BKUP_RET_ERRTERM;
+ } else if (e_status == eFrameworkunifiedStatusFileLoadError) {
+ ret = BKUP_RET_ERRNOENT;
+ } else if (e_status == eFrameworkunifiedStatusAccessError) {
+ ret = BKUP_RET_ERRSIZE;
+ } else {
+ ret = BKUP_RET_ERROR;
+ }
+ goto exit;
+ }
+ if (rcv_size != real_rcvlen) {
+ goto exit;
+ }
+ ret = BKUP_RET_NORMAL;
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataRd(PCSTR tag_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size) {
+ int32_t ret = BKUP_RET_NORMAL;
+ bkup_protocol_header_t hdr;
+
+ if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) {
+ goto exit;
+ }
+ if (pv_buf == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = BKUP_RET_ERRPARAM;
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_READ;
+ BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name));
+ hdr.offset = ui_offset;
+ hdr.size = ui_size;
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), pv_buf, ui_size);
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataWt(PCSTR tag_id, void *pv_buf, uint32_t ui_offset, uint32_t ui_size) {
+ int32_t ret;
+ char *snd_buf = NULL;
+ size_t snd_buf_size = 0;
+ bkup_protocol_header_t *hdr;
+
+ if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) {
+ goto exit;
+ }
+ if (pv_buf == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = BKUP_RET_ERRPARAM;
+ goto exit;
+ }
+
+ // LCOV_EXCL_BR_START 5:mmap's error case.
+ if ((snd_buf = BkupAnonMmap(sizeof(bkup_protocol_header_t) + ui_size)) == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ ret = BKUP_RET_ERROR;
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+ snd_buf_size = sizeof(bkup_protocol_header_t) + ui_size;
+
+ hdr = reinterpret_cast<bkup_protocol_header_t *>(snd_buf);
+ hdr->command = BKUP_CMD_WRITE;
+ BkupStrlcpy(hdr->item_name, tag_id, sizeof(hdr->item_name));
+ hdr->offset = ui_offset;
+ hdr->size = ui_size;
+ memcpy(snd_buf + sizeof(bkup_protocol_header_t), pv_buf, ui_size);
+
+ ret = BkupApiCall(snd_buf, snd_buf_size, NULL, 0);
+
+exit:
+ if (snd_buf) {
+ munmap(snd_buf, snd_buf_size);
+ }
+ return ret;
+}
+
+int32_t Backup_DataFil(PCSTR tag_id, uint32_t ui_offset, uint8_t uc_pat, uint32_t ui_size) {
+ int32_t ret;
+ bkup_protocol_header_t hdr;
+
+ if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) {
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_FILL;
+ BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name));
+ hdr.offset = ui_offset;
+ hdr.size = ui_size;
+ hdr.fill_patern = uc_pat;
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), NULL, 0);
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataSz(PCSTR tag_id, uint32_t *pui_size) {
+ int32_t ret;
+ bkup_protocol_header_t hdr;
+
+ if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) {
+ goto exit;
+ }
+ if (pui_size == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = BKUP_RET_ERRPARAM;
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_SIZE;
+ BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name));
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), pui_size, sizeof(uint32_t));
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataRdByNumID(uint32_t num_id, uint32_t ui_offset, void *pv_buf, uint32_t ui_size) {
+ int32_t ret = BKUP_RET_NORMAL;
+ bkup_protocol_header_t hdr;
+
+ if (pv_buf == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = BKUP_RET_ERRPARAM;
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_READ_NUM;
+ hdr.num_id = num_id;
+ hdr.offset = ui_offset;
+ hdr.size = ui_size;
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), pv_buf, ui_size);
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataSzByNumID(uint32_t num_id, uint32_t *pui_size) {
+ int32_t ret;
+ bkup_protocol_header_t hdr;
+
+ if (pui_size == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Buf is NULL");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = BKUP_RET_ERRPARAM;
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_SIZE_NUM;
+ hdr.num_id = num_id;
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), pui_size, sizeof(uint32_t));
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataChk(PCSTR tag_id) {
+ int32_t ret;
+ bkup_protocol_header_t hdr;
+
+ if ((ret = BkupApiCheckTagid(tag_id)) != BKUP_RET_NORMAL) {
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_CHECK;
+ BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name));
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), NULL, 0);
+
+exit:
+ return ret;
+}
+
+int32_t Backup_DataDel(PCSTR tag_id) {
+ int32_t ret;
+ bkup_protocol_header_t hdr;
+
+ ret = BkupApiCheckTagid(tag_id);
+ if (ret != BKUP_RET_NORMAL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "tag_id is invalid");
+ goto exit;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.command = BKUP_CMD_DELETE;
+ BkupStrlcpy(hdr.item_name, tag_id, sizeof(hdr.item_name));
+
+ ret = BkupApiCall(&hdr, sizeof(hdr), NULL, 0);
+
+exit:
+ return ret;
+}
diff --git a/nsframework/backup_manager/config/Makefile b/nsframework/backup_manager/config/Makefile
new file mode 100644
index 00000000..b307a660
--- /dev/null
+++ b/nsframework/backup_manager/config/Makefile
@@ -0,0 +1,42 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+XML_PATH := ./conf/backup
+RNG_FILE := backup.rng
+ALL_XML := ALL_.xml
+ID_HEADER := ns_backup_id.h
+BACKUP_XML := backup*.xml
+
+######### headers to be installed(*.h) #############
+INST_HEADERS := $(ID_HEADER)
+
+######### make rule #############
+all: $(ID_HEADER)
+
+$(ID_HEADER): $(XML_PATH)/$(ALL_XML)
+ @set -e; \
+ for xml_file in `find $(XML_PATH) -name \*.xml | grep -v $(ALL_XML)`; do \
+ xmllint --noout --relaxng $(RNG_FILE) $$xml_file; \
+ ./uniqcheck.pl $$xml_file; \
+ done
+ ./createhdr.pl $(XML_PATH)/$(ALL_XML) > $(ID_HEADER)
+
+CLEAN_FILES := $(ID_HEADER)
+
+install: $(XML_PATH)/$(BACKUP_XML)
+ install -m 0755 -d $(DESTDIR)/usr/agl/conf/BS/ns/backup_manager/rodata
+ install -m 0644 $(XML_PATH)/$(BACKUP_XML) $(DESTDIR)/usr/agl/conf/BS/ns/backup_manager/rodata/
+include ../../native_service.mk
diff --git a/nsframework/backup_manager/config/backup.rng b/nsframework/backup_manager/config/backup.rng
new file mode 100644
index 00000000..6c9822b3
--- /dev/null
+++ b/nsframework/backup_manager/config/backup.rng
@@ -0,0 +1,123 @@
+<element name="backup" xmlns="http://relaxng.org/ns/structure/1.0">
+ <zeroOrMore>
+ <element name="category" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <attribute name="name">
+ <data type="Name">
+ <param name="maxLength">64</param>
+ </data>
+ </attribute>
+ <choice>
+ <!-- NAND -->
+ <group>
+ <attribute name="nand">
+ <choice>
+ <value type="boolean">true</value>
+ </choice>
+ </attribute>
+ <optional>
+ <attribute name="cacheDram">
+ <data type="boolean"/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="backupDram">
+ <data type="boolean"/>
+ </attribute>
+ </optional>
+ <attribute name="sync">
+ <data type="boolean"/>
+ </attribute>
+ <optional>
+ <attribute name="backupCycle">
+ <data type="positiveInteger"/>
+ </attribute>
+ </optional>
+ <attribute name="encrypt">
+ <data type="boolean"/>
+ </attribute>
+ </group>
+ <!-- CacheDRAM -->
+ <group>
+ <attribute name="cacheDram">
+ <choice>
+ <value type="boolean">true</value>
+ </choice>
+ </attribute>
+ <optional>
+ <attribute name="nand">
+ <choice>
+ <value type="boolean">false</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="backupDram">
+ <choice>
+ <value type="boolean">false</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="sync">
+ <choice>
+ <value type="boolean">false</value>
+ </choice>
+ </attribute>
+ </optional>
+ <attribute name="encrypt">
+ <data type="boolean"/>
+ </attribute>
+ </group>
+ <!-- BackupDRAM -->
+ <group>
+ <attribute name="backupDram">
+ <choice>
+ <value type="boolean">true</value>
+ </choice>
+ </attribute>
+ <optional>
+ <attribute name="nand">
+ <choice>
+ <value type="boolean">false</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="cacheDram">
+ <choice>
+ <value type="boolean">false</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="sync">
+ <choice>
+ <value type="boolean">false</value>
+ </choice>
+ </attribute>
+ </optional>
+ <attribute name="encrypt">
+ <data type="boolean"/>
+ </attribute>
+ </group>
+ </choice>
+ <zeroOrMore>
+ <element name="item">
+ <attribute name="name">
+ <data type="Name">
+ <param name="maxLength">64</param>
+ </data>
+ </attribute>
+ <attribute name="id">
+ <data type="positiveInteger">
+ <param name="maxInclusive">32767</param>
+ </data>
+ </attribute>
+ <attribute name="size">
+ <data type="positiveInteger"/>
+ </attribute>
+ </element>
+ </zeroOrMore>
+ </element>
+ </zeroOrMore>
+</element>
diff --git a/nsframework/backup_manager/config/conf/backup/ALL_.xml b/nsframework/backup_manager/config/conf/backup/ALL_.xml
new file mode 100644
index 00000000..bb42b635
--- /dev/null
+++ b/nsframework/backup_manager/config/conf/backup/ALL_.xml
@@ -0,0 +1,1216 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<backup>
+ <category name="D_BK_CA_GID_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_GID_D" id="0001" size="1"/>
+ </category>
+ <category name="D_BK_CA_MPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MPT_D" id="0002" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LPT_D" id="0003" size="1"/>
+ </category>
+ <category name="D_BK_CA_LSDBKUP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LSDBKUP" id="0004" size="1"/>
+ </category>
+ <category name="D_BK_CA_GPSINFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_GPSINFO" id="0005" size="1"/>
+ </category>
+ <category name="D_BK_CA_MADTIME" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MADTIME" id="0006" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_TEC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_TEC" id="0007" size="1"/>
+ </category>
+ <category name="D_BK_CA_HDW_SCL" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HDW_SCL" id="0008" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_POS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_POS" id="0009" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GYRO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GYRO" id="0010" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_DIST" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_DIST" id="0011" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_HELP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_HELP" id="0012" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_TDST" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_TDST" id="0013" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_PSSR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_PSSR" id="0014" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GSRV" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GSRV" id="0015" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_TTBL" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_TTBL" id="0016" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_PLGN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_PLGN" id="0017" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_CAM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_CAM" id="0018" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_DIAG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_DIAG" id="0019" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_SLRN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_SLRN" id="0020" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_MCKH" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_MCKH" id="0021" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GSBK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GSBK" id="0022" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_RLRN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_RLRN" id="0023" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_PARK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_PARK" id="0024" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_SAPA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_SAPA" id="0025" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_TTJD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_TTJD" id="0026" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_UPLD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_UPLD" id="0027" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_TTKH" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_TTKH" id="0028" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_UPNR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_UPNR" id="0029" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_OFRD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_OFRD" id="0030" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_OSRS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_OSRS" id="0031" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_MCIN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_MCIN" id="0032" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCSM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCSM" id="0033" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCSR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCSR" id="0034" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS1" id="0035" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS2" id="0036" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS3" id="0037" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS4" id="0038" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS5" id="0039" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS6" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS6" id="0040" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS7" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS7" id="0041" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_LCS8" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_LCS8" id="0042" size="1"/>
+ </category>
+ <category name="D_BK_CA_MNT_BK1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MNT_BK1" id="0043" size="1"/>
+ </category>
+ <category name="D_BK_CA_MNT_BK2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MNT_BK2" id="0044" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLCM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLCM" id="0045" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLCR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLCR" id="0046" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC1" id="0047" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC2" id="0048" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC3" id="0049" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC4" id="0050" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC5" id="0051" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC6" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC6" id="0052" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC7" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC7" id="0053" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GLC8" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GLC8" id="0054" size="1"/>
+ </category>
+ <category name="D_BK_CA_GPSCNT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_GPSCNT" id="0055" size="1"/>
+ </category>
+ <category name="D_BK_CA_MYRT_MNG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MYRT_MNG" id="0056" size="1"/>
+ </category>
+ <category name="D_BK_CA_MYRT_RT1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MYRT_RT1" id="0057" size="1"/>
+ </category>
+ <category name="D_BK_CA_MYRT_RT2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MYRT_RT2" id="0058" size="1"/>
+ </category>
+ <category name="D_BK_CA_MYRT_RT3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MYRT_RT3" id="0059" size="1"/>
+ </category>
+ <category name="D_BK_CA_MYRT_RT4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MYRT_RT4" id="0060" size="1"/>
+ </category>
+ <category name="D_BK_CA_MYRT_RT5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MYRT_RT5" id="0061" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_NS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_NS1" id="0062" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_NS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_NS2" id="0063" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_NS3" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_HMI_NS3" id="0064" size="1"/>
+ </category>
+ <category name="D_BK_CA_AVD_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_AVD_D" id="0065" size="1"/>
+ </category>
+ <category name="D_BK_CA_GPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_GPT_D" id="0066" size="1"/>
+ </category>
+ <category name="D_BK_CA_RTINF_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_RTINF_D" id="0067" size="1"/>
+ </category>
+ <category name="D_BK_CA_RDT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_RDT_D" id="0068" size="1"/>
+ </category>
+ <category name="D_BK_CA_ETA_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_ETA_D" id="0069" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_GYTP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_GYTP" id="0070" size="1"/>
+ </category>
+ <category name="D_BK_CA_GID_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GID_F" id="0071" size="1"/>
+ </category>
+ <category name="D_BK_CA_MPT_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MPT_F" id="0072" size="1"/>
+ </category>
+ <category name="D_BK_CA_AVD_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_AVD_F" id="0073" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_LPT_F" id="0074" size="1"/>
+ </category>
+ <category name="D_BK_CA_VR_POI" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VR_POI" id="0075" size="1"/>
+ </category>
+ <category name="D_BK_CA_BKWNRO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_BKWNRO" id="0076" size="1"/>
+ </category>
+ <category name="D_BK_CA_MPTGRP_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MPTGRP_D" id="0077" size="1"/>
+ </category>
+ <category name="D_BK_CA_MPTGRP_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MPTGRP_F" id="0078" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_TFPMMC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_TFPMMC" id="0079" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_TFPDATA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_TFPDATA" id="0080" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_BCN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_BCN" id="0081" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_FM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_FM" id="0082" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_DSRC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_DSRC" id="0083" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_DRG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_DRG" id="0084" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_BRD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_BRD" id="0085" size="1"/>
+ </category>
+ <category name="D_BK_CA_MADMNG_RCVINFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MADMNG_RCVINFO" id="0086" size="1"/>
+ </category>
+ <category name="D_BK_CA_MAD_UPDATEINFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MAD_UPDATEINFO" id="0087" size="1"/>
+ </category>
+ <category name="D_BK_CA_NM_NWINF01" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NM_NWINF01" id="0088" size="1"/>
+ </category>
+ <category name="D_BK_CA_NM_NWINF02" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NM_NWINF02" id="0089" size="1"/>
+ </category>
+ <category name="D_BK_CA_ND2_SAPA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_ND2_SAPA" id="0090" size="1"/>
+ </category>
+ <category name="D_BK_CA_SMS_RVS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_SMS_RVS" id="0091" size="1"/>
+ </category>
+ <category name="D_BK_CA_SMS_VSC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_SMS_VSC" id="0092" size="1"/>
+ </category>
+ <category name="D_BK_CA_VCJ_CTL1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VCJ_CTL1" id="0093" size="1"/>
+ </category>
+ <category name="D_BK_CA_VCJ_MNT1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VCJ_MNT1" id="0094" size="1"/>
+ </category>
+ <category name="D_BK_CA_VCJ_CTL2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VCJ_CTL2" id="0095" size="1"/>
+ </category>
+ <category name="D_BK_CA_VCJ_MNT2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VCJ_MNT2" id="0096" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIC_SDAT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DIC_SDAT" id="0097" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIC_UDAT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DIC_UDAT" id="0098" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIC_MDAT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DIC_MDAT" id="0099" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPMNG_PB" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPMNG_PB" id="0100" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPMNG_UP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPMNG_UP" id="0101" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPMNG_CT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPMNG_CT" id="0102" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_EA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_EA" id="0103" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_ER" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_ER" id="0104" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_EBA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_EBA" id="0105" size="1"/>
+ </category>
+ <category name="D_BK_CA_LOC_EBD" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LOC_EBD" id="0106" size="1"/>
+ </category>
+ <category name="D_BK_CA_AWYMNG_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_AWYMNG_D" id="0107" size="1"/>
+ </category>
+ <category name="D_BK_CA_AWYDT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_AWYDT_D" id="0108" size="1"/>
+ </category>
+ <category name="D_BK_CA_AWYCD_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_AWYCD_D" id="0109" size="1"/>
+ </category>
+ <category name="D_BK_CA_PWMPT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PWMPT_D" id="0110" size="1"/>
+ </category>
+ <category name="D_BK_CA_GPOI_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_GPOI_D" id="0111" size="1"/>
+ </category>
+ <category name="D_BK_CA_LFM_REC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LFM_REC" id="0112" size="1"/>
+ </category>
+ <category name="D_BK_CA_LFM_RUN1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LFM_RUN1" id="0113" size="1"/>
+ </category>
+ <category name="D_BK_CA_LFM_RUN2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LFM_RUN2" id="0114" size="1"/>
+ </category>
+ <category name="D_BK_CA_LFM_INIT" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LFM_INIT" id="0115" size="1"/>
+ </category>
+ <category name="D_BK_CA_PWMPT_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_PWMPT_F" id="0116" size="1"/>
+ </category>
+ <category name="D_BK_CA_BDMPT_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BDMPT_F" id="0117" size="1"/>
+ </category>
+ <category name="D_BK_CA_GPOI_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GPOI_F" id="0118" size="1"/>
+ </category>
+ <category name="D_BK_CA_ECOLRNJP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_ECOLRNJP" id="0119" size="1"/>
+ </category>
+ <category name="D_BK_CA_RDTECOJP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_RDTECOJP" id="0120" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPH_CONF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPH_CONF" id="0121" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPH_ONDATA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPH_ONDATA" id="0122" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPH_CODATA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPH_CODATA" id="0123" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPFU_CND" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPFU_CND" id="0124" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPFU_COL" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPFU_COL" id="0125" size="1"/>
+ </category>
+ <category name="D_BK_CA_NPFU_STR" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_NPFU_STR" id="0126" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD67__ITS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID__CWORD67__ITS" id="0127" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_MS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_MS1" id="0128" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_MS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_MS2" id="0129" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_BTN" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_BTN" id="0134" size="1"/>
+ </category>
+ <category name="D_BK_CA_G_PER_CA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_G_PER_CA" id="0135" size="1"/>
+ </category>
+ <category name="D_BK_CA_G_BR_HIS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_G_BR_HIS" id="0136" size="1"/>
+ </category>
+ <category name="D_BK_CA_CAR_CDF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_CAR_CDF" id="0137" size="1"/>
+ </category>
+ <category name="D_BK_CA_ACC_CDF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_ACC_CDF" id="0138" size="1"/>
+ </category>
+ <category name="D_BK_CA_CEL_CDF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_CEL_CDF" id="0139" size="1"/>
+ </category>
+ <category name="D_BK_CA_CDF_ONS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_CDF_ONS" id="0140" size="1"/>
+ </category>
+ <category name="D_BK_CA_CON_CDF1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_CON_CDF1" id="0141" size="1"/>
+ </category>
+ <category name="D_BK_CA_CON_CDF2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_CON_CDF2" id="0142" size="1"/>
+ </category>
+ <category name="D_BK_CA_SPFC_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_SPFC_D" id="0143" size="1"/>
+ </category>
+ <category name="D_BK_CA_ECORT_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_ECORT_D" id="0144" size="1"/>
+ </category>
+ <category name="D_BK_CA_SPFC_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_SPFC_F" id="0145" size="1"/>
+ </category>
+ <category name="D_BK_CA_ECORT_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_ECORT_F" id="0146" size="1"/>
+ </category>
+ <category name="D_BK_CA_G_BM_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_G_BM_D" id="0149" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J09" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J09" id="0150" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J10" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J10" id="0151" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J11" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J11" id="0152" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J12" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J12" id="0153" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J13" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J13" id="0154" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J14" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J14" id="0155" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J15" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J15" id="0156" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J16" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J16" id="0157" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J17" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J17" id="0158" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J18" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J18" id="0159" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J19" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J19" id="0160" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J20" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J20" id="0161" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J21" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J21" id="0162" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J22" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J22" id="0163" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J23" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J23" id="0164" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J24" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J24" id="0165" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J25" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J25" id="0166" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J26" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J26" id="0167" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J27" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J27" id="0168" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J28" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J28" id="0169" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J29" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J29" id="0170" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J30" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J30" id="0171" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J31" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J31" id="0172" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J32" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J32" id="0173" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J33" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J33" id="0174" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J34" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J34" id="0175" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J35" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J35" id="0176" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J36" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J36" id="0177" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J37" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J37" id="0178" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J38" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J38" id="0179" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E01" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E01" id="0180" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E02" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E02" id="0181" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E03" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E03" id="0182" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E04" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E04" id="0183" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E05" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E05" id="0184" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E06" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E06" id="0185" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E07" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E07" id="0186" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E08" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E08" id="0187" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E09" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E09" id="0188" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E10" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E10" id="0189" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E11" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E11" id="0190" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E12" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E12" id="0191" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E13" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E13" id="0192" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E14" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E14" id="0193" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E15" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E15" id="0194" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E16" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E16" id="0195" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E17" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E17" id="0196" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E18" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E18" id="0197" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E19" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E19" id="0198" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E20" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E20" id="0199" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E21" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E21" id="0200" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E22" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E22" id="0201" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E23" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E23" id="0202" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E24" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E24" id="0203" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E25" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E25" id="0204" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E26" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E26" id="0205" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E27" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E27" id="0206" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E28" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E28" id="0207" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E29" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E29" id="0208" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E30" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E30" id="0209" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E31" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E31" id="0210" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E32" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E32" id="0211" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E33" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E33" id="0212" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E34" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E34" id="0213" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E35" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E35" id="0214" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E36" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E36" id="0215" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E37" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E37" id="0216" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_E38" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_E38" id="0217" size="1"/>
+ </category>
+ <category name="D_BK_CA_DAPL_ICN" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DAPL_ICN" id="0218" size="1"/>
+ </category>
+ <category name="D_BK_CA_MADMNG_MEMCLEAR" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MADMNG_MEMCLEAR" id="0219" size="1"/>
+ </category>
+ <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="1"/>
+ </category>
+ <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="1"/>
+ </category>
+ <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="1"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="1"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="1"/>
+ <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1"/>
+ <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1"/>
+ <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="1"/>
+ <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1"/>
+ <item name="D_BK_ID_MEDSRV_CDRIP_RESUME" id="0278" size="1"/>
+ <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="1"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="1"/>
+ <item name="D_BK_ID_REPROS_SERVICEFLG" id="0371" size="1"/>
+ <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_RESULT" id="0374" size="1"/>
+ <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="1"/>
+ <item name="D_BK_ID_REPROS_NA05OUT_RESULT" id="0379" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="1"/>
+ <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/>
+ <item name="D_BK_ID_REPROS_MAP_VER" id="0383" size="1"/>
+ <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="1"/>
+ <item name="D_BK_ID_REPROS_UPDATE_INFO" id="0386" size="1"/>
+ <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="1"/>
+ <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1"/>
+ <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="1"/>
+ <item name="D_BK_ID_REPROS_START_STATE_INFO" id="0403" size="1"/>
+ <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="1"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="1"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKB_N" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKB_N" id="0235" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKB_M" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKB_M" id="0236" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKB_G" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKB_G" id="0237" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKB_B" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKB_B" id="0238" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKB_T" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKB_T" id="0239" size="1"/>
+ </category>
+ <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="1"/>
+ <item name="D_BK_ID_CLOCK_STATE" id="0241" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_ASYNC" nand="true" cacheDram="true" sync="false" backupCycle="15" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_ASYNC_OFFSET" id="0243" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAG_UTILIZATION" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DIAG_UTILIZATION" id="0245" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_FIX_CNT" nand="true" cacheDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_FIX_CNT" id="0251" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TD_STS" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TD_STS" id="0252" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_ROLLOVER_CNT" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_ROLLOVER_CNT" id="0253" size="1"/>
+ </category>
+ <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_WLANM_INFO" id="0254" size="1"/>
+ </category>
+ <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="1"/>
+ </category>
+ <category name="D_BK_CA_EOM_CONTENTS_STATUS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_EOM_CONTENTS_STATUS" id="0256" size="1"/>
+ </category>
+ <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_GENERAL_STARTUPBGM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_GENERAL_STARTUPBGM" id="0261" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_MENU_UIC_TAB" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_INFS_MENU_UIC_TAB" id="0268" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_METERCOOP_MET" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_INFS_METERCOOP_MET" id="0270" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_UIC_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_UIC_GRP" id="0271" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_UIC_FILENAME" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_UIC_FILENAME" id="0272" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="1"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1"/>
+ <item name="D_BK_ID_MEDSRV_CDRIP_SETTING" id="0280" size="1"/>
+ <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="1"/>
+ </category>
+ <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="1"/>
+ </category>
+ <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="1"/>
+ </category>
+ <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="1"/>
+ </category>
+ <category name="D_BK_CA_G_INFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_G_INFO" id="0288" size="1"/>
+ </category>
+ <category name="D_BK_CA_G_BM_S" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_G_BM_S" id="0289" size="1"/>
+ </category>
+ <category name="D_BK_CA_F_BR_HIS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_F_BR_HIS" id="0290" size="1"/>
+ </category>
+ <category name="D_BK_CA_F_COOKIE" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_F_COOKIE" id="0291" size="1"/>
+ </category>
+ <category name="D_BK_CA_F_INFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_F_INFO" id="0292" size="1"/>
+ </category>
+ <category name="D_BK_CA_F_USE_INF" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_F_USE_INF" id="0293" size="1"/>
+ </category>
+ <category name="D_BK_CA_F_BM_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_F_BM_D" id="0294" size="1"/>
+ </category>
+ <category name="D_BK_CA_F_BM_S" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_F_BM_S" id="0295" size="1"/>
+ </category>
+ <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="1"/>
+ </category>
+ <category name="D_BK_CA_AUDIOSETTING_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_AUDIOSETTING_PARAMETER" id="0297" size="1"/>
+ </category>
+ <category name="D_BK_CA_CONNECTIVITY_LASTAPP" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CONNECTIVITY_LASTAPP" id="0298" size="1"/>
+ </category>
+ <category name="D_BK_CA_RADIOAPP_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RADIOAPP_PARAMETER" id="0299" size="1"/>
+ </category>
+ <category name="D_BK_CA_TOUCH" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_TOUCH_CONFIG" id="0300" size="1"/>
+ <item name="D_BK_ID_TOUCH_PARAMETER" id="0301" size="1"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_DCMFLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_DCMFLAG" id="0302" size="1"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_SRVFLAG" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_SRVFLAG" id="0303" size="1"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_ACCON_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_ACCON_CDF" id="0304" size="1"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_SRVFLAG_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_SRVFLAG_CDF" id="0305" size="1"/>
+ </category>
+ <category name="D_BK_CA_GRA_AMFMHD_CTRL" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LIST" id="0321" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LOGO" id="0322" size="1"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="1"/>
+ </category>
+ <category name="D_BK_CA_GRA_SDARS_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_STATION_LIST" id="0326" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_CATEGORY_LIST" id="0327" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_IMDB_URL_CHN_LOGO" id="0328" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_SMS_CFG" id="0365" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_RADIO_ID" id="0405" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_SUBSCRIPTION_STATUS" id="0439" size="1"/>
+ </category>
+ <category name="D_BK_CA_DAB_TUN" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_DAB_LM_ENS" id="0329" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_ENS_ORDER" id="0330" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_SRVC" id="0331" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_SRV_ORDER" id="0332" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_CMP" id="0333" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_COMP_ORDER" id="0334" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_HARD_LINK" id="0335" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_HARD_LINK_ORDER" id="0336" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_LINK_INFO" id="0337" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_LM_LINK_INFO_ORDER" id="0338" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_TPEG_LIST" id="0339" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_TPEG_LIST_ORDER" id="0340" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_OE_FREQ" id="0341" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_OE_FREQ_ORDER" id="0342" size="1"/>
+ <item name="D_BK_ID_NVM_DAB_OE_EID" id="0343" size="1"/>
+ <item name="D_BK_ID_NVM_DAB_OE_EID_ORDER" id="0344" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_BEST_FM_LINK" id="0440" size="1"/>
+ <item name="D_BK_ID_NVM_ID_DAB_ERROR_COUNT" id="0441" size="1"/>
+ </category>
+ <category name="D_BK_CA_DBG_POSTMORTEM" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_CPF_POSTMORTEM" id="0345" size="1"/>
+ </category>
+ <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="1"/>
+ </category>
+ <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="1"/>
+ </category>
+ <category name="D_BK_CA_PMG_CLK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PMG_CLK" id="0348" size="1"/>
+ </category>
+ <category name="D_BK_CA_PMG_CP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PMG_CP" id="0349" size="1"/>
+ </category>
+ <category name="D_BK_CA_PMG_LCTY" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PMG_LCTY" id="0350" size="1"/>
+ </category>
+ <category name="D_BK_CA_PMG_LPOS" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PMG_LPOS" id="0351" size="1"/>
+ </category>
+ <category name="D_BK_CA_PMG_SRCA" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PMG_SRCA" id="0352" size="1"/>
+ </category>
+ <category name="D_BK_CA_MPTMNG_D" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MPTMNG_D" id="0353" size="1"/>
+ </category>
+ <category name="D_BK_CA_MPTMNG_F" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MPTMNG_F" id="0354" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TEST_ROLLOVER_CNT" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TEST_ROLLOVER_CNT" id="0355" size="1"/>
+ </category>
+ <category name="D_BK_CA_PAYD_ODO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PAYD_ODO" id="0358" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WC_INFO" id="0362" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J01" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J01" id="0388" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J02" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J02" id="0389" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J03" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J03" id="0390" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J04" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J04" id="0391" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J05" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J05" id="0392" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J06" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J06" id="0393" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J07" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J07" id="0394" size="1"/>
+ </category>
+ <category name="D_BK_CA_SKN_J08" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_SKN_J08" id="0395" size="1"/>
+ </category>
+ <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="1"/>
+ </category>
+ <category name="D_BK_CA_MODBPFSG" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MODBPFSG" id="0397" size="1"/>
+ </category>
+ <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="1"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="1"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="1"/>
+ </category>
+ <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="1"/>
+ <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="1"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="1"/>
+ </category>
+ <category name="D_BK_CA_PCSECBK" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PCSECBK" id="0410" size="1"/>
+ </category>
+ <category name="D_BK_CA_HV_LRN_1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HV_LRN_1" id="0412" size="1"/>
+ </category>
+ <category name="D_BK_CA_HV_LRN_2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HV_LRN_2" id="0413" size="1"/>
+ </category>
+ <category name="D_BK_CA_HV_LRN_3" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HV_LRN_3" id="0414" size="1"/>
+ </category>
+ <category name="D_BK_CA_HV_LRN_4" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HV_LRN_4" id="0415" size="1"/>
+ </category>
+ <category name="D_BK_CA_HV_LRN_5" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HV_LRN_5" id="0416" size="1"/>
+ </category>
+ <category name="D_BK_CA_HV_HISORY" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HV_HISORY" id="0417" size="1"/>
+ </category>
+ <category name="D_BK_CA_REPROS_MAPUPDATE_PARAM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_MAPUPDATE_STATUS" id="0418" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__SYNC_GRP" id="0419" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_PNS1" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_PNS1" id="0421" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_PNS2" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_PNS2" id="0422" size="1"/>
+ </category>
+ <category name="D_BK_CA_HMI_USER" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_HMI_USER" id="0423" size="1"/>
+ </category>
+ <category name="D_BK_CA_PMG_SMAP" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_PMG_SMAP" id="0424" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT1_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LPT1_F" id="0425" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT2_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LPT2_F" id="0426" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT3_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LPT3_F" id="0427" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT4_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LPT4_F" id="0428" size="1"/>
+ </category>
+ <category name="D_BK_CA_LPT5_F" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_LPT5_F" id="0429" size="1"/>
+ </category>
+ <category name="D_BK_CA_MUDINFO" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_MUDINFO" id="0430" size="1"/>
+ </category>
+ <category name="D_BK_CA_CTRRTSRV" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_CTRRTSRV" id="0431" size="1"/>
+ </category>
+ <category name="D_BK_CA_VDU_MNG" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VDU_MNG" id="0432" size="1"/>
+ </category>
+ <category name="D_BK_CA_VDU_ICON" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_VDU_ICON" id="0433" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="1"/>
+ </category>
+ <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BT_PAIRING" id="0435" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_SET_TIME" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_SET_TIME" id="0436" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTSERVICE_WRITE_AT_SHUT_DOWN" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DTSERVICE_FORECAST" id="0221" size="1"/>
+ <item name="D_BK_ID_DTSERVICE_COORDINATE" id="0223" size="1"/>
+ <item name="D_BK_ID_DTSERVICE_AFLIST" id="0224" size="1"/>
+ <item name="D_BK_ID_DTSERVICE_DOPPLER" id="0225" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTSERVICE_WRITE_AT_IMMIEDIATELY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DTSERVICE_CITYDB" id="0220" size="1"/>
+ <item name="D_BK_ID_DTSERVICE_SETUP" id="0222" size="1"/>
+ <item name="D_BK_ID_DTSERVICE_WEATHER_HISTORY" id="0226" size="1"/>
+ </category>
+ <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="1"/>
+ <item name="D_BK_ID_TCS_WNN_LEARN_DICTIONARY" id="438" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_INFO" id="0442" size="1"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_FLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_FLAG" id="0443" size="1"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER1_LIST" id="0366" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER2_LIST" id="0367" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER3_LIST" id="0368" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER4_LIST" id="0369" size="1"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER5_LIST" id="0370" size="1"/>
+ </category>
+ <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="1"/>
+ </category>
+ <category name="D_BK_CA_HELP_DATA" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_HELP_DATA" id="0446" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="1"/>
+ </category>
+ <category name="D_BK_CA_NAVIPROXY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NAVIPROXY" id="0450" size="1"/>
+ </category>
+ <category name="D_BK_CA_AWBPROXY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_AWBPROXY" id="0451" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_CMRSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_CMRSRV_PARAMETER" id="0452" size="1"/>
+ </category>
+ <category name="D_BK_CA_DWR_DWRM" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DWR_DWRM" id="0453" size="1"/>
+ </category>
+ <category name="D_BK_CA_MUDINIT" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MUDINIT" id="0454" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD27__USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD27__SETTING" id="0457" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD27__SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD27__CONNECTION_MODE" id="0456" size="1"/>
+ </category>
+ <category name="D_BK_CA_DTI_ETCC" nand="true" backupDram="true" sync="false" backupCycle="30" encrypt="false">
+ <item name="D_BK_ID_DTI_ETCC" id="0458" size="1"/>
+ </category>
+ <category name="D_BK_CA_BT_MANAGEMENT" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BT_POWER" id="0459" size="1"/>
+ <item name="D_BK_ID_BT_PINCODE" id="0460" size="1"/>
+ <item name="D_BK_ID_BT_NAME" id="0461" size="1"/>
+ <item name="D_BK_ID_BT_DEFAULT_NAME" id="0462" size="1"/>
+ <item name="D_BK_ID_BT_ADDRESS" id="0463" size="1"/>
+ <item name="D_BK_ID_BT_AUTOMATIC_CONNECTION" id="0464" size="1"/>
+ <item name="D_BK_ID_BT_PREFERRED_SETTING" id="0465" size="1"/>
+ <item name="D_BK_ID_BT_PHONE_DISPLAY_STATE" id="0466" size="1"/>
+ <item name="D_BK_ID_BT_AUDIOPLAYER_DISPLAY_STATE" id="0467" size="1"/>
+ <item name="D_BK_ID_BT_PROFILE_AVAILABLE" id="0468" size="1"/>
+ <item name="D_BK_ID_BT_DCM_PHONE" id="0469" size="1"/>
+ </category>
+ <category name="D_BK_CA_EOMSERVICE_LOCALSTORAGE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_EOMSERVICE_LOCALSTORAGE" id="0470" size="1"/>
+ </category>
+ <category name="D_BK_CA_DOA_EXISTENCE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DOA_EXISTENCE" id="0471" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="1"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__ASYNC_GRP" id="0475" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__1TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__1TRIP_ASYNC_GRP" id="0476" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD28_AUTO_SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD28_AUTO_CONNECTION_MODE" id="0477" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD28_AUTO_USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD28_AUTO_SETTING" id="0478" size="1"/>
+ </category>
+ <category name="D_BK_CA__CWORD24_" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD24_" id="0479" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_ASYNC_GRP" id="0480" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_SYNC" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_SYNC_GRP" id="0481" size="1"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__TRIP_ASYNC_GRP" id="0482" size="1"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_METER_TYPE" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_METER_TYPE" id="0483" size="1"/>
+ </category>
+ <category name="D_BK_CA_ADAS_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ADAS_SETTING" id="0484" size="1"/>
+ </category>
+</backup>
diff --git a/nsframework/backup_manager/config/conf/backup/backup_AREA1_L.xml b/nsframework/backup_manager/config/conf/backup/backup_AREA1_L.xml
new file mode 100644
index 00000000..a9d523a8
--- /dev/null
+++ b/nsframework/backup_manager/config/conf/backup/backup_AREA1_L.xml
@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<backup>
+ <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="16"/>
+ </category>
+ <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="16"/>
+ </category>
+ <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="512"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="4096"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="53280"/>
+ <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1024"/>
+ <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="10656"/>
+ <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_CDRIP_RESUME" id="0278" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="256"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="32"/>
+ <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="4"/>
+ <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="6"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="4"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="2048"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="8192"/>
+ <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/>
+ <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="169192"/>
+ <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="8"/>
+ <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1024"/>
+ <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="4"/>
+ <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="4"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="4096"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="33792"/>
+ </category>
+ <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="16"/>
+ <item name="D_BK_ID_CLOCK_STATE" id="0241" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="256"/>
+ </category>
+ <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="2560"/>
+ </category>
+ <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="4096"/>
+ </category>
+ <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="256"/>
+ </category>
+ <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_WLANM_INFO" id="0254" size="1024"/>
+ </category>
+ <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="20480"/>
+ </category>
+ <category name="D_BK_CA_EOM_CONTENTS_STATUS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_EOM_CONTENTS_STATUS" id="0256" size="4"/>
+ </category>
+ <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="4096"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="512"/>
+ </category>
+ <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="64"/>
+ </category>
+ <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="384"/>
+ </category>
+ <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="128"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_CDRIP_SETTING" id="0280" size="32"/>
+ <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="32"/>
+ </category>
+ <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="400"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="9011200"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="32"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="16"/>
+ </category>
+ <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="16"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="9068544"/>
+ </category>
+ <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="200"/>
+ </category>
+ <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="8"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="2048"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="64"/>
+ </category>
+ <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="240"/>
+ </category>
+ <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="4"/>
+ </category>
+ <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="2804"/>
+ </category>
+ <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WC_INFO" id="0362" size="400"/>
+ </category>
+ <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="712"/>
+ </category>
+ <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="512"/>
+ </category>
+ <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="26384"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="16"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="8"/>
+ </category>
+ <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="4"/>
+ <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="4"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="128"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__SYNC_GRP" id="0419" size="19433"/>
+ </category>
+ <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="10240"/>
+ </category>
+ <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BT_PAIRING" id="0435" size="102400"/>
+ </category>
+ <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="2097152"/>
+ <item name="D_BK_ID_TCS_WNN_LEARN_DICTIONARY" id="438" size="1176004"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_FLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_FLAG" id="0443" size="4"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="22896"/>
+ </category>
+ <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="256"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="128"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="4"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="64"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="8"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="4"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__ASYNC_GRP" id="0475" size="19334"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__1TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__1TRIP_ASYNC_GRP" id="0476" size="99"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_ASYNC_GRP" id="0480" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_SYNC" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_SYNC_GRP" id="0481" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__TRIP_ASYNC_GRP" id="0482" size="19334"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_METER_TYPE" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_METER_TYPE" id="0483" size="1"/>
+ </category>
+ <category name="D_BK_CA_ADAS_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ADAS_SETTING" id="0484" size="512"/>
+ </category>
+</backup>
diff --git a/nsframework/backup_manager/config/conf/backup/backup_AREA1_TE.xml b/nsframework/backup_manager/config/conf/backup/backup_AREA1_TE.xml
new file mode 100644
index 00000000..a9d523a8
--- /dev/null
+++ b/nsframework/backup_manager/config/conf/backup/backup_AREA1_TE.xml
@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<backup>
+ <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="16"/>
+ </category>
+ <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="16"/>
+ </category>
+ <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="512"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="4096"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="53280"/>
+ <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1024"/>
+ <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="10656"/>
+ <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_CDRIP_RESUME" id="0278" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="256"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="32"/>
+ <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="4"/>
+ <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="6"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="4"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="2048"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="8192"/>
+ <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/>
+ <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="169192"/>
+ <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="8"/>
+ <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1024"/>
+ <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="4"/>
+ <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="4"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="4096"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="33792"/>
+ </category>
+ <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="16"/>
+ <item name="D_BK_ID_CLOCK_STATE" id="0241" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="256"/>
+ </category>
+ <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="2560"/>
+ </category>
+ <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="4096"/>
+ </category>
+ <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="256"/>
+ </category>
+ <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_WLANM_INFO" id="0254" size="1024"/>
+ </category>
+ <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="20480"/>
+ </category>
+ <category name="D_BK_CA_EOM_CONTENTS_STATUS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_EOM_CONTENTS_STATUS" id="0256" size="4"/>
+ </category>
+ <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="4096"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="512"/>
+ </category>
+ <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="64"/>
+ </category>
+ <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="384"/>
+ </category>
+ <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="128"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_CDRIP_SETTING" id="0280" size="32"/>
+ <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="32"/>
+ </category>
+ <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="400"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="9011200"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="32"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="16"/>
+ </category>
+ <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="16"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="9068544"/>
+ </category>
+ <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="200"/>
+ </category>
+ <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="8"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="2048"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="64"/>
+ </category>
+ <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="240"/>
+ </category>
+ <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="4"/>
+ </category>
+ <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="2804"/>
+ </category>
+ <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WC_INFO" id="0362" size="400"/>
+ </category>
+ <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="712"/>
+ </category>
+ <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="512"/>
+ </category>
+ <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="26384"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="16"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="8"/>
+ </category>
+ <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="4"/>
+ <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="4"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="128"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__SYNC_GRP" id="0419" size="19433"/>
+ </category>
+ <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="10240"/>
+ </category>
+ <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BT_PAIRING" id="0435" size="102400"/>
+ </category>
+ <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="2097152"/>
+ <item name="D_BK_ID_TCS_WNN_LEARN_DICTIONARY" id="438" size="1176004"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_FLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_FLAG" id="0443" size="4"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="22896"/>
+ </category>
+ <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="256"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="128"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="4"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="64"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="8"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="4"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__ASYNC_GRP" id="0475" size="19334"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__1TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__1TRIP_ASYNC_GRP" id="0476" size="99"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_ASYNC_GRP" id="0480" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_SYNC" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_SYNC_GRP" id="0481" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV__CWORD66__TRIP_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="60" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV__CWORD66__TRIP_ASYNC_GRP" id="0482" size="19334"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_METER_TYPE" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_METER_TYPE" id="0483" size="1"/>
+ </category>
+ <category name="D_BK_CA_ADAS_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ADAS_SETTING" id="0484" size="512"/>
+ </category>
+</backup>
diff --git a/nsframework/backup_manager/config/conf/backup/backup_AREA2_T.xml b/nsframework/backup_manager/config/conf/backup/backup_AREA2_T.xml
new file mode 100644
index 00000000..ec028eae
--- /dev/null
+++ b/nsframework/backup_manager/config/conf/backup/backup_AREA2_T.xml
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<backup>
+ <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="16"/>
+ </category>
+ <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="16"/>
+ </category>
+ <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="512"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="4096"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="53280"/>
+ <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1024"/>
+ <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="10656"/>
+ <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="256"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="32"/>
+ <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="4"/>
+ <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="6"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="4"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="2048"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="8192"/>
+ <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/>
+ <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="169192"/>
+ <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="8"/>
+ <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1024"/>
+ <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="4"/>
+ <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="4"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="4096"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="33792"/>
+ </category>
+ <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="16"/>
+ <item name="D_BK_ID_CLOCK_STATE" id="0241" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="256"/>
+ </category>
+ <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="2560"/>
+ </category>
+ <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="4096"/>
+ </category>
+ <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="256"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_FIX_CNT" nand="true" cacheDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_FIX_CNT" id="0251" size="16"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_ROLLOVER_CNT" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_ROLLOVER_CNT" id="0253" size="32"/>
+ </category>
+ <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_WLANM_INFO" id="0254" size="1024"/>
+ </category>
+ <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="20480"/>
+ </category>
+ <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="4096"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="512"/>
+ </category>
+ <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="64"/>
+ </category>
+ <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="384"/>
+ </category>
+ <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="128"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="32"/>
+ </category>
+ <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="400"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="9011200"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="32"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="16"/>
+ </category>
+ <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="16"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="9068544"/>
+ </category>
+ <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="200"/>
+ </category>
+ <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="8"/>
+ </category>
+ <category name="D_BK_CA_TOUCH" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_TOUCH_CONFIG" id="0300" size="32"/>
+ <item name="D_BK_ID_TOUCH_PARAMETER" id="0301" size="4"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_DCMFLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_DCMFLAG" id="0302" size="8"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_SRVFLAG" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_SRVFLAG" id="0303" size="2048"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_ACCON_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_ACCON_CDF" id="0304" size="2048"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_SRVFLAG_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_SRVFLAG_CDF" id="0305" size="2048"/>
+ </category>
+ <category name="D_BK_CA_GRA_AMFMHD_CTRL" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LIST" id="0321" size="13168"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="2048"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="64"/>
+ </category>
+ <category name="D_BK_CA_GRA_SDARS_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_STATION_LIST" id="0326" size="45056"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_CATEGORY_LIST" id="0327" size="7168"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_SMS_CFG" id="0365" size="65536"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_RADIO_ID" id="0405" size="16"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_SUBSCRIPTION_STATUS" id="0439" size="8"/>
+ </category>
+ <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="240"/>
+ </category>
+ <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="4"/>
+ </category>
+ <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="2804"/>
+ </category>
+ <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WC_INFO" id="0362" size="400"/>
+ </category>
+ <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="712"/>
+ </category>
+ <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="512"/>
+ </category>
+ <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="26384"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="16"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="8"/>
+ </category>
+ <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="4"/>
+ <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="4"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="128"/>
+ </category>
+ <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="10240"/>
+ </category>
+ <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BT_PAIRING" id="0435" size="102400"/>
+ </category>
+ <category name="D_BK_CA_DTSERVICE_WRITE_AT_SHUT_DOWN" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DTSERVICE_FORECAST" id="0221" size="153600"/>
+ <item name="D_BK_ID_DTSERVICE_COORDINATE" id="0223" size="128"/>
+ <item name="D_BK_ID_DTSERVICE_AFLIST" id="0224" size="1024"/>
+ <item name="D_BK_ID_DTSERVICE_DOPPLER" id="0225" size="73728"/>
+ </category>
+ <category name="D_BK_CA_DTSERVICE_WRITE_AT_IMMIEDIATELY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DTSERVICE_CITYDB" id="0220" size="113664"/>
+ <item name="D_BK_ID_DTSERVICE_SETUP" id="0222" size="64"/>
+ <item name="D_BK_ID_DTSERVICE_WEATHER_HISTORY" id="0226" size="1024"/>
+ </category>
+ <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="2097152"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_INFO" id="0442" size="8"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_FLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_FLAG" id="0443" size="4"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="22896"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER1_LIST" id="0366" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER2_LIST" id="0367" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER3_LIST" id="0368" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER4_LIST" id="0369" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER5_LIST" id="0370" size="10240"/>
+ </category>
+ <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="256"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="128"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD27__USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD27__SETTING" id="0457" size="1024"/>
+ </category>
+ <category name="D_BK_CA__CWORD27__SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD27__CONNECTION_MODE" id="0456" size="1024"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="64"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="8"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="4"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_ASYNC_GRP" id="0480" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_SYNC" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_SYNC_GRP" id="0481" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_METER_TYPE" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_METER_TYPE" id="0483" size="1"/>
+ </category>
+ <category name="D_BK_CA_ADAS_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ADAS_SETTING" id="0484" size="512"/>
+ </category>
+</backup>
diff --git a/nsframework/backup_manager/config/conf/backup/backup_AREA2_TE.xml b/nsframework/backup_manager/config/conf/backup/backup_AREA2_TE.xml
new file mode 100644
index 00000000..f80637cc
--- /dev/null
+++ b/nsframework/backup_manager/config/conf/backup/backup_AREA2_TE.xml
@@ -0,0 +1,289 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<backup>
+ <category name="D_BK_CA_VEHICLE_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_STABLE_DATA" id="0227" size="16"/>
+ </category>
+ <category name="D_BK_CA_VEHICLE_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VEHICLE_DRAMBKUP_DATA" id="0228" size="16"/>
+ </category>
+ <category name="D_BK_CA_DUMMYREAD_OFFSET" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DUMMYREAD_OFFSET" id="0229" size="512"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_PARAMETER" id="0230" size="4096"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_RESUME" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_MMCOM_RESUME" id="0231" size="53280"/>
+ <item name="D_BK_ID_MEDSRV_ITGP_RESUME" id="0274" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_DISC_RESUME" id="0275" size="1024"/>
+ <item name="D_BK_ID_MEDSRV__CWORD57__RESUME" id="0276" size="10656"/>
+ <item name="D_BK_ID_MEDSRV_BTA_RESUME" id="0277" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_SDVCOM_RESUME" id="0444" size="256"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEPARAM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEPARAM" id="0232" size="32"/>
+ <item name="D_BK_ID_REPROS_AUTO_UPDATE_CHECK" id="0372" size="1"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLID" id="0373" size="4"/>
+ <item name="D_BK_ID_REPROS_RESUME_TIME" id="0375" size="6"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_PCGVER" id="0376" size="4"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMING" id="0377" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_TIMEOUT" id="0378" size="2"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_DLURL" id="0380" size="2048"/>
+ <item name="D_BK_ID_REPROS_NA03OUT_UPDATE_INFO" id="0381" size="8192"/>
+ <item name="D_BK_ID_REPROS_CENTERCOMM_STATE" id="0382" size="1"/>
+ <item name="D_BK_ID_REPROS_NA07_HISTORY_INFO" id="0385" size="169192"/>
+ <item name="D_BK_ID_REPROS_NA05_DOWNLOAD_SIZE" id="0387" size="8"/>
+ <item name="D_BK_ID_REPROS_FILE_PATH_INFO" id="0399" size="1024"/>
+ <item name="D_BK_ID_REPROS_UPDATE_FILE_EXIST" id="0401" size="4"/>
+ <item name="D_BK_ID_REPROS_CHECKFORUPDATE_TIME" id="0404" size="4"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEHISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEHISTORY" id="0233" size="4096"/>
+ </category>
+ <category name="D_BK_CA_REPROS_UPDATEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_REPROS_UPDATEINFO" id="0234" size="33792"/>
+ </category>
+ <category name="D_BK_CA_CLOCK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_CLOCK_OFFSET" id="0240" size="16"/>
+ <item name="D_BK_ID_CLOCK_STATE" id="0241" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_SYNC_OFFSET" id="0242" size="256"/>
+ </category>
+ <category name="D_BK_CA_DIAG_INFORMATION" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAG_INFORMATION" id="0244" size="2560"/>
+ </category>
+ <category name="D_BK_CA_VS_VSDSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_VSDSRV_PARAMETER" id="0246" size="4096"/>
+ </category>
+ <category name="D_BK_CA_VS_ACNSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_ACNSRV_PARAMETER" id="0247" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_ASYNC_GRP" id="0248" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_SYNC" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VS_FUCSRV_SYNC_GRP" id="0249" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_PARAMETER" id="0250" size="256"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_FIX_CNT" nand="true" cacheDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_FIX_CNT" id="0251" size="16"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_ROLLOVER_CNT" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_ROLLOVER_CNT" id="0253" size="32"/>
+ </category>
+ <category name="D_BK_CA_WLANM_INFO" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_WLANM_INFO" id="0254" size="1024"/>
+ </category>
+ <category name="D_BK_CA_BTSTK_LINKKEY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BTSTK_LINKKEY" id="0255" size="20480"/>
+ </category>
+ <category name="D_BK_CA_UPDSERVICE_PARAMETER" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_UPDSERVICE_PARAMETER" id="0257" size="4096"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_RCV" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_RCV" id="0259" size="1"/>
+ </category>
+ <category name="D_BK_CA_INFS_GENERAL_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_GENERAL_GRP" id="0260" size="512"/>
+ </category>
+ <category name="D_BK_CA_INFS_CLOCK_GRP" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_INFS_CLOCK_GRP" id="0262" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_HOME_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_HOME_GRP" id="0263" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_GRP" id="0264" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_VOL" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_VOL" id="0265" size="64"/>
+ </category>
+ <category name="D_BK_CA_INFS_MENU_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_MENU_GRP" id="0266" size="384"/>
+ </category>
+ <category name="D_BK_CA_INFS_METERCOOP_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_METERCOOP_GRP" id="0269" size="128"/>
+ </category>
+ <category name="D_BK_CA_INFS_SMARTAGENT_GRP" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_SMARTAGENT_GRP" id="0273" size="128"/>
+ </category>
+ <category name="D_BK_CA_MEDSRV_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MEDSRV_DISC_SETTING" id="0279" size="1024"/>
+ <item name="D_BK_ID_MEDSRV_COM_SETTING" id="420" size="32"/>
+ </category>
+ <category name="D_BK_CA_GNDB_UPDATE_HISTORY" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_GNDB_UPDATE_HISTORY" id="0281" size="400"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MEM" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_MEM" id="0282" size="9011200"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_EXTINFO" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_EXTINFO" id="0283" size="32"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_TRIPCNT" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_TRIPCNT" id="0284" size="16"/>
+ </category>
+ <category name="D_BK_CA_PFDREC_FUNC" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_PFDREC_FUNC" id="0285" size="16"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_WORK_BUF" nand="false" backupDram="true" sync="false" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_WORK_BUF" id="0286" size="9068544"/>
+ </category>
+ <category name="D_BK_CA_AS__CWORD76_VOLUME" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_AS__CWORD76_VOLUME" id="0287" size="200"/>
+ </category>
+ <category name="D_BK_CA_KEYBOARD_PARAMETER" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_KEYBOARD_PARAMETER" id="0296" size="8"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_DCMFLAG" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_DCMFLAG" id="0302" size="8"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_SRVFLAG" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_SRVFLAG" id="0303" size="2048"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_ACCON_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_ACCON_CDF" id="0304" size="2048"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_SRVFLAG_CDF" nand="true" cacheDram="true" sync="false" backupCycle="60" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_SRVFLAG_CDF" id="0305" size="2048"/>
+ </category>
+ <category name="D_BK_CA_GRA_AMFMHD_CTRL" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_AMFMHD_STATION_LIST" id="0321" size="13168"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_LSM_DATA" id="0323" size="2048"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_SC_CONFIG_PARAMS" id="0324" size="64"/>
+ </category>
+ <category name="D_BK_CA_GRA_SDARS_CTRL" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_STATION_LIST" id="0326" size="45056"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_CATEGORY_LIST" id="0327" size="7168"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_SMS_CFG" id="0365" size="65536"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_RADIO_ID" id="0405" size="16"/>
+ <item name="D_BK_ID_NVM_ID_GRA_SDARS_SUBSCRIPTION_STATUS" id="0439" size="8"/>
+ </category>
+ <category name="D_BK_CA_DBG_FILTER_SET" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_DBG_FILTER_SET" id="0346" size="240"/>
+ </category>
+ <category name="D_BK_CA_DCM_CNCT_EN" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DCM_CNCT_EN" id="0347" size="4"/>
+ </category>
+ <category name="D_BK_CA_RS_RSDDS_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_RSDDS_STATS" id="0359" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_UPDATE_DB_STATS" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_UPDATE_DB_STATS" id="0360" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_WNG_HISTORY_LIST" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WNG_HISTORY_LIST" id="0361" size="2804"/>
+ </category>
+ <category name="D_BK_CA_RS_WC_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_WC_INFO" id="0362" size="400"/>
+ </category>
+ <category name="D_BK_CA_RS_VIDCM_DEPLOYMENT_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_RS_VIDCM_DEPLOYMENT_INFO" id="0363" size="1"/>
+ </category>
+ <category name="D_BK_CA_RS_DEALER_INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_RS_DEALER_INFO" id="0384" size="712"/>
+ </category>
+ <category name="D_BK_CA_MODEMANAGER_LASTMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_MODEMANAGER_LASTMODE" id="0396" size="512"/>
+ </category>
+ <category name="D_BK_CA_ASS_PARAMETER" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ASS_PARAMETER" id="0406" size="26384"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_N" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_N" id="0407" size="16"/>
+ </category>
+ <category name="D_BK_CA_DPSSERVICE_ASPECTSET_D" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DPSSERVICE_ASPECTSET_D" id="0408" size="8"/>
+ </category>
+ <category name="D_BK_CA_VR_SYNC_NAND" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_VR_INPUT_AUDIO_DUMP" id="0258" size="4"/>
+ <item name="D_BK_ID_VR_PVR_FLAG" id="0364" size="4"/>
+ </category>
+ <category name="D_BK_CA_CUSERVICE_MANAGEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CUSERVICE_MANAGEINFO" id="0409" size="128"/>
+ </category>
+ <category name="D_BK_CA_DIAG_DEVICEINFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAG_DEVICEINFO" id="0434" size="10240"/>
+ </category>
+ <category name="D_BK_CA_BT_PAIRING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_BT_PAIRING" id="0435" size="102400"/>
+ </category>
+ <category name="D_BK_CA_DTSERVICE_WRITE_AT_SHUT_DOWN" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DTSERVICE_FORECAST" id="0221" size="153600"/>
+ <item name="D_BK_ID_DTSERVICE_COORDINATE" id="0223" size="128"/>
+ <item name="D_BK_ID_DTSERVICE_AFLIST" id="0224" size="1024"/>
+ <item name="D_BK_ID_DTSERVICE_DOPPLER" id="0225" size="73728"/>
+ </category>
+ <category name="D_BK_CA_DTSERVICE_WRITE_AT_IMMIEDIATELY" nand="true" cacheDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DTSERVICE_CITYDB" id="0220" size="113664"/>
+ <item name="D_BK_ID_DTSERVICE_SETUP" id="0222" size="64"/>
+ <item name="D_BK_ID_DTSERVICE_WEATHER_HISTORY" id="0226" size="1024"/>
+ </category>
+ <category name="D_BK_CA_TCS_LEARN_DICTIONARY" nand="true" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_TCS_LEARN_DICTIONARY" id="437" size="2097152"/>
+ </category>
+ <category name="D_BK_CA_POS_GPS_TIME_SET_INFO" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_POS_GPS_TIME_SET_INFO" id="0442" size="8"/>
+ </category>
+ <category name="D_BK_CA_GRA_MSTR_CTRL_IMM" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_LIST" id="0325" size="22896"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER1_LIST" id="0366" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER2_LIST" id="0367" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER3_LIST" id="0368" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER4_LIST" id="0369" size="10240"/>
+ <item name="D_BK_ID_NVM_ID_GRA_MSTR_PRESET_USER5_LIST" id="0370" size="10240"/>
+ </category>
+ <category name="D_BK_CA_CON_CWORD57__INFO" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_CON_CWORD57__INFO" id="0445" size="256"/>
+ </category>
+ <category name="D_BK_CA__CWORD76__INFO_DRAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD76__INFO_DRAM_OFFSET" id="0447" size="256"/>
+ </category>
+ <category name="D_BK_CA_VS_METSRV_PARAMETER" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VS_METSRV_PARAMETER" id="0448" size="128"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_MASK" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_MASK" id="0449" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD27__USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD27__SETTING" id="0457" size="1024"/>
+ </category>
+ <category name="D_BK_CA__CWORD27__SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD27__CONNECTION_MODE" id="0456" size="1024"/>
+ </category>
+ <category name="D_BK_CA_INFS_VOICE_INTERRUPT_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_INFS_VOICE_INTERRUPT_SETTING" id="0472" size="64"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_ODOMETER" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_DIAGCODE_ODOMETER" id="0473" size="8"/>
+ </category>
+ <category name="D_BK_CA_DIAGCODE_DIAGMODE" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_DIAGCODE_DIAGMODE" id="0474" size="4"/>
+ </category>
+ <category name="D_BK_CA__CWORD28_AUTO_SHARED_RAM" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID__CWORD28_AUTO_CONNECTION_MODE" id="0477" size="1024"/>
+ </category>
+ <category name="D_BK_CA__CWORD28_AUTO_USER_DATA" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD28_AUTO_SETTING" id="0478" size="1024"/>
+ </category>
+ <category name="D_BK_CA__CWORD24_" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID__CWORD24_" id="0479" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_ASYNC" nand="true" backupDram="true" sync="false" backupCycle="15" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_ASYNC_GRP" id="0480" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VS_FUCSRV_HISTORY_SYNC" nand="true" backupDram="true" sync="true" encrypt="true">
+ <item name="D_BK_ID_VS_FUCSRV_HISTORY_SYNC_GRP" id="0481" size="1024"/>
+ </category>
+ <category name="D_BK_CA_VINFOSRV_METER_TYPE" nand="false" backupDram="true" sync="false" encrypt="false">
+ <item name="D_BK_ID_VINFOSRV_METER_TYPE" id="0483" size="1"/>
+ </category>
+ <category name="D_BK_CA_ADAS_SETTING" nand="true" backupDram="true" sync="true" encrypt="false">
+ <item name="D_BK_ID_ADAS_SETTING" id="0484" size="512"/>
+ </category>
+</backup>
diff --git a/nsframework/backup_manager/config/createhdr.pl b/nsframework/backup_manager/config/createhdr.pl
new file mode 100755
index 00000000..c282f7b9
--- /dev/null
+++ b/nsframework/backup_manager/config/createhdr.pl
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+sub getlist($$)
+{
+ my $xmlfile = shift(@_);
+ my $xpath = shift(@_);
+
+ $xmlfile =~ s/([\[\]\*\(\)])/\\$1/g;
+
+ open(my $rs, "xmllint --xpath \"$xpath\" $xmlfile |") or die "Cannot open $xmlfile:$!";
+ my $result = join('', <$rs>);
+ close $rs;
+ $result =~ s/^ +//;
+ my @result_array = split(/ +/, $result);
+ return @result_array;
+}
+
+if ($#ARGV < 0 || !(-f $ARGV[0])) {
+ print "No such file or directory.\n";
+ exit 1;
+}
+
+my @item_array = getlist($ARGV[0], '//item/@name');
+
+print<<'HEADER';
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ns_backup_id.h
+ * @brief backup id define
+ */
+
+#ifndef BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_
+#define BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup backup_manager
+ * @ingroup native_service
+ * @{
+ */
+
+HEADER
+
+foreach my $item (@item_array) {
+ if ($item =~ /^name="(.+)"$/) {
+ printf("#define %s \"%s\"\n", $1, $1);
+ }
+ else {
+ print "Invalid input:$item\n";
+ exit 1;
+ }
+}
+
+print<<'FOOTER';
+
+/**@}*/ // end of backup_manager
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
+
+#endif // BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_
+FOOTER
+
+0;
diff --git a/nsframework/backup_manager/config/sample.xml b/nsframework/backup_manager/config/sample.xml
new file mode 100644
index 00000000..cbf6c7ae
--- /dev/null
+++ b/nsframework/backup_manager/config/sample.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<backup>
+ <category name="NandUnsync" nand="true" cacheDram="true" sync="false">
+ <item name="NandUnsync_001" id="1000" size="4491"/>
+ <item name="NandUnsync_002" id="1001" size="18752"/>
+ </category>
+ <category name="NandCycle" nand="true" cacheDram="true" sync="false" backupCycle="30">
+ <item name="NandCycle_001" id="2000" size="32231"/>
+ <item name="NandCycle_002" id="2001" size="8353"/>
+ </category>
+ <category name="NandSync" nand="true" cacheDram="false" sync="true">
+ <item name="NandSync_001" id="3000" size="25120"/>
+ <item name="NandSync_002" id="3001" size="18187"/>
+ </category>
+ <category name="BackupOnly" backupDram="true">
+ <item name="BackupOnly_001" id="4000" size="657"/>
+ <item name="BackupOnly_002" id="4001" size="526"/>
+ </category>
+ <category name="CacheOnly" cacheDram="true">
+ <item name="CacheOnly_001" id="5000" size="8694"/>
+ <item name="CacheOnly_002" id="5001" size="2051"/>
+ </category>
+</backup>
diff --git a/nsframework/backup_manager/config/uniqcheck.pl b/nsframework/backup_manager/config/uniqcheck.pl
new file mode 100755
index 00000000..1470d7c8
--- /dev/null
+++ b/nsframework/backup_manager/config/uniqcheck.pl
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my @checkxpath = ('//item/@name', '//item/@id', '//category/@name');
+
+sub uniqcheck($$)
+{
+ my $xpath = shift(@_);
+ my $list = shift(@_);
+ my %u = ();
+ foreach my $key (@{$list}) {
+ if (exists($u{$key})) {
+ print "detect duplicate $xpath $key\n";
+ exit 1;
+ }
+ $u{$key} = 1;
+ }
+}
+
+sub getlist($$)
+{
+ my $xmlfile = shift(@_);
+ my $xpath = shift(@_);
+
+ $xmlfile =~ s/([\[\]\*\(\)])/\\$1/g;
+
+ open(my $rs, "xmllint --xpath \"$xpath\" $xmlfile |") or die "Cannot open $xmlfile:$!";
+ my $result = join('', <$rs>);
+ close $rs;
+ $result =~ s/^ +//;
+ my @result_array = split(/ +/, $result);
+ return @result_array;
+}
+
+if ($#ARGV < 0 || !(-f $ARGV[0])) {
+ print "No such file or directory.\n";
+ exit 1;
+}
+
+foreach my $xpath (@checkxpath) {
+ my @result_array = getlist($ARGV[0], $xpath);
+ uniqcheck($xpath, \@result_array);
+}
+
+0;
diff --git a/nsframework/backup_manager/server/Makefile b/nsframework/backup_manager/server/Makefile
new file mode 100644
index 00000000..7f9fa395
--- /dev/null
+++ b/nsframework/backup_manager/server/Makefile
@@ -0,0 +1,67 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### programs to be installed #############
+INST_PROGS := NS_BackupMgr
+
+######### sources to be compiled #############
+NS_BackupMgr_SRCS := backupmanager_main.cpp \
+ bkup_process.cpp \
+ bkup_param.cpp \
+ bkup_crc32.cpp \
+ backupmanager_application.cpp
+
+######### search paths #############
+VPATH += ./src ./include ../client/include/$(COMPONENT_NAME)
+
+######### include paths #############
+CPPFLAGS += -I./include
+CPPFLAGS += -I../client/include
+CPPFLAGS += -I$(SDKTARGETSYSROOT)/usr/include/libxml2
+
+######### frameworkunifiedlog options #############
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+
+LDFLAGS += -Wl,--no-as-needed
+LDFLAGS += -Wl,--no-undefined
+
+######### libraries to be linked(dynamic)#############
+LDLIBS += -Wl,-Bdynamic \
+ -lSS_SystemIfUnified \
+ -lNS_FrameworkUnified \
+ -lxml2 \
+ -lrt \
+ -lnv_hal \
+ -lvp
+
+######### other unit specific options #############
+LINK_CXX=Y
+
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+install-data: install_data
+
+install_data:
+ install -d -m 755 $(DESTDIR)/nv/BS/ns/backup_manager/rwdata
+
+include ../../native_service.mk
diff --git a/nsframework/backup_manager/server/include/bkup_backupmanagerlog.h b/nsframework/backup_manager/server/include/bkup_backupmanagerlog.h
new file mode 100644
index 00000000..9df4a1cb
--- /dev/null
+++ b/nsframework/backup_manager/server/include/bkup_backupmanagerlog.h
@@ -0,0 +1,80 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_BACKUPMANAGERLOG_H_
+#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_BACKUPMANAGERLOG_H_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_APP ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define ZONE_ALSA ZONEMASK(103)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 "StateMachine Example"
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_TEXT_103 "Api"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_APP, ZONE_ERR, ZONE_WARN, ZONE_INFO, ZONE_ALSA
+#endif
+
+extern const CHAR kAppName[];
+
+#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_BACKUPMANAGERLOG_H_
diff --git a/nsframework/backup_manager/server/include/bkup_crc32.h b/nsframework/backup_manager/server/include/bkup_crc32.h
new file mode 100644
index 00000000..132ffdcc
--- /dev/null
+++ b/nsframework/backup_manager/server/include/bkup_crc32.h
@@ -0,0 +1,22 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_CRC32_H_
+#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_CRC32_H_
+
+uint32_t BkupCrc32(const void *data, size_t length);
+
+#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_CRC32_H_
diff --git a/nsframework/backup_manager/server/include/bkup_param.h b/nsframework/backup_manager/server/include/bkup_param.h
new file mode 100644
index 00000000..0a2dbb14
--- /dev/null
+++ b/nsframework/backup_manager/server/include/bkup_param.h
@@ -0,0 +1,39 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PARAM_H_
+#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PARAM_H_
+
+typedef struct {
+ int id;
+ int size;
+ void *opt;
+ bool nand;
+ bool cache_dram;
+ bool backup_dram;
+ bool sync;
+ bool encrypt;
+ int backup_cycle;
+ char category_name[64];
+} bkup_query_result_t;
+
+int BckupParamInit(void);
+
+int BkupParamGet(const char *item_name, bkup_query_result_t *result);
+int BkupParamGetNumid(uint32_t num_id, bkup_query_result_t *result, char *item_name, size_t item_name_size);
+void *BkupParamSetOpt(const char *item_name, void *opt);
+
+#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PARAM_H_
diff --git a/nsframework/backup_manager/server/include/bkup_process.h b/nsframework/backup_manager/server/include/bkup_process.h
new file mode 100644
index 00000000..72ac7e17
--- /dev/null
+++ b/nsframework/backup_manager/server/include/bkup_process.h
@@ -0,0 +1,31 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PROCESS_H_
+#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PROCESS_H_
+
+#include <native_service/frameworkunified_types.h>
+
+EFrameworkunifiedStatus BkupHandler(HANDLE h_app);
+
+EFrameworkunifiedStatus bkup_power_handler(HANDLE hApp);
+EFrameworkunifiedStatus BkupInitHandler(HANDLE h_app);
+EFrameworkunifiedStatus BkupTerminateHandler(HANDLE h_app);
+
+void *BkupNandThread(void *arg);
+void *BkupDelayThread(void *arg);
+
+#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_PROCESS_H_
diff --git a/nsframework/backup_manager/server/include/bkup_util.h b/nsframework/backup_manager/server/include/bkup_util.h
new file mode 100644
index 00000000..78494fac
--- /dev/null
+++ b/nsframework/backup_manager/server/include/bkup_util.h
@@ -0,0 +1,53 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BACKUP_MANAGER_SERVER_INCLUDE_BKUP_UTIL_H_
+#define BACKUP_MANAGER_SERVER_INCLUDE_BKUP_UTIL_H_
+
+#include <sys/mman.h>
+#include <ctime>
+#include <cstring>
+
+static inline size_t BkupStrlcpy(char *dst, const char *src, size_t siz) {
+ size_t ret = strlen(src);
+ if (dst == NULL) {
+ return -1;
+ }
+ if (src == NULL) {
+ return -1;
+ }
+ if (siz) { // LCOV_EXCL_BR_LINE 6:double check
+ size_t len = (ret >= siz) ? siz - 1 : ret; // LCOV_EXCL_BR_LINE 11:unexpected branch
+ memcpy(dst, src, len);
+ dst[len] = '\0';
+ }
+ return ret;
+}
+
+static inline char *BkupAnonMmap(size_t size) {
+ char *map = static_cast<char *>(mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0));
+ return map;
+}
+
+static inline uint64_t BkupTimerReal(void) {
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) != -1) { // LCOV_EXCL_BR_LINE 5:clock_gettime's error case.
+ return (uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
+ }
+ return -1;
+}
+
+#endif // BACKUP_MANAGER_SERVER_INCLUDE_BKUP_UTIL_H_
diff --git a/nsframework/backup_manager/server/src/backupmanager_application.cpp b/nsframework/backup_manager/server/src/backupmanager_application.cpp
new file mode 100644
index 00000000..c08e7256
--- /dev/null
+++ b/nsframework/backup_manager/server/src/backupmanager_application.cpp
@@ -0,0 +1,277 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <native_service/ns_backup.h>
+#include <agl_thread.h>
+#include <system_service/ss_system_if.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <native_service/frameworkunified_multithreading.h>
+
+#include <nv_hal.h>
+#include <signal.h>
+#include <cerrno>
+#include <cstdio>
+#include "bkup_api.h"
+#include "bkup_param.h"
+#include "bkup_backupmanagerlog.h"
+#include "bkup_process.h"
+
+pthread_t g_work_thread_id = 0;
+pthread_t g_delay_thread_id = 0;
+pthread_t g_nand_thread_id = 0;
+HANDLE g_msg_handle_thread = NULL;
+
+typedef void (* signal_handler)(int);
+
+void SignalHandlerFuncForMsgHandleThread(int signum) {
+ pthread_exit(0);
+}
+
+EFrameworkunifiedStatus MsgHandleThreadStart(HANDLE h_app) {
+ signal_handler p_signal = SignalHandlerFuncForMsgHandleThread;
+ signal(SIGUSR1, p_signal);
+
+ g_work_thread_id = pthread_self();
+
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = FrameworkunifiedAttachCallbackToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, BACKUP_CID, BkupHandler)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedAttachCallbacksToDispatcher e_status:%d\n", e_status);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ return e_status;
+}
+
+EFrameworkunifiedStatus MsgHandleThreadStop(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ return e_status;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ pthread_attr_t t_attr;
+ pthread_t t;
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = FrameworkunifiedRegisterServiceAvailabilityNotification(h_app, NTFY_BackupMgr_Availability)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedRegisterServiceAvailabilityNotification e_status:%d\n", e_status);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ if (pthread_attr_init(&t_attr) < 0) { // LCOV_EXCL_BR_LINE 5:pthread_attr_init's error case.
+ // LCOV_EXCL_START 5:pthread_attr_init's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_attr_init:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5:pthread_attr_init's error case.
+ }
+
+ // LCOV_EXCL_BR_START 5:pthread_attr_setinheritsched's error case.
+ if (pthread_attr_setinheritsched(&t_attr, PTHREAD_INHERIT_SCHED) < 0) {
+ // LCOV_EXCL_BR_STOP 5:pthread_attr_setinheritsched's error case.
+ // LCOV_EXCL_START 5:pthread_attr_setinheritsched's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_attr_setinheritsched:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5:pthread_attr_setinheritsched's error case.
+ }
+
+ if (pthread_create(&t, &t_attr, BkupNandThread, NULL) < 0) { // LCOV_EXCL_BR_LINE 5:pthread_create's error case.
+ // LCOV_EXCL_START 5:pthread_create's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_create:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5:pthread_create's error case.
+ }
+
+ if (pthread_create(&t, &t_attr, BkupDelayThread, NULL) < 0) { // LCOV_EXCL_BR_LINE 5:pthread_create's error case.
+ // LCOV_EXCL_START 5:pthread_create's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_create:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5:pthread_create's error case.
+ }
+
+ e_status = InitNv();
+ if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "InitNv e_status:%d", e_status);
+ exit(EXIT_FAILURE);
+ }
+
+ if (BckupParamInit() < 0) { // LCOV_EXCL_BR_LINE 5:C API's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ exit(EXIT_FAILURE); // LCOV_EXCL_LINE 5:C API's error case.
+ }
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = FrameworkunifiedAttachCallbackToDispatcher(h_app, FRAMEWORKUNIFIED_ANY_SOURCE, BACKUP_CID, BkupHandler)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedAttachCallbacksToDispatcher e_status:%d\n", e_status);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+
+ g_msg_handle_thread = FrameworkunifiedCreateChildThread(h_app, SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD, MsgHandleThreadStart, MsgHandleThreadStop); // LCOV_EXCL_BR_LINE 11:Unexpected branch // NOLINT (whitespace/line_length)
+ if (g_msg_handle_thread == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 4: NSFW error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Fail to create SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD");
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ } else {
+ if (eFrameworkunifiedStatusOK != (e_status = FrameworkunifiedStartChildThread(h_app, g_msg_handle_thread, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Fail to Start SERVICE_BACKUP_MANAGER_MSG_HANDLE_THREAD. Status:%#x", e_status); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
+ }
+ }
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = FrameworkunifiedSubscribeNotificationWithCallback(h_app,
+ NTFY_SSSystemMgrPowerOnOff,
+ bkup_power_handler)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSubscribeNotificationWithCallback eStatus:%d", e_status); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT (whitespace/line_length)
+ }
+
+ e_status = BkupInitHandler(h_app); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = FrameworkunifiedPublishServiceAvailability(h_app, TRUE)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedPublishServiceAvailability e_status:%d\n", e_status);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ return e_status;
+}
+
+// LCOV_EXCL_START 14 Resident process, not called by NSFW
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE h_app) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 14 Resident process, not called by NSFW
+
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE h_app) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = BkupTerminateHandler(h_app);
+
+ if (FrameworkunifiedPublishServiceAvailability(h_app, FALSE) != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 15:marco defined in "native_service/ns_logger_if.h"
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedPublishServiceAvailability fail\n");
+ // LCOV_EXCL_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if (eFrameworkunifiedStatusOK == (FrameworkunifiedStopChildThread(h_app, g_msg_handle_thread, 0, NULL))) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ FrameworkunifiedDestroyChildThread(h_app, g_msg_handle_thread);
+ g_msg_handle_thread = NULL;
+ }
+
+ int ret2 = pthread_kill(g_work_thread_id, SIGUSR1);
+ if (ESRCH == ret2) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "thread is already exit !");
+ } else if (EINVAL == ret2) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "signal is invalid !");
+ } else {
+ pthread_join(g_work_thread_id, NULL);
+ }
+
+ ret2 = pthread_kill(g_nand_thread_id, SIGUSR1);
+ if (ESRCH == ret2) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "thread is already exit !");
+ } else if (EINVAL == ret2) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "signal is invalid !");
+ } else {
+ pthread_join(g_nand_thread_id, NULL);
+ }
+
+ ret2 = pthread_kill(g_delay_thread_id, SIGUSR1);
+ if (ESRCH == ret2) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "thread is already exit !");
+ } else if (EINVAL == ret2) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "signal is invalid !");
+ } else {
+ pthread_join(g_delay_thread_id, NULL);
+ }
+
+ return e_status;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE h_app) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 7:debug code
+
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE h_app) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "called");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP 7:debug code
diff --git a/nsframework/backup_manager/server/src/backupmanager_main.cpp b/nsframework/backup_manager/server/src/backupmanager_main.cpp
new file mode 100644
index 00000000..f2255248
--- /dev/null
+++ b/nsframework/backup_manager/server/src/backupmanager_main.cpp
@@ -0,0 +1,61 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <native_service/ns_version_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <agl_thread.h>
+#include <system_service/ss_system_if.h>
+#include <cerrno>
+#include <cstdio>
+#include "bkup_backupmanagerlog.h"
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(0, 0, 0); // NOLINT(readability/nolint).
+
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT(readability/nolint) The varable is used by FW
+ FRAMEWORKUNIFIEDLOGOPTIONS,
+ {
+ ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31
+ },
+ FRAMEWORKUNIFIEDLOGZONES
+};
+
+int main(int argc, char *argv[]) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ FrameworkunifiedDefaultCallbackHandler cb_funcs;
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cb_funcs);
+ FRAMEWORKUNIFIED_SET_ZONES();
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ EFrameworkunifiedStatus e_status = FrameworkunifiedDispatcherWithArguments(MN_NS_BACKUPMGR, argc, argv, &cb_funcs);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ if (e_status != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedDispatcherWithArguments: %d", e_status);
+ return EXIT_FAILURE;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ return EXIT_SUCCESS;
+} // LCOV_EXCL_BR_LINE 10:The final line
diff --git a/nsframework/backup_manager/server/src/bkup_crc32.cpp b/nsframework/backup_manager/server/src/bkup_crc32.cpp
new file mode 100644
index 00000000..f1d8449c
--- /dev/null
+++ b/nsframework/backup_manager/server/src/bkup_crc32.cpp
@@ -0,0 +1,62 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cstdio>
+#include "bkup_crc32.h"
+#include "bkup_util.h"
+
+/*
+ * CRC-32C lookup table
+ *
+ * Polynomial 0x1EDC6F41
+ */
+static const uint32_t kBkupCrc32Lookup[4][256] = {
+ {
+ },
+ {
+ },
+ {
+ },
+ {
+ }
+};
+
+/**
+ * compute CRC-32C (Slicing-by-4)
+ */
+uint32_t BkupCrc32(const void *data, size_t length) {
+ uint32_t crc = 0xFFFFFFFF;
+ const uint32_t *current = (const uint32_t *)data;
+
+ if (data == NULL) {
+ return -1;
+ }
+ while (length >= 4) {
+ uint32_t one = *current++ ^ crc;
+ crc = kBkupCrc32Lookup[0][(one >> 24) & 0xFF] ^
+ kBkupCrc32Lookup[1][(one >> 16) & 0xFF] ^
+ kBkupCrc32Lookup[2][(one >> 8) & 0xFF] ^
+ kBkupCrc32Lookup[3][one & 0xFF];
+ length -= 4;
+ }
+
+ const uint8_t *current_char = (const uint8_t *)current;
+ while (length-- > 0) {
+ crc = (crc >> 8) ^ kBkupCrc32Lookup[0][(crc & 0xFF) ^ *current_char++];
+ }
+
+ return ~crc;
+}
diff --git a/nsframework/backup_manager/server/src/bkup_param.cpp b/nsframework/backup_manager/server/src/bkup_param.cpp
new file mode 100644
index 00000000..900779ba
--- /dev/null
+++ b/nsframework/backup_manager/server/src/bkup_param.cpp
@@ -0,0 +1,447 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <other_service/VP_GetEnv.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <libxml/xmlerror.h>
+#include <libxml/parser.h>
+#include <libxml/SAX2.h>
+#include <inttypes.h>
+#include <cerrno>
+#include <cstdio>
+#include <string>
+#include <map>
+#include <utility>
+#include "bkup_param.h"
+#include "bkup_backupmanagerlog.h"
+#include "bkup_util.h"
+
+#define BKUP_XML_PATH_MAX 100
+#define BKUP_XML_PATH "/usr/agl/conf/BS/ns/backup_manager/rodata/"
+#define BKUP_XML_PREFIX "backup_"
+#define BKUP_XML_EXTENSION ".xml"
+
+#define BKUP_AREA_1 "AREA1"
+#define BKUP_AREA_2 "AREA2"
+#define BKUP_BRAND_1 "BRAND1"
+#define BKUP_BRAND_2 "BRAND2"
+#define BKUP_GRADE_1 "GRADE1"
+#define BKUP_GRADE_2 "GRADE2"
+#define BKUP_DESTINATION_TYPE_AREA1_TE "AREA1_TE"
+#define BKUP_DESTINATION_TYPE_AREA1_L "AREA1_L"
+#define BKUP_DESTINATION_TYPE_AREA2_T "AREA2_T"
+#define BKUP_DESTINATION_TYPE_AREA2_TE "AREA2_TE"
+
+#define BKUP_DESTINATION_STR_MAX 10
+typedef struct {
+ char area[VP_MAX_LENGTH];
+ char brand[VP_MAX_LENGTH];
+ char grade[VP_MAX_LENGTH];
+ char destination[BKUP_DESTINATION_STR_MAX];
+} BkupDestinationTbl;
+
+const BkupDestinationTbl kDestinationTbl[] = {
+ // Destination:Area1
+ {BKUP_AREA_1, BKUP_BRAND_1, BKUP_GRADE_1, BKUP_DESTINATION_TYPE_AREA1_TE},
+ {BKUP_AREA_1, BKUP_BRAND_1, BKUP_GRADE_2, BKUP_DESTINATION_TYPE_AREA1_TE},
+ {BKUP_AREA_1, BKUP_BRAND_2, BKUP_GRADE_1, BKUP_DESTINATION_TYPE_AREA1_L},
+ {BKUP_AREA_1, BKUP_BRAND_2, BKUP_GRADE_2, BKUP_DESTINATION_TYPE_AREA1_L},
+ // Destination:Area2
+ {BKUP_AREA_2, BKUP_BRAND_1, BKUP_GRADE_1, BKUP_DESTINATION_TYPE_AREA2_TE},
+ {BKUP_AREA_2, BKUP_BRAND_1, BKUP_GRADE_2, BKUP_DESTINATION_TYPE_AREA2_TE},
+ {BKUP_AREA_2, BKUP_BRAND_2, BKUP_GRADE_1, BKUP_DESTINATION_TYPE_AREA2_T},
+ {BKUP_AREA_2, BKUP_BRAND_2, BKUP_GRADE_2, BKUP_DESTINATION_TYPE_AREA2_T},
+};
+
+typedef std::string Category;
+typedef struct {
+ bool nand;
+ bool cache_dram;
+ bool backup_dram;
+ bool sync;
+ bool encrypt;
+ int backup_cycle;
+} CategoryProperty;
+typedef std::map<Category, CategoryProperty> CategoryTable;
+
+typedef std::string Item;
+typedef struct {
+ int id;
+ int size;
+ void *opt;
+ Category category;
+} ItemProperty; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+typedef std::map<Item, ItemProperty> ItemTable;
+typedef std::map<int, Item> IdTable;
+
+typedef struct {
+ Category current;
+ CategoryTable category_table;
+ ItemTable item_table;
+ IdTable id_table;
+} BackupParams; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+static BackupParams *g_backup_params = NULL;
+
+static void StartElementNs(void *ctx, const xmlChar *localname,
+ const xmlChar *prefix, const xmlChar *uri,
+ int nb_namespaces, const xmlChar **namespaces,
+ int nb_attributes, int nb_defaulted,
+ const xmlChar **attributes) {
+ if (ctx == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "ctx is NULL");
+ return;
+ }
+ if (localname == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "localname is NULL");
+ return;
+ }
+ BackupParams *p_backup_params = static_cast<BackupParams *>(ctx);
+ std::string tag = (const char *)localname; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (tag.compare("backup") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // do nothing
+ } else if (tag.compare("category") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ CategoryProperty category_attr = {false, false, false, false, false, 0};
+ std::string category_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ for (int i = 0; i < nb_attributes; i++) {
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ std::string localname = (const char *)attributes[i * 5];
+ std::string value((const char *)attributes[i * 5 + 3], (const char *)attributes[i * 5 + 4]);
+ if (localname.compare("name") == 0) {
+ category_name = value;
+ } else if (localname.compare("nand") == 0) {
+ if (value.compare("true") == 0) {
+ category_attr.nand = true;
+ }
+ } else if (localname.compare("backupDram") == 0) {
+ if (value.compare("true") == 0) {
+ category_attr.backup_dram = true;
+ }
+ } else if (localname.compare("cacheDram") == 0) {
+ if (value.compare("true") == 0) {
+ category_attr.cache_dram = true;
+ }
+ } else if (localname.compare("sync") == 0) {
+ if (value.compare("true") == 0) {
+ category_attr.sync = true;
+ }
+ } else if (localname.compare("encrypt") == 0) {
+ if (value.compare("true") == 0) {
+ category_attr.encrypt = true;
+ }
+ } else if (localname.compare("backupCycle") == 0) {
+ category_attr.backup_cycle = atoi(value.c_str());
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Unknown attribute:%s", localname.c_str());
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ }
+
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ CategoryTable::iterator c_it = p_backup_params->category_table.find(category_name);
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ if (c_it != p_backup_params->category_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // LCOV_EXCL_START 200:Execute in server start period
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "duplicate category:%s", category_name.c_str());
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 200:Execute in server start period
+ }
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ p_backup_params->category_table.insert(std::make_pair(category_name, category_attr));
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ p_backup_params->current = category_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ } else if (tag.compare("item") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (p_backup_params->current.compare("") == 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // LCOV_EXCL_START 200:Execute in server start period
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Detect item before category");
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 200:Execute in server start period
+ }
+
+ ItemProperty item_property = {0, 0, NULL, p_backup_params->current}; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ std::string item_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ for (int i = 0; i < nb_attributes; i++) {
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ std::string localname = (const char *)attributes[i * 5];
+ std::string value((const char *)attributes[i * 5 + 3], (const char *)attributes[i * 5 + 4]);
+ if (localname.compare("name") == 0) {
+ item_name = value;
+ } else if (localname.compare("id") == 0) {
+ item_property.id = atoi(value.c_str());
+ } else if (localname.compare("size") == 0) {
+ item_property.size = atoi(value.c_str());
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Unknown attribute:%s", localname.c_str());
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ }
+
+ ItemTable::iterator i_it = p_backup_params->item_table.find(item_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (i_it != p_backup_params->item_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // LCOV_EXCL_START 200:Execute in server start period
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Duplicate item:%s", item_name.c_str());
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 200:Execute in server start period
+ }
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ p_backup_params->item_table.insert(std::make_pair(item_name, item_property));
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+
+ IdTable::iterator id_it = p_backup_params->id_table.find(item_property.id); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (id_it != p_backup_params->id_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // LCOV_EXCL_START 200:Execute in server start period
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Duplicate id:%d", item_property.id);
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 200:Execute in server start period
+ }
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ p_backup_params->id_table.insert(std::make_pair(item_property.id, item_name));
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Unknown tag:%s", localname);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+}
+
+static int BkupGetXmlPath(char* path) {
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6:Excluded as no NULL is currently passed
+ // LCOV_EXCL_START 6:Excluded as no NULL is currently passed
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "path is NULL");
+ return -1;
+ // LCOV_EXCL_STOP 6:Excluded as no NULL is currently passed
+ }
+ memset(path, 0, BKUP_XML_PATH_MAX);
+ char param_area[VP_MAX_LENGTH] = "";
+ VP_GetEnv(VP_VEHICLEPARAMETERLIBRARY_AREA, param_area);
+ char param_brand[VP_MAX_LENGTH] = "";
+ VP_GetEnv(VEHICLEPARAMETERLIBRARY_BRAND, param_brand);
+ char param_grade[VP_MAX_LENGTH] = "";
+ VP_GetEnv(VP_VEHICLEPARAMETERLIBRARY_GRADE, param_grade);
+
+ bool is_match = false;
+ for (uint16_t i = 0; i < _countof(kDestinationTbl); i++) {
+ size_t area_size = static_cast<size_t>(std::string(kDestinationTbl[i].area).size());
+ // Check vehicle parameter settings (For VP_VEHICLEPARAMETERLIBRALY_AREA only, check the area size of tbl to check the character strings common to each area)
+ if ((strncmp(param_area, kDestinationTbl[i].area, area_size) == 0) &&
+ (strncmp(param_brand, kDestinationTbl[i].brand, sizeof(param_area)) == 0) &&
+ (strncmp(param_grade, kDestinationTbl[i].grade, sizeof(param_area)) == 0)) {
+ is_match = true;
+ snprintf(path, BKUP_XML_PATH_MAX, "%s%s%s%s", BKUP_XML_PATH, BKUP_XML_PREFIX,
+ kDestinationTbl[i].destination, BKUP_XML_EXTENSION);
+ break;
+ }
+ }
+ if (is_match == false) {
+ // If the destination settings do not match, set the AREA2_T path as failsafe
+ snprintf(path, BKUP_XML_PATH_MAX, "%s%s%s%s", BKUP_XML_PATH, BKUP_XML_PREFIX,
+ BKUP_DESTINATION_TYPE_AREA2_T, BKUP_XML_EXTENSION);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Unexpected VP area[%s] brand[%s] grade[%s]",
+ param_area, param_brand, param_grade);
+ }
+ return 0;
+}
+
+int BckupParamInit(void) {
+ int ret = -1;
+ xmlParserCtxtPtr xmlctx;
+ xmlSAXHandler saxh;
+ xmlDocPtr doc;
+ int fd = -1;
+ struct stat sb;
+ char *map = NULL;
+ uint64_t start, end;
+
+ g_backup_params = new BackupParams; // LCOV_EXCL_BR_LINE 11:except,C++ operator
+
+ LIBXML_TEST_VERSION // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ xmlInitParser(); // NOLINT(readability/nolint) Defined in library of libxml
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+
+ memset(&saxh, 0, sizeof(saxh));
+ saxh.initialized = XML_SAX2_MAGIC;
+ saxh.startElementNs = StartElementNs;
+
+ xmlctx = xmlCreatePushParserCtxt(&saxh, g_backup_params, NULL, 0, NULL); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ char xml_path[BKUP_XML_PATH_MAX] = {0};
+ ret = BkupGetXmlPath(xml_path);
+ if (ret != 0) { // LCOV_EXCL_BR_LINE 6:Excluded because the return value does not cause an error
+ // LCOV_EXCL_START 6:Excluded because the return value does not cause an error
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "BkupGetXmlPath Error");
+ goto exit;
+ // LCOV_EXCL_STOP 6:Excluded because the return value does not cause an error
+ }
+
+ if ((fd = open(xml_path, O_RDONLY)) < 0) { // LCOV_EXCL_BR_LINE 5:open's error case.
+ // LCOV_EXCL_START 5:open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "open:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5:open's error case.
+ }
+ if (fstat(fd, &sb) < 0) { // LCOV_EXCL_BR_LINE 5:fstat's error case.
+ // LCOV_EXCL_START 5:fstat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "fstat:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5:fstat's error case.
+ }
+ map = reinterpret_cast<char *>(mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0));
+ if (map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+
+ start = BkupTimerReal();
+ if (xmlParseChunk(xmlctx, map, static_cast<int>(sb.st_size), 1)) { // LCOV_EXCL_BR_LINE 5:xmlParseChunk's error case.
+ // LCOV_EXCL_START 5:xmlParseChunk's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ xmlParserError(xmlctx, "xmlParseChunk");
+ goto exit;
+ // LCOV_EXCL_STOP 5:xmlParseChunk's error case.
+ }
+ end = BkupTimerReal();
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "spent:%" PRIu64 ".%06" PRIu64 "ms",
+ static_cast<uint64_t>((end - start) / 1000000),
+ static_cast<uint64_t>((end - start) % 1000000));
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+
+ doc = xmlctx->myDoc;
+ xmlFreeParserCtxt(xmlctx); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ xmlFreeDoc(doc); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ xmlCleanupParser(); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ ret = 0;
+
+exit:
+ if (fd >= 0) { // LCOV_EXCL_BR_LINE 5:open's error case.
+ if (close(fd) < 0) { // LCOV_EXCL_BR_LINE 5:close's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, "close:%s", strerror(errno)); // LCOV_EXCL_LINE 5:close's error case.
+ }
+ }
+ if (map) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ if (munmap(map, sb.st_size) < 0) { // LCOV_EXCL_BR_LINE 5:munmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, "munmap:%s", strerror(errno)); // LCOV_EXCL_LINE 5:munmap's error case.
+ }
+ }
+ return ret;
+}
+
+int BkupParamGet(const char *item_name, bkup_query_result_t *result) {
+ if (g_backup_params == NULL) { // LCOV_EXCL_BR_LINE 6:g_backup_params will not be NULL
+ // LCOV_EXCL_START 6:g_backup_params will not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Uninitialize call");
+ return -1;
+ // LCOV_EXCL_STOP 6:g_backup_params will not be NULL
+ }
+ if (result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "result is NULL");
+ return -1;
+ }
+ ItemTable::iterator item_it = g_backup_params->item_table.find(item_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (item_it == g_backup_params->item_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ return -1;
+ }
+
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ CategoryTable::iterator category_it = g_backup_params->category_table.find(item_it->second.category);
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ if (category_it == g_backup_params->category_table.end()) { // LCOV_EXCL_BR_LINE 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 6:double check
+ }
+
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ result->id = item_it->second.id;
+ result->size = item_it->second.size;
+ result->opt = item_it->second.opt;
+ result->nand = category_it->second.nand;
+ result->cache_dram = category_it->second.cache_dram;
+ result->backup_dram = category_it->second.backup_dram;
+ result->sync = category_it->second.sync;
+ result->encrypt = category_it->second.encrypt;
+ result->backup_cycle = category_it->second.backup_cycle;
+ BkupStrlcpy(result->category_name, item_it->second.category.c_str(), sizeof(result->category_name));
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+
+ return 0;
+}
+
+int BkupParamGetNumid(uint32_t num_id, bkup_query_result_t *result,
+ char *item_name, size_t item_name_size) {
+ if (g_backup_params == NULL) { // LCOV_EXCL_BR_LINE 6:g_backup_params will not be NULL
+ // LCOV_EXCL_START 6:g_backup_params will not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Uninitialize call");
+ return -1;
+ // LCOV_EXCL_STOP 6:g_backup_params will not be NULL
+ }
+
+ // LCOV_EXCL_BR_START 11:except,C++ STL
+ IdTable::iterator id_it = g_backup_params->id_table.find(static_cast<int>(num_id));
+ // LCOV_EXCL_BR_STOP 11:except,C++ STL
+ if (id_it == g_backup_params->id_table.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ return -1;
+ }
+ BkupStrlcpy(item_name, id_it->second.c_str(), item_name_size); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ return BkupParamGet(id_it->second.c_str(), result); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+}
+
+void *BkupParamSetOpt(const char *item_name, void *opt) {
+ if (g_backup_params == NULL) { // LCOV_EXCL_BR_LINE 6:g_backup_params will not be NULL
+ // LCOV_EXCL_START 6:g_backup_params will not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Uninitialize call");
+ return reinterpret_cast<void *>((-1));
+ // LCOV_EXCL_STOP 6:g_backup_params will not be NULL
+ }
+
+ ItemTable::iterator item_it = g_backup_params->item_table.find(item_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (item_it == g_backup_params->item_table.end()) { // LCOV_EXCL_BR_LINE 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return reinterpret_cast<void *>((-1)); // LCOV_EXCL_LINE 6:double check
+ }
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ return __sync_val_compare_and_swap(&item_it->second.opt, NULL, opt); // NOLINT(readability/nolint) Supplied by gcc
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+}
diff --git a/nsframework/backup_manager/server/src/bkup_process.cpp b/nsframework/backup_manager/server/src/bkup_process.cpp
new file mode 100644
index 00000000..f8032efd
--- /dev/null
+++ b/nsframework/backup_manager/server/src/bkup_process.cpp
@@ -0,0 +1,2497 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <inttypes.h>
+#include <mqueue.h>
+#include <agl_thread.h>
+#include <poll.h>
+#include <signal.h>
+#include <sys/epoll.h>
+#include <sys/eventfd.h>
+#include <sys/prctl.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/timerfd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_system_manager_if.h>
+#include <nv_hal.h>
+#include <aglpath.h>
+#include <cerrno>
+#include <cstdio>
+#include <map>
+#include <set>
+#include <string>
+#include <utility>
+#include "bkup_api.h"
+#include "bkup_backupmanagerlog.h"
+#include "bkup_param.h"
+#include "bkup_crc32.h"
+#include "bkup_util.h"
+
+#define BKUP_THREAD_NAND "NS_BkupNAND"
+#define BKUP_THREAD_DELAY "NS_BkupDelay"
+const char kBkupPrexixEncryption[] = "ENC_";
+const size_t kBkupPrexixEncryptionSize = 4;
+
+typedef void (* signal_handler)(int);
+extern void SignalHandlerFuncForMsgHandleThread(int signum);
+extern pthread_t g_delay_thread_id;
+extern pthread_t g_nand_thread_id;
+
+#define MAX_FD_EPOLL 8
+
+/**
+ * internal state
+ */
+typedef enum {
+ BKUP_STATE_INIT = 0,
+ BKUP_STATE_NORMAL,
+ BKUP_STATE_TERM,
+} bkup_state_t;
+static bkup_state_t g_bkup_internal_state = BKUP_STATE_INIT;
+
+
+/**
+ * delay thread command
+ */
+typedef enum {
+ BKUP_DELAY_CMD_TERM = 0,
+ BKUP_DELAY_CMD_PRE_ACCOFF,
+ BKUP_DELAY_CMD_REGIST,
+} bkup_delay_cmd_t;
+
+
+/**
+ * inter thread communication message
+ */
+typedef union {
+ struct {
+ char client_name[16];
+ uint32_t seq_id;
+ char *rcv_buf;
+ int rcv_size;
+ } nand;
+ struct {
+
+// bool terminate;
+ bkup_delay_cmd_t cmd;
+
+ int event_fd;
+ char item_name[64];
+ } delay;
+} bkup_itc_message_t;
+
+/**
+ * reference response function
+ */
+typedef struct {
+ int (*set_response)(void *, void *, int, EFrameworkunifiedStatus);
+ void *opt;
+} bkup_response_t;
+
+/**
+ * response MQ map(TLS)
+ */
+typedef std::map<std::string, HANDLE> g_bkup_response_mq_t;
+static __thread g_bkup_response_mq_t *g_bkup_response_mq;
+
+/**
+ * NAND thread itc MQ
+ */
+static mqd_t g_bkup_nand_mqd = -1;
+
+/**
+ * Delay thread itc MQ
+ */
+static mqd_t g_bkup_delay_mqd = -1;
+
+static int g_bkup_nand_tid;
+static int g_bkup_delay_tid;
+
+/**
+ * prototype declared
+ */
+static void BkupApilog(bkup_response_t *response, enum NvHalMedia current_media,
+ bkup_protocol_header_t *hdr,
+ bkup_query_result_t *query_result, char *buf,
+ uint32_t crc32, EFrameworkunifiedStatus ret_value);
+
+/**
+ * check status of file spicefied by path
+ */
+static int BkupCheckStatFromNv(enum NvHalMedia media, const char *path,
+ int check_size);
+
+/**
+ * rwlock unlock
+ */
+static inline void BkupRwlockUnlock(pthread_rwlock_t *rwlock, const char *path);
+
+/**
+ * rwlock read lock
+ */
+static inline void BkupRwlockRdlock(pthread_rwlock_t *rwlock, const char *path);
+
+/**
+ * rwlock write lock
+ */
+static inline void BkupRwlockWrlock(pthread_rwlock_t *rwlock, const char *path);
+
+/**\ingroup CheckNv
+ * \~english @par Brief
+ * Check the data stored on the storage device and check the data size.
+ * \~english @param [in] media
+ * enum NvHalMedia - Media type
+ * \~english @param [in] filename
+ * const char* - Concatenated string of "category name/item name"
+ * \~english @param [in] size
+ * uint32_t - Data size to be checked
+ * \~english @retval eFrameworkunifiedStatusOK OK
+ * \~english @retval eFrameworkunifiedStatusFileLoadError The file does not exist.
+ * \~english @retval eFrameworkunifiedStatusAccessError Check size failed
+ * \~english @retval eFrameworkunifiedStatusInvldParam Parameter error
+ * \~english @par Preconditons
+ * - none
+ * \~english @par Conditions of processing failure
+ * - If the media (media) specified in the parameter is smaller than NVHALMEDIA_CACHEDRAM or larger than NVHALMEDIA_NAND.\n
+ * [eFrameworkunifiedStatusInvldParam]
+ * - The identifier specified in the arguments is a NULL.[eFrameworkunifiedStatusInvldParam]
+ * - When the size specified in the arguments is 0.[eFrameworkunifiedStatusInvldParam]
+ * - Internal I/O handling errors (lstat).[eFrameworkunifiedStatusFileLoadError]
+ * - The size specified by the parameter does not correspond to the file size specified by the identifier.[eFrameworkunifiedStatusAccessError]
+ */
+static EFrameworkunifiedStatus CheckNv(enum NvHalMedia media, const char *filename, uint32_t size) {
+ uint32_t size_;
+ EFrameworkunifiedStatus ret;
+ ret = GetSizeNv(media, filename, &size_); // Get size
+ if (ret != eFrameworkunifiedStatusOK) { // If the GetSizeNv fails, the error is returned unchanged.
+ return ret;
+ }
+ if (size_ != size) { // Returns eFrameworkunifiedStatusAccessError if the sizes do not match.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "invalid size:%d\n", size);
+ return eFrameworkunifiedStatusAccessError;
+ }
+ return eFrameworkunifiedStatusOK; // Returns eFrameworkunifiedStatusOK if size matches
+}
+
+
+
+/**
+ * read file spicefied by id
+ *
+ * \retval 0 read success
+ * \retval -1 crc error
+ * \retval -2 read failed
+ * \retval -3 invalid param
+ */
+static int32_t BkupBufferReadFromNv(const enum NvHalMedia media, const char* path,
+ char *buf, size_t size, uint32_t *crc32) {
+ int32_t ret = 0;
+ EFrameworkunifiedStatus nv_ret = eFrameworkunifiedStatusFail;
+ const uint32_t size_all = static_cast<uint32_t>(size + sizeof(uint32_t));
+ void* buffer = MAP_FAILED;
+ uint8_t* read_buffer = NULL;
+ uint32_t calc_crc32, get_crc32;
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 6:double check
+ }
+
+ if (!buf) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "buf is NULL");
+ return -1;
+ }
+ if ((buffer = BkupAnonMmap(size_all)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:map failed");
+ ret = -1;
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+
+ read_buffer = reinterpret_cast<uint8_t*>(buffer);
+ nv_ret = ReadNv(media, path, read_buffer, size_all);
+ if (nv_ret == eFrameworkunifiedStatusOK) {
+ const void* const src_buffer = reinterpret_cast<void *>(read_buffer + size);
+ void* dest_buffer = reinterpret_cast<void *>(&get_crc32);
+ memcpy(dest_buffer, src_buffer, sizeof(uint32_t));
+ calc_crc32 = BkupCrc32(read_buffer, size); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (get_crc32 != calc_crc32) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "invalid crc(%s):%#x:%#x", path, get_crc32, calc_crc32);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = -1;
+ goto exit;
+ }
+ if (crc32 != NULL) {
+ *crc32 = get_crc32;
+ }
+ dest_buffer = reinterpret_cast<void *>(buf);
+ memcpy(dest_buffer, buffer, size);
+ } else if (nv_ret == eFrameworkunifiedStatusInvldParam) { // LCOV_EXCL_BR_LINE 6:double check
+ ret = -3;
+ } else {
+ ret = -2;
+ }
+exit:
+ if (buffer != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ munmap(buffer, size_all);
+ }
+
+ return ret;
+}
+
+/*
+ * buffer -> file write
+ */
+static int32_t BkupBufferWriteToNv(const enum NvHalMedia media, const char* path,
+ char *buf, size_t size, uint32_t *crc32) {
+ if (buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "buf is NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ int32_t ret = 0;
+ EFrameworkunifiedStatus nv_ret = eFrameworkunifiedStatusFail;
+ const uint32_t size_all = static_cast<uint32_t>(size + sizeof(uint32_t));
+ char *buffer = reinterpret_cast<char *>(MAP_FAILED);
+ uint32_t calc_crc32;
+
+ if ((buffer = BkupAnonMmap(size_all)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ ret = -1;
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+
+ calc_crc32 = BkupCrc32(buf, size); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (crc32) {
+ *crc32 = calc_crc32;
+ }
+
+ memcpy(buffer, buf, size);
+ memcpy(buffer + size, &calc_crc32, sizeof(uint32_t));
+
+ nv_ret = WriteNv(media, path, reinterpret_cast<uint8_t *>(buffer), size_all);
+ if (nv_ret != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "write to nv(%s):%s", path, strerror(ret));
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ ret = -1;
+ }
+
+exit:
+ if (buffer != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ munmap(buffer, size_all);
+ }
+
+ return ret;
+}
+
+/**
+ * inter media copy
+ */
+static int BkupMediaCopyFromNv(char *category_name, const char *item_name,
+ enum NvHalMedia src, enum NvHalMedia dst,
+ pthread_rwlock_t *src_rwlock,
+ pthread_rwlock_t *dst_rwlock) {
+ if (category_name == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "category_name is NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ if (item_name == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "item_name is NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ int ret = -1;
+ uint32_t crc32;
+ char id_path[FILENAME_MAX] = {0};
+ char *buffer = reinterpret_cast<char *>(MAP_FAILED);
+
+ bkup_query_result_t query_result;
+ BkupParamGet(item_name, &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ char prefix_name[kBkupPrexixEncryptionSize + 1] = {0};
+ if (query_result.encrypt != false) {
+ strncpy(prefix_name, kBkupPrexixEncryption, kBkupPrexixEncryptionSize);
+ }
+ snprintf(id_path, FILENAME_MAX, "%s/%s%s", category_name, prefix_name, item_name);
+
+ if ((buffer = BkupAnonMmap(query_result.size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:map failed");
+ ret = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+
+ BkupRwlockRdlock(src_rwlock, id_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if ((ret = BkupBufferReadFromNv(src, id_path, buffer, query_result.size,
+ &crc32)) >= 0) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupRwlockWrlock(dst_rwlock, id_path);
+ ret = BkupBufferWriteToNv(dst, id_path, buffer, query_result.size, &crc32);
+ BkupRwlockUnlock(dst_rwlock, id_path);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+ BkupRwlockUnlock(src_rwlock, id_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+exit:
+ if (buffer != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ munmap(buffer, query_result.size);
+ }
+
+ return ret;
+}
+
+/**
+ * make backup path
+ */
+static int BkupMakeBkupPathToNvId(const char *category_name,
+ const char *item_name, char **path_buf,
+ int buf_size) {
+ int ret = -1;
+ char prefix_name[kBkupPrexixEncryptionSize + 1] = {0};
+
+ if ((*path_buf = BkupAnonMmap(buf_size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+ bkup_query_result_t query_result;
+ if (BkupParamGet(item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function
+ // LCOV_EXCL_START 6:Excluded due to checking by upper-level function
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", item_name);
+ goto exit;
+ // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function
+ }
+ if (query_result.encrypt != false) {
+ strncpy(prefix_name, kBkupPrexixEncryption, kBkupPrexixEncryptionSize);
+ }
+ snprintf(*path_buf, static_cast<size_t>(buf_size), "%s/%s%s",
+ category_name, prefix_name, item_name);
+ ret = 0;
+
+exit:
+ return ret;
+}
+
+/**
+ * delete data
+ */
+static int BkupDeleteDataFromNv(const enum NvHalMedia media, const char* const path) {
+ int ret = 0;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function
+ // LCOV_EXCL_START 6:Excluded due to checking by upper-level function
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "path is NULL");
+ ret = -1;
+ return ret;
+ // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function
+ }
+ const size_t path_size = static_cast<size_t>(std::string(path).length());
+ if (path_size > FILENAME_MAX) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function
+ // LCOV_EXCL_START 6:Excluded due to checking by upper-level function
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "path size error");
+ ret = -1;
+ return ret;
+ // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function
+ }
+
+ uint32_t size = 0;
+ e_status = GetSizeNv(media, path, &size);
+ if (e_status == eFrameworkunifiedStatusFileLoadError) {
+ // If the file does not exist, deleet it successfully
+ return ret;
+ } else if (e_status != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "GetSizeNv e_status:%d\n", e_status);
+ ret = -1;
+ return ret;
+ } else {
+ // no proc
+ }
+
+ e_status = DeleteNv(media, path);
+ if (e_status != eFrameworkunifiedStatusOK) {
+ ret = -1;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "DeleteNv e_status:%d\n", e_status);
+ }
+ return ret;
+}
+
+/**
+ * get rwlock
+ */
+static pthread_rwlock_t *BkupGetRwlock(const char *item_name,
+ enum NvHalMedia media,
+ bkup_query_result_t *query_result) {
+ int ret;
+ pthread_rwlock_t *rwlock, *org_rwlock;
+ pthread_rwlockattr_t attr;
+
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "query_result is NULL");
+ return NULL;
+ }
+
+ if (media != NVHALMEDIA_BACKUPDRAM || query_result->backup_dram == false || query_result->nand == false) {
+ return NULL;
+ }
+ // backupDram && nand
+ if (query_result->opt != NULL) {
+ return reinterpret_cast<pthread_rwlock_t *>(query_result->opt);
+ }
+
+ if ((ret = pthread_rwlockattr_init(&attr)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlockattr_init's error case.
+ // LCOV_EXCL_START 5:pthread_rwlockattr_init's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlockattr_init:%s", strerror(ret));
+ return NULL;
+ // LCOV_EXCL_STOP 5:pthread_rwlockattr_init's error case.
+ }
+
+ // LCOV_EXCL_BR_START 5:pthread_rwlockattr_setkind_np's error case.
+ if ((ret = pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)) != 0) {
+ // LCOV_EXCL_BR_STOP 5:pthread_rwlockattr_setkind_np's error case.
+ // LCOV_EXCL_START 5:pthread_rwlockattr_setkind_np's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlockattr_setkind_np:%s", strerror(ret));
+ return NULL;
+ // LCOV_EXCL_STOP 5:pthread_rwlockattr_setkind_np's error case.
+ }
+
+ // LCOV_EXCL_BR_START 5:malloc's error case.
+ if ((rwlock = reinterpret_cast<pthread_rwlock_t *>(malloc(sizeof(pthread_rwlock_t)))) == NULL) {
+ // LCOV_EXCL_BR_STOP 5:malloc's error case.
+ // LCOV_EXCL_START 5:malloc's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "malloc failed");
+ return NULL;
+ // LCOV_EXCL_STOP 5:malloc's error case.
+ }
+
+ if ((ret = pthread_rwlock_init(rwlock, &attr)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_init's error case.
+ // LCOV_EXCL_START 5:pthread_rwlock_init's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_init:%s", strerror(ret));
+ free(rwlock);
+ return NULL;
+ // LCOV_EXCL_STOP 5:pthread_rwlock_init's error case.
+ }
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ org_rwlock = reinterpret_cast<pthread_rwlock_t *>(BkupParamSetOpt(item_name, rwlock));
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ if (org_rwlock == reinterpret_cast<void *>(-1)) { // LCOV_EXCL_BR_LINE 6:org_rwlock will not be -1
+ // LCOV_EXCL_START 6:org_rwlock will not be -1
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", item_name != 0 ? item_name : NULL);
+ free(rwlock);
+ return NULL;
+ // LCOV_EXCL_STOP 6:org_rwlock will not be -1
+ } else if (org_rwlock != NULL) { // LCOV_EXCL_BR_LINE 5:gcc builtin function's error case
+ // conflict
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ free(rwlock); // LCOV_EXCL_LINE 5:gcc builtin function's error case
+ rwlock = org_rwlock; // LCOV_EXCL_LINE 5:gcc builtin function's error case
+ }
+
+ query_result->opt = rwlock;
+ return rwlock;
+}
+
+/**
+ * rwlock read lock
+ */
+static inline void BkupRwlockRdlock(pthread_rwlock_t *rwlock, const char *path) {
+ if (rwlock) {
+ int ret;
+ if ((ret = pthread_rwlock_rdlock(rwlock)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_rdlock's error case.
+ // LCOV_EXCL_START 5:pthread_rwlock_rdlock's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_rdlock(%s):%s", path, strerror(ret));
+ // LCOV_EXCL_STOP 5:pthread_rwlock_rdlock's error case.
+ }
+ }
+}
+
+/**
+ * rwlock write lock
+ */
+static inline void BkupRwlockWrlock(pthread_rwlock_t *rwlock, const char *path) {
+ if (rwlock) {
+ int ret;
+ if ((ret = pthread_rwlock_wrlock(rwlock)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_wrlock's error case.
+ // LCOV_EXCL_START 5:pthread_rwlock_wrlock's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_wrlock(%s):%s", path, strerror(ret));
+ // LCOV_EXCL_STOP 5:pthread_rwlock_wrlock's error case.
+ }
+ }
+}
+
+/**
+ * rwlock unlock
+ */
+static inline void BkupRwlockUnlock(pthread_rwlock_t *rwlock, const char *path) {
+ if (rwlock) {
+ int ret;
+ if ((ret = pthread_rwlock_unlock(rwlock)) != 0) { // LCOV_EXCL_BR_LINE 5:pthread_rwlock_unlock's error case.
+ // LCOV_EXCL_START 5:pthread_rwlock_unlock's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "pthread_rwlock_unlock(%s):%s", path, strerror(ret));
+ // LCOV_EXCL_STOP 5:pthread_rwlock_unlock's error case.
+ }
+ }
+}
+
+/**
+ * inter thread communication MQ open
+ */
+static mqd_t BkupItcMqopen(const char *mq_name, int flags) {
+ struct mq_attr attr;
+
+ if (mq_name == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "mq_name is NULL");
+ return -1;
+ }
+
+ attr.mq_flags = 0;
+ attr.mq_maxmsg = 256;
+ attr.mq_msgsize = sizeof(bkup_itc_message_t);
+
+ return mq_open(mq_name, flags, 0660, &attr);
+}
+
+/**
+ * write & rename
+ */
+static int BkupWriteRename(const char *category_name, const char *item_name,
+ enum NvHalMedia media, char *buf, int size,
+ pthread_rwlock_t *rwlock) {
+ int ret = -1;
+ char *full_path = reinterpret_cast<char *>(MAP_FAILED);
+
+ // LCOV_EXCL_BR_START 5:mmap's error case.
+ if (BkupMakeBkupPathToNvId(category_name, item_name, &full_path, FILENAME_MAX) < 0) {
+ // LCOV_EXCL_BR_STOP 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+
+ BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (BkupBufferWriteToNv(media, full_path, buf, size, NULL) < 0) {
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ goto exit;
+ }
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ ret = size;
+
+exit:
+ if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ munmap(full_path, FILENAME_MAX);
+ }
+ return ret;
+}
+
+/**
+ * stat check
+ *
+ * \retval 0 file exists
+ * \retval -1 file not exists
+ * \retval -2 size error
+ */
+static int BkupCheckStatFromNv(enum NvHalMedia media, const char *path,
+ int check_size) {
+ uint32_t size = check_size + static_cast<uint32_t>(sizeof(uint32_t));
+ const EFrameworkunifiedStatus ret = CheckNv(media, path, size);
+
+ if (path == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "path is NULL");
+ return -1;
+ }
+
+ if (eFrameworkunifiedStatusOK == ret) {
+ return 0;
+ } else if (eFrameworkunifiedStatusAccessError == ret) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CheckNv e_status:%d", ret);
+ return -2;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "CheckNv e_status:%d", ret);
+ return -1;
+ }
+}
+
+/**
+ * media stat
+ */
+static int BkupMediaStat(const char *category_name, const char *item_name, enum NvHalMedia src, int size) {
+ int ret = -1;
+ char *path = reinterpret_cast<char *>(MAP_FAILED);
+
+ // LCOV_EXCL_BR_START 5:mmap's error case.
+ if (BkupMakeBkupPathToNvId(category_name, item_name, &path, FILENAME_MAX) < 0) {
+ // LCOV_EXCL_BR_STOP 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+ ret = BkupCheckStatFromNv(src, path, size); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+exit:
+ if (path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ munmap(path, FILENAME_MAX);
+ }
+ return ret;
+}
+
+/**
+ * stat check & read
+ *
+ * \retval 0 file exists
+ * \retval -1 file not exists
+ */
+static int BkupCheckStatRead(enum NvHalMedia current_media, const char *path,
+ char *buf, int check_size, uint32_t *crc32,
+ pthread_rwlock_t *rwlock) {
+ int ret;
+
+ if ((ret = BkupCheckStatFromNv(current_media, path, check_size)) < 0) {
+ return ret;
+ }
+
+ BkupRwlockRdlock(rwlock, path);
+
+ if (BkupBufferReadFromNv(current_media, path, buf, check_size, crc32) < 0) {
+ BkupRwlockUnlock(rwlock, path);
+ return -1;
+ }
+
+ BkupRwlockUnlock(rwlock, path);
+ return 0;
+}
+
+/**
+ * valid check
+ *
+ * \retval 0 file invalid & do nothing
+ * \retval -1 file invalid but create 0 fill file
+ * \retval 1 file valid
+ */
+static int BkupCheckRead(const char *path, enum NvHalMedia current_media,
+ bkup_protocol_command_t command, char *rcv_buf,
+ char *read_buf, uint32_t *crc32,
+ bkup_query_result_t *query_result,
+ pthread_rwlock_t *rwlock) {
+ int ret = -1;
+
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return 0;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return 0;
+ }
+
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+
+ if (BkupCheckStatRead(current_media, path, read_buf, query_result->size, crc32, rwlock) < 0) {
+ // file not exists
+ if (current_media == NVHALMEDIA_NAND || query_result->nand == false) {
+ goto exit;
+ } else {
+ if (command == BKUP_CMD_READ) {
+ /*
+ * Read
+ */
+ if (BkupCheckStatFromNv(NVHALMEDIA_NAND, path, query_result->size) == 0) {
+ // do nothing
+ ret = 0;
+ } else {
+ // take preference BackupDRAM or CacheDRAM
+ ret = -1;
+ }
+ } else {
+ /*
+ * Write/Fill
+ */
+ pthread_rwlock_t *nand_rwlock = BkupGetRwlock(hdr->item_name, NVHALMEDIA_NAND, query_result);
+ if (BkupCheckStatRead(NVHALMEDIA_NAND, path, read_buf, query_result->size, NULL, nand_rwlock) == 0) {
+ // write back cache
+ if (BkupWriteRename(query_result->category_name, hdr->item_name,
+ current_media, read_buf, query_result->size,
+ rwlock) >= 0) {
+ ret = 1;
+ } else {
+ // copy error, do nothing
+ ret = 0;
+ }
+ } else {
+ // take preference BackupDRAM or CacheDRAM
+ ret = -1;
+ }
+ }
+ goto exit;
+ }
+ }
+ ret = 1;
+exit:
+ return ret;
+}
+
+/**
+ * read command
+ */
+static int BkupCmdRead(bkup_response_t *response, enum NvHalMedia current_media,
+ char *rcv_buf, bkup_query_result_t *query_result) {
+ int ret = -1;
+ if (response == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "response is NULL");
+ return -1;
+ }
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return -1;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return -1;
+ }
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ char *full_path = reinterpret_cast<char *>(MAP_FAILED);
+ char *buf = reinterpret_cast<char *>(MAP_FAILED);
+ size_t buf_size = 0;
+ uint32_t crc32 = 0;
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+
+ // LCOV_EXCL_BR_START 5:mmap's error case.
+ if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) {
+ // LCOV_EXCL_BR_STOP 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ e_status = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+
+ if ((buf = BkupAnonMmap(query_result->size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:mmap's error case.
+ // LCOV_EXCL_START 5:mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ e_status = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5:mmap's error case.
+ }
+ buf_size = query_result->size;
+
+ ret = BkupCheckRead(full_path, current_media, hdr->command, rcv_buf, buf,
+ &crc32, query_result, rwlock); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (ret == -1) {
+ // return all 0
+ ret = hdr->size;
+ goto exit;
+ } else if (ret == 0) {
+ // do nothing
+ goto exit;
+ }
+
+ // success
+ ret = hdr->size;
+
+ // caching to memory
+ if (current_media == NVHALMEDIA_NAND) {
+ if (query_result->cache_dram) {
+ if (BkupMediaStat(query_result->category_name, hdr->item_name,
+ NVHALMEDIA_CACHEDRAM, query_result->size) < 0) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *dst_rwlock =
+ BkupGetRwlock(hdr->item_name, NVHALMEDIA_CACHEDRAM, query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ BkupWriteRename(query_result->category_name, hdr->item_name,
+ NVHALMEDIA_CACHEDRAM, buf, query_result->size,
+ dst_rwlock); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ }
+ if (query_result->backup_dram) {
+ if (BkupMediaStat(query_result->category_name, hdr->item_name,
+ NVHALMEDIA_BACKUPDRAM, query_result->size) < 0) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *dst_rwlock =
+ BkupGetRwlock(hdr->item_name, NVHALMEDIA_BACKUPDRAM, query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ BkupWriteRename(query_result->category_name, hdr->item_name,
+ NVHALMEDIA_BACKUPDRAM, buf, query_result->size,
+ dst_rwlock); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+ }
+ }
+
+exit:
+ if (ret != 0 && buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupApilog(response, current_media, hdr, query_result, buf, crc32, e_status);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((*response->set_response)(response->opt, buf + hdr->offset, hdr->size, e_status) < 0) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = -1; // LCOV_EXCL_LINE 4: NSFW error case
+ }
+ }
+
+ if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(full_path, FILENAME_MAX);
+ }
+ if (buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(buf, buf_size);
+ }
+ return ret;
+}
+
+/**
+ * write command
+ */
+static int BkupCmdWrite(bkup_response_t *response,
+ enum NvHalMedia current_media, char *rcv_buf,
+ bkup_query_result_t *query_result) {
+ int ret = -1;
+
+ if (response == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "response is NULL");
+ return -1;
+ }
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return -1;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return -1;
+ }
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ char *full_path = reinterpret_cast<char *>(MAP_FAILED);
+ char *buf = reinterpret_cast<char *>(MAP_FAILED);
+ char *header = NULL;
+ uint32_t crc32 = 0;
+ int buf_size = 0;
+
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ goto exit; // LCOV_EXCL_LINE 5: mmap's error case.
+ }
+
+ if (hdr->offset != 0 || hdr->size != (uint32_t)query_result->size) {
+ /*
+ * partial write
+ */
+ if ((buf = BkupAnonMmap(query_result->size)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ buf_size = query_result->size;
+
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupCheckRead(full_path, current_media, hdr->command, rcv_buf, buf, NULL, query_result, rwlock);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ if (ret == 0) {
+ // do nothing
+ goto exit;
+ }
+
+ header = buf;
+ memcpy(buf + hdr->offset, rcv_buf + sizeof(bkup_protocol_header_t), hdr->size);
+ BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (BkupBufferWriteToNv(current_media, full_path, buf, query_result->size, &crc32) < 0) {
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ goto exit;
+ }
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ } else {
+ /*
+ * whole write
+ */
+ header = rcv_buf + sizeof(bkup_protocol_header_t);
+ BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (BkupBufferWriteToNv(current_media, full_path,
+ rcv_buf + sizeof(bkup_protocol_header_t), hdr->size, &crc32) < 0) {
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ goto exit;
+ }
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ // success
+ ret = hdr->size;
+
+exit:
+ EFrameworkunifiedStatus e_status = ret < 0 ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ if (current_media == NVHALMEDIA_NAND) {
+ if (query_result->cache_dram == false && query_result->backup_dram == false) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupApilog(response, current_media, hdr, query_result, header, crc32, e_status);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+ if ((*response->set_response)(response->opt, NULL, 0, e_status) < 0) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = -1; // LCOV_EXCL_LINE 4: NSFW error case
+ }
+ } else {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupApilog(response, current_media, hdr, query_result, header, crc32, e_status);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+
+ if (buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(buf, buf_size);
+ }
+ if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(full_path, FILENAME_MAX);
+ }
+ return ret;
+}
+
+/**
+ * fill command
+ */
+static int BkupCmdFill(bkup_response_t *response, enum NvHalMedia current_media,
+ char *rcv_buf, bkup_query_result_t *query_result) {
+ int ret = -1;
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ char *full_path = reinterpret_cast<char *>(MAP_FAILED);
+ char *buf = reinterpret_cast<char *>(MAP_FAILED);
+ uint32_t crc32 = 0;
+
+ if (response == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "response is NULL");
+ return -1;
+ }
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return -1;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return -1;
+ }
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ goto exit; // LCOV_EXCL_LINE 5: mmap's error case.
+ }
+
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if ((buf = BkupAnonMmap(query_result->size)) == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+
+ if (hdr->offset != 0 || hdr->size != (uint32_t)query_result->size) {
+ /*
+ * partial fill
+ */
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupCheckRead(full_path, current_media, hdr->command, rcv_buf, buf, NULL, query_result, rwlock);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ if (ret == 0) {
+ // do nothing
+ goto exit;
+ }
+ }
+
+ memset(buf + hdr->offset, hdr->fill_patern, hdr->size);
+ BkupRwlockWrlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (BkupBufferWriteToNv(current_media, full_path, buf, query_result->size, &crc32) < 0) {
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ goto exit;
+ }
+ BkupRwlockUnlock(rwlock, full_path); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ // success
+ ret = hdr->size;
+
+exit:
+ EFrameworkunifiedStatus e_status = ret < 0 ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ if (current_media == NVHALMEDIA_NAND) {
+ if (query_result->cache_dram == false && query_result->backup_dram == false) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupApilog(response, current_media, hdr, query_result, buf, crc32, e_status);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+ if ((*response->set_response)(response->opt, NULL, 0, e_status) < 0) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = -1; // LCOV_EXCL_LINE 4: NSFW error case
+ }
+ } else {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupApilog(response, current_media, hdr, query_result, buf, crc32, e_status);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+
+ if (buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(buf, query_result->size);
+ }
+ if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(full_path, FILENAME_MAX);
+ }
+ return ret;
+}
+
+/**
+ * copy command
+ */
+static int BkupCmdCopy(bkup_response_t *response, enum NvHalMedia current_media,
+ char *rcv_buf, bkup_query_result_t *query_result) {
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return -1;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return -1;
+ }
+ bkup_protocol_header_t *hdr =
+ reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ pthread_rwlock_t *src_rwlock =
+ BkupGetRwlock(hdr->item_name, hdr->src_media, query_result);
+ pthread_rwlock_t *dst_rwlock =
+ BkupGetRwlock(hdr->item_name, current_media, query_result);
+
+ int ret = BkupMediaCopyFromNv(query_result->category_name, hdr->item_name, hdr->src_media, current_media, src_rwlock,
+ dst_rwlock);
+
+ if (response == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "response is NULL");
+ return -1;
+ }
+
+ if (current_media == NVHALMEDIA_NAND) {
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((*response->set_response)(response->opt, NULL, 0, ret < 0 ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK) < 0) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = -1; // LCOV_EXCL_LINE 4: NSFW error case
+ }
+ }
+ return ret;
+}
+
+/**
+ * check command
+ */
+static int BkupCmdCheck(bkup_response_t *response,
+ enum NvHalMedia current_media, char *rcv_buf,
+ bkup_query_result_t *query_result) {
+ int ret = 0;
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ char *full_path = reinterpret_cast<char *>(MAP_FAILED);
+
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return -1;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return -1;
+ }
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = -3;
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ ret = BkupCheckStatFromNv(current_media, full_path, query_result->size); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+exit:
+ if (full_path != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ munmap(full_path, FILENAME_MAX);
+ }
+ return ret;
+}
+
+/**
+ * delete command
+ */
+static int BkupCmdDeleteData(bkup_response_t* const response,
+ const enum NvHalMedia current_media,
+ char* const rcv_buf,
+ bkup_query_result_t* const query_result) {
+ int ret = -1;
+ char *full_path = NULL;
+ bkup_protocol_header_t* hdr = reinterpret_cast<bkup_protocol_header_t*>(NULL);
+ pthread_rwlock_t* rwlock = reinterpret_cast<pthread_rwlock_t*>(NULL);
+ if ((response == NULL) || (rcv_buf == NULL) || (query_result == NULL)) { // LCOV_EXCL_BR_LINE 6:Excluded as no NULL is currently passed
+ // LCOV_EXCL_START 6:Excluded as no NULL is currently passed
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Resp or Buf or Query is NULL");
+ goto exit;
+ // LCOV_EXCL_STOP 6:Excluded as no NULL is currently passed
+ }
+ hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ rwlock = BkupGetRwlock(hdr->item_name, current_media, query_result);
+ if (BkupMakeBkupPathToNvId(query_result->category_name, hdr->item_name, &full_path, FILENAME_MAX) < 0) { // LCOV_EXCL_BR_LINE 6:Excluded due to checking by upper-level function
+ // LCOV_EXCL_START 6:Excluded due to checking by upper-level function
+ AGL_ASSERT_NOT_TESTED();
+ goto exit;
+ // LCOV_EXCL_STOP 6:Excluded due to checking by upper-level function
+ }
+ BkupRwlockWrlock(rwlock, full_path);
+ ret = BkupDeleteDataFromNv(current_media, full_path);
+ if (ret != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "BkupDeleteDataFromNv Error");
+ }
+ BkupRwlockUnlock(rwlock, full_path);
+
+exit:
+ if ((response != NULL) && (query_result != NULL) && (hdr != NULL)) { // LCOV_EXCL_BR_LINE 6:Excluded as no NULL is currently passed
+ EFrameworkunifiedStatus e_status = (ret < 0) ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ if (current_media == NVHALMEDIA_NAND) {
+ if ((query_result->cache_dram == false) && (query_result->backup_dram == false)) {
+ BkupApilog(response, current_media, hdr, query_result, NULL, 0, e_status);
+ }
+ if ((*response->set_response)(response->opt, NULL, 0, e_status) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Response Error");
+ ret = -1;
+ }
+ } else {
+ BkupApilog(response, current_media, hdr, query_result, NULL, 0, e_status);
+ }
+ }
+
+ if (full_path != NULL) { // LCOV_EXCL_BR_LINE 6:Excluded because checked by BkupMakeBkupPathToNvId()
+ munmap(full_path, FILENAME_MAX);
+ }
+ return ret;
+}
+
+/**
+ * common file handler
+ */
+static int BkupHandlerFile(bkup_response_t *response,
+ enum NvHalMedia current_media, char *rcv_buf,
+ bkup_query_result_t *query_result) {
+ int ret = 0;
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+
+ if (rcv_buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "rcv_buf is NULL");
+ return -1;
+ }
+
+ switch (hdr->command) { // LCOV_EXCL_BR_LINE 6:double check
+ case BKUP_CMD_READ:
+ ret = BkupCmdRead(response, current_media, rcv_buf, query_result);
+ break;
+
+ case BKUP_CMD_WRITE:
+ ret = BkupCmdWrite(response, current_media, rcv_buf, query_result);
+ break;
+
+ case BKUP_CMD_FILL:
+ ret = BkupCmdFill(response, current_media, rcv_buf, query_result);
+ break;
+
+ case BKUP_CMD_COPY_INNER:
+ ret = BkupCmdCopy(response, current_media, rcv_buf, query_result);
+ break;
+
+ case BKUP_CMD_DELETE:
+ ret = BkupCmdDeleteData(response, current_media, rcv_buf, query_result);
+ break;
+
+ default:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ break; // LCOV_EXCL_LINE 6:double check
+ }
+ return ret;
+}
+
+/**
+ * Main's response
+ */
+static int BkupSetResponseNsfw(void *opt, void *buf, int size, EFrameworkunifiedStatus ret_value) {
+ EFrameworkunifiedStatus e_status;
+
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 6:double check
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((e_status = FrameworkunifiedSetSyncResponseData((HANDLE)opt, buf, size)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedSetSyncResponseData:%d", e_status);
+ return -1;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+ }
+ return 0;
+}
+
+/**
+ * write apilog
+ */
+static void BkupApilog(bkup_response_t *response, enum NvHalMedia current_media,
+ bkup_protocol_header_t *hdr,
+ bkup_query_result_t *query_result, char *buf,
+ uint32_t crc32, EFrameworkunifiedStatus ret_value) {
+ const char *src;
+ const char *cmd;
+ char header[12] = "-- -- -- --";
+ const char c[] = "0123456789abcdef";
+
+ if (response == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "response is NULL");
+ return;
+ }
+ if (hdr == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "hdr is NULL");
+ return;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "query_result is NULL");
+ return;
+ }
+ if (response->set_response == BkupSetResponseNsfw) {
+ src = FrameworkunifiedGetMsgSrc((HANDLE)response->opt); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ } else {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ src = (reinterpret_cast<bkup_itc_message_t *>(response->opt))->nand.client_name;
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+
+ switch (hdr->command) { // LCOV_EXCL_BR_LINE 6:double check
+ case BKUP_CMD_READ:
+ cmd = "RD";
+ break;
+ case BKUP_CMD_WRITE:
+ cmd = "WR";
+ break;
+ case BKUP_CMD_FILL:
+ cmd = "FILL";
+ break;
+ case BKUP_CMD_READ_NUM:
+ // LCOV_EXCL_START 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cmd = "RDN";
+ break;
+ // LCOV_EXCL_STOP 6:double check
+ case BKUP_CMD_SIZE_NUM:
+ // LCOV_EXCL_START 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cmd = "SZN";
+ break;
+ // LCOV_EXCL_STOP 6:double check
+ case BKUP_CMD_DELETE:
+ cmd = "DEL";
+ break;
+ default:
+ // LCOV_EXCL_START 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cmd = "UNKNOWN";
+ break;
+ // LCOV_EXCL_STOP 6:double check
+ }
+
+ if (buf) { // LCOV_EXCL_BR_LINE 6:double check
+ int i;
+ for (i = 0; i < 4; i++) {
+ if (query_result->size > i) {
+ header[i * 3] = c[*(buf + i) >> 4];
+ header[i * 3 + 1] = c[*(buf + i) & 0xf];
+ }
+ }
+ }
+
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ALSA, "", "%s/%s/%s/o:%d/s:%d/h:%s/c:%x/r:%d", src, cmd, hdr->item_name, hdr->offset, hdr->size,
+ header, crc32, ret_value);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+}
+
+/**
+ * Tweak command
+ */
+static int BkupTweakCommand(enum NvHalMedia current_media, char **rcv_buf,
+ int *rcv_size, bkup_query_result_t *query_result) {
+ int ret = -1;
+ bkup_protocol_header_t update_hdr;
+ bkup_protocol_header_t *hdr = reinterpret_cast<bkup_protocol_header_t *>(*rcv_buf);
+
+ if (current_media == NVHALMEDIA_NAND) { // LCOV_EXCL_BR_LINE 6:current_media never will be NVHALMEDIA_NAND
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ret = 0; // LCOV_EXCL_LINE 6:current_media never will be NVHALMEDIA_NAND
+ goto exit; // LCOV_EXCL_LINE 6:current_media never will be NVHALMEDIA_NAND
+ }
+ if (rcv_size == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "rcv_size is NULL");
+ return -1;
+ }
+ if (query_result == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "query_resul is NULL");
+ return -1;
+ }
+
+ if ((hdr->command == BKUP_CMD_WRITE || hdr->command == BKUP_CMD_FILL) &&
+ (hdr->offset != 0 || hdr->size != (uint32_t)query_result->size)) {
+ // partial request
+ if ((current_media == NVHALMEDIA_CACHEDRAM &&
+ (query_result->nand || query_result->backup_dram)) ||
+ (current_media == NVHALMEDIA_BACKUPDRAM && query_result->nand)) {
+ memset(&update_hdr, 0, sizeof(update_hdr));
+ BkupStrlcpy(update_hdr.item_name, hdr->item_name, sizeof(update_hdr.item_name));
+ update_hdr.command = BKUP_CMD_COPY_INNER;
+ update_hdr.src_media = current_media;
+ munmap(*rcv_buf, *rcv_size);
+ *rcv_size = 0;
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if ((*rcv_buf = BkupAnonMmap(sizeof(bkup_protocol_header_t))) == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ *rcv_size = sizeof(bkup_protocol_header_t);
+ memcpy(*rcv_buf, &update_hdr, sizeof(update_hdr));
+ }
+ }
+ ret = 0;
+
+exit:
+ return ret;
+}
+
+/**
+ * Main callback handler
+ */
+EFrameworkunifiedStatus BkupHandler(HANDLE h_app) {
+ EFrameworkunifiedStatus e_status = eFrameworkunifiedStatusOK;
+ uint32_t rcv_size = 0;
+ char *rcv_buf = NULL;
+ bkup_protocol_header_t *hdr;
+ bkup_query_result_t query_result;
+ bool hold_rcv_buf = false;
+ int ret = 0;
+ bkup_response_t response_nsfw = {BkupSetResponseNsfw, h_app};
+
+ if ((rcv_size = FrameworkunifiedGetMsgLength(h_app)) < sizeof(bkup_protocol_header_t)) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgLength: size fail:%d", rcv_size);
+ e_status = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ rcv_buf = reinterpret_cast<char *>(mmap(NULL, rcv_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0));
+ if (rcv_buf == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ rcv_size = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap:%s", strerror(errno));
+ e_status = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+
+ // LCOV_EXCL_BR_START 4: NSFW error case.
+ if ((e_status = FrameworkunifiedGetMsgDataOfSize(h_app, rcv_buf, rcv_size, eSMRRelease)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize:%d", e_status);
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+
+ hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ if (hdr->command < 0 || hdr->command >= BKUP_CMD_MAX) { // LCOV_EXCL_BR_LINE 6:double check
+ // LCOV_EXCL_START 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid command:%d", hdr->command);
+ e_status = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ // LCOV_EXCL_STOP 6:double check
+ }
+
+ if (hdr->command == BKUP_CMD_READ_NUM || hdr->command == BKUP_CMD_SIZE_NUM) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ if (BkupParamGetNumid(hdr->num_id, &query_result, hdr->item_name, sizeof(hdr->item_name)) < 0) {
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", hdr->num_id);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ e_status = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ }
+
+ if (hdr->command == BKUP_CMD_READ_NUM) {
+ hdr->command = BKUP_CMD_READ;
+ }
+ } else {
+ if (BkupParamGet(hdr->item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", hdr->item_name != 0 ? hdr->item_name : NULL);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ e_status = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ }
+ }
+
+ if (hdr->command == BKUP_CMD_READ || hdr->command == BKUP_CMD_WRITE || hdr->command == BKUP_CMD_FILL) {
+ if (hdr->size == 0) {
+ // do nothing
+ goto exit;
+ }
+ if (hdr->size + hdr->offset > (uint32_t)query_result.size) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid size+offset:%d+%d", hdr->size, hdr->offset);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ e_status = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ }
+ }
+
+ // LCOV_EXCL_BR_START 6: g_bkup_internal_state will not be BKUP_STATE_INIT
+ if (g_bkup_internal_state == BKUP_STATE_INIT) {
+ // LCOV_EXCL_BR_STOP 6: g_bkup_internal_state will not be BKUP_STATE_INIT
+ // LCOV_EXCL_START 6: same as above
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ e_status = eFrameworkunifiedStatusErrOther;
+ goto exit;
+ // LCOV_EXCL_STOP 6: same as above
+ }
+ // LCOV_EXCL_BR_START 6: g_bkup_internal_state will not be BKUP_STATE_TERM
+ if (g_bkup_internal_state == BKUP_STATE_TERM) {
+ // LCOV_EXCL_BR_STOP 6: g_bkup_internal_state will not be BKUP_STATE_TERM
+ // LCOV_EXCL_START 6: same as above
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ e_status = eFrameworkunifiedStatusExit;
+ goto exit;
+ // LCOV_EXCL_STOP 6: same as above
+ }
+
+ if (hdr->command == BKUP_CMD_SIZE || hdr->command == BKUP_CMD_SIZE_NUM) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupSetResponseNsfw(h_app, &query_result.size, sizeof(query_result.size), eFrameworkunifiedStatusOK);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ } else if (hdr->command == BKUP_CMD_CHECK) {
+ if (query_result.nand) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupCmdCheck(&response_nsfw, NVHALMEDIA_NAND, rcv_buf, &query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ } else if (query_result.backup_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupCmdCheck(&response_nsfw, NVHALMEDIA_BACKUPDRAM, rcv_buf, &query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ } else if (query_result.cache_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupCmdCheck(&response_nsfw, NVHALMEDIA_CACHEDRAM, rcv_buf, &query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ } else {
+ ret = -3;
+ }
+
+ if (ret == -1) {
+ // not exists
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Not exists:%s", hdr->item_name != 0 ? hdr->item_name : NULL);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ e_status = eFrameworkunifiedStatusFileLoadError;
+ } else if (ret == -2) {
+ // size error
+ e_status = eFrameworkunifiedStatusAccessError;
+ } else if (ret == -3) {
+ e_status = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ /*
+ * Cache DRAM
+ */
+ if (query_result.cache_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupHandlerFile(&response_nsfw, NVHALMEDIA_CACHEDRAM, rcv_buf, &query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ if (ret > 0) {
+ if (hdr->command == BKUP_CMD_READ) {
+ goto exit;
+ }
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if (BkupTweakCommand(NVHALMEDIA_CACHEDRAM, &rcv_buf,
+ reinterpret_cast<int *>(&rcv_size),
+ &query_result) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ e_status = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ }
+ }
+
+ /*
+ * Backup DRAM
+ */
+ if (query_result.backup_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupHandlerFile(&response_nsfw, NVHALMEDIA_BACKUPDRAM, rcv_buf, &query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ if (ret > 0) {
+ if (hdr->command == BKUP_CMD_READ) {
+ goto exit;
+ }
+ // LCOV_EXCL_BR_START 5: mmap's error case.
+ if (BkupTweakCommand(NVHALMEDIA_BACKUPDRAM, &rcv_buf,
+ reinterpret_cast<int *>(&rcv_size),
+ &query_result) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mmap's error case.
+ // LCOV_EXCL_START 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ e_status = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_buf);
+ }
+ }
+
+ /*
+ * NAND
+ */
+ if (query_result.nand) {
+ bkup_itc_message_t snd_msg;
+
+ if ((hdr->command == BKUP_CMD_READ) || (hdr->command == BKUP_CMD_DELETE) || (query_result.sync) || (ret == 0)) {
+ /*
+ * operation offload
+ */
+ const char *client_name;
+ char system_info[MAX_SYS_INFO_SIZE];
+
+ if (g_bkup_nand_mqd == -1) {
+ // LCOV_EXCL_BR_START 5: mq_open's error case.
+ if ((g_bkup_nand_mqd = BkupItcMqopen("/" BKUP_THREAD_NAND, O_WRONLY | O_CREAT | O_NONBLOCK | O_CLOEXEC)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_open's error case.
+ // LCOV_EXCL_START 5: mq_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: mq_open's error case.
+ }
+ }
+
+ if ((client_name = FrameworkunifiedGetMsgSrc(h_app)) == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "invalid client_name");
+ e_status = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ FrameworkunifiedGetSystemInfo(h_app, system_info); // LCOV_EXCL_BR_LINE 11:unexpected branch.
+
+ memset(&snd_msg, 0, sizeof(snd_msg));
+ BkupStrlcpy(snd_msg.nand.client_name, client_name, sizeof(snd_msg.nand.client_name));
+ snd_msg.nand.seq_id = static_cast<uint32_t>(strtoul(system_info, NULL, 16));
+ snd_msg.nand.rcv_buf = rcv_buf;
+ snd_msg.nand.rcv_size = rcv_size;
+
+ // LCOV_EXCL_BR_START 5: mq_send's error case.
+ if (mq_send(g_bkup_nand_mqd, reinterpret_cast<char *>(&snd_msg), sizeof(snd_msg), 0) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_send's error case.
+ // LCOV_EXCL_START 5: mq_send's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ int save_errno = errno;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno));
+ e_status = eFrameworkunifiedStatusFail;
+ if (save_errno == EAGAIN) {
+ kill(g_bkup_nand_tid, SIGABRT);
+ }
+ goto exit;
+ // LCOV_EXCL_STOP 5: mq_send's error case.
+ }
+ FrameworkunifiedSetDeferredSyncResponse(h_app); // LCOV_EXCL_BR_LINE 11:unexpected branch.
+ hold_rcv_buf = true;
+ } else {
+ /*
+ * delay write
+ */
+ if (g_bkup_delay_mqd == -1) {
+ // LCOV_EXCL_BR_START 5: mq_open's error case.
+ if ((g_bkup_delay_mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_WRONLY | O_CREAT | O_NONBLOCK | O_CLOEXEC)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_open's error case.
+ // LCOV_EXCL_START 5: mq_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: mq_open's error case.
+ }
+ }
+
+ memset(&snd_msg, 0, sizeof(snd_msg));
+
+// snd_msg.delay.terminate = false;
+ snd_msg.delay.cmd = BKUP_DELAY_CMD_REGIST;
+
+ BkupStrlcpy(snd_msg.delay.item_name, hdr->item_name, sizeof(snd_msg.delay.item_name));
+
+ // LCOV_EXCL_BR_START 5: mq_send's error case.
+ if (mq_send(g_bkup_delay_mqd, reinterpret_cast<char *>(&snd_msg), sizeof(snd_msg), 0) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_send's error case.
+ // LCOV_EXCL_START 5: mq_send's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ int save_errno = errno;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno));
+ e_status = eFrameworkunifiedStatusFail;
+ if (save_errno == EAGAIN) {
+ kill(g_bkup_delay_tid, SIGABRT);
+ }
+ goto exit;
+ // LCOV_EXCL_STOP 5: mq_send's error case.
+ }
+ }
+ }
+ }
+
+exit:
+ if (hold_rcv_buf == false && rcv_buf != MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case
+ munmap(rcv_buf, rcv_size);
+ }
+ return e_status;
+}
+
+
+/**
+ * Power callback handler
+ */
+EFrameworkunifiedStatus bkup_power_handler(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ uint32_t rcv_size = 0;
+ T_SS_SM_UserModeOnOffNotification_StructType power_status;
+
+ if ((rcv_size = FrameworkunifiedGetMsgLength(hApp)) != sizeof(power_status)) { // LCOV_EXCL_BR_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 4: NSFW error case
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgLength: size fail:%d", rcv_size);
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ // LCOV_EXCL_BR_START 4: NSFW error case
+ if ((eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &power_status, rcv_size, eSMRRelease)) != eFrameworkunifiedStatusOK) {
+ // LCOV_EXCL_BR_STOP 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 4: NSFW error case
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "FrameworkunifiedGetMsgDataOfSize:%d", eStatus);
+ goto exit;
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+
+ if (g_bkup_internal_state != BKUP_STATE_NORMAL) { // LCOV_EXCL_BR_LINE 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 6:double check
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __func__, "Invalid state:%d", g_bkup_internal_state);
+ goto exit;
+ // LCOV_EXCL_STOP 6:double check
+ }
+
+ if (power_status.isUserModeOn == FALSE) {
+ bkup_itc_message_t snd_msg;
+
+ if (g_bkup_delay_mqd == -1) {
+ // LCOV_EXCL_BR_START 5: mq_open's error case.
+ if ((g_bkup_delay_mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_WRONLY|O_CREAT|O_NONBLOCK|O_CLOEXEC)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 5: mq_open's error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5: mq_open's error case.
+ }
+ }
+
+ memset(&snd_msg, 0, sizeof(snd_msg));
+ snd_msg.delay.cmd = BKUP_DELAY_CMD_PRE_ACCOFF;
+
+ // LCOV_EXCL_BR_START 5: mq_send's error case.
+ if (mq_send(g_bkup_delay_mqd, (char *)&snd_msg, sizeof(snd_msg), 0) < 0) {
+ // LCOV_EXCL_BR_START 5: mq_send's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 5: mq_send's error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP 5: mq_send's error case.
+ }
+ }
+
+exit:
+ return eStatus;
+}
+
+
+/**
+ * thread's response
+ */
+static int BkupSetResponseThread(void *opt, void *buf, int size, EFrameworkunifiedStatus ret_value) {
+ HANDLE response_mq;
+ char invoker_name[MAX_QUEUE_NAME_SIZE];
+ if (opt == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "opt is NULL");
+ return -1;
+ }
+ bkup_itc_message_t *msg = reinterpret_cast<bkup_itc_message_t *>(opt);
+ EFrameworkunifiedStatus e_status;
+ // LCOV_EXCL_BR_START 11:unexpected branch.
+ McCreateInvokerName(msg->nand.client_name, 0, invoker_name, sizeof(invoker_name));
+ // LCOV_EXCL_BR_STOP 11:unexpected branch.
+
+ if (g_bkup_response_mq == NULL) {
+ g_bkup_response_mq = new g_bkup_response_mq_t; // LCOV_EXCL_BR_LINE 11:except,C++ operator
+ }
+ g_bkup_response_mq_t::iterator mq_it = g_bkup_response_mq->find(invoker_name); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (mq_it != g_bkup_response_mq->end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ response_mq = mq_it->second; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ } else {
+ if ((response_mq = McOpenSyncSender(invoker_name)) == NULL) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mcOpenSyncSender");
+ return -1;
+ // LCOV_EXCL_STOP 4: NSFW error case.
+ }
+ g_bkup_response_mq->insert(std::make_pair(invoker_name, response_mq)); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+
+ // LCOV_EXCL_BR_START 11:unexpected branch.
+ e_status = McSendSyncResponse(response_mq, MN_NS_BACKUPMGR, BACKUP_CID, msg->nand.seq_id, ret_value, size, buf);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch.
+ return (e_status == eFrameworkunifiedStatusOK) ? 0 : -1; // LCOV_EXCL_BR_LINE 11:unexpected branch
+}
+
+/**
+ * NAND Thread
+ */
+void *BkupNandThread(void *arg) {
+ mqd_t mqd;
+ struct pollfd fds[1];
+ bkup_itc_message_t rcv_msg;
+ bkup_protocol_header_t *hdr;
+ bkup_query_result_t query_result;
+ bkup_response_t response_thread = {BkupSetResponseThread, NULL};
+
+ signal_handler p_signal = SignalHandlerFuncForMsgHandleThread;
+ signal(SIGUSR1, p_signal);
+ g_nand_thread_id = pthread_self();
+
+ if (prctl(PR_SET_NAME, BKUP_THREAD_NAND) < 0) { // LCOV_EXCL_BR_LINE 5: prctl's error case.
+ // LCOV_EXCL_START 5: prctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "prctl(PR_SET_NAME):%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: prctl's error case.
+ }
+
+ // LCOV_EXCL_BR_START 5: mq_open's error case.
+ if ((mqd = BkupItcMqopen("/" BKUP_THREAD_NAND, O_RDONLY | O_CREAT | O_CLOEXEC)) < -1) {
+ // LCOV_EXCL_BR_STOP 5: mq_open's error case.
+ // LCOV_EXCL_START 5: mq_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: mq_open's error case.
+ }
+ g_bkup_nand_tid = static_cast<int>(syscall(__NR_gettid));
+
+ fds[0].fd = mqd;
+ fds[0].events = POLLIN;
+
+ while (1) {
+ int ret = poll(fds, sizeof(fds) / sizeof(struct pollfd), -1); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: poll's error case.
+ // LCOV_EXCL_START 5: poll's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == EINTR) {
+ continue;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "poll errno:%s", strerror(errno));
+ // LCOV_EXCL_STOP 5: poll's error case.
+ } else {
+ if ((fds[0].revents & POLLIN) != 0) {
+ // LCOV_EXCL_BR_START 5: mq_receive's error case.
+ if (mq_receive(mqd, reinterpret_cast<char *>(&rcv_msg), sizeof(rcv_msg), NULL) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_receive's error case.
+ // LCOV_EXCL_START 5: mq_receive's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno != EINTR) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_receive:%s", strerror(errno));
+ }
+ continue;
+ // LCOV_EXCL_STOP 5: mq_receive's error case.
+ }
+ hdr = reinterpret_cast<bkup_protocol_header_t *>(rcv_msg.nand.rcv_buf);
+ BkupParamGet(hdr->item_name, &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ response_thread.opt = &rcv_msg;
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ ret = BkupHandlerFile(&response_thread, NVHALMEDIA_NAND, rcv_msg.nand.rcv_buf, &query_result);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+
+ munmap(rcv_msg.nand.rcv_buf, rcv_msg.nand.rcv_size);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * delay backup thread
+ */
+typedef struct {
+ int fd;
+ std::string name;
+} bkup_delay_t; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+static int BkupDelayTimerAdd(int efd, const char *item_name, time_t backup_cycle) {
+ int ret = -1;
+ struct epoll_event ev;
+ bkup_delay_t *timer_ev = new bkup_delay_t; // LCOV_EXCL_BR_LINE 11:except,C++ operator
+ struct itimerspec itime;
+
+ if ((timer_ev->fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) { // LCOV_EXCL_BR_LINE 5: timerfd_create's error case.
+ // LCOV_EXCL_START 5: timerfd_create's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_create:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5: timerfd_create's error case.
+ }
+ timer_ev->name = item_name; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ ev.events = EPOLLIN;
+ ev.data.ptr = timer_ev;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, timer_ev->fd, &ev) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_ctl's error case.
+ // LCOV_EXCL_START 5: epoll_ctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_ctl:%s", strerror(errno));
+ goto exit;
+ // LCOV_EXCL_STOP 5: epoll_ctl's error case.
+ }
+
+ memset(&itime, 0, sizeof(itime));
+ itime.it_value.tv_sec = backup_cycle;
+ itime.it_interval.tv_sec = backup_cycle;
+
+ if (timerfd_settime(timer_ev->fd, 0, &itime, NULL) < 0) { // LCOV_EXCL_BR_LINE 5: timerfd_settime's error case.
+ // LCOV_EXCL_START 5: timerfd_settime's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_settime:%s", strerror(errno));
+ epoll_ctl(efd, EPOLL_CTL_DEL, timer_ev->fd, &ev);
+ goto exit;
+ // LCOV_EXCL_STOP 5: timerfd_settime's error case.
+ }
+ ret = 0;
+
+exit:
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: C API's error case.
+ // LCOV_EXCL_START 5: C API's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (timer_ev->fd >= 0) {
+ if (close(timer_ev->fd) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "timerfd_settime:%s", strerror(errno));
+ }
+ }
+ delete timer_ev;
+ }
+ // LCOV_EXCL_STOP 5: C API's error case.
+ return ret;
+}
+
+static uint64_t *g_bkup_syncreq;
+static pthread_rwlock_t g_syncreq_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+#define BKUP_SYNCREQ_SIZE (4096)
+#define BKUP_SYNCREQ_ID_MAX (BKUP_SYNCREQ_SIZE * 8 - 1)
+#define BKUP_SYNCREQ_NAME "syncreq"
+
+static int BkupSyncreqInit(void) {
+ int ret = -1;
+ char *map;
+
+ map = reinterpret_cast<char *>(mmap(NULL, BKUP_SYNCREQ_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0));
+ if (map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 5: mmap's error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap failed");
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ g_bkup_syncreq = reinterpret_cast<uint64_t *>(map);
+ memset(g_bkup_syncreq, 0, BKUP_SYNCREQ_SIZE);
+
+ pthread_rwlock_wrlock(&g_syncreq_rwlock);
+ BkupBufferWriteToNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME,
+ reinterpret_cast<char *>(g_bkup_syncreq),
+ BKUP_SYNCREQ_SIZE, NULL);
+ pthread_rwlock_unlock(&g_syncreq_rwlock);
+ ret = 0;
+
+exit:
+ return ret;
+}
+
+static void BkupSyncreqTerm(void) {
+ if (g_bkup_syncreq != NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL
+ munmap(g_bkup_syncreq, BKUP_SYNCREQ_SIZE);
+ g_bkup_syncreq = NULL;
+ }
+}
+
+static int BkupSyncreqSet(int id) {
+ if (g_bkup_syncreq == NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 5: mmap's error case.
+ }
+ if (id > BKUP_SYNCREQ_ID_MAX) {
+ return -1;
+ }
+ if (!(*(g_bkup_syncreq + id / 64) & (1ULL << (id % 64)))) {
+ *(g_bkup_syncreq + id / 64) |= (1ULL << (id % 64));
+ pthread_rwlock_wrlock(&g_syncreq_rwlock);
+ BkupBufferWriteToNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME,
+ reinterpret_cast<char *>(g_bkup_syncreq),
+ BKUP_SYNCREQ_SIZE, NULL);
+ pthread_rwlock_unlock(&g_syncreq_rwlock);
+ }
+ return 0;
+}
+
+static int BkupSyncreqClear(int id) {
+ if (g_bkup_syncreq == NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 5: mmap's error case.
+ }
+ if (id > BKUP_SYNCREQ_ID_MAX) {
+ return -1;
+ }
+ if (*(g_bkup_syncreq + id / 64) & (1ULL << (id % 64))) {
+ *(g_bkup_syncreq + id / 64) &= ~(1ULL << (id % 64));
+ pthread_rwlock_wrlock(&g_syncreq_rwlock);
+ BkupBufferWriteToNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME,
+ reinterpret_cast<char *>(g_bkup_syncreq),
+ BKUP_SYNCREQ_SIZE, NULL);
+ pthread_rwlock_unlock(&g_syncreq_rwlock);
+ }
+
+ return 0;
+}
+
+static inline int BkupPopcnt64(uint64_t x) {
+ uint64_t n;
+
+ n = (x >> 1) & 0x7777777777777777ULL;
+ x = x - n;
+ n = (n >> 1) & 0x7777777777777777ULL;
+ x = x - n;
+ n = (n >> 1) & 0x7777777777777777ULL;
+ x = x - n;
+ x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
+ x = x * 0x0101010101010101ULL;
+ return static_cast<int>(x >> 56);
+}
+
+static int BkupSyncreqSearch(void) {
+ int i;
+
+ if (g_bkup_syncreq == NULL) { // LCOV_EXCL_BR_LINE 6:g_bkup_syncreq will not be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 5: mmap's error case.
+ }
+
+ for (i = 0; i < static_cast<int>(BKUP_SYNCREQ_SIZE / sizeof(uint64_t)); i++) {
+ if (*(g_bkup_syncreq + i) != 0) {
+ uint64_t bits, mrb1; // most right bit 1
+ bits = *(g_bkup_syncreq + i);
+ mrb1 = bits & (-bits);
+ return i * 64 + BkupPopcnt64(mrb1 - 1);
+ }
+ }
+
+ return -1;
+}
+
+static void BkupSyncreqDone(bool skip_cache) {
+ int id;
+ uint64_t start, end;
+
+ start = BkupTimerReal();
+
+ while ((id = BkupSyncreqSearch()) >= 0) {
+ char item_name[64];
+ bkup_query_result_t query_result;
+
+ if (BkupParamGetNumid(id, &query_result, item_name, sizeof(item_name)) < 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", id);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ } else {
+ if (query_result.cache_dram) {
+ if (!skip_cache) {
+ BkupMediaCopyFromNv(query_result.category_name, item_name,
+ NVHALMEDIA_CACHEDRAM, NVHALMEDIA_NAND, NULL,
+ NULL);
+ }
+ } else if (query_result.backup_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupMediaCopyFromNv(query_result.category_name, item_name,
+ NVHALMEDIA_BACKUPDRAM, NVHALMEDIA_NAND, NULL, NULL);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+ }
+
+ BkupSyncreqClear(id); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ }
+
+ end = BkupTimerReal();
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __func__, "spent:%" PRIu64 ".%06" PRIu64 "ms",
+ static_cast<uint64_t>((end - start) / 1000000),
+ static_cast<uint64_t>((end - start) % 1000000));
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+}
+
+void BkupSyncreqRestart(void) {
+ char *map;
+
+ map = reinterpret_cast<char *>(mmap(NULL, BKUP_SYNCREQ_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0));
+ if (map == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_START 5: mmap's error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mmap failed");
+ goto exit;
+ // LCOV_EXCL_STOP 5: mmap's error case.
+ }
+ g_bkup_syncreq = reinterpret_cast<uint64_t *>(map);
+
+ if (BkupBufferReadFromNv(NVHALMEDIA_BACKUPDRAM, BKUP_SYNCREQ_NAME,
+ reinterpret_cast<char *>(g_bkup_syncreq),
+ BKUP_SYNCREQ_SIZE, NULL) < 0) {
+ goto exit;
+ }
+ BkupSyncreqDone(true);
+ BkupSyncreqTerm();
+
+exit:
+ return;
+}
+
+void *BkupDelayThread(void *arg) {
+ mqd_t mqd;
+ int efd;
+ struct epoll_event ev;
+ bkup_delay_t *mq_ev;
+ bkup_itc_message_t rcv_msg;
+ std::map<std::string, int> delay_req; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ signal_handler p_signal = SignalHandlerFuncForMsgHandleThread;
+ signal(SIGUSR1, p_signal);
+ g_delay_thread_id = pthread_self();
+
+
+ if (prctl(PR_SET_NAME, BKUP_THREAD_DELAY) < 0) { // LCOV_EXCL_BR_LINE 5: prctl's error case.
+ // LCOV_EXCL_START 5: prctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "prctl(PR_SET_NAME):%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: prctl's error case.
+ }
+
+ // LCOV_EXCL_BR_START 5: mq_open's error case.
+ if ((mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_RDONLY | O_CREAT | O_CLOEXEC)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_open's error case.
+ // LCOV_EXCL_START 5: mq_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: mq_open's error case.
+ }
+
+ if ((efd = epoll_create(MAX_FD_EPOLL)) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_create's error case.
+ // LCOV_EXCL_START 5: epoll_create's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_create:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: epoll_create's error case.
+ }
+ g_bkup_delay_tid = static_cast<int>(syscall(__NR_gettid));
+
+ mq_ev = new bkup_delay_t; // LCOV_EXCL_BR_LINE 11:except,C++ operator
+ mq_ev->fd = static_cast<int>(mqd);
+ mq_ev->name = "mq"; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ ev.events = EPOLLIN;
+ ev.data.ptr = mq_ev;
+ // LCOV_EXCL_BR_START 5: epoll_ctl's error case.
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, static_cast<int>(mqd), &ev) < 0) {
+ // LCOV_EXCL_BR_STOP 5: epoll_ctl's error case.
+ // LCOV_EXCL_START 5: epoll_ctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_ctl:%s", strerror(errno));
+ exit(EXIT_FAILURE);
+ // LCOV_EXCL_STOP 5: epoll_ctl's error case.
+ }
+
+ while (1) {
+ struct epoll_event events[MAX_FD_EPOLL];
+ int nfds;
+
+ nfds = epoll_wait(efd, events, MAX_FD_EPOLL, -1); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (nfds < 0) { // LCOV_EXCL_BR_LINE 5: epoll_wait's error case.
+ // LCOV_EXCL_START 5: epoll_wait's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno != EINTR) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_wait:%s", strerror(errno));
+ }
+ continue;
+ // LCOV_EXCL_STOP 5: epoll_wait's error case.
+ }
+
+ for (int i = 0; i < nfds; i++) {
+ bkup_delay_t *cur_ev = reinterpret_cast<bkup_delay_t *>(events[i].data.ptr);
+
+ if (cur_ev->fd == mqd) {
+ /*
+ * mq
+ */
+ // LCOV_EXCL_BR_START 5: mq_receive's error case.
+ if (mq_receive(mqd, reinterpret_cast<char *>(&rcv_msg), sizeof(rcv_msg), NULL) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_receive's error case.
+ // LCOV_EXCL_START 5: mq_receive's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno != EINTR) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_receive:%s", strerror(errno));
+ }
+ continue;
+ // LCOV_EXCL_STOP 5: mq_receive's error case.
+ }
+
+#if 0
+ if (rcv_msg.delay.terminate) {
+ // terminate request
+ // shutdown sync
+ BkupSyncreqDone(false); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ for (std::map<std::string, int>::iterator i = delay_req.begin(); i != delay_req.end(); ++i) {
+ i->second = 0; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+
+ // terminate finish response
+ int64_t term_event = 1;
+ // LCOV_EXCL_BR_START 5: write's error case.
+ if (write(rcv_msg.delay.event_fd, &term_event, sizeof(term_event)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: write's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "write:%s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case.
+ }
+ } else {
+ // delay request
+ bkup_query_result_t query_result;
+ BkupParamGet(rcv_msg.delay.item_name, &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ if (query_result.backup_cycle > 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (delay_req.find(rcv_msg.delay.item_name) != delay_req.end()) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ delay_req[rcv_msg.delay.item_name]++; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ } else {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ BkupDelayTimerAdd(efd, rcv_msg.delay.item_name, query_result.backup_cycle);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ delay_req[rcv_msg.delay.item_name] = 1; // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ if (BkupSyncreqSet(query_result.id) < 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ // write to ACC OFF
+ bkup_query_result_t query_result;
+ if (BkupParamGet(rcv_msg.delay.item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s",
+ rcv_msg.delay.item_name != 0 ? rcv_msg.delay.item_name : NULL);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ } else {
+ if (BkupSyncreqSet(query_result.id) < 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ }
+ }
+ }
+#endif
+ switch (rcv_msg.delay.cmd) {
+ case BKUP_DELAY_CMD_TERM:
+ case BKUP_DELAY_CMD_PRE_ACCOFF:
+ /*
+ * terminate or pre-acc_off request
+ */
+ // shutdown sync
+ BkupSyncreqDone(false);
+
+ for (std::map<std::string, int>::iterator i = delay_req.begin(); i != delay_req.end(); ++i) {
+ i->second = 0;
+ }
+
+ if (rcv_msg.delay.cmd == BKUP_DELAY_CMD_TERM) {
+ BkupSyncreqTerm();
+
+ // terminate finish response
+ int64_t term_event = 1;
+ // LCOV_EXCL_BR_START 5: write's error case.
+ if (write(rcv_msg.delay.event_fd, &term_event, sizeof(term_event)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: write's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "write:%s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case.
+ }
+ }
+ break;
+
+ case BKUP_DELAY_CMD_REGIST:
+ // delay regist request
+ bkup_query_result_t query_result;
+ BkupParamGet(rcv_msg.delay.item_name, &query_result);
+
+ if (query_result.backup_cycle > 0) {
+ if (delay_req.find(rcv_msg.delay.item_name) != delay_req.end()) {
+ delay_req[rcv_msg.delay.item_name]++;
+ } else {
+ BkupDelayTimerAdd(efd, rcv_msg.delay.item_name, query_result.backup_cycle);
+ delay_req[rcv_msg.delay.item_name] = 1;
+ }
+
+ if (BkupSyncreqSet(query_result.id) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id);
+ }
+ } else {
+ // wite to ACC OFF
+ bkup_query_result_t query_result;
+ if (BkupParamGet(rcv_msg.delay.item_name, &query_result) < 0) { // LCOV_EXCL_BR_LINE 6:double check
+ // LCOV_EXCL_START 6:double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid item_name:%s", rcv_msg.delay.item_name);
+ // LCOV_EXCL_STOP 6:double check
+ } else {
+ if (BkupSyncreqSet(query_result.id) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id);
+ }
+ }
+ }
+ break;
+ }
+
+ } else {
+ /*
+ * timerfd
+ */
+ uint64_t exp;
+ if (read(cur_ev->fd, &exp, sizeof(exp)) < 0) { // LCOV_EXCL_BR_LINE 5: read's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "read:%s", strerror(errno)); // LCOV_EXCL_LINE 5: read's error case.
+ }
+
+ if (delay_req[cur_ev->name] > 0) { // LCOV_EXCL_BR_LINE 11:unexpected branch
+ bkup_query_result_t query_result;
+ BkupParamGet(cur_ev->name.c_str(), &query_result); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ if (query_result.cache_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *src_rwlock = BkupGetRwlock(
+ cur_ev->name.c_str(), NVHALMEDIA_CACHEDRAM, &query_result);
+ pthread_rwlock_t *dst_rwlock = BkupGetRwlock(
+ cur_ev->name.c_str(), NVHALMEDIA_NAND, &query_result);
+ BkupMediaCopyFromNv(query_result.category_name,
+ cur_ev->name.c_str(), NVHALMEDIA_CACHEDRAM,
+ NVHALMEDIA_NAND, src_rwlock, dst_rwlock);
+ BkupMediaCopyFromNv(query_result.category_name,
+ cur_ev->name.c_str(), NVHALMEDIA_CACHEDRAM,
+ NVHALMEDIA_NAND, NULL, NULL);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ } else if (query_result.backup_dram) {
+ // LCOV_EXCL_BR_START 11:unexpected branch
+ pthread_rwlock_t *src_rwlock = BkupGetRwlock(
+ cur_ev->name.c_str(), NVHALMEDIA_BACKUPDRAM, &query_result);
+ pthread_rwlock_t *dst_rwlock = BkupGetRwlock(
+ cur_ev->name.c_str(), NVHALMEDIA_NAND, &query_result);
+ BkupMediaCopyFromNv(query_result.category_name,
+ cur_ev->name.c_str(), NVHALMEDIA_BACKUPDRAM,
+ NVHALMEDIA_NAND, src_rwlock, dst_rwlock);
+ // LCOV_EXCL_BR_STOP 11:unexpected branch
+ }
+ delay_req[cur_ev->name] = 0; // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (BkupSyncreqClear(query_result.id) < 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "Invalid num_id:%d", query_result.id);
+ // LCOV_EXCL_BR_STOP 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ // not update. timer delte
+ // LCOV_EXCL_BR_START 5: epoll_ctl's error case.
+ if (epoll_ctl(efd, EPOLL_CTL_DEL, cur_ev->fd, &events[i]) < 0) {
+ // LCOV_EXCL_BR_STOP 5: epoll_ctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "epoll_ctl:%s", strerror(errno)); // LCOV_EXCL_LINE 5: epoll_ctl's error case.
+ }
+ if (close(cur_ev->fd) < 0) { // LCOV_EXCL_BR_LINE 5: close's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "close:%s", strerror(errno)); // LCOV_EXCL_LINE 5: close's error case.
+ }
+ delay_req.erase(cur_ev->name); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ delete cur_ev; // LCOV_EXCL_BR_LINE 11:except,C++ operator
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Terminate handler
+ */
+EFrameworkunifiedStatus BkupTerminateHandler(HANDLE h_app) {
+ bkup_itc_message_t snd_msg;
+ int event_fd;
+ int64_t term_event;
+
+ g_bkup_internal_state = BKUP_STATE_TERM;
+
+ if (g_bkup_delay_mqd == -1) {
+ // LCOV_EXCL_BR_START 5: mq_open's error case.
+ if ((g_bkup_delay_mqd = BkupItcMqopen("/" BKUP_THREAD_DELAY, O_WRONLY | O_CREAT | O_NONBLOCK | O_CLOEXEC)) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_open's error case.
+ // LCOV_EXCL_START 5: mq_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_open:%s", strerror(errno));
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP 5: mq_open's error case.
+ }
+ }
+
+ if ((event_fd = eventfd(0, 0)) < 0) { // LCOV_EXCL_BR_LINE 5: eventfd's error case.
+ // LCOV_EXCL_START 5: eventfd's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "eventfd:%s", strerror(errno));
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP 5: eventfd's error case.
+ }
+
+ memset(&snd_msg, 0, sizeof(snd_msg));
+
+// snd_msg.delay.terminate = true;
+ snd_msg.delay.cmd = BKUP_DELAY_CMD_TERM;
+
+ snd_msg.delay.event_fd = event_fd;
+
+ // LCOV_EXCL_BR_START 5: mq_send's error case.
+ if (mq_send(g_bkup_delay_mqd, reinterpret_cast<char *>(&snd_msg), sizeof(snd_msg), 0) < 0) {
+ // LCOV_EXCL_BR_STOP 5: mq_send's error case.
+ // LCOV_EXCL_START 5: mq_send's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "mq_send:%s", strerror(errno));
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP 5: mq_send's error case.
+ }
+
+ while (1) {
+ if (read(event_fd, &term_event, sizeof(term_event)) < 0) { // LCOV_EXCL_BR_LINE 5: read's error case.
+ // LCOV_EXCL_START 5: read's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == EINTR) {
+ continue;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "read:%s", strerror(errno));
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP 5: read's error case.
+ } else {
+ break;
+ }
+ }
+ if (close(event_fd) < 0) { // LCOV_EXCL_BR_LINE 5: close's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __func__, "close:%s", strerror(errno)); // LCOV_EXCL_LINE 5: close's error case.
+ }
+
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * Init handler
+ */
+EFrameworkunifiedStatus BkupInitHandler(HANDLE h_app) {
+ BkupSyncreqRestart();
+ BkupSyncreqInit();
+
+ g_bkup_internal_state = BKUP_STATE_NORMAL;
+
+ return eFrameworkunifiedStatusOK;
+}
diff --git a/nsframework/common_library/LICENSE b/nsframework/common_library/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/nsframework/common_library/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/nsframework/common_library/Makefile.client b/nsframework/common_library/Makefile.client
new file mode 100644
index 00000000..e6210c45
--- /dev/null
+++ b/nsframework/common_library/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := client
+
+include ../native_service.mk
diff --git a/nsframework/common_library/client/Makefile b/nsframework/common_library/client/Makefile
new file mode 100644
index 00000000..4bda2aa2
--- /dev/null
+++ b/nsframework/common_library/client/Makefile
@@ -0,0 +1,30 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+INST_SHLIBS := libcommon
+
+libcommon_SRCS := cl_process.c cl_sem.c cl_monitor.c cl_region.c cl_lock.c cl_cgroup.c
+INST_HEADERS := common_library.h cl_process.h cl_sem.h cl_monitor.h cl_lock.h cl_region.h cl_lockid.h
+
+VPATH = ./src ./include/$(COMPONENT_NAME)
+
+CPPFLAGS += -I./include/
+
+LDFLAGS += -Wl,--no-as-needed
+
+LDLIBS += -lrt
+
+include ../../native_service.mk
diff --git a/nsframework/common_library/client/include/cl_cgroup.h b/nsframework/common_library/client/include/cl_cgroup.h
new file mode 100644
index 00000000..10a71791
--- /dev/null
+++ b/nsframework/common_library/client/include/cl_cgroup.h
@@ -0,0 +1,35 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _cl_cgroup_h_ // NOLINT(build/header_guard)
+#define _cl_cgroup_h_ // NOLINT(build/header_guard)
+
+typedef enum {
+ CL_CGROUP_MEMORY,
+ CL_CGROUP_CPU,
+} cl_cgroup_t;
+
+int cl_cgroup_make(cl_cgroup_t cgroup, const char *cgroup_name); // NOLINT(readability/nolint)
+int cl_cgroup_remove(cl_cgroup_t cgroup, const char *cgroup_name); // NOLINT(readability/nolint)
+int cl_cgroup_exist(cl_cgroup_t cgroup, const char *cgroup_name); // NOLINT(readability/nolint)
+int cl_cgroup_open(cl_cgroup_t cgroup, const char *cgroup_name, // NOLINT(readability/nolint)
+ const char *controler, int flags);
+int cl_cgroup_set_string(cl_cgroup_t cgroup, const char *cgroup_name, // NOLINT(readability/nolint)
+ const char *controler, const char *str);
+int cl_cgroup_set_num(cl_cgroup_t cgroup, const char *cgroup_name, // NOLINT(readability/nolint)
+ const char *controler, int64_t value);
+
+#endif // ifndef _cl_cgroup_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/cl_error.h b/nsframework/common_library/client/include/cl_error.h
new file mode 100644
index 00000000..84bf64e0
--- /dev/null
+++ b/nsframework/common_library/client/include/cl_error.h
@@ -0,0 +1,44 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _cl_error_h_ // NOLINT(build/header_guard)
+#define _cl_error_h_ // NOLINT(build/header_guard)
+
+#include <stdio.h>
+#include <unistd.h>
+#include <asm/unistd.h>
+
+static inline int gettid(void) { // NOLINT(readability/nolint)
+ return (int)syscall(__NR_gettid); // NOLINT(readability/casting)
+}
+
+#define _num_to_str(num) #num
+#define num_to_str(num) _num_to_str(num)
+#define CL_PERROR(msg) \
+ perror(__FILE__ ":" num_to_str(__LINE__)":"msg)
+
+#define CL_ERR_PRINT(fmt, args...) \
+ fprintf(stderr, "[ERR]%d %s:%d:"fmt"\n", gettid(), __func__, __LINE__, ##args)
+
+#if defined(CL_DBG_ENABLE)
+#define CL_DBG_PRINT(fmt, args...) \
+ fprintf(stdout, "[DBG]%d %s:%d:"fmt"\n", gettid(), __func__, __LINE__, ##args)
+#else
+#define CL_DBG_PRINT(fmt, args...)
+#endif
+
+
+#endif // #ifndef _cl_error_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/cl_lock_internal.h b/nsframework/common_library/client/include/cl_lock_internal.h
new file mode 100644
index 00000000..7a2f623c
--- /dev/null
+++ b/nsframework/common_library/client/include/cl_lock_internal.h
@@ -0,0 +1,55 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _cl_lock_internal_h_ // NOLINT(build/header_guard)
+#define _cl_lock_internal_h_ // NOLINT(build/header_guard)
+
+#include <native_service/cl_lockid.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file cl_lock_internal.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+#define LOCKFILE_NAME "lockfile" // lock file name
+#define SLOT_SIZE 4096 // slot size
+#define LOCKFILE_SIZE SLOT_SIZE * LID_NUM // the lock file size
+
+#define LOCK_TIMEOUT 3 // timeout(sec) for CL_LockTimedGet
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef _cl_lock_internal_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/cl_monitor_internal.h b/nsframework/common_library/client/include/cl_monitor_internal.h
new file mode 100644
index 00000000..0a864a21
--- /dev/null
+++ b/nsframework/common_library/client/include/cl_monitor_internal.h
@@ -0,0 +1,30 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _cl_monitor_internal_h_ // NOLINT(build/header_guard)
+#define _cl_monitor_internal_h_ // NOLINT(build/header_guard)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int cl_monitor_cleanup(int pid); // NOLINT(readability/nolint)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ifndef _cl_monitor_internal_h_ */
diff --git a/nsframework/common_library/client/include/cl_process_internal.h b/nsframework/common_library/client/include/cl_process_internal.h
new file mode 100644
index 00000000..ce001de5
--- /dev/null
+++ b/nsframework/common_library/client/include/cl_process_internal.h
@@ -0,0 +1,53 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _cl_process_internal_h_ // NOLINT(build/header_guard)
+#define _cl_process_internal_h_ // NOLINT(build/header_guard)
+
+typedef struct {
+ char name[20];
+ uid_t uid;
+ gid_t gid;
+ int sched_policy;
+ int sched_priority;
+ int create_group;
+ int stack_size;
+ int cpu_assign;
+ int hold_fds[CL_PROCESSS_ATTR_HOLD_FDS_NUM];
+ int disable_close_fds;
+ char cgroup_name[64];
+} CL_ProcessAttrInternal_t;
+
+typedef struct {
+ char name[20];
+} CL_ThreadAttrInternal_t;
+
+typedef struct {
+ int rt_runtime_us;
+ int cfs_quota_us;
+ int cpu_shares;
+ int memory_limit;
+ int usage_in_bytes;
+ int event_fd;
+} CL_ProcessCreateCgroupAttrInternal_t;
+
+#define CL_PROCESS_NAME_ENV "CL_PROCESS_NAME"
+
+#define CL_PROCESS_EXIT_INTERNAL 0x80
+
+#define CL_PROCESS_CGROUP_NAME_FORMAT "CGRP%05d"
+
+#endif // #ifndef _cl_process_internal_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/native_service/cl_lock.h b/nsframework/common_library/client/include/native_service/cl_lock.h
new file mode 100644
index 00000000..d9745405
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/cl_lock.h
@@ -0,0 +1,259 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _cl_lock_h_ // NOLINT(build/header_guard)
+#define _cl_lock_h_ // NOLINT(build/header_guard)
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file cl_lock.h
+ * @brief \~english This file contains the base api of cl_clock.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockSystemInit
+/// \~english @par Brief
+/// Initialize the system lock.
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - On system call shm_open error, -1 is returned.
+/// - On system call ftrancate error, -1 is returned.
+/// - On system call mmap error, -1 is returned.
+/// - On system call pthread_mutexattr_setpshared error, -1 is returned.
+/// \~english @par Detail
+/// This function will generate the Lock file, and initialize all the pthread_mutex_t slots.\n
+/// This function must to be called in the system once, which is recommended on the SystemManager start.\n
+/// \~english @par
+/// Lock file is formed with lots of slots. Every slot occupies 4KB.
+/// The slot layout is:
+/// 0 ~ 4Byte : field of PID
+/// 4Byte ~ 28Byte : field of pthread_mutex_t
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int32_t CL_LockSystemInit(void); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockProcessInit
+/// \~english @par Brief
+/// Initialize the process Lock file.
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// Should call CL_LockSystemInit() to generate Lock file.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - On system call shm_open error, -1 is returned.
+/// \~english @par Detail
+/// Open the Lock file.\n
+/// If process want to use the Lock, this function should be called.\n
+/// It is recommended that this function should be called since start main function.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int32_t CL_LockProcessInit(void); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockMap
+/// \~english @par Brief
+/// Mapping the Lock information address.
+/// \~english @param [in] lid
+/// int32_t - LockID of the Lock used.(0~LID_NUM) \n
+/// \~english @retval addr Lock address
+/// \~english @retval MAP_FAILED Error (errno)
+/// \~english @par Prerequisite
+/// Should call CL_LockSystemInit(), CL_LockProcessInit() to open the Lock file.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - If LockID(lid) < 0, errno is set as EINVAL, and MAP_FAILED is returned
+/// - If LockID(lid) > LID_NUM, errno is set as EINVAL, and MAP_FAILED is returned
+/// - If systemcall mmap is failure, errno is set euqal with the errno of mmap, and MAP_FAILED is returned
+/// \~english @par Detail
+/// Mapping the Lock information to the memory.\n
+/// The related LockID should be assigned, when apply the share memory.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// CL_LockUnmap
+////////////////////////////////////////////////////////////////////////////////////
+void *CL_LockMap(int32_t lid); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockUnmap
+/// \~english @par Brief
+/// Unmapping the Lock information.
+/// \~english @param [in] addr
+/// void* - Lock information address.
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// Should call CL_LockSystemInit(), CL_LockProcessInit() before this function is called
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - If systemcall munmap is failure, errno is set euqal with the errno of munmap, -1 is returned
+/// \~english @par Detail
+/// 0 would be returned, even if not get the Lock.
+/// The addr is the Lock information address that acquired from CL_LockMap.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// CL_LockMap
+////////////////////////////////////////////////////////////////////////////////////
+int32_t CL_LockUnmap(void *addr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockGet
+/// \~english @par Brief
+/// Get the Lock. Block until get the Lock.
+/// \~english @param [in] addr
+/// void* - Lock information address.
+/// \~english @retval 0 Success
+/// \~english @retval EINVAL Invalid parameter
+/// \~english @retval EDEADLK Mutex already locked
+/// \~english @par Prerequisite
+/// Should call CL_LockMap to get the Lock information address.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - EINVAL as the parameter of Lock information address is NULL
+/// - EINVAL as the parameter of Lock information address is MAP_FAILED
+/// - EINVAL as the mutex does not be initialized in the systemcall pthread_mutex_lock failure.
+/// - EDEADLK as the current thread already owns the mutex in the systemcall pthread_mutex_lock failure.
+/// \~english @par Detail
+/// Get the Lock until other threads release it.
+/// It will be deadlock if the current thread already owns the mutex.
+/// The addr is the Lock information address that should be acquired from CL_LockMap.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// CL_LockRelease
+////////////////////////////////////////////////////////////////////////////////////
+int32_t CL_LockGet(void *addr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockNowait
+/// \~english @par Brief
+/// Try to get Lock, shall immediately return.
+/// \~english @param [in] addr
+/// void* - Lock information address.
+/// \~english @retval 0 Success
+/// \~english @retval EINVAL Invalid parameter
+/// \~english @retval EBUSY Busy
+/// \~english @par Prerequisite
+/// Should call CL_LockMap to get the Lock information address.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - EINVAL as input parameter addr, the Lock information address is NULL
+/// - EINVAL as input parameter addr, the Lock information address if MAP_FAILED
+/// - EINVAL as the mutex does not be initialized in the systemcall pthread_mutex_trylock failure.
+/// - EBUSY as the mutex could not be acquired as it was already locked in the
+/// systemcall pthread_mutex_trylock failure.
+/// \~english @par Detail
+/// The addr is the Lock information address that should be acquired from CL_LockMap.
+/// Get the Lock information from the pointed share memory.
+/// Shall immediately return while not acquire the Lock.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// CL_LockRelease
+////////////////////////////////////////////////////////////////////////////////////
+int32_t CL_LockNowait(void *addr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_LockRelease
+/// \~english @par Brief
+/// Release the Lock.
+/// \~english @param [in] addr
+/// addr - Lock information address.
+/// \~english @retval 0 Success
+/// \~english @retval EINVAL Invalid parameter
+/// \~english @retval EPERM The current thread does not own the mutex
+/// \~english @par Prerequisite
+/// - Should call CL_LockMap to get the Lock information address.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - EINVAL as input parameter addr, the Lock information address is NULL
+/// - EINVAL as input parameter addr, the Lock information address if MAP_FAILED
+/// - EINVAL as the mutex does not be initialized in the systemcall pthread_mutex_unlock failure.
+/// - EPERM as the current thread does not own the mutex in the systemcall pthread_mutex_unlock failure.
+/// \~english @par Detail
+/// 0 would be returned, even if not get the Lock.
+/// The addr is the Lock information address that should be acquired from CL_LockMap.
+/// Release the Lock related with the share memory.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// CL_LockGet, CL_LockNowait
+////////////////////////////////////////////////////////////////////////////////////
+int CL_LockRelease(void *addr); // NOLINT(readability/nolint)
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+#define LOCK_POS_MTX_RSV 40
+#define LOCK_HRDS_RSV 15
+#define LOCK_NSLOG_ACCES_IF_RSV 50
+#define LID_NUM 140
+#endif // #ifndef _cl_lock_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/native_service/cl_lockid.h b/nsframework/common_library/client/include/native_service/cl_lockid.h
new file mode 100644
index 00000000..a790a4bb
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/cl_lockid.h
@@ -0,0 +1,180 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file cl_lockid.h
+ * @brief Definition of LockID(LID)
+ *
+ */
+
+#ifndef _cl_lockid_h_ // NOLINT(build/header_guard)
+#define _cl_lockid_h_ // NOLINT(build/header_guard)
+#include <native_service/cl_lock.h>
+#include <assert.h>
+
+/**
+ * @file cl_lockid.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+/*
+ * Numbering rules
+ * Assign LID corresponding to the Lock name specified when requesting shared memories.
+ */
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup ENUM_LOCK_ID
+/// \~english @par Brief
+/// ID for Exclusive Control\n
+/// When AGL users add their own definitions, add "_**" to the definitions.\n
+/// ("**" is an aribitrary character string indicating the organization that uses AGL.)
+/////////////////////////////////////////////////////////////////////////////////////
+
+typedef enum {
+// LID_TEST_1 = 0,
+// LID_TEST_2,
+ LOCK_ANA_LOG_SEM = 0, /* Exclusive Control to store application log on kernel unmanaged RAM*/
+ LOCK_POS_MTX_1, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_2, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_3, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_4, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_5, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_6, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_7, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_8, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_9, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_10, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_11, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_12, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_13, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_14, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_15, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_16, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_17, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_18, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_19, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_20, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_21, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_22, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_23, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_24, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_25, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_26, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_27, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_28, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_29, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_30, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_31, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_32, /* Exclusive Control between POSITIONING and others */
+ LOCK_POS_MTX_MAX, /* Exclusive Control between POSITIONING and others MAX */
+ LOCK_CLOCK_SEM_TZ = (LOCK_POS_MTX_1+LOCK_POS_MTX_RSV), /* Access control to shared memory for TimeZone */
+ LOCK_SEC_DATA_PROTECT, /* Exclusive control to shared memory for the application that use the security chip. */
+ LOCK_OS_SEM_ID__CWORD68_, /* Exclusive Control for SSL library. */
+ LOCK_ROM_ACCESS_IF, /* Exclusive access control for system manager nv area */
+ LOCK_BOOT_ACCESS_IF, /* Exclusive access control for system manager nor area */
+ LOCK_RAM_ACCESS_IF, /* Exclusive access control for system manager drambackup area */
+ LOCK_HRDS_1, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_2, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_3, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_4, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_5, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_6, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_7, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_8, /* Exclusive Control between DataService and others */
+ LOCK_HRDS_MAX, /* Exclusive Control between DataService and others MAX */
+ LOCK_LOGG_ACCESS_IF = (LOCK_HRDS_1+LOCK_HRDS_RSV), /* Exclusive access control for NsLoggerService nv area */
+ LOCK__CWORD76__HMI, /* Exclusive Control between _CWORD76_Service and HMI's */
+ LOCK__CWORD76___CWORD58_, /* Exclusive Control between _CWORD76_Service and _CWORD58_Service */
+ LOCK_DIAGCODE_MEM, /* Exclusive Control to diag code memory area */
+ LOCK_MOUNTER_MOUNT, /* Exclusive Control for Mount */
+ LOCK_NOR_ERCNT, /* Exclusive access control for NOR erase count information */
+ LOCK_RS_WNG_HIS_LIST_DATA, /* Exclusive Control between RemoteService and RS-HMI. */
+ LOCK_RS_WNG_SCREEN_DATA, /* Exclusive Control between RemoteService and RS-HMI. */
+ LOCK_RS_SCREEN_DATA, /* Exclusive Control between RemoteService and RS-HMI. */
+ LOCK_NSLOG_ACCES_IF_1, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_2, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_3, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_4, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_5, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_6, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_7, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_8, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_9, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_10, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_11, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_12, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_13, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_14, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_15, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_16, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_17, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_18, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_19, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_20, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_21, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_22, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_23, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_24, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_25, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_26, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_27, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_28, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_29, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_30, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_31, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_32, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_33, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_34, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_35, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_36, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_37, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_38, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_39, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_40, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_41, /* Exclusive Control between writing to log file */
+
+ LOCK_NSLOG_ACCES_IF_42, /* Exclusive Control between writing to log file */
+
+ LOCK_NSLOG_ACCES_IF_43, /* Exclusive Control between writing to log file */
+ LOCK_NSLOG_ACCES_IF_MAX, /* Exclusive Control between writing to log file MAX */
+ LOCK_INFOSETTING_REV = (LOCK_NSLOG_ACCES_IF_1+LOCK_NSLOG_ACCES_IF_RSV), /* Exclusive control revision information for managing the settings */
+ LOCK_SUBMENU_SELECT, /* Exclusive control between writing the selection information of the sub-menu*/
+ LOCK_DIAG_SEM1, /* Exclusive Control between DiagService and others */
+ LOCK_DIAG_SEM2, /* Exclusive Control between Collect thread and Upload thread */
+ LID_NUM_MAX /* Number of LockID */
+} ENUM_LOCK_ID;
+
+static_assert(LOCK_POS_MTX_MAX <= (LOCK_POS_MTX_1+LOCK_POS_MTX_RSV), "LOCK_POS_MTX_RSV resource empty. Please change limit and build AGL.");
+static_assert(LOCK_HRDS_MAX <= (LOCK_HRDS_1+LOCK_HRDS_RSV), "LOCK_HRDS_RSV resource empty. Please change limit and build AGL.");
+static_assert(LOCK_NSLOG_ACCES_IF_MAX <= (LOCK_NSLOG_ACCES_IF_1+LOCK_NSLOG_ACCES_IF_RSV), "LOCK_NSLOG_ACCES_IF_RSV resource empty. Please change limit and build AGL.");
+static_assert(LID_NUM_MAX <= LID_NUM, "LOCK_ID resource empty. Please change limit and build AGL.");
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+
+#endif // #ifndef _cl_lockid_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/native_service/cl_monitor.h b/nsframework/common_library/client/include/native_service/cl_monitor.h
new file mode 100644
index 00000000..650492cf
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/cl_monitor.h
@@ -0,0 +1,269 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @brief \~english This file contains the enum,struct and api of cl_monitor.
+ */
+#ifndef _cl_monitor_h_ // NOLINT(build/header_guard)
+#define _cl_monitor_h_ // NOLINT(build/header_guard)
+
+#include <stdint.h>
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor init enum
+/////////////////////////////////////////////////////////////////////////////////////
+typedef enum {
+ CL_MONITOR_INIT_SYSTEM = 0,
+ CL_MONITOR_INIT_USER
+} CL_MonitorInit_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// the struct of Monitor Entry
+/////////////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ uint16_t pid;
+ uint8_t type;
+ uint8_t state;
+
+// uint32_t timeout;
+ time_t timeout;
+ uint32_t id;
+ uint32_t user_data;
+} CL_MonitorEntry_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor type enum
+/////////////////////////////////////////////////////////////////////////////////////
+typedef enum {
+ CL_MONITOR_TYPE_GENERIC = 0,
+ CL_MONITOR_TYPE_RPC
+} CL_MonitorType_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor state enum
+/////////////////////////////////////////////////////////////////////////////////////
+typedef enum {
+ CL_MONITOR_STATE_SLEEP = 0,
+ CL_MONITOR_STATE_RUN
+} CL_MonitorState_t;
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// the struct of Monitor Search
+/////////////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ CL_MonitorEntry_t *entry_list;
+ int entry_num;
+} CL_MonitorSearch_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * @file cl_monitor.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor initialize
+/// \~english @param [in] init_type
+/// CL_MonitorInit_t - the type of initialzation
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+int CL_MonitorInit(CL_MonitorInit_t init_type); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Set Monitor Entry
+/// \~english @param [in] type
+/// CL_MonitorType_t - the type of monitor
+/// \~english @param [in] state
+/// CL_MonitorState_t - the state of monitor
+/// \~english @param [in] timeout
+/// uint32_t - the vlaue of timeout
+/// \~english @param [in] user_data
+/// uint32_t - the user data
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+int CL_MonitorSetEntry(CL_MonitorType_t type, uint32_t id, // NOLINT(readability/nolint)
+ CL_MonitorState_t state, uint32_t timeout,
+ uint32_t user_data);
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Get Monitor Entry
+/// \~english @param [in] type
+/// CL_MonitorType_t - the type of monitor
+/// \~english @param [in] id
+/// uint32_t - the monitor id
+/// \~english @param [out] entry
+/// CL_MonitorEntry_t* - the pointer to monitor entry
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+int CL_MonitorGetEntry(CL_MonitorType_t type, uint32_t id, CL_MonitorEntry_t *entry); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor searth intialize
+/// \~english @param [in] serch
+/// CL_MonitorSearch_t* - the pointor to monitory search
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+int CL_MonitorSearchInit(CL_MonitorSearch_t *serch); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor searth destroy
+/// \~english @param [in] serch
+/// CL_MonitorSearch_t* - the pointor to monitory search
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+int CL_MonitorSearchDestroy(CL_MonitorSearch_t *serch); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// Monitor searth timeout
+/// \~english @param [in] serch
+/// CL_MonitorSearch_t* - the pointor to monitory search
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+int CL_MonitorSearchTimeout(CL_MonitorSearch_t *search); // NOLINT(readability/nolint)
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ifndef _cl_monitor_h_ */ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/native_service/cl_process.h b/nsframework/common_library/client/include/native_service/cl_process.h
new file mode 100644
index 00000000..6a9adbfb
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/cl_process.h
@@ -0,0 +1,1288 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _cl_process_h_ // NOLINT(build/header_guard)
+#define _cl_process_h_ // NOLINT(build/header_guard)
+
+#include <sys/types.h>
+
+#define CL_PROCESSS_ATTR_HOLD_FDS_NUM 8
+
+#define CL_INTFY_FILENAME_FORMAT "/tmp/intfy_%05d"
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessAttr_t
+/// \~english @par Brief
+/// Process attribute structure
+/////////////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ char body[148]; ///< process attribute
+} CL_ProcessAttr_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCleanupInfo_t
+/// \~english @par Brief
+/// Child-process attribute structure
+/////////////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ pid_t pid; ///< child-process ID
+ int code; ///< signal code
+ int status; ///< end status or signal
+} CL_ProcessCleanupInfo_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessSchedPolicy_t
+/// \~english @par Brief
+/// Schedule policy
+/////////////////////////////////////////////////////////////////////////////////////
+typedef enum {
+ CL_PROCESS_SCHED_POLICY_OTHER = 0, ///< TSS
+ CL_PROCESS_SCHED_POLICY_RR, ///< Round robin
+ CL_PROCESS_SCHED_POLICY_FIFO, ///< FIFO
+} CL_ProcessSchedPolicy_t;
+
+typedef struct {
+ char body[20];
+} CL_ThreadAttr_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttr_t
+/// Cgroup attribute structure
+/////////////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ char body[24]; ///< Cgroup attribute
+} CL_ProcessCreateCgroupAttr_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * @file cl_process.h
+ * @brief \~english This file contains the base api,enum and struct of cl_process.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessInit
+/// \~english @par Brief
+/// Initialize the process
+/// \~english @retval int file descriptor
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Failed to set up process prctl, -1 is returned.
+/// - Failed to set the signal set to the empty set sigemptyset, -1 is returned.
+/// - Failed to add a signal to the signal mask sigaddset, -1 is returned.
+/// - Failed to set sigprocmask, -1 is returned.
+/// - Failed to create a scripter in the file for signal acceptance signalfd, -1 is returned.
+/// \~english @par Detail
+/// This API must be called before createing a thread.
+/// Therefore, it is recommended that this API be called from within the main() function immediately after the API started.\n
+/// Initialize the process.\n
+/// The retuen value fd is assumed to be poll/select and used for waiting for event.\n
+/// An ready occurs when the child process terminates.\n
+/// Call process name setting(\ref CL_ProcessCreateAttrSetName) uniformly
+/// because it is applied only to the number of architecture after exec.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessInit(void); // NOLINT(readability/nolint)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreate
+/// \~english @par Brief
+/// Create the process
+/// \~english @param [in] file
+/// const char* -
+/// \~english @param [in] argv[]
+/// char* const -
+/// \~english @param [in] envp[]
+/// char* const
+/// \~english @param [in] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval int Success(PID)
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Need to be running CL_ProcessInit.
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the executable name (file) in the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the ARG parameter (argv[]) in the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When memory (malloc) of the data storagee area of the environment variable parameter (envp[]) specified
+/// by the arguments fails, set errno to EINVAL, -1 is returned.
+/// - When memory (malloc) of the data control area of the environment variable parameter (envp[]) specified
+/// by the arguments fails, set errno to EINVAL, -1 is returned.
+/// - Process creation (fork) fail, -1 is returned.
+/// - Process CPU affinity masking (sched_setaffinity) fail, -1 is returned.
+/// - When the character string output processing (snprintf) for process creation fail, -1 is returned.
+/// - When the character string output processing (snprintf) for PID setting of cgroup fail, -1 is returned.
+/// - Failure to allocate the area fo sstoring the path name of cgroup (malloc), -1 is returned.
+/// - Failure to open file descriptor (open) of cgroup, -1 is returned.
+/// - Failure to write file descriptor (write) of cgroup, -1 is returned.
+/// \~english @par Detail
+/// - This API must be called before createing a thread.
+/// \~english @par
+/// Create the process.\n
+/// The ARG parameter (argv[]) specified in the argment must satisfy the following conditions:\n
+/// - Can not be omitted.\n
+/// - The first argument must specify a pointer o the filename to be executed.\n
+/// - An array of pointer to NULL terminated strings.\n
+/// - Arrays must be terminated by NULL pointer.\n
+/// \~english @par
+/// Enviroment-variable parameters (envp[]) specified in arguments mus satisfy the following condiions:\n
+/// - When NULL is specified, the parent process inherits the parent process's environment variables.\n
+/// - An array of pointer to NULL terminated strings.\n
+/// - Arrays must be terminated by NULL pointer.\n
+/// \~english @par
+/// Be aware of the following.\n
+/// - Processing continues without interrupting event if setrlimit() fail.\n
+/// - System call access() checks whether or not there is access privilege,
+/// but returns PID regardless of the access privilege status.
+/// (If the process does not have access privilege, 100 retries are executed at 100 microseconds.)
+/// \~english @par
+/// Since the process attribute of a process cannot be changed during processing,
+/// if it is necessary to change the process attribute,
+/// it is necessary to call the following API and change the process attribute before calling this API.\n
+/// - CL_ProcessCreateAttrInit Initialize process attribute
+/// - CL_ProcessCreateAttrSetCgroup Setting process attribute (Cgroup)
+/// - CL_ProcessCreateAttrSetDisableCloseFds Setting process attribute (stop compulsion FD close)
+/// - CL_ProcessCreateAttrSetGid Setting process attribute (group ID)
+/// - CL_ProcessCreateAttrSetGroup Setting process attribute (process group)
+/// - CL_ProcessCreateAttrSetHoldFds Setting process attribute (maintain FD)
+/// - CL_ProcessCreateAttrSetName Setting process attribute (process name)
+/// - CL_ProcessCreateAttrSetSchedule Setting process attribute (schedule policy and priority)
+/// - CL_ProcessCreateAttrSetStackSize Setting process attribute (Stack Size)
+/// - CL_ProcessCreateAttrSetUid Setting process attribute (user ID)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// CL_ProcessTerminate, CL_ProcessTerminateGroup
+/// CL_ProcessCreateAttrInit, CL_ProcessCreateAttrSetCgroup,
+/// CL_ProcessCreateAttrSetDisableCloseFds, CL_ProcessCreateAttrSetGid,
+/// CL_ProcessCreateAttrSetGroup, CL_ProcessCreateAttrSetHoldFds,
+/// CL_ProcessCreateAttrSetName, CL_ProcessCreateAttrSetSchedule,
+/// CL_ProcessCreateAttrSetStackSize, CL_ProcessCreateAttrSetUid
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreate(const char *file, char * const argv[], char * const envp[], // NOLINT(readability/nolint)
+ const CL_ProcessAttr_t *attr);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrInit
+/// \~english @par Brief
+/// Initialize process attribute
+/// \~english @param [out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Initilize the CL_ProcessAttr_t structure that stores process attribute.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method(Async) / Fire and Forget / Broadcast / Sync / Set Get / Open Close / Request Notify / No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrInit(CL_ProcessAttr_t *attr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetName
+/// \~english @par Brief
+/// Set process name in process attribute
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] name
+/// const char* - process name (max length 16byte)
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When the pointer (name) to the character string hat stores the process name specified
+/// by the argument is NULL, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process name to process attribute.\n
+/// The charactr string that stores the process name specified by the argument must satisfy the following conditions:\n
+/// - Terminated by a NULL.\n
+/// - The maximum lengthof character string is 16 byte including the termination character.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetName(CL_ProcessAttr_t *attr, const char *name); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetUid
+/// \~english @par Brief
+/// Set process attribute to user ID
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] uid
+/// uid_t - user ID
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to user ID.\n
+/// When UINT_MAX is set for the user ID,
+/// the user ID is set to 0 in the process attribute in the processing of CL_ProcessCreate().\n
+/// When 0 is set for the user ID,
+/// it is not reflected in the process attribute becose if is played by the process of CL_ProcessCreate().\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetUid(CL_ProcessAttr_t *attr, uid_t uid); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetGid
+/// \~english @par Brief
+/// Set process attribute to group ID
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] gid
+/// gid_t - Group ID
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to group ID.\n
+/// When 0 is set for the group ID,
+/// it is not reflected in the process attribute becose if is played by the process of CL_ProcessCreate().\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetGid(CL_ProcessAttr_t *attr, gid_t gid); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetSchedule
+/// \~english @par Brief
+/// Set process attribute to schedule policy and priority
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] policy
+/// CL_ProcessSchedPolicy_t - schedule policy
+/// \~english @param [in] priority
+/// int - priority
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @par
+/// enum CL_ProcessSchedPolicy_t Variable
+/// \~english @code
+/// typedef enum {
+/// CL_PROCESS_SCHED_POLICY_OTHER = 0, // TSS
+/// CL_PROCESS_SCHED_POLICY_RR, // Round-robin
+/// CL_PROCESS_SCHED_POLICY_FIFO, // FIFO
+/// } CL_ProcessSchedPolicy_t;
+/// @endcode
+/// \~english @par
+/// target to priority
+/// - -20~19 : CL_PROCESS_SCHED_POLICY_OTHER
+/// - 1~99 : CL_PROCESS_SCHED_POLICY_RR or CL_PROCESS_SCHED_POLICY_FIFO
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When the schedule policy (policy) specified in the parameter is CL_PROCESS_SCHED_POLICY_RR
+/// and the priority (priority) is other than 1 to 99, set errno to EINVAL, -1 is returned.
+/// - When the schedule policy (policy) specified in the parameter is CL_PROCESS_SCHED_POLICY_FIFO
+/// and the priority (priority) is other than 1 to 99, set errno to EINVAL, -1 is returned.
+/// - Incorrect parameters are specified for the schedule policy (policy) specified in the arguments,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to schedule policy and priority.\n
+/// Error occur if the real-time schedule policy is set and
+/// the priority is passed value outside the range of 1-99.\n
+/// In the case of TSS, an error does not occur even if it is outside the range of -20 to 19,
+/// but ti is rounded to the nearest integer by a system call when a process is created.\n
+/// If not set by this funtion, the schedule policy set the TSS and priority sets 0.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetSchedule(CL_ProcessAttr_t *attr, // NOLINT(readability/nolint)
+ CL_ProcessSchedPolicy_t policy,
+ int priority);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetGroup
+/// \~english @par Brief
+/// Set process attribute to process group
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] create
+/// int - (0 or 1)
+/// \~english @par
+/// - 1 make
+/// - 0 not make(default)
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When a value oher than 0 or 1 is secified for the process group cration flag (create)
+/// specified in the parameter, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to process group.\n
+/// When a process group is created, all descendant process fork from child process also belong
+/// to the same process group, and the entire process group can be forcibly terminated.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetGroup(CL_ProcessAttr_t *attr, int create); // NOLINT(readability/nolint)
+
+int CL_ProcessCreateAttrSetCpuAssign(CL_ProcessAttr_t *attr, int cpu_assign); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetStackSize
+/// \~english @par Brief
+/// Set process attribute to stack size
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] stack_size
+/// int - stack size(byte)
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to stack size.\n
+/// The muximum configurable stack size is 1MB.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetStackSize(CL_ProcessAttr_t *attr, int stack_size); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetHoldFds
+/// \~english @par Brief
+/// Set process attribute to FD to maintain
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] hold_fds[]
+/// int -
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When the array (hode_openfd[]) storing the list of the FD to be maintained specified
+/// by the arguments is NULL, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to FD to maintain.\n
+/// When nothing is set, FD other than 0, 1, and 2 are automatically close.\n
+/// For hold_openfds is stored in a CL_PROCESSS_ATTR_HOLD_FDS_NUM array,
+/// it is recommended that int hold_openfds[CL_PROCESSS_ATTR_HOLD_FDS_NUM] be used.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetHoldFds(CL_ProcessAttr_t *attr, int hold_fds[]); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetDisableCloseFds
+/// \~english @par Brief
+/// Set process attribute to suspend forced FD close
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to suspend forced FD close.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetDisableCloseFds(CL_ProcessAttr_t *attr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateAttrSetCgroup
+/// \~english @par Brief
+/// Set process attribute to Cgroup
+/// \~english @param [in,out] attr
+/// const CL_ProcessAttr_t* - Process attribute pointer
+/// \~english @param [in] cgroup_name
+/// const char* - Cgroup name
+/// \~english @par
+/// CL_ProcessAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[148];
+/// } CL_ProcessAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateAttrInit.
+/// - cgroup specified by CL_ProcessCreateCgroupCreate() has been created.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When the pointer (name) to the character string hat stores the process name specified
+/// by the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the character string length of the character string (cgroup_name) storing the process name specified
+/// by the argument is 64 byte or more, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set process attribute to Cgroup.\n
+/// Creat new Cgroup with CL_ProcessCreateCgroupCreate().\n
+/// An error occurs if an Cgroup name that does not exist is specified.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateAttrSetCgroup(CL_ProcessAttr_t *attr, // NOLINT(readability/nolint)
+ const char *cgroup_name);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessTerminate
+/// \~english @par Brief
+/// Kill the process
+/// \~english @param [in] pid
+/// pid_t - PID
+/// \~english @retval int file descriptor
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - CL_ProcessInit and CL_ProcessCreate must be running.
+/// (Process ID to be forcibly terminated exists)
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the process ID to be forcibly terminated does not exist, -1 is returned.
+/// \~english @par Detail
+/// The PID of the process is he return value (PID) of CL_ProcessCreate().
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// CL_ProcessCreate
+/////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessTerminate(pid_t pid); // NOLINT(readability/nolint)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessTerminateGroup
+/// \~english @par Brief
+/// Kill process group
+/// \~english @param [in] pid
+/// pid_t - process group ID
+/// \~english @retval int file descriptor
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - CL_ProcessInit and CL_ProcessCreate must be running.
+/// (Process ID to be forcibly terminated exists)
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the process ID to be forcibly terminated does not exist, -1 is returned.
+/// \~english @par Detail
+/// The process group ID is he return value (PID) of CL_ProcessCreate().
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// CL_ProcessCreate
+/////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessTerminateGroup(pid_t pid); // NOLINT(readability/nolint)
+
+int CL_ProcessAbort(pid_t pid); // NOLINT(readability/nolint)
+
+int CL_ProcessAbortGroup(pid_t pid); // NOLINT(readability/nolint)
+
+int CL_ProcessEuthanizeGroup(pid_t pid); // NOLINT(readability/nolint)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCleanup
+/// \~english @par Brief
+/// Collect child process
+/// \~english @param [in] sigchld_fd
+/// int - CL_ProcessInit() function return to fd
+/// \~english @param [out] cleanup_info
+/// CL_ProcessCleanupInfo_t* - Pointer to chiled process info
+/// \~english @par
+/// CL_ProcessCleanupInfo_t struct
+/// \~english @code
+/// typedef struct {
+/// pid_t pid; /* The process ID of the child. */
+/// int code; /* signal code */
+/// int status; /* the exit status of the child or the signal */
+/// } CL_ProcessCleanupInfo_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval 1 Success
+/// (If WNOHANG was specified and no child(ren) specified by id has yet changed state)
+/// \~english @retval -1 Error (setting to errno)
+/// \~english @par Prerequisite
+/// - Must be runnning CL_ProcessInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer (cleanup_info) to the child process information structure is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When a systemu call (waitid) fails, -1 is returned.
+/// - When there are no child process in state waitable, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// This API must be called before createing a thread.\n
+/// \~english @par
+/// It must be called many times while the return valu is 1.
+/// After the return value reaches 0, calling it again results in an error (ECHILD).\n
+/// The code of CL_ProcessCleanupInfo_t cotains the following value:\n
+/// - CLD_EXITED : Finished child process (exited)
+/// - CLD_KILLED : Killed child process
+/// - CLD_DUMPED : Ended abnormally child process
+/// - CLD_TRAPPED : Trapped traced child process
+/// - CLD_STOPPED : Stopped child process (stop)
+/// - CLD_CONTINUED restarted the sopped child process (after Linux 2.6.9)
+/// - The exit status is stored in status only when code is CLD_EXITED. Otherwise, signals are stored.
+/// - Need to include signal.h to use CLD_*.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCleanup(int sigchld_fd, CL_ProcessCleanupInfo_t *cleanup_info); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ThreadCreate
+/// \~english @par Brief
+/// Create thread
+/// \~english @param [out] thread
+/// pthread_t* - thread hadle
+/// \~english @param [in] attr
+/// pthread_attr_t* - Thread attibute pointer for pthread
+/// \~english @param [in] cl_attr
+/// CL_ThreadAttr_t* - Tred attribute pointer for expansion
+/// \~english @param [in] start_routine
+/// void*(*)(void*) - Pointer to the entry function of the thread
+/// \~english @param [in] arg
+/// void* - Argument to the entry function of the thread
+/// \~english @par
+/// CL_ThreadAttr_t structure
+/// \~english @code
+/// typedef struct {
+/// char body[20];
+/// } CL_ThreadAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error (set errno)
+/// \~english @retval EAGAIN failure to create thread
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the thread handler (thread) specified in the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the pointer of the thread attribute specified in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When the pointer (start_routine) of the entry function of the thread specified by the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - Failure to initialize semaphore, set errno to sem_init, -1 is returned.
+/// - Failure to create thread (pthread_create), EAGAIN is returned.
+/// - Failure to rock semaphore (sem_wait), set errno to sem_init, -1 is returned.
+/// \~english @par Detail
+/// Create thread.\n
+/// The extension thread attribute (cl_attr) is used o assign the thread name set
+/// by CL_ThreadCreateAttrSetName(CL_ThreadAttr_t*, const char*).\n
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ThreadCreate(pthread_t *thread, pthread_attr_t *attr, // NOLINT(readability/nolint)
+ CL_ThreadAttr_t *cl_attr, void *(*start_routine)(void *),
+ void *arg);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ThreadCreateAttrInit
+/// \~english @par Brief
+/// Initialize thread attribute
+/// \~english @param [out] attr
+/// CL_ThreadAttr_t* - thread attribute pointer
+/// \~english @par
+/// CL_ThreadAttr_t structure
+/// \~english @code
+/// typedef struct {
+/// char body[20];
+/// } CL_ThreadAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error (set errno)
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer (attr) of the thread attributespecified by the argument is NULL, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Initialize structure CL_ThreadAttr_t that stores threade attribute.\n
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ThreadCreateAttrInit(CL_ThreadAttr_t *attr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ThreadCreateAttrSetName
+/// \~english @par Brief
+/// Set thread attribute to thread name
+/// \~english @param [out] attr
+/// CL_ThreadAttr_t* - thread attribute pointer
+/// \~english @param [in] name
+/// const char* - Pointer to the string storing the thread name (max length 16byte)
+/// \~english @par
+/// CL_ThreadAttr_t structure
+/// \~english @code
+/// typedef struct {
+/// char body[20];
+/// } CL_ThreadAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error (set errno)
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer (attr) of thread attribute specified by the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the pointer (name) to the character string that stores the thread name specified
+/// by the argument is NULL, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Set thread attribute to thread name\n
+/// The characer string that stores the thread name specified by the argument must satisfy the following conditions:\n
+/// - Terminated by a NULL.\n
+/// - The maximum lengthof character string is 16 byte including the termination character.\n
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ThreadCreateAttrSetName(CL_ThreadAttr_t *attr, const char *name); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupCreate
+/// \~english @par Brief
+/// Create Cgroup
+/// \~english @param [in] cgroup_name
+/// const char* - cgroup name
+/// \~english @param [in] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribut
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr by CL_ProcessCreateCgroupAttrInit
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the Cgroup name (cgroup_name) specified by the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the pointer (attr) of the Cgroup attribute specified by the argumet is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When the area for directory path name of the CPU subsystem of Cgroup could not be allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When the area for directory of the CPU subsystem of Cgroup could not be create, -1 is returned.
+/// - When the area for file path name of the CPU subsystem of Cgroup could not be allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When file descriptor of the CPU subsystem of Cgroup could not be acquired, -1 is returned.
+/// - When setting value to CPU subsystem of Cgroup could not be written, -1 is returned.
+/// - When the area for directory path name of the memory subsystem of Cgroup could not be allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When the area for directory of the memory subsystem of Cgroup could not be create, -1 is returned.
+/// - When the area for file path name of the memory subsystem of Cgroup could not be allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When file descriptor of the memory subsystem of Cgroup could not be acquired, -1 is returned.
+/// - When setting value to memory subsystem of Cgroup could not be written, -1 is returned.
+/// \~english @par Detail
+/// Create Cgroup to which the process to be created belongs.
+/// If it belongs to Cgroup that has already been created, it is not necessary to create it.\n
+/// \~english @par
+/// Since the Cgroup attribute cannot be changed during Cgroup, if it is necessary o chage the Cgroup attribute,
+/// it is necessary to call the following API and change the Cgroup attribute calling this API.\n
+/// - CL_ProcessCreateCgroupAttrInit :Initialize Cgroup attribute
+/// - CL_ProcessCreateCgroupAttrSetCfsBandwidthControl :TSS process CPU time control by Bandwidth Control
+/// - CL_ProcessCreateCgroupAttrSetCpuShares :TSS process CPU time control
+/// - CL_ProcessCreateCgroupAttrSetMemoryLimit :Contol memory usage
+/// - CL_ProcessCreateCgroupAttrSetMemoryUsageNotification :Memory usage notification setting
+/// - CL_ProcessCreateCgroupAttrSetRtThrottling :FIFO/RR process CPU time control
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// CL_ProcessCreateCgroupDelete,
+/// CL_ProcessCreateCgroupAttrInit, CL_ProcessCreateCgroupAttrSetCfsBandwidthControl,
+/// CL_ProcessCreateCgroupAttrSetCpuShares, CL_ProcessCreateCgroupAttrSetMemoryLimit,
+/// CL_ProcessCreateCgroupAttrSetMemoryUsageNotification, CL_ProcessCreateCgroupAttrSetRtThrottling,
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupCreate(const char *cgroup_name, // NOLINT(readability/nolint)
+ CL_ProcessCreateCgroupAttr_t *attr);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttrInit
+/// \~english @par Brief
+/// Initialize Cgroup attribute
+/// \~english @param [out] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of Cgroup attribute (attr) specified in the arguments is NULL, set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Initialize Cgroup attibute with 0.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupAttrInit(CL_ProcessCreateCgroupAttr_t *attr); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttrSetRtThrottling
+/// \~english @par Brief
+/// Set FIFO/RR process CPU time control
+/// \~english @param [in,out] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute
+/// \~english @param [in] runtime_us
+/// int - CPU allocation time(us)
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateCgroupAttrInit.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of Cgroup attribute (attr) specified in the arguments is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Limiting the CPU time allocated to a process to
+/// which a real-time class schedule policy (SCHED_FIFO/SCHED_RR) is applied.\n
+/// Set the value of argument runtime_us to the cpu.rt_runtime_us (CPU allocation time) of created Cgroup.\n
+/// cpu.rt_period_us(unit time:1000000us) is not changed.\n
+/// If not set, Cgroup created will remain at default (CPU allocation time:950000us).\n
+/// The configurable range of runtime_us depends on the use of Cgroup and the kernel version.
+/// The user sets an appropriate value.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupAttrSetRtThrottling( // NOLINT(readability/nolint)
+ CL_ProcessCreateCgroupAttr_t *attr, int runtime_us);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttrSetCpuShares
+/// \~english @par Brief
+/// Set TSS process CPU time control
+/// \~english @param [in,out] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
+/// \~english @param [in] cpu_shares
+/// int - An integer value that sepcified the relative distribution of CPU time
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateCgroupAttrInit
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer (attr) of the Cgroup attribute specified by the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Cotrols the CPU time allocated to a process to which
+/// a class TSS schedule policy (SCHED_OTHER, etc.) is applied.\n
+/// If cpu_shares is set with this function, a single Cgroup is created and cpu.shares is set with that value.\n
+/// If not set, remain at default.\n
+/// cpu_shares is set to the standard value 1024, and CPU time is allocated according
+/// to the allocaion value specified between Cgroup.\n
+/// Task Cgroup with cpu.shares set to 1024 has twice as much CPU time as
+/// task Cgroup with cpu.shares set to 512.\n
+/// Processes belonging to the same Cgroup are equally allocated CPU time allocated to Cgroup.\n
+/// Note that the time distribution is distributed across al CPU cores on a multi-core system.\n
+/// In a multicore system, if Cgroup limit is set to 100% of the CPU,
+/// 100% of each CPU core wil be available.\n\n
+/// Examle) If Cgroup A is set to use 25% of the CPU and Cgroup B is set to use 75% of the CPU,\n
+/// and a process that uses CPU intensively is started on a 4-core system (1 process in A and 3 processes in B),\n
+/// the CPU allocaion is distributed as follows.\n\n
+/// \~english @par
+/// | PID | cgroup | CPU | CPU allotment |
+/// |:---:|:------:|:---:|:-------:|
+/// | 100 | A | 0 | CPU0 100% |
+/// | 101 | B | 1 | CPU1 100% |
+/// | 102 | B | 2 | CPU2 100% |
+/// | 103 | B | 3 | CPU3 100% |
+/// \~english @par
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupAttrSetCpuShares(CL_ProcessCreateCgroupAttr_t *attr, // NOLINT(readability/nolint)
+ int cpu_shares);
+
+///////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttrSetCfsBandwidthControl
+/// \~english @par Brief
+/// Set TS process CU time control by Bandwidth Control
+/// \~english @param [in,out] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
+/// \~english @param [in] cfs_quota_us
+/// int - CPU allocation time
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateCgroupAttrInit
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Controls the amount of time allocated to processes o whitch TSS class schedule plicy (SCHED_OTHER, etc.) are
+/// applied using bandwidth control of CFS(Completely Fair Scheduler) implemented from kernel 3.2.\n
+/// Set the value of argument cfs_quota_us to the cpu.cfs_quota_us of created Cgroup.\n
+/// cpu.cfs_period_us(unit time:1000000us) is not changed.\n
+/// If not set, the created Cgroup will not have CPU allocatio control. (set cpu.cfs_guota_us to -1).\n
+/// The time (%) allocated to Cgroup can be set correctly,
+/// and it can be allocated correctly if the CPU is free.\n
+/// It is scheduled to be allocated as much as possible even if it conflicts with other Cgroup's.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupAttrSetCfsBandwidthControl( // NOLINT(readability/nolint)
+ CL_ProcessCreateCgroupAttr_t *attr, int cfs_quota_us);
+
+/////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttrSetMemoryLimit
+/// \~english @par Brief
+/// Control memory usage
+/// \~english @param [in,out] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
+/// \~english @param [in] memory_limit
+/// int - memory limit (byte)
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateCgroupAttrInit
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// Control the CPU time allocated to a process.\n
+/// Set the value of argument memory_limit to the memory.limit_in_bytes of created Cgroup.\n
+/// If not set, there is no memory limit.When a request exceeding the memory limit is issued,
+/// a SIGKILL is sent from the kernel and the process is discarded.
+/// Note: When the memory limit is exceeded, control moves to 00M,
+/// but its operation ca be changed (Documentation/cgroup/memory.txt).\n
+/// Write memory.oom_control to 1 to stop the OOM-Killer.
+/// When OOM-Killer is stopped, the task below Cgroup becomes hang/sleep.\n
+/// The task moves when the limit of the memory Cgroup increaes or when usage decreases. When usage decreases,\n
+/// - Task was killed\n
+/// - Task was moved other group\n
+/// - File has been deleted\n
+/// \~english @par
+/// You can also receive a eventf notification from OOM.\n
+/// Memory usage is counted as follows\n
+/// - RSS(All mapped anon pages)\n
+/// - Page Cache\n
+/// - First acess Shared Pages in Cgroup\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupAttrSetMemoryLimit(CL_ProcessCreateCgroupAttr_t *attr, // NOLINT(readability/nolint)
+ int memory_limit);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupAttrSetMemoryUsageNotification
+/// \~english @par Brief
+/// Set notificatio when memory usage exceeds the specified amount
+/// \~english @param [in,out] attr
+/// const CL_ProcessCreateCgroupAttr_t* - Cgroup attribute pointer
+/// \~english @param [in] usage_in_bytes
+/// int - usage in bytes(byte)
+/// \~english @param [in] event_fd
+/// int - File dexcriptor created by system call eventfd()
+/// \~english @par
+/// CL_ProcessCreateCgroupAttr_t struct
+/// \~english @code
+/// typedef struct {
+/// char body[24];
+/// } CL_ProcessCreateCgroupAttr_t;
+/// @endcode
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Initialize attr with CL_ProcessCreateCgroupAttrInit
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the pointer of the process attribute specified (attr) in the argument is NULL,
+/// set errno to EINVAL, -1 is returned.
+/// - When event_fd is negative for a file descriptor created by system call eventfd(),
+/// set errno to EINVAL, -1 is returned.
+/// \~english @par Detail
+/// event_fd is notifued when memory usage exceeds argument usage_in_bytes.\n
+/// See eventfd for details of event_fd.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupAttrSetMemoryUsageNotification( // NOLINT(readability/nolint)
+ CL_ProcessCreateCgroupAttr_t *attr, int usage_in_bytes, int event_fd);
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupDelete
+/// \~english @par Brief
+/// Delete Cgroup
+/// \~english @param [in] cgroup_name
+/// const char* - cgroup name
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Need to be runnning CL_ProcessCreateCgroupCreate.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the Cgroup (cgroup_name) name specified inthe argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the area for directory path name of the CPU subsystem of Cgroup and
+/// memory subsystem of Cgroup could not be allocated, set errno to EINVAL, -1 is returned.
+/// - When the area for the directory path name of the memory subsystem of Cgroup cannot be allocated and
+/// the directory for the CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
+/// - When the directory for the CPU subsystem of Cgroup does not exist and
+/// the area for the directory path name of the memory subsystem of Cgroup cannot be allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When the directory for the memory subsystem of Cgroup and
+/// the directory for the CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
+/// - When the directory for the memory subsystem of Cgroup could not be deleted, -1 is returned.
+/// - When the directory for the CPU subsystem of Cgroup could not be deleted, -1 is returned.
+/// \~english @par Detail
+/// Delete Cgroup. If there is a proess belonging to Cgroup, error code (EBUSY) is returned.\n
+/// \~english @par
+/// Success is also notified in the following cases:\n
+/// - When the area for directory path name of memory subsyste Cgroup could not be allocated
+/// but CPU subsystem of Cgroup was deleted successfully.
+/// - When the directory for the memory subsystem of Cgroup does not exist,
+/// but CPU subsystem of Cgroup was deleted successfully.
+/// - When the area for directory path name of CPU subsyste Cgroup could not be allocated
+/// but memory subsystem of Cgroup was deleted successfully.
+/// - When the directory for the CPU subsystem of Cgroup does not exist,
+/// but memory subsystem of Cgroup was deleted successfully.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// CL_ProcessCreateCgroupCreate
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupDelete(const char *cgroup_name); // NOLINT(readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup CL_ProcessCreateCgroupClassify
+/// \~english @par Brief
+/// Move process to the Cgroup
+/// \~english @param [in,out] cgroup_name
+/// const char* - Destination A name
+/// \~english @param [in] pid
+/// pid_t - process ID
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// - Need to be running CL_ProcessCreateCgroupCreate.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - When the Cgroup (cgroup_name) specified in the argument is NULL, set errno to EINVAL, -1 is returned.
+/// - When the area for directory path name of memory subsystem of Cgroup and
+/// CPU subsystem of Cgroup could not be allocated, set errno to EINVAL, -1 is returned.
+/// - When the area for directory path name of memory subsystem of Cgroup could not be allocated,
+/// and the directory for CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
+/// - When the directory for memory subsystem of Cgroup does not exist and
+/// the directory for CU subsystem of Cgroup could not allocated , set errno to EINVAL, -1 is returned.
+/// - When the directory for the memory subsystem of Cgroup and
+/// the directory for the CPU subsystem of Cgroup does not exist, set errno to EINVAL, -1 is returned.
+/// - When the area for directory path name of the memory subsystem of Cgroup could not allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When the file descripter for the memory subsystem of Cgroup could not be obtained, -1 is returned.
+/// - When pid could not be written to the file for memory subsystem of Cgroup, -1 is returned.
+/// - When the area for directory path name of the CPU subsystem of Cgroup could not be allocated,
+/// set errno to EINVAL, -1 is returned.
+/// - When the file decsripter for the CPU subsystem of Cgroup could not be allocated, -1 is returned.
+/// - When pid could not be written to the file for CPU subsystem of Cgroup, -1 is returned.
+/// \~english @par Detail
+/// Move process to the Cgroup.\n
+/// \~english @par
+/// Success is also notified in the following cases:\n
+/// - When the area for directory path name of memory subsyste Cgroup could not be allocated
+/// but CPU subsystem of Cgroup was deleted successfully.
+/// - When the directory for the memory subsystem of Cgroup does not exist,
+/// but CPU subsystem of Cgroup was deleted successfully.
+/// - When the area for directory path name of CPU subsyste Cgroup could not be allocated
+/// but memory subsystem of Cgroup was deleted successfully.
+/// - When the directory for the CPU subsystem of Cgroup does not exist,
+/// but memory subsystem of Cgroup was deleted successfully.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////
+int CL_ProcessCreateCgroupClassify(const char *cgroup_name, pid_t pid); // NOLINT(readability/nolint)
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef _cl_process_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/native_service/cl_region.h b/nsframework/common_library/client/include/native_service/cl_region.h
new file mode 100644
index 00000000..c9eec5f3
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/cl_region.h
@@ -0,0 +1,257 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file cl_region.h
+ * @brief region manage
+ *
+ */
+
+#ifndef _CL_REGION_H_ // NOLINT(build/header_guard)
+#define _CL_REGION_H_ // NOLINT(build/header_guard)
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <unistd.h>
+
+#define CL_REGION_DEFAULT_SIZE (4 * 1024)
+
+#define CL_ALIGNOF(type) __alignof(type)
+
+typedef void (*cl_region_cleanup_pt)(void *data);
+
+typedef struct cl_region_cleanup_s cl_region_cleanup_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// region cleanup struct
+/////////////////////////////////////////////////////////////////////////////////////
+struct cl_region_cleanup_s { // NOLINT(readability/nolint)
+ cl_region_cleanup_pt handler;
+ void *data;
+ cl_region_cleanup_t *next;
+};
+
+
+typedef struct cl_region_large_s cl_region_large_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// region large struct
+/////////////////////////////////////////////////////////////////////////////////////
+struct cl_region_large_s { // NOLINT(readability/nolint)
+ cl_region_large_t *next;
+ void *alloc;
+ size_t size;
+};
+
+
+typedef struct cl_region_s cl_region_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// region data struct
+/////////////////////////////////////////////////////////////////////////////////////
+typedef struct {
+ uint8_t *last;
+ uint8_t *end;
+ cl_region_t *next;
+ int failed;
+} cl_region_data_t;
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Monitor
+/// \~english @par Brief
+/// region struct
+/////////////////////////////////////////////////////////////////////////////////////
+struct cl_region_s { // NOLINT(readability/nolint)
+ cl_region_data_t d;
+ size_t max;
+ cl_region_t *current;
+ cl_region_large_t *large;
+ cl_region_cleanup_t *cleanup;
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * @file cl_region.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Region
+/// \~english @par Brief
+/// Region create
+/// \~english @param [in] size
+/// size_t - the size to create
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+cl_region_t *CL_RegionCreate(size_t size); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Region
+/// \~english @par Brief
+/// Region destroy
+/// \~english @param [in] region
+/// cl_region_t * - the region to destroy
+/// \~english @retval 0 Success
+/// \~english @retval -1 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+void CL_RegionDestroy(cl_region_t *region); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Region
+/// \~english @par Brief
+/// Region allocation
+/// \~english @param [in] region
+/// cl_region_t * - the region to allocate
+/// \~english @param [in] size
+/// size_t * - the size to allocate
+/// \~english @param [in] align_size
+/// size_t * - the size to align
+/// \~english @retval the pointer to region allocated
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+#define CL_RegionAlloc(region, type, length) \
+ cl_region_alloc(region, sizeof(type) * length, CL_ALIGNOF(type))
+void *cl_region_alloc(cl_region_t *region, size_t size, size_t align_size); // NOLINT(readability/nolint)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Region
+/// \~english @par Brief
+/// Region free
+/// \~english @param [in] region
+/// cl_region_t * - the region to free
+/// \~english @param [in] p
+/// void * - the pointer to region
+/// \~english @retval true Success
+/// \~english @retval false Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+bool CL_RegionFree(cl_region_t *region, void *p); // NOLINT(readability/nolint)
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Region
+/// \~english @par Brief
+/// add region cleanup
+/// \~english @param [in] region
+/// cl_region_t * - the region to allocate
+/// \~english @param [in] size
+/// size_t * - the size to add
+/// \~english @param [in] align_size
+/// size_t * - the size to align
+/// \~english @retval the pointer to region cleanup added
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+#define CL_RegionCleanupAdd(region, type, length) \
+ cl_region_cleanup_add(region, sizeof(type) * length, CL_ALIGNOF(type))
+cl_region_cleanup_t *cl_region_cleanup_add(cl_region_t *region, size_t size, // NOLINT(readability/nolint)
+ size_t align_size);
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _CL_REGION_H_ */ // NOLINT(build/header_guard)
+
+/* vim:set ts=8 sw=2 sts=2: */
diff --git a/nsframework/common_library/client/include/native_service/cl_sem.h b/nsframework/common_library/client/include/native_service/cl_sem.h
new file mode 100644
index 00000000..9dbe54e4
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/cl_sem.h
@@ -0,0 +1,73 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _cl_sem_h_ // NOLINT(build/header_guard)
+#define _cl_sem_h_ // NOLINT(build/header_guard)
+
+#include <semaphore.h>
+
+#ifdef __cplusplus
+#define EXT_C extern "C"
+#else
+#define EXT_C
+#endif // __cplusplus
+
+/**
+ * @file cl_sem.h
+ * @brief \~english This file contains the api of sem wait.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup Sem
+/// \~english @par Brief
+/// Sem wait
+/// \~english @param [in] semid
+/// sem_t * - the pointer to the union sem_t
+/// \~english @param [in] timeout
+/// unsigned int - the count of timeout
+/// \~english @retval 0 Success
+/// \~english @retval not 0 Error
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @par Detail
+/// None
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EXT_C int CL_SemWait(sem_t *semid, unsigned int timeout); // NOLINT(readability/nolint)
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+#endif // #ifndef _cl_sem_h_ // NOLINT(build/header_guard)
diff --git a/nsframework/common_library/client/include/native_service/common_library.h b/nsframework/common_library/client/include/native_service/common_library.h
new file mode 100644
index 00000000..929d04d6
--- /dev/null
+++ b/nsframework/common_library/client/include/native_service/common_library.h
@@ -0,0 +1,48 @@
+//
+// @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef NATIVESERVICE_COMMONLIBRARY_H_ // NOLINT(build/header_guard)
+#define NATIVESERVICE_COMMONLIBRARY_H_
+
+/**
+ * @file common_library.h
+ * @brief \~english include all common_library head files
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup common_library
+ * @ingroup native_service
+ * @{
+ */
+
+#include <native_service/cl_process.h>
+#include <native_service/cl_sem.h>
+#include <native_service/cl_monitor.h>
+#include <native_service/cl_lock.h>
+#include <native_service/cl_region.h>
+#include <native_service/cl_lockid.h>
+
+
+/** @}*/ // end of common_library
+/** @}*/ // end of NativeService
+/** @}*/ // end of BaseSystem
+
+#endif // NATIVESERVICE_COMMONLIBRARY_H_
diff --git a/nsframework/common_library/client/libcommon.ver b/nsframework/common_library/client/libcommon.ver
new file mode 100644
index 00000000..f89c9ba3
--- /dev/null
+++ b/nsframework/common_library/client/libcommon.ver
@@ -0,0 +1,30 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#
+# CommonLib version script
+#
+{
+ global:
+ ### .text section ###
+ CL_*;
+ cl_region_alloc;
+ cl_region_cleanup_add;
+ ### .data section ###
+ local:
+ *;
+};
+
diff --git a/nsframework/common_library/client/src/cl_cgroup.c b/nsframework/common_library/client/src/cl_cgroup.c
new file mode 100644
index 00000000..812ccaaa
--- /dev/null
+++ b/nsframework/common_library/client/src/cl_cgroup.c
@@ -0,0 +1,260 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <inttypes.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "cl_cgroup.h"
+
+#define CL_CGROOT "/sys/fs/cgroup/"
+
+static char *cl_cgroup_base(cl_cgroup_t cgroup) {
+ switch (cgroup) { // LCOV_EXCL_BR_LINE 200: internal interface,code make sure
+ case CL_CGROUP_MEMORY:
+ return CL_CGROOT "/memory";
+ case CL_CGROUP_CPU:
+ return CL_CGROOT "/cpu";
+ }
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return NULL;// LCOV_EXCL_LINE 200:internal interface,code make sure nerver run
+}
+
+static char *cl_cgroup_create_path(cl_cgroup_t cgroup, const char *cgroup_name, const char *controler) {
+ char *path = malloc(FILENAME_MAX);
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 5:fail safe for libc malloc
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = ENOMEM; // LCOV_EXCL_LINE 5:fail safe for libc malloc
+ goto error; // LCOV_EXCL_LINE 5:fail safe for libc malloc
+ }
+
+ if (cgroup != CL_CGROUP_MEMORY && cgroup != CL_CGROUP_CPU) { // LCOV_EXCL_BR_LINE 200: internal interface,code make sure
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = EINVAL; // LCOV_EXCL_LINE 200: internal interface,code make sure
+ goto error; // LCOV_EXCL_LINE 200: internal interface,code make sure
+ }
+
+ if (cgroup_name == NULL) { // LCOV_EXCL_BR_LINE 200: internal interface,code make sure
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = EINVAL; // LCOV_EXCL_LINE 200: internal interface,code make sure
+ goto error; // LCOV_EXCL_LINE 200: internal interface,code make sure
+ }
+
+ if (controler) {
+ snprintf(path, FILENAME_MAX, "%s/%s/%s", cl_cgroup_base(cgroup), cgroup_name, controler);
+ } else {
+ snprintf(path, FILENAME_MAX, "%s/%s", cl_cgroup_base(cgroup), cgroup_name);
+ }
+
+ return path;
+
+error:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ free(path); // LCOV_EXCL_LINE 200: internal interface,code make sure
+ return NULL; // LCOV_EXCL_LINE 200: internal interface,code make sure
+}
+
+int cl_cgroup_make(cl_cgroup_t cgroup, const char *cgroup_name) {
+ int r = -1;
+ char *path = cl_cgroup_create_path(cgroup, cgroup_name, NULL);
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ goto exit; // LCOV_EXCL_LINE 6: double check
+ }
+
+ if (mkdir(path, 0777) < 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc mkdir
+ goto exit;
+ }
+
+ r = 0;
+
+exit:
+ if (path) {// LCOV_EXCL_BR_LINE 6: double check
+ free(path);
+ }
+ return r;
+}
+
+int cl_cgroup_remove(cl_cgroup_t cgroup, const char *cgroup_name) {
+ int r = -1;
+ char *path = cl_cgroup_create_path(cgroup, cgroup_name, NULL);
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ goto exit; // LCOV_EXCL_LINE 6: double check
+ }
+
+ if (rmdir(path) < 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc rmdir
+ goto exit;
+ }
+
+ r = 0;
+
+exit:
+ if (path) { // LCOV_EXCL_BR_LINE 6: double check
+ free(path);
+ }
+ return r;
+}
+
+int cl_cgroup_exist(cl_cgroup_t cgroup, const char *cgroup_name) {
+ int r = -1;
+ char *path = cl_cgroup_create_path(cgroup, cgroup_name, NULL);
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ goto exit; // LCOV_EXCL_LINE 6: double check
+ }
+
+ r = access(path, F_OK);
+
+exit:
+ if (path) { // LCOV_EXCL_BR_LINE 6: double check
+ free(path);
+ }
+ return r;
+}
+
+int cl_cgroup_open(cl_cgroup_t cgroup, const char *cgroup_name, const char *controler, int flags) {
+ int r = -1;
+ char *path = cl_cgroup_create_path(cgroup, cgroup_name, controler);
+ int fd = -1;
+
+ if (path == NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ goto exit; // LCOV_EXCL_LINE 6: double check
+ }
+
+ if (controler == NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = EINVAL; // LCOV_EXCL_LINE 6: double check
+ goto exit; // LCOV_EXCL_LINE 6: double check
+ }
+
+ if ((fd = open(path, flags | O_CLOEXEC)) < 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc open
+ goto exit;
+ }
+
+ r = fd;
+
+exit:
+ if (path) { // LCOV_EXCL_BR_LINE 6: double check
+ free(path);
+ }
+ return r;
+}
+
+int cl_cgroup_set_string(cl_cgroup_t cgroup, const char *cgroup_name, const char *controler, const char *string) {
+ int r = -1;
+ int fd = -1;
+
+ if (controler == NULL || string == NULL) { // LCOV_EXCL_BR_LINE 6: double check
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = EINVAL;// LCOV_EXCL_LINE 6: double check
+ goto exit;// LCOV_EXCL_LINE 6: double check
+ }
+
+ fd = cl_cgroup_open(cgroup, cgroup_name, controler, O_WRONLY);
+ if (fd < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc funtion open
+ goto exit;
+ }
+
+ if (write(fd, string, strlen(string)) < 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc write
+ goto exit;
+ }
+
+ r = 0;
+
+exit:
+ if (fd >= 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc funtion open
+ int save_err = errno;
+ close(fd);
+ errno = save_err;
+ }
+ return r;
+}
+
+int cl_cgroup_set_num(cl_cgroup_t cgroup, const char *cgroup_name, const char *controler, int64_t value) {
+ char num_str[22];
+
+ snprintf(num_str, sizeof(num_str), "%" PRId64, value);
+
+ return cl_cgroup_set_string(cgroup, cgroup_name, controler, num_str);
+}
+
+int cl_cgroup_get_string(cl_cgroup_t cgroup, const char *cgroup_name, const char *controler, char *string, size_t length) { // LCOV_EXCL_START 8: dead code // NOLINT (readability/nolint)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ int r = -1;
+ int fd = -1;
+
+ if (controler == NULL || string == NULL) {
+ errno = EINVAL;
+ goto exit;
+ }
+
+ fd = cl_cgroup_open(cgroup, cgroup_name, controler, O_RDONLY);
+ if (fd < 0) {
+ goto exit;
+ }
+
+ if (read(fd, string, length) < 0) {
+ goto exit;
+ }
+
+ r = 0;
+
+exit:
+ if (fd >= 0) {
+ int save_err = errno;
+ close(fd);
+ errno = save_err;
+ }
+ return r;
+}
+// LCOV_EXCL_STOP
+
+int64_t cl_cgroup_get_num(cl_cgroup_t cgroup, const char *cgroup_name, const char *controler) { // LCOV_EXCL_START 8: dead code // NOLINT (readability/nolint)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ int r;
+ char num_str[22];
+
+ if ((r = cl_cgroup_get_string(cgroup, cgroup_name, controler, num_str, sizeof(num_str))) < 0) {
+ return r;
+ }
+
+ return atoll(num_str);
+}
+// LCOV_EXCL_STOP
diff --git a/nsframework/common_library/client/src/cl_lock.c b/nsframework/common_library/client/src/cl_lock.c
new file mode 100644
index 00000000..6add2a5a
--- /dev/null
+++ b/nsframework/common_library/client/src/cl_lock.c
@@ -0,0 +1,221 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// #include <stdio.h>
+// #include <stdlib.h>
+#include <errno.h>
+
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <native_service/cl_lock.h>
+#include <native_service/cl_lockid.h>
+#include "cl_lock_internal.h"
+#include "cl_error.h"
+
+static int shm_id = -1;
+
+/*
+ * Lock file is consists of slots(4KB)
+ * The slot layout is:
+ * 0 ~ 4Byte : field of PID
+ * 4Byte ~ 28Byte : field of pthread_mutex_t
+ */
+
+
+static int cl_LockfileInit(void *base) {
+ int i;
+ /*
+ int j;
+ */
+ void *addr;
+ pthread_mutexattr_t attr;
+
+ if (pthread_mutexattr_init(&attr) != 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc pthread_mutexattr_init
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5:fail safe for libc pthread_mutexattr_init
+ }
+ if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED) != 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc pthread_mutexattr_setpshared
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5:fail safe for libc pthread_mutexattr_setpshared
+ }
+// if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP) != 0) {
+// return -1;
+// }
+ if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST) != 0) {
+ return -1;
+ }
+
+ for (i = 0; i < LID_NUM; i++) {
+ /*
+ addr = SLOT_SIZE * 1 + base;
+ for (j = 0; j < 1024; j++) {
+ *(int*)(addr + j * sizeof(int)) = j;
+ }
+ */
+ addr = SLOT_SIZE * i + (char *)base + sizeof(int);
+ pthread_mutex_init((pthread_mutex_t *)addr, &attr);
+
+ }
+ if (pthread_mutexattr_destroy(&attr) != 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc pthread_mutexattr_destroy
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5:fail safe for libc pthread_mutexattr_destroy
+ }
+ return 0;
+}
+
+/*
+ * Initialize in the system
+ * This function will generate the Lock file, and initialize pthread_mutex_t for all slots
+ */
+int CL_LockSystemInit(void) {
+ int fd = -1;
+ int ret = 0;
+ void *base = MAP_FAILED;
+
+ fd = shm_open(LOCKFILE_NAME, O_CREAT | O_EXCL | O_RDWR, (S_IRWXG | S_IRWXO | S_IRWXU));
+ if (fd < 0) {
+ ret = -1;
+ goto exit;
+ }
+ if (ftruncate(fd, LOCKFILE_SIZE) != 0) { // LCOV_EXCL_BR_LINE 5:fail safe for libc ftruncate
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ ret = -1; // LCOV_EXCL_LINE 5:fail safe for libc ftruncate
+ goto exit; // LCOV_EXCL_LINE 5:fail safe for libc ftruncate
+ }
+
+ base = mmap(NULL, LOCKFILE_SIZE, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
+ if (base == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5:fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ ret = -1; // LCOV_EXCL_LINE 5:fail safe for libc mmap
+ goto exit; // LCOV_EXCL_LINE 5:fail safe for libc mmap
+ }
+
+ if (cl_LockfileInit(base) < 0) { // LCOV_EXCL_BR_LINE 11:out branch
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ ret = -1; // LCOV_EXCL_LINE 5:fail safe for libc
+ goto exit; // LCOV_EXCL_LINE 5:fail safe for libc
+ }
+
+exit:
+ if (fd >= 0) {
+ close(fd);
+ }
+ if (base != MAP_FAILED) {
+ munmap(base, LOCKFILE_SIZE);
+ }
+ return ret;
+}
+
+void CL_LockSystemFin_debug(void) {
+ if (shm_id >= 0) {
+ close(shm_id);
+ }
+ shm_unlink(LOCKFILE_NAME);
+ shm_id = -1;
+}
+
+/*
+ * Initialize in the process
+ * Open the Lock file
+ */
+int CL_LockProcessInit(void) {
+ if (shm_id < 0) {
+ shm_id = shm_open(LOCKFILE_NAME, O_RDWR, (S_IRWXG | S_IRWXO | S_IRWXU));
+ }
+ if (shm_id < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function shm_open
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for glibc function shm_open
+ }
+ return 0;
+}
+
+void *CL_LockMap(int lid) {
+ if ((lid < 0) || (lid >= LID_NUM)) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+ return mmap(NULL, SLOT_SIZE, (PROT_READ | PROT_WRITE), MAP_SHARED, shm_id, (off_t)(lid * SLOT_SIZE));
+}
+
+int CL_LockUnmap(void *addr) {
+ return munmap(addr, SLOT_SIZE);
+}
+
+int CL_LockGet(void *addr) {
+ int ret;
+
+ if ((addr == NULL) || (addr == MAP_FAILED)) {
+ ret = EINVAL;
+ } else {
+ CL_DBG_PRINT("@@@@@ %s Start: pid = %d\n", __func__, *(int *)addr);
+ // LCOV_EXCL_BR_START 5:fail safe for libc pthread_mutex_lock
+ if ((ret = pthread_mutex_lock((pthread_mutex_t*)((char *)addr + sizeof(int)))) == 0) {
+ // LCOV_EXCL_BR_STOP
+ *(int *)addr = (int)getpid();
+ } else if (ret == EOWNERDEAD) {
+ if ((ret = pthread_mutex_consistent((pthread_mutex_t *)((char *)addr + sizeof(int)))) == 0) {
+ *(int *)addr = (int)getpid();
+ }
+ }
+ CL_DBG_PRINT("@@@@@ %s End: pid = %d\n", __func__, *(int *)addr);
+ }
+ return ret;
+}
+
+int CL_LockNowait(void *addr) {
+ int ret;
+
+ if ((addr == NULL) || (addr == MAP_FAILED)) {
+ ret = EINVAL;
+ } else {
+ CL_DBG_PRINT("@@@@@ %s Start: pid = %d\n", __func__, *(int *)addr);
+ if ((ret = pthread_mutex_trylock((pthread_mutex_t*)((char *)addr + sizeof(int)))) == 0) {
+ *(int *)addr = (int)getpid();
+ } else if (ret == EOWNERDEAD) {
+ if ((ret = pthread_mutex_consistent((pthread_mutex_t *)((char *)addr + sizeof(int)))) == 0) {
+ *(int *)addr = (int)getpid();
+ }
+ }
+ CL_DBG_PRINT("@@@@@ %s End: pid = %d\n", __func__, *(int *)addr);
+ }
+ return ret;
+}
+
+
+int CL_LockRelease(void *addr) {
+ int ret;
+ if ((addr == NULL) || (addr == MAP_FAILED)) {
+ ret = EINVAL;
+ } else {
+ CL_DBG_PRINT("@@@@@ %s : pid = %d\n", __func__, *(int *)addr);
+ *(int *)addr = (int)0;
+ ret = pthread_mutex_unlock((pthread_mutex_t*)((char *)addr + sizeof(int)));
+ }
+ return ret;
+}
+
+
+
diff --git a/nsframework/common_library/client/src/cl_monitor.c b/nsframework/common_library/client/src/cl_monitor.c
new file mode 100644
index 00000000..26d8e2e5
--- /dev/null
+++ b/nsframework/common_library/client/src/cl_monitor.c
@@ -0,0 +1,442 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <errno.h>
+#include <semaphore.h>
+
+#include "cl_error.h"
+#include <native_service/cl_region.h>
+#include <native_service/cl_monitor.h>
+
+#define CL_MONITOR_SHM_NAME "/cl_monitor"
+
+#define CL_MONITOR_ID_REAL_GENERIC_START (0)
+#define CL_MONITOR_ID_REAL_GENERIC_END (1023)
+#define CL_MONITOR_ID_REAL_RPC_START (49952)
+#define CL_MONITOR_ID_REAL_RPC_END (59999)
+
+#define CL_MONITOR_ID_FLAT_GENERIC_START (0)
+#define CL_MONITOR_ID_FLAT_GENERIC_END \
+ (CL_MONITOR_ID_FLAT_GENERIC_START + (CL_MONITOR_ID_REAL_GENERIC_END - CL_MONITOR_ID_REAL_GENERIC_START))
+#define CL_MONITOR_ID_FLAT_RPC_START (CL_MONITOR_ID_FLAT_GENERIC_END + 1)
+#define CL_MONITOR_ID_FLAT_RPC_END \
+ (CL_MONITOR_ID_FLAT_RPC_START + (CL_MONITOR_ID_REAL_RPC_END - CL_MONITOR_ID_REAL_RPC_START))
+#define CL_MONITOR_ENTRY_NUM (CL_MONITOR_ID_FLAT_RPC_END + 1)
+
+#define CL_MONITOR_BITMAP_LENGTH ((CL_MONITOR_ENTRY_NUM + 63) / 64) // aligned
+
+#define CL_ALIGN(x, a) (((x) + (a - 1)) / (a) * (a))
+
+struct cl_monitor_header {
+ char signature[4];
+ uint64_t bitmap[CL_MONITOR_BITMAP_LENGTH];
+ sem_t sem;
+};
+
+#define CL_MONITOR_OBJECT_SIZE \
+ CL_ALIGN((sizeof(struct cl_monitor_header) + (sizeof(CL_MonitorEntry_t) * CL_MONITOR_ENTRY_NUM)), 4096)
+
+#define CL_MONITOR_SET_BIT(a, i) (a[i / 64] |= (1ULL << (i % 64)))
+#define CL_MONITOR_CLEAR_BIT(a, i) (a[i / 64] &= ~(1ULL << (i % 64)))
+
+static struct cl_monitor_header *cl_monitor_obj;
+static CL_MonitorEntry_t *cl_monitor_entry_head;
+
+int CL_MonitorInit(CL_MonitorInit_t init_type) {
+ int fd;
+ int oflag;
+ mode_t mode;
+
+ if (init_type != CL_MONITOR_INIT_SYSTEM && init_type != CL_MONITOR_INIT_USER) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (cl_monitor_obj != NULL) {
+ return 0;
+ }
+
+ if (init_type == CL_MONITOR_INIT_SYSTEM) {
+ oflag = O_RDWR | O_CREAT | O_EXCL;
+ mode = 0666;
+ } else {
+ oflag = O_RDWR;
+ mode = 0;
+ }
+
+ if ((fd = shm_open(CL_MONITOR_SHM_NAME, oflag, mode)) == -1) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function shm_open
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1;// LCOV_EXCL_LINE 5: fail safe for glibc function shm_open
+ }
+
+ if (init_type == CL_MONITOR_INIT_SYSTEM) {
+ if (ftruncate(fd, CL_MONITOR_OBJECT_SIZE) == -1) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function ftruncate
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for glibc function ftruncate
+ }
+ } else {
+ struct stat st_buf;
+ if (fstat(fd, &st_buf) == -1) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function fstat
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for glibc function fstat
+ }
+
+ if (st_buf.st_size != CL_MONITOR_OBJECT_SIZE) {
+ errno = EAGAIN;
+ return -1;
+ }
+ }
+
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function mmap
+ if ((cl_monitor_obj = mmap(NULL, CL_MONITOR_OBJECT_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for glibc function mmap
+ }
+
+ if (init_type == CL_MONITOR_INIT_SYSTEM) { // LCOV_EXCL_BR_LINE 11: out branch
+ memcpy(cl_monitor_obj->signature, "CLAM", 4);
+ memset(cl_monitor_obj->bitmap, 0, sizeof(cl_monitor_obj->bitmap));
+ sem_init(&cl_monitor_obj->sem, 1, 1);
+ }
+ cl_monitor_entry_head = (CL_MonitorEntry_t *)(((char *)cl_monitor_obj) + sizeof(struct cl_monitor_header));
+
+ return 0;
+}
+
+static inline int cl_monitor_check_type_id(CL_MonitorType_t type, uint32_t id, int *offset) {
+ if (type == CL_MONITOR_TYPE_GENERIC) {
+ if (id > CL_MONITOR_ID_REAL_GENERIC_END) {
+ errno = ENOENT;
+ return -1;
+ }
+ *offset = (int)((id - CL_MONITOR_ID_REAL_GENERIC_START) + CL_MONITOR_ID_FLAT_GENERIC_START);
+ } else if (type == CL_MONITOR_TYPE_RPC) {
+ if (id < CL_MONITOR_ID_REAL_RPC_START || id > CL_MONITOR_ID_REAL_RPC_END) {
+ errno = ENOENT;
+ return -1;
+ }
+ *offset = (int)((id - CL_MONITOR_ID_REAL_RPC_START) + CL_MONITOR_ID_FLAT_RPC_START);
+ } else {
+ errno = ENOENT;
+ return -1;
+ }
+
+ return 0;
+}
+
+static inline int cl_monitor_sem_wait(sem_t *sem) {
+ int ret;
+
+retry:
+ ret = sem_wait(sem);
+ if (ret == -1) { // LCOV_EXCL_BR_LINE 5: fail safe for libc sem_wait
+ // LCOV_EXCL_START 5: fail safe for libc sem_wait
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ if (errno == EINTR) {
+ goto retry;
+ }
+ CL_PERROR("sem_wait");
+ }
+ // LCOV_EXCL_STOP
+
+ return ret;
+}
+
+static inline int cl_monitor_sem_post(sem_t *sem) {
+ int ret;
+
+ if ((ret = sem_post(sem)) == -1) { // LCOV_EXCL_BR_LINE 5: fail safe for libc sem_post
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ CL_PERROR("sem_post"); // LCOV_EXCL_LINE 5: fail safe for libc sem_post
+ }
+
+ return ret;
+}
+
+int CL_MonitorSetEntry(CL_MonitorType_t type, uint32_t id, CL_MonitorState_t state, uint32_t timeout,
+ uint32_t user_data) {
+ int offset;
+ CL_MonitorEntry_t *e;
+ struct timespec ts;
+
+ if (cl_monitor_obj == NULL) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ if (cl_monitor_check_type_id(type, id, &offset) == -1) {
+ return -1;
+ }
+
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) { // LCOV_EXCL_BR_LINE 5: fail safe for libc clock_gettime
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for libc clock_gettime
+ }
+
+ e = cl_monitor_entry_head + offset;
+ cl_monitor_sem_wait(&cl_monitor_obj->sem);
+
+ if (state == CL_MONITOR_STATE_SLEEP) {
+ memset(e, 0, sizeof(CL_MonitorEntry_t));
+ CL_MONITOR_CLEAR_BIT(cl_monitor_obj->bitmap, offset);
+ } else {
+ e->pid = (uint16_t)getpid();
+ e->type = type;
+ e->state = state;
+
+// e->timeout = (uint32_t)ts.tv_sec + timeout;
+ e->timeout = ts.tv_sec + timeout;
+ e->id = id;
+ e->user_data = user_data;
+ CL_MONITOR_SET_BIT(cl_monitor_obj->bitmap, offset);
+ }
+
+ cl_monitor_sem_post(&cl_monitor_obj->sem);
+
+ return 0;
+}
+
+int CL_MonitorGetEntry(CL_MonitorType_t type, uint32_t id, CL_MonitorEntry_t *entry) {
+ int offset;
+ CL_MonitorEntry_t *e;
+
+ if (cl_monitor_obj == NULL) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ if (entry == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (cl_monitor_check_type_id(type, id, &offset) == -1) {
+ return -1;
+ }
+
+ e = cl_monitor_entry_head + offset;
+ cl_monitor_sem_wait(&cl_monitor_obj->sem);
+
+ memcpy(entry, e, sizeof(CL_MonitorEntry_t));
+
+ cl_monitor_sem_post(&cl_monitor_obj->sem);
+
+ return 0;
+}
+
+int CL_MonitorSearchInit(CL_MonitorSearch_t *serch) {
+ if (serch == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ serch->entry_list = NULL;
+ serch->entry_num = 0;
+ return 0;
+}
+
+int CL_MonitorSearchDestroy(CL_MonitorSearch_t *serch) {
+ if (serch == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ free(serch->entry_list);
+ serch->entry_num = 0;
+ return 0;
+}
+
+static inline int cl_monitor_popcnt64(uint64_t x) {
+ uint64_t n;
+
+ n = (x >> 1) & 0x7777777777777777ULL;
+ x = x - n;
+ n = (n >> 1) & 0x7777777777777777ULL;
+ x = x - n;
+ n = (n >> 1) & 0x7777777777777777ULL;
+ x = x - n;
+ x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
+ x = x * 0x0101010101010101ULL;
+ return (int)(x >> 56);
+}
+
+typedef struct cl_monitor_offset_s cl_monitor_offset_t;
+struct cl_monitor_offset_s {
+ cl_monitor_offset_t *next;
+ int offset;
+};
+
+int CL_MonitorSearchTimeout(CL_MonitorSearch_t *search) {
+ int i;
+ int offset;
+ CL_MonitorEntry_t *e;
+ struct timespec ts;
+ int timeout_entry_num = 0;
+ cl_region_t *r;
+ cl_monitor_offset_t *o, *head = NULL, *tail = NULL;
+
+ if (cl_monitor_obj == NULL) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ if (search == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ((r = CL_RegionCreate(CL_REGION_DEFAULT_SIZE)) == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ free(search->entry_list);
+ search->entry_list = NULL;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {// LCOV_EXCL_BR_LINE 5: fail safe for libc clock_gettime
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1;// LCOV_EXCL_LINE 5: fail safe for libc clock_gettime
+ }
+
+ cl_monitor_sem_wait(&cl_monitor_obj->sem);
+
+ for (i = 0; i < CL_MONITOR_BITMAP_LENGTH; i++) {
+ if (cl_monitor_obj->bitmap[i] != 0) {
+ uint64_t bits, mrb1; // most right bit 1
+
+ bits = cl_monitor_obj->bitmap[i];
+ while (bits) {
+ mrb1 = bits & (-bits);
+ offset = i * 64 + cl_monitor_popcnt64(mrb1 - 1);
+ e = cl_monitor_entry_head + offset;
+
+ if (e->timeout <= ts.tv_sec) {
+ timeout_entry_num++;
+ if ((o = CL_RegionAlloc(r, cl_monitor_offset_t, 1)) == NULL) { // LCOV_EXCL_BR_LINE 5: fail safe for mmap
+ // LCOV_EXCL_START 5: fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = ENOMEM;
+ timeout_entry_num = -1;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+
+ o->offset = offset;
+ o->next = NULL;
+
+ if (head == NULL) {
+ head = tail = o;
+ } else {
+ tail->next = o;
+ tail = o;
+ }
+ }
+ bits &= ~mrb1;
+ }
+ }
+ }
+
+ if (timeout_entry_num) {
+ CL_MonitorEntry_t *src, *dst;
+ dst = malloc(sizeof(CL_MonitorEntry_t) * (size_t)timeout_entry_num);
+ if (dst == NULL) { // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = ENOMEM; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ timeout_entry_num = -1; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ }
+
+ search->entry_list = dst;
+ o = head;
+ for (i = 0; i < timeout_entry_num; i++) {
+ src = cl_monitor_entry_head + o->offset;
+ memcpy(dst, src, sizeof(CL_MonitorEntry_t));
+
+ o = o->next;
+ dst++;
+ }
+ }
+
+exit:
+ cl_monitor_sem_post(&cl_monitor_obj->sem);
+
+ CL_RegionDestroy(r);
+ search->entry_num = (timeout_entry_num == -1) ? 0 : timeout_entry_num; // LCOV_EXCL_BR_LINE 11: out branch
+ return timeout_entry_num;
+}
+
+int cl_monitor_cleanup(int pid) {
+ int ret = 0;
+ int i;
+ int offset;
+ CL_MonitorEntry_t *e;
+
+ if (cl_monitor_obj == NULL) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ if (pid <= 0) { // LCOV_EXCL_LINE 5: fail safe for glibc function waitid
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = EINVAL;// LCOV_EXCL_LINE 5: fail safe for glibc function waitid
+ return -1;// LCOV_EXCL_LINE 5: fail safe for glibc function waitid
+ }
+
+ cl_monitor_sem_wait(&cl_monitor_obj->sem);
+
+ for (i = 0; i < CL_MONITOR_BITMAP_LENGTH; i++) {
+ if (cl_monitor_obj->bitmap[i] != 0) {
+ uint64_t bits, mrb1; // most right bit 1
+
+ bits = cl_monitor_obj->bitmap[i];
+ while (bits) {
+ mrb1 = bits & (-bits);
+ offset = i * 64 + cl_monitor_popcnt64(mrb1 - 1);
+
+ e = cl_monitor_entry_head + offset;
+ if (e->pid == pid) {
+ memset(e, 0, sizeof(CL_MonitorEntry_t));
+ CL_MONITOR_CLEAR_BIT(cl_monitor_obj->bitmap, offset);
+ ret++;
+ }
+
+ bits &= ~mrb1;
+ }
+ }
+ }
+
+ cl_monitor_sem_post(&cl_monitor_obj->sem);
+
+ return ret;
+}
diff --git a/nsframework/common_library/client/src/cl_process.c b/nsframework/common_library/client/src/cl_process.c
new file mode 100644
index 00000000..5c9f5a4b
--- /dev/null
+++ b/nsframework/common_library/client/src/cl_process.c
@@ -0,0 +1,1198 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <errno.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <semaphore.h>
+#include <pthread.h>
+#include <limits.h>
+#include <sys/prctl.h>
+#include <sys/signalfd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include <native_service/cl_process.h>
+#include "cl_process_internal.h"
+#include "cl_error.h"
+#include "cl_cgroup.h"
+#include "cl_monitor_internal.h"
+
+#define assert_static(e) \
+ do { \
+ enum { assert_static__ = 1/(e) }; \
+ } while (0)
+
+struct linux_dirent64 {
+ ino64_t d_ino;
+ off64_t d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[];
+};
+
+/*
+ * Initialize the process
+ */
+int CL_ProcessInit(void) {
+ int sfd = -1;
+ char *name;
+ sigset_t mask;
+
+ assert_static(sizeof(CL_ProcessAttr_t) == sizeof(CL_ProcessAttrInternal_t));
+
+ name = getenv(CL_PROCESS_NAME_ENV);
+ if (name != NULL) { // LCOV_EXCL_BR_LINE 5: fail safe for libc getenv
+ if (prctl(PR_SET_NAME, name) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc getenv
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ CL_PERROR("prctl"); // LCOV_EXCL_LINE 5: fail safe for libc getenv
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc getenv
+ }
+ }
+
+ if (sigemptyset(&mask) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc sigemptyset
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ CL_PERROR("sigemptyset"); // LCOV_EXCL_LINE 5: fail safe for libc sigemptyset
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc sigemptyset
+ }
+ if (sigaddset(&mask, SIGCHLD) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc sigaddset
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ CL_PERROR("sigaddset"); // LCOV_EXCL_LINE 5: fail safe for libc sigaddset
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc sigaddset
+ }
+ if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc sigprocmask
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ CL_PERROR("sigprocmask"); // LCOV_EXCL_LINE 5: fail safe for libc sigprocmask
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc sigprocmask
+ }
+
+ if ((sfd = signalfd(-1, &mask, SFD_NONBLOCK | SFD_CLOEXEC)) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc signalfd
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ CL_PERROR("signalfd"); // LCOV_EXCL_LINE 5: fail safe for libc signalfd
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc signalfd
+ }
+
+exit:
+ return sfd;
+}
+
+/*
+ * start of the functions to be executed from fork to exec
+ */
+static void cl_process_pf_err(char no) {
+ char errorstr[17] = "err:post_fork:0\n";
+
+ errorstr[14] = no;
+ while (1) {
+ if (write(STDERR_FILENO, errorstr, 16) == -1 && errno == EINTR) { // LCOV_EXCL_BR_LINE 5: fail safe for libc write
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ continue; // LCOV_EXCL_LINE 5: fail safe for libc write
+ }
+ break;
+ }
+}
+
+static inline int cl_process_pf_set_schedule(const CL_ProcessAttrInternal_t *ia) {
+ int ret = -1;
+ struct sched_param param;
+ int policy;
+
+ switch (ia->sched_policy) {
+ case CL_PROCESS_SCHED_POLICY_RR:
+ policy = SCHED_RR;
+ param.sched_priority = ia->sched_priority;
+ break;
+ case CL_PROCESS_SCHED_POLICY_FIFO:
+ param.sched_priority = ia->sched_priority;
+ policy = SCHED_FIFO;
+ break;
+ default:
+ param.sched_priority = 0;
+ policy = SCHED_OTHER;
+ break;
+ }
+ if (sched_setscheduler(getpid(), policy, &param) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function sched_setscheduler
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('3');// LCOV_EXCL_LINE 5: fail safe for glibc function sched_setscheduler
+ goto exit;// LCOV_EXCL_LINE 5: fail safe for glibc function sched_setscheduler
+ }
+ if (ia->sched_policy == CL_PROCESS_SCHED_POLICY_OTHER) {
+ if (setpriority(PRIO_PROCESS, (__id_t)getpid(), ia->sched_priority) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function setpriority
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ cl_process_pf_err('4');// LCOV_EXCL_LINE 5: fail safe for glibc function setpriority
+ goto exit;// LCOV_EXCL_LINE 5: fail safe for glibc function setpriority
+ }
+ }
+ ret = 0;
+
+exit:
+ return ret;
+}
+
+static inline int cl_process_pf_check_close_fd(int check_fd, int dirfd, int hold_fds_num, const int *hold_fds) {
+ int i;
+
+ if (check_fd < 3 || check_fd == dirfd) {
+ return 0;
+ }
+
+ for (i = 0; i < hold_fds_num; i++) {
+ if (check_fd == *(hold_fds + i)) {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+static inline int cl_process_pf_fname2fd(const char *s) {
+ int result = 0;
+ for (; *s != '\0'; s++) {
+ result = result * 10 + (*s - '0');
+ }
+ return result;
+}
+
+static inline int cl_process_pf_cleanup_fds(const CL_ProcessAttrInternal_t *ia) {
+ int ret = -1;
+ int dfd;
+#define BUF_SIZE 128
+ char buf[BUF_SIZE];
+ struct linux_dirent64 *d;
+ int hold_fds_num, i;
+
+ for (i = 0; i < CL_PROCESSS_ATTR_HOLD_FDS_NUM; i++) {
+ if (ia->hold_fds[i] == 0) {
+ break;
+ }
+ }
+ hold_fds_num = i;
+
+ if ((dfd = open("/proc/self/fd/", O_RDONLY | O_DIRECTORY | O_CLOEXEC)) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function open
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ cl_process_pf_err('8');// LCOV_EXCL_LINE 5: fail safe for glibc function open
+ goto exit;// LCOV_EXCL_LINE 5: fail safe for glibc function open
+ }
+
+ while (1) {
+ long nread;
+ int fd;
+ int bpos;
+
+ nread = syscall(SYS_getdents64, dfd, buf, sizeof(buf));
+ if (nread == -1) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function syscall
+ // LCOV_EXCL_START 5: fail safe for glibc function syscall
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ cl_process_pf_err('9');
+ close(dfd);
+ goto exit;
+ }
+ // LCOV_EXCL_STOP
+
+ if (nread == 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function syscall
+ break;
+ }
+
+ for (bpos = 0; bpos < nread;) {
+ d = (struct linux_dirent64 *)(buf + bpos);
+ fd = cl_process_pf_fname2fd(d->d_name);
+ if (cl_process_pf_check_close_fd(fd, dfd, hold_fds_num, ia->hold_fds)) {
+ close(fd);
+ }
+ bpos += d->d_reclen;
+ }
+ }
+ close(dfd);
+ ret = 0;
+
+exit:
+ return ret;
+}
+
+static void cl_process_post_fork(const char *file, char *const argv[], char *const envp[],
+ const CL_ProcessAttrInternal_t *ia) {
+ int intfy_fd;
+ char intfy_fname[32] = "/tmp/intfy_00000";
+ pid_t pid = getpid();
+
+ intfy_fname[11] = (char)(intfy_fname[11] + (pid / 10000));
+ intfy_fname[12] = (char)(intfy_fname[12] + ((pid / 1000) % 10));
+ intfy_fname[13] = (char)(intfy_fname[13] + ((pid / 100) % 10));
+ intfy_fname[14] = (char)(intfy_fname[14] + ((pid / 10) % 10));
+ intfy_fname[15] = (char)(intfy_fname[15] + (pid % 10));
+
+ unlink(intfy_fname);
+ if ((intfy_fd = open(intfy_fname, O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666)) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function open
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('0'); // LCOV_EXCL_LINE 5:libc fail safe for open
+ goto exit; // LCOV_EXCL_LINE 5:libc fail safe for open
+ }
+ if (close(intfy_fd) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function close
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('1'); // LCOV_EXCL_LINE 5:libc fail safe for close
+ goto exit; // LCOV_EXCL_LINE 5:libc fail safe for close
+ }
+
+ // Process group
+ if (ia->create_group) {
+ if (setpgid(getpid(), getpid()) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function setpgid
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('2'); // LCOV_EXCL_LINE 5: fail safe for glibc function setpgid
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for glibc function setpgid
+ }
+ }
+
+ // Scheduling Policy/Priority
+ if (cl_process_pf_set_schedule(ia) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function sched_setscheduler
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for glibc function sched_setscheduler
+ }
+
+ // UID/GID
+ if (ia->gid) {
+ if (setgid(ia->gid) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function setgid
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('5'); // LCOV_EXCL_LINE 5: fail safe for glibc function setgid
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for glibc function setgid
+ }
+ }
+
+ if (ia->uid) {
+ uid_t uid = (ia->uid == UINT_MAX) ? 0 : ia->uid;
+ if (setuid(uid) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function setuid
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('6');// LCOV_EXCL_LINE 5: fail safe for glibc function setuid
+ goto exit;// LCOV_EXCL_LINE 5: fail safe for glibc function setuid
+ }
+ }
+
+ // stack size
+ if (ia->stack_size) {
+ struct rlimit rlim;
+ getrlimit(RLIMIT_STACK, &rlim);
+ rlim.rlim_cur = (rlim_t)ia->stack_size;
+ if (setrlimit(RLIMIT_STACK, &rlim) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function setrlimit
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ cl_process_pf_err('7');// LCOV_EXCL_LINE 5: fail safe for glibc function setrlimit
+ }
+ }
+
+ // cleanup fds
+ if (ia->disable_close_fds == 0) {
+ if (cl_process_pf_cleanup_fds(ia) < 0) {
+ goto exit;
+ }
+ }
+
+ // exec
+ if (execve(file, argv, envp) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function execve
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ cl_process_pf_err('A');// LCOV_EXCL_LINE 5: fail safe for glibc function execve
+ }
+
+exit:
+ return;
+}
+/*
+ * end of the functions to be executed from fork to exec
+ */
+
+static int cl_process_pre_fork(char *const envp[], char ***new_env, const CL_ProcessAttrInternal_t *ia) {
+ int i;
+ size_t envlen = 0;
+ char **e;
+ char *b;
+ int new_env_count;
+ size_t name_env_len = strlen(CL_PROCESS_NAME_ENV);
+ int last_name_env_pos = -1;
+
+ if (envp == NULL) {
+ e = environ;
+ } else {
+ e = (char **)envp;
+ }
+
+ for (i = 0; e[i] != NULL; i++) {
+ if (strncmp(e[i], CL_PROCESS_NAME_ENV, name_env_len) == 0) {
+ last_name_env_pos = i;
+ } else {
+ envlen += strlen(e[i]) + 1;
+ }
+ }
+
+ if (ia->name[0] != 0) {
+ envlen += strlen(CL_PROCESS_NAME_ENV) + 1 + strlen(ia->name) + 1;
+ i++;
+ }
+
+ if ((b = malloc(envlen)) == NULL) { // LCOV_EXCL_BR_LINE 5: fail safe for libc malloc
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_ERR_PRINT("malloc fail"); // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ errno = EFAULT; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ goto error; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ }
+ memset(b, 0, envlen);
+
+ if ((*new_env = malloc(sizeof(char *) * (size_t)(i + 1))) == NULL) { // LCOV_EXCL_BR_LINE 5: fail safe for libc malloc
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ free(b); // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ CL_ERR_PRINT("malloc fail"); // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ errno = EFAULT; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ goto error; // LCOV_EXCL_LINE 5: fail safe for libc malloc
+ }
+ memset(*new_env, 0, sizeof(char *) * (size_t)(i + 1));
+
+ new_env_count = 0;
+ for (i = 0; e[i] != NULL; i++) {
+ if (i == last_name_env_pos) {
+ continue;
+ }
+ strcpy(b, e[i]);
+ *(*new_env + i) = b;
+ b += strlen(e[i]) + 1;
+ new_env_count++;
+ }
+
+ if (ia->name[0] != 0) {
+ *(*new_env + new_env_count) = b;
+ b += sprintf(b, "%s=%s", CL_PROCESS_NAME_ENV, ia->name);
+ b++;
+ new_env_count++;
+ }
+
+ return 0;
+
+error:
+ return -1;
+}
+
+/*
+ * Create process
+ */
+int CL_ProcessCreate(const char *file, char *const argv[], char *const envp[], const CL_ProcessAttr_t *attr) {
+ const CL_ProcessAttrInternal_t *ia = (const CL_ProcessAttrInternal_t *)attr;
+ pid_t childpid;
+ char intfy_fname[32];
+ char **new_env;
+ int ret;
+ int retry;
+ int i = 0;
+
+ if (file == NULL || argv == NULL || attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (cl_process_pre_fork(envp, &new_env, ia) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc function malloc
+ return -1;
+ }
+
+ childpid = fork();
+ switch (childpid) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function fork
+ case 0: /* child process */
+ cl_process_post_fork(file, argv, new_env, ia);
+ _exit(CL_PROCESS_EXIT_INTERNAL);
+ break;
+
+ case -1: /* error */
+ goto exit;
+
+ default: /* parent process */
+ break;
+ }
+
+ if (ia->cpu_assign != 0) {
+ cpu_set_t set;
+ CPU_ZERO(&set);
+ for (i = 0; i < (sizeof(ia->cpu_assign) * 8); i++) {
+ if ((ia->cpu_assign >> i) & 0x1) {
+ CPU_SET(i, &set);
+ }
+ }
+ // LCOV_EXCL_BR_START 5: fail safe for libc sched_setaffinity
+ if (sched_setaffinity(childpid, sizeof(set), &set) < 0) {
+ // LCOV_EXCL_BR_STOP
+ int last_errno = errno;
+ CL_PERROR("sched_setaffinity");
+ errno = last_errno;
+ childpid = -1;
+ goto exit;
+ }
+ }
+
+ ret = snprintf(intfy_fname, sizeof(intfy_fname), CL_INTFY_FILENAME_FORMAT, childpid);
+ if (ret < 0 || ret > sizeof(intfy_fname)) {// LCOV_EXCL_BR_LINE 5: fail safe for libc snprintf
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_ERR_PRINT("snprintf fail:%d", ret); // LCOV_EXCL_LINE 5: fail safe for libc snprintf
+ childpid = -1; // LCOV_EXCL_LINE 5: fail safe for libc snprintf
+ goto exit; // LCOV_EXCL_LINE 5: fail safe for libc snprintf
+ }
+
+ if (ia->cgroup_name[0] != '\0') {
+ if (cl_cgroup_exist(CL_CGROUP_CPU, ia->cgroup_name) == 0) {
+ if (cl_cgroup_set_num(CL_CGROUP_CPU, ia->cgroup_name, "tasks", childpid) < 0) {
+ int last_errno = errno;
+ CL_PERROR("cl_cgroup_set_num");
+ errno = last_errno;
+ childpid = -1;
+ goto exit;
+ }
+ }
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function access
+ if (cl_cgroup_exist(CL_CGROUP_MEMORY, ia->cgroup_name) == 0) {
+ // LCOV_EXCL_BR_STOP
+ if (cl_cgroup_set_num(CL_CGROUP_MEMORY, ia->cgroup_name, "tasks", childpid) < 0) {
+ int last_errno = errno;
+ CL_PERROR("cl_cgroup_set_num");
+ errno = last_errno;
+ childpid = -1;
+ goto exit;
+ }
+ }
+ }
+
+ for (retry = 100; retry >= 0; retry--) {
+ if (access(intfy_fname, F_OK) == 0) { // LCOV_EXCL_BR_LINE 5: fail safe for glibc function access
+ break;
+ }
+ usleep(100);
+ }
+
+exit:
+ free(new_env[0]);
+ free(new_env);
+
+ return childpid;
+}
+
+/*
+ * Initialize process attribute
+ */
+int CL_ProcessCreateAttrInit(CL_ProcessAttr_t *attr) {
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(attr, 0, sizeof(CL_ProcessAttr_t));
+ return 0;
+}
+
+/*
+ * Set process attribute (process name)
+ */
+int CL_ProcessCreateAttrSetName(CL_ProcessAttr_t *attr, const char *name) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL || name == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ strncpy(ia->name, name, 16);
+ ia->name[15] = 0;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (user ID)
+ */
+int CL_ProcessCreateAttrSetUid(CL_ProcessAttr_t *attr, uid_t uid) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->uid = uid;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (group ID)
+ */
+int CL_ProcessCreateAttrSetGid(CL_ProcessAttr_t *attr, gid_t gid) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->gid = gid;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (schedule policy and priority)
+ */
+int CL_ProcessCreateAttrSetSchedule(CL_ProcessAttr_t *attr, CL_ProcessSchedPolicy_t policy, int priority) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (policy == CL_PROCESS_SCHED_POLICY_RR || policy == CL_PROCESS_SCHED_POLICY_FIFO) {
+ if (priority < 1 || priority > 99) {
+ errno = EINVAL;
+ return -1;
+ }
+ } else if (policy == CL_PROCESS_SCHED_POLICY_OTHER) {
+ if (priority < -20 || priority > 19) {
+ CL_ERR_PRINT("Invlid SCHED_OTHER priority:%d", priority);
+ }
+ } else {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->sched_policy = policy;
+ ia->sched_priority = priority;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (process group)
+ */
+int CL_ProcessCreateAttrSetGroup(CL_ProcessAttr_t *attr, int create) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (create < 0 || create > 1) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->create_group = create;
+
+ return 0;
+}
+
+static int32_t CL_CpuAssignMsbCpu(int cpu_assign) {
+ int32_t i;
+ int32_t ret = 0;
+
+ for (i = 0; i < (sizeof(cpu_assign) * 8); i++) {
+ if ((cpu_assign >> i) & 0x1)
+ ret = i;
+ }
+
+ return ret;
+}
+
+/**
+ * Set process attribute (CPU Assign)
+ */
+int CL_ProcessCreateAttrSetCpuAssign(CL_ProcessAttr_t *attr, int cpu_assign) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (cpu_assign < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (CL_CpuAssignMsbCpu(cpu_assign) >= sysconf(_SC_NPROCESSORS_CONF)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->cpu_assign = cpu_assign;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (Stack Size)
+ */
+int CL_ProcessCreateAttrSetStackSize(CL_ProcessAttr_t *attr, int stack_size) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->stack_size = stack_size;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (FD to maintain)
+ */
+int CL_ProcessCreateAttrSetHoldFds(CL_ProcessAttr_t *attr, int hold_fds[]) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL || hold_fds == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memcpy(ia->hold_fds, hold_fds, sizeof(ia->hold_fds));
+
+ return 0;
+}
+
+/*
+ * Set process attribute (to suspend forced FD close)
+ */
+int CL_ProcessCreateAttrSetDisableCloseFds(CL_ProcessAttr_t *attr) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->disable_close_fds = 1;
+
+ return 0;
+}
+
+/*
+ * Set process attribute (Cgroup)
+ */
+int CL_ProcessCreateAttrSetCgroup(CL_ProcessAttr_t *attr, const char *cgroup_name) {
+ CL_ProcessAttrInternal_t *ia = (CL_ProcessAttrInternal_t *)attr;
+
+ if (attr == NULL || cgroup_name == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (strlen(cgroup_name) >= sizeof(ia->cgroup_name)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ strcpy(ia->cgroup_name, cgroup_name);
+
+ return 0;
+}
+
+/*
+ * Kill process
+ */
+int CL_ProcessTerminate(pid_t pid) {
+ return kill(pid, SIGKILL);
+}
+
+/*
+ * Kill process group
+ */
+int CL_ProcessTerminateGroup(pid_t pid) {
+ return killpg(pid, SIGKILL);
+}
+
+/**
+ * Forced process termination
+ */
+int CL_ProcessAbort(pid_t pid) {
+ return kill(pid, SIGABRT);
+}
+
+/**
+ * Forced process group termination
+ */
+int CL_ProcessAbortGroup(pid_t pid) {
+ return killpg(pid, SIGABRT);
+}
+
+/**
+ * Euthanize process group
+ */
+int CL_ProcessEuthanizeGroup(pid_t pid) {
+ usleep(10 * 1000);
+ return killpg(pid, SIGKILL);
+}
+
+/*
+ * Collect child process
+ */
+int CL_ProcessCleanup(int sigchld_fd, CL_ProcessCleanupInfo_t *cleanup_info) {
+ struct signalfd_siginfo fdsi;
+ ssize_t s;
+ siginfo_t info;
+ int ret;
+ char intfy_fname[32];
+
+ if (cleanup_info == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ while (1) {
+ s = read(sigchld_fd, &fdsi, sizeof(struct signalfd_siginfo));
+ if (s != sizeof(struct signalfd_siginfo)) {
+ if (s == -1 && errno == EINTR) {
+ continue;
+ }
+ break;
+ }
+ }
+
+ info.si_pid = 0;
+ while (1) {
+ ret = waitid(P_ALL, 0, &info, WEXITED | WNOHANG);
+ if (ret == -1) {
+ return -1;
+ } else if (ret == 0 && info.si_pid == 0) {
+ errno = ECHILD;
+ return -1;
+ }
+ break;
+ }
+
+ cleanup_info->pid = info.si_pid;
+ cleanup_info->code = info.si_code;
+ cleanup_info->status = info.si_status;
+
+ cl_monitor_cleanup(info.si_pid);
+
+ ret = snprintf(intfy_fname, sizeof(intfy_fname), CL_INTFY_FILENAME_FORMAT, info.si_pid);
+
+ if (ret < 0 || ret > sizeof(intfy_fname)) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function snprintf
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_ERR_PRINT("snprintf fail:%d\n", ret);// LCOV_EXCL_LINE 5: fail safe for glibc function snprintf
+ goto exit;// LCOV_EXCL_LINE 5: fail safe for glibc function snprintf
+ }
+ if (unlink(intfy_fname) < 0) {
+ CL_PERROR("unlink");
+ }
+
+exit:
+ info.si_pid = 0;
+ ret = waitid(P_ALL, 0, &info, WEXITED | WNOWAIT | WNOHANG);
+ if (ret == 0 && info.si_pid != 0) {
+ return 1;
+ } else if (ret == -1 && errno != ECHILD) {
+ return -1;
+ }
+ return 0;
+}
+
+typedef struct {
+ sem_t sem;
+ CL_ThreadAttrInternal_t *ia;
+ void *(*start_routine)(void *);
+ void *start_arg;
+} create_thread_arg_t;
+
+static void *thread_start_func(void *arg) {
+ create_thread_arg_t *p = (create_thread_arg_t *)arg;
+ void *(*start_routine)(void *) = p->start_routine;
+ void *start_arg = p->start_arg;
+
+ prctl(PR_SET_NAME, p->ia->name != 0 ? p->ia->name : NULL);
+
+ if (sem_post(&p->sem) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for libc sem_post
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_PERROR("sem_post"); // LCOV_EXCL_LINE 5: fail safe for libc sem_post
+ }
+
+ return (*start_routine)(start_arg);
+}
+
+/*
+ * Create thread
+ */
+int CL_ThreadCreate(pthread_t *thread, pthread_attr_t *attr, CL_ThreadAttr_t *cl_attr, void *(*start_routine)(void *),
+ void *arg) {
+ int ret;
+ create_thread_arg_t cr_arg = { .ia = (CL_ThreadAttrInternal_t *)cl_attr,
+ .start_routine = start_routine,
+ .start_arg = arg
+ };
+
+ if (thread == NULL || cl_attr == NULL || start_routine == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (sem_init(&cr_arg.sem, 0, 0) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc sem_init
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for libc sem_init
+ }
+
+ // LCOV_EXCL_BR_START 5: fail safe for libc pthread_create
+ if ((ret = pthread_create(thread, attr, thread_start_func, &cr_arg)) != 0) {
+ // LCOV_EXCL_BR_STOP
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ errno = ret; // LCOV_EXCL_LINE 5: fail safe for libc pthread_create
+ return -1; // LCOV_EXCL_LINE 5: fail safe for libc pthread_create
+ }
+
+ if (sem_wait(&cr_arg.sem) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for libc sem_wait
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1; // LCOV_EXCL_LINE 5: fail safe for libc sem_wait
+ }
+
+ return 0;
+}
+
+/*
+ * Initialize CommonLibrary extension thread attribute
+ */
+int CL_ThreadCreateAttrInit(CL_ThreadAttr_t *attr) {
+ assert_static(sizeof(CL_ThreadAttr_t) == sizeof(CL_ThreadAttrInternal_t));
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(attr, 0, sizeof(CL_ThreadAttr_t));
+ return 0;
+}
+
+/*
+ * Set CommonLibrary extension thread attribute (thread name)
+ */
+int CL_ThreadCreateAttrSetName(CL_ThreadAttr_t *attr, const char *name) {
+ CL_ThreadAttrInternal_t *ia = (CL_ThreadAttrInternal_t *)attr;
+
+ if (attr == NULL || name == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ strncpy(ia->name, name, 16);
+ ia->name[15] = 0;
+
+ return 0;
+}
+
+/*
+ * Create Cgroup
+ */
+int CL_ProcessCreateCgroupCreate(const char *cgroup_name, CL_ProcessCreateCgroupAttr_t *attr) {
+ CL_ProcessCreateCgroupAttrInternal_t *ia = (CL_ProcessCreateCgroupAttrInternal_t *)attr;
+ CL_ProcessCreateCgroupAttrInternal_t cmp;
+
+ if (cgroup_name == NULL || attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(&cmp, 0, sizeof(CL_ProcessCreateCgroupAttrInternal_t));
+ if (memcmp(ia, &cmp, sizeof(CL_ProcessCreateCgroupAttrInternal_t)) == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (ia->rt_runtime_us || ia->cfs_quota_us || ia->cpu_shares) {
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function mkdir
+ if (cl_cgroup_make(CL_CGROUP_CPU, cgroup_name) < 0) {
+ // LCOV_EXCL_BR_STOP
+ return -1;
+ }
+
+ if (ia->rt_runtime_us) {
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function write
+ if (cl_cgroup_set_num(CL_CGROUP_CPU, cgroup_name, "cpu.rt_runtime_us", ia->rt_runtime_us) < 0) {
+ // LCOV_EXCL_BR_STOP
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1;// LCOV_EXCL_LINE 5: fail safe for glibc function write
+ }
+ }
+
+ if (ia->cfs_quota_us) {
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function write
+ if (cl_cgroup_set_num(CL_CGROUP_CPU, cgroup_name, "cpu.cfs_quota_us", ia->cfs_quota_us) < 0) {
+ // LCOV_EXCL_BR_STOP
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1;// LCOV_EXCL_LINE 5: fail safe for glibc function write
+ }
+ }
+
+ if (ia->cpu_shares) {
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function write
+ if (cl_cgroup_set_num(CL_CGROUP_CPU, cgroup_name, "cpu.shares", ia->cpu_shares) < 0) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1;// LCOV_EXCL_LINE 5: fail safe for glibc function write
+ }
+ }
+ }
+
+ if (ia->memory_limit || ia->usage_in_bytes || ia->event_fd) {
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function mkdir
+ if (cl_cgroup_make(CL_CGROUP_MEMORY, cgroup_name) < 0) {
+ // LCOV_EXCL_BR_STOP
+ return -1;
+ }
+
+ if (ia->memory_limit) {
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function write
+ if (cl_cgroup_set_num(CL_CGROUP_MEMORY, cgroup_name, "memory.limit_in_bytes", ia->memory_limit) < 0) {
+ // LCOV_EXCL_BR_STOP
+ return -1;
+ }
+
+ if (cl_cgroup_set_num(CL_CGROUP_MEMORY, cgroup_name, "memory.memsw.limit_in_bytes", ia->memory_limit) < 0) {
+ return -1;
+ }
+
+ }
+
+ if (ia->usage_in_bytes || ia->event_fd) {
+ int checkfd;
+ char setstr[64];
+
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function open
+ if ( (checkfd = cl_cgroup_open(CL_CGROUP_MEMORY, cgroup_name, "memory.memsw.usage_in_bytes", O_RDONLY)) < 0) {
+ // LCOV_EXCL_BR_STOP
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return -1; // LCOV_EXCL_LINE 5: fail safe for glibc function open
+ }
+
+ snprintf(setstr, sizeof(setstr), "%d %d %d", ia->event_fd, checkfd, ia->usage_in_bytes);
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function write
+ if (cl_cgroup_set_string(CL_CGROUP_MEMORY, cgroup_name, "cgroup.event_control", setstr) < 0) {
+ // LCOV_EXCL_BR_STOP
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+
+ return -1;// LCOV_EXCL_LINE 5: fail safe for glibc function write
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * Initialize Cgroup attribute
+ */
+int CL_ProcessCreateCgroupAttrInit(CL_ProcessCreateCgroupAttr_t *attr) {
+ assert_static(sizeof(CL_ProcessCreateCgroupAttr_t) == sizeof(CL_ProcessCreateCgroupAttrInternal_t));
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(attr, 0, sizeof(CL_ProcessCreateCgroupAttr_t));
+ return 0;
+}
+
+/*
+ * Set Cgroup attribute (RT Throttling)
+ */
+int CL_ProcessCreateCgroupAttrSetRtThrottling(CL_ProcessCreateCgroupAttr_t *attr, int runtime_us) {
+ CL_ProcessCreateCgroupAttrInternal_t *ia = (CL_ProcessCreateCgroupAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->rt_runtime_us = runtime_us;
+
+ return 0;
+}
+
+/*
+ * Set Cgroup attribute (CFS Bandwidth Control)
+ */
+int CL_ProcessCreateCgroupAttrSetCfsBandwidthControl(CL_ProcessCreateCgroupAttr_t *attr, int cfs_quota_us) {
+ CL_ProcessCreateCgroupAttrInternal_t *ia = (CL_ProcessCreateCgroupAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->cfs_quota_us = cfs_quota_us;
+
+ return 0;
+}
+
+/*
+ * Set Cgroup attribute (CPU Shares)
+ */
+int CL_ProcessCreateCgroupAttrSetCpuShares(CL_ProcessCreateCgroupAttr_t *attr, int cpu_shares) {
+ CL_ProcessCreateCgroupAttrInternal_t *ia = (CL_ProcessCreateCgroupAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->cpu_shares = cpu_shares;
+
+ return 0;
+}
+
+/*
+ * Set Cgroup attribute (Memory Limit)
+ */
+int CL_ProcessCreateCgroupAttrSetMemoryLimit(CL_ProcessCreateCgroupAttr_t *attr, int memory_limit) {
+ CL_ProcessCreateCgroupAttrInternal_t *ia = (CL_ProcessCreateCgroupAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->memory_limit = memory_limit;
+
+ return 0;
+}
+
+/*
+ * Set Cgroup attribute (Memory Usage Notification)
+ */
+int CL_ProcessCreateCgroupAttrSetMemoryUsageNotification(CL_ProcessCreateCgroupAttr_t *attr, int usage_in_bytes,
+ int event_fd) {
+ CL_ProcessCreateCgroupAttrInternal_t *ia = (CL_ProcessCreateCgroupAttrInternal_t *)attr;
+
+ if (attr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (event_fd < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ia->usage_in_bytes = usage_in_bytes;
+ ia->event_fd = event_fd;
+
+ return 0;
+}
+
+/*
+ * Delete Cgroup
+ */
+int CL_ProcessCreateCgroupDelete(const char *cgroup_name) {
+ int mem_ret = 1, mem_err;
+ int cpu_ret = 1, cpu_err;
+
+ if (cgroup_name == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function access
+ if (cl_cgroup_exist(CL_CGROUP_MEMORY, cgroup_name) == 0) {
+ // LCOV_EXCL_BR_STOP
+ mem_ret = cl_cgroup_remove(CL_CGROUP_MEMORY, cgroup_name);
+ mem_err = errno;
+ }
+
+ // LCOV_EXCL_BR_START 5: fail safe for glibc function access
+ if (cl_cgroup_exist(CL_CGROUP_CPU, cgroup_name) == 0) {
+ // LCOV_EXCL_BR_STOP
+ cpu_ret = cl_cgroup_remove(CL_CGROUP_CPU, cgroup_name);
+ cpu_err = errno;
+ }
+
+ if (mem_ret == 1 && cpu_ret == 1) {
+ errno = ENOENT;
+ return -1;
+ } else if (mem_ret < 0) {
+ errno = mem_err;
+ return -1;
+ } else if (cpu_ret < 0) {
+ errno = cpu_err;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Move process to the Cgroup
+ */
+int CL_ProcessCreateCgroupClassify(const char *cgroup_name, pid_t pid) {
+ int mem_ret = 1, mem_err;
+ int cpu_ret = 1, cpu_err;
+
+ if (cgroup_name == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (cl_cgroup_exist(CL_CGROUP_MEMORY, cgroup_name) == 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function access
+ mem_ret = cl_cgroup_set_num(CL_CGROUP_MEMORY, cgroup_name, "tasks", pid);
+ mem_err = errno;
+ }
+
+ if (cl_cgroup_exist(CL_CGROUP_CPU, cgroup_name) == 0) {// LCOV_EXCL_BR_LINE 5: fail safe for glibc function access
+ cpu_ret = cl_cgroup_set_num(CL_CGROUP_CPU, cgroup_name, "tasks", pid);
+ cpu_err = errno;
+ }
+
+ if (mem_ret == 1 && cpu_ret == 1) {
+ errno = ENOENT;
+ return -1;
+ } else if (mem_ret < 0) {
+ errno = mem_err;
+ return -1;
+ } else if (cpu_ret < 0) {
+ errno = cpu_err;
+ return -1;
+ }
+
+ return 0;
+}
+
+/* vim:set ts=8 sts=2 sw=2: */
diff --git a/nsframework/common_library/client/src/cl_region.c b/nsframework/common_library/client/src/cl_region.c
new file mode 100644
index 00000000..0f6d470c
--- /dev/null
+++ b/nsframework/common_library/client/src/cl_region.c
@@ -0,0 +1,295 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file cl_region.c
+ * @brief region manage
+ *
+ */
+
+#include <stdio.h>
+#include <sys/mman.h>
+#include <native_service/cl_region.h>
+#include "cl_error.h"
+
+#define cl_align_ptr(p, a) \
+ (uint8_t *) (((long)(p) + ((long)a - 1)) & ~((long)a - 1))
+
+static void *cl_region_anonmmap(size_t size);
+static void *cl_region_expand(cl_region_t *region, size_t size, size_t align_size);
+static void *cl_region_alloc_large(cl_region_t *region, size_t size);
+
+cl_region_t *
+CL_RegionCreate(size_t size) {
+ cl_region_t *r;
+ long pagesize;
+
+ pagesize = sysconf(_SC_PAGE_SIZE);
+ size = ((size + (size_t)pagesize - 1) / (size_t)pagesize) * (size_t)pagesize;
+
+ r = cl_region_anonmmap(size);
+ if (r == NULL) {
+ return NULL;
+ }
+
+ r->d.last = (uint8_t *) r + sizeof(cl_region_t);
+ r->d.end = (uint8_t *) r + size;
+ r->d.next = NULL;
+ r->d.failed = 0;
+
+ size = size - sizeof(cl_region_t);
+ r->max = (size < (pagesize - 1)) ? size : (size_t)(pagesize - 1);
+
+ r->current = r;
+ r->large = NULL;
+ r->cleanup = NULL;
+
+ return r;
+}
+
+
+void
+CL_RegionDestroy(cl_region_t *region) {
+ cl_region_t *r, *n;
+ cl_region_large_t *l;
+ cl_region_cleanup_t *c;
+
+ for (c = region->cleanup; c; c = c->next) {
+ if (c->handler) {
+ CL_DBG_PRINT("run cleanup: %p\n", c->handler);
+ c->handler(c->data);
+ }
+ }
+
+ for (l = region->large; l; l = l->next) {
+
+ CL_DBG_PRINT("free: %p\n", l->alloc);
+
+ if (l->alloc) { // LCOV_EXCL_BR_LINE 6: double check, mmap in cl_monitor.c
+ if (munmap(l->alloc, l->size) < 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc munmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_PERROR("munmap"); // LCOV_EXCL_LINE 5: fail safe for libc munmap
+ }
+ }
+ }
+
+ for (r = region, n = region->d.next; /* void */; r = n, n = n->d.next) {
+ if (munmap(r, (size_t)(r->d.end - (uint8_t *)r)) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for libc munmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_PERROR("munmap"); // LCOV_EXCL_LINE 5: fail safe for libc munmap
+ }
+
+ if (n == NULL) {
+ break;
+ }
+ }
+}
+
+
+void *
+cl_region_alloc(cl_region_t *region, size_t size, size_t align_size) {
+ uint8_t *m;
+ volatile uint8_t *old_last;
+ cl_region_t *r;
+
+ if (size <= region->max) {
+
+ r = region->current;
+
+ do {
+ retry:
+ old_last = r->d.last;
+ m = cl_align_ptr(old_last, align_size);
+ if ((size_t)(r->d.end - m) >= size) {
+ if (false == __sync_bool_compare_and_swap(&r->d.last, old_last, m + size)) {
+ goto retry;
+ }
+ return m;
+ }
+
+ r = r->d.next;
+
+ } while (r);
+
+ return cl_region_expand(region, size, align_size);
+ }
+
+ return cl_region_alloc_large(region, size);
+}
+
+
+static void *
+cl_region_anonmmap(size_t size) {
+ uint8_t *p;
+
+ p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED) { /* pgr0203 */
+ CL_PERROR("mmap");
+ return NULL;
+ }
+
+ return p;
+}
+
+
+static void *
+cl_region_expand(cl_region_t *region, size_t size, size_t align_size) {
+ uint8_t *m;
+ size_t psize;
+ cl_region_t *r, *new, *current;
+
+ psize = (size_t)(region->d.end - (uint8_t *)region);
+
+ m = cl_region_anonmmap(psize);
+ if (m == NULL) { // LCOV_EXCL_BR_LINE 5: fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return NULL;// LCOV_EXCL_LINE 5: fail safe for libc mmap
+ }
+
+ new = (cl_region_t *)m;
+
+ new->d.end = m + psize;
+ new->d.next = NULL;
+ new->d.failed = 0;
+
+ m += sizeof(cl_region_data_t);
+ m = cl_align_ptr(m, align_size);
+ new->d.last = m + size;
+
+ current = region->current;
+
+ for (r = current; r->d.next; r = r->d.next) { /* pgr0689 */
+ if (r->d.failed++ > 4) {
+ current = r->d.next;
+ }
+ }
+
+ while (false == __sync_bool_compare_and_swap(&r->d.next, NULL, new)) {
+ for (r = r->d.next; r->d.next; r = r->d.next) {} /* pgr0689 */
+ }
+
+ region->current = current ? current : new;
+
+ return m;
+}
+
+
+static void *
+cl_region_alloc_large(cl_region_t *region, size_t size) {
+ void *p;
+ int n;
+ long pagesize;
+ cl_region_large_t *large;
+
+ pagesize = sysconf(_SC_PAGE_SIZE);
+ size = ((size + (size_t)pagesize - 1) / (size_t)pagesize) * (size_t)pagesize;
+
+ p = cl_region_anonmmap(size);
+
+ if (p == NULL) { // LCOV_EXCL_BR_LINE 5: fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return NULL;// LCOV_EXCL_LINE 5: fail safe for libc mmap
+ }
+
+ n = 0;
+
+ for (large = region->large; large; large = large->next) {
+ if (large->alloc == NULL) {
+ if (false == __sync_bool_compare_and_swap(&large->alloc, NULL, p)) {
+ break;
+ }
+ large->size = size;
+ return p;
+ }
+
+ if (n++ > 3) {
+ break;
+ }
+ }
+
+ large = CL_RegionAlloc(region, cl_region_large_t, 1);
+ if (large == NULL) { // LCOV_EXCL_START 5: fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (munmap(p, size) < 0) {
+ CL_PERROR("munmap");
+ }
+ return NULL;
+ } // LCOV_EXCL_STOP
+
+ large->alloc = p;
+ large->size = size;
+ large->next = region->large;
+ while (false == __sync_bool_compare_and_swap(&region->large, large->next, large)) { // LCOV_EXCL_BR_LINE 100: race condition // NOLINT (readability/nolint)
+ // LCOV_EXCL_START 100: race condition
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ large->next = region->large;
+ } // LCOV_EXCL_STOP
+
+ return p;
+}
+
+
+bool
+CL_RegionFree(cl_region_t *region, void *p) {
+ cl_region_large_t *l;
+
+ for (l = region->large; l; l = l->next) {
+ if (p == l->alloc) {
+ CL_DBG_PRINT("free: %p\n", l->alloc);
+ if (munmap(l->alloc, l->size) < 0) {// LCOV_EXCL_BR_LINE 5: fail safe for libc munmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CL_PERROR("munmap");// LCOV_EXCL_LINE 5: fail safe for libc munmap
+ }
+ l->alloc = NULL;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+cl_region_cleanup_t *
+cl_region_cleanup_add(cl_region_t *region, size_t size, size_t align_size) {
+ cl_region_cleanup_t *c;
+
+ c = CL_RegionAlloc(region, cl_region_cleanup_t, 1);
+ if (c == NULL) { // LCOV_EXCL_START 5: fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return NULL;
+ } // LCOV_EXCL_STOP
+
+ if (size) {
+ c->data = cl_region_alloc(region, size, align_size);
+ if (c->data == NULL) { // LCOV_EXCL_START 5: fail safe for libc mmap
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return NULL;
+ } // LCOV_EXCL_STOP
+ } else {
+ c->data = NULL;
+ }
+
+ c->handler = NULL;
+ c->next = region->cleanup;
+
+ region->cleanup = c;
+
+ CL_DBG_PRINT("add cleanup: %p\n", c);
+
+ return c;
+}
+
+/* vim:set ts=8 sw=2 sts=2: */
diff --git a/nsframework/common_library/client/src/cl_sem.c b/nsframework/common_library/client/src/cl_sem.c
new file mode 100644
index 00000000..911daff4
--- /dev/null
+++ b/nsframework/common_library/client/src/cl_sem.c
@@ -0,0 +1,67 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <semaphore.h>
+#include <time.h>
+
+#include <native_service/cl_sem.h>
+#include "cl_error.h"
+
+#define CL_MILLI_TO_NANO(time) ((time) * 1000000U)
+#define CL_SEC_TO_NANO(time) ((time) * 1000000000U)
+#define CL_NANO_TO_SEC(time) ((time) / 1000000000U)
+
+static void cl_TimeoutCalc(struct timespec *ts, unsigned int timeout) {
+ unsigned long long nsec;
+
+ clock_gettime(CLOCK_REALTIME, ts);
+ nsec = (unsigned long long)ts->tv_nsec + (CL_MILLI_TO_NANO((unsigned long long)timeout));
+ ts->tv_sec = ts->tv_sec + (time_t)CL_NANO_TO_SEC(nsec);
+ ts->tv_nsec = (__syscall_slong_t)(nsec - CL_SEC_TO_NANO((unsigned long long)CL_NANO_TO_SEC(nsec)));
+}
+
+int CL_SemWait(sem_t *semid, unsigned int timeout) {
+ struct timespec ts, tmp;
+ int ret;
+
+ while (1) {
+ cl_TimeoutCalc(&ts, timeout);
+ if ((ret = sem_timedwait(semid, &ts)) != 0) { // LCOV_EXCL_BR_LINE 5: fail safe for libc
+ // LCOV_EXCL_START 5: fail safe for libc
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == ETIMEDOUT) {
+ /* Check the time considering the case where the time has been changed by clock_settime/settimeofday */
+ /* If the current time is much larger than the timeout specified time,
+ the system assumes that the time has changed and re-executes the command.
+ (A threshold of 100 is appropriate) */
+ clock_gettime(CLOCK_REALTIME, &tmp);
+ if (difftime(tmp.tv_sec, ts.tv_sec) > 100.0) {
+ CL_DBG_PRINT("detect clock changed\n");
+ continue;
+ }
+ }
+ }
+ // LCOV_EXCL_STOP 5: fail safe for libc
+ break;
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ } // LCOV_EXCL_LINE 10: end line
+
+ return ret;
+}
+
diff --git a/nsframework/framework_unified/LICENSE b/nsframework/framework_unified/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/nsframework/framework_unified/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/nsframework/framework_unified/Makefile.client b/nsframework/framework_unified/Makefile.client
new file mode 100644
index 00000000..69ea68dd
--- /dev/null
+++ b/nsframework/framework_unified/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := client
+
+include ../native_service.mk
diff --git a/nsframework/framework_unified/client/Makefile b/nsframework/framework_unified/client/Makefile
new file mode 100644
index 00000000..29ed6284
--- /dev/null
+++ b/nsframework/framework_unified/client/Makefile
@@ -0,0 +1,269 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+#INST_PROGS =
+
+######### installed library(*.a) #############
+#INST_LIBS =
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libNS_FrameworkUnified
+
+######### install headers(*.h) #############
+
+VPATH += ./include/$(COMPONENT_NAME)
+# native
+INST_HEADERS = ns_config_parser_if.h
+INST_HEADERS += ns_reader.h
+INST_HEADERS += ns_writer.h
+INST_HEADERS += ns_eventlogger.h
+INST_HEADERS += ns_logger_if.h
+INST_HEADERS += ns_message_center_if.h
+INST_HEADERS += ns_np_service.h
+INST_HEADERS += ns_np_service_if.h
+INST_HEADERS += ns_np_service_nor_persistence.h
+INST_HEADERS += ns_np_service_notification.h
+INST_HEADERS += ns_np_service_protocol.h
+INST_HEADERS += ns_np_service_nor_persistence_internal.h
+INST_HEADERS += ns_np_types.h
+INST_HEADERS += ns_plogger_if.h
+INST_HEADERS += ns_shared_mem.h
+INST_HEADERS += ns_shared_mem_if.h
+INST_HEADERS += ns_sharedmem.h
+INST_HEADERS += ns_sharedmem_reader.h
+INST_HEADERS += ns_sharedmem_writer.h
+INST_HEADERS += ns_ringbuffer.h
+INST_HEADERS += ns_system_mode.h
+INST_HEADERS += ns_timer_if.h
+INST_HEADERS += ns_timer_if.hpp
+INST_HEADERS += ns_transmit_log.h
+INST_HEADERS += ns_utility.hpp
+INST_HEADERS += ns_utility_if.h
+INST_HEADERS += ns_utility_sys.hpp
+INST_HEADERS += ns_version_if.h
+INST_HEADERS += ns_resource_controler.h
+INST_HEADERS += XMLParser.h
+INST_HEADERS += ns_msgs.h
+INST_HEADERS += ns_mc_system_info.h
+
+# inc
+INST_HEADERS += ns_version.h
+INST_HEADERS += frameworkunified_service_protocol.h
+INST_HEADERS += frameworkunified_types.h
+INST_HEADERS += wpf_legacy.h
+INST_HEADERS += framework_unified.h
+
+# nsrcs
+INST_HEADERS += ns_rcs_data_handler.hpp
+INST_HEADERS += ns_rcs_logger_types.h
+INST_HEADERS += ns_rcs_plugin.hpp
+
+# _CWORD77_
+INST_HEADERS += ns__CWORD77__common.h
+INST_HEADERS += ns__CWORD77__data_pool_if.h
+INST_HEADERS += ns__CWORD77__data_pool_key.h
+INST_HEADERS += ns__CWORD77__data_pool_table.h
+INST_HEADERS += ns__CWORD77__notifications.h
+INST_HEADERS += ns__CWORD77__types.h
+INST_HEADERS += frameworkunified__CWORD77__service_if.h
+INST_HEADERS += frameworkunified__CWORD77__session_if.h
+
+# utility
+INST_HEADERS += ns_endianess.h
+INST_HEADERS += nslogutil_cmd_if.h
+INST_HEADERS += nsfw_message.h
+INST_HEADERS += ns_util_directory.h
+INST_HEADERS += ns_util_crc.h
+
+# framework
+INST_HEADERS += frameworkunified_application.h
+INST_HEADERS += frameworkunified_dispatcher.h
+INST_HEADERS += frameworkunified_framework_error.hpp
+INST_HEADERS += frameworkunified_framework_if.h
+INST_HEADERS += frameworkunified_framework_sync.h
+INST_HEADERS += frameworkunified_framework_system_if.h
+INST_HEADERS += frameworkunified_framework_types.h
+INST_HEADERS += frameworkunified_multithreading.h
+INST_HEADERS += frameworkunified_service_if.h
+INST_HEADERS += frameworkunified_thread_priority.h
+INST_HEADERS += frameworkunified_timer.h
+
+# framework/statemachine
+INST_HEADERS += frameworkunified_sm_action.h
+INST_HEADERS += frameworkunified_sm_compositestate.h
+INST_HEADERS += frameworkunified_sm_conditionconnector.h
+INST_HEADERS += frameworkunified_sm_deephistorystate.h
+INST_HEADERS += frameworkunified_sm_dispatcher.h
+INST_HEADERS += frameworkunified_sm_eventdata.h
+INST_HEADERS += frameworkunified_sm_eventfactory.h
+INST_HEADERS += frameworkunified_sm_externaltransition.h
+INST_HEADERS += frameworkunified_sm_framework_dispatch.h
+INST_HEADERS += frameworkunified_sm_framework_if.h
+INST_HEADERS += frameworkunified_sm_framework_types.h
+INST_HEADERS += frameworkunified_sm_guard.h
+INST_HEADERS += frameworkunified_sm_historystate.h
+INST_HEADERS += frameworkunified_sm_hsm.h
+INST_HEADERS += frameworkunified_sm_hsmframework.h
+INST_HEADERS += frameworkunified_sm_internaltransition.h
+INST_HEADERS += frameworkunified_sm_leafstate.h
+INST_HEADERS += frameworkunified_sm_localtransition.h
+INST_HEADERS += frameworkunified_sm_multithreading.h
+INST_HEADERS += frameworkunified_sm_orthogonalstate.h
+INST_HEADERS += frameworkunified_sm_reaction.h
+INST_HEADERS += frameworkunified_sm_shallowhistorystate.h
+INST_HEADERS += frameworkunified_sm_state.h
+INST_HEADERS += frameworkunified_sm_transition.h
+
+# xmlparser
+INST_HEADERS += ns_xml_reader.h
+INST_HEADERS += ns_xml_writer.h
+INST_HEADERS += ns_xmlparser_if.h
+
+######### compiled sources #############
+
+# NS_Logger
+libNS_FrameworkUnified_SRCS += ./NS_Logger/src/ns_logger.cpp
+CPPFLAGS += -I./NS_Logger/include
+
+# NS_MessageQueue
+libNS_FrameworkUnified_SRCS += ./NS_MessageQueue/src/ns_msg_queue.c
+libNS_FrameworkUnified_SRCS += ./NS_MessageQueue/src/ns_mq_string.c
+CPPFLAGS += -I./NS_MessageQueue/include
+
+# NS_SharedMemIf
+libNS_FrameworkUnified_SRCS += ./NS_SharedMemIf/src/ns_shared_mem_if.cpp
+libNS_FrameworkUnified_SRCS += ./NS_SharedMemIf/src/ns_sharedmem.cpp
+libNS_FrameworkUnified_SRCS += ./NS_SharedMemIf/src/ns_sharedmem_reader.cpp
+libNS_FrameworkUnified_SRCS += ./NS_SharedMemIf/src/ns_sharedmem_writer.cpp
+
+# NS_RingBuffer
+libNS_FrameworkUnified_SRCS += ./NS_RingBuffer/src/ns_ringbuffer.cpp
+
+# NS_UtilityCenter
+libNS_FrameworkUnified_SRCS += ./NS_UtilityCenter/src/ns_endianess.cpp
+libNS_FrameworkUnified_SRCS += ./NS_UtilityCenter/src/ns_util_crc.cpp
+libNS_FrameworkUnified_SRCS += ./NS_UtilityCenter/src/ns_util_directory.cpp
+libNS_FrameworkUnified_SRCS += ./NS_UtilityCenter/src/ns_utility.cpp
+libNS_FrameworkUnified_SRCS += ./NS_UtilityCenter/src/frameworkunified_version.cpp
+CPPFLAGS += -I./NS_UtilityCenter/include
+
+# NS_MessageCenter
+libNS_FrameworkUnified_SRCS += ./NS_MessageCenter/src/ns_message_center.c
+CPPFLAGS += -I./NS_MessageCenter/include
+
+# NS_ConfigParser
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_cfg_parser.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_cfg_reader.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_cfg_writer.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_config_reader.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_config_reader_writer.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_config_writer.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_reader.cpp
+libNS_FrameworkUnified_SRCS += ./NS_ConfigParser/src/ns_writer.cpp
+CPPFLAGS += -I./NS_ConfigParser/include
+
+# NS_NPServiceIf
+libNS_FrameworkUnified_SRCS += ./NS_NPServiceIf/src/ns_np_service_api.c
+libNS_FrameworkUnified_SRCS += ./NS_NPServiceIf/src/ns_np_service_nor_persistence.cpp
+CPPFLAGS += -I./NS_NPServiceIf/include
+
+# NS_Timer
+libNS_FrameworkUnified_SRCS += ./NS_Timer/src/mod_version.c
+libNS_FrameworkUnified_SRCS += ./NS_Timer/src/ns_timer.c
+libNS_FrameworkUnified_SRCS += ./NS_Timer/src/ns_timer_class.cpp
+CPPFLAGS += -I./NS_Timer/include
+
+# NS_FrameworkCore
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_dispatcher.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_error.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_logger.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_session.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_sync.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_framework_system.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_multithreading.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_service_if.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_thread_priority.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/frameworkunified_timer.cpp
+CPPFLAGS += -I./NS_FrameworkCore/include
+
+# NS_FrameworkCore/src/statemachine
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp
+libNS_FrameworkUnified_SRCS += ./NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp
+CPPFLAGS += -I./NS_FrameworkCore/include/statemachine
+
+# NS__CWORD77__ServiceIf
+libNS_FrameworkUnified_SRCS += ./NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_table.cpp
+libNS_FrameworkUnified_SRCS += ./NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__service_if.cpp
+libNS_FrameworkUnified_SRCS += ./NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__session_if.cpp
+
+# NS_ResourceControler
+libNS_FrameworkUnified_SRCS += ./NS_ResourceControler/src/ns_resource_controler.cpp
+
+######### add include path #############
+CPPFLAGS += -I./include
+
+######### add compile option #############
+
+LDFLAGS += -Wl,--no-as-needed
+
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lrt
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+LDLIBS += -Wl,-Bdynamic -lcommon
+LINK_SHLIB_CXX = Y
+
+# buildversioncheck
+INST_HEADERS += ns_buildversioncheck.hpp
+
+
+SUBDIRS := NS_XMLConfigeParser NS_Utility
+
+
+
+all:
+
+install-data:install_cfg
+ install -d -m 775 $(DESTDIR)/nv/BS/ns/framework_unified/rwdata
+
+install_cfg:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/BS/ns/framework_unified/rodata
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/BS/ns/framework_unified/rodata NativeServices/scfg/ns_logger_frameworkunifiedlog__CWORD84_.cfg
+
+include ../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/cfg/depends.mk b/nsframework/framework_unified/client/NS_ConfigParser/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_internal.h b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_internal.h
new file mode 100644
index 00000000..64aad8b0
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_internal.h
@@ -0,0 +1,54 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains the declaration of internal structure for parsing cfg configuration
+/// file.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_INTERNAL_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include <vector>
+
+class CNode {
+ public:
+ CNode(): m_cComment(""), m_cTag(""), m_cValue("") {} // LCOV_EXCL_BR_LINE 11:except branch
+
+ ~CNode() {}
+
+ std::string m_cComment;
+ std::string m_cTag;
+ std::string m_cValue;
+};
+
+class CBlock {
+ public:
+ CBlock(): m_cComment("") {} // LCOV_EXCL_BR_LINE 11:except branch
+
+ ~CBlock() {}
+
+ std::string m_cComment;
+ std::vector<CNode> m_vElementPair;
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_parser.h b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_parser.h
new file mode 100644
index 00000000..8d7a47fd
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_parser.h
@@ -0,0 +1,148 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains the declaration of class CCFGParser.
+/// This class contains the parsing logic for reading and writing from and to cfg files
+/// respectively.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <map>
+
+// forward declaration of classes
+class CNode;
+class CBlock;
+
+typedef std::map<std::string, CBlock *> CFGData_Type;
+
+class CCFGParser {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCFGParser
+ /// Constructor of CCFGReader class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CCFGParser();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCFGParser
+ /// Constructor of CCFGReader class
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - Full path of the configuration file
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CCFGParser(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CCFGParser
+ /// Destructor of CCFGReader class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CCFGParser();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFGParseFile
+ /// This function is used to parse the configuration file and store data in internal structure
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - full path of the configuration file
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CFGParseFile(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFGGetData
+ /// This function is used to get the value associated with the key from internal CFG structure
+ ///
+ /// \param [IN] f_c_key
+ /// std::string - key to search
+ ///
+ /// \return std::string - value for key
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string CFGGetData(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFGGetData
+ /// This function is used to get the value associated with the key from internal CFG structure
+ ///
+ /// \param [IN] f_c_key
+ /// std::string - key to search
+ /// \param [IN] f_c_value
+ /// std::string - Value of key
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - error if key not founf or else eFrameworkunifiedStatusOK
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CFGGetData(const std::string &f_c_key, std::string &f_c_value); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFGSetData
+ /// This function is used to set the value for the key in internal CFG structure
+ ///
+ /// \param [IN] f_c_key
+ /// std::string - key to search
+ /// \param [IN] f_c_value
+ /// std::string - value to set
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CFGSetData(const std::string &f_c_key, std::string f_c_value);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFGSaveData
+ /// This function is used to save the changed value to the cfg config file
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - full path of the configuration file
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CFGSaveData(const std::string &f_c_filepath);
+
+ private:
+ // internal data structure created by parsing the cfg file
+ CFGData_Type *m_pmCFGData;
+ std::string m_cLastComment;
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_PARSER_H_
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_reader.h b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_reader.h
new file mode 100644
index 00000000..d47c04b1
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_reader.h
@@ -0,0 +1,133 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains declaration of class CCFGReader.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_READER_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_READER_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_reader.h>
+#include <string>
+
+class CCFGParser;
+
+/*
+ * This class provides functionalities to read from CFG config file
+ */
+class CCFGReader: public IConfigReader {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCFGReader
+ /// Constructor of CCFGReader class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CCFGReader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCFGReader
+ /// Constructor of CCFGReader class
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - Full path of the configuration file
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CCFGReader(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CCFGReader
+ /// Destructor of CCFGReader class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CCFGReader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ParseFile
+ /// This function is used to parse the file
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - path of file to parse
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ParseFile(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetString
+ /// This function is used to get the value associated with the key
+ ///
+ /// \param [IN] f_c_key
+ /// std::string - key to search
+ ///
+ /// \return std::string - value for key
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetValue(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetString
+ /// This function is used to get the value associated with the key
+ ///
+ /// \param [IN] f_c_key
+ /// std::string - key to search
+ /// \param [REF] f_c_value
+ /// std::string - Value of key
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - error if key not found else eFrameworkunifiedStatusOK
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetValue(const std::string &f_c_key, std::string &f_c_value); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetDataPtr
+ /// This function is used to get the data pointer. This pointer is then set in config writer.
+ /// This is needed to avoid recreation of same data structure object in both reader and writer
+ /// when we create object of NSConfigParser.
+ ///
+ /// \param
+ ///
+ /// \return PVOID - pointer of data structure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ PVOID GetDataPtr();
+
+ private:
+ // path of config file
+ std::string m_cFilePath;
+
+ // CFG file parser object
+ CCFGParser *m_pCFGParser;
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_READER_H_
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_writer.h b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_writer.h
new file mode 100644
index 00000000..58d16399
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_cfg_writer.h
@@ -0,0 +1,146 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains declaration of class CCFGWriter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_writer.h>
+#include <string>
+
+class CCFGParser;
+
+/*
+ * This class provides functionalities to write to CFG config file
+ */
+class CCFGWriter: public IConfigWriter {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCFGWriter
+ /// Constructor of CCFGWriter class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CCFGWriter();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCFGWriter
+ /// Constructor of CCFGWriter class
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - Full path of the configuration file
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CCFGWriter(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CCFGWriter
+ /// Destructor of CCFGWriter class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CCFGWriter();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ParseFile
+ /// This function is used to parse the file
+ ///
+ /// \param [IN] f_c_filepath
+ /// std::string - path of file to parse
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ParseFile(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetValue
+ /// This function is used to set the value for the key
+ ///
+ /// \param [IN] f_c_key
+ /// std::string - key to search
+ /// \param [IN] f_c_value
+ /// std::string - value to set
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - error if key not found else eFrameworkunifiedStatusOK
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetValue(const std::string &f_c_key, std::string f_c_value);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SaveData
+ /// This function is used to save the changed value to the cfg config file
+ ///
+ /// \param
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SaveData();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetDataPtr
+ /// This function is used to set the config file path
+ ///
+ /// \param [IN] f_c_path
+ /// std::string - Path of file
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetPath(const std::string &f_c_path);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetDataPtr
+ /// This function is used to set the data pointer in writer class with data pointer
+ /// created in config reader class.
+ /// This is needed to avoid recreation of same data structure object in both reader and writer
+ /// when we create object of NSConfigParser
+ ///
+ /// \param [IN] f_p_data
+ /// PVOID - Pointer to data structure
+ ///
+ /// \return VOID
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetDataPtr(PVOID f_p_data);
+
+ private:
+ // path of config file
+ std::string m_cFilePath;
+
+ // CFG file parser object
+ CCFGParser *m_pCFGParser;
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CFG_WRITER_H_
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/include/ns_config_parser_frameworkunifiedlog.h b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_config_parser_frameworkunifiedlog.h
new file mode 100644
index 00000000..c48f09d7
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/include/ns_config_parser_frameworkunifiedlog.h
@@ -0,0 +1,88 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CONFIG_PARSER_FRAMEWORKUNIFIEDLOG_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CONFIG_PARSER_FRAMEWORKUNIFIEDLOG_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGZONES
+// #define FRAMEWORKUNIFIEDLOGZONES (ZONE_WARN|ZONE_ERR)
+#define FRAMEWORKUNIFIEDLOGZONES (ZONE_INIT|ZONE_FUNC|ZONE_INFO|ZONE_WARN|ZONE_ERR|ZONE_NS_WAR|ZONE_NS_ERR)
+#endif
+
+extern const CHAR kAppName[];
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_CONFIGPARSER_INCLUDE_NS_CONFIG_PARSER_FRAMEWORKUNIFIEDLOG_H_
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_ConfigParser/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..1e6e556b
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/makefile_PosixBasedOS001
@@ -0,0 +1,207 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_ConfigParser
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_ConfigParser
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_XMLConfigParser/inc
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/native/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+#DYNAMIC_LIBS += \
+# xml2 \
+# m
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+module_dirs: build_dirs
+
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_parser.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_parser.cpp
new file mode 100644
index 00000000..a2abd785
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_parser.cpp
@@ -0,0 +1,365 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CCFGParser class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <ns_cfg_internal.h>
+#include <ns_cfg_parser.h>
+#include <ns_config_parser_frameworkunifiedlog.h>
+
+#include <fstream>
+#include <string>
+
+CCFGParser::CCFGParser()
+ : m_pmCFGData(NULL) {
+}
+
+// LCOV_EXCL_START 200:CCFGParser is not external API class, this constructed function isn't used by other function
+CCFGParser::CCFGParser(const std::string &f_cfilepath)
+ : m_pmCFGData(NULL) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CFGParseFile(f_cfilepath);
+}
+// LCOV_EXCL_STOP
+
+CCFGParser::~CCFGParser() {
+ CFGData_Type::iterator l_itCfgStructure;
+
+ if (NULL != m_pmCFGData) { // LCOV_EXCL_BR_LINE 5:m_pmCFGData cannot be NULL, because internal logic guarantee
+ // release the structure
+ for (l_itCfgStructure = m_pmCFGData->begin();
+ l_itCfgStructure != m_pmCFGData->end();
+ l_itCfgStructure++) {
+ CBlock *l_pBlock = (*l_itCfgStructure).second;
+ if (NULL != l_pBlock) { // LCOV_EXCL_BR_LINE 5:l_pBlock cannot be NULL, because map insert data success.
+ // clear the vector
+ l_pBlock->m_vElementPair.clear();
+
+ delete l_pBlock; // LCOV_EXCL_BR_LINE 11:except branch
+ l_pBlock = NULL;
+ }
+ }
+
+ delete m_pmCFGData; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pmCFGData = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CCFGParser::CFGParseFile(const std::string &f_cfilepath) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ size_t l_uiPos = 0;
+ std::string l_cLine("");
+ std::string l_cTag(""); // LCOV_EXCL_BR_LINE 11:except branch
+ std::string l_cComment(""); // LCOV_EXCL_BR_LINE 11:except branch
+
+ m_pmCFGData = new(std::nothrow) CFGData_Type(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (NULL != m_pmCFGData) { // LCOV_EXCL_BR_LINE 5:new's error case
+ // open the file
+ std::ifstream l_objFile(f_cfilepath.c_str()); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // check if file is opened
+ if (l_objFile.is_open()) {
+ CBlock *l_pBlock = NULL;
+
+ // read until end of file is not reached or any other stream error occurred
+ while (!l_objFile.eof()) {
+ // read the line from the file
+ getline(l_objFile, l_cLine); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // if line is a comment
+ if ('#' == l_cLine[0] || ';' == l_cLine[0]) {
+ if (!l_cComment.empty()) {
+ l_cComment.append("\n"); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+ l_cComment.append(l_cLine);
+ } else if ('[' == l_cLine[0]) { // if line is main tag
+ // creates new CBlock object,
+ // each block contains information of single like all its key-value pair and
+ // all the comments associated with it.
+ l_pBlock = new CBlock(); // LCOV_EXCL_BR_LINE 11:except branch
+ if (NULL != l_pBlock) { // LCOV_EXCL_BR_LINE 5:new's error case
+ // set the tag comment
+ l_pBlock->m_cComment = l_cComment;
+ l_cComment.clear();
+
+ if (std::string::npos != (l_uiPos = l_cLine.find(']'))) {
+ // set the tag
+ l_cTag = l_cLine.substr(1, l_uiPos - 1); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // insert the block with its tag name in structure(map)
+ m_pmCFGData->insert(make_pair(l_cTag, l_pBlock)); // NOLINT (readability/nolint)
+ } else {
+ delete l_pBlock; // LCOV_EXCL_BR_LINE 11:except branch
+ l_pBlock = NULL;
+
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "End Tag missing");
+ // LCOV_EXCL_BR_STOP
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ break;
+ }
+ } else {
+ // LCOV_EXCL_START 5:new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error allocating memory for l_pBlock");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } else if (std::string::npos != (l_uiPos = l_cLine.find('='))) { // LCOV_EXCL_BR_LINE 11:except branch
+ if (NULL != l_pBlock) { // LCOV_EXCL_BR_LINE 5:new's error case
+ // create new node object,
+ // each node object contains the information of singlr key-value pair and
+ /// it's comment(if any)
+ // LCOV_EXCL_BR_START 11:except branch
+ CNode l_objNode;
+ l_objNode.m_cComment.append(l_cComment);
+ l_objNode.m_cTag = l_cLine.substr(0, l_uiPos);
+ l_objNode.m_cValue = l_cLine.substr(l_uiPos + 1);
+
+ // insert the node object in block
+ l_pBlock->m_vElementPair.push_back(l_objNode);
+ // LCOV_EXCL_BR_STOP
+
+ l_cComment.clear();
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "l_pBlock is NULL");
+ // LCOV_EXCL_BR_STOP
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ break;
+ }
+ }
+ }
+
+ // last comment
+ if (!l_cComment.empty()) {
+ m_cLastComment = l_cComment;
+ } else {
+ m_cLastComment.clear();
+ }
+
+ // close the file
+ l_objFile.close(); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error Opening File");
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 5:new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "m_pmCFGData is NULL");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ return l_eStatus;
+}
+
+std::string CCFGParser::CFGGetData(const std::string &f_ckey) {
+ CFGData_Type::iterator l_itCfgStructure;
+ std::string l_cHeadTag = "";
+ std::string l_cTag = ""; // LCOV_EXCL_BR_LINE 11:except branch
+ std::string l_cValue = ""; // LCOV_EXCL_BR_LINE 11:except branch
+
+ size_t l_uiPos = 0;
+
+ if (NULL != m_pmCFGData && !f_ckey.empty()) { // LCOV_EXCL_BR_LINE 5:new's error case(in function CFGParseFile)
+ if (std::string::npos != (l_uiPos = f_ckey.find('.'))) { // LCOV_EXCL_BR_LINE 11:except branch
+ l_cHeadTag = f_ckey.substr(0, l_uiPos); // LCOV_EXCL_BR_LINE 11:except branch
+ l_cTag = f_ckey.substr(l_uiPos + 1); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ // search for the key and its associated value in internal structure
+ for (l_itCfgStructure = m_pmCFGData->begin();
+ l_itCfgStructure != m_pmCFGData->end();
+ l_itCfgStructure++) {
+ CBlock *l_pBlock = (*l_itCfgStructure).second;
+
+ if (!l_cHeadTag.compare((*l_itCfgStructure).first) && NULL != l_pBlock) {
+ for (UI_32 l_uiCount = 0; l_uiCount < l_pBlock->m_vElementPair.size(); l_uiCount++) {
+ if (!l_cTag.compare(l_pBlock->m_vElementPair[l_uiCount].m_cTag)) {
+ // LCOV_EXCL_BR_START 200:After l_cValue assignment is empty,there is no other place to assignment the value
+ if (!l_cValue.empty()) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 200:After l_cValue assignment is empty,there is no other place to assignment the value
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_cValue.append("\n");
+ // LCOV_EXCL_STOP 200
+ }
+ l_cValue.append(l_pBlock->m_vElementPair[l_uiCount].m_cValue);
+ }
+ }
+ }
+ }
+ }
+
+ return l_cValue;
+}
+
+EFrameworkunifiedStatus CCFGParser::CFGGetData(const std::string &f_ckey, std::string &f_cvalue) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ CFGData_Type::iterator l_itCfgStructure;
+ std::string l_cHeadTag = "";
+ std::string l_cTag = ""; // LCOV_EXCL_BR_LINE 11:except branch
+ std::string l_cValue = ""; // LCOV_EXCL_BR_LINE 11:except branch
+
+ size_t l_uiPos = 0;
+
+ if (NULL != m_pmCFGData && !f_ckey.empty()) { // LCOV_EXCL_BR_LINE 5:new's error case(in function CFGParseFile)
+ if (std::string::npos != (l_uiPos = f_ckey.find('.'))) { // LCOV_EXCL_BR_LINE 11:except branch
+ l_cHeadTag = f_ckey.substr(0, l_uiPos); // LCOV_EXCL_BR_LINE 11:except branch
+ l_cTag = f_ckey.substr(l_uiPos + 1); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ // search for the key and its associated value in internal structure
+ for (l_itCfgStructure = m_pmCFGData->begin();
+ l_itCfgStructure != m_pmCFGData->end();
+ l_itCfgStructure++) {
+ CBlock *l_pBlock = (*l_itCfgStructure).second;
+
+ if (!l_cHeadTag.compare((*l_itCfgStructure).first) && NULL != l_pBlock) {
+ for (UI_32 l_uiCount = 0; l_uiCount < l_pBlock->m_vElementPair.size(); l_uiCount++) {
+ if (!l_cTag.compare(l_pBlock->m_vElementPair[l_uiCount].m_cTag)) {
+ if (!f_cvalue.empty()) {
+ f_cvalue.append("\n");
+ }
+ f_cvalue.append(l_pBlock->m_vElementPair[l_uiCount].m_cValue);
+
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ }
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CCFGParser::CFGSetData(const std::string &f_cKey, std::string f_cvalue) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ CFGData_Type::iterator l_itCfgStructure;
+ std::string l_cHeadTag = "";
+ std::string l_cTag = ""; // LCOV_EXCL_BR_LINE 11:except branch
+ std::string l_cValue = ""; // LCOV_EXCL_BR_LINE 11:except branch
+ size_t l_uiPos = 0;
+
+ // LCOV_EXCL_BR_START 6:f_cKey is not NULL, because checked in CCFGWriter::SetValue
+ if (NULL != m_pmCFGData && !f_cKey.empty()) {
+ // LCOV_EXCL_BR_STOP
+ if (std::string::npos != (l_uiPos = f_cKey.find('.'))) { // LCOV_EXCL_BR_LINE 11:except branch
+ l_cHeadTag = f_cKey.substr(0, l_uiPos); // LCOV_EXCL_BR_LINE 11:except branch
+ l_cTag = f_cKey.substr(l_uiPos + 1); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ // search for the key in internal structure and set the data for it
+ for (l_itCfgStructure = m_pmCFGData->begin();
+ l_itCfgStructure != m_pmCFGData->end();
+ l_itCfgStructure++) {
+ CBlock *l_pBlock = (*l_itCfgStructure).second;
+
+ if (!l_cHeadTag.compare((*l_itCfgStructure).first) && NULL != l_pBlock) {
+ for (UI_32 l_uiCount = 0; l_uiCount < l_pBlock->m_vElementPair.size(); l_uiCount++) {
+ if (!l_cTag.compare(l_pBlock->m_vElementPair[l_uiCount].m_cTag)) {
+ l_pBlock->m_vElementPair[l_uiCount].m_cValue.assign(f_cvalue);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6:f_cKey is not NULL, because checked in CCFGWriter::SetValue
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "m_pmCFGData is NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CCFGParser::CFGSaveData(const std::string &f_cfilepath) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ CFGData_Type::iterator l_itCfgStructure;
+
+ if (NULL != m_pmCFGData) { // LCOV_EXCL_BR_LINE 5:m_pmCFGData cannot be NULL, because internal logic guarantee
+ std::ofstream l_objFile(f_cfilepath.c_str());
+
+ // check if file is open
+ if (l_objFile.is_open()) {
+ // write the updated CFG structure back to the file
+ for (l_itCfgStructure = m_pmCFGData->begin();
+ l_itCfgStructure != m_pmCFGData->end();
+ l_itCfgStructure++) {
+ CBlock *l_pBlock = (*l_itCfgStructure).second;
+ if (NULL != l_pBlock) { // LCOV_EXCL_BR_LINE 11:except branch
+ // write the main tag comment in file
+ if (!l_pBlock->m_cComment.empty()) {
+ l_objFile << l_pBlock->m_cComment << std::endl;
+ }
+
+ // write main tag to file
+ l_objFile << "[" << (*l_itCfgStructure).first << "]" << std::endl;
+
+ for (UI_32 l_uiCount = 0; l_uiCount < l_pBlock->m_vElementPair.size(); l_uiCount++) {
+ // comment over the key-value pair
+ if (!l_pBlock->m_vElementPair[l_uiCount].m_cComment.empty()) {
+ l_objFile << l_pBlock->m_vElementPair[l_uiCount].m_cComment << std::endl;;
+ }
+
+ // key-value
+ l_objFile << l_pBlock->m_vElementPair[l_uiCount].m_cTag << "="
+ << l_pBlock->m_vElementPair[l_uiCount].m_cValue << std::endl;
+ }
+ }
+ }
+
+ // last comment
+ if (!m_cLastComment.empty()) {
+ l_objFile << m_cLastComment << std::endl;
+ }
+
+ // close the file
+ l_objFile.close(); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Cannot Open File");
+ }
+ } else {
+ // LCOV_EXCL_START 5:m_pmCFGData cannot be NULL, because internal logic guarantee
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "m_pmCFGData is NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_reader.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_reader.cpp
new file mode 100644
index 00000000..9eeb3c00
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_reader.cpp
@@ -0,0 +1,117 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CCFGReader class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <ns_cfg_reader.h>
+#include <ns_cfg_parser.h>
+#include <ns_config_parser_frameworkunifiedlog.h>
+#include <string>
+
+
+
+CCFGReader::CCFGReader(): m_cFilePath(""), m_pCFGParser(NULL) { // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+// LCOV_EXCL_START 200:CCFGReader is not external API class, this constructed function isn't used by other function
+CCFGReader::CCFGReader(const std::string &f_c_filepath): m_cFilePath(f_c_filepath), m_pCFGParser(NULL) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", m_cFilePath.c_str());
+
+ m_pCFGParser = new CCFGParser(m_cFilePath);
+
+ if (NULL == m_pCFGParser) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Memory allocation error for m_pCFGParser");
+ }
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CCFGReader::ParseFile(const std::string &f_c_filepath) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ m_cFilePath.assign(f_c_filepath);
+
+ m_pCFGParser = new(std::nothrow) CCFGParser(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (NULL == m_pCFGParser) { // LCOV_EXCL_BR_LINE 5:new's error case
+ // LCOV_EXCL_START 5:new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Memory allocation error for m_pCFGParser");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ l_e_status = m_pCFGParser->CFGParseFile(f_c_filepath);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_e_status;
+}
+
+CCFGReader::~CCFGReader() {
+ if (NULL != m_pCFGParser) {
+ delete m_pCFGParser;
+ m_pCFGParser = NULL;
+ }
+}
+
+PVOID CCFGReader::GetDataPtr() {
+ return m_pCFGParser;
+}
+
+std::string CCFGReader::GetValue(const std::string &f_c_key) {
+ std::string l_cValue = "";
+
+ if (NULL != m_pCFGParser && !f_c_key.empty()) { // LCOV_EXCL_BR_LINE 11:except branch
+ // read the data from internal CFG structure
+ l_cValue = m_pCFGParser->CFGGetData(f_c_key); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ return l_cValue;
+}
+
+EFrameworkunifiedStatus CCFGReader::GetValue(const std::string &f_c_key, std::string &f_c_value) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL == m_pCFGParser) { // LCOV_EXCL_BR_LINE 5:m_pCFGParser cannot be NULL, because internal logic guarantee
+ // LCOV_EXCL_START 5:m_pCFGParser cannot be NULL, because internal logic guarantee
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Parser object(m_pCFGParser) is NULL");
+ // LCOV_EXCL_STOP
+ } else if (f_c_key.empty()) {
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid Key");
+ // LCOV_EXCL_BR_STOP
+ } else {
+ // read the data from internal CFG structure
+ l_e_status = m_pCFGParser->CFGGetData(f_c_key, f_c_value);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_e_status;
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_writer.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_writer.cpp
new file mode 100644
index 00000000..4bf16d5f
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_cfg_writer.cpp
@@ -0,0 +1,135 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CCFGWriter class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <ns_cfg_parser.h>
+#include <ns_cfg_writer.h>
+#include <ns_config_parser_frameworkunifiedlog.h>
+
+#include <fstream>
+#include <string>
+
+
+CCFGWriter::CCFGWriter(): m_cFilePath(""), m_pCFGParser(NULL) { // LCOV_EXCL_BR_LINE 11:except branch
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+}
+
+CCFGWriter::CCFGWriter(const std::string &f_c_filepath): m_cFilePath(f_c_filepath), m_pCFGParser(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", m_cFilePath.c_str());
+
+ m_pCFGParser = new CCFGParser(m_cFilePath);
+
+ if (NULL == m_pCFGParser) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Memory allocation error for m_pCFGParser");
+ }
+}
+
+CCFGWriter::~CCFGWriter() {
+ if (NULL != m_pCFGParser) {
+ delete m_pCFGParser; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pCFGParser = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CCFGWriter::ParseFile(const std::string &f_c_filepath) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ m_cFilePath.assign(f_c_filepath);
+
+ m_pCFGParser = new(std::nothrow) CCFGParser(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (NULL == m_pCFGParser) { // LCOV_EXCL_BR_LINE 5:m_pCFGParser cannot be NULL, because internal logic guarantee
+ // LCOV_EXCL_START 5:m_pCFGParser cannot be NULL, because internal logic guarantee
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Memory allocation error for m_pCFGParser");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ l_e_status = m_pCFGParser->CFGParseFile(f_c_filepath);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CCFGWriter::SetPath(const std::string &f_c_path) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (!f_c_path.empty()) { // LCOV_EXCL_BR_LINE 11:except branch
+ // set the file path
+ m_cFilePath.assign(f_c_path);
+ } else {
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_e_status;
+}
+
+VOID CCFGWriter::SetDataPtr(PVOID f_p_data) {
+ if (NULL != f_p_data) {
+ // set the doc pointer
+ m_pCFGParser = static_cast<CCFGParser *>(f_p_data);
+ } else {
+ m_pCFGParser = NULL;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Data Pointer not set in cfg writer"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+}
+
+EFrameworkunifiedStatus CCFGWriter::SetValue(const std::string &f_c_key, std::string f_c_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pCFGParser && !f_c_key.empty()) {
+ // set the data in internal CFG structure
+ l_e_status = m_pCFGParser->CFGSetData(f_c_key, f_c_value); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CCFGWriter::SaveData() {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pCFGParser) {
+ if (0 == access(m_cFilePath.c_str(), W_OK)) {
+ // save the data permanently in config file
+ l_e_status = m_pCFGParser->CFGSaveData(m_cFilePath);
+ } else {
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader.cpp
new file mode 100644
index 00000000..839053af
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader.cpp
@@ -0,0 +1,346 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CNSConfigReader class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <stdlib.h>
+#include <ctype.h>
+#include <dlfcn.h>
+#include <errno.h>
+
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/ns_reader.h>
+
+#include <cstring>
+#include <string>
+
+#include "ns_config_parser_frameworkunifiedlog.h"
+#include "ns_cfg_reader.h"
+CNSConfigReader::CNSConfigReader() {
+ m_pReader = NULL;
+}
+
+CNSConfigReader::CNSConfigReader(const std::string &f_c_filepath): m_pReader(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ if (eFrameworkunifiedStatusOK != Parse(f_c_filepath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Parsing file %s", f_c_filepath.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+}
+
+CNSConfigReader::~CNSConfigReader() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Destructor");
+
+ if (NULL != m_pReader) {
+ delete m_pReader; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pReader = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CNSConfigReader::Parse(const std::string &f_c_filepath) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ if (NULL != m_pReader) {
+ delete m_pReader; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pReader = NULL;
+ }
+
+ // create parser object depending on file extension
+ if (NULL != std::strstr(f_c_filepath.c_str(), ".cfg")) {
+ m_pReader = new(std::nothrow) CCFGReader(); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Not CFG"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+
+ if (NULL != m_pReader) {
+ l_e_status = m_pReader->ParseFile(f_c_filepath);
+ } else {
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_e_status;
+}
+
+PVOID CNSConfigReader::GetDataPtr() {
+ if (NULL != m_pReader) {
+ // get the data pointer
+ return m_pReader->GetDataPtr();
+ } else {
+ return NULL;
+ }
+}
+
+BOOL CNSConfigReader::GetBool(const std::string &f_c_key) {
+ BOOL l_bResult = FALSE;
+
+ if (NULL != m_pReader) {
+ std::string l_c_temp = m_pReader->GetValue(f_c_key);
+
+ l_c_temp = FormatValue(l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (!strcasecmp(l_c_temp.c_str(), "true")) {
+ l_bResult = TRUE;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ return l_bResult;
+}
+
+F_64 CNSConfigReader::GetDouble(const std::string &f_c_key) {
+ F_64 l_fValue = 0;
+
+ if (NULL != m_pReader) {
+ std::string l_c_temp = m_pReader->GetValue(f_c_key);
+
+ errno = EOK;
+
+ // convert string to double
+ l_fValue = strtod(l_c_temp.c_str(), NULL);
+
+ if (EOK != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to double, errno=%d", l_c_temp.c_str(), errno);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ return l_fValue;
+}
+
+F_32 CNSConfigReader::GetFloat(const std::string &f_c_key) {
+ F_32 l_fValue = 0;
+
+ if (NULL != m_pReader) {
+ std::string l_c_temp = m_pReader->GetValue(f_c_key);
+ errno = EOK;
+ l_fValue = strtof(l_c_temp.c_str(), NULL);
+
+ if (EOK != errno) {
+ l_fValue = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to float, errno=%d", l_c_temp.c_str(), errno);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ return l_fValue;
+}
+
+SI_32 CNSConfigReader::GetInt(const std::string &f_c_key) {
+ UI_64 l_ui_value = 0;
+
+ if (NULL != m_pReader) {
+ std::string l_c_temp = m_pReader->GetValue(f_c_key);
+
+ errno = EOK;
+
+ if ((l_c_temp.size() >= 3) && ('0' == l_c_temp[0]) && ('X' == toupper(l_c_temp[1]))) {
+ l_ui_value = strtoul(l_c_temp.c_str(), NULL, 16);
+ } else {
+ l_ui_value = strtoul(l_c_temp.c_str(), NULL, 10);
+ }
+
+ if (EOK != errno) {
+ l_ui_value = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to int, errno=%d", l_c_temp.c_str(), errno);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ return static_cast<SI_32>(l_ui_value);
+}
+
+std::string CNSConfigReader::GetString(const std::string &f_c_key) {
+ std::string l_c_temp = "";
+
+ if (NULL != m_pReader) {
+ l_c_temp = m_pReader->GetValue(f_c_key); // LCOV_EXCL_BR_LINE 11:except branch
+
+ l_c_temp = FormatValue(l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL");
+ }
+
+ return l_c_temp;
+}
+
+EFrameworkunifiedStatus CNSConfigReader::GetBool(const std::string &f_c_key, BOOL &f_b_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ std::string l_c_temp = "";
+
+ if (NULL != m_pReader) {
+ l_e_status = m_pReader->GetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (eFrameworkunifiedStatusOK == l_e_status) {
+ l_c_temp = FormatValue(l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (!strcasecmp(l_c_temp.c_str(), "true")) {
+ f_b_value = TRUE;
+ } else if (!strcasecmp(l_c_temp.c_str(), "false")) {
+ f_b_value = FALSE;
+ } else {
+ l_e_status = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigReader::GetDouble(const std::string &f_c_key, F_64 &f_d_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ std::string l_c_temp = "";
+
+ if (NULL != m_pReader) {
+ l_e_status = m_pReader->GetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (eFrameworkunifiedStatusOK == l_e_status) {
+ errno = EOK;
+ f_d_value = strtod(l_c_temp.c_str(), NULL);
+
+ if (EOK != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to double, errno=%d", l_c_temp.c_str(), errno);
+ l_e_status = eFrameworkunifiedStatusInvldBuf;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigReader::GetFloat(const std::string &f_c_key, F_32 &f_f_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ std::string l_c_temp = "";
+
+ if (NULL != m_pReader) {
+ l_e_status = m_pReader->GetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (eFrameworkunifiedStatusOK == l_e_status) {
+ errno = EOK;
+ f_f_value = strtof(l_c_temp.c_str(), NULL);
+
+ if (EOK != errno) {
+ f_f_value = 0;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to float, errno=%d", l_c_temp.c_str(), errno);
+ l_e_status = eFrameworkunifiedStatusInvldBuf;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigReader::GetInt(const std::string &f_c_key, SI_32 &f_i_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ std::string l_c_temp = "";
+
+ UI_64 l_ui_value = 0;
+
+ if (NULL != m_pReader) {
+ l_e_status = m_pReader->GetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (eFrameworkunifiedStatusOK == l_e_status) {
+ errno = EOK;
+
+ if ((l_c_temp.size() >= 3) && ('0' == l_c_temp[0]) && ('X' == toupper(l_c_temp[1]))) {
+ l_ui_value = strtoul(l_c_temp.c_str(), NULL, 16);
+ } else {
+ l_ui_value = strtoul(l_c_temp.c_str(), NULL, 10);
+ }
+
+ f_i_value = static_cast<SI_32>(l_ui_value);
+
+ if (EOK != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to int, errno=%d", l_c_temp.c_str(), errno);
+ l_e_status = eFrameworkunifiedStatusInvldBuf;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigReader::GetString(const std::string &f_c_key, std::string &f_c_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ std::string l_c_temp = "";
+
+ if (NULL != m_pReader) {
+ l_e_status = m_pReader->GetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (eFrameworkunifiedStatusOK == l_e_status) {
+ l_c_temp = FormatValue(l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+
+ f_c_value.assign(l_c_temp);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Reader (m_pReader) is NULL");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+std::string CNSConfigReader::FormatValue(const std::string &f_c_value) {
+ std::string l_c_newvalue = f_c_value;
+
+ if (0 < f_c_value.length()) {
+ UI_32 l_uiStrPos = static_cast<UI_32>(l_c_newvalue.length() - 1);
+
+ while ('\n' == l_c_newvalue[l_uiStrPos] || '\r' == l_c_newvalue[l_uiStrPos]) {
+ l_c_newvalue = l_c_newvalue.substr(0, l_uiStrPos);
+
+ if (0 == l_uiStrPos) {
+ break;
+ }
+
+ l_uiStrPos--;
+ }
+ }
+
+ return l_c_newvalue;
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader_writer.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader_writer.cpp
new file mode 100644
index 00000000..6c2b2d6e
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_reader_writer.cpp
@@ -0,0 +1,74 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CNSConfigParser class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_config_parser_if.h>
+#include <string>
+#include "ns_config_parser_frameworkunifiedlog.h"
+
+CNSConfigParser::CNSConfigParser() : CNSConfigReader(), CNSConfigWriter() { // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+CNSConfigParser::CNSConfigParser(const std::string &f_c_filepath): CNSConfigReader(f_c_filepath),
+ CNSConfigWriter(f_c_filepath, TRUE) { // LCOV_EXCL_BR_LINE 11:except branch
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ // get the data pointer from the config reader
+ PVOID l_pdata = GetDataPtr(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // set the same data pointer in config writer
+ SetDataPtr(l_pdata); // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+CNSConfigParser::~CNSConfigParser() { // LCOV_EXCL_BR_LINE 11:except branch
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Destructor");
+
+ // set the data pointer to NULL in writer
+ SetDataPtr(NULL); // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+EFrameworkunifiedStatus CNSConfigParser::Parse(const std::string &f_c_filepath) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ // parse and create config document structure with reader
+ if (eFrameworkunifiedStatusOK == (l_e_status = CNSConfigReader::Parse(f_c_filepath))) {
+ // set the data pointer to NULL in writer
+ SetDataPtr(NULL);
+
+ // sets the same config document structure in writer
+ if (eFrameworkunifiedStatusOK == (l_e_status = CNSConfigWriter::Create(f_c_filepath))) {
+ // get the data pointer from the config reader
+ PVOID l_pdata = GetDataPtr();
+
+ // set the same data pointer in config writer
+ SetDataPtr(l_pdata);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_e_status;
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_writer.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_writer.cpp
new file mode 100644
index 00000000..601500de
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_config_writer.cpp
@@ -0,0 +1,227 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CNSConfigWriter class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/ns_writer.h>
+#include <dlfcn.h>
+#include <sstream>
+#include <cstring>
+#include <string>
+#include "ns_cfg_writer.h"
+#include "ns_config_parser_frameworkunifiedlog.h"
+
+
+CNSConfigWriter::CNSConfigWriter(): m_pWriter(NULL) {
+}
+
+CNSConfigWriter::CNSConfigWriter(const std::string &f_c_filepath): m_pWriter(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ Parse(f_c_filepath);
+}
+
+CNSConfigWriter::CNSConfigWriter(const std::string &f_c_filepath, BOOL f_b_noload): m_pWriter(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_c_filepath.c_str());
+
+ Create(f_c_filepath);
+}
+
+CNSConfigWriter::~CNSConfigWriter() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Destructor");
+
+ if (NULL != m_pWriter) {
+ delete m_pWriter; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pWriter = NULL;
+ }
+ // TODO(my_username): dlclose.
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Parse(const std::string &f_c_filepath) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ delete m_pWriter; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pWriter = NULL;
+ }
+
+ // create parser object depending on file extension
+ if (std::strstr(f_c_filepath.c_str(), ".cfg") != NULL) {
+ m_pWriter = new(std::nothrow) CCFGWriter(); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Not CFG");
+ // LCOV_EXCL_BR_STOP
+ }
+
+ if (NULL != m_pWriter) {
+ l_e_status = m_pWriter->ParseFile(f_c_filepath);
+ } else {
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Create(const std::string &f_c_filepath) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ delete m_pWriter; // LCOV_EXCL_BR_LINE 11:except branch
+ m_pWriter = NULL;
+ }
+
+ // create parser object depending on file extension
+ if (std::strstr(f_c_filepath.c_str(), ".cfg") != NULL) {
+ m_pWriter = new(std::nothrow) CCFGWriter(); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Not CFG");
+ // LCOV_EXCL_BR_STOP
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+
+ if (NULL != m_pWriter) {
+ l_e_status = m_pWriter->SetPath(f_c_filepath);
+ } else {
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+VOID CNSConfigWriter::SetDataPtr(PVOID f_p_data) {
+ if (NULL != m_pWriter) {
+ m_pWriter->SetDataPtr(f_p_data);
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "m_pWriter is NULL");
+ // LCOV_EXCL_BR_STOP
+ }
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Save() {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ // save the updated config file
+ l_e_status = m_pWriter->SaveData();
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Writer (m_pWriter) is NULL");
+ // LCOV_EXCL_BR_STOP
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::SetBool(const std::string &f_c_key, BOOL f_b_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ std::string l_c_temp = "";
+
+ if (TRUE == f_b_value) {
+ l_c_temp = "TRUE";
+ l_e_status = m_pWriter->SetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+ } else if (FALSE == f_b_value) { // LCOV_EXCL_BR_LINE 11:except branch
+ l_c_temp = "FALSE";
+ l_e_status = m_pWriter->SetValue(f_c_key, l_c_temp); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "received bool value is not proper:: %d", f_b_value);
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Writer (m_pWriter) is NULL");
+ // LCOV_EXCL_BR_STOP
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Set(const std::string &f_cKey, F_64 f_f_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ std::stringstream l_cStream;
+ l_cStream << f_f_value;
+
+ l_e_status = m_pWriter->SetValue(f_cKey, l_cStream.str()); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Writer (m_pWriter) is NULL");
+ // LCOV_EXCL_BR_STOP
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Set(const std::string &f_cKey, F_32 f_fValue) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) { // LCOV_EXCL_BR_LINE 11:except branch
+ std::stringstream l_cStream;
+ l_cStream << f_fValue;
+
+ l_e_status = m_pWriter->SetValue(f_cKey, l_cStream.str()); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Writer (m_pWriter) is NULL");
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Set(const std::string &f_cKey, SI_32 f_si_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ std::stringstream l_cStream;
+ l_cStream << f_si_value; // LCOV_EXCL_BR_LINE 11:except branch
+
+ l_e_status = m_pWriter->SetValue(f_cKey, l_cStream.str()); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Writer (m_pWriter) is NULL"); // LCOV_EXCL_BR_LINE 11:except branch
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
+
+EFrameworkunifiedStatus CNSConfigWriter::Set(const std::string &f_cKey, const std::string &f_s_value) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pWriter) {
+ l_e_status = m_pWriter->SetValue(f_cKey, f_s_value); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Config Writer (m_pWriter) is NULL"); // LCOV_EXCL_BR_LINE 11:except branch
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_e_status;
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_reader.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_reader.cpp
new file mode 100644
index 00000000..ff3cc7a4
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_reader.cpp
@@ -0,0 +1,36 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of IConfigReader class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_reader.h>
+#include <ns_config_parser_frameworkunifiedlog.h>
+
+
+IConfigReader::IConfigReader() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+}
+
+IConfigReader::~IConfigReader() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+}
diff --git a/nsframework/framework_unified/client/NS_ConfigParser/src/ns_writer.cpp b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_writer.cpp
new file mode 100644
index 00000000..b2b52f08
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ConfigParser/src/ns_writer.cpp
@@ -0,0 +1,36 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of IConfigWriter class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_writer.h>
+#include <ns_config_parser_frameworkunifiedlog.h>
+
+
+IConfigWriter::IConfigWriter() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+}
+
+IConfigWriter::~IConfigWriter() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/cfg/depends.mk b/nsframework/framework_unified/client/NS_FrameworkCore/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h
new file mode 100644
index 00000000..cb8bcee7
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_core.h
@@ -0,0 +1,676 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Application framework's core structures and data types.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_CORE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_CORE_H_
+
+#include <pthread.h>
+#include <errno.h>
+
+#include <other_service/strlcpy.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/ns_logger_if.h>
+
+#include <iostream>
+#include <string>
+#include <map>
+#include <queue>
+#include <cstdio>
+#include <vector>
+#include <utility>
+
+static const UI_32 THREAD_SESSION_ID = 0;
+
+typedef HANDLE SessionHandle;
+typedef int SessionId; // < service protocol command
+typedef int ServiceProtocolCommand; // < service protocol command
+typedef int Fd; // < FD associated with callback
+typedef std::string Notification; // < notification name
+typedef std::string ServiceName; // < service name
+typedef std::string ThreadName;
+typedef std::string DataKey;
+typedef std::string InvokerName;
+typedef int Socket;
+typedef std::string ConnectKey;
+typedef PVOID Data;
+
+typedef std::map<Notification, CallbackFunctionPtr> NotificationTable;
+
+
+typedef std::map<ServiceProtocolCommand, CallbackFunctionPtr> ServiceProtocolTable;
+typedef std::map<SessionId, ServiceProtocolTable> SessionTable;
+typedef std::map<ServiceName, SessionTable> Services;
+typedef std::map<HANDLE, ServiceName> ServiceSendMsgHandle;
+typedef std::map<Fd, CallbackFunctionPtr> FdTable;
+
+typedef int EventId;
+typedef std::map<ServiceProtocolCommand, EventId> ServiceEventProtocolTable;
+typedef std::map<SessionId, ServiceEventProtocolTable> EventSessionTable;
+typedef std::map<ServiceName, EventSessionTable> EventServices;
+typedef std::map<Notification, EventId> NotificationEventTable;
+typedef std::map<SessionId, SessionHandle> SessionHandleTable;
+typedef std::map<ServiceName, SessionHandleTable> ServiceSessionTable;
+typedef std::map<InvokerName, HANDLE> InvokeResponseQTable;
+typedef std::map<Socket, ConnectKey> AcceptMonitorTable;
+typedef std::map<Socket, ConnectKey> ConnectMonitorTable;
+
+typedef std::pair<NotificationTable::iterator, bool> NotificationTableRetStatus;
+typedef std::map<DataKey, Data> AppData;
+
+// private event data structure
+typedef struct _EventData {
+ PVOID pData; /// <message data
+ UI_32 uiLength; /// <message length
+} EventData;
+
+// framework message queue info
+typedef struct _MsgQInfo {
+ CHAR cSrcName[MAX_NAME_SIZE_APP]; /// <source message queue name
+ CHAR cMsgQName[MAX_NAME_SIZE_APP]; /// <name of the handle to the msgq
+ UI_32 checkCode;
+ pthread_t self;
+ HANDLE hMsgQ; /// <handle to message queue
+ UI_32 sessionId; /// <Used only when it is a session handle
+} MsgQInfo;
+
+#define MSGQ_CHECK_CODE (0xACCE55ED)
+
+static inline BOOL frameworkunifiedCheckValidMsgQ(HANDLE hService) {
+ static __thread int detect_once = 0;
+ if (NULL != hService) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
+ /**
+ * @todo
+ * If an application handle is specified in place of a session handle,
+ * the element is accessed illegally without type checking,
+ * and a DeathTest occurs because the thread_self check is violated.
+ */
+ if (pMsgQ->self != pthread_self() && detect_once == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Invalid thread context detect(hService/hSession):%#lx:%#lx", pMsgQ->self,
+ pthread_self());
+ detect_once = 1;
+ }
+ if (pMsgQ->checkCode == MSGQ_CHECK_CODE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/* data structure for public state events and data associated with it */
+// map of state events and data associated with it
+typedef std::map<UI_32, EventData *> PublicStateEventTable;
+
+/* data structure for private state events and data associated with it */
+// list of session id's of service and event data(private) associated with it
+typedef std::map<UI_32, EventData *> SessionEventData;
+
+// map of service name and list of its session id's and associated event data
+typedef std::map<ServiceName, SessionEventData> ServiceSessionEventData;
+
+// map of private events and the data published on the all sessions of all services subscribed to it
+typedef std::map<UI_32, ServiceSessionEventData> PrivateStateEventTable;
+
+
+// list of session id's for each service registering with event
+typedef std::vector<UI_32> SessionIdList;
+typedef std::vector<UI_32> EventIdList;
+
+// map of service name and and list of its session id
+typedef std::map<ServiceName, SessionIdList> ServiceSessionIdListTable;
+// map of events and its subscribers
+typedef std::map<UI_32, ServiceSessionIdListTable> EventTable;
+
+// structure to hold the session handle and list of event ids for that session
+typedef struct _SessionEventInfo {
+ HANDLE m_hSession; // Msg queue handle for the specific session
+ EventIdList m_vEvents; // List of event ids corresponding to the session
+} SessionEventInfo, *PSessionEventInfo;
+
+// map to hold the session id and structure of session event info
+typedef std::map<SessionId, SessionEventInfo *> SessionToEventInfo;
+
+// map of service name with session id and session handle
+typedef std::map<ServiceName, SessionToEventInfo > ServiceSessionHandleTable;
+
+// Defer'ed queue
+// When a pop is issued this data will be copied to the internal CFrameworkunifiedFrameworkApp struct
+// which will call the FrameworkunifiedDispatchProcess that will process the message as if
+// it was received off the message queue!
+class DeferedMsgInfo {
+ void copy_me(const DeferedMsgInfo &defer) {
+ if (this != &defer) {
+ uiProtocolCmd = defer.uiProtocolCmd;
+ strlcpy(cMsgSrcName, defer.cMsgSrcName, sizeof(cMsgSrcName));
+ std::memcpy(uiMsgRcvBuffer, defer.uiMsgRcvBuffer, MAX_MSGQ_BUFFER);
+ }
+ }
+
+ public:
+ UI_32 uiProtocolCmd; /// <protocol req/ack received
+ CHAR cMsgSrcName[MAX_NAME_SIZE_APP]; /// <name of client/server(application) message queue
+ UI_8 uiMsgRcvBuffer[MAX_MSGQ_BUFFER]; /// <receive buffer for message queue
+
+ DeferedMsgInfo() : uiProtocolCmd(0) {
+ std::memset(uiMsgRcvBuffer, 0, MAX_MSGQ_BUFFER);
+ std::memset(cMsgSrcName, '\0', MAX_NAME_SIZE_APP);
+ }
+
+ DeferedMsgInfo(const DeferedMsgInfo &defer) {
+ copy_me(defer); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ DeferedMsgInfo(UI_32 cmd, PCSTR name, UI_8 buf[MAX_MSGQ_BUFFER]) {
+ DeferedMsgInfo defer;
+
+ defer.uiProtocolCmd = cmd;
+ strlcpy(defer.cMsgSrcName, name, sizeof(defer.cMsgSrcName));
+ std::memcpy(defer.uiMsgRcvBuffer, buf, MAX_MSGQ_BUFFER);
+
+ copy_me(defer);
+ }
+
+ DeferedMsgInfo &operator = (const DeferedMsgInfo &defer) {
+ copy_me(defer);
+
+ return *this;
+ }
+};
+
+typedef struct _ServiceNotificationInfo {
+ CHAR sNotificationName[MAX_SYS_INFO_SIZE];
+ UI_32 uiEventId;
+} ServiceNotificationInfo;
+
+typedef std::vector<ServiceNotificationInfo> NotificationList;
+typedef std::queue<DeferedMsgInfo> DeferedMessageQueue;
+
+typedef struct _LostSessionInfo {
+ std::string sServiceName;
+ SessionId iSessionId;
+} LostSessionInfo;
+
+typedef std::queue<LostSessionInfo> LostSessionQueue;
+
+#ifdef DISPATCHER_PROFILER
+class FrameworkunifiedMsgProfiler;
+#endif
+
+class ResponseData {
+ std::vector<UI_8> rawBuffer;
+
+ public:
+ void set(PVOID src, UI_32 size) {
+ rawBuffer.resize(size);
+ std::memcpy(&rawBuffer[0], src, size);
+ }
+
+ UI_8 *data(void) {
+ return rawBuffer.empty() ? NULL : &rawBuffer[0];
+ }
+
+ void clear(void) {
+ std::vector<UI_8>().swap(rawBuffer);
+ }
+
+ UI_32 size(void) {
+ return static_cast<UI_32>(rawBuffer.size());
+ }
+};
+
+
+// framework container
+typedef struct _CFrameworkunifiedFrameworkApp {
+ CHAR cAppName[MAX_NAME_SIZE_APP]; /// <application(client/service) name
+ UI_32 checkCode; /// <check code
+ pthread_t self;
+
+ // message receive information
+ HANDLE hAppRcvMsgQ; /// <handle to apps receive message queue
+ HANDLE hAppSndMsgQ; /// <handle to apps send message queue
+ UI_32 uiMsgLength; /// <length of data in message queue
+ UI_32 uiProtocolCmd; /// <protocol req/ack received
+ UI_32 uiSessionId;
+ CHAR cSystemInfo[MAX_SYS_INFO_SIZE];
+ CHAR cMsgSrcName[MAX_NAME_SIZE_APP]; /// <name of client/server(application) message queue
+ UI_8 uiMsgRcvBuffer[MAX_MSGQ_BUFFER]; /// <receive buffer for message queue
+ int efd; /// <FD for multiple wait generated by the epoll_create()
+ int defer_evfd; /// <FD for receiving Defer events to Dispatcher
+
+ Services services; /// <services <map>
+ ServiceSendMsgHandle servicesHandle; /// <serviceHandle <map>
+ NotificationTable notifications; /// <notification <map>
+ FdTable fds; /// <fdTable <map>
+
+ InvokeResponseQTable invokeResQTable;
+
+ AcceptMonitorTable acceptMonitorTable;
+ ConnectMonitorTable connectMonitorTable;
+ LostSessionQueue lostSessionQueue;
+ CallbackFunctionPtr lostSessionHandler;
+
+ EventServices eventservices;
+ NotificationEventTable notificationevents;
+
+ AppData appdata;
+
+ // Defer'ed Message Queue
+ DeferedMessageQueue deferedMsgQueue; /// <defer'ed message <queue>
+ BOOL fPopDeferedMsg;
+
+ HANDLE hNPSndMsgQ; /// <send msgq handle to NPService
+
+ // application & framework errors
+ EFrameworkunifiedStatus eLastFrameworkError; /// <Framework internal errors
+ EFrameworkunifiedStatus eLastAppError; /// <application(client/server/child thread) reported errors
+
+ /////////////////////////////////////////
+ void *FrameworkData;
+ HANDLE hParentSndMsgQ;
+ CHAR cParentAppName[MAX_NAME_SIZE_APP]; /// <application(client/service) name
+ /////////////////////////////////////////
+
+ HANDLE hConfigFileHandle;
+
+ class CFrameworkunifiedHSMFramework *m_pFrameworkunifiedStateMachine;
+
+ ServiceSessionTable sessiontable;
+ NotificationList servicenotificationlist;
+ CHAR sServiceAvailabilityNotification[MAX_SYS_INFO_SIZE];
+ BOOL bIsAvailable;
+
+ ServiceSessionHandleTable servicesessionhandletable;
+
+ void *pRsrcMgr;
+
+ // framework state information
+ // TODO(framework_unified): consider this for future
+
+ // Current user
+ HANDLE hUser;
+
+ // table holding list of all the events of service and its subscribers
+ EventTable eventtable;
+
+ // table holding list of all the public events of service and the event data corresponding to it
+ PublicStateEventTable publicstateeventtable;
+
+ // table holding list of all the private events of service and
+ // the event data corresponding to each of the subscribed session of its subscribers
+ PrivateStateEventTable privatestateeventtable;
+
+ ResponseData responsedata;
+
+ UI_64 total_occupy_time;
+ UI_64 total_run_count;
+ UI_32 max_occupy_time;
+
+ SI_32 siMonitorSock;
+
+ BOOL fDeferredSyncResponse;
+
+#ifdef DISPATCHER_PROFILER
+ // Profiler object. This is required per dispatcher
+ FrameworkunifiedMsgProfiler *m_pFrameworkunifiedMsgProfiler;
+#endif
+} CFrameworkunifiedFrameworkApp;
+
+// Structure containing the synchronization data
+struct SFrameworkunifiedSyncDataPacket {
+ PVOID m_pNotificationData; // Data published with the notification
+ UI_32 m_uiDataSize; // Size of the data published with the notification
+ time_t m_tTimeStamp; // Time when the notification was recently published
+};
+
+struct PCData {
+ PCData(pthread_barrier_t *bar, EFrameworkunifiedStatus *status, PCSTR parent, PCSTR child, CbFuncPtr init, CbFuncPtr shdn,
+ EFrameworkunifiedSchedPolicy policy, SI_32 priority, CbFuncPtr CreateHSM = NULL)
+ : barrier(bar),
+ childStatus(status),
+ parentName(parent),
+ childName(child),
+ initFn(init),
+ shdnFn(shdn),
+ schedPolicy(policy),
+ schedPriority(priority),
+ CbCreateStateMachine(CreateHSM) { // LCOV_EXCL_BR_LINE 11:except branch
+ }
+
+ pthread_barrier_t *barrier;
+ EFrameworkunifiedStatus *childStatus;
+ const ServiceName parentName;
+ const ServiceName childName;
+ CbFuncPtr initFn;
+ CbFuncPtr shdnFn;
+ EFrameworkunifiedSchedPolicy schedPolicy;
+ SI_32 schedPriority;
+ CbFuncPtr CbCreateStateMachine;
+};
+
+#define APP_CHECK_CODE (0xAC1D5EED)
+
+static inline BOOL frameworkunifiedCheckValidAppHandle(HANDLE hApp) {
+ static __thread int detect_once = 0;
+ if (NULL != hApp) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+ /**
+ * @todo
+ * eFrameworkunifiedStatusOK is returned even if a appHandle created in another thread is passed,
+ * and the specifications and operations differ.
+ * @todo
+ * If an application handle is specified in place of a session handle,
+ * the element is accessed illegally without type checking,
+ * and a DeathTest occurs because the thread_self check is violated.
+ * @todo
+ * If you specify an app handle for a child thread,
+ * the NULL's return value is not terminated abnormally at the intended point (frameworkunifiedCheckValidAppHandle).
+ */
+ if (pApp->self != pthread_self() && detect_once == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Invalid thread context detect(hApp):%#lx:%#lx", pApp->self, pthread_self());
+ detect_once = 1;
+ }
+ if (pApp->checkCode == APP_CHECK_CODE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSubscribeToNotification
+/// API to send message to Notification Service to add to subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotification(HANDLE hApp, PCSTR pNotification);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSubscribeToNotifications
+/// API to send message to Notification Service to add multiple subscriptions list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationCallbackHandler - Name of Notification
+/// \param [in] uiListLength
+/// UI_32 - number of notification that your subscribing too.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList, UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPUnsubscribeFromNotification
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotification(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPUnsubscribeFromNotifications
+/// API to send message to Notification Service to remove multiple notification from subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationCallbackHandler - notifications list
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
+ UI_32 uiListLength);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMSubscribeToNotificationsEvents
+/// API to send message to Notification Service to add multiple subscriptions list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationEvent - list of notification events
+/// \param [in] uiListLength
+/// UI_32 - number of notification that your subscribing too.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
+ UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMSubscribeToNotificationEvent
+/// API to send message to Notification Service to add to subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationEvent(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents
+/// API to send message to Notification Service to remove multiple subscriptions list for
+/// that notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationEvent - list of notification events
+/// \param [in] uiListLength
+/// UI_32 - number of notification that your subscribing too.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
+ UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDispatcher
+///
+/// \param [in] cAppName
+/// PCSTR - Application name
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocol(HANDLE hApp);
+
+EFrameworkunifiedStatus frameworkunifiedAddConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName);
+EFrameworkunifiedStatus frameworkunifiedDelConnectMonitorPre(int efd, PCSTR serverName, PCSTR clientName);
+EFrameworkunifiedStatus frameworkunifiedDelConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDispatcher
+///
+/// \param [in] cAppName
+/// PCSTR - Application name
+/// \param [out] hApp
+/// HANDLE& - Reference of application handle
+/// \param [in] bIsChildThread
+/// BOOL - child thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if success
+/// eFrameworkunifiedStatusFail if invalid app name
+/// eFrameworkunifiedStatusNullPointer if unable to open message Q handle
+/// or possible errors from call FrameworkunifiedAttachSystemCallbacksDispatcher/
+/// FrameworkunifiedAttachLoggerCallbacksDispatcher/
+/// FrameworkunifiedAttachVersionCallbacksDispatcher
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread = FALSE); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RunDispatcher
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RunDispatcher(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RunChildDispatcher
+/// Dispatcher for child thread. Only difference with \ref RunDispatcher is, child dispatcher
+/// exits when non eFrameworkunifiedStatusOK value by callback function is returned.
+/// Whereas, \ref RunDispatcher is not supposed to exit.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RunChildDispatcher(HANDLE hChildApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsValidWaitBarrier
+///
+/// \param [in] wbret
+/// int - barrier
+///
+/// \return bool
+/// valid or invalid
+////////////////////////////////////////////////////////////////////////////////////////////
+bool IsValidWaitBarrier(int wbret);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// setChildThreadSched
+///
+/// \param [in] policy
+/// EFrameworkunifiedSchedPolicy - scheduling policy
+/// \param [in] priority
+/// SI_32 - scheduling priority
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus setChildThreadSched(EFrameworkunifiedSchedPolicy policy, SI_32 priority);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateChildThread
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] childName
+/// PCSTR - Name of child thread to be created
+/// \param [in] CbInitialize
+/// CbFuncPtr - Initialize function.
+/// \param [in] CbShutdown
+/// CbFuncPtr - Shutdown function.
+/// \param [in] attr
+/// const FrameworkunifiedChildThreadAttr * - child thread attribute
+/// \param [in] CbCreateStateMachine
+/// CbFuncPtr - Function pointer to create state machine, in case of SM child thread, else NULL
+///
+/// \return HANDLE
+/// Non-null value if thread is created else NULL
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE CreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown,
+ const FrameworkunifiedChildThreadAttr *attr, CbFuncPtr CbCreateStateMachine);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Child thread attribute initialize
+///
+/// \param [out] attr
+/// FrameworkunifiedChildThreadAttr - Child thread attribute
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Child thread attribute set schedule policy & priority
+///
+/// \param [out] attr
+/// FrameworkunifiedChildThreadAttr - Child thread attribute
+/// \param [int] policy
+/// EFrameworkunifiedSchedPolicy - Child thread scheduling policy
+/// \param [in] priority
+/// SI_32 - Child thread scheduling priority
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// DestroyThread
+// Sends eFrameworkunifiedStatusExit status to exits the dispatcher loop to terminate the thread.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DestroyThread(HANDLE hApp);
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_CORE_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp
new file mode 100644
index 00000000..8599fb22
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_error_internal.hpp
@@ -0,0 +1,43 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief This file provides framework's API which are used by system services.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_INTERNAL_HPP_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_INTERNAL_HPP_
+
+#include <stdexcept>
+#include <native_service/frameworkunified_types.h>
+
+namespace frameworkunified {
+namespace framework {
+namespace error {
+
+class CSystemError : public std::runtime_error {
+ public:
+ explicit CSystemError(EFrameworkunifiedSystemError error, PCSTR errorMsg);
+ const EFrameworkunifiedSystemError m_eSystemError;
+};
+}
+}
+}
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_INTERNAL_HPP_
+//@}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h
new file mode 100644
index 00000000..4d38828a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_internal.h
@@ -0,0 +1,675 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Internal functions of the application framework.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_INTERNAL_H_
+
+#include <native_service/ns_shared_mem_if.h>
+#include <native_service/frameworkunified_types.h>
+#include "frameworkunified_framework_core.h"
+#define PASA_APPCONFIG_FILES "PASA_APPCONFIG_FILES"
+
+#define FRAMEWORKUNIFIEDLOG_CUT(zone, funcname, print_fmt, args...)
+
+//////////////////////////////////////////////////
+// dispatcher internal functions
+//////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachSystemCallbacksDispatcher
+/// All system defined callbacks will be attached to the dispatcher
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework.
+///
+/// \return eStatus
+/// EFrameworkunifiedStatus - success or error
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachSystemCallbacksDispatcher(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendSystemErrMessage
+/// This API is used to send application's critical error message to system manager.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework.
+/// \param [in] eSystemError
+/// EFrameworkunifiedSystemError - System error type
+///
+/// \return EFrameworkunifiedStatus - success or error
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendSystemErrMessage(HANDLE hApp, EFrameworkunifiedSystemError eSystemError);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateDispatcher
+/// Creates and initializes an applications/threads dispatcher.
+///
+/// \param [in] cAppname
+/// PCSTR - Application/ thread name
+/// \param [out] hApp
+/// HANDLE& - Reference of application handle
+/// \param [in] bIsChildThread
+/// BOOL - child thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
+/// possible errors from call CreateDispatcher
+///
+/// \see FrameworkunifiedDispatchBlock,
+/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateHSMDispatcher
+/// Creates and initializes an applications/threads hsm dispatcher.
+///
+/// \param [in] cAppname
+/// PCSTR - Application/ thread name
+/// \param [out] hApp
+/// HANDLE& - Reference of application handle
+/// \param [in] bIsThread
+/// BOOL - child thread
+/// \param [in] f_pFrameworkunifiedHSM
+/// CFrameworkunifiedHSMFramework* - statemachine instances
+///
+/// \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
+/// possible errors from call CreateDispatcher
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcher(PCSTR cAppName,
+ HANDLE &hApp, // NOLINT (readability/nolint)
+ BOOL bIsThread,
+ CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatchBlock
+/// Blocked until the dipatcher receives a notification of a service request or ack.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher,
+/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchBlock(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// frameworkunifiedFdHandler
+/// FD POLLIN blocked & process.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] efd
+/// int - epoll FD
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchProcess, FrameworkunifiedDispatchBlock,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus frameworkunifiedFdHandler(HANDLE hApp , int efd);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatchProcess
+/// Processes the Service/system request or notification.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedCloseDispatcher,
+///
+/// \details
+/// \code
+/// Pseudo code:
+/// IF message_source != Notification Service
+/// FIND source_name
+/// IF source_name available
+/// FIND protocol_cmd
+/// IF protocol_cmd available
+/// execute callback
+/// ELSE
+/// ignore
+/// END
+/// ELSE
+/// ignore
+/// END
+/// ELSE // notification
+/// FIND notification_callback
+/// IF available
+/// execute callback
+/// END
+/// \endcode
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchProcess(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCloseDispatcher
+/// Closing the dispatcher
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus -Success or error
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseDispatcher(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPopedDeferedMessage
+/// Checks the Defer'ed Message Queue should be pop'ed off
+/// the front of the queue!
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// BOOL - TRUE (a message has been pop'ed of the defer'ed msg queue)
+/// FALSE (no msg was pop'ed of the defer'ed msg queue)
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedPopedDeferedMessage(HANDLE hApp);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatcherMain
+/// Main processing loop that is shared between FrameworkunifiedDispacther and FrameworkunifiedDispatcherWithCmdLnArguments.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// BOOL - TRUE (a message has been pop'ed of the defer'ed msg queue)
+/// FALSE (no msg was pop'ed of the defer'ed msg queue)
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatcherMain(HANDLE hApp);
+
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatcherMain
+/// Main processing loop that is shared between FrameworkunifiedDispacther and FrameworkunifiedDispatcherWithCmdLnArguments.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// BOOL - TRUE (a message has been pop'ed of the defer'ed msg queue)
+/// FALSE (no msg was pop'ed of the defer'ed msg queue)
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock
+/// FrameworkunifiedDispatchProcess.
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedArgumentParser(HANDLE hApp, int argc, char *argv[], CustomCommandLineOptions *cmdLineOptions);
+
+
+EFrameworkunifiedStatus FrameworkunifiedOnInitializationInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnDestroyInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnStartInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnStopInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnPreStartInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnPreStopInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStartInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStopInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDumpInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachineInternal(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterfaceInternal(HANDLE hApp);
+EFrameworkunifiedStatus RegistDefaultCbHandler(const FrameworkunifiedDefaultCallbackHandler *CbHandler);
+
+
+//////////////////////////////////////////////////
+// message center internal functions
+//////////////////////////////////////////////////
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// frameworkunifiedGetIsTypeOfSync
+/// Gets if message type is sync, return TRUE. or not return FALSE
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+///
+/// \return status
+/// BOOL - TRUE or FALSE
+///
+/// \see FrameworkunifiedInvokeSync, frameworkunifiedSendSyncResponse
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL frameworkunifiedGetIsTypeOfSync(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendSyncResponse
+/// Send Sync Response to the hApp.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the dispatcher to receive message
+/// \param [in] seq_id
+/// UI_32 - Sync sequence ID
+/// \param [in] retValue
+/// EFrameworkunifiedStatus - Return Status
+/// \param [in] length
+/// UI_32 - Length of the data to be receive response.
+/// \param [in] data
+/// PVOID - Pointer to the response data.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedInvokeSync
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus frameworkunifiedSendSyncResponse(HANDLE hApp, UI_32 iCmd, UI_32 seq_id, EFrameworkunifiedStatus retValue, UI_32 length, PCVOID data);
+
+//////////////////////////////////////////////////
+// logger internal functions
+//////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachLoggerCallbacksDispatcher(HANDLE hApp);
+
+#ifdef DISPATCHER_PROFILER
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachMsgProfilerCallbacksDispatcher
+/// This function attaches callback function for profiler protocol for main thread.
+/// Protocol is attached considering the source as "nsprofilerutil"
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachMsgProfilerCallbacksDispatcher(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachMsgProfilerCallbacksDispatcher
+/// This function attaches callback function for profiler protocol for child threads.
+/// Protocol is attached considering the source as parent thread
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachChildMsgProfilerCallbacksDispatcher(HANDLE hApp);
+#endif
+
+EFrameworkunifiedStatus FrameworkunifiedSetLogMask(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedGetLogMask(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedSetOutputLogOpts(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedGetOutputLogOpts(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedSetLogSeverity(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedGetLogSeverity(HANDLE hApp);
+EFrameworkunifiedStatus FrameworkunifiedDebugDumpRequest(HANDLE hApp);
+
+EFrameworkunifiedStatus NSRcsSetLogSettings(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsGetLogSettings(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsSetLogMask(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsSetOutputLogOpts(HANDLE hApp);
+EFrameworkunifiedStatus NSRcsSetLogSeverity(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetConfigHandle
+/// This Function opens the configuration file from given path and sets the file handle in hApp
+///
+/// \param [in] cAppname
+/// HANDLE - Application handle
+/// \param [in] sFilePath
+/// PCHAR - File path of the config file
+///
+/// \return status of the operation
+///
+/// \see SetDefaultFilePath,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetConfigHandle(HANDLE hApp, PCHAR sFilePath);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetDefaultFilePath
+/// This Function fetches the default config path, opens the configuration file and sets the file
+/// handle in the application
+///
+/// \param [in] cAppname
+/// HANDLE - Application handle
+/// \param [in] sFilePath
+/// PCHAR - File path of the config file
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetDefaultConfigFile(HANDLE hApp);
+
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocolHSMEvent(HANDLE hApp, PCSTR pRequester);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessProtocolEvents
+/// This Function registers the events of server with the client.
+/// If the event is published previously and is a state event then send the event data to the client.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus ProcessProtocolEvents(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessPrivateEvents
+/// This Function registers the events of server with the client.
+/// If the event is published previously and is a state event then send the event data to the client.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus ProcessPrivateEvents(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CleanAllEventsOfSession
+/// This Function closes the session handle and removes its entry from the table of
+/// ServiceSessionHandleTable of application framework handle.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Name of a service
+/// \param [in] sessionId
+/// UI_32 - Session id
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CleanAllEventsOfSession(HANDLE hApp, PCSTR serviceName, UI_32 sessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveEntryFromSessionEventInfoTable
+/// This Function removes the entry of event id from the session table based on the service
+/// name and session id.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Name of service
+/// \param [in] sessionId
+/// UI_32 - Session id
+/// \param [in] eventId
+/// UI_32 - Event id which needs to be removed from internal table
+///
+/// \return eFrameworkunifiedStatusOK- Success, or eFrameworkunifiedStatusFail
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RemoveEntryFromSessionEventInfoTable(HANDLE hApp, PCSTR serviceName, UI_32 sessionId, UI_32 eventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// HandleSessionEventOnCloseSession
+/// This Function does the handling of session events on close session request
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus HandleSessionEventOnCloseSession(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UnregisterPrivateEvents
+/// This Function unregisters the private event.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return status of the operation
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus UnregisterPrivateEvents(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetMsgQueueHandle
+/// Gets the message queue handle from servicesessionhandletable map.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Service name of receiver
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return Message queue handle
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE GetMsgQueueHandle(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetNewMsgQueueHandle
+/// This function creates and returns the message queue handle.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] serviceName
+/// PCSTR - Service name of receiver
+/// \param [in] uiSessionId
+/// UI_32 - session id
+/// \param [in] uiEventId
+/// const UI_32 - event id
+///
+/// \return Message queue handle
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE GetNewHandleAndUpdateEventInfoTable(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId,
+ const UI_32 uiEventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsEventAlreadyRegistered
+/// Searches for the session id in the vector
+///
+/// \param [in] vSessionIdList
+/// SessionIdList - list of sessions id's
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return true or false
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL IsEventAlreadyRegistered(const SessionIdList &vSessionIdList, const UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveEventEntryFromEventTable
+/// This Function removes the entry of event for received service on the active session id
+/// from Event Table.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] serviceName
+/// PCSTR - Service name of receiver
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus RemoveEventEntryFromEventTable(HANDLE hApp, UI_32 uiEventId, PCSTR cServiceName, const UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendEventMessage
+/// This function sends the private event message to all the sessions of service registered
+/// for event.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] vSessionIdList
+/// SessionIdList - session id list
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] cServiceName
+/// PCSTR - Service name of receiver
+/// \param [in] pData
+/// PCVOID - data to send
+/// \param [in] uiLength
+/// UI_32 - length of data
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendEventMessage(HANDLE hApp, const SessionIdList &vSessionIdList, UI_32 uiEventId, PCSTR cServiceName,
+ PCVOID pData, UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdatePublicStateEventData
+/// This API updates the event data of public state event for all the session of
+/// all subscribed clients.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] pData
+/// PCVOID - data to send
+/// \param [in] uiLength
+/// UI_32 - length of data
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus UpdatePublicStateEventData(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdatePrivateStateEventData
+/// This API updates the event data of private state event for session with
+/// session id uiSessionId of client pClientName.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - event id
+/// \param [in] pClientName
+/// PCSTR - Event Subscriber name
+/// \param [in] uiSessionId
+/// UI_32 - session id
+/// \param [in] pData
+/// PCVOID - data to send
+/// \param [in] uiLength
+/// UI_32 - length of data
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus UpdatePrivateStateEventData(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, UI_32 uiSessionId, PCVOID pData,
+ UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// DeleteSessionEventData
+/// This function is called while destroying the session with client.
+/// This method removes the private event data associated with the session.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pClientName
+/// PCSTR - Event Subscriber name
+/// \param [in] uiSessionId
+/// UI_32 - session id
+///
+/// \return success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DeleteSessionEventData(HANDLE hApp, PCSTR pClientName, UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetDataUSID
+/// Gets the shared memory ID
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// UI_32 - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+TMemID FrameworkunifiedGetDataUSID(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedIsAutoPublishServiceAvailableEnabled
+/// This function is used to check whether auto publishing of service availability is
+/// enabled or not.
+///
+/// \param None
+///
+/// \return BOOL
+/// BOOL - true if auto publish is enabled for service else false
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsAutoPublishServiceAvailableEnabled();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedIsWaitInStoppingStateEnabled
+/// Check if wait in stopping state is enabled.
+///
+/// \param [in] none
+///
+/// \return BOOL - TRUE if enabled or FALSE
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsWaitInStoppingStateEnabled();
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h
new file mode 100644
index 00000000..b78297e3
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_framework_utility.h
@@ -0,0 +1,41 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_UTILITY_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_UTILITY_H_
+
+#include <native_service/ns_utility.hpp>
+#include "frameworkunified_framework_internal.h"
+
+DEFINE_EXCEPTION(happ_error, std::runtime_error);
+
+class HAppTraits {
+ public:
+ typedef HANDLE Type;
+ typedef happ_error Exception;
+ static void Release(Type rsrc) {
+ FrameworkunifiedOnDestroyInternal(rsrc);
+ FrameworkunifiedCloseDispatcher(rsrc);
+ }
+
+ static BOOL BadValue(Type rsrc) {
+ return NULL == rsrc;
+ }
+};
+
+typedef ResourceMgr< HANDLE, HAppTraits > THApp;
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_FRAMEWORK_UTILITY_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h
new file mode 100644
index 00000000..f512e760
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/frameworkunified_msgprofiler.h
@@ -0,0 +1,148 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief File declares FrameworkunifiedMsgProfiler class which keeps profiler information for message dispatcher
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <vector>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Profiler class which keeps and manage profiler information for message dispatcher
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class FrameworkunifiedMsgProfiler {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedMsgProfiler
+ /// Parameterized constructor
+ /// \param [in] f_cAppName
+ /// const std::string& - Name of the application or dispatcher
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ explicit FrameworkunifiedMsgProfiler(const std::string &f_cAppName);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~FrameworkunifiedMsgProfiler
+ /// Class destructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ~FrameworkunifiedMsgProfiler();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// GetAppName
+ /// Returns application name corresponding to profiler
+ ///
+ /// \param [in] none
+ ///
+ /// \return std::string
+ /// std::string - Returns application name corresponding to profiler
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetAppName();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// AddChildName
+ /// Returns application name corresponding to profiler
+ ///
+ /// \param [in] f_cChildName
+ /// const std::string& - Add the name of child dispatcher profiler
+ ///
+ /// \return none
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID AddChildName(const std::string &f_cChildName);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// MsgReceived
+ /// Updates the profiler information once the message is received.
+ /// e.g. increaments msg count, save the time of msg received
+ ///
+ /// \param [in] none
+ ///
+ /// \return none
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID MsgReceived();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// MsgProcessed
+ /// Updates the profiler information once the message is processed.
+ /// e.g. Updates the frequency of execution of message
+ ///
+ /// \param [in] none
+ ///
+ /// \return none
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID MsgProcessed();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// PrintProfileInfo
+ /// All the profiler information which FrameworkunifiedMsgProfiler class has prints it in message
+ /// queue FRAMEWORKUNIFIED_NS_MSGPROFILERUTIL
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Application framework handle
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or failure
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PrintProfileInfo(HANDLE f_hApp);
+
+ static BOOL m_bMsgProfilerEnabled; /// Flag is enabled when command line argument -q is passed.
+ /// Otherwise no profiler information is maintained.
+
+ private:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// GetClock
+ /// GetClock of milliseconds
+ ///
+ /// \param [in] none
+ ///
+ /// \return UI_64
+ /// UI_64 - returns time in Milliseconds
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ UI_64 GetClock();
+
+ std::vector<std::string> m_vChildNames; /// vector to save list of all child threads dispatcher
+ std::string m_cAppName; /// Dispacther application name
+ UI_32 m_ui32TotalNoOfMsgsReceived; /// Total number of messages received by the dispatcher
+
+ // NOTE: Storing time in ClockCycle. So that it will not add overhead for converting it to miliseconds.
+ // It will get converted only when information is required to print.
+ UI_64 m_ui64MinMsgProcessingTime; // time is in clock cycles
+ UI_64 m_ui64MaxMsgProcessingTime; // time is in clock cycles
+
+ UI_64 m_ui64TotalMsgExecutionTime; /// total time spent in message execution
+ UI_64 m_ui64LastMsgReceivedTime; /// save the time when last message was received
+ UI_64 m_ui64AppInitTime; /// save the time when application got initialized
+ BOOL m_bLastMsgWasPrintProfile; /// TRUE if the last message received
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_FRAMEWORKUNIFIED_MSGPROFILER_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h
new file mode 100644
index 00000000..20ed3f62
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_finalstate.h
@@ -0,0 +1,97 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedFinalState class definitions. CFrameworkunifiedFinalState is derived from
+/// CFrameworkunifiedState class.This class implements the additional functionality supported by HSM Final
+/// state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_
+
+
+#include <native_service/frameworkunified_sm_state.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM Final state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedFinalState : public CFrameworkunifiedState {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedFinalState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedFinalState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedFinalState
+ /// Class destructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedFinalState();
+
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateHistory
+ /// This function stores the last active state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UpdateHistory();
+
+ protected :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEntry
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnExit
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData);
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FINALSTATE_H_
+// @}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h
new file mode 100644
index 00000000..ea564df7
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_framework_core.h
@@ -0,0 +1,89 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This File has public Macro definition that simplifies the statemachine implementation
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
+/// Include files
+#include <native_service/frameworkunified_framework_types.h>
+#include <vector>
+#include <utility>
+
+/// connect child state to parent state and sets it as default state
+#define CONNECT_DEFAULTSTATE(parent, child) \
+ FrameworkunifiedConnect(l_p## parent, l_p## child, TRUE);
+
+/// connect child state to parent state
+#define CONNECT_STATE(parent, child) \
+ FrameworkunifiedConnect(l_p## parent, l_p## child);
+
+/// connect the deferred event and reactions and associate them with the state
+#define CONNECT_DEFERREDEVENT(state, eventid) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, NULL, #eventid, TRUE); \
+
+/// connect the event and reactions and associate them with the state
+#define CONNECT_EVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid);
+
+/// connect the event and reactions and associate them with the state
+#define CONNECT_LOCAL_EVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pLocalTrn## reaction, #eventid);
+
+/// Sets the state as root state in the statemachine
+#define CONNECTROOT(state) \
+ FrameworkunifiedConnect(l_p## state);
+
+/// Creates the state
+#define CREATE_STATE(class_name) \
+ CHKNULL(m_pFrameworkunifiedStateList) \
+ C## class_name *l_p## class_name = new C## class_name(#class_name); \
+ CHKNULL(l_p## class_name) \
+ m_pFrameworkunifiedStateList->insert(std::pair<UI_32, CFrameworkunifiedState*>(e## class_name, l_p## class_name));
+
+// create a new shallow history state and add it in parent state
+#define ADD_SHALLOWHISTORYSTATE(parent) \
+ CFrameworkunifiedShallowHistoryState *l_p##parent##SHALLOWHISTORYSTATE = new CFrameworkunifiedShallowHistoryState(SHALLOWHISTORYSTATE);\
+ FrameworkunifiedConnect(l_p## parent, l_p##parent##SHALLOWHISTORYSTATE);\
+ l_p##parent##SHALLOWHISTORYSTATE->SetDefaultHistory();
+
+// create a new shallow history state and add it in parent state
+#define ADD_DEEPHISTORYSTATE(parent) \
+ CFrameworkunifiedDeepHistoryState *l_p##parent##DEEPHISTORYSTATE = new CFrameworkunifiedDeepHistoryState(DEEPHISTORYSTATE);\
+ FrameworkunifiedConnect(l_p## parent, l_p##parent##DEEPHISTORYSTATE);\
+ l_p##parent##DEEPHISTORYSTATE->SetDefaultHistory();
+
+/// connect deep history event to reaction and add to state
+#define CONNECT_DEEPHISTORYEVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##DEEPHISTORYSTATE, #eventid);
+
+/// connect shallow history event to reaction and add to state
+#define CONNECT_SHALLOWHISTORYEVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##SHALLOWHISTORYSTATE, #eventid);
+
+typedef struct _HSMConfigOptions {
+ EUserChangeOptions eUserChange;
+ BOOL bAutoPublishServiceAvaialble;
+ BOOL bWaitInStoppingState;
+} HSMConfigOptions;
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_CORE_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h
new file mode 100644
index 00000000..ff670295
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/include/statemachine/frameworkunified_sm_multithreading_internal.h
@@ -0,0 +1,30 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Internal functions related to state machine child threads
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_
+
+void *child_hsm_thread_proc(void *args);
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_FRAMEWORKCORE_INCLUDE_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp
new file mode 100644
index 00000000..250edce2
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_dispatcher.cpp
@@ -0,0 +1,2382 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/epoll.h>
+#include <sys/eventfd.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/frameworkunified_framework_sync.h>
+#include <native_service/frameworkunified_sm_hsmframework.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/ns_resource_controler.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <other_service/strlcpy.h>
+
+#include <string>
+#include <utility>
+#include <map>
+
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+#include "ns_message_center_internal.h"
+#include "ns_mc_internal.h"
+#include "frameworkunified_framework_error_internal.hpp"
+#include "frameworkunified_framework_utility.h"
+#include "frameworkunified_sm_framework_core.h"
+
+#ifdef DISPATCHER_PROFILER
+#include "frameworkunified_msgprofiler.h"
+#include <boost/bind.hpp>
+#endif
+
+/*
+ * static variable
+ */
+static FrameworkunifiedDefaultCallbackHandler g_defaultCallbackHandler;
+
+//////////////////////////
+// prototype declaration
+//////////////////////////
+static EFrameworkunifiedStatus GetDispatcherMqFD(HANDLE hApp, int *fd);
+static EFrameworkunifiedStatus CreateMultiWaitingFD(HANDLE hApp);
+static EFrameworkunifiedStatus ProcessMq(HANDLE hApp);
+static EFrameworkunifiedStatus ProcessFd(HANDLE hApp , int fd);
+
+//////////////////////////////////////////
+// Function : ostream &operator<<
+//////////////////////////////////////////
+template <typename K, typename V, class C, class A>
+std::ostream &operator<< (std::ostream &os, const std::map<K, V, C, A> &m) {
+ os << "{ ";
+ typename std::map<K, V, C, A>::const_iterator p;
+ for (p = m.begin(); p != m.end(); ++p) {
+ os << p->first << ":" << p->second << ", ";
+ }
+ return os << "}";
+}
+
+EFrameworkunifiedStatus CreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread) { // NOLINT (readability/nolint)
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = new CFrameworkunifiedFrameworkApp; // LCOV_EXCL_BR_LINE 11:except branch
+ if (pApp != NULL) { // LCOV_EXCL_BR_LINE 5:fail safe for new
+ pApp->checkCode = APP_CHECK_CODE;
+ pApp->self = pthread_self();
+ // app name size should not exceed the max length
+ memset(pApp->cAppName, 0, MAX_NAME_SIZE_APP);
+ memset(pApp->sServiceAvailabilityNotification, 0, MAX_SYS_INFO_SIZE);
+ pApp->bIsAvailable = FALSE;
+ /*
+ * todo
+ * Setting NULL for arguments causes an Exception
+ */
+ if (strlen(cAppName) < MAX_NAME_SIZE_APP) {
+ memcpy(pApp->cAppName, cAppName, strlen(cAppName));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error : Aborting ... Exceeds Max App name size MAX_NAME_SIZE_APP : %d ",
+ MAX_NAME_SIZE_APP);
+ /*
+ * Error is set here, but the error is overwritten by the following process
+ */
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, " Application Created ");
+
+ // opening handle to receive message for the application
+ pApp->hAppRcvMsgQ = NULL;
+ if (NULL == (pApp->hAppRcvMsgQ = McOpenReceiver(pApp->cAppName))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to McOpenReceiver ");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ } else {
+ if (strcmp(cAppName, "NS_NPPService") != 0) {
+ McFlushReceiver(pApp->hAppRcvMsgQ);
+ }
+ }
+
+ // opening socket for abnormal monitoring
+ pApp->siMonitorSock = -1;
+ if ((eFrameworkunifiedStatusOK == eStatus) && (-1 == (pApp->siMonitorSock = mcOpenMonitor(pApp->cAppName)))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to mcOpenMonitor ");
+ eStatus = eFrameworkunifiedStatusFail;
+ pApp->siMonitorSock = -1;
+ }
+
+ // opening handle to send messages to itself
+ pApp->hAppSndMsgQ = NULL;
+ if ((eFrameworkunifiedStatusOK == eStatus) && (NULL == (pApp->hAppSndMsgQ = McOpenSender(pApp->cAppName)))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to McOpenSender ");
+ // LCOV_EXCL_BR_STOP
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ // opening handles for Notification Persistence Service and Service Directory
+ pApp->hNPSndMsgQ = NULL;
+ if ((eFrameworkunifiedStatusOK == eStatus) &&
+ (NULL == (pApp->hNPSndMsgQ = FrameworkunifiedMcOpenSender(reinterpret_cast<HANDLE>(pApp), FRAMEWORKUNIFIED_NS_NPSERVICE)))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error : Failed to FrameworkunifiedMcOpenSender < NS_NPPService >");
+ // LCOV_EXCL_BR_STOP
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ // stores the message queue handle of the parent thread.
+ // It will set after the dispatcher of child thread is created. And will be NULL for main thread.
+ pApp->hParentSndMsgQ = NULL;
+
+ if ((eFrameworkunifiedStatusOK == eStatus) && (!bIsChildThread)) {
+ // Define any system callback's with the dispatcher.
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachSystemCallbacksDispatcher(reinterpret_cast<HANDLE>(pApp)))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error :: (%d) Failed to FrameworkunifiedAttachSystemCallbacksDispatcher ", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ // Define the logger callback's for setting up gets and sets with the dispatcher.
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachLoggerCallbacksDispatcher(reinterpret_cast<HANDLE>(pApp)))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error :: (%d) Failed to FrameworkunifiedAttachLoggerCallbacksDispatcher ", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ }
+
+ // initialize
+ pApp->m_pFrameworkunifiedStateMachine = NULL;
+ pApp->uiProtocolCmd = 0;
+
+ // Clear the Defer'ed message pop flag.
+ pApp->fPopDeferedMsg = FALSE;
+
+ // Clear the Defer'ed sync response flag.
+ pApp->fDeferredSyncResponse = FALSE;
+
+ // buffer initialize
+ memset(pApp->uiMsgRcvBuffer, 0, MAX_MSGQ_BUFFER);
+ memset(pApp->cMsgSrcName, '\0', MAX_NAME_SIZE_APP);
+ memset(pApp->cSystemInfo, '\0', MAX_SYS_INFO_SIZE);
+
+ pApp->defer_evfd = -1;
+ pApp->efd = -1;
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ eStatus = CreateMultiWaitingFD((HANDLE)pApp);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : CreateMultiWaitingFD Failed, status=%d", eStatus);
+ }
+ }
+
+#ifdef DISPATCHER_PROFILER
+ // Assign default value
+ pApp->m_pFrameworkunifiedMsgProfiler = NULL;
+#endif
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ if (NULL != pApp->hAppRcvMsgQ) {
+ McClose(pApp->hAppRcvMsgQ);
+ pApp->hAppRcvMsgQ = NULL;
+ }
+
+ if (0 < pApp->siMonitorSock) {
+ mcCloseMonitor(pApp->cAppName);
+ pApp->siMonitorSock = -1;
+ }
+
+ if (NULL != pApp->hAppSndMsgQ) {
+ McClose(pApp->hAppSndMsgQ);
+ pApp->hAppSndMsgQ = NULL;
+ }
+
+ if (NULL != pApp->hNPSndMsgQ) {
+ FrameworkunifiedMcClose(pApp->hNPSndMsgQ);
+ pApp->hNPSndMsgQ = NULL;
+ }
+
+ // LCOV_EXCL_BR_START 6:According to line 158, pApp->hParentSndMsgQ is NULL.
+ if (NULL != pApp->hParentSndMsgQ) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6:According to line 158, pApp->hParentSndMsgQ is NULL.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ McClose(pApp->hParentSndMsgQ);
+ pApp->hParentSndMsgQ = NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ if (0 < pApp->defer_evfd) {
+ close(pApp->defer_evfd);
+ pApp->defer_evfd = -1;
+ }
+
+ if (0 < pApp->efd) {
+ close(pApp->efd);
+ pApp->efd = -1;
+ }
+
+ delete pApp; // LCOV_EXCL_BR_LINE 11:except branch
+ pApp = NULL;
+ }
+ }
+
+ hApp = pApp;
+
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedCreateDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcher(PCSTR cAppName, HANDLE &hApp, BOOL bIsChildThread) { // NOLINT (readability/nolint)
+ return CreateDispatcher(cAppName, hApp, bIsChildThread);
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedDispatchBlock
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchBlock(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+// FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "+");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (eFrameworkunifiedStatusOK != (eStatus = McReceiveWithSession(pApp->hAppRcvMsgQ, pApp->cMsgSrcName,
+ &pApp->uiProtocolCmd, &pApp->uiSessionId, MAX_MSGQ_BUFFER,
+ (PVOID)(pApp->uiMsgRcvBuffer)))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: (%d) Failed on McReceive", eStatus);
+ // LCOV_EXCL_BR_STOP
+ } else {
+// FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Message received on dispatcher:: Source: %s, Cmd: 0x%X, SessionId: %d ",
+// pApp->cMsgSrcName, pApp->uiProtocolCmd, pApp->uiSessionId);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+// FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "-");
+ return eStatus;
+}
+
+
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocolCallback(HANDLE hApp, PCSTR pRequester) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ Services::iterator s_iterator;
+
+ s_iterator = pApp->services.find(pRequester);
+ if (s_iterator != pApp->services.end()) {
+ SessionTable::iterator session_iterator;
+ session_iterator = (s_iterator->second).find(pApp->uiSessionId);
+ if (session_iterator != (s_iterator->second).end()) {
+ // FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " %s found :: (%s) ", pApp->cMsgSrcName, s_iterator->second);
+
+ // find the protocol req/ack handler
+ ServiceProtocolTable::iterator spt_iterator;
+ spt_iterator = (session_iterator->second).find(pApp->uiProtocolCmd);
+ if (spt_iterator != (session_iterator->second).end()) {
+ // calling the protocol req/ack handler
+ eStatus = (*spt_iterator).second(hApp);
+ } else if ((session_iterator->second).end() != (spt_iterator =
+ (session_iterator->second).find(FRAMEWORKUNIFIED_ANY_COMMAND))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__,
+ "Processing callback function for (FRAMEWORKUNIFIED_ANY_COMMAND). "
+ "Dispatcher protocol command: (0x%x)", pApp->uiProtocolCmd);
+ // LCOV_EXCL_BR_STOP
+ eStatus = (*spt_iterator).second(hApp);
+ } else {
+ eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocol(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // Check if the callback is associated with the Protocol for message source
+ eStatus = FrameworkunifiedProcessServiceProtocolCallback(hApp, const_cast<PCSTR>(pApp->cMsgSrcName));
+
+ if (eFrameworkunifiedStatusMsgNotProcessed == eStatus) {
+ // Check if the callback is associated with the Protocol for FRAMEWORKUNIFIED_ANY_SOURCE
+ eStatus = FrameworkunifiedProcessServiceProtocolCallback(hApp, FRAMEWORKUNIFIED_ANY_SOURCE);
+ if (eFrameworkunifiedStatusMsgNotProcessed == eStatus) {
+ if (pApp->m_pFrameworkunifiedStateMachine) {
+ // Check if the HSM event is associated with the Protocol for message source
+ eStatus = FrameworkunifiedProcessServiceProtocolHSMEvent(hApp, const_cast<PCSTR>(pApp->cMsgSrcName));
+
+ if (eFrameworkunifiedStatusMsgNotProcessed == eStatus) {
+ // Check if the HSM event is associated with the Protocol for FRAMEWORKUNIFIED_ANY_SOURCE
+ eStatus = FrameworkunifiedProcessServiceProtocolHSMEvent(hApp, FRAMEWORKUNIFIED_ANY_SOURCE);
+ }
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+EFrameworkunifiedStatus FrameworkunifiedSetDeferredSyncResponse(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->fDeferredSyncResponse = TRUE;
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ return eStatus;
+}
+
+
+static void frameworkunifiedProcessSyncResponse(HANDLE hApp, EFrameworkunifiedStatus retValue) {
+ EFrameworkunifiedStatus eStatus;
+ CHAR systemInfo[MAX_SYS_INFO_SIZE];
+ UI_32 seq_id;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (frameworkunifiedGetIsTypeOfSync(hApp) == TRUE) {
+ if (pApp->fDeferredSyncResponse == TRUE) {
+ if (pApp->responsedata.size() != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Response data is ignored for "
+ ":: source: %s, Protocol Command: 0x%x, Session Id: %u.",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
+ pApp->uiProtocolCmd, pApp->uiSessionId);
+ pApp->responsedata.clear();
+ }
+ } else {
+ FrameworkunifiedGetSystemInfo(hApp, systemInfo);
+ seq_id = (UI_32)strtoul(systemInfo, NULL, 16);
+
+ eStatus = frameworkunifiedSendSyncResponse(hApp, PROTOCOL_FRAMEWORKUNIFIED_ANY_COMMAND, seq_id, retValue, pApp->responsedata.size(),
+ pApp->responsedata.data());
+ if (eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "retValu:%d errno:%d", eStatus, errno);
+ }
+ pApp->responsedata.clear();
+ }
+ } else {
+ if (pApp->responsedata.size() != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Response data is ignored for :: "
+ "source: %s, Protocol Command: 0x%x, Session Id: %u.",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
+ pApp->uiProtocolCmd, pApp->uiSessionId);
+ pApp->responsedata.clear();
+ }
+ }
+ pApp->fDeferredSyncResponse = FALSE;
+}
+
+
+inline static time_t frameworkunifiedTimeval2usec(const struct timeval &time) {
+ return static_cast<time_t>(time.tv_sec * 1000000 + time.tv_usec);
+}
+
+
+static void frameworkunifiedPrintRusage(HANDLE hApp, const struct rusage &start, const struct rusage &end) {
+ UI_32 occupy_time;
+ UI_32 average;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ occupy_time = static_cast<UI_32>(frameworkunifiedTimeval2usec(end.ru_utime) - frameworkunifiedTimeval2usec(start.ru_utime));
+ occupy_time += static_cast<UI_32>(frameworkunifiedTimeval2usec(end.ru_stime) - frameworkunifiedTimeval2usec(start.ru_stime));
+
+ pApp->total_occupy_time += occupy_time;
+ pApp->total_run_count++;
+ average = static_cast<UI_32>(pApp->total_occupy_time / pApp->total_run_count);
+
+ if (occupy_time > pApp->max_occupy_time) {
+ pApp->max_occupy_time = occupy_time;
+ }
+
+// FRAMEWORKUNIFIEDLOG(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "cur:%d.%06d avg:%d.%06d max:%d.%06d",
+// occupy_time / 1000000, occupy_time % 1000000,
+// average / 1000000, average % 1000000,
+// pApp->max_occupy_time / 1000000, pApp->max_occupy_time % 1000000);
+}
+
+
+static inline void frameworkunifiedGetRusage(struct rusage *r) {
+ if (r == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "r is NULL");
+ return;
+ }
+ memset(r, 0, sizeof(struct rusage));
+ if (getrusage(RUSAGE_THREAD, r) == -1) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "getrusage errno:%d", errno);
+ // LCOV_EXCL_BR_STOP
+ }
+}
+
+static int frameworkunifiedPushLostSessionInfo(HANDLE hApp, PCSTR serviceName) {
+ int cntFound = 0;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ ServiceSessionTable::iterator s_iterator = pApp->sessiontable.find(serviceName);
+ if (s_iterator != pApp->sessiontable.end()) {
+ // LCOV_EXCL_BR_START 11:except branch
+ SessionHandleTable::iterator sh_iterator = pApp->sessiontable[serviceName].begin();
+ // LCOV_EXCL_BR_STOP
+ while (sh_iterator != pApp->sessiontable[serviceName].end()) {
+ LostSessionInfo l_info;
+ l_info.sServiceName = serviceName;
+ l_info.iSessionId = sh_iterator->first;
+ pApp->lostSessionQueue.push(l_info);
+ cntFound++;
+ sh_iterator++;
+ }
+ }
+ return cntFound;
+}
+
+///
+/// Abnormal monitor(server): Client socket close handle
+///
+EFrameworkunifiedStatus frameworkunifiedProcessClientAbnormalState(HANDLE hApp, int sockfd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ AcceptMonitorTable::iterator it;
+
+ if ((it = pApp->acceptMonitorTable.find(sockfd)) == pApp->acceptMonitorTable.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid fd", sockfd);
+ } else {
+ char clientName[16];
+ if (mcGetClientNameFromConnectKey((it->second).c_str(), clientName, sizeof(clientName)) < 0) {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Invlid connectKey:%s", (it->second).c_str());
+ // LCOV_EXCL_BR_STOP
+ } else {
+ if (pApp->lostSessionHandler != NULL) {
+ int cntFound = frameworkunifiedPushLostSessionInfo(hApp, clientName);
+ if (cntFound) {
+ // calling lost session handler
+ try {
+ eStatus = pApp->lostSessionHandler(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", e.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ }
+ }
+ pApp->acceptMonitorTable.erase(sockfd);
+ }
+
+ return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///
+/// Abnormal monitor(server): Add
+///
+EFrameworkunifiedStatus frameworkunifiedAddAcceptMonitor(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ int acceptSock;
+
+ if ((acceptSock = mcGetAcceptMonitor(pApp->cAppName, pApp->cMsgSrcName)) < 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : mcGetAcceptMonitor srv:%s clnt:%s",
+ pApp->cAppName != 0 ? pApp->cAppName : NULL, pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL);
+ // LCOV_EXCL_BR_STOP
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ char connectKey[32];
+ mcSetConnectKey(connectKey, sizeof(connectKey), pApp->cAppName, pApp->cMsgSrcName);
+ pApp->acceptMonitorTable.insert(std::make_pair(acceptSock, connectKey));
+ }
+
+ return eStatus;
+}
+
+///
+/// Abnormal monitor(server): Del
+///
+EFrameworkunifiedStatus frameworkunifiedDelAcceptMonitor(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ long acceptSock; // NOLINT (readability/nolint)
+
+ char connectKey[32];
+ mcSetConnectKey(connectKey, sizeof(connectKey), pApp->cAppName, pApp->cMsgSrcName);
+ if (frameworkunifiedGetResource(FRAMEWORKUNIFIED_RES_ABNMLMON, connectKey, &acceptSock) < 0) {
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ if (pApp->acceptMonitorTable.find(static_cast<Socket>(acceptSock)) != pApp->acceptMonitorTable.end()) {
+ pApp->acceptMonitorTable.erase(static_cast<Socket>(acceptSock));
+ }
+ }
+
+ return eStatus;
+}
+
+///
+/// Abnormal monitor(client): Server socket close handle
+///
+EFrameworkunifiedStatus frameworkunifiedProcessServerAbnormalState(HANDLE hApp, int sockfd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ ConnectMonitorTable::iterator it;
+
+ if ((it = pApp->connectMonitorTable.find(sockfd)) == pApp->connectMonitorTable.end()) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid fd", sockfd);
+ // LCOV_EXCL_BR_STOP
+ } else {
+ char serverName[16];
+ if (mcGetServerNameFromConnectKey((it->second).c_str(), serverName, sizeof(serverName)) < 0) {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Invlid connectKey:%s", (it->second).c_str());
+ // LCOV_EXCL_BR_STOP
+ } else {
+ if (pApp->lostSessionHandler != NULL) {
+ int cntFound = frameworkunifiedPushLostSessionInfo(hApp, serverName); // LCOV_EXCL_BR_LINE 11:except branch
+ if (cntFound) {
+ // calling lost session handler
+ try {
+ eStatus = pApp->lostSessionHandler(hApp);
+ } catch (const std::exception &e) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", e.what());
+ // LCOV_EXCL_BR_STOP
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ }
+ }
+ pApp->connectMonitorTable.erase(sockfd);
+ }
+
+ return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///
+/// Abnormal monitor(client): Add
+///
+EFrameworkunifiedStatus frameworkunifiedAddConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ int connectSock = mcConnectMonitor(serverName, clientName);
+ if (connectSock < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error::%s:%s mcConnectMonitor",
+ serverName != 0 ? serverName : NULL, pApp->cAppName != 0 ? pApp->cAppName : NULL);
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ if (pApp->connectMonitorTable.find(connectSock) == pApp->connectMonitorTable.end()) {
+ char connectKey[32];
+ mcSetConnectKey(connectKey, sizeof(connectKey), serverName, clientName);
+
+ struct epoll_event event;
+ event.events = EPOLLRDHUP;
+ event.data.fd = connectSock;
+
+ if (epoll_ctl(pApp->efd, EPOLL_CTL_ADD, connectSock, &event) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (eStatus == eFrameworkunifiedStatusOK) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->connectMonitorTable.insert(std::make_pair(connectSock, connectKey));
+ }
+ }
+ }
+
+ return eStatus;
+}
+
+///
+/// Abnormal monitor(client): Del
+///
+EFrameworkunifiedStatus frameworkunifiedDelConnectMonitor(HANDLE hApp, PCSTR serverName, PCSTR clientName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ char connectKey[32];
+ mcSetConnectKey(connectKey, sizeof(connectKey), serverName, clientName);
+
+ long connectSock; // NOLINT (readability/nolint)
+ if (frameworkunifiedGetResource(FRAMEWORKUNIFIED_RES_ABNMLMON, connectKey, &connectSock) < 0) {
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ if (pApp->connectMonitorTable.find(static_cast<Socket>(connectSock)) != pApp->connectMonitorTable.end()) {
+ pApp->connectMonitorTable.erase(static_cast<Socket>(connectSock));
+ }
+
+ if (epoll_ctl(pApp->efd, EPOLL_CTL_DEL, static_cast<int>(connectSock), NULL) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ return eStatus;
+}
+
+///
+/// Abnormal monitor(common): Attach callback
+///
+EFrameworkunifiedStatus FrameworkunifiedAttachLostSessionCallbackToDispatcher(HANDLE hApp, CbFuncPtr fpLostSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) == FALSE || fpLostSession == NULL) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->lostSessionHandler = fpLostSession;
+ }
+
+ return eStatus;
+}
+
+///
+/// Abnormal monitor(common): Get lost session data
+///
+EFrameworkunifiedStatus FrameworkunifiedGetLostSessionData(HANDLE hApp, PSTR pServiceName, PUI_32 puiSessionId) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) == FALSE || pServiceName == NULL || puiSessionId == NULL) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (pApp->lostSessionQueue.empty()) {
+ eStatus = eFrameworkunifiedStatusAccessError;
+ } else {
+ LostSessionInfo info = pApp->lostSessionQueue.front();
+ pApp->lostSessionQueue.pop();
+ strcpy(pServiceName, info.sServiceName.c_str()); // NOLINT (readability/nolint)
+ *puiSessionId = info.iSessionId;
+ }
+ }
+
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedDispatchProcess
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchProcess(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ // FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "+");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ struct rusage start, end;
+ BOOL enable_rusage = NsLogIsZoneSet(ZONE_NS_DEBUG_DUMP);
+
+ if (enable_rusage == TRUE) {
+ frameworkunifiedGetRusage(&start);
+ }
+
+ if (0 != strcmp(FRAMEWORKUNIFIED_NS_NPSERVICE, pApp->cMsgSrcName)) { // < if not from NPP service
+ switch (pApp->uiProtocolCmd) {
+ case PROTOCOL_REGISTER_EVENTS: {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "%s subscribing to session event on sessionid %d",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL, pApp->uiSessionId);
+
+ eStatus = ProcessProtocolEvents(hApp);
+ }
+ break;
+
+ case PROTOCOL_UNREGISTER_EVENTS: {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "%s unsubscribing private event on sessionid %d",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL, pApp->uiSessionId);
+
+ eStatus = UnregisterPrivateEvents(hApp);
+ }
+ break;
+
+ case PROTOCOL_CLOSE_SESSION_REQ:
+ case PROTOCOL_CLOSE_SESSION_REQ_SYNC: {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "Close session request received from %s",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL);
+
+ // Handle the session events on the close session request
+ (VOID)HandleSessionEventOnCloseSession(hApp);
+
+ frameworkunifiedDelAcceptMonitor(hApp);
+
+ eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
+ }
+ break;
+
+ case PROTOCOL_OPEN_SESSION_REQ:
+ case PROTOCOL_OPEN_SESSION_REQ_SYNC: {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "Open session request received from %s",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL);
+
+ eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
+ if (eStatus == eFrameworkunifiedStatusOK) {
+ frameworkunifiedAddAcceptMonitor(hApp);
+ }
+ }
+ break;
+
+ default: {
+ eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
+ }
+ break;
+ }
+ } else {
+ NotificationTable::iterator n_iterator;
+ FrameworkunifiedGetSystemInfo(pApp, pApp->cSystemInfo);
+ n_iterator = pApp->notifications.find(static_cast<PSTR>(pApp->cSystemInfo));
+ if (n_iterator != pApp->notifications.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " Notification found in NS_NP :: (%s)."
+ " Processing callback function.", n_iterator->first.c_str());
+ eStatus = (*n_iterator).second(hApp);
+ } else {
+ NotificationEventTable::iterator n_iterator;
+ FrameworkunifiedGetSystemInfo(pApp, pApp->cSystemInfo);
+ n_iterator = pApp->notificationevents.find(static_cast<PSTR>(pApp->cSystemInfo));
+ if (n_iterator != pApp->notificationevents.end()) {
+ CFrameworkunifiedHSMFramework *l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
+ if (l_pStateMachine) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " Notification found in NS_NP :: (%s)."
+ " Processing HSM event.", n_iterator->first.c_str());
+ eStatus = l_pStateMachine->FrameworkunifiedPostEvent(n_iterator->second);
+ }
+ } else {
+ /// Paul A. Dennis (FOUND BUG)
+ /// For Persistent Data NS_NP sends the data back as a normal command not via the
+ /// notification logic... The Ack's for NPReadPersistedData,NPRegisterFilePath and
+ /// NPLoadFileFromPersistentStorage were never getting back
+ /// to the requester because its's not looking in the correct location.
+ /// So, Check the Services to see if the user has defined the Ack commands via the
+ /// services map
+ eStatus = FrameworkunifiedProcessServiceProtocol(hApp);
+ }
+ }
+ }
+
+ frameworkunifiedProcessSyncResponse(hApp, eStatus);
+
+ if ((eStatus != eFrameworkunifiedStatusOK) && (eStatus != eFrameworkunifiedStatusExit) && (eStatus != eFrameworkunifiedStatusMsgNotProcessed)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error :: %d, (%s) Event Info :: (%s), (%d), (%s)",
+ eStatus,
+ pApp->cAppName != 0 ? static_cast<PSTR>(pApp->cAppName) : NULL,
+ pApp->cMsgSrcName != 0 ? static_cast<PSTR>(pApp->cMsgSrcName) : NULL,
+ pApp->uiProtocolCmd,
+ pApp->cSystemInfo != 0 ? static_cast<PSTR>(pApp->cSystemInfo) : NULL);
+ }
+
+ if (eStatus == eFrameworkunifiedStatusMsgNotProcessed) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING:: No handler found for :: "
+ "Source: %s, Protocol Command: 0x%x, Session Id: %u.",
+ pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
+ pApp->uiProtocolCmd, pApp->uiSessionId);
+ FrameworkunifiedClearMsgData(hApp);
+ eStatus = eFrameworkunifiedStatusOK;
+ } else {
+// FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Message processed. Status (0x%X) ::"
+// " Source: %s Command: 0x%x SessionId: %d.",
+// eStatus, pApp->cMsgSrcName != 0 ? pApp->cMsgSrcName : NULL,
+// pApp->uiProtocolCmd, pApp->uiSessionId);
+ }
+
+ if (enable_rusage == TRUE) {
+ frameworkunifiedGetRusage(&end);
+ frameworkunifiedPrintRusage(hApp, start, end);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "-");
+ return eStatus;
+}
+
+
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedCloseDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseDispatcher(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->checkCode = 0;
+
+ if (NULL != pApp->hAppRcvMsgQ) {
+ McClose(pApp->hAppRcvMsgQ);
+ pApp->hAppRcvMsgQ = NULL;
+ }
+
+ if (pApp->siMonitorSock) {
+ mcCloseMonitor(pApp->cAppName);
+ pApp->siMonitorSock = 0;
+ }
+
+ if (NULL != pApp->hAppSndMsgQ) {
+ McClose(pApp->hAppSndMsgQ);
+ pApp->hAppSndMsgQ = NULL;
+ }
+
+ if (NULL != pApp->hNPSndMsgQ) {
+ FrameworkunifiedMcClose(pApp->hNPSndMsgQ);
+ pApp->hNPSndMsgQ = NULL;
+ }
+
+ if (NULL != pApp->hParentSndMsgQ) {
+ McClose(pApp->hParentSndMsgQ);
+ pApp->hParentSndMsgQ = NULL;
+ }
+
+ if (0 < pApp->defer_evfd) {
+ close(pApp->defer_evfd);
+ pApp->defer_evfd = 0;
+ }
+
+ if (0 < pApp->efd) {
+ close(pApp->efd);
+ pApp->efd = 0;
+ }
+
+ delete(pApp);
+ pApp = NULL; // mb20110110 Added per comment 216
+ // NOTE: However, client still needs to set his own pointer to NULL
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedPopedDeferedMessage
+//////////////////////////////////////////
+BOOL FrameworkunifiedPopedDeferedMessage(HANDLE hApp) {
+ BOOL rtnFlag = FALSE;
+
+ // LCOV_EXCL_BR_START 6:FrameworkunifiedPopedDeferedMessage is internal function, hApp is checked in extenal API
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ // LCOV_EXCL_BR_STOP
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // check if the pop flag is send and there is something to pop!
+ if (pApp->fPopDeferedMsg && !pApp->deferedMsgQueue.empty()) {
+ // get the message at the top\front of the queue
+ DeferedMsgInfo defered(pApp->deferedMsgQueue.front());
+
+ // remove this item from the queue using pop
+ pApp->deferedMsgQueue.pop();
+
+ // copy the data into the pApp
+ pApp->uiProtocolCmd = defered.uiProtocolCmd;
+ strlcpy(pApp->cMsgSrcName, defered.cMsgSrcName, sizeof(pApp->cMsgSrcName));
+ std::memcpy(pApp->uiMsgRcvBuffer, defered.uiMsgRcvBuffer, MAX_MSGQ_BUFFER);
+
+ // clear the pop flag!
+ pApp->fPopDeferedMsg = FALSE;
+
+ // set the return flag TRUE, we have pop'ed
+ rtnFlag = TRUE;
+ }
+ }
+
+ return rtnFlag;
+}
+
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatcher(PCSTR cAppName, const FrameworkunifiedDefaultCallbackHandler *CbHandler) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "In");
+ return FrameworkunifiedDispatcherWithArguments(cAppName, 0, NULL, CbHandler);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+// FrameworkunifiedDispatcherWithArguments
+// Creates, initializes and runs the dispatcher
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[],
+ const FrameworkunifiedDefaultCallbackHandler *CbHandler,
+ CustomCommandLineOptions *cmdLineOptions) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (cAppName == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ NsLogSetProcessName(cAppName);
+ PLOG_TEXT("FrameworkunifiedDispatcher Start");
+ // set main thread name as provided in dispatcher
+ pthread_setname_np(pthread_self(), cAppName);
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In");
+
+ if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
+ return eStatus;
+ }
+
+ try {
+ HANDLE hFrameworkApp = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(cAppName, hFrameworkApp, FALSE))) {
+ // LCOV_EXCL_BR_START 6:if FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hFrameworkApp is not NULL
+ if (NULL != hFrameworkApp) {
+ // LCOV_EXCL_BR_STOP
+ THApp hApp(hFrameworkApp);
+
+ /// Parse the Arguments via the FrameworkunifiedArgumentParser
+ /// passing an handle to the app and argument list
+ eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions);
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ eStatus = FrameworkunifiedDispatcherMain(hApp);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
+ }
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher: %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+
+ return eStatus;
+}
+
+// required for parsing subargument of -r
+char *g_cPlogSubOpts[] = {
+#define PLOG_OUTPUT 0
+ const_cast<PSTR>("output"),
+ NULL
+};
+
+EFrameworkunifiedStatus FrameworkunifiedArgumentParser(HANDLE hApp, int argc, char *argv[], CustomCommandLineOptions *cmdLineOptions) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ TFrameworkunifiedZoneMask mask = {};
+ PCHAR l_cMask = NULL;
+ UI_32 l_iMaskCount = 0;
+ CHAR l_logoutput[MAX_QUEUE_NAME_SIZE];
+ CHAR l_tFilePath[MAX_PATH_LENGTH];
+
+ BOOL l_bHasConfigFilepath = FALSE;
+
+ SI_32 l_iOpt = 0;
+ SI_32 l_iPriority = 10;
+ PSTR l_cOptions;
+ PSTR l_cValue;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "In");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+#ifdef DISPATCHER_PROFILER
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+#endif
+
+ if (argc > 0 && argv != NULL) {
+ // l:m:t:c: options are reserved for NS Framework and should not be used by other FRAMEWORKUNIFIED Applications.
+ CHAR l_cNSOptions[MAX_STRING_SIZE_TAG] = {};
+
+ strncpy(l_cNSOptions, "l:m:c:p:qr:s", (MAX_STRING_SIZE_TAG - 1));
+ optind = 1;
+
+ if (NULL != cmdLineOptions) {
+ // append custom options
+ strncat(l_cNSOptions, cmdLineOptions->cShortOptions, (MAX_STRING_SIZE_TAG - strlen(l_cNSOptions) - 1));
+ }
+ while ((eFrameworkunifiedStatusOK == eStatus) && ((l_iOpt = getopt(argc, argv, l_cNSOptions)) != -1)) {
+ switch (l_iOpt) {
+ case 'm': // mask value..
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-m (mask value): %s", optarg);
+ /*
+ * @todo
+ * If the second of the command-line arguments is-m and the third is not, an exception occurs.
+ */
+ char *saveptr;
+ l_cMask = strtok_r(optarg, ",", &saveptr);
+
+ while (NULL != l_cMask) {
+ mask[l_iMaskCount++] = static_cast<TFrameworkunifiedZone>(strtoul(l_cMask, NULL, 16));
+ l_cMask = strtok_r(NULL, ",", &saveptr);
+ }
+ NsLogSetControlMask(mask);
+ break;
+ case 'l': // log output
+ strncpy(l_logoutput, optarg, (MAX_QUEUE_NAME_SIZE - 1));
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-l (log output option): %s", l_logoutput);
+ NsLogSetLogMethod(NsLogDetermineLogMethod(l_logoutput));
+ break;
+ case 'c': // config file option
+ strncpy(l_tFilePath, optarg, (MAX_PATH_LENGTH - 1));
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-c (set config file): %s", l_tFilePath);
+ eStatus = SetConfigHandle(hApp, l_tFilePath);
+ l_bHasConfigFilepath = TRUE;
+ break;
+ case 'p': // priority
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-p (set priority): %s", optarg);
+ if (eFrameworkunifiedStatusOK != frameworkunified::framework::CFrameworkunifiedThreadPriorities::ParseThreadArguments(optarg)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING!! Failed to parse sub arguments of -p");
+ }
+ l_iPriority = frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(FrameworkunifiedGetAppName(hApp));
+ // set only if valid prio, otherwise use the default one
+ if (FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND != l_iPriority) {
+ pthread_setschedprio(pthread_self(),
+ frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(FrameworkunifiedGetAppName(hApp)));
+ }
+ break;
+ case 'q':
+#ifdef DISPATCHER_PROFILER
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-q (set msg dispatcher profiler)");
+ FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled = TRUE;
+ pApp->m_pFrameworkunifiedMsgProfiler = new(nothrow) FrameworkunifiedMsgProfiler(FrameworkunifiedGetAppName(hApp));
+#endif
+ break;
+ case 'r':
+ NSLogEnablePLog(TRUE);
+ l_cOptions = optarg;
+ while (*l_cOptions != '\0') {
+ switch (getsubopt(&l_cOptions, g_cPlogSubOpts, &l_cValue)) {
+ case PLOG_OUTPUT: {
+ if (l_cValue != NULL) {
+ NSLogSetPlogOutputOptions(static_cast<UI_8>(strtoul(l_cValue, NULL, 16)));
+ }
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+ break;
+ case 's':
+ NSLogEnableSysEventLog(TRUE);
+ break;
+ default:
+ if (NULL != cmdLineOptions) {
+ // option other than l:m:t:c: is a custom option, therefore let application handle that option.
+ if (eFrameworkunifiedStatusOK != cmdLineOptions->callback(l_iOpt, optarg)) {
+ // Do not terminate an application even if invalid arguments received
+ // eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING!! Invalid cmd line argument received.");
+ }
+ } else {
+ // Do not terminate an application even if invalid arguments received
+ // eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING!! Invalid cmd line argument received.");
+ }
+ break;
+ }
+ }
+ }
+
+ // if no config option is selected then use the default config path
+ if ((FALSE == l_bHasConfigFilepath) && (eFrameworkunifiedStatusOK == eStatus)) {
+ eStatus = SetDefaultConfigFile(hApp);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedSimpleDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSimpleDispatcher(PCSTR cAppName, const FrameworkunifiedDefaultCallbackHandler *CbHandler, CbFuncPtr CbShutdown,
+ BOOL isChildThread) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ // if main thread then set log process name
+ if (!isChildThread) {
+ NsLogSetProcessName(cAppName);
+ }
+
+ if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
+ return eStatus;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "+");
+
+ if (NULL != CbShutdown) {
+ try {
+ HANDLE hFrameworkApp = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(cAppName, hFrameworkApp, isChildThread))) {
+ // LCOV_EXCL_BR_START 6:if FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hFrameworkApp is not NULL
+ if (NULL != hFrameworkApp) {
+ // LCOV_EXCL_BR_STOP
+ THApp hApp(hFrameworkApp);
+
+ // Call application defined start function
+ eStatus = FrameworkunifiedOnInitializationInternal(hApp);
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
+ throw happ_error();
+ } else {
+ while (eFrameworkunifiedStatusExit != eStatus) {
+ try {
+ // dispatch block: waits on receive message
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDispatchBlock(hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: FrameworkunifiedDispatchBlock : 0x%x ", eStatus);
+ continue;
+ }
+ // dispatch process: calls respective call back functions
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDispatchProcess(hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: FrameworkunifiedDispatchProcess : 0x%x ", eStatus);
+ }
+ } catch (const frameworkunified::framework::error::CSystemError &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
+ } catch (const std::exception &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exiting dispatcher ");
+ }
+ // Call application defined stop function
+ eStatus = CbShutdown(hApp);
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
+ }
+ } catch (const THApp::Exception &) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus RunDispatcher(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ int efd;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+#ifdef DISPATCHER_PROFILER
+ // Get the application handle
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+ if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
+ FrameworkunifiedAttachMsgProfilerCallbacksDispatcher(hApp);
+ }
+#endif
+ FrameworkunifiedGetDispatcherFD(hApp, &efd);
+
+ while (1) {
+ frameworkunifiedFdHandler(hApp, efd);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+EFrameworkunifiedStatus FrameworkunifiedDispatcherMain(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ try {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "Success: FrameworkunifiedCreateDispatcher ");
+
+ // Initialize the global structures
+ // register service with service dir
+ // register notifications
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
+ eStatus = FrameworkunifiedOnInitializationInternal(hApp);
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
+ throw happ_error();
+ } else {
+ eStatus = RunDispatcher(hApp);
+ CFrameworkunifiedSyncData::FrameworkunifiedReleaseSyncDataInstance();
+ }
+ } catch (const frameworkunified::framework::error::CSystemError &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
+ } catch (const THApp::Exception &) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherWithoutLoop(PCSTR cAppName, HANDLE &hApp, int argc, char *argv[], // NOLINT (readability/nolint)
+ const FrameworkunifiedDefaultCallbackHandler *CbHandler,
+ BOOL bIsConnectSM, CustomCommandLineOptions *cmdLineOptions) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ THApp *l_hApp = NULL;
+
+ if (cAppName == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ NsLogSetProcessName(cAppName);
+
+ PLOG_TEXT("FrameworkunifiedDispatcher Start");
+ // set main thread name as provided in dispatcher
+ pthread_setname_np(pthread_self(), cAppName);
+
+ if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
+ return eStatus;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In");
+
+ try {
+ HANDLE hFrameworkApp = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(cAppName, hFrameworkApp,
+ bIsConnectSM == TRUE ? FALSE : TRUE))) {
+ // LCOV_EXCL_BR_START 6:if FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hFrameworkApp is not NULL
+ if (NULL != hFrameworkApp) {
+ // LCOV_EXCL_BR_STOP
+ l_hApp = new THApp(hFrameworkApp);
+ hApp = *l_hApp;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->pRsrcMgr = reinterpret_cast<void *>(l_hApp);
+
+ eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions);
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
+ eStatus = FrameworkunifiedOnInitializationInternal(hApp);
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
+ }
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
+ }
+ } catch (const THApp::Exception &) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedDispatchProcessWithoutLoop(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ int efd; // FD for multi waiting
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ FrameworkunifiedGetDispatcherFD(hApp, &efd);
+ eStatus = frameworkunifiedFdHandler(hApp, efd);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedDestroyDispatcherWithoutLoop(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ try {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ THApp *RsrcMgr = reinterpret_cast<THApp *>(pApp->pRsrcMgr);
+ delete RsrcMgr;
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+static EFrameworkunifiedStatus GetDispatcherMqFD(HANDLE hApp, int *fd) {
+ if (fd == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "fd is NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ *fd = McGetQueueFD(pApp->hAppRcvMsgQ);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+static EFrameworkunifiedStatus CreateMultiWaitingFD(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ int efd; // FD for multi waiting
+ int q_fd; // FD for Dispatcher's message queue
+ int defer_evfd; // FD for receiving Defer events to Dispatcher
+ struct epoll_event ev; // Info struct to associate with multiwaiting FD
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // Create efd
+ efd = epoll_create1(EPOLL_CLOEXEC);
+ if (-1 != efd) {
+ pApp->efd = efd;
+
+ // get fd to Dispatcher's message queue
+ eStatus = GetDispatcherMqFD(hApp, &q_fd);
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ // efd to monitor the q_fd.
+ ev.events = EPOLLIN;
+ ev.data.fd = q_fd;
+ if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, q_fd, &ev)) {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(q_fd, ADD) Failed, "
+ "status=%d, errno=%d", eStatus, errno);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : GetDispatcherMqFD Failed, status=%d", eStatus);
+ }
+
+ // create FD for receiving Defer events to Dispatcher
+ defer_evfd = eventfd(0, EFD_CLOEXEC);
+ if (-1 != defer_evfd) {
+ pApp->defer_evfd = defer_evfd;
+
+ // efd to monitor the defer_evfd.
+ ev.events = EPOLLIN;
+ ev.data.fd = defer_evfd;
+ if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, defer_evfd, &ev)) {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(defer_evfd, ADD) Failed,"
+ " status=%d, errno=%d", eStatus, errno);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : eventfd Failed, status=%d, errno=%d", eStatus, errno);
+ }
+
+ // add abnormal monitor socket polling
+ if (-1 != pApp->siMonitorSock) {
+ ev.events = EPOLLIN;
+ ev.data.fd = pApp->siMonitorSock;
+ if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, pApp->siMonitorSock, &ev)) {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_create1 Failed, status=%d, errno=%d", eStatus, errno);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedGetDispatcherFD(HANDLE hApp, int *efd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (NULL != efd) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ *efd = pApp->efd;
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnInitializationInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onInitilization != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onInitilization(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnDestroyInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onDestroy != NULL) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (pApp->hParentSndMsgQ == NULL) {
+ // main thread
+ try {
+ eStatus = g_defaultCallbackHandler.onDestroy(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnStartInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onStart != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onStart(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnStopInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onStop != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onStop(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStartInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onPreStart != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onPreStart(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnPreStopInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onPreStop != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onPreStop(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStartInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onBackgroundStart != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onBackgroundStart(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStopInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onBackgroundStop != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onBackgroundStop(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDumpInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.onDebugDump != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.onDebugDump(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachineInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.createStateMachine != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.createStateMachine(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterfaceInternal(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (g_defaultCallbackHandler.ssFrameworkInterface != NULL) {
+ try {
+ eStatus = g_defaultCallbackHandler.ssFrameworkInterface(hApp);
+ } catch (const std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: %s", e.what());
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus RegistDefaultCbHandler(const FrameworkunifiedDefaultCallbackHandler *CbHandler) {
+ if (CbHandler == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ } else if (CbHandler->onInitilization == NULL || CbHandler->onDestroy == NULL || CbHandler->onStart == NULL ||
+ CbHandler->onStop == NULL
+ || CbHandler->onPreStart == NULL || CbHandler->onPreStop == NULL
+ || CbHandler->onBackgroundStart == NULL || CbHandler->onBackgroundStop == NULL
+ || CbHandler->onDebugDump == NULL || CbHandler->createStateMachine == NULL
+ || CbHandler->ssFrameworkInterface == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " [ ABORT ] DefaultCallbackHandler is NULL");
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ g_defaultCallbackHandler = *CbHandler;
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedGetDefaultCbHandler(FrameworkunifiedDefaultCallbackHandler *CbHandler) {
+ if (CbHandler == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ *CbHandler = g_defaultCallbackHandler;
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus frameworkunifiedFdHandler(HANDLE hApp , int efd) {
+ struct epoll_event events[MAX_FD_MULTIWAITING];
+ int nfds; // The number of events received
+ int q_fd; // The FD of events received
+ int n; // Loop counter
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ const char *key;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ eStatus = GetDispatcherMqFD(hApp, &q_fd);
+ // LCOV_EXCL_BR_START 6:Because of hApp is valid, GetDispatcherMqFD return eFrameworkunifiedStatusOK.
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ // LCOV_EXCL_BR_STOP
+ nfds = epoll_wait(efd, events, MAX_FD_MULTIWAITING, -1);
+ if (-1 != nfds) {
+ for (n = 0; n < nfds; ++n) {
+ if (pApp->siMonitorSock == events[n].data.fd) {
+ // abnormal monitor connect request
+ int socket;
+
+ if ((socket = mcAcceptMonitor(pApp->cAppName, pApp->siMonitorSock)) >= 0) {
+ struct epoll_event event;
+
+ event.events = EPOLLRDHUP;
+ event.data.fd = socket;
+
+ if (epoll_ctl(pApp->efd, EPOLL_CTL_ADD, socket, &event) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
+ }
+ }
+ }
+ }
+
+ for (n = 0; n < nfds; ++n) {
+ // The branch processing by FD on which the message was received
+ if (q_fd == events[n].data.fd) {
+ // process the message to the Dispatcher's message queue
+ eStatus = ProcessMq(hApp);
+ } else if (pApp->defer_evfd == events[n].data.fd) {
+ // process the Defer event to the Dispatcher
+ uint64_t data;
+ ssize_t len;
+
+ len = read(pApp->defer_evfd, &data, sizeof(uint64_t));
+ if (len < 0) {
+ // read error
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : read Failed, status=%d, errno=%d, defer_evfd=%d",
+ eStatus, errno, pApp->defer_evfd);
+ } else {
+ while (TRUE == (FrameworkunifiedPopedDeferedMessage(hApp))) {
+ try {
+ // dispatch process: calls respective call back functions
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDispatchProcess(hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : FrameworkunifiedDispatchProcess Status : 0x%x", eStatus);
+ }
+ } catch (const frameworkunified::framework::error::CSystemError &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
+ } catch (const std::exception &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from : %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ }
+ } else if (pApp->siMonitorSock == events[n].data.fd) {
+ // do nothing
+ } else if (frameworkunifiedSearchResourseKey(FRAMEWORKUNIFIED_RES_ABNMLMON, events[n].data.fd, &key) == 0) {
+ if (pApp->acceptMonitorTable.find(events[n].data.fd) != pApp->acceptMonitorTable.end()) {
+ // server: accept socket close
+ eStatus = frameworkunifiedProcessClientAbnormalState(hApp, events[n].data.fd);
+ } else if (pApp->connectMonitorTable.find(events[n].data.fd) != pApp->connectMonitorTable.end()) {
+ // client: connect socket close
+ eStatus = frameworkunifiedProcessServerAbnormalState(hApp, events[n].data.fd);
+ }
+
+ if (epoll_ctl(pApp->efd, EPOLL_CTL_DEL, events[n].data.fd, NULL) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl:%s", strerror(errno));
+ }
+ close(events[n].data.fd);
+ frameworkunifiedUnregistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, key);
+ } else {
+ // process the message to the FD set by the user
+ eStatus = ProcessFd(hApp, events[n].data.fd);
+ }
+ }
+ } else {
+ if (errno == EINTR) {
+ // signal interrupt
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_wait Failed, status=%d, errno=%d", eStatus, errno);
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6:Because of hApp is valid, GetDispatcherMqFD return eFrameworkunifiedStatusOK.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : GetDispatcherMqFD Failed, status=%d", eStatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+static EFrameworkunifiedStatus ProcessMq(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+#ifdef DISPATCHER_PROFILER
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+#endif
+
+ // handle defer'ed message
+ if (FALSE == FrameworkunifiedPopedDeferedMessage(hApp)) {
+ // dispatch block: waits on receive message
+ if ((eStatus = FrameworkunifiedDispatchBlock(hApp)) != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : FrameworkunifiedDispatchBlock Status : 0x%x", eStatus);
+ }
+ #ifdef DISPATCHER_PROFILER
+ else if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) { // NOLINT (readability/nolint)
+ pApp->m_pFrameworkunifiedMsgProfiler->MsgReceived();
+ }
+ #endif
+ }
+ try {
+ // dispatch process: calls respective call back functions
+ eStatus = FrameworkunifiedDispatchProcess(hApp);
+ } catch (const frameworkunified::framework::error::CSystemError &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
+ } catch (const std::exception &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from : %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+#ifdef DISPATCHER_PROFILER
+ if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
+ pApp->m_pFrameworkunifiedMsgProfiler->MsgProcessed();
+ }
+#endif
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+static EFrameworkunifiedStatus ProcessFd(HANDLE hApp , int fd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ FdTable::iterator f_iterator;
+ struct rusage start, end;
+ BOOL enable_rusage = NsLogIsZoneSet(ZONE_NS_DEBUG_DUMP);
+
+ if (enable_rusage == TRUE) {
+ frameworkunifiedGetRusage(&start);
+ }
+
+ // finding callback func associated with FD
+ f_iterator = pApp->fds.find(fd);
+ if (f_iterator != pApp->fds.end()) {
+ try {
+ // calling func associated with FD
+ eStatus = (*f_iterator).second(hApp);
+ } catch (const frameworkunified::framework::error::CSystemError &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
+ } catch (const std::exception &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Recovering from: %s", err.what());
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Callback associated with FD is not found. ", eStatus);
+ }
+
+ if (enable_rusage == TRUE) {
+ frameworkunifiedGetRusage(&end);
+ frameworkunifiedPrintRusage(hApp, start, end);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////////
+/// EFrameworkunifiedStatus SetConfigHandle(HANDLE hApp, PCHAR sFilePath )
+/// This Function opens the file from give path and sets the file handle in hApp
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetConfigHandle(HANDLE hApp, PCHAR sFilePath) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "This function is not implemented");
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////////
+/// EFrameworkunifiedStatus SetDefaultFilePath(HANDLE hApp)
+/// This Function fetches the file path from Environment variable from PASA_APPCONFIG_FILES and
+/// pass it to the SetConfigHandle function
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetDefaultConfigFile(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ // Get the file path from environment variable
+ PCHAR l_strEnvValue = getenv(PASA_APPCONFIG_FILES);
+
+ if (l_strEnvValue) {
+ // FRAMEWORKUNIFIEDLOG( ZONE_NS_DIS, __FUNCTION__, "Configuration file path %s ",l_strEnvValue);
+
+ std::string l_strFilePath(l_strEnvValue);
+
+ if (!l_strFilePath.empty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Configuration file path %s ", l_strFilePath.c_str());
+ // Open the configuration file
+ SetConfigHandle(hApp, (PCHAR)l_strFilePath.c_str());
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedProcessServiceProtocolHSMEvent(HANDLE hApp, PCSTR pRequester) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ EventServices::iterator s_iterator;
+
+ // finding the service
+ s_iterator = pApp->eventservices.find(pRequester);
+ if (s_iterator != pApp->eventservices.end()) {
+ EventSessionTable::iterator session_iterator;
+ session_iterator = (s_iterator->second).find(pApp->uiSessionId);
+ if (session_iterator != (s_iterator->second).end()) {
+ ServiceEventProtocolTable::iterator spt_iterator;
+
+ // FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " %s found :: (%s) ", pApp->cMsgSrcName, s_iterator->second);
+
+ // find the protocol req/ack handler
+ spt_iterator = (session_iterator->second).find(pApp->uiProtocolCmd);
+ if (spt_iterator != (session_iterator->second).end()) {
+ // FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, " Protocol Command :: (0x%x) ", pApp->uiProtocolCmd);
+ // Post corresponding event
+ CFrameworkunifiedHSMFramework *l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
+ if (l_pStateMachine) {
+ eStatus = l_pStateMachine->FrameworkunifiedPostEvent(spt_iterator->second);
+ }
+ } else if ((session_iterator->second).end() != (spt_iterator =
+ (session_iterator->second).find(FRAMEWORKUNIFIED_ANY_COMMAND))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Processing HSM event for (FRAMEWORKUNIFIED_ANY_COMMAND). "
+ "Dispatcher protocol command: (0x%x)",
+ pApp->uiProtocolCmd);
+ // Post corresponding event
+ CFrameworkunifiedHSMFramework *l_pStateMachine = FrameworkunifiedGetStateMachine(hApp);
+ if (l_pStateMachine) {
+ eStatus = l_pStateMachine->FrameworkunifiedPostEvent(spt_iterator->second);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ }
+
+ // if FrameworkunifiedPostEvent returns NULL
+ if (eFrameworkunifiedStatusNullPointer == eStatus) {
+ eStatus = eFrameworkunifiedStatusExit;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ }
+
+ } else {
+ eStatus = eFrameworkunifiedStatusMsgNotProcessed;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : ProcessProtocolEvents
+//////////////////////////////////////////
+EFrameworkunifiedStatus ProcessProtocolEvents(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // common event table iterator
+ EventTable::iterator e_iterator;
+ ServiceSessionIdListTable::iterator ssidl_iterator;
+
+ // public state event table iterator
+ PublicStateEventTable::iterator se_iterator;
+
+ // private state event table iterator
+ PrivateStateEventTable::iterator pse_iterator;
+ ServiceSessionEventData::iterator ssed_iterator;
+ SessionEventData::iterator sed_iterator;
+
+ HANDLE l_pClientHandle = NULL;
+
+ // get the name of the service from which message is received
+ PCSTR l_cServiceName = pApp->cMsgSrcName;
+ const UI_32 l_uiSessionId = pApp->uiSessionId;
+
+ // number of events to register
+ UI_32 l_uiListSize = static_cast<UI_32>(FrameworkunifiedGetMsgLength(hApp) / sizeof(UI_32));
+
+ // check if the received service name and data is valid
+ if (NULL != l_cServiceName && 0 < l_uiListSize) {
+ PUI_32 l_pData = new UI_32[l_uiListSize];
+ UI_32 l_uiEventId = 0;
+
+ // get the list of events
+ eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, l_pData, static_cast<UI_32>(l_uiListSize * sizeof(UI_32)));
+
+ if (NULL != l_pData && eFrameworkunifiedStatusOK == eStatus) {
+ for (UI_32 uiCount = 0; uiCount < l_uiListSize; uiCount++) {
+ // received event id
+ l_uiEventId = l_pData[uiCount];
+
+ // find the event in map of EventTable
+ e_iterator = pApp->eventtable.find(l_uiEventId);
+
+ // if event is registered by any of the clients
+ if (pApp->eventtable.end() != e_iterator) {
+ // table of services with list of their session id's registering this event
+ ServiceSessionIdListTable &l_mServiceSessionIdListTable = e_iterator->second;
+
+ // find the service name in map of ServiceSessionIdListTable
+ ssidl_iterator = l_mServiceSessionIdListTable.find(l_cServiceName);
+
+ // if service have already registered this event with any of its session
+ if (l_mServiceSessionIdListTable.end() != ssidl_iterator) {
+ // list of sessions id's registering with this event
+ SessionIdList &l_vSessionIdList = ssidl_iterator->second;
+
+ // event is registered with this session
+ if (IsEventAlreadyRegistered(l_vSessionIdList, l_uiSessionId)) {
+ // get the message queue handle from map servicesessionhandletable
+ l_pClientHandle = GetMsgQueueHandle(hApp, l_cServiceName, l_uiSessionId);
+ } else { // event is not registered with this session
+ // create new message queue handle and insert it in map servicesessionhandletable
+ l_pClientHandle = GetNewHandleAndUpdateEventInfoTable(hApp,
+ l_cServiceName, l_uiSessionId, l_uiEventId);
+
+ // insert the current session id
+ l_vSessionIdList.push_back(l_uiSessionId);
+ }
+ } else { // if service have not registered this event with any of its session
+ // create a list for storing session id's registering this event for this service
+ SessionIdList l_vSessionIdList;
+
+ // insert the current session id
+ l_vSessionIdList.push_back(l_uiSessionId);
+
+ // create new message queue handle and insert it in map servicesessionhandletable
+ l_pClientHandle = GetNewHandleAndUpdateEventInfoTable(hApp, l_cServiceName, l_uiSessionId, l_uiEventId);
+
+ // make a entry for service name and session id's list in map of ServiceSessionIdListTable
+ l_mServiceSessionIdListTable.insert(make_pair(l_cServiceName, l_vSessionIdList));
+ }
+ } else { // if event is not registered by any of the clients
+ // create a list for storing session id's registering this event for this service
+ SessionIdList l_vSessionIdList;
+
+ // insert the current session id
+ l_vSessionIdList.push_back(l_uiSessionId);
+
+ // create new message queue handle and insert it in map servicesessionhandletable
+ l_pClientHandle = GetNewHandleAndUpdateEventInfoTable(hApp, l_cServiceName, l_uiSessionId, l_uiEventId);
+
+ // create a table for storing services and its session id list, registering this event
+ ServiceSessionIdListTable l_mServiceSessionIdListTable;
+
+ // make a entry for service name and session id's list in map of ServiceSessionIdListTable
+ l_mServiceSessionIdListTable.insert(make_pair(l_cServiceName, l_vSessionIdList));
+
+ // insert the table with event id in EventTable
+ pApp->eventtable.insert(make_pair(l_uiEventId, l_mServiceSessionIdListTable));
+ }
+
+ // check whether event is defined as public state event
+ se_iterator = pApp->publicstateeventtable.find(l_uiEventId);
+
+ // if event is a state event, publish the event
+ if (pApp->publicstateeventtable.end() != se_iterator) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "%d is a public state event", l_uiEventId);
+
+ if (NULL != (se_iterator->second)) {
+ // send the event data for state event
+ eStatus = FrameworkunifiedSendMsg(l_pClientHandle,
+ l_uiEventId,
+ (se_iterator->second)->uiLength,
+ (se_iterator->second)->pData);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Sending event:%d to service:%s, session:%d, status:%d",
+ l_uiEventId,
+ l_cServiceName,
+ l_uiSessionId,
+ eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d yet not published ", l_uiEventId);
+ }
+ } else { // check whether the event is defined as private state event
+ pse_iterator = pApp->privatestateeventtable.find(l_uiEventId);
+
+ // if event found, publish the event
+ if (pApp->privatestateeventtable.end() != pse_iterator) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "%d is a private state event", l_uiEventId);
+
+ ssed_iterator = (pse_iterator->second).find(l_cServiceName);
+
+ // check whether the event had been published for this service before subscription
+ if ((pse_iterator->second).end() != ssed_iterator) {
+ sed_iterator = (ssed_iterator->second).find(l_uiSessionId);
+
+ // check whether the event had been published for this service for the same session
+ if ((ssed_iterator->second).end() != sed_iterator) {
+ if (NULL != (sed_iterator->second)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%d had been published for the "
+ "service:%s on sessionId:%d ", l_uiEventId,
+ l_cServiceName, l_uiSessionId);
+
+ // send the event data for state event
+ eStatus = FrameworkunifiedSendMsg(l_pClientHandle,
+ l_uiEventId,
+ (sed_iterator->second)->uiLength,
+ (sed_iterator->second)->pData);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Sending event:%d to service:%s, session:%d, status:%d",
+ l_uiEventId,
+ l_cServiceName,
+ l_uiSessionId,
+ eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d yet not published ", l_uiEventId);
+ }
+ }
+ }
+ }
+ }
+ } // end of for loop of events list
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_REGISTER_EVENTS Invalid data ", eStatus);
+ }
+
+ if (NULL != l_pData) {
+ delete[] l_pData;
+ l_pData = NULL;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_REGISTER_EVENTS Service Name invalid ", eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : IsEventAlreadyRegistered
+//////////////////////////////////////////
+BOOL IsEventAlreadyRegistered(const SessionIdList &vSessionIdList, const UI_32 uiSessionId) {
+ for (UI_32 uiCount = 0; uiCount < vSessionIdList.size(); uiCount++) {
+ if (uiSessionId == vSessionIdList[uiCount]) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+//////////////////////////////////////////
+// Function : GetMsgQueueHandle
+//////////////////////////////////////////
+HANDLE GetMsgQueueHandle(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId) {
+ HANDLE l_pClientHandle = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ ServiceSessionHandleTable::iterator ssh_iterator;;
+ SessionToEventInfo::iterator sh_iterator;
+
+ // find the service name
+ ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
+
+ if (pApp->servicesessionhandletable.end() != ssh_iterator) {
+ // search for session id
+ sh_iterator = ssh_iterator->second.find(uiSessionId);
+
+ if (ssh_iterator->second.end() != sh_iterator) {
+ SessionEventInfo *l_ptSessionEventInfo = sh_iterator->second;
+ if (NULL != l_ptSessionEventInfo) {
+ l_pClientHandle = l_ptSessionEventInfo->m_hSession;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Handle found for service: %s, session: %d, handle:%p.",
+ serviceName, uiSessionId, l_pClientHandle);
+ }
+ }
+ }
+ }
+
+ if (NULL == l_pClientHandle) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Handle NULL for service: %s, session: %d.",
+ serviceName != 0 ? serviceName : NULL, uiSessionId);
+ }
+
+ return l_pClientHandle;
+}
+
+//////////////////////////////////////////
+// Function : GetNewHandleAndUpdateEventInfoTable
+//////////////////////////////////////////
+HANDLE GetNewHandleAndUpdateEventInfoTable(HANDLE hApp, PCSTR serviceName, const UI_32 uiSessionId,
+ const UI_32 uiEventId) {
+ HANDLE l_pClientHandle = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ ServiceSessionHandleTable::iterator ssh_iterator;;
+ SessionToEventInfo::iterator sh_iterator;
+
+ ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
+
+ if (pApp->servicesessionhandletable.end() == ssh_iterator) {
+ SessionToEventInfo l_mSessionToEventInfoTable;
+ pApp->servicesessionhandletable.insert(make_pair(serviceName, l_mSessionToEventInfoTable));
+ }
+
+ sh_iterator = pApp->servicesessionhandletable[serviceName].find(uiSessionId);
+
+ if (pApp->servicesessionhandletable[serviceName].end() == sh_iterator) {
+ l_pClientHandle = FrameworkunifiedMcOpenSender(hApp, serviceName);
+ if (NULL != l_pClientHandle) {
+ (reinterpret_cast<MsgQInfo *>(l_pClientHandle))->sessionId = uiSessionId;
+ }
+ SessionEventInfo *l_ptSessionEventInfo = new(std::nothrow) SessionEventInfo;
+ if (NULL != l_ptSessionEventInfo) { // LCOV_EXCL_BR_LINE 5: new's error case.
+ l_ptSessionEventInfo->m_hSession = l_pClientHandle;
+ l_ptSessionEventInfo->m_vEvents.push_back(uiEventId);
+ pApp->servicesessionhandletable[serviceName].insert(std::make_pair(uiSessionId, l_ptSessionEventInfo));
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error(NULL) createing new session event info for "
+ "service:%s, session:%d, event:%d.",
+ serviceName, uiSessionId, uiEventId);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ SessionEventInfo *l_ptSessionEventInfo = sh_iterator->second;
+ if (NULL != l_ptSessionEventInfo) {
+ if (NULL == l_ptSessionEventInfo->m_hSession) {
+ l_ptSessionEventInfo->m_hSession = FrameworkunifiedMcOpenSender(hApp, serviceName);
+ if (NULL != l_ptSessionEventInfo->m_hSession) {
+ (reinterpret_cast<MsgQInfo *>(l_ptSessionEventInfo->m_hSession))->sessionId = uiSessionId;
+ }
+ }
+ l_pClientHandle = l_ptSessionEventInfo->m_hSession;
+ l_ptSessionEventInfo->m_vEvents.push_back(uiEventId);
+ }
+ }
+ }
+ return l_pClientHandle;
+}
+
+//////////////////////////////////////////
+// Function : UnregisterPrivateEvents
+//////////////////////////////////////////
+EFrameworkunifiedStatus UnregisterPrivateEvents(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // get the name of the service from which message is received
+ PCSTR l_cServiceName = pApp->cMsgSrcName;
+ const UI_32 l_uiSessionId = pApp->uiSessionId;
+
+ // number of events to unregister
+ UI_32 l_uiListSize = static_cast<UI_32>(FrameworkunifiedGetMsgLength(hApp) / sizeof(UI_32));
+
+ // check if the received service name and data is valid
+ if (NULL != l_cServiceName && 0 < l_uiListSize) {
+ PUI_32 l_pData = new(std::nothrow) UI_32[l_uiListSize];
+ UI_32 l_uiEventId = 0;
+
+ if (NULL != l_pData) { // LCOV_EXCL_BR_LINE 5: new's error case.
+ // get the list of events
+ eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, l_pData, static_cast<UI_32>(l_uiListSize * sizeof(UI_32)));
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ for (UI_32 uiCount = 0; uiCount < l_uiListSize; uiCount++) {
+ // received event id
+ l_uiEventId = l_pData[uiCount];
+
+ // remove the entry from map of Events and Session id's of services
+ eStatus = RemoveEventEntryFromEventTable(hApp, l_uiEventId, l_cServiceName, l_uiSessionId);
+ (VOID)RemoveEntryFromSessionEventInfoTable(hApp, l_cServiceName, l_uiSessionId, l_uiEventId);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_REGISTER_EVENTS Invalid data ", eStatus);
+ }
+ delete[] l_pData;
+ l_pData = NULL;
+ } else {
+ // LCOV_EXCL_START 5: new's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: PROTOCOL_UNREGISTER_EVENTS: "
+ "Unable to allocate memory for l_pData");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, PROTOCOL_UNREGISTER_EVENTS Service Name invalid ", eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, Invalid hApp ", eStatus);
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : HandleSessionEventOnCloseSession
+//////////////////////////////////////////
+EFrameworkunifiedStatus HandleSessionEventOnCloseSession(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ // close session request structure
+ CloseSessionReq tClose = {};
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(tClose)) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tClose, sizeof(tClose)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, FrameworkunifiedGetMsgDataOfSize Failed ", eStatus);
+ } else {
+ CleanAllEventsOfSession(hApp, pApp->cMsgSrcName, tClose.sessionId);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid data length received:: Expected: %ld, Received: %d",
+ static_cast<long int>(sizeof(tClose)), FrameworkunifiedGetMsgLength(hApp)); // NOLINT (readability/nolint)
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid application handle status.");
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDummy
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDummy(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+#ifdef DISPATCHER_PROFILER
+EFrameworkunifiedStatus FrameworkunifiedAttachMsgProfilerCallbacksDispatcher(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
+ eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp,
+ "NSProfileUtil",
+ PROTOCOL_DIS_MSGPROFILER,
+ boost::bind(&FrameworkunifiedMsgProfiler::PrintProfileInfo,
+ pApp->m_pFrameworkunifiedMsgProfiler, hApp));
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "FrameworkunifiedAttachCallbackToDispatcher success for PROTOCOL_DIS_MSGPROFILER.");
+ }
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedAttachChildMsgProfilerCallbacksDispatcher(HANDLE hChildApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "+");
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
+ if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
+ eStatus = FrameworkunifiedAttachCallbackToDispatcher(hChildApp,
+ pApp->cParentAppName,
+ PROTOCOL_DIS_MSGPROFILER,
+ boost::bind(&FrameworkunifiedMsgProfiler::PrintProfileInfo,
+ pApp->m_pFrameworkunifiedMsgProfiler, hChildApp));
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "FrameworkunifiedAttachCallbackToDispatcher success for PROTOCOL_DIS_MSGPROFILER.");
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, "", "-");
+ return eStatus;
+}
+#endif
+// EOF
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp
new file mode 100644
index 00000000..cb573c97
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_dispatch.cpp
@@ -0,0 +1,983 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <sys/epoll.h>
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_plogger_if.h>
+#include <other_service/strlcpy.h>
+
+#include <map>
+#include <utility>
+
+#include "frameworkunified_framework_core.h"
+///////////////////////////////////////////////////
+// Utility
+///////////////////////////////////////////////////
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetAppName
+//////////////////////////////////////////
+PCSTR FrameworkunifiedGetAppName(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ const CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return ((PCSTR)pApp->cAppName);
+ } else {
+ return NULL;
+ }
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedSetThreadSpecificData
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetThreadSpecificData(HANDLE hApp, PVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->FrameworkData = data;
+
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetThreadSpecificData
+//////////////////////////////////////////
+PVOID FrameworkunifiedGetThreadSpecificData(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ const CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+ return pApp->FrameworkData;
+ } else {
+ return NULL;
+ }
+}
+
+
+
+template <typename K, typename V, class C, class A>
+std::ostream &operator<< (std::ostream &os, std::map<K, V, C, A> const &m) {
+ os << "{ ";
+ typename std::map<K, V, C, A>::const_iterator p;
+ for (p = m.begin(); p != m.end(); ++p) {
+ os << p->first << ":" << p->second << ", ";
+ }
+ return os << "}";
+}
+
+
+
+
+
+
+
+///////////////////////////////////////////////////
+// Service Protocol attach/detach to dispatcher
+///////////////////////////////////////////////////
+
+
+
+
+
+
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachCallbacksToDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbacksToDispatcher(HANDLE hApp, PCSTR pServiceName, const FrameworkunifiedProtocolCallbackHandler *handlers,
+ UI_32 handlerCount, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName && NULL != handlers && 0 != handlerCount) {
+ // setup callbacks
+ for (UI_32 i = 0; i < handlerCount; ++i) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, pServiceName, handlers[ i ].iCmd,
+ handlers[ i ].callBack, hSession))) {
+ break;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+/////////////////////////////////////////////
+// Function : FrameworkunifiedAttachCallbackToDispatcher
+/////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbackToDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, CbFuncPtr fpOnCmd,
+ HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName && NULL != fpOnCmd) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ Services::iterator s_iterator;
+ SessionTable::iterator session_iterator;
+
+ UI_32 uiSessionId = 0;
+ if (hSession) {
+ uiSessionId = FrameworkunifiedGetSessionId(hSession);
+ }
+
+ // finding the service
+ s_iterator = pApp->services.find(pServiceName);
+ if (s_iterator == pApp->services.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (New service entry): service name [%s]", pApp->cAppName, pServiceName);
+ s_iterator = pApp->services.insert(std::make_pair(pServiceName, SessionTable())).first;
+ }
+
+ session_iterator = s_iterator->second.find(uiSessionId);
+ if (session_iterator == s_iterator->second.end()) {
+ session_iterator = s_iterator->second.insert(std::make_pair(uiSessionId, ServiceProtocolTable())).first;
+ }
+
+ session_iterator->second.insert(std::make_pair(iCmd, fpOnCmd));
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachCallbacksToDispatcherWithFd
+///////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbacksToDispatcherWithFd(HANDLE hApp, const FrameworkunifiedFdProtocolCallbackHandler *handlers,
+ UI_32 handlerCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != handlers && 0 != handlerCount) {
+ // setup callbacksWithFd
+ for (UI_32 i = 0; i < handlerCount; ++i) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachCallbackToDispatcherWithFd(hApp, handlers[ i ].fd,
+ handlers[ i ].callBack))) {
+ break;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %d, Invalid param ", eStatus);
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachCallbackToDispatcherWithFd
+///////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbackToDispatcherWithFd(HANDLE hApp, int fd, CbFuncPtr fpOnCmd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ int efd; // FD for multi waiting
+ struct epoll_event ev; // Info struct to associate with multiwaiting FD
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && 0 < fd && NULL != fpOnCmd) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // attach callbackFuncPtr and FD to FdTable.
+ pApp->fds.insert(std::make_pair(fd, fpOnCmd));
+
+ // Monitor FD by epoll.
+ efd = pApp->efd;
+ if (0 < efd) {
+ ev.events = EPOLLIN;
+ ev.data.fd = fd;
+ if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ev)) {
+ /**
+ * Duplicate registering the same FD in the Dispatcher causes an internal epoll_ctl errno EEXIST(val17) to be returned, which results in an error.
+ */
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(ADD) Failed, status=%d, errno=%d", eStatus, errno);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Multi waiting FD is Invalid , status=%d, efd=%d", eStatus, efd);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %d, Invalid param ", eStatus);
+ }
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachParentCallbacksToDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachParentCallbacksToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolCallbackHandler *handlers,
+ UI_32 handlerCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hChildApp) && NULL != handlers && 0 != handlerCount) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
+
+ eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hChildApp, pApp->cParentAppName, handlers, handlerCount);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachParentCallbacksFromDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachParentCallbacksFromDispatcher(HANDLE hChildApp, const PUI_32 puiCmdArray, UI_32 uiCommandCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hChildApp) && NULL != puiCmdArray && 0 != uiCommandCount) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
+
+ eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hChildApp, pApp->cParentAppName, puiCmdArray, uiCommandCount);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachCallbacksFromDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbacksFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiCmdArray,
+ UI_32 uiCommandCount, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName && NULL != puiCmdArray && 0 != uiCommandCount) {
+ // setup callbacks
+ for (UI_32 i = 0; i < uiCommandCount; ++i) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(hApp, pServiceName,
+ puiCmdArray[ i ], hSession))) {
+ break;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+
+////////////////////////////////////////////
+// Function : FrameworkunifiedDetachCallbackFromDispatcher
+/////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbackFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ Services::iterator s_iterator;
+
+ UI_32 uiSessionId = 0;
+ if (hSession) {
+ uiSessionId = FrameworkunifiedGetSessionId(hSession);
+ }
+
+ // finding the service
+ s_iterator = pApp->services.find(pServiceName);
+ if (s_iterator != pApp->services.end()) {
+ SessionTable::iterator session_iterator;
+ session_iterator = (s_iterator->second).find(uiSessionId);
+ if (session_iterator != (s_iterator->second).end()) {
+ ServiceProtocolTable::iterator spt_iterator;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName);
+
+ spt_iterator = (session_iterator->second).find(iCmd);
+ if (spt_iterator != (session_iterator->second).end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Detaching command [0x%X] service [%s]",
+ pApp->cAppName, iCmd, pServiceName);
+ (session_iterator->second).erase(spt_iterator);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cmd NOT found [%d] service [%s]",
+ pApp->cAppName, iCmd, pServiceName);
+ }
+ }
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cannot find service [%s]", pApp->cAppName, pServiceName);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachCallbacksFromDispatcherWithFd
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbacksFromDispatcherWithFd(HANDLE hApp, const int *fdArray, UI_32 uiCommandCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != fdArray && 0 != uiCommandCount) {
+ // setup callbacks
+ for (UI_32 i = 0; i < uiCommandCount; ++i) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcherWithFd(hApp, fdArray[ i ]))) {
+ break;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %d, Invalid param ", eStatus);
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachCallbackFromDispatcherWithFd
+////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbackFromDispatcherWithFd(HANDLE hApp, int fd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && 0 < fd) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ FdTable::iterator f_iterator;
+ int efd; // FD for multi waiting
+ struct epoll_event ev; // Info struct to associate with multiwaiting FD
+
+ // finding the FD from FD table
+ f_iterator = pApp->fds.find(fd);
+ if (f_iterator != pApp->fds.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Detaching fd [0x%x]", pApp->cAppName, fd);
+ pApp->fds.erase(f_iterator);
+
+ // Remove the monitoring of FD from multi waiting FD
+ efd = pApp->efd;
+ if (0 < efd) {
+ ev.events = EPOLLIN;
+ ev.data.fd = fd;
+ if (-1 == epoll_ctl(efd, EPOLL_CTL_DEL, fd, &ev)) {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(DEL) Failed, status=%d, errno=%d", eStatus, errno);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Multi waiting FD is Invalid , status=%d, efd=%d", eStatus, efd);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cannot find fd [0x%x]", pApp->cAppName, fd);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error :: %d, Invalid param ", eStatus);
+ }
+
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachServiceFromDispatcher
+///////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachServiceFromDispatcher(HANDLE hApp, PCSTR pServiceName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ Services::iterator s_iterator;
+ EventServices::iterator es_iterator;
+
+ // finding the service
+ s_iterator = pApp->services.find(pServiceName);
+ if (s_iterator != pApp->services.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName);
+ pApp->services.erase(s_iterator);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning: Cannot find service [%s]", pApp->cAppName, pServiceName);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ // finding the service
+ es_iterator = pApp->eventservices.find(pServiceName);
+ if (es_iterator != pApp->eventservices.end()) {
+ eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s] in event map", pApp->cAppName, pServiceName);
+ pApp->eventservices.erase(es_iterator);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "%s : Warning : Cannot find service [%s] in event map",
+ pApp->cAppName, pServiceName);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////
+// Notification functions
+///////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachNotificationCallbacksToDispatcher
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithCallback(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pNtfyHandler,
+ UI_32 uiHandlerCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyHandler && (uiHandlerCount > 0)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ /// Deal with handling batch processing of subscriptions.
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPSubscribeToNotifications(hApp, pNtfyHandler, uiHandlerCount))) {
+ for (UI_32 i = 0; i < uiHandlerCount; ++i) {
+ // Notification names are character arrays of the MAX_STRING_SIZE_NOTIFICATION byte
+ // If there are no NULL characters in the array of Notification names, they will overrun during make_pair,
+ // so use a strlcpy that substitutes a trailing NULL character.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNtfyHandler[ i ].cNotification, MAX_STRING_SIZE_NOTIFICATION);
+ // service found
+ pApp->notifications.insert(std::make_pair(tmp_notification, pNtfyHandler[ i ].callBack));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]", pApp->cAppName,
+ pNtfyHandler[ i ].cNotification);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe to batch set of notifications",
+ pApp->cAppName, eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachNotificationCallbackToDispatcher
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithCallback(HANDLE hApp, PCSTR pNotification, CbFuncPtr fpOnCmd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification && NULL != fpOnCmd) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ NotificationTableRetStatus mRet;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPSubscribeToNotification(hApp, pNotification))) {
+ // Notification names are character arrays of the MAX_STRING_SIZE_NOTIFICATION byte
+ // If there are no NULL characters in the array of Notification names, they will overrun during make_pair,
+ // so use a strlcpy that substitutes a trailing NULL character.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
+
+ // service found
+ mRet = pApp->notifications.insert(std::make_pair(tmp_notification, fpOnCmd));
+ if (false == mRet.second) {
+ eStatus = eFrameworkunifiedStatusDuplicate;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:[%d] Unable to Subscribe to notification [%s]",
+ pApp->cAppName, eStatus, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s:attaching call-back for notification [%s]",
+ pApp->cAppName, pNotification);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:[%d] Unable to Subscribe to notification [%s]",
+ pApp->cAppName, eStatus, pNotification);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachNotificationCallbacksFromDispatcher
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithCallback(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pNtfyHandler,
+ UI_32 uiHandlerCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ NotificationTable::iterator n_iterator;
+ PCSTR pNotification = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNtfyHandler && (uiHandlerCount > 0)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPUnsubscribeFromNotifications(hApp, pNtfyHandler, uiHandlerCount))) {
+ for (UI_32 l_unCount = 0; l_unCount < uiHandlerCount; ++l_unCount) {
+ // When registering using FrameworkunifiedSubscribeNotificationWithCallback, etc., the Nortification names NULL the 64th byte.
+ // In response to this, the UnRegister uses a strlcpy that puts a NULL in the 64th byte.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNtfyHandler[ l_unCount ].cNotification, MAX_STRING_SIZE_NOTIFICATION);
+
+ n_iterator = pApp->notifications.find(tmp_notification);
+ if (n_iterator != pApp->notifications.end()) {
+ pApp->notifications.erase(n_iterator);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]", pApp->cAppName,
+ pNotification != 0 ? pNotification : NULL);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : detaching call-back for notification [%s]", pApp->cAppName,
+ pNotification != 0 ? pNotification : NULL);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notifications ", pApp->cAppName,
+ eFrameworkunifiedStatusOK);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachNotificationCallbackToDispatcher
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithCallback(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ NotificationTable::iterator n_iterator;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPUnsubscribeFromNotification(hApp, pNotification))) {
+ // \todo : error handling on all map function calls
+
+ // When registering using FrameworkunifiedSubscribeNotificationWithCallback, etc., the Nortification names NULL the 64th byte.
+ // In response to this, the UnRegister uses a strlcpy that puts a NULL in the 64th byte.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
+
+ n_iterator = pApp->notifications.find(tmp_notification);
+ if (n_iterator != pApp->notifications.end()) {
+ pApp->notifications.erase(n_iterator);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s:removed notification [%s]", pApp->cAppName, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:Cannot find notification [%s]", pApp->cAppName, pNotification);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s:Error:[%d] Unable to UnSubscribe from notification [%s]",
+ pApp->cAppName, eStatus, pNotification);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////
+// Defer Message functions
+///////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedGetDeferQueueCnt
+////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetDeferQueueCnt(HANDLE hApp) {
+ UI_32 l_uiCnt = 0;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ l_uiCnt = static_cast<UI_32>(pApp->deferedMsgQueue.size());
+ }
+
+ return l_uiCnt;
+}
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedIsDeferQueueEmpty
+////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsDeferQueueEmpty(HANDLE hApp) {
+ BOOL l_bIsQEmpty = TRUE;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ l_bIsQEmpty = static_cast<BOOL>(pApp->deferedMsgQueue.empty());
+ }
+
+ return l_bIsQEmpty;
+}
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedDeferMessage
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDeferMessage(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ DeferedMsgInfo defer(pApp->uiProtocolCmd, pApp->cMsgSrcName, pApp->uiMsgRcvBuffer);
+ pApp->deferedMsgQueue.push(defer);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedClearDeferMessages
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedClearDeferMessages(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // clear the pop flag!
+ pApp->fPopDeferedMsg = FALSE;
+
+ // remove all items from the queue!
+ while (!pApp->deferedMsgQueue.empty()) {
+ pApp->deferedMsgQueue.pop();
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////
+// Function : FrameworkunifiedRetrieveDeferMessage
+////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRetrieveDeferMessage(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ uint64_t data = 1;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->fPopDeferedMsg = pApp->deferedMsgQueue.empty() ? FALSE : TRUE;
+ if (pApp->fPopDeferedMsg) {
+ if (-1 == (write(pApp->defer_evfd, &data, sizeof(uint64_t)))) {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : write Failed, status=%d, errno=%d, defer_evfd=%d",
+ eStatus, errno, pApp->defer_evfd);
+ }
+ }
+
+
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedIsStateMachineApp
+/// Returns TRUE if it's a state machine application else FALSE.
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsStateMachineApp(HANDLE hApp) {
+ BOOL l_bIsStateMachine = FALSE;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (NULL != pApp->m_pFrameworkunifiedStateMachine) {
+ l_bIsStateMachine = TRUE;
+ }
+ }
+
+ return l_bIsStateMachine;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetXMLConfigHandle
+/// Returns the handle to config file handle
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetXMLConfigHandle(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "This function is not implemented!!!!");
+ return NULL;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedSetMandatoryServiceInfo(HANDLE hApp, PCSTR pNotification, UI_32 uiEventId) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ ServiceNotificationInfo objNotification = {};
+ if (strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
+ strlcpy(objNotification.sNotificationName, pNotification, sizeof(objNotification.sNotificationName));
+ objNotification.uiEventId = uiEventId;
+ pApp->servicenotificationlist.push_back(objNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ " Error : Aborting ... Exceeds Max Notification name size MAX_STRING_SIZE_NOTIFICATION : %d ",
+ MAX_STRING_SIZE_NOTIFICATION);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+BOOL FrameworkunifiedIsServiceAvailable(HANDLE hApp) {
+ BOOL l_bIsServiceAvailable = FALSE;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ // Publish notification
+ ServiceAvailability tServiceAvailability = {};
+
+ UI_32 l_uiLength = FrameworkunifiedGetMsgLength(hApp);
+
+ if (sizeof(tServiceAvailability) == l_uiLength) {
+ // Read the data from the message
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedGetMsgDataOfSize(hApp, &tServiceAvailability, sizeof(tServiceAvailability))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ } else {
+ // Check the Service availability
+ if (eFrameworkunifiedServiceAvailable == tServiceAvailability.eServiceAvailability) {
+ l_bIsServiceAvailable = TRUE;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error: Received message data size not matched :: %d", l_uiLength);
+ }
+ }
+
+ return l_bIsServiceAvailable;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedPublishServiceAvailability(HANDLE hApp, BOOL bIsAvailable) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (strlen(pApp->sServiceAvailabilityNotification)) {
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ pApp->bIsAvailable = bIsAvailable;
+ ServiceAvailability tServiceAvailability = {};
+ strlcpy(tServiceAvailability.cServiceName, FrameworkunifiedGetAppName(hApp), sizeof(tServiceAvailability.cServiceName));
+
+ if (bIsAvailable) {
+ tServiceAvailability.eServiceAvailability = eFrameworkunifiedServiceAvailable;
+ } else {
+ tServiceAvailability.eServiceAvailability = eFrameworkunifiedServiceNotAvailable;
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPPublishNotification(hApp, pApp->sServiceAvailabilityNotification,
+ &tServiceAvailability, sizeof(tServiceAvailability)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
+ "Failed to Publish notification: %s, status: %d", pApp->sServiceAvailabilityNotification, eStatus);
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE("Service Availability Status: %s, ERRORED %d", bIsAvailable ? "TRUE" : "FALSE", eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE("Service Availability Status: %s", bIsAvailable ? "TRUE" : "FALSE");
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__,
+ "Publish availability notfn:%s, status:%s", pApp->sServiceAvailabilityNotification,
+ bIsAvailable ? "TRUE" : "FALSE");
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+BOOL FrameworkunifiedGetSelfAvailability(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return pApp->bIsAvailable;
+ }
+
+ return FALSE;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedRegisterServiceAvailabilityNotification(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
+ strlcpy(pApp->sServiceAvailabilityNotification, pNotification, sizeof(pApp->sServiceAvailabilityNotification));
+
+ // Register Notifications
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPRegisterNotification(hApp, pNotification,
+ sizeof(ServiceAvailability), eFrameworkunifiedStateVar))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedNPRegisterNotifications %s Failed Status:0x%x ", pNotification, eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedNPRegisterNotifications %s success Status:0x%x ",
+ pNotification, eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ " Error : Aborting ... Exceeds Max Notification name size MAX_STRING_SIZE_NOTIFICATION : %d ",
+ MAX_STRING_SIZE_NOTIFICATION);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedUnRegisterServiceAvailabilityNotification(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // Register Notifications
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedNPUnRegisterNotification(hApp, pApp->sServiceAvailabilityNotification))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedNPUnRegisterNotifications %s Failed Status:0x%x ",
+ pApp->sServiceAvailabilityNotification != 0 ? pApp->sServiceAvailabilityNotification : NULL, eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedNPUnRegisterNotifications %s success Status:0x%x ",
+ pApp->sServiceAvailabilityNotification, eStatus);
+ }
+ memset(pApp->sServiceAvailabilityNotification, 0, MAX_SYS_INFO_SIZE);
+ pApp->bIsAvailable = FALSE;
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification
+/// To be used when client receives service availability notification to get the available
+/// service name.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification(HANDLE hApp, PSTR pServiceName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ // Publish notification
+ ServiceAvailability tServiceAvailability;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
+ UI_32 l_uiLength = FrameworkunifiedGetMsgLength(hApp);
+
+ if (sizeof(tServiceAvailability) == l_uiLength) {
+ // Read the data from the message
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tServiceAvailability, sizeof(tServiceAvailability)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ if (NULL == std::strncpy(pServiceName, tServiceAvailability.cServiceName, MAX_NAME_SIZE_APP)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " strcpy failed Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Error: Received message data size not matched :: %d", l_uiLength);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetCurrentUser
+//////////////////////////////////////////
+HANDLE FrameworkunifiedGetCurrentUser(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ const CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return pApp->hUser;
+ } else {
+ return NULL;
+ }
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedSetUser
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetUser(HANDLE hApp, HANDLE hUser) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pApp->hUser = hUser;
+ return eFrameworkunifiedStatusOK;
+ } else {
+ return eFrameworkunifiedStatusFail;
+ }
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedSetAppData
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetAppData(HANDLE hApp, PCSTR pKey, PVOID pData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ // Insert the data element
+ std::pair<AppData::iterator, bool> l_tRet = pApp->appdata.insert(std::make_pair(pKey, pData));
+ if (false == l_tRet.second) {
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetAppData
+//////////////////////////////////////////
+PVOID FrameworkunifiedGetAppData(HANDLE hApp, PCSTR pKey) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ AppData::iterator n_iterator = pApp->appdata.find(pKey);
+ if (n_iterator != pApp->appdata.end()) {
+ return n_iterator->second;
+ }
+ }
+ return NULL;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedRemoveAppData
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRemoveAppData(HANDLE hApp, PCSTR pKey) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ AppData::iterator n_iterator = pApp->appdata.find(pKey);
+ if (n_iterator != pApp->appdata.end()) {
+ pApp->appdata.erase(n_iterator);
+
+ eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ return eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp
new file mode 100644
index 00000000..cf079222
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_error.cpp
@@ -0,0 +1,130 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <native_service/frameworkunified_framework_error.hpp>
+#include <cstdio>
+#include <string>
+#include "frameworkunified_framework_error_internal.hpp"
+
+// using std::snprintf;
+typedef std::string TErrorDesc;
+typedef const TErrorDesc TCErrorDesc;
+
+namespace {
+
+PCSTR FrameworkunifiedStatusDesc(EFrameworkunifiedStatus status) {
+ switch (status) {
+ case eFrameworkunifiedStatusSessionLimitMaxedOut:
+ return "Session limit maxed out";
+ case eFrameworkunifiedStatusDbRecNotFound:
+ return "Db record not Found";
+ case eFrameworkunifiedStatusDbResultError:
+ return "Db result error";
+ case eFrameworkunifiedStatusDbExecuteFail:
+ return "Db execute failure";
+ case eFrameworkunifiedStatusSemCloseFail:
+ return "Semaphore close failure";
+ case eFrameworkunifiedStatusSemUnlockFail:
+ return "Semaphore unlock gailure";
+ case eFrameworkunifiedStatusSemLockFail:
+ return "Semaphore lock failure";
+ case eFrameworkunifiedStatusFail:
+ return "failure";
+ case eFrameworkunifiedStatusOK:
+ return "Status OK";
+ case eFrameworkunifiedStatusInvldBuf:
+ return "Invalid buffer";
+ case eFrameworkunifiedStatusInvldHandle:
+ return "Invalid handle";
+ case eFrameworkunifiedStatusInvldHndlType:
+ return "Invalid handle yype";
+ case eFrameworkunifiedStatusInvldQName:
+ return "Invalid queue name";
+ case eFrameworkunifiedStatusMsgQFull:
+ return "Message queue full";
+ case eFrameworkunifiedStatusInvldNotification:
+ return "Invliad notification";
+ case eFrameworkunifiedStatusInvldParam:
+ return "Invalid parameter";
+ case eFrameworkunifiedStatusInvldBufSize:
+ return "Invalid buffer size";
+ case eFrameworkunifiedStatusInvldID:
+ return "Invalid MemID";
+ case eFrameworkunifiedStatusCannotRelease:
+ return "Cannot release resource";
+ case eFrameworkunifiedStatusBadConnection:
+ return "Bad connection";
+ case eFrameworkunifiedStatusExit:
+ return "Exit";
+ case eFrameworkunifiedStatusNotImplemented:
+ return "Not implemented";
+ case eFrameworkunifiedStatusThreadBusy:
+ return "Thread busy";
+ case eFrameworkunifiedStatusThreadSelfJoin:
+ return "Attempted to self-join";
+ case eFrameworkunifiedStatusThreadInvalidVal:
+ return "Invalid value passed";
+ case eFrameworkunifiedStatusThreadNotExist:
+ return "Thread does not exist";
+ case eFrameworkunifiedStatusFault:
+ return "Fault";
+ case eFrameworkunifiedStatusServNotFound:
+ return "Service not found";
+ case eFrameworkunifiedStatusErrOther:
+ default:
+ return "Other error";
+ }
+}
+
+TCErrorDesc BuildFrameworkunifiedErrorDesc(EFrameworkunifiedStatus error, PCSTR errorMsg) {
+ CHAR buf[ MAX_QUEUE_MSG_SIZE ] = {};
+ snprintf(&buf[ 0 ],
+ MAX_QUEUE_MSG_SIZE,
+ "Framework Error: %s - %s",
+ FrameworkunifiedStatusDesc(error),
+ errorMsg != 0 ? errorMsg : NULL);
+ return TErrorDesc(&buf[ 0 ]);
+}
+
+TCErrorDesc BuildFrameworkunifiedSystemErrorDesc(EFrameworkunifiedSystemError error, PCSTR errorMsg) {
+ TErrorDesc l_cErrorMsg("Framework defined error desc: ");
+
+ switch (error) {
+ // Commented, because this is product specific error. Must handle by SystemServices only.
+ // case eFrameworkunifiedDSPHardwareReset : l_cErrorMsg.append("DSP HW RESET ERROR"); break;
+ default:
+ l_cErrorMsg.append("Other error");
+ break;
+ }
+
+ l_cErrorMsg.append(" :: Application provided error desc:");
+ l_cErrorMsg.append(errorMsg);
+ return l_cErrorMsg;
+}
+
+} // end namespace
+
+
+
+frameworkunified::framework::error::error::error(EFrameworkunifiedStatus error, PCSTR errorMsg)
+ : std::runtime_error(BuildFrameworkunifiedErrorDesc(error, errorMsg)),
+ m_error(error) {
+}
+
+frameworkunified::framework::error::CSystemError::CSystemError(EFrameworkunifiedSystemError error, PCSTR errorMsg)
+ : std::runtime_error(BuildFrameworkunifiedSystemErrorDesc(error, errorMsg)),
+ m_eSystemError(error) {
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp
new file mode 100644
index 00000000..29125271
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_logger.cpp
@@ -0,0 +1,575 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Framework wrapper over the logger interface APIs
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_rcs_logger_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/nslogutil_cmd_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <cstdio>
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+#include "frameworkunified_framework_utility.h"
+
+FrameworkunifiedProtocolCallbackHandler rcs_logging_callbacks[] = {
+ { NSRCS_SET_LOG_SETTINGS_REQ, NSRcsSetLogSettings },
+ { NSRCS_GET_LOG_SETTINGS_REQ, NSRcsGetLogSettings },
+ { NSRCS_SET_LOG_MASK_REQ, NSRcsSetLogMask },
+ { NSRCS_SET_LOG_OUT_OPT_REQ, NSRcsSetOutputLogOpts },
+ { NSRCS_SET_LOG_SEVERITY_REQ, NSRcsSetLogSeverity },
+};
+
+
+FrameworkunifiedProtocolCallbackHandler logging_callbacks[] = {
+ { SET_LOG_MASK, FrameworkunifiedSetLogMask },
+ { GET_LOG_MASK, FrameworkunifiedGetLogMask },
+ { SET_LOG_OUT_OPT, FrameworkunifiedSetOutputLogOpts },
+ { GET_LOG_OUT_OPT, FrameworkunifiedGetOutputLogOpts },
+ // { kDebugDumpRequest, FrameworkunifiedDebugDumpRequest }, /// < Added to help Debug Issues with in CCR Radio
+ // Callback attach with frameworkunifieddebug is moved to SystemServices
+ { SET_LOG_SEVERITY, FrameworkunifiedSetLogSeverity },
+ { GET_LOG_SEVERITY, FrameworkunifiedGetLogSeverity },
+};
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachLoggerCallbacksDispatcher(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, "nslogutil", logging_callbacks,
+ static_cast<UI_32>(_countof(logging_callbacks)));
+ // Callback attach with of kDebugDumpRequest with frameworkunifieddebug is moved to SystemServices. Keep only nslogutil.
+ eStatus = (eStatus != eFrameworkunifiedStatusOK) ? eStatus : FrameworkunifiedAttachCallbackToDispatcher(hApp, "nslogutil", kDebugDumpRequest,
+ FrameworkunifiedDebugDumpRequest);
+ eStatus = (eStatus != eFrameworkunifiedStatusOK) ? eStatus : FrameworkunifiedAttachCallbacksToDispatcher(hApp,
+ "SS_LoggerService",
+ logging_callbacks,
+ static_cast<UI_32>(_countof(logging_callbacks)));
+ eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_LOGGER_SETCONTROLMASK, FrameworkunifiedSetLogMask);
+
+ // This is optional only for remote control service. Therefore return value not checked
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbacksToDispatcher(hApp, FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE, rcs_logging_callbacks,
+ static_cast<UI_32>(_countof(rcs_logging_callbacks)))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_WAR, __FUNCTION__,
+ " FrameworkunifiedAttachCallbacksToDispatcher failed for rcs_logging_callbacks with FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE");
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CHANGELOGPARAMS chngLogOpts;
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&chngLogOpts, sizeof(chngLogOpts))) {
+ // Set the mask to the value that was just sent.
+ NsLogSetControlMask(chngLogOpts.uiZoneMask);
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Retervial of Data Failed");
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Incorrect message sz");
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ PCSTR pAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR pSrcName = FrameworkunifiedGetMsgSrc(hApp);
+
+ if (NULL != pAppName && NULL != pSrcName) {
+ HANDLE echoBack = McOpenSender(pSrcName);
+ if (NULL != echoBack) {
+ CHANGELOGPARAMS chng_log_params;
+
+ NsLogGetControlMask(chng_log_params.uiZoneMask);
+ if (eFrameworkunifiedStatusOK != (eStatus = McSend(echoBack, pAppName, GET_LOG_MASK_RESPONSE, sizeof(chng_log_params),
+ &chng_log_params))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_MASK_RESPONSE");
+ }
+
+ McClose(echoBack);
+ echoBack = NULL;
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CHANGELOGPARAMS chngLogOpts;
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&chngLogOpts, sizeof(chngLogOpts))) {
+ // Set the logging method to the value that was just received.
+ NsLogSetLogMethod(chngLogOpts.uiLogOptions);
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Retervial of Data Failed");
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Incorrect message sz");
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ }
+
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ PCSTR pAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR pSrcName = FrameworkunifiedGetMsgSrc(hApp);
+
+ if (NULL != pAppName && NULL != pSrcName) {
+ HANDLE echoBack = McOpenSender(pSrcName);
+
+ if (NULL != echoBack) {
+ CHANGELOGPARAMS chng_log_params;
+
+ chng_log_params.uiLogOptions = NsLogGetLogMethod();
+ if (eFrameworkunifiedStatusOK != (eStatus = McSend(echoBack, pAppName, GET_LOG_OUT_OPT_RESPONSE, sizeof(chng_log_params),
+ &chng_log_params))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_OUT_OPT_RESPONSE");
+ }
+
+ McClose(echoBack);
+ echoBack = NULL;
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSetLogSeverity
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CHANGELOGPARAMS l_tChngLogOpts = {};
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tChngLogOpts, sizeof(l_tChngLogOpts))) {
+ // Set the logging method to the value that was just received.
+ NsLogSetSeverity(l_tChngLogOpts.eSeverity);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of log severity data Failed");
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size CHANGELOGPARAMS");
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetLogSeverity
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
+
+ if (NULL != l_cAppName && NULL != l_cSrcName) {
+ HANDLE l_hEchoBack = McOpenSender(l_cSrcName);
+
+ if (NULL != l_hEchoBack) {
+ CHANGELOGPARAMS l_tChngLogParams = {};
+
+ l_tChngLogParams.eSeverity = NsLogGetSeverity();
+ if (eFrameworkunifiedStatusOK != (eStatus = McSend(l_hEchoBack, l_cAppName, GET_LOG_SEVERITY_RESPONSE,
+ sizeof(l_tChngLogParams), &l_tChngLogParams))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_OUT_OPT_RESPONSE");
+ }
+
+ McClose(l_hEchoBack);
+ l_hEchoBack = NULL;
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDebugDumpRequest: Calls an Applications FrameworkunifiedOnDebugDump method.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDebugDumpRequest(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "+");
+ eStatus = FrameworkunifiedOnDebugDumpInternal(hApp);
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "+");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus NSRcsSetLogSettings(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
+ TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
+ // Set the log mask
+ NsLogSetControlMask(l_tSetLogSettings.m_pui32ZoneMask);
+ // set the log output option
+ NsLogSetLogMethod(l_tSetLogSettings.m_ui8OutputLogOption);
+ // set the log severity
+ NsLogSetSeverity(l_tSetLogSettings.m_si32Severity);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings applied");
+
+ // send the response back with the current settings
+ TNSRCS_SetLogSettingsResp l_tSetLogSettingsResp = {};
+ PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ HANDLE l_hSendTo = McOpenSender(l_cSrcName);
+
+ if (NULL != l_hSendTo) {
+ l_tSetLogSettingsResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
+ l_tSetLogSettingsResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
+
+ NsLogGetControlMask(l_tSetLogSettingsResp.m_pui32ZoneMask);
+ l_tSetLogSettingsResp.m_ui8OutputLogOption = NsLogGetLogMethod();
+ l_tSetLogSettingsResp.m_si32Severity = NsLogGetSeverity();
+
+ if (eFrameworkunifiedStatusOK !=
+ McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_SETTINGS_RESP,
+ sizeof(TNSRCS_SetLogSettingsResp), &l_tSetLogSettingsResp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
+ "NSRCS_SET_LOG_SETTINGS_RESP to %s", l_cSrcName);
+ }
+ McClose(l_hSendTo);
+ l_hSendTo = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
+ FrameworkunifiedGetMsgLength(hApp),
+ static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus NSRcsGetLogSettings(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_GetLogSettingsReq)) {
+ TNSRCS_GetLogSettingsReq l_tGetLogSettings = {};
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tGetLogSettings, sizeof(l_tGetLogSettings))) {
+ // send the response back with the current settings
+ TNSRCS_GetLogSettingsResp l_tGetLogSettingsResp = {};
+ PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ HANDLE l_hSendTo = McOpenSender(l_cSrcName);
+
+ if (NULL != l_hSendTo) {
+ l_tGetLogSettingsResp.m_ui8ClientId = l_tGetLogSettings.m_ui8ClientId;
+ NsLogGetZoneTextList(l_tGetLogSettingsResp.m_cZoneList);
+ NsLogGetControlMask(l_tGetLogSettingsResp.m_pui32ZoneMask);
+ l_tGetLogSettingsResp.m_ui8OutputLogOption = NsLogGetLogMethod();
+ l_tGetLogSettingsResp.m_si32Severity = NsLogGetSeverity();
+
+ if (eFrameworkunifiedStatusOK !=
+ McSend(l_hSendTo, l_cAppName, NSRCS_GET_LOG_SETTINGS_RESP,
+ sizeof(TNSRCS_GetLogSettingsResp), &l_tGetLogSettingsResp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
+ "NSRCS_GET_LOG_SETTINGS_RESP to %s", l_cSrcName);
+ }
+ McClose(l_hSendTo);
+ l_hSendTo = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
+ FrameworkunifiedGetMsgLength(hApp),
+ static_cast<long int>(sizeof(TNSRCS_GetLogSettingsReq))); // NOLINT (readability/nolint)
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus NSRcsSetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
+ TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
+ // Set the log mask
+ NsLogSetControlMask(l_tSetLogSettings.m_pui32ZoneMask);
+
+ // 11 = number of chars in UI_32, 1 - nul char at the end
+ CHAR l_cOutMask[(ZONE_MASK_ARRAY_ELTS * 11) + 1] = {};
+ CHAR l_cMask[12] = {}; // 12 = 11+1: 11 = number of chars in UI_32, 1 - nul char at the end
+ for (UI_32 zoneIndex = 0; zoneIndex < ZONE_MASK_ARRAY_ELTS; zoneIndex++) {
+ std::strncpy(l_cMask, "", 11);
+ snprintf(l_cMask, sizeof(l_cMask), "0x%X,", l_tSetLogSettings.m_pui32ZoneMask[zoneIndex]);
+ std::strncat(l_cOutMask, l_cMask, (sizeof(l_cOutMask) - std::strlen(l_cMask) - 1));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings (zone mask) applied: %s", l_cOutMask);
+
+ // send the response back with the current settings
+ TNSRCS_SetLogMaskResp l_tSetLogMaskResp = {};
+ PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ HANDLE l_hSendTo = McOpenSender(l_cSrcName);
+
+ if (NULL != l_hSendTo) {
+ l_tSetLogMaskResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
+ l_tSetLogMaskResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
+
+ NsLogGetControlMask(l_tSetLogMaskResp.m_pui32ZoneMask);
+
+ if (eFrameworkunifiedStatusOK !=
+ McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_MASK_RESP,
+ sizeof(TNSRCS_SetLogMaskResp), &l_tSetLogMaskResp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
+ "NSRCS_SET_LOG_MASK_RESP to %s", l_cSrcName);
+ }
+ McClose(l_hSendTo);
+ l_hSendTo = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
+ FrameworkunifiedGetMsgLength(hApp),
+ static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus NSRcsSetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
+ TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
+ // set the log output option
+ NsLogSetLogMethod(l_tSetLogSettings.m_ui8OutputLogOption);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings(log output option) applied: %d.",
+ l_tSetLogSettings.m_ui8OutputLogOption);
+
+ // send the response back with the current settings
+ TNSRCS_SetLogOutOptResp l_tSetLogOutputOptResp = {};
+ PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ HANDLE l_hSendTo = McOpenSender(l_cSrcName);
+
+ if (NULL != l_hSendTo) {
+ l_tSetLogOutputOptResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
+ l_tSetLogOutputOptResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
+
+ l_tSetLogOutputOptResp.m_ui8OutputLogOption = NsLogGetLogMethod();
+
+ if (eFrameworkunifiedStatusOK !=
+ McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_OUT_OPT_RESP,
+ sizeof(TNSRCS_SetLogOutOptResp), &l_tSetLogOutputOptResp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
+ "NSRCS_SET_LOG_OUT_OPT_RESP to %s", l_cSrcName);
+ }
+ McClose(l_hSendTo);
+ l_hSendTo = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
+ FrameworkunifiedGetMsgLength(hApp),
+ static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus NSRcsSetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
+ TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
+ // set the log severity
+ NsLogSetSeverity(l_tSetLogSettings.m_si32Severity);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings(log severity) applied: %d.",
+ l_tSetLogSettings.m_si32Severity);
+
+ // send the response back with the current settings
+ TNSRCS_SetLogSeverityResp l_tSetLogSeverityResp = {};
+ PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
+ PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ HANDLE l_hSendTo = McOpenSender(l_cSrcName);
+
+ if (NULL != l_hSendTo) {
+ l_tSetLogSeverityResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
+ l_tSetLogSeverityResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
+
+ l_tSetLogSeverityResp.m_si32Severity = NsLogGetSeverity();
+
+ if (eFrameworkunifiedStatusOK !=
+ McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_SEVERITY_RESP,
+ sizeof(TNSRCS_SetLogSeverityResp), &l_tSetLogSeverityResp)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
+ "NSRCS_SET_LOG_SEVERITY_RESP to %s", l_cSrcName);
+ }
+ McClose(l_hSendTo);
+ l_hSendTo = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
+ FrameworkunifiedGetMsgLength(hApp),
+ static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp
new file mode 100644
index 00000000..ea953c98
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_message_center.cpp
@@ -0,0 +1,502 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <other_service/strlcpy.h>
+#include "frameworkunified_framework_core.h"
+#include "ns_mc_internal.h"
+
+using std::malloc;
+using std::free;
+using std::strcpy;
+using std::strlen;
+using std::memset;
+
+extern __thread HANDLE responseWaitQ;
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedMcOpenSender
+//////////////////////////////////////////
+HANDLE FrameworkunifiedMcOpenSender(HANDLE hApp, PCSTR pName) {
+ MsgQInfo *pMsgQ = NULL;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pName)) {
+ UI_32 l_ui32SrvNameLen = static_cast<UI_32>(strlen(pName));
+ /**
+ * @todo
+ * CHAR cSessionName[MAX_QUEUE_NAME_SIZE] cannot be determined to be 20 bytes including the termination NULL.
+ */
+ if ((l_ui32SrvNameLen < MAX_NAME_SIZE_APP) && (l_ui32SrvNameLen > 0)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ pMsgQ = reinterpret_cast<MsgQInfo *>(malloc(sizeof(MsgQInfo)));
+
+ if (NULL != pMsgQ) { // LCOV_EXCL_BR_LINE 5:malloc's error case.
+ errno = EOK; // flush previous errors, if any.
+ memset(pMsgQ, 0, sizeof(MsgQInfo));
+ if (NULL == (pMsgQ->hMsgQ = McOpenSender(pName))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Error::errno:%d, hApp:0x%p, %s failed to McOpenSender",
+ errno, hApp, pName);
+ free(pMsgQ);
+ pMsgQ = NULL;
+ } else {
+ pMsgQ->checkCode = MSGQ_CHECK_CODE;
+ pMsgQ->self = pthread_self();
+ strlcpy(pMsgQ->cSrcName, pApp->cAppName, sizeof(pMsgQ->cSrcName));
+ strlcpy(pMsgQ->cMsgQName, pName, sizeof(pMsgQ->cMsgQName));
+ pMsgQ->sessionId = 0;
+ }
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Invalid param. Name:%s, Following must be true: %d > len of passed name(%u) > 0.",
+ pName, MAX_NAME_SIZE_APP, l_ui32SrvNameLen);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Invalid param. hApp:0x%p, name:0x%p",
+ hApp, pName); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ return static_cast<HANDLE>(pMsgQ);
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedMcClose
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedMcClose(HANDLE hService) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidMsgQ(hService)) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
+ pMsgQ->checkCode = 0;
+ if (NULL != pMsgQ->hMsgQ) {
+ eStatus = McClose(pMsgQ->hMsgQ);
+ pMsgQ->hMsgQ = NULL;
+ }
+ free(pMsgQ);
+ pMsgQ = NULL;
+ hService = NULL; // This has no effect because hService is not passed as reference.
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedSendMsg
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendMsg(HANDLE hService, UI_32 iCmd, UI_32 length, PCVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidMsgQ(hService)) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
+
+ if ((NULL != pMsgQ->hMsgQ) && (0 != std::strlen(pMsgQ->cSrcName))) {
+ eStatus = McSendWithSession(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd, length, data, pMsgQ->sessionId);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ // check if McSendWithSession failed with error destination msg queue full
+ // log the information
+ if (eFrameworkunifiedStatusMsgQFull == eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error!! Message queue full of receiver '%s' while sending CmdId = 0x%X",
+ FrameworkunifiedGetSessionName(hService), iCmd);
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedSendPriorityMsg
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendPriorityMsg(HANDLE hService, UI_32 iCmd, UI_32 length, PCVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidMsgQ(hService)) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hService);
+ eStatus = McSendWithPriority(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd,
+ length, data, eFrameworkunifiedMsgPrioEmergency, pMsgQ->sessionId);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function: FrameworkunifiedSendSelf
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendSelf(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+ eStatus = McSend(pApp->hAppSndMsgQ, &pApp->cAppName[ 0 ], iCmd, length, data);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedInvokeSync
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedInvokeSync(HANDLE hService, UI_32 iCmd, UI_32 msgLenght, PCVOID msgData, UI_32 responseLength,
+ PVOID responseData, UI_32 *receivedLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidMsgQ(hService)) {
+ if (NULL != receivedLength) {
+ MsgQInfo *pMsgQ = static_cast<MsgQInfo *>(hService);
+
+ if (responseWaitQ == NULL) {
+ char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
+ InvokerName invokerName;
+ // LCOV_EXCL_BR_START 11:except branch
+ McCreateInvokerName(pMsgQ->cSrcName, pMsgQ->sessionId, mc_invoker_name, sizeof(mc_invoker_name));
+ // LCOV_EXCL_BR_STOP
+ invokerName = mc_invoker_name;
+
+ responseWaitQ = McOpenSyncReceiver(invokerName.c_str());
+ if (NULL == responseWaitQ) {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ if (eStatus == eFrameworkunifiedStatusOK) {
+ eStatus = McInvokeSync(pMsgQ->hMsgQ, pMsgQ->cSrcName, iCmd, msgLenght, msgData, pMsgQ->sessionId,
+ responseWaitQ, responseLength, responseData, receivedLength);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : frameworkunifiedSendSyncResponse
+//////////////////////////////////////////
+EFrameworkunifiedStatus frameworkunifiedSendSyncResponse(HANDLE hApp, UI_32 iCmd, UI_32 seq_id, EFrameworkunifiedStatus retValue, UI_32 length, PCVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ HANDLE responseSendQ;
+
+ char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
+ InvokerName invokerName;
+ PVOID rcv_buf = static_cast<PVOID>(pApp->uiMsgRcvBuffer);
+ McCreateInvokerName(McGetMsgSrc(rcv_buf), mcGetMsgSsessionId(rcv_buf), mc_invoker_name, sizeof(mc_invoker_name));
+ invokerName = mc_invoker_name;
+
+ InvokeResponseQTable::iterator s_iterator = pApp->invokeResQTable.find(invokerName);
+ if (s_iterator != pApp->invokeResQTable.end()) {
+ responseSendQ = s_iterator->second;
+ } else {
+ responseSendQ = McOpenSyncSender(invokerName.c_str()); // LCOV_EXCL_BR_LINE 11:except branch
+ /*
+ * @todo
+ * FrameworkunifiedSendSyncResponse() uses McOpenSyncSender() to create a synchronous communication response queue handle,
+ * but there is no process to release the queue handle after the response.
+ */
+ if (NULL == responseSendQ) {
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ pApp->invokeResQTable[invokerName] = responseSendQ; // LCOV_EXCL_BR_LINE 11:except branch
+ }
+ }
+
+ if (eStatus == eFrameworkunifiedStatusOK) {
+ eStatus = McSendSyncResponse(responseSendQ, pApp->cAppName, iCmd, seq_id, retValue, length, data);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedDispatchProcess
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetSyncResponseData(HANDLE hApp, PVOID data, UI_32 size) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ /*
+ * @todo
+ * When the response data is 0 bytes, it can be transmitted as SYNC data.
+ */
+ if (frameworkunifiedCheckValidAppHandle(hApp) && data != NULL) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ try {
+ pApp->responsedata.set(data, size); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+ catch(std::bad_alloc) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "bad_alloc");
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetMsgLength
+//////////////////////////////////////////
+UI_32 FrameworkunifiedGetMsgLength(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return McGetLength(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
+ }
+ return 0;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetMsgProtocol
+//////////////////////////////////////////
+UI_32 FrameworkunifiedGetMsgProtocol(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return static_cast<UI_32>(pApp->uiProtocolCmd);
+ }
+ return 0;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetMsgDataOfSize
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetMsgDataOfSize(HANDLE hApp, PVOID pData, UI_32 uiSize, ESMRetrieveTypes eRetrieveMethod) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ /*
+ * @todo
+ * The behavior is the same as when "eSMRRetain" is set without getting an error when the ESMRetrieveTypes is not appropriate.
+ */
+ if (eSMRRelease == eRetrieveMethod) {
+ eStatus = McGetDataOfSize(static_cast<PVOID>(pApp->uiMsgRcvBuffer), pData, uiSize);
+ } else {
+ eStatus = McGetDataOfSizeWithSMRetain(static_cast<PVOID>(pApp->uiMsgRcvBuffer), pData, uiSize);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetDataPointer
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetDataPointer(HANDLE hApp, void **datap) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (NULL == datap) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ void *dt;
+ if ((dt = McGetDataPointer(reinterpret_cast<PVOID>(pApp->uiMsgRcvBuffer))) == NULL) {
+ return eFrameworkunifiedStatusInvldBufSize;
+ }
+
+ *datap = dt;
+ return eFrameworkunifiedStatusOK;
+ }
+ return eFrameworkunifiedStatusInvldHandle;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetMsgSrc
+//////////////////////////////////////////
+PCSTR FrameworkunifiedGetMsgSrc(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return (reinterpret_cast<PCSTR>(pApp->cMsgSrcName));
+ }
+ return NULL;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetMsgNotification
+//////////////////////////////////////////
+PCSTR FrameworkunifiedGetMsgNotification(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return (reinterpret_cast<PCSTR>(pApp->cSystemInfo));
+ }
+ return NULL;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedClearMsgData
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedClearMsgData(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ eStatus = McClearData(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetDataUSID
+//////////////////////////////////////////
+TMemID FrameworkunifiedGetDataUSID(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return McGetDataUSID(static_cast<PVOID>(pApp->uiMsgRcvBuffer));
+ }
+ return BAD_MEM_ID;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedForwardMessage
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedForwardMessage(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && hChildQ) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+
+ eStatus = McForward(hChildQ, &pApp->cAppName[ 0 ], iCmd, FrameworkunifiedGetDataUSID(hApp));
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedGetSystemInfo
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetSystemInfo(HANDLE hApp, PVOID pSystemInfo) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldBuf;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pSystemInfo != NULL) { // LCOV_EXCL_BR_LINE 11:except branch
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ eStatus = McGetSysInfoData(pApp->uiMsgRcvBuffer, pSystemInfo);
+// memcpy(pSystemInfo, pApp->cSystemInfo, _countof(pApp->cSystemInfo));
+// eStatus = eFrameworkunifiedStatusOK;
+ }
+ return eStatus;
+}
+
+
+//////////////////////////////////////////
+// Function : frameworkunifiedGetIsTypeOfSync
+//////////////////////////////////////////
+BOOL frameworkunifiedGetIsTypeOfSync(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return mcGetIsTypeOfSync(pApp->uiMsgRcvBuffer);
+ }
+ return FALSE;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetLastNotification
+/// Returns the last notification string that was received.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return pSourceName
+/// PCSTR - the last notification name that has been received.
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetLastNotification(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return static_cast<PCSTR>(pApp->cSystemInfo);
+ }
+
+ return NULL;
+}
+
+
+EFrameworkunifiedStatus FrameworkunifiedSendResponse(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ HANDLE hSession = FrameworkunifiedGetCurrentSessionHandle(hApp);
+
+ if (hSession) {
+ // send response
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, iCmd, length, data))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
+ "Response send Failed Status:0x%x ", eStatus);
+ // LCOV_EXCL_BR_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Response sent ");
+ }
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedSendRequest(HANDLE hApp, PCSTR pServerName, UI_32 uiSessionId, UI_32 iCmd,
+ UI_32 length, PCVOID data) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ HANDLE hSession = FrameworkunifiedGetSessionHandle(hApp, pServerName, uiSessionId);
+ if (hSession) {
+ // send response
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, iCmd, length, data))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__,
+ "Response send Failed Status:0x%x ", eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Response sent ");
+ }
+ }
+ }
+ return eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp
new file mode 100644
index 00000000..063e3572
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_npservice.cpp
@@ -0,0 +1,867 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Framework wrapper over the NPService interface APIs
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <other_service/strlcpy.h>
+
+#include "frameworkunified_framework_core.h"
+#include "ns_np_service_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
+ const EFrameworkunifiedNotificationType persType) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ if (strlen(pNotification) && strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ NotificationInfo notifInfo = {};
+ strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
+ notifInfo.persType = persType;
+ notifInfo.maxLength = max_length;
+
+ eStatus = NPRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, &notifInfo);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterImmediatePersistNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
+ const UI_32 delay) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
+ if (strlen(pNotification) && strlen(pNotification) <= MAX_STRING_SIZE_NOTIFICATION) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ ImmediateNotificationInfo notifInfo = {};
+ strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
+ notifInfo.persType = eFrameworkunifiedImmediatePersistedStateVar;
+ notifInfo.maxLength = max_length;
+ notifInfo.delay = delay;
+
+ eStatus = NPRegisterImmediateNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, &notifInfo);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPPersistentSync
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPPersistentSync(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPPersistentSync(pMqInfo->cSrcName, pMqInfo->hMsgQ, pMqInfo->sessionId, pApp->cAppName);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eStatus;
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterNotifications
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ NotificationInfo *pNotificationList =
+ reinterpret_cast<NotificationInfo *>(malloc(sizeof(NotificationInfo) * uiListLength));
+
+ for (UI_32 i = 0; i < uiListLength; ++i) {
+ strlcpy(pNotificationList[i].notificationName, pList[i].cNotification,
+ sizeof(pNotificationList[i].notificationName));
+ pNotificationList[i].maxLength = pList[i].uiLengthData;
+ pNotificationList[i].persType = pList[i].persType;
+ }
+ eStatus = NPRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pNotificationList);
+
+ free(pNotificationList);
+ pNotificationList = NULL; // mb20110110 Fixed per comment 295
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPUnRegisterNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotification(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification && strlen(pNotification)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ NotificationInfo notifInfo = {};
+ strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
+
+ eStatus = NPUnRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, &notifInfo);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPUnRegisterNotifications
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ NotificationInfo *pNotificationList =
+ reinterpret_cast<NotificationInfo *>(malloc(sizeof(NotificationInfo) * uiListLength));
+
+ for (UI_32 i = 0; i < uiListLength; ++i) {
+ strlcpy(pNotificationList[i].notificationName, pList[i].cNotification,
+ sizeof(pNotificationList[i].notificationName));
+ pNotificationList[i].maxLength = pList[i].uiLengthData;
+ pNotificationList[i].persType = pList[i].persType;
+ }
+ eStatus = NPUnRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pNotificationList);
+
+ free(pNotificationList);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPPublishNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPPublishNotification(HANDLE hApp, PCSTR pNotification,
+ PCVOID pData, UI_32 iLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if ((NULL != pMqInfo->hMsgQ) && (0 != std::strlen(pApp->cAppName))) {
+ eStatus = NPPublishNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification, pData, iLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSubscribeToNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotification(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPSubscribeToNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
+ UI_32 uiListLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ SubscribeInfo *pSubscribeList =
+ reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
+
+ for (UI_32 i = 0; i < uiListLength; ++i) {
+ strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
+ sizeof(pSubscribeList[i].notificationName));
+ }
+ eStatus = NPSubscribeToNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
+
+ free(pSubscribeList);
+ pSubscribeList = NULL; // mb20110110 Fixed per comment 307
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPUnSubscribeNotifications
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
+ UI_32 uiListLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ SubscribeInfo *pSubscribeList =
+ reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
+
+ for (UI_32 i = 0; i < uiListLength; ++i) {
+ strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification, MAX_STRING_SIZE_NOTIFICATION);
+ }
+ eStatus = NPUnsubscribeFromNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
+
+ free(pSubscribeList);
+ pSubscribeList = NULL; // mb20110110 Fixed per comment 307
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPUnsubscribeFromNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotification(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPUnsubscribeFromNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReadPersistedData
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReadPersistedData(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPReadPersistedData(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSavePersistentData
+////////////////////////////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus FrameworkunifiedNPSavePersistentData(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED();
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPSavePersistentData(pMqInfo->hMsgQ, pApp->cAppName);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterPersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFile(HANDLE hApp, PCSTR pTag, BOOL bIsUserFile) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ eStatus = NPRegisterPersistentFile(pMqInfo->hMsgQ, pApp->cAppName, pTag, bIsUserFile);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPLoadPersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFile(HANDLE hApp, PCSTR pDstFilePath, PCSTR pTag, HANDLE hUser) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pDstFilePath && pTag) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ eStatus = NPLoadPersistentFile(pMqInfo->hMsgQ, pApp->cAppName, pDstFilePath, pTag, hUser);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReleasePersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, BOOL bIsPersist, PCSTR pTag,
+ PCSTR pFullFilePath, HANDLE hUser) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFilePath) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ EFrameworkunifiedReleaseType eReleaseType = (bIsPersist == FALSE) ? eFrameworkunifiedNotOnRelease : eFrameworkunifiedPersistOnShutdown;
+ eStatus = NPReleasePersistentFile(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
+ pFullFilePath, hUser);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReleasePersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
+ PCSTR pFullFilePath, HANDLE hUser) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFilePath) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ eStatus = NPReleasePersistentFile(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
+ pFullFilePath, hUser);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPRegisterPersistentFolder
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFolder(HANDLE hApp, PCSTR pTag, BOOL bIsUserFolder) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ eStatus = NPRegisterPersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, pTag, bIsUserFolder);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPLoadPersistentFolder
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFolder(HANDLE hApp, PCSTR pDstFolderPath, PCSTR pTag, HANDLE hUser) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pDstFolderPath) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ eStatus = NPLoadPersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, pDstFolderPath, pTag, hUser);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReleasePersistentFolder
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, BOOL bIsPersist, PCSTR pTag, PCSTR pFullFolderPath,
+ HANDLE hUser) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFolderPath) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ EFrameworkunifiedReleaseType eReleaseType = (bIsPersist == FALSE) ? eFrameworkunifiedNotOnRelease : eFrameworkunifiedPersistOnShutdown;
+ eStatus = NPReleasePersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
+ pFullFolderPath, hUser);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReleasePersistentFolder
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
+ PCSTR pFullFolderPath,
+ HANDLE hUser) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFolderPath) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ eStatus = NPReleasePersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
+ pFullFolderPath, hUser);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+// 20110429_brp
+// defined for backward compatibility; will be removed once the persistence feature is finalized
+EFrameworkunifiedStatus FrameworkunifiedRegisterPersistentStorage(HANDLE hApp, PCSTR pFullFilePath) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pFullFilePath) {
+ eStatus = FrameworkunifiedNPRegisterPersistentFile(hApp, pFullFilePath);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+EFrameworkunifiedStatus FrameworkunifiedReleaseFileToPersistentStorage(HANDLE hApp, PCSTR pFullFilePath, BOOL persist) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pFullFilePath) {
+ eStatus = FrameworkunifiedNPReleasePersistentFile(hApp, persist, pFullFilePath, pFullFilePath);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMRegisterNotificationsEvents
+/// API to send message to Notification Service to register a notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationsList *pList,
+ UI_32 uiListLength) {
+ return FrameworkunifiedNPRegisterNotifications(hApp, pList, uiListLength);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMRegisterNotificatsionEvent
+/// API to send message to Notification Service to register a notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificatsionEvent(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
+ const EFrameworkunifiedNotificationType persType) {
+ return FrameworkunifiedNPRegisterNotification(hApp, pNotification, max_length, persType);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnRegisterNotificationEvent
+/// API to send message to Notification Service to remove a notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnRegisterNotificationEvent(HANDLE hApp, PCSTR pNotification) {
+ return FrameworkunifiedNPUnRegisterNotification(hApp, pNotification);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMSubscribeToNotificationsEvents
+/// API to send message to Notification Service to add multiple subscriptions list for
+/// that notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
+ UI_32 uiListLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ SubscribeInfo *pSubscribeList =
+ reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
+
+ for (UI_32 i = 0; i < uiListLength; ++i) {
+ strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
+ sizeof(pSubscribeList[i].notificationName));
+ }
+ eStatus = NPSubscribeToNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
+
+ free(pSubscribeList);
+ pSubscribeList = NULL; // mb20110110 Fixed per comment 307
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMSubscribeToNotificationEvent
+/// API to send message to Notification Service to add to subscription list for
+/// that notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationEvent(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPSubscribeToNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(HANDLE hApp, PCSTR pNotification) {
+ return FrameworkunifiedNPUnsubscribeFromNotification(hApp, pNotification);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
+ UI_32 uiListLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ SubscribeInfo *pSubscribeList =
+ reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
+
+ for (UI_32 i = 0; i < uiListLength; ++i) {
+ strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
+ sizeof(pSubscribeList[i].notificationName));
+ }
+ eStatus = NPUnsubscribeFromNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
+
+ free(pSubscribeList);
+ pSubscribeList = NULL; // mb20110110 Fixed per comment 307
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetPersonality
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetPersonality(HANDLE hApp, PCSTR pUserName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pUserName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPSetPersonality(pMqInfo->hMsgQ, pApp->cAppName, pUserName);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPChangePersonality
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPChangePersonality(HANDLE hApp, PCSTR pUserName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pUserName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPChangePersonality(pMqInfo->hMsgQ, pApp->cAppName, pUserName);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendStopToNSNPP
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendStopToNSNPP(HANDLE hApp, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = SendStopToNSNPP(pMqInfo->hMsgQ, pApp->cAppName, eShutdownType, uiStopMsgData);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPGetReadyStatusOfNPP
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPGetReadyStatusOfNPP(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ eStatus = NPGetReadyStatusOfNPP(pMqInfo->hMsgQ, pApp->cAppName);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPClearPersistedData
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPClearPersistedData(HANDLE hApp, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ eStatus = NPClearPersistedData(pMqInfo->hMsgQ, pApp->cAppName, eFrameworkunifiedClearPersistenceScope);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetPersistNotfnDefaultValue
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetPersistNotfnDefaultValue(HANDLE hApp, PCSTR pNotification, PVOID pData,
+ const UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pNotification)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ eStatus = NPSetPersistNotfnDefaultValue(pMqInfo->hMsgQ,
+ pApp->cAppName,
+ pNotification,
+ pData,
+ uiLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetPersistentNotfnType
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetPersistentNotfnType(HANDLE hApp, PCSTR pNotification, EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pNotification)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+ if (NULL != pMqInfo) {
+ eStatus = NPSetPersistentNotfnType(pMqInfo->hMsgQ,
+ pApp->cAppName,
+ pNotification,
+ ePersistCategory);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetFilePersistentType
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetFilePersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pTag)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ eStatus = NPSetFilePersistentType(pMqInfo->hMsgQ,
+ pApp->cAppName,
+ pTag,
+ ePersistCategory);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetFolderPersistentType
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetFolderPersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pTag)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
+
+ if (NULL != pMqInfo) {
+ eStatus = NPSetFolderPersistentType(pMqInfo->hMsgQ,
+ pApp->cAppName,
+ pTag,
+ ePersistCategory);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp
new file mode 100644
index 00000000..7c9935be
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_session.cpp
@@ -0,0 +1,1357 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Framework service protocol session APIs implementation
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/ns_logger_if.h>
+#include <other_service/strlcpy.h>
+#include <utility>
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedOpenService
+//////////////////////////////////////////////////////
+HANDLE FrameworkunifiedOpenService(HANDLE hApp, PCSTR pServiceName) {
+ HANDLE hService = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pServiceName) {
+ if (NULL == (hService = FrameworkunifiedMcOpenSender(hApp, pServiceName))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error::hApp:0x%p, %s failed to FrameworkunifiedMcOpenSender", hApp, pServiceName);
+ // LCOV_EXCL_BR_STOP
+ } else {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ frameworkunifiedAddConnectMonitor(hApp, pServiceName, pApp->cAppName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Invalid param. hApp:0x%p, name:0x%p",
+ hApp, pServiceName);
+ }
+
+ return static_cast<HANDLE>(hService);
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedCloseService
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseService(HANDLE hApp, HANDLE hService) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hService)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ MsgQInfo *pMsgQ = static_cast<MsgQInfo *>(hService);
+
+ if (eFrameworkunifiedStatusOK != frameworkunifiedDelConnectMonitor(hApp, pMsgQ->cMsgQName, pApp->cAppName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : frameworkunifiedDelConnectMonitor(%s, %s) fail",
+ pMsgQ->cMsgQName != 0 ? pMsgQ->cMsgQName : NULL, pApp->cAppName != 0 ? pApp->cAppName : NULL);
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(hService))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : %s Failed to FrameworkunifiedMcClose",
+ pApp->cAppName != 0 ? pApp->cAppName : NULL);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+HANDLE FrameworkunifiedGenerateSessionHandle(HANDLE hApp, PCSTR pServiceName) {
+ HANDLE l_pSession = NULL;
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pServiceName)) {
+ l_pSession = FrameworkunifiedMcOpenSender(hApp, pServiceName);
+
+ if (NULL != l_pSession) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(l_pSession);
+ pMsgQ->sessionId = FrameworkunifiedGenerateNewSessionId();
+ }
+ }
+
+ return l_pSession;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedOpenSessionWithData
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSessionWithData(HANDLE hService, PVOID pData, UI_32 length) {
+ return FrameworkunifiedSendMsg(hService, PROTOCOL_OPEN_SESSION_REQ, length, pData);
+}
+
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedOpenSession
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSession(HANDLE hService) {
+ UI_32 l_uiDummy = 0;
+ return FrameworkunifiedSendMsg(hService, PROTOCOL_OPEN_SESSION_REQ, 0, &l_uiDummy);
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedOpenSessionWithDataSync
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSessionWithDataSync(HANDLE hService, PVOID pData, UI_32 length, OpenSessionAck *ack) {
+ UI_32 rcvLen;
+ return FrameworkunifiedInvokeSync(hService, PROTOCOL_OPEN_SESSION_REQ_SYNC, length, pData, sizeof(OpenSessionAck), ack, &rcvLen);
+}
+
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedOpenSessionSync
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSessionSync(HANDLE hService, OpenSessionAck *ack) {
+ UI_32 l_uiDummy = 0;
+ UI_32 rcvLen;
+ return FrameworkunifiedInvokeSync(hService, PROTOCOL_OPEN_SESSION_REQ_SYNC, 0, &l_uiDummy, sizeof(OpenSessionAck), ack, &rcvLen);
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedGetSessionHandle
+//////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetOpenSessionHandle(HANDLE hApp) {
+ HANDLE hSession = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ OpenSessionAck tAck;
+
+ if (sizeof(OpenSessionAck) == FrameworkunifiedGetMsgLength(hApp)) {
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedGetMsgDataOfSize(hApp, &tAck, sizeof(tAck))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedGetMsgDataOfSize");
+ } else {
+ if (eFrameworkunifiedStatusOK == tAck.eStatus) {
+ hSession = FrameworkunifiedMcOpenSender(hApp, tAck.cSessionName);
+ if (NULL != hSession) {
+ (reinterpret_cast<MsgQInfo *>(hSession))->sessionId = tAck.sessionId;
+ }
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedGetOpenSessionHandle");
+ }
+ }
+
+ return hSession;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedGetOpenSessionSyncHandle
+//////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetOpenSessionSyncHandle(HANDLE hApp, OpenSessionAck *tAck) {
+ HANDLE hSession = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && (NULL != tAck)) {
+ if (eFrameworkunifiedStatusOK == tAck->eStatus) {
+ hSession = FrameworkunifiedMcOpenSender(hApp, tAck->cSessionName);
+ if (NULL != hSession) {
+ (reinterpret_cast<MsgQInfo *>(hSession))->sessionId = tAck->sessionId;
+ }
+ }
+ }
+
+ return hSession;
+}
+
+//////////////////////////////////////////////////////
+/// frameworkunifiedCloseSessionInner
+//////////////////////////////////////////////////////
+static EFrameworkunifiedStatus frameworkunifiedCloseSessionInner(HANDLE hService, HANDLE hSession, CloseSessionAck *ack) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
+ CloseSessionReq tClose = {};
+
+ if (frameworkunifiedCheckValidMsgQ(hService) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ tClose.sessionId = (reinterpret_cast<MsgQInfo *>(hSession))->sessionId;
+ strlcpy(tClose.cSessionName, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, sizeof(tClose.cSessionName));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Info : sessionid %d", tClose.sessionId);
+
+ if (NULL != ack) {
+ UI_32 rcvLen;
+ eStatus = FrameworkunifiedInvokeSync(hService, PROTOCOL_CLOSE_SESSION_REQ_SYNC, sizeof(tClose), (PVOID)&tClose,
+ sizeof(CloseSessionAck), ack, &rcvLen);
+ if (rcvLen != sizeof(CloseSessionAck)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : Invalid receive length %d", rcvLen);
+ }
+ } else {
+ eStatus = FrameworkunifiedSendMsg(hService, PROTOCOL_CLOSE_SESSION_REQ, sizeof(tClose), (PVOID)&tClose);
+ }
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ eStatus = FrameworkunifiedMcClose(hSession);
+ hSession = NULL;
+ }
+ }
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedCloseSession
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseSession(HANDLE hService, HANDLE hSession) {
+ return frameworkunifiedCloseSessionInner(hService, hSession, NULL);
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedCloseSessionSync
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseSessionSync(HANDLE hService, HANDLE hSession, CloseSessionAck *ack) {
+ if (NULL == ack) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ return frameworkunifiedCloseSessionInner(hService, hSession, ack);
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedGetSessionId -> On Client side
+//////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetSessionId(HANDLE hSession) {
+ if (frameworkunifiedCheckValidMsgQ(hSession)) {
+ return ((reinterpret_cast<MsgQInfo *>(hSession))->sessionId);
+ } else {
+ return MAX_SESSION_ID_VAL;
+ }
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedGetSessionId -> On Client side
+//////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetMsgSessionId(HANDLE hApp) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ return pApp->uiSessionId;
+ }
+ return MAX_SESSION_ID_VAL;
+}
+
+
+//////////////////////////////////////////////////////
+/// GenerateNewSessionId -> On Server side
+//////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGenerateNewSessionId() {
+ static UI_16 lastSessionId = 0;
+ lastSessionId++;
+ UI_32 sessionId = (lastSessionId % MAX_SESSION_ID_VAL);
+ return sessionId;
+}
+
+
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedRegisterEvents
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRegisterEvents(HANDLE hSession, PVOID puiEventsArray, UI_32 uiListSize) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (hSession) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS,
+ static_cast<UI_32>(uiListSize * sizeof(uiListSize)), puiEventsArray);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedRegisterEvent
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRegisterEvent(HANDLE hSession, UI_32 uiEvent) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (hSession) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(uiEvent), (PVOID)&uiEvent);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedUnRegisterEvents
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnRegisterEvents(HANDLE hSession, PVOID puiEventsArray, UI_32 uiListSize) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (hSession) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS,
+ static_cast<UI_32>(uiListSize * sizeof(uiListSize)), puiEventsArray);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedUnRegisterEvent
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnRegisterEvent(HANDLE hSession, UI_32 uiEvent) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (hSession) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEvent), (PVOID)&uiEvent);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedDefineStateEvents
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDefineStateEvents(HANDLE hApp, PVOID puiEvents, UI_32 uiListSize) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && puiEvents) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ EventData *l_pEventData = NULL;
+
+ UI_32 l_uiEventId;
+ PUI_32 l_pEventList = (PUI_32)puiEvents;
+
+ for (UI_32 uiCount = 0; uiCount < uiListSize; uiCount++) {
+ l_uiEventId = l_pEventList[uiCount];
+
+ // checks if event exists in state event list
+ if (pApp->publicstateeventtable.end() == pApp->publicstateeventtable.find(l_uiEventId)) {
+ // insert the event in state event list, data is passed as NULL as there is no data published
+ pApp->publicstateeventtable.insert(std::make_pair(l_uiEventId, l_pEventData));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d already registered as state event ", l_uiEventId);
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedBroadcastEvent
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedBroadcastEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ eStatus = FrameworkunifiedPublishEvent(hApp, uiEventId, NULL, pData, uiLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedPublishEvent
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishEvent(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, PCVOID pData, UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus eRetStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ EventTable::iterator e_iterator;
+ ServiceSessionIdListTable::iterator ssidl_iterator;
+
+ PCSTR l_cServiceName = "";
+
+ // set the data, if event is a state events
+ UpdatePublicStateEventData(hApp, uiEventId, pData, uiLength);
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // check if event is registered by client/s
+ e_iterator = pApp->eventtable.find(uiEventId);
+
+ if (pApp->eventtable.end() != e_iterator) {
+ // for loop for event table
+ for (ssidl_iterator = e_iterator->second.begin();
+ ssidl_iterator != e_iterator->second.end();
+ ssidl_iterator++) {
+ l_cServiceName = ssidl_iterator->first.c_str();
+
+ if (NULL != pClientName) {
+ // send message to only specified client
+ if (!std::strcmp(pClientName, l_cServiceName)) {
+ eStatus = SendEventMessage(hApp, ssidl_iterator->second, uiEventId, l_cServiceName, pData, uiLength);
+ break;
+ }
+ } else {
+ // send message to all registered client
+ eRetStatus = SendEventMessage(hApp, ssidl_iterator->second, uiEventId, l_cServiceName, pData, uiLength);
+ if (eFrameworkunifiedStatusOK != eRetStatus) {
+ eStatus = eRetStatus;
+ }
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "No subscriber has subscribed for event %d.", uiEventId);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// UpdatePublicStateEventData
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus UpdatePublicStateEventData(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if ((NULL == pData) && (uiLength > 0)) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ PublicStateEventTable::iterator se_iterator;
+ EventData *l_pEventData = NULL;
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // set the data, if event is a state events
+ se_iterator = pApp->publicstateeventtable.find(uiEventId);
+ if (pApp->publicstateeventtable.end() != se_iterator) {
+ l_pEventData = se_iterator->second;
+ if (NULL != l_pEventData) {
+ if (NULL != l_pEventData->pData) {
+ delete[](static_cast<PCHAR>(l_pEventData->pData));
+ (se_iterator->second)->pData = NULL;
+ }
+
+ delete l_pEventData;
+ se_iterator->second = NULL;
+ }
+
+ l_pEventData = new(std::nothrow) EventData();
+ /*
+ * @todo
+ * UpdatePublicStateEventData() in the pApp->publicstateeventtable
+ * The data area is being created, but there is no process to release.
+ */
+ if (NULL != l_pEventData) {
+ l_pEventData->uiLength = uiLength;
+ // LCOV_EXCL_BR_START 6:pData is checked in the top of this function, it should be not NULL here.
+ if (NULL == pData) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 6:pData is checked in the top of this function, it should be not NULL here.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_pEventData->pData = NULL;
+ // LCOV_EXCL_STOP
+ } else {
+ l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
+ if (NULL != l_pEventData->pData) {
+ std::memset(l_pEventData->pData, 0, uiLength);
+ std::memcpy(l_pEventData->pData, pData, uiLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+
+ se_iterator->second = l_pEventData;
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// SendEventMessage
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendEventMessage(HANDLE hApp,
+ const SessionIdList &vSessionIdList,
+ UI_32 uiEventId,
+ PCSTR cServiceName,
+ PCVOID pData,
+ UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus eStatusSendMsg = eFrameworkunifiedStatusOK;
+
+ UI_32 l_uiSessionId = 0;
+ HANDLE l_hClientHandle = NULL;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != cServiceName)) {
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < vSessionIdList.size();
+ l_uiCount++) {
+ l_uiSessionId = vSessionIdList[l_uiCount];
+ l_hClientHandle = GetMsgQueueHandle(hApp, cServiceName, l_uiSessionId);
+
+ // send message to all the registered sessions of the service
+ if (NULL != l_hClientHandle) {
+ if (eFrameworkunifiedStatusOK != (eStatusSendMsg = FrameworkunifiedSendMsg(l_hClientHandle, uiEventId, uiLength, pData))) {
+ eStatus = eFrameworkunifiedStatusErrOther;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "FrameworkunifiedSendMsg failed for EventID %d to service %s, status %d",
+ uiEventId, cServiceName, eStatusSendMsg);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Unable to send event %d to service %s, session %d. NULL handle found.",
+ uiEventId, cServiceName, l_uiSessionId);
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// RemoveEventEntryFromEventTable
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus RemoveEventEntryFromEventTable(HANDLE hApp, UI_32 uiEventId,
+ PCSTR cServiceName, const UI_32 uiSessionId) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != cServiceName)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ EventTable::iterator e_iterator;
+ ServiceSessionIdListTable::iterator ssidl_iterator;
+
+ // event table = event id, service name, vector of session ids
+ // check if event is registered by client/s
+ e_iterator = pApp->eventtable.find(uiEventId);
+
+ if (pApp->eventtable.end() != e_iterator) {
+ ssidl_iterator = e_iterator->second.find(cServiceName);
+
+ if (e_iterator->second.end() != ssidl_iterator) {
+ // search for the session id in list of registered session of service with the event uiEventId
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < ssidl_iterator->second.size();
+ l_uiCount++) {
+ if (uiSessionId == ssidl_iterator->second[l_uiCount]) {
+ ssidl_iterator->second.erase(ssidl_iterator->second.begin() + l_uiCount);
+ break;
+ }
+ }
+
+ // no other session of service cServiceName is registered with the event uiEventId
+ if (ssidl_iterator->second.empty()) {
+ e_iterator->second.erase(ssidl_iterator);
+
+ // no other session is registered for the event uiEventId
+ if (e_iterator->second.empty()) {
+ pApp->eventtable.erase(e_iterator);
+ }
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////
+// Function : CleanAllEventsOfSession
+////////////////////////////////////////////
+EFrameworkunifiedStatus CleanAllEventsOfSession(HANDLE hApp, PCSTR serviceName, UI_32 sessionId) {
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != serviceName)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ ServiceSessionHandleTable::iterator ssh_iterator;
+ SessionToEventInfo::iterator sh_iterator;
+ HANDLE l_pClientHandle = NULL;
+ SessionEventInfo *l_ptSessionEventInfo = NULL;
+
+ // check whether client has registered for private event/s
+ ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
+
+ if (pApp->servicesessionhandletable.end() != ssh_iterator) {
+ // get the table of session id and session handle of the received service over which private events are
+ // registered
+ sh_iterator = ssh_iterator->second.find(sessionId);
+
+ // client has registered for private event/s over this session
+ if (ssh_iterator->second.end() != sh_iterator) {
+ l_ptSessionEventInfo = sh_iterator->second;
+
+ if (NULL != l_ptSessionEventInfo) {
+ l_pClientHandle = l_ptSessionEventInfo->m_hSession;
+ if (NULL != l_pClientHandle) {
+ // close the session handle
+ eStatus = FrameworkunifiedMcClose(l_pClientHandle);
+ l_ptSessionEventInfo->m_hSession = NULL;
+ }
+ // Remove all the event entries from Event registry table
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_ptSessionEventInfo->m_vEvents.size();
+ l_uiCount++) {
+ (VOID)RemoveEventEntryFromEventTable(hApp,
+ l_ptSessionEventInfo->m_vEvents[l_uiCount],
+ serviceName,
+ sessionId);
+ }
+ l_ptSessionEventInfo->m_vEvents.clear(); // clear the event list
+ delete l_ptSessionEventInfo;
+ sh_iterator->second = NULL; // l_ptSessionEventInfo
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Deleting session event info entry for service: %s, session id: %d.",
+ serviceName, sessionId);
+ // remove the entry from SessionHandle table
+ ssh_iterator->second.erase(sh_iterator);
+
+ // remove the entry from ServiceSessionHandle table if this service have not registered for
+ // private events over other session
+ if (ssh_iterator->second.empty()) {
+ pApp->servicesessionhandletable.erase(ssh_iterator);
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid application handle or service name NULL");
+ }
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// RemoveEntryFromSessionEventInfoTable
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus RemoveEntryFromSessionEventInfoTable(HANDLE hApp, PCSTR serviceName, UI_32 sessionId, UI_32 eventId) {
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != serviceName)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ ServiceSessionHandleTable::iterator ssh_iterator;
+ SessionToEventInfo::iterator sh_iterator;
+ HANDLE l_pClientHandle = NULL;
+ SessionEventInfo *l_ptSessionEventInfo = NULL;
+
+ // check whether client has registered for private event/s
+ ssh_iterator = pApp->servicesessionhandletable.find(serviceName);
+
+ if (pApp->servicesessionhandletable.end() != ssh_iterator) {
+ // get the table of session id and session handle of the received service over which private events are
+ // registered
+ sh_iterator = ssh_iterator->second.find(sessionId);
+
+ // client has registered for private event/s over this session
+ if (ssh_iterator->second.end() != sh_iterator) {
+ l_ptSessionEventInfo = sh_iterator->second;
+
+ if (NULL != l_ptSessionEventInfo) {
+ // Remove event entry from session event info table
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_ptSessionEventInfo->m_vEvents.size();
+ l_uiCount++) {
+ if (eventId == l_ptSessionEventInfo->m_vEvents[l_uiCount]) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Removing session event info entry for "
+ "service:%s, session id:%d. event:%d",
+ serviceName, sessionId, eventId);
+ l_ptSessionEventInfo->m_vEvents.erase(l_ptSessionEventInfo->m_vEvents.begin() + l_uiCount);
+ break;
+ }
+ }
+
+ if (l_ptSessionEventInfo->m_vEvents.empty()) {
+ l_pClientHandle = l_ptSessionEventInfo->m_hSession;
+ if (NULL != l_pClientHandle) {
+ // close the session handle
+ eStatus = FrameworkunifiedMcClose(l_pClientHandle);
+ l_ptSessionEventInfo->m_hSession = NULL;
+ }
+ delete l_ptSessionEventInfo;
+ sh_iterator->second = NULL; // l_ptSessionEventInfo
+
+ // remove the entry from SessionHandle table
+ ssh_iterator->second.erase(sh_iterator);
+ }
+ }
+
+ // remove the entry from ServiceSessionHandle table if this service have not registered for
+ // private events over other session
+ if (ssh_iterator->second.empty()) {
+ pApp->servicesessionhandletable.erase(ssh_iterator);
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid application handle status:: %d", eStatus);
+ }
+
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedDefinePublicStateEvents
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDefinePublicStateEvents(HANDLE hApp, PUI_32 puiEvents, UI_32 uiListSize) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != puiEvents) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ UI_32 l_uiEventId;
+
+ for (UI_32 uiCount = 0; uiCount < uiListSize; uiCount++) {
+ l_uiEventId = puiEvents[uiCount];
+
+ // checks if event exists in state event list
+ if (pApp->publicstateeventtable.end() == pApp->publicstateeventtable.find(l_uiEventId)) {
+ EventData *l_pEventData = NULL;
+ // insert the event in state event list, data is passed as NULL as there is no data published
+ pApp->publicstateeventtable.insert(std::make_pair(l_uiEventId, l_pEventData));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d already registered as public state event ", l_uiEventId);
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedDefinePrivateStateEvents
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDefinePrivateStateEvents(HANDLE hApp, PUI_32 puiEvents, UI_32 uiListSize) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != puiEvents) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ UI_32 l_uiEventId = 0;
+
+ for (UI_32 uiCount = 0; uiCount < uiListSize; uiCount++) {
+ l_uiEventId = puiEvents[uiCount];
+
+ // checks if event exists in state event list
+ if (pApp->privatestateeventtable.end() == pApp->privatestateeventtable.find(l_uiEventId)) {
+ ServiceSessionEventData servicesessioneventdata;
+ pApp->privatestateeventtable.insert(std::make_pair(l_uiEventId, servicesessioneventdata));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event %d already registered as private state event", l_uiEventId);
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeToSessionEventWithCallback
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithCallback(HANDLE hApp, UI_32 uiCmd, CbFuncPtr fpOnCmd, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
+ uiCmd,
+ fpOnCmd,
+ hSession))) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(UI_32), (PVOID)&uiCmd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedAttachCallbackToDispatcher for "
+ "PROTOCOL_REGISTER_EVENTS Failed Status:: %d", eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeToSessionEventsWithCallbacks
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithCallbacks(HANDLE hApp, const FrameworkunifiedProtocolCallbackHandler *pMsgHandler,
+ UI_32 uiHandlerCount, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == pMsgHandler) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ } else if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ /**
+ * @todo
+ * If the CbFuncPtr in the pMsgHandler is set to NULL, the expected value is eFrameworkunifiedStatusInvldParam,
+ * but eFrameworkunifiedStatusOK is returned in the implementation.
+ * [Proposed measures]
+ * Exit by referring to the return code of the FrameworkunifiedAttachCallbacksToDispatcher executed in the FrameworkunifiedSubscribeToSessionEventsWithCallbacks.
+ */
+ /**
+ * @todo
+ * The behavior when NULL is set for a CbFuncPtr in a pMsgHandler in which more than one callback message is registered
+ * is not specified in the specifications.
+ * Ex: Prepare a pMsgHandler in which three callback information are registered,
+ * and specify NULL as the callback function pointer of the second callback information, and execute it.
+ * - Register the first callback function.
+ * - The second callback function is not registered with an error.
+ * - It is unspecified whether the third callback function is registered.
+ * [Proposed measures]
+ * Specifies that if there is callback information including NULL in the callback function pointer in pMsgHandler,
+ * the callback information will not be registered from the element following that callback function pointer.
+ */
+ eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
+ pMsgHandler,
+ uiHandlerCount,
+ hSession);
+ UI_32 l_uiCmdList[uiHandlerCount]; // NOLINT (readability/nolint)
+ for (UI_32 l_uiCnt = 0; l_uiCnt < uiHandlerCount; l_uiCnt++) {
+ l_uiCmdList[l_uiCnt] = pMsgHandler[l_uiCnt].iCmd;
+ }
+
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS,
+ static_cast<UI_32>(uiHandlerCount * sizeof(UI_32)), l_uiCmdList);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithCallback(HANDLE hApp, UI_32 uiEvent, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEvent), (PVOID)&uiEvent);
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
+ uiEvent,
+ hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : Failed to send PROTOCOL_UNREGISTER_EVENTS request to service:: %d",
+ eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithCallbacks(HANDLE hApp, PUI_32 puiEventsArray, UI_32 uiListSize,
+ HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, static_cast<UI_32>(uiListSize * sizeof(uiListSize)),
+ puiEventsArray);
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
+ puiEventsArray,
+ uiListSize,
+ hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : Failed to send PROTOCOL_UNREGISTER_EVENTS request to service:: %d",
+ eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedPublishPrivateEvent
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishPrivateEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ EventTable::iterator e_iterator;
+ ServiceSessionIdListTable::iterator ssidl_iterator;
+
+ PCSTR l_cServiceName = "";
+ BOOL l_bIsPublished = FALSE;
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // set the data, if event is a public state events
+ UpdatePrivateStateEventData(hApp,
+ uiEventId,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName,
+ (reinterpret_cast<MsgQInfo *>(hSession))->sessionId,
+ pData,
+ uiLength);
+
+ // check if event is registered by client/s
+ e_iterator = pApp->eventtable.find(uiEventId);
+
+ if (pApp->eventtable.end() != e_iterator) {
+ // for loop for event table
+ for (ssidl_iterator = e_iterator->second.begin();
+ ssidl_iterator != e_iterator->second.end();
+ ssidl_iterator++) {
+ l_cServiceName = ssidl_iterator->first.c_str();
+
+ // send message to only specified client
+ if (!std::strcmp(l_cServiceName, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName)) {
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < ssidl_iterator->second.size();
+ l_uiCount++) {
+ if ((reinterpret_cast<MsgQInfo *>(hSession))->sessionId == ssidl_iterator->second[l_uiCount]) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(hSession, uiEventId, uiLength, pData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed for Event %d", uiEventId);
+ }
+
+ l_bIsPublished = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (l_bIsPublished) {
+ break;
+ }
+ }
+
+ if (!l_bIsPublished) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Failed to publish event %d to client [%s], session: [%d]. "
+ "Client not subscribed to the event on specified session.",
+ uiEventId, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName != 0 ? \
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName : NULL,
+ (reinterpret_cast<MsgQInfo *>(hSession))->sessionId);
+ eStatus = eFrameworkunifiedStatusServNotFound;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Client %s is not subscribed to Event %d, session: [%d]",
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId,
+ (reinterpret_cast<MsgQInfo *>(hSession))->sessionId);
+ eStatus = eFrameworkunifiedStatusServNotFound;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedPublishPublicEvent
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishPublicEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus eRetStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ EventTable::iterator e_iterator;
+ ServiceSessionIdListTable::iterator ssidl_iterator;
+
+ PCSTR l_cServiceName = "";
+
+ // set the data, if event is a state events
+ UpdatePublicStateEventData(hApp, uiEventId, pData, uiLength);
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // check if event is registered by client/s
+ e_iterator = pApp->eventtable.find(uiEventId);
+
+ if (pApp->eventtable.end() != e_iterator) {
+ // for loop for event table
+ for (ssidl_iterator = e_iterator->second.begin();
+ ssidl_iterator != e_iterator->second.end();
+ ssidl_iterator++) {
+ l_cServiceName = ssidl_iterator->first.c_str();
+
+ eRetStatus = SendEventMessage(hApp, ssidl_iterator->second, uiEventId, l_cServiceName, pData, uiLength);
+ if (eFrameworkunifiedStatusOK != eRetStatus) {
+ eStatus = eRetStatus;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "No client subscribed to EventID %d.", uiEventId);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// UpdatePrivateStateEventData
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus UpdatePrivateStateEventData(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, UI_32 uiSessionId,
+ PCVOID pData,
+ UI_32 uiLength) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((NULL == pData) && (uiLength > 0)) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ if ((eFrameworkunifiedStatusOK == eStatus) && (frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pClientName)) {
+ PrivateStateEventTable::iterator pse_iterator;
+ ServiceSessionEventData::iterator ssed_iterator;
+ SessionEventData::iterator sed_iterator;
+
+ EventData *l_pEventData = NULL;
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // set the data, if event is a state events
+ pse_iterator = pApp->privatestateeventtable.find(uiEventId);
+ if (pApp->privatestateeventtable.end() != pse_iterator) {
+ ssed_iterator = (pse_iterator->second).find(pClientName);
+
+ if ((pse_iterator->second).end() != ssed_iterator) {
+ sed_iterator = (ssed_iterator->second).find(uiSessionId);
+ if ((ssed_iterator->second).end() != sed_iterator) {
+ l_pEventData = sed_iterator->second;
+
+ if (NULL != l_pEventData) {
+ if (NULL != l_pEventData->pData) {
+ delete[](static_cast<PCHAR>(l_pEventData->pData));
+ (sed_iterator->second)->pData = NULL;
+ }
+
+ delete l_pEventData;
+ sed_iterator->second = NULL;
+ }
+
+ l_pEventData = new(std::nothrow) EventData();
+
+ if (NULL != l_pEventData) {
+ l_pEventData->uiLength = uiLength;
+
+ if (NULL == pData) {
+ l_pEventData->pData = NULL;
+ } else {
+ l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
+ if (NULL != l_pEventData->pData) {
+ std::memset(l_pEventData->pData, 0, uiLength);
+ std::memcpy(l_pEventData->pData, pData, uiLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ l_pEventData->uiLength = 0;
+ }
+ }
+
+ sed_iterator->second = l_pEventData;
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else { // if client has not yet subscribed to this event over the session uiSessionId
+ l_pEventData = new(std::nothrow) EventData();
+
+ if (NULL != l_pEventData) {
+ l_pEventData->uiLength = uiLength;
+
+ if (NULL == pData) {
+ l_pEventData->pData = NULL;
+ } else {
+ l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
+ if (NULL != l_pEventData->pData) {
+ std::memset(l_pEventData->pData, 0, uiLength);
+ std::memcpy(l_pEventData->pData, pData, uiLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+
+ (ssed_iterator->second).insert(std::make_pair(uiSessionId, l_pEventData));
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ } else { // if client has not yet subscribed to this event
+ SessionEventData sessionEventData;
+
+ l_pEventData = new(std::nothrow) EventData();
+
+ if (NULL != l_pEventData) {
+ l_pEventData->uiLength = uiLength;
+
+ if (NULL == pData) {
+ l_pEventData->pData = NULL;
+ } else {
+ l_pEventData->pData = new(std::nothrow) CHAR[uiLength];
+ if (NULL != l_pEventData->pData) {
+ std::memset(l_pEventData->pData, 0, uiLength);
+ std::memcpy(l_pEventData->pData, pData, uiLength);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ l_pEventData->uiLength = 0;
+ }
+ }
+ sessionEventData.insert(std::make_pair(uiSessionId, l_pEventData));
+
+ (pse_iterator->second).insert(std::make_pair(pClientName, sessionEventData));
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// DeleteSessionEventData
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus DeleteSessionEventData(HANDLE hApp, PCSTR pClientName, UI_32 uiSessionId) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ // map: eventid -> servicename -> sessionid -> eventdata(data, length)
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pClientName) {
+ PrivateStateEventTable::iterator pse_iterator;
+ ServiceSessionEventData::iterator ssed_iterator;
+ SessionEventData::iterator sed_iterator;
+
+ EventData *l_pEventData = NULL;
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ // delete the private event data associated with the service over this session
+ for (pse_iterator = pApp->privatestateeventtable.begin();
+ pse_iterator != pApp->privatestateeventtable.end();
+ ++pse_iterator) {
+ ssed_iterator = (pse_iterator->second).find(pClientName);
+
+ if ((pse_iterator->second).end() != ssed_iterator) {
+ sed_iterator = (ssed_iterator->second).find(uiSessionId);
+ if ((ssed_iterator->second).end() != sed_iterator) {
+ l_pEventData = sed_iterator->second;
+
+ if (NULL != l_pEventData) {
+ if (NULL != l_pEventData->pData) {
+ delete[](static_cast<PCHAR>(l_pEventData->pData));
+ (sed_iterator->second)->pData = NULL;
+ }
+
+ delete l_pEventData;
+ sed_iterator->second = NULL;
+ }
+ }
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// Returns the number of session opened by the server for one client
+//////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetNumberOfSession(HANDLE hApp, PCSTR strServiceName) {
+ UI_32 l_uiSessionCount = 0;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ Services::iterator s_iterator = pApp->services.find(strServiceName);
+ if (s_iterator != pApp->services.end()) {
+ l_uiSessionCount = static_cast<UI_32>((s_iterator->second).size());
+ }
+ }
+
+ return l_uiSessionCount;
+}
+
+//////////////////////////////////////////////////////
+/// Sets the handle in the Application Framework
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetSessionHandle(HANDLE hApp, PCSTR strServiceName, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_uiSessionId = 0;
+ if (frameworkunifiedCheckValidMsgQ(hSession) && NULL != strServiceName && frameworkunifiedCheckValidAppHandle(hApp) &&
+ 0 != std::strlen(strServiceName)) {
+ MsgQInfo *pMsgQ = reinterpret_cast<MsgQInfo *>(hSession);
+
+ // Get session Id
+ l_uiSessionId = pMsgQ->sessionId;
+
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ ServiceSessionTable::iterator session_iterator;
+ SessionHandleTable::iterator session_handle_iterator;
+
+ // Find the service name
+ session_iterator = pApp->sessiontable.find(strServiceName);
+ if (session_iterator == pApp->sessiontable.end()) {
+ pApp->sessiontable.insert(std::make_pair(strServiceName, SessionHandleTable()));
+ }
+
+ // Find the session id
+ session_handle_iterator = pApp->sessiontable[strServiceName].find(l_uiSessionId);
+ if (session_handle_iterator != pApp->sessiontable[strServiceName].end()) {
+ pApp->sessiontable[strServiceName].erase(l_uiSessionId);
+ }
+
+ // Set the session handle
+ pApp->sessiontable[strServiceName].insert(std::make_pair(l_uiSessionId, hSession));
+
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// reads the handle from the Application Framework
+//////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetSessionHandle(HANDLE hApp, PCSTR strServiceName, UI_32 uiSessionId) {
+ HANDLE hSession = NULL;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && strServiceName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ ServiceSessionTable::iterator session_iterator;
+ SessionHandleTable::iterator session_handle_iterator;
+
+ // Find the service name
+ session_iterator = pApp->sessiontable.find(strServiceName);
+ if (session_iterator != pApp->sessiontable.end()) {
+ // Find the session id
+ session_handle_iterator = pApp->sessiontable[strServiceName].find(uiSessionId);
+ if (session_handle_iterator != pApp->sessiontable[strServiceName].end()) {
+ // Fetch the session handle
+ hSession = session_handle_iterator->second;
+ }
+ }
+ }
+ return hSession;
+}
+//////////////////////////////////////////////////////
+/// Close the handle stored in the Application Framework
+//////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRemoveSessionHandle(HANDLE hApp, PCSTR strServiceName, UI_32 uiSessionId) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && strServiceName && 0 != std::strlen(strServiceName)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ pApp->sessiontable[strServiceName].erase(uiSessionId);
+ if (0 == pApp->sessiontable[strServiceName].size()) {
+ // If no entry is available for current service then remove the servicename
+ pApp->sessiontable.erase(strServiceName);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return eStatus;
+}
+
+//////////////////////////////////////////////////////
+/// FrameworkunifiedGetSession|Name -> On Client side
+//////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetSessionName(HANDLE hSession) {
+ if (frameworkunifiedCheckValidMsgQ(hSession)) {
+ return ((reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName);
+ } else {
+ return NULL;
+ }
+}
+
+
+HANDLE FrameworkunifiedGetCurrentSessionHandle(HANDLE hApp) {
+ HANDLE hSession = NULL;
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ UI_32 l_uiSessionId = FrameworkunifiedGetMsgSessionId(hApp);
+ PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
+
+ hSession = FrameworkunifiedGetSessionHandle(hApp, pRequester, l_uiSessionId);
+ }
+ return hSession;
+}
+
+HANDLE FrameworkunifiedCreateSession(HANDLE hApp, PCSTR pSessionName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ HANDLE hSession = NULL;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pSessionName && strlen(pSessionName)) {
+ hSession = FrameworkunifiedGenerateSessionHandle(hApp, pSessionName);
+ if (hSession) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSetSessionHandle(hApp, pSessionName, hSession))) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Close session failed");
+ }
+ hSession = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "FrameworkunifiedCreateSession Failed Status:0x%x ", eStatus);
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return hSession;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedDestroySession(HANDLE hApp, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ UI_32 uiSessionId = (reinterpret_cast<MsgQInfo *>(hSession))->sessionId;
+ CHAR pRequester[MAX_NAME_SIZE_APP] = {};
+ strncpy(pRequester, (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, sizeof(pRequester) - 1);
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(hSession))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Close session failed. Status: %d", eStatus);
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedRemoveSessionHandle(hApp, pRequester, uiSessionId))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Remove session failed. Status: %d", eStatus);
+ }
+
+ DeleteSessionEventData(hApp, pRequester, uiSessionId);
+ }
+
+ return eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp
new file mode 100644
index 00000000..80eec1fe
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_sync.cpp
@@ -0,0 +1,439 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NativeService
+/// \brief This file contains the implementation for the synchronization
+/// API's class.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/frameworkunified_framework_sync.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_logger_if.h>
+#include <string>
+#include <algorithm>
+#include <utility>
+#include "frameworkunified_framework_core.h"
+
+/// initialization of static members of class
+CFrameworkunifiedSyncData *CFrameworkunifiedSyncData::m_psSyncData = NULL;
+
+pthread_spinlock_t CFrameworkunifiedSyncData::m_pSyncLock;
+static pthread_mutex_t g_instance_lock = PTHREAD_MUTEX_INITIALIZER;
+
+// Template function to invoke callback function of CFrameworkunifiedSyncData class
+template <typename C, eFrameworkunifiedStatus(C::*M)(HANDLE)> EFrameworkunifiedStatus SyncDataCallback(HANDLE hThread) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ C *l_pClass = C::FrameworkunifiedGetSyncDataInstance();
+
+ if (NULL != l_pClass) {
+ l_eStatus = (l_pClass->*M)(hThread);
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedSyncData
+/// Constructor of CFrameworkunifiedSyncData class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedSyncData::CFrameworkunifiedSyncData(): m_bSyncThreadStarted(FALSE),
+ m_mSyncDataMap(NULL),
+ m_hSyncThreadAppHandle(NULL),
+ m_hAppHandle(NULL),
+ m_hSyncThreadMsgQHandle(NULL) {
+ pthread_spin_init(&m_pSyncLock, 1);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedSyncData
+/// Destructor of CFrameworkunifiedSyncData class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedSyncData::~CFrameworkunifiedSyncData() {
+ pthread_spin_destroy(&m_pSyncLock);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedStartNotificationSync
+/// This method is used to start the synchronization notification thread.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedStartNotificationSync(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ pthread_spin_lock(&m_pSyncLock);
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ m_hAppHandle = hApp;
+ std::string l_cThreadName = FrameworkunifiedGetAppName(hApp);
+ // l_cThreadName.append("SyncThread");
+ std::reverse(l_cThreadName.begin(), l_cThreadName.end());
+
+ if (NULL == m_hSyncThreadMsgQHandle) {
+ // Create Sync Thread
+ m_hSyncThreadMsgQHandle = FrameworkunifiedCreateChildThread(hApp,
+ l_cThreadName.c_str(),
+ SyncDataCallback<CFrameworkunifiedSyncData,
+ &CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStart>,
+ SyncDataCallback<CFrameworkunifiedSyncData,
+ &CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStop>);
+ if (NULL != m_hSyncThreadMsgQHandle) {
+ if (FALSE == m_bSyncThreadStarted) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp,
+ m_hSyncThreadMsgQHandle,
+ 0,
+ NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Failed to start Thread.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Sync Data Thread Started");
+ m_bSyncThreadStarted = TRUE;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusThreadAlreadyRunning;
+ }
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Sync Data Thread Message Queue Null");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusThreadAlreadyRunning;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ pthread_spin_unlock(&m_pSyncLock);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedStartNotificationSync
+/// This method is used to stop the synchronization notification thread.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedStopNotificationSync(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (NULL != m_hSyncThreadMsgQHandle) {
+ pthread_spin_lock(&m_pSyncLock);
+ if (eFrameworkunifiedStatusOK != (l_eStatus = (FrameworkunifiedStopChildThread(hApp,
+ m_hSyncThreadMsgQHandle,
+ 0,
+ NULL)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedStopChildThread Sync Thread Failed.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedStopChildThread Sync Thread Success.");
+ m_bSyncThreadStarted = FALSE;
+ }
+ pthread_spin_unlock(&m_pSyncLock);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusThreadNotExist;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetSyncDataInstance
+/// This function is used to get the singleton instance of class.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedSyncData *CFrameworkunifiedSyncData::FrameworkunifiedGetSyncDataInstance() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (NULL == m_psSyncData) {
+ pthread_mutex_lock(&g_instance_lock);
+ if (NULL == m_psSyncData) {
+ CFrameworkunifiedSyncData *l_pFrameworkunifiedSyncData = new(std::nothrow)CFrameworkunifiedSyncData();
+ m_psSyncData = l_pFrameworkunifiedSyncData;
+ }
+ pthread_mutex_unlock(&g_instance_lock);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return m_psSyncData;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedReleaseSyncDataInstance
+/// This function is used to release the instance of class.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedReleaseSyncDataInstance() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_psSyncData) {
+ pthread_mutex_lock(&g_instance_lock);
+ if (NULL != m_psSyncData) {
+ delete m_psSyncData;
+ m_psSyncData = NULL;
+ }
+ pthread_mutex_unlock(&g_instance_lock);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSyncDataThreadStart
+/// This function is callback function on the start of the sync thread.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStart(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hThread) {
+ // Set Sync Thread Handle
+ m_hSyncThreadAppHandle = hThread;
+
+ if (NULL == m_mSyncDataMap) {
+ m_mSyncDataMap = new(std::nothrow)TSyncDataPacketList();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSyncDataThreadStop
+/// This function is callback function on the stop of the sync thread.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSyncDataThreadStop(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (NULL != m_mSyncDataMap) {
+ for (TSyncDataPacketItr l_itSyncDataPacketItr = m_mSyncDataMap->begin() ;
+ l_itSyncDataPacketItr != m_mSyncDataMap->end();) {
+ SFrameworkunifiedSyncDataPacket *l_ptDataPacket = l_itSyncDataPacketItr->second;
+
+ if (NULL != l_ptDataPacket) {
+ if (NULL != l_ptDataPacket->m_pNotificationData) {
+ delete[](static_cast<PCHAR>(l_ptDataPacket->m_pNotificationData));
+ l_ptDataPacket->m_pNotificationData = NULL;
+ }
+ delete l_ptDataPacket;
+ l_ptDataPacket = NULL;
+ m_mSyncDataMap->erase(l_itSyncDataPacketItr++);
+ } else {
+ l_itSyncDataPacketItr++;
+ }
+ }
+
+ delete m_mSyncDataMap;
+ m_mSyncDataMap = NULL;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusExit;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeNotificationWithDataSync
+/// This function is used to subscribe to notifications.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSubscribeNotificationWithDataSync(const std::string &f_cNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ pthread_spin_lock(&m_pSyncLock);
+ if (TRUE != f_cNotification.empty() && NULL != m_hSyncThreadAppHandle) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(
+ m_hSyncThreadAppHandle, // Thread Application handle
+ f_cNotification.c_str(), // Notification
+ SyncDataCallback<CFrameworkunifiedSyncData,
+ &CFrameworkunifiedSyncData::FrameworkunifiedSyncDataNotifCallback>))) { // Callback Function
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithCallback Sync Notification Data failed.");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithCallback Sync Notification Data success.");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ pthread_spin_unlock(&m_pSyncLock);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeNotificationWithDataSync
+/// This function is used to unsubscribe to notifications.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedUnSubscribeNotificationWithDataSync(const std::string &f_cNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ pthread_spin_lock(&m_pSyncLock);
+ if (TRUE != f_cNotification.empty() && NULL != m_hSyncThreadAppHandle) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithCallback
+ (m_hSyncThreadAppHandle, // Thread Application Handle
+ f_cNotification.c_str()))) { // Notification
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedUnsubscribeNotificationWithCallback failed.");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "FrameworkunifiedUnsubscribeNotificationWithCallback success.");
+
+ TSyncDataPacketItr l_itSycDataPacketItr = m_mSyncDataMap->find(f_cNotification);
+ // Delete the notification data
+ if (m_mSyncDataMap->end() != l_itSycDataPacketItr) {
+ SFrameworkunifiedSyncDataPacket *l_ptDataPacket = l_itSycDataPacketItr->second;
+ if (NULL != l_ptDataPacket && NULL != l_ptDataPacket->m_pNotificationData) {
+ delete[](static_cast<PCHAR>(l_ptDataPacket->m_pNotificationData));
+ l_ptDataPacket->m_pNotificationData = NULL;
+ delete l_ptDataPacket;
+ l_ptDataPacket = NULL;
+ m_mSyncDataMap->erase(l_itSycDataPacketItr);
+ }
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ pthread_spin_unlock(&m_pSyncLock);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSyncDataNotifCallback
+/// This function is callback to notifications on publication of notifications.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedSyncDataNotifCallback(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == hThread) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ PCSTR l_pcLastNotification = FrameworkunifiedGetLastNotification(hThread);
+
+ if (NULL == l_pcLastNotification || 0 == std::strlen(l_pcLastNotification)) {
+ return eFrameworkunifiedStatusInvldNotification;
+ }
+
+ UI_32 l_uiBufferSize = FrameworkunifiedGetMsgLength(hThread);
+ PVOID l_pDataBuffer = new(std::nothrow)CHAR[l_uiBufferSize];
+
+ if ((NULL != l_pDataBuffer) &&
+ (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hThread, l_pDataBuffer, l_uiBufferSize, eSMRRelease))) {
+ SFrameworkunifiedSyncDataPacket *l_ptDataPacket = NULL;
+
+ pthread_spin_lock(&m_pSyncLock);
+
+ TSyncDataPacketItr l_itSycDataPacketItr = m_mSyncDataMap->find(l_pcLastNotification);
+ // Delete the last notification data
+ if (m_mSyncDataMap->end() == l_itSycDataPacketItr) {
+ l_ptDataPacket = new(std::nothrow)SFrameworkunifiedSyncDataPacket();
+ } else {
+ l_ptDataPacket = l_itSycDataPacketItr->second;
+ if (NULL != l_ptDataPacket && NULL != l_ptDataPacket->m_pNotificationData) {
+ delete[](static_cast<PCHAR>(l_ptDataPacket->m_pNotificationData));
+ l_ptDataPacket->m_pNotificationData = NULL;
+ }
+ }
+
+ if (NULL != l_ptDataPacket) {
+ l_ptDataPacket->m_pNotificationData = l_pDataBuffer;
+ l_ptDataPacket->m_uiDataSize = l_uiBufferSize;
+ l_ptDataPacket->m_tTimeStamp = time(NULL);
+ m_mSyncDataMap->insert(std::make_pair(l_pcLastNotification, l_ptDataPacket));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "NULL pointer: l_ptDataPacket");
+ }
+
+ pthread_spin_unlock(&m_pSyncLock);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetSyncDataSize
+/// This function is used to get the size of the synchronization data.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CFrameworkunifiedSyncData::FrameworkunifiedGetSyncDataSize(const std::string &f_cNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ UI_32 l_uiSyncDataSize = 0;
+
+ if (TRUE != f_cNotification.empty()) {
+ pthread_spin_lock(&m_pSyncLock);
+
+ TSyncDataPacketItr l_itSyncDataPacketItr = m_mSyncDataMap->find(f_cNotification);
+ SFrameworkunifiedSyncDataPacket *l_ptDataPacket = NULL;
+
+ if (m_mSyncDataMap->end() != l_itSyncDataPacketItr) {
+ l_ptDataPacket = l_itSyncDataPacketItr->second;
+ l_uiSyncDataSize = l_ptDataPacket->m_uiDataSize;
+ }
+ pthread_spin_unlock(&m_pSyncLock);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_uiSyncDataSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetSyncNotificationData
+/// This function is used to get the synchronization notification data for a particular notification .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedSyncData::FrameworkunifiedGetSyncNotificationData(const std::string &f_cNotification, PVOID f_pBuffer,
+ UI_16 f_nBufferSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (TRUE != f_cNotification.empty() && NULL != f_pBuffer && 0 != f_nBufferSize) {
+ pthread_spin_lock(&m_pSyncLock);
+ TSyncDataPacketItr l_itSyncDataPacketItr = m_mSyncDataMap->find(f_cNotification);
+ if (m_mSyncDataMap->end() != l_itSyncDataPacketItr) {
+ if (NULL != l_itSyncDataPacketItr->second) {
+ if (NULL != std::memcpy(f_pBuffer, l_itSyncDataPacketItr->second->m_pNotificationData,
+ l_itSyncDataPacketItr->second->m_uiDataSize)) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ pthread_spin_unlock(&m_pSyncLock);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp
new file mode 100644
index 00000000..3a2d434a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_framework_system.cpp
@@ -0,0 +1,77 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Framework wrapper over the service directory interface APIs
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/ns_logger_if.h>
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+
+/// This is a library method in System Services....
+/// Note: Special care has been taken so that Native Services
+/// binaries don't have any circular dependence on System services.
+extern EFrameworkunifiedStatus SendSystemErrorToSystemManager(EFrameworkunifiedSystemError eSystemError) __attribute__((weak));
+
+
+EFrameworkunifiedStatus FrameworkunifiedAttachSystemCallbacksDispatcher(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ EFrameworkunifiedStatus eStatus = FrameworkunifiedSSFrameworkInterfaceInternal(hApp);
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendSystemErrMessage
+/// Sends a request to system manager for hard reset using function SendHardResetRequestToSystemManager
+/// which is defined in SystemServices library.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \param [in] eResetReason
+/// EFrameworkunifiedSystemError - Error Type
+///
+/// \return EFrameworkunifiedStatus
+/// EFrameworkunifiedStatus - Returns status of operation
+///
+///////////////////////////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 200: System Error can't be tested for UT.
+EFrameworkunifiedStatus FrameworkunifiedSendSystemErrMessage(HANDLE hApp, EFrameworkunifiedSystemError eSystemError) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+
+ if (SendSystemErrorToSystemManager) {
+ l_eStatus = SendSystemErrorToSystemManager(eSystemError);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp
new file mode 100644
index 00000000..468478ca
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_msgprofiler.cpp
@@ -0,0 +1,210 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief File defines FrameworkunifiedMsgProfiler class which keeps profiler information for message dispatcher
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* For FRAMEWORKUNIFIEDLOG*/
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_message_center_if.h>
+/* For PROTOCOL_DIS_MSGPROFILER */
+#include <native_service/frameworkunified_service_protocol.h>
+/* For FrameworkunifiedGetAppName */
+#include <native_service/frameworkunified_framework_if.h>
+
+#include <string>
+#include <vector>
+/* Required for OpenSender, SendMessage, McSend, McOpenSender */
+#include "ns_msg_queue.h"
+#include "frameworkunified_msgprofiler.h"
+
+BOOL FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled = FALSE;
+
+//////////////////////////////////////////
+// Constructor
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+FrameworkunifiedMsgProfiler::FrameworkunifiedMsgProfiler(const std::string &f_cAppName)
+ : m_cAppName(f_cAppName),
+ m_ui32TotalNoOfMsgsReceived(0),
+ m_ui64MinMsgProcessingTime(720575940), // assign some big value
+ m_ui64MaxMsgProcessingTime(0),
+ m_ui64TotalMsgExecutionTime(0),
+ m_ui64LastMsgReceivedTime(0),
+ m_ui64AppInitTime(0),
+ m_bLastMsgWasPrintProfile(FALSE) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ m_ui64AppInitTime = GetClock();
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Destructor
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+FrameworkunifiedMsgProfiler::~FrameworkunifiedMsgProfiler() {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : GetAppName
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+std::string FrameworkunifiedMsgProfiler::GetAppName() {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ return m_cAppName;
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : MsgReceived
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID FrameworkunifiedMsgProfiler::MsgReceived() {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ m_ui32TotalNoOfMsgsReceived++;
+ m_ui64LastMsgReceivedTime = GetClock();
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : MsgProcessed
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID FrameworkunifiedMsgProfiler::MsgProcessed() {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ if (!m_bLastMsgWasPrintProfile) {
+ UI_64 l_ui64MsgProcessedTime = GetClock() - m_ui64LastMsgReceivedTime;
+
+ // set minimum execution time
+ if (l_ui64MsgProcessedTime < m_ui64MinMsgProcessingTime) {
+ m_ui64MinMsgProcessingTime = l_ui64MsgProcessedTime;
+ }
+
+ // set maximum execution time
+ if (l_ui64MsgProcessedTime > m_ui64MaxMsgProcessingTime) {
+ m_ui64MaxMsgProcessingTime = l_ui64MsgProcessedTime;
+ }
+
+ m_ui64TotalMsgExecutionTime += l_ui64MsgProcessedTime;
+ } else {
+ m_bLastMsgWasPrintProfile = FALSE;
+ }
+
+ // reset the last msg received time
+ m_ui64LastMsgReceivedTime = 0;
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : PrintProfileInfo
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus FrameworkunifiedMsgProfiler::PrintProfileInfo(HANDLE f_hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ HANDLE l_hProfileQ = OpenSender(FRAMEWORKUNIFIED_NS_MSGPROFILERUTIL);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __PRETTY_FUNCTION__, "Inside");
+ CHAR l_cData[MAX_QUEUE_MSG_SIZE] = {};
+ m_bLastMsgWasPrintProfile = TRUE;
+ // don't consider this message which is profiler specific. So decreasing the msg count by 1
+ m_ui32TotalNoOfMsgsReceived--;
+ if (NULL != l_hProfileQ) {
+ UI_64 l_ui64TimeSinceAppStart = (GetClock() - m_ui64AppInitTime) / 1000;
+ UI_64 l_ui64AvgMsgProcessingTime = m_ui64TotalMsgExecutionTime / m_ui32TotalNoOfMsgsReceived;
+
+ // MSG FORMAT: Tick, App/ThreadName, TotalMsgs, Freq(msgs/sec),
+ // Min MsgProcessingtime(cs,ms),:, Avg MsgProcessingtime (cs,ms) ,:, Max MsgProcessingtime (cs,ms)
+ snprintf(l_cData, MAX_QUEUE_MSG_SIZE, "%010lld, %-23s, %9d, %6.3f, "
+ "%30lld,%-5lld ,:, %30lld,%-5lld ,:, %30lld,%-5lld\n",
+ static_cast<long long int>(l_ui64TimeSinceAppStart), // NOLINT (readability/nolint)
+ m_cAppName.c_str(),
+ m_ui32TotalNoOfMsgsReceived,
+ (F_64)m_ui32TotalNoOfMsgsReceived / (F_64)l_ui64TimeSinceAppStart,
+ static_cast<long long int>(m_ui64MinMsgProcessingTime), // NOLINT (readability/nolint)
+ static_cast<long long int>(m_ui64MinMsgProcessingTime), // NOLINT (readability/nolint)
+ static_cast<long long int>(l_ui64AvgMsgProcessingTime), // NOLINT (readability/nolint)
+ static_cast<long long int>(l_ui64AvgMsgProcessingTime), // NOLINT (readability/nolint)
+ static_cast<long long int>(m_ui64MaxMsgProcessingTime), // NOLINT (readability/nolint)
+ static_cast<long long int>(m_ui64MaxMsgProcessingTime)); // NOLINT (readability/nolint)
+
+ SendMessage(l_hProfileQ, MAX_QUEUE_MSG_SIZE, l_cData);
+
+ if (eFrameworkunifiedStatusOK == CloseSender(l_hProfileQ)) {
+ l_hProfileQ = NULL;
+ }
+
+ // inform all childs to print msg profiler information.
+ std::vector<std::string>::iterator l_itChildList = m_vChildNames.begin();
+
+ HANDLE l_hChild = NULL;
+ while (m_vChildNames.end() != l_itChildList) {
+ if (!((*l_itChildList).empty())) {
+ l_hChild = McOpenSender((*l_itChildList).c_str());
+ if (NULL != l_hChild) {
+ if (eFrameworkunifiedStatusOK != McSend(l_hChild, FrameworkunifiedGetAppName(f_hApp), PROTOCOL_DIS_MSGPROFILER, 0, NULL)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "Error sending PROTOCOL_DIS_MSGPROFILER to child");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __PRETTY_FUNCTION__, "Msg PROTOCOL_DIS_MSGPROFILER sent to child");
+ }
+
+ McClose(l_hChild);
+ l_hChild = NULL;
+ }
+ }
+ l_itChildList++;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __PRETTY_FUNCTION__, "Exiting");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : AddChildName
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID FrameworkunifiedMsgProfiler::AddChildName(const std::string &f_cChildName) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ if (!f_cChildName.empty()) {
+ m_vChildNames.push_back(f_cChildName);
+ }
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : GetClock
+//////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+UI_64 FrameworkunifiedMsgProfiler::GetClock() {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ struct timespec tp;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "clock_gettime errno:%d", errno);
+ return 0;
+ }
+ return (UI_64)tp.tv_sec * 1000 * 1000 + tp.tv_nsec / 1000;
+}
+// LCOV_EXCL_STOP
+
+// EOF
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp
new file mode 100644
index 00000000..986f3b34
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_multithreading.cpp
@@ -0,0 +1,531 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Framework wrapper over the service directory interface APIs
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <pthread.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/prctl.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
+
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/ns_utility.hpp>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_system_mode.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/frameworkunified_sm_hsmframework.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+
+#include <iostream>
+
+#ifdef DISPATCHER_PROFILER
+#include <boost/bind.hpp>
+#include "frameworkunified_msgprofiler.h"
+#endif
+
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_utility.h"
+#include "frameworkunified_framework_internal.h"
+#include "frameworkunified_sm_multithreading_internal.h"
+
+__thread HANDLE responseWaitQ = NULL;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsValidWaitBarrier
+////////////////////////////////////////////////////////////////////////////////////////////
+bool IsValidWaitBarrier(int wbret) {
+ return (PTHREAD_BARRIER_SERIAL_THREAD == wbret) ||
+ (0 == wbret);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// DestroyThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DestroyThread(HANDLE hApp) {
+ // terminates the dispatcher loop to destroy the thread
+ if (responseWaitQ != NULL) {
+ /**
+ * @todo
+ * The responseWaitQ is set in the FrameworkunifiedInvokeSync and is closed in the callback process (DestroyThread) of the FrameworkunifiedDestroyChildThread.
+ * Therefore, the responseWaitQ is not closed when FrameworkunifiedInvokeSync is used on the parent.
+ */
+ McClose(responseWaitQ);
+ responseWaitQ = NULL;
+ }
+ return eFrameworkunifiedStatusExit;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// setChildThreadSched
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus setChildThreadSched(EFrameworkunifiedSchedPolicy policy, SI_32 priority) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ struct sched_param param;
+ int get_policy, set_policy;
+ int set_priority;
+
+ if (pthread_getschedparam(pthread_self(), &get_policy, &param) != 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: pthread_getschedparam errno:%d", errno);
+ // LCOV_EXCL_BR_STOP
+ return eFrameworkunifiedStatusFail;
+ }
+
+ if (policy == eFrameworkunifiedSchedPolicyInherit) {
+ set_policy = get_policy;
+ } else {
+ if (policy == eFrameworkunifiedSchedPolicyFIFO) {
+ set_policy = SCHED_FIFO;
+ } else if (policy == eFrameworkunifiedSchedPolicyRR) {
+ set_policy = SCHED_RR;
+ } else {
+ set_policy = SCHED_OTHER;
+ }
+ }
+
+ if (priority == INHERIT_PARENT_THREAD_PRIO) {
+ if (get_policy != set_policy) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: Change policy(%d-%d) but inherit priority", get_policy, set_policy);
+
+ if (set_policy == SCHED_OTHER) {
+ set_priority = 0;
+ } else {
+ set_priority = sched_get_priority_min(set_policy);
+ }
+ } else {
+ set_priority = param.sched_priority;
+ }
+ } else {
+ set_priority = priority;
+ }
+
+ switch (set_policy) {
+ case SCHED_OTHER:
+ param.sched_priority = 0;
+ if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: pthread_setschedparam errno:%d", errno);
+ eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ if (setpriority(PRIO_PROCESS, static_cast<int>(syscall(__NR_gettid)), set_priority) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: setpriority errno:%d", errno);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ break;
+
+ case SCHED_FIFO:
+ case SCHED_RR:
+ param.sched_priority = set_priority;
+ if (pthread_setschedparam(pthread_self(), set_policy, &param) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: pthread_setschedparam errno:%d", errno);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ break;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// child_thread_proc
+////////////////////////////////////////////////////////////////////////////////////////////
+void *child_thread_proc(void *args) {
+ if (args == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "args is NULL");
+ return NULL;
+ }
+ PCData pcdata = *reinterpret_cast< PCData * >(args); // Create a local copy of data
+
+ try {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ HANDLE hApp = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcherChild(hApp,
+ pcdata.childName.c_str(),
+ pcdata.parentName.c_str()))) {
+ // LCOV_EXCL_BR_START 200: If FrameworkunifiedCreateDispatcherChild return eFrameworkunifiedStatusOK, hApp would also be valid.
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ // LCOV_EXCL_BR_STOP
+ THApp hChildApp(hApp);
+
+ const FrameworkunifiedProtocolCallbackHandler pcbhs[] = { { SYSTEM_ON_INITIALIZATION, pcdata.initFn },
+ { SYSTEM_ON_SHUTDOWN, pcdata.shdnFn },
+ { SYSTEM_ON_DESTROY, DestroyThread }
+ }; // LCOV_EXCL_BR_LINE 11:except branch
+
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbacksToDispatcher(hChildApp,
+ pcdata.parentName.c_str(),
+ &pcbhs[ 0 ],
+ static_cast<UI_32>(_countof(pcbhs)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Error: Attaching child callbacks to dispatcher %s", pcdata.childName.c_str());
+ }
+
+ char thread_name[16];
+ strncpy(thread_name, pcdata.childName.c_str(), sizeof(thread_name));
+ prctl(PR_SET_NAME, thread_name);
+ thread_name[15] = '\0';
+
+ setChildThreadSched(pcdata.schedPolicy, pcdata.schedPriority);
+
+ *pcdata.childStatus = eFrameworkunifiedStatusOK;
+ if (IsValidWaitBarrier(pthread_barrier_wait(pcdata.barrier))) {
+ RunChildDispatcher(hChildApp);
+ }
+ } else {
+ // LCOV_EXCL_START 200: If FrameworkunifiedCreateDispatcherChild return eFrameworkunifiedStatusOK, hApp would also be valid.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcherChild error, status=%d", eStatus);
+
+ *pcdata.childStatus = eFrameworkunifiedStatusFail;
+ pthread_barrier_wait(pcdata.barrier);
+ }
+ } catch (const THApp::Exception &) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to create child %s", pcdata.childName.c_str());
+ }
+
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE CreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown,
+ const FrameworkunifiedChildThreadAttr *attr, CbFuncPtr CbCreateStateMachine) {
+ HANDLE hChildQ = NULL;
+ pthread_attr_t tAttr;
+ pthread_attr_t *pAttr = NULL;
+ SI_32 l_iThrCreate = 0;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
+ NULL != CbInitialize && NULL != CbShutdown && NULL != attr) {
+ if (attr->schedPolicy < eFrameworkunifiedSchedPolicyInherit || attr->schedPolicy >= eFrameworkunifiedSchedPolicyMAX) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ if (EOK == pthread_attr_init(&tAttr)) {
+ if (EOK != pthread_attr_setinheritsched(&tAttr, PTHREAD_INHERIT_SCHED)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ pAttr = &tAttr;
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ pthread_barrier_t barrier;
+ if (EOK == pthread_barrier_init(&barrier, NULL, 2)) {
+ PCData pc(&barrier, &l_eStatus, FrameworkunifiedGetAppName(hApp), childName, CbInitialize, CbShutdown,
+ attr->schedPolicy, attr->schedPriority, CbCreateStateMachine);
+ pthread_t childThread = 0;
+
+ if (NULL != CbCreateStateMachine) {
+ l_iThrCreate = pthread_create(&childThread, pAttr, child_hsm_thread_proc, &pc);
+ } else {
+ l_iThrCreate = pthread_create(&childThread, pAttr, child_thread_proc, &pc);
+ }
+
+ if (EOK == l_iThrCreate) {
+ if (IsValidWaitBarrier(pthread_barrier_wait(&barrier))) {
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ hChildQ = McOpenSenderChild(childName, childThread);
+ }
+ }
+ }
+ pthread_barrier_destroy(&barrier);
+ }
+ }
+#ifdef DISPATCHER_PROFILER
+ if (TRUE == FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
+ pApp->m_pFrameworkunifiedMsgProfiler->AddChildName(childName);
+ }
+ }
+#endif
+ }
+ return hChildQ;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateChildThreadAttrInit
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (attr == NULL) {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ } else {
+ memset(attr, 0, sizeof(FrameworkunifiedChildThreadAttr));
+ attr->schedPolicy = eFrameworkunifiedSchedPolicyInherit;
+ attr->schedPriority = INHERIT_PARENT_THREAD_PRIO;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateChildThreadAttrSetSched
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (attr == NULL) {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ } else {
+ if (policy < eFrameworkunifiedSchedPolicyInherit || policy >= eFrameworkunifiedSchedPolicyMAX) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ attr->schedPolicy = policy;
+ attr->schedPriority = priority;
+ }
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateChildThreadAttrInit
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr) {
+ return CreateChildThreadAttrInit(attr);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateChildThreadAttrSetSched
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority) {
+ return CreateChildThreadAttrSetSched(attr, policy, priority);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
+ , CbFuncPtr CbShutdown) {
+ HANDLE hChildQ = NULL;
+ FrameworkunifiedChildThreadAttr attr;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
+ NULL != CbInitialize && NULL != CbShutdown) {
+ CreateChildThreadAttrInit(&attr);
+ hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, NULL);
+ }
+
+ return hChildQ;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateChildThreadWithPriority
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
+ , CbFuncPtr CbShutdown, SI_32 schedPrio) {
+ HANDLE hChildQ = NULL;
+ FrameworkunifiedChildThreadAttr attr;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
+ NULL != CbInitialize && NULL != CbShutdown) {
+ CreateChildThreadAttrInit(&attr);
+ CreateChildThreadAttrSetSched(&attr, eFrameworkunifiedSchedPolicyFIFO, schedPrio);
+ hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, NULL);
+ }
+
+ return hChildQ;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateChildThreadWithAttribute
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateChildThreadWithAttribute(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
+ , CbFuncPtr CbShutdown, const FrameworkunifiedChildThreadAttr *attr) {
+ HANDLE hChildQ = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && strlen(childName) < LIMIT_NAME_SIZE_APP &&
+ NULL != CbInitialize && NULL != CbShutdown && NULL != attr) {
+ hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, attr, NULL);
+ }
+
+ return hChildQ;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDestroyChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDestroyChildThread(HANDLE hApp, HANDLE hChildQ) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != hChildQ) {
+ eStatus = FrameworkunifiedSendChild(hApp, hChildQ, PROTOCOL_THREAD_DESTROY, 0, NULL);
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedJoinChild(hChildQ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedJoinChild Error. status: %d", eStatus);
+ }
+
+ // close the child message queue handle
+ eStatus = McClose(hChildQ);
+ hChildQ = NULL;
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedStartChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedStartChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data) {
+ return FrameworkunifiedSendChild(hApp, hChildQ, SYSTEM_ON_INITIALIZATION, length, data);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedStopChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedStopChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data) {
+ return FrameworkunifiedSendChild(hApp, hChildQ, SYSTEM_ON_SHUTDOWN, length, data);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendChild
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendChild(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd, UI_32 length, PCVOID data) {
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hApp);
+ return McSend(hChildQ, &pApp->cAppName[ 0 ], iCmd, length, data);
+ }
+ return eFrameworkunifiedStatusInvldHandle;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendParent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendParent(HANDLE hChildApp, UI_32 iCmd, UI_32 length, PCVOID data) {
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
+ return McSend(pApp->hParentSndMsgQ, &pApp->cAppName[ 0 ], iCmd, length, data);
+ }
+ return eFrameworkunifiedStatusInvldHandle;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateDispatcherChild
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherChild(HANDLE &hChildApp, // NOLINT (readability/nolint)
+ PCSTR childName,
+ PCSTR parentName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((NULL != childName) && (NULL != parentName) && (LIMIT_NAME_SIZE_APP > strlen(parentName)) &&
+ (LIMIT_NAME_SIZE_APP > strlen(parentName))) {
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateDispatcher(childName, hChildApp, TRUE))) {
+ // LCOV_EXCL_BR_START 200: If FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hChildApp would also be valid.
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ // LCOV_EXCL_BR_STOP
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
+
+ memset(pApp->cParentAppName, 0, sizeof(pApp->cParentAppName));
+ memcpy(pApp->cParentAppName, parentName, strlen(parentName));
+
+ pApp->hParentSndMsgQ = McOpenSender(parentName);
+ if (NULL == pApp->hParentSndMsgQ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "McOpenSender is NULL");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ return eStatus;
+ }
+ pApp->uiSessionId = THREAD_SESSION_ID;
+ } else {
+ // LCOV_EXCL_START 200: If FrameworkunifiedCreateDispatcher return eFrameworkunifiedStatusOK, hChildApp would also be valid.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hChildApp is NULL");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateDispatcher error, status=%d", eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid parameter received");
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedJoinChild
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedJoinChild(HANDLE hChildApp) {
+ return McJoinChild(hChildApp);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetChildThreadPriority
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio) {
+ return McGetChildThreadPriority(hChildApp, threadPrio);
+}
+
+EFrameworkunifiedStatus RunChildDispatcher(HANDLE hChildApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int efd;
+ // LCOV_EXCL_BR_START 6: RunChildDispatcher is a internal function, hChildApp would checked in child_thread_proc.
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ // LCOV_EXCL_BR_STOP
+#ifdef DISPATCHER_PROFILER
+ // Get the application handle
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
+ if (TRUE == FrameworkunifiedMsgProfiler::m_bMsgProfilerEnabled) {
+ pApp->m_pFrameworkunifiedMsgProfiler = new(std::nothrow) FrameworkunifiedMsgProfiler(FrameworkunifiedGetAppName(hChildApp));
+ if (NULL != pApp->m_pFrameworkunifiedMsgProfiler) {
+ FrameworkunifiedAttachChildMsgProfilerCallbacksDispatcher(hChildApp);
+ }
+ }
+#endif
+ FrameworkunifiedGetDispatcherFD(hChildApp, &efd);
+
+ while (eFrameworkunifiedStatusExit != l_eStatus) {
+ l_eStatus = frameworkunifiedFdHandler(hChildApp, efd);
+ }
+ } else {
+ // LCOV_EXCL_START 6: RunChildDispatcher is a internal function, hChildApp would checked in child_thread_proc.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp
new file mode 100644
index 00000000..dccffa8c
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_service_if.cpp
@@ -0,0 +1,128 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_service_if.h>
+#include <string>
+//////////////////////////////////////////
+/// Function : CFrameworkunifiedServiceInterface
+//////////////////////////////////////////
+CFrameworkunifiedServiceInterface::CFrameworkunifiedServiceInterface() {
+}
+//////////////////////////////////////////
+/// Function : ~CFrameworkunifiedServiceInterface
+//////////////////////////////////////////
+CFrameworkunifiedServiceInterface::~CFrameworkunifiedServiceInterface() {
+}
+//////////////////////////////////////////
+/// Function : OpenService
+//////////////////////////////////////////
+HANDLE CFrameworkunifiedServiceInterface::OpenService(const HANDLE f_hApp, std::string f_sServiceName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ HANDLE l_hService = NULL;
+ if (NULL == (l_hService = FrameworkunifiedOpenService(f_hApp, f_sServiceName.c_str()))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Failed to open Service [%s]", f_sServiceName.c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_hService;
+}
+//////////////////////////////////////////
+/// Function : CloseService
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseService(const HANDLE f_hApp, const HANDLE f_hService) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ if ((NULL == f_hApp) || (NULL == f_hService)) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseService(f_hApp, f_hService))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "CloseService Failed");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : OpenSession
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::OpenSession(const HANDLE f_hApp, UI_32 f_uisessionType) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ if (NULL == f_hApp) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ l_eStatus = FrameworkunifiedOpenSessionWithData(f_hApp, (PVOID)&f_uisessionType, sizeof(UI_32));
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOpenSession Failed, eFrameworkunifiedStatusOK = 0x%x, l_eStatus = 0x%x", eFrameworkunifiedStatusOK,
+ l_eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : OpenSessionAcknowledge
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::OpenSessionAcknowledge(const HANDLE f_hApp, HANDLE &hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : CloseSession
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseSession(const HANDLE f_hService, const HANDLE f_hSession) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ if ((NULL == f_hService) || (NULL == f_hSession)) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(f_hService, f_hSession))) {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Failed to send session close request");
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS__CWORD77_, __FUNCTION__, " Session close request sent successfully");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : CloseSessionAcknowledge
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedServiceInterface::CloseSessionAcknowledge(const HANDLE hClient) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseAck;
+ if (NULL == hClient) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hClient, &tCloseAck, sizeof(tCloseAck)))) {
+ l_eStatus = tCloseAck.eStatus;
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR,
+ __FUNCTION__,
+ "Failed to get message data:%x", l_eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp
new file mode 100644
index 00000000..88b5c501
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_thread_priority.cpp
@@ -0,0 +1,156 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+/// \brief <INSERT INFO HERE>.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+#include <stdlib.h>
+#include <string.h>
+
+#include <native_service/frameworkunified_thread_priority.h>
+#include <native_service/ns_logger_if.h>
+
+#include <string>
+
+char *priopts[] = {
+#define THREAD 0
+ const_cast<PSTR>("thrd"),
+ NULL
+};
+
+namespace frameworkunified {
+namespace framework {
+
+CFrameworkunifiedThreadPriorities::TThreadPriorityList CFrameworkunifiedThreadPriorities::ms_mapThreadPritories;
+
+//////////////////////////////////////////
+// Constructor
+//////////////////////////////////////////
+CFrameworkunifiedThreadPriorities::CFrameworkunifiedThreadPriorities() { // LCOV_EXCL_START 200:only use static function of this class
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Destructor
+//////////////////////////////////////////
+CFrameworkunifiedThreadPriorities::~CFrameworkunifiedThreadPriorities() { // LCOV_EXCL_START 200:only use static function of this class
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// GetPriority
+//////////////////////////////////////////
+SI_32 CFrameworkunifiedThreadPriorities::GetPriority(const std::string &f_cThreadName) {
+ SI_32 l_si32Prio = FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND;
+ ThreadPrioMapIter iter = ms_mapThreadPritories.find(f_cThreadName);
+ if (iter != ms_mapThreadPritories.end() && (FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND == l_si32Prio)) {
+ l_si32Prio = iter->second;
+ }
+
+ return l_si32Prio;
+}
+
+//////////////////////////////////////////
+// AddPriority
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedThreadPriorities::AddPriority(const std::string &f_cThreadName, SI_32 f_si32Priority) {
+ ms_mapThreadPritories[f_cThreadName] = f_si32Priority;
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// PrintPriorites
+//////////////////////////////////////////
+VOID CFrameworkunifiedThreadPriorities::PrintPriorites() { // LCOV_EXCL_START 7: debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ ThreadPrioMapIter iter = ms_mapThreadPritories.begin();
+ for (; iter != ms_mapThreadPritories.end(); iter++) {
+ std::string name = iter->first;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Thread name: %s Priority: %d", name.data(), iter->second);
+ }
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// ParseThreadArguments
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedThreadPriorities::ParseThreadArguments(PCHAR f_cArgumentValue) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ PCHAR l_cData = NULL;
+ PSTR l_cOptions;
+ PSTR l_cValue;
+ PCHAR saveptr;
+
+ if (NULL != f_cArgumentValue) {
+ l_cOptions = f_cArgumentValue;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "args of -p: %s", l_cOptions); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ while (*l_cOptions != '\0' && (eFrameworkunifiedStatusOK == l_eStatus)) {
+ switch (getsubopt(&l_cOptions, priopts, &l_cValue)) {
+ case THREAD: {
+ if (l_cValue == NULL) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ std::string l_cName("");
+ std::string l_cPriority(""); // LCOV_EXCL_BR_LINE 11: except branch
+ int at = static_cast<int>(frameworkunified::framework::args::name);
+
+ l_cData = strtok_r(l_cValue, ":", &saveptr); // NOLINT (readability/nolint)
+ while (NULL != l_cData) {
+ switch (at) {
+ case frameworkunified::framework::args::name:
+ l_cName = l_cData;
+ break;
+ case frameworkunified::framework::args::priority:
+ l_cPriority = l_cData;
+ break;
+ default:
+ break;
+ }
+
+ if (!l_cName.empty() && !l_cPriority.empty()) {
+ frameworkunified::framework::CFrameworkunifiedThreadPriorities::AddPriority(l_cName, atoi(l_cPriority.data()));
+ at = static_cast<int>(frameworkunified::framework::args::name);
+ l_cName.clear();
+ l_cPriority.clear();
+ } else {
+ at++;
+ }
+
+ l_cData = strtok_r(NULL, ":", &saveptr); // NOLINT (readability/nolint)
+ }
+ }
+ break;
+ }
+ default: {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ }
+ }
+ }
+ return l_eStatus;
+}
+
+} // namespace framework
+}; // namespace frameworkunified
+/// EOF
+
+
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp
new file mode 100644
index 00000000..0663b858
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/frameworkunified_timer.cpp
@@ -0,0 +1,67 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <native_service/frameworkunified_timer.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_timer_if.h>
+#include "frameworkunified_framework_core.h"
+
+const UI_32 TIMER_CALLBACK_CMD_ID = 42; // The answer to life, the universe, and everything
+const PCSTR TIMER_SERVICE_NAME = "TIMER";
+
+
+HANDLE FrameworkunifiedAttachTimerCallback(HANDLE hApp, UI_32 initMS, UI_32 repeatMS, CbFuncPtr CbFn) {
+ HANDLE timer = NULL;
+
+ if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != CbFn)) {
+ FrameworkunifiedAttachCallbackToDispatcher(hApp, TIMER_SERVICE_NAME, TIMER_CALLBACK_CMD_ID, CbFn);
+
+ CFrameworkunifiedFrameworkApp *pApp = const_cast<CFrameworkunifiedFrameworkApp *>(reinterpret_cast<const CFrameworkunifiedFrameworkApp *>(hApp));
+ NSTimerInfo ti = { WholeSeconds(initMS),
+ MSToNS(RemainderMs(initMS)),
+ TIMER_CALLBACK_CMD_ID,
+ WholeSeconds(repeatMS),
+ MSToNS(RemainderMs(repeatMS))
+ };
+ timer = NS_TimerCreate(ti, CALLBACK_MESSAGE, pApp->hAppSndMsgQ);
+ }
+
+ return timer;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedDetachTimerCallback(HANDLE hApp, HANDLE hTimer) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != hTimer) {
+ EFrameworkunifiedStatus sDel = NS_TimerDelete(hTimer);
+ hTimer = NULL;
+
+ EFrameworkunifiedStatus sDet = FrameworkunifiedDetachCallbackFromDispatcher(hApp,
+ TIMER_SERVICE_NAME,
+ TIMER_CALLBACK_CMD_ID);
+
+ // out of coverage
+ // Since the above frameworkunifiedCheckValidAppHandle(hApp) && NULL != hTimer have been confirmed,
+ // the condition will not be satisfied.
+ if (eFrameworkunifiedStatusOK != sDel || eFrameworkunifiedStatusOK != sDet) {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..025ec700
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/makefile_PosixBasedOS001
@@ -0,0 +1,214 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_FrameworkCore
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_FrameworkCore
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS += -D DISPATCHER_PROFILER
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_MessageQueue/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_UtilityCenter/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc/statemachine \
+ $(DEPENDS_INCLUDES) \
+
+# Libraries should be exported to the Domain Root. However if there is a
+# local static library (3rd Party) go ahead and add it here.
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+ $(wildcard statemachine/*.cpp)
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+# assuming all objects should be included in the library.
+ALL_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(notdir $(basename $(NON_LOCAL_SRCS) )) ) ) \
+ $(OBJECTS)
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/native/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/framework/*.h) \
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+ifdef DYNAMIC
+ DYNAMIC_LIBS += \
+ NS_MessageCenter$(DEBUG_EXT) \
+ NS_ConfigParser$(DEBUG_EXT) \
+ NS_NPServiceIf$(DEBUG_EXT) \
+ NS_Timer$(DEBUG_EXT)
+else
+ STATIC_LIBS +=
+endif
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS) $(ALL_OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+ $(MAKE) -C statemachine $(MAKECMDGOALS)
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(ALL_OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp
new file mode 100644
index 00000000..0cb4d670
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_action.cpp
@@ -0,0 +1,32 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+/// This file has class declaration of the CFrameworkunifiedAction. This is an interface class that defines
+/// interfaces for implementing action
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_action.h>
+#include <string>
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedAction
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedAction::CFrameworkunifiedAction(std::string f_strName): m_strName(f_strName) {
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp
new file mode 100644
index 00000000..d975e930
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_compositestate.cpp
@@ -0,0 +1,371 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedCompositeState class definitions. CFrameworkunifiedCompositeState is derived from C
+/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Composite
+/// state. It provides the standard interfaces for adding state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_compositestate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <native_service/frameworkunified_sm_historystate.h>
+
+#include <sstream>
+#include <string>
+#include <map>
+#include <utility>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedCompositeState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedCompositeState::CFrameworkunifiedCompositeState(std::string f_pName): CFrameworkunifiedState(f_pName) {
+ try {
+ // ChildState map stores the pointers to sub state, key is state name
+ m_pChildStates = new ChildStateList();
+
+ m_pDefaultState = NULL;
+
+ m_pActiveState = NULL;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed in %s state ", f_pName.c_str());
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedCompositeState::~CFrameworkunifiedCompositeState() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedCompositeState destructor");
+ StateIterator l_objStateIterator;
+ try {
+ CHKNULL(m_pChildStates);
+
+ // Deleting the States
+ for (l_objStateIterator = m_pChildStates->begin();
+ l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " deleting the state %s in state %s ",
+ (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->m_strStateName.c_str(),
+ m_strStateName.c_str());
+
+ CHKNULL((*l_objStateIterator).second);
+
+ delete(*l_objStateIterator).second;
+ (*l_objStateIterator).second = NULL;
+ }
+ m_pChildStates->clear();
+ delete m_pChildStates;
+ m_pChildStates = NULL;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to delete state %s",
+ ((reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->m_strStateName).c_str());
+ }
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAddState
+/// sets the given state as a substate of the current state. If the f_eStateType is
+/// eFrameworkunifiedDefaultState then substate is default state for current state.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedAddState(CFrameworkunifiedState *f_pState,
+ FRAMEWORKUNIFIED_STATE_TYPE f_eStateType) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ std::map<std::string, CFrameworkunifiedState *>::iterator l_itChildStates;
+ CFrameworkunifiedHistoryState *l_pHistoryState = NULL;
+ try {
+ CHKNULL(f_pState);
+
+ CHKNULL(m_pChildStates);
+
+ // Set current state as the parent state of given state object
+ f_pState->m_pParentState = this;
+
+ // if given state is default state then set it as the default and active state of parent
+ // state
+ if (eFrameworkunifiedDefaultState == f_eStateType) {
+ m_pDefaultState = f_pState;
+ m_pActiveState = f_pState;
+
+ // set default shallow history state
+ l_itChildStates = m_pChildStates->find(SHALLOWHISTORYSTATE);
+ if (m_pChildStates->end() != l_itChildStates) {
+ l_pHistoryState = static_cast<CFrameworkunifiedHistoryState *>((*l_itChildStates).second);
+ CHKNULL(l_pHistoryState);
+ eStatus = l_pHistoryState->SetDefaultHistory();
+ }
+
+ // set default deep history state
+ l_itChildStates = m_pChildStates->find(DEEPHISTORYSTATE);
+ if (m_pChildStates->end() != l_itChildStates) {
+ l_pHistoryState = static_cast<CFrameworkunifiedHistoryState *>((*l_itChildStates).second);
+ CHKNULL(l_pHistoryState);
+ eStatus = l_pHistoryState->SetDefaultHistory();
+ }
+ }
+
+ // Insert the state in the map with key as state name
+ m_pChildStates->insert(std::pair<std::string, CFrameworkunifiedState *>(f_pState->m_strStateName, f_pState));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " %s state added in the state %s "
+ , (f_pState->m_strStateName).c_str(), (this->m_strStateName).c_str());
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add state %s",
+ f_pState->m_strStateName.c_str());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetDefaultState
+/// Returns the default state of the current composite state.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedCompositeState::FrameworkunifiedGetDefaultState() {
+ return m_pDefaultState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPrintStates
+/// This logs the state name and events associated with the state
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedPrintStates() {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ StateIterator l_objStateIterator;
+ EventReactionIterator l_objEventIterator;
+ try {
+ CHKNULL(m_pEventList);
+
+ if (m_pParentState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s",
+ (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "NULL:%s", m_strStateName.c_str());
+ }
+
+ // print event
+ for (l_objEventIterator = m_pEventList->begin();
+ l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "event %d %s", ((*l_objEventIterator).first),
+ (m_pEventName->find((*l_objEventIterator).first)->second).c_str());
+ }
+ CHKNULL(m_pDeferredEventList);
+ // print deferred events
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s", m_pDeferredEventList->at(l_uiCount),
+ (m_pEventName->find(m_pDeferredEventList->at(l_uiCount))->second).c_str());
+ }
+ CHKNULL(m_pChildStates);
+ // print states
+ for (l_objStateIterator = m_pChildStates->begin();
+ l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
+ (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedPrintStates();
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s",
+ m_strStateName.c_str());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedHasSubStates
+/// This indicates if the state has sub states. It returns TRUE only in the CompositeState
+/// where this function is overridden
+///////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFrameworkunifiedCompositeState::FrameworkunifiedHasSubStates() {
+ return TRUE;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedCompositeState::FrameworkunifiedGetActiveState() {
+ CFrameworkunifiedState *l_pActiveState = NULL;
+ if (NULL != m_pActiveState) {
+ l_pActiveState = m_pActiveState->FrameworkunifiedGetActiveState();
+ } else {
+ l_pActiveState = this;
+ }
+ return l_pActiveState;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ StateIterator l_objStateIterator;
+ try {
+ CHKNULL(f_pStatemachine);
+ // iterate child states
+ for (l_objStateIterator = m_pChildStates->begin();
+ l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
+ (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedSetHSM(f_pStatemachine);
+ }
+ m_pStateMachine = f_pStatemachine;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EventReactionIterator l_objEventIterator;
+ StateIterator l_objStateIterator;
+ try {
+ CHKNULL(m_pEventList);
+ CHKNULL(m_pEventName);
+ CHKNULL(m_pDeferredEventList);
+
+ f_strXMLString << "<" << m_strStateName.c_str() << ">";
+
+ CHKNULL(m_pChildStates);
+ f_strXMLString << "<ChildStates>";
+ // print states
+ for (l_objStateIterator = m_pChildStates->begin();
+ l_objStateIterator != m_pChildStates->end(); l_objStateIterator++) {
+ (reinterpret_cast<CFrameworkunifiedState *>((*l_objStateIterator).second))->FrameworkunifiedPrintXML(f_strXMLString);
+ }
+
+ f_strXMLString << "</ChildStates>";
+
+ f_strXMLString << "<EventList>";
+ // print events
+ for (l_objEventIterator = m_pEventList->begin();
+ l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
+ std::string l_strEventName =
+ (m_pEventName->find((*l_objEventIterator).first)->second);
+
+ UI_32 l_uiEventId = (*l_objEventIterator).first;
+
+ f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
+
+ f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
+
+ f_strXMLString << "</Event>";
+ }
+ f_strXMLString << "</EventList>";
+
+ // print deferred events
+ f_strXMLString << "<DeferredEventList>";
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
+ UI_32 l_uiEventId = m_pDeferredEventList->at(l_uiCount);
+
+ std::string l_strEventName = (m_pEventName->find(l_uiEventId)->second);
+
+ f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
+
+ f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
+
+ f_strXMLString << "</Event>";
+ }
+
+ f_strXMLString << "</DeferredEventList>";
+ f_strXMLString << "</" << m_strStateName.c_str() << ">";
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateHistory
+/// This function stores the last active state
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::UpdateHistory() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // update shallow history state
+ l_eStatus = CheckHistory(SHALLOWHISTORYSTATE);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s Shallow History Update Failed", m_strStateName.c_str());
+ return l_eStatus;
+ }
+
+ // update deep history state
+ l_eStatus = CheckHistory(DEEPHISTORYSTATE);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s Deep History Update Failed", m_strStateName.c_str());
+ return l_eStatus;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CheckHistory
+/// This function searches for history state in this composite state and updates it.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedCompositeState::CheckHistory(std::string l_cHistoryType) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(m_pChildStates);
+
+ CFrameworkunifiedState *l_pHistoryState = NULL;
+
+ std::map<std::string, CFrameworkunifiedState *>::iterator l_itChildStates;
+
+ // update history state
+ l_itChildStates = m_pChildStates->find(l_cHistoryType);
+
+ if (m_pChildStates->end() != l_itChildStates) {
+ l_pHistoryState = (*l_itChildStates).second;
+ CHKNULL(l_pHistoryState);
+ l_eStatus = l_pHistoryState->UpdateHistory();
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp
new file mode 100644
index 00000000..6f273190
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_conditionconnector.cpp
@@ -0,0 +1,152 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has class definition of the CFrameworkunifiedConditionConnector. This class is responsible for
+/// implementing interfaces required to use condition connector in statemachine.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_conditionconnector.h>
+#include <native_service/frameworkunified_sm_state.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_guard.h>
+
+#include <vector>
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedConditionConnector
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedConditionConnector::CFrameworkunifiedConditionConnector(std::string f_strName): CFrameworkunifiedExternalTransition(NULL),
+ m_strName(f_strName) {
+ // Create the condition list
+ m_pConditionList = new std::vector<CCondition * >();
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedConditionConnector
+/// destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedConditionConnector::~CFrameworkunifiedConditionConnector() {
+ if (m_pConditionList) {
+ TConditionIterator l_itConditionList = m_pConditionList->begin();
+
+ while (m_pConditionList->end() != l_itConditionList) {
+ delete *l_itConditionList;
+ l_itConditionList++;
+ }
+ // clear condition list
+ m_pConditionList->clear();
+ delete m_pConditionList;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CCondition
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedConditionConnector::CCondition::CCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState)
+ : m_pGuard(f_pGuard), m_pTargetState(f_pTargetState) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedReaction
+/// This API evaluates the guards added in the condition list. If the guard is evaluated as
+/// true then statemachine transitions to target state associated with guard.
+//////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedConditionConnector::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
+ CFrameworkunifiedState *l_pActiveState = NULL;
+ BOOL l_bAllowTransition = FALSE;
+ try {
+ CHKNULL(f_pSourceState);
+ CHKNULL(m_pConditionList);
+ TConditionIterator l_itConditionList
+ = m_pConditionList->begin();
+
+ // iterate condition list and set the target state
+ while (m_pConditionList->end() != l_itConditionList) {
+ CCondition *l_pCondition = *l_itConditionList;
+ CHKNULL(l_pCondition);
+
+ CFrameworkunifiedGuard *l_pGuard = l_pCondition->m_pGuard;
+ CFrameworkunifiedState *l_pTargetState = l_pCondition->m_pTargetState;
+
+ CHKNULL(l_pGuard);
+ CHKNULL(l_pTargetState);
+
+ if (l_pGuard->FrameworkunifiedEvaluate()) {
+ m_pTargetState = l_pTargetState;
+ l_bAllowTransition = TRUE;
+ break;
+ }
+ l_itConditionList++;
+ }
+
+ if (l_bAllowTransition) {
+ // Transition to target state
+ l_pActiveState = ExecuteTransition(f_pSourceState, f_pData);
+
+ } else {
+ // No state changed
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__,
+ "Guard condition for External Transition from state %s to condition connector %s failed",
+ f_pSourceState->m_strStateName.c_str(), m_strName.c_str());
+
+ l_pActiveState = f_pSourceState;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+ return l_pActiveState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAddCondition
+/// Adds condition to condition list
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedConditionConnector::FrameworkunifiedAddCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState) {
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pConditionList);
+ CHKNULL(f_pGuard);
+ CHKNULL(f_pTargetState);
+
+ CCondition *l_pCondition = new CCondition(f_pGuard, f_pTargetState);
+
+ m_pConditionList->push_back(l_pCondition);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+
+ return l_eFrameworkunifiedStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp
new file mode 100644
index 00000000..baac0d46
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_deephistorystate.cpp
@@ -0,0 +1,79 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedDeepHistoryState class definitions. CFrameworkunifiedDeepHistoryState is derived
+/// from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported by
+/// HSM DeepHistory state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_deephistorystate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <string>
+
+// define static members of class
+const UI_32 CFrameworkunifiedDeepHistoryState::m_suievDeepHistory = 72;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedDeepHistoryState
+/// Parameterized constructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedDeepHistoryState::CFrameworkunifiedDeepHistoryState(std::string f_pName): CFrameworkunifiedHistoryState(f_pName) {
+ m_uiEventId = m_suievDeepHistory;
+ m_cEventName = "evDeepHistory";
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedDeepHistoryState
+/// Class destructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedDeepHistoryState::~CFrameworkunifiedDeepHistoryState() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedDeepHistoryState destructor");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateHistory
+/// This function stores the last active state
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedDeepHistoryState::UpdateHistory() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ CFrameworkunifiedState *l_pActiveState = NULL;
+
+ try {
+ CHKNULL(m_pParentState);
+ l_pActiveState = m_pParentState->m_pActiveState;
+
+ while (NULL != l_pActiveState) {
+ m_pLastActiveState = l_pActiveState;
+ l_pActiveState = l_pActiveState->m_pActiveState;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp
new file mode 100644
index 00000000..a73408a8
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_dispatcher.cpp
@@ -0,0 +1,240 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <pthread.h>
+
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/frameworkunified_sm_hsmframework.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_sm_dispatcher.h>
+
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_error_internal.hpp"
+#include "frameworkunified_sm_framework_core.h"
+#include "frameworkunified_framework_utility.h"
+
+static HSMConfigOptions s_tHSMConfigOptions = {eUserchangeIgnore, TRUE, FALSE};
+
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp);
+//////////////////////////////////////////
+// Function : FrameworkunifiedCreateDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcher(PCSTR cAppName,
+ HANDLE &hFrameworkApp, // NOLINT (readability/nolint)
+ BOOL bIsThread, CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != cAppName) {
+ if (eFrameworkunifiedStatusOK == (eStatus = CreateDispatcher(cAppName, hFrameworkApp, bIsThread))) {
+ if (NULL != hFrameworkApp) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hFrameworkApp);
+
+ if (NULL != f_pFrameworkunifiedHSM) {
+ pApp->m_pFrameworkunifiedStateMachine = f_pFrameworkunifiedHSM;
+ pApp->m_pFrameworkunifiedStateMachine->m_pHApp = pApp;
+ } else {
+ if (bIsThread) {
+ pApp->m_pFrameworkunifiedStateMachine = new CFrameworkunifiedHSMChildFramework(pApp);
+ } else {
+ pApp->m_pFrameworkunifiedStateMachine = new CFrameworkunifiedHSMParentFramework(pApp);
+ }
+ }
+
+ if (NULL != pApp->m_pFrameworkunifiedStateMachine) {
+ pApp->m_pFrameworkunifiedStateMachine->FrameworkunifiedCreate(&s_tHSMConfigOptions);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "CreateDispatcher returned error, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "AppName is NULL");
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDispatcherWithArguments
+/// Creates, initializes and runs the dispatcher
+///
+/// \param [in] cAppname
+/// PCSTR - Application/ thread name
+///
+/// \return Never does, main loop for your application.
+///
+/// \see FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock,
+/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[],
+ const FrameworkunifiedDefaultCallbackHandler *CbHandler, CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM,
+ CustomCommandLineOptions *cmdLineOptions) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (cAppName == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ NsLogSetProcessName(cAppName);
+ PLOG_TEXT("FrameworkunifiedHSMDispatcher Start");
+ // set main thread name as provided in dispatcher
+ pthread_setname_np(pthread_self(), cAppName);
+
+ if ((eStatus = RegistDefaultCbHandler(CbHandler)) != eFrameworkunifiedStatusOK) {
+ return eStatus;
+ }
+
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_DIS, __FUNCTION__, "In"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ try {
+ HANDLE hFrameworkApp = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcher(cAppName, hFrameworkApp, FALSE, f_pFrameworkunifiedHSM))) {
+ if (NULL != hFrameworkApp) {
+ THApp hApp(hFrameworkApp);
+
+ /// Parse the Arguments via the FrameworkunifiedArgumentParser
+ /// passing an handle to the app and argument list
+ eStatus = FrameworkunifiedArgumentParser(hApp, argc, argv, cmdLineOptions);
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ eStatus = FrameworkunifiedHSMDispatcherMain(hApp);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcher error, status=%d", eStatus);
+ }
+ } catch (const THApp::Exception &) {
+ /**
+ * @todo
+ * When an exception error occurs in a FrameworkunifiedCreateHSMDispatcher,
+ * the caller cannot detect the exception because the exception becomes the eFrameworkunifiedStatusOK return code.
+ */
+ FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedHSMCreateDispatcher ");
+ }
+
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function : FrameworkunifiedHSMDispatcherMain
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherMain(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "Success: FrameworkunifiedCreateDispatcher ");
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ CFrameworkunifiedHSMFramework *l_pStateMachine = pApp->m_pFrameworkunifiedStateMachine;
+
+ if (l_pStateMachine) {
+ eStatus = l_pStateMachine->FrameworkunifiedStart();
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedOnInitialization failed ");
+ l_pStateMachine->FrameworkunifiedClose();
+ throw happ_error();
+ } else {
+ eStatus = RunDispatcher(hApp);
+ }
+
+ l_pStateMachine->FrameworkunifiedClose();
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "l_pStateMachine is NULL");
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ } catch (const frameworkunified::framework::error::CSystemError &err) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :: %s", err.what());
+
+ FrameworkunifiedSendSystemErrMessage(hApp, err.m_eSystemError);
+ } catch (const THApp::Exception &) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to FrameworkunifiedCreateDispatcher ");
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function : FrameworkunifiedSetHSMType
+////////////////////////////////////////////////////////////////////////////////////////////
+void FrameworkunifiedSetHSMType(EUserChangeOptions f_eHSMType) {
+ s_tHSMConfigOptions.eUserChange = f_eHSMType;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function : FrameworkunifiedEnableAutoPublishServiceAvailable
+////////////////////////////////////////////////////////////////////////////////////////////
+void FrameworkunifiedEnableAutoPublishServiceAvailable() {
+ s_tHSMConfigOptions.bAutoPublishServiceAvaialble = TRUE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function : FrameworkunifiedDisableAutoPublishServiceAvailable
+////////////////////////////////////////////////////////////////////////////////////////////
+void FrameworkunifiedDisableAutoPublishServiceAvailable() {
+ s_tHSMConfigOptions.bAutoPublishServiceAvaialble = FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function : FrameworkunifiedIsAutoPublishServiceAvailableEnabled
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsAutoPublishServiceAvailableEnabled() {
+ return s_tHSMConfigOptions.bAutoPublishServiceAvaialble;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedHSMEnableWaitInStoppingState
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID FrameworkunifiedHSMEnableWaitInStoppingState() {
+ s_tHSMConfigOptions.bWaitInStoppingState = TRUE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedHSMDisableWaitInStoppingState
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID FrameworkunifiedHSMDisableWaitInStoppingState() {
+ s_tHSMConfigOptions.bWaitInStoppingState = FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedIsWaitInStoppingStateEnabled
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsWaitInStoppingStateEnabled() {
+ return s_tHSMConfigOptions.bWaitInStoppingState;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp
new file mode 100644
index 00000000..294dcf55
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_externaltransition.cpp
@@ -0,0 +1,225 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
+/// from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
+/// from one state to another state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_externaltransition.h>
+#include <native_service/frameworkunified_sm_state.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_guard.h>
+#include <native_service/frameworkunified_sm_action.h>
+#include <vector>
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) {
+ m_pGuard = NULL;
+
+ // Create the condition list
+ m_pActionList = new std::vector<CFrameworkunifiedAction * >(); // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedExternalTransition::~CFrameworkunifiedExternalTransition() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+ if (m_pActionList) {
+ TActionListIterator l_itActionList = m_pActionList->begin();
+
+ while (m_pActionList->end() != l_itActionList) {
+ if (NULL != *l_itActionList) {
+ delete *l_itActionList;
+ *l_itActionList = NULL;
+ }
+ l_itActionList++;
+ }
+ // clear condition list
+ m_pActionList->clear();
+ delete m_pActionList;
+ m_pActionList = NULL;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedReaction
+/// The reaction for an event is implemented in this function. For external transition, Exit
+/// of the source state is called and entry of the target state is called recursively.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedExternalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
+ CFrameworkunifiedState *l_pActiveState = NULL;
+ BOOL l_bAllowTransition = FALSE;
+
+ try {
+ CHKNULL(f_pSourceState);
+ CHKNULL(m_pTargetState);
+
+ // Check if External transition has Guard condition
+ if (m_pGuard) {
+ // Evaluate guard condition
+ l_bAllowTransition = m_pGuard->FrameworkunifiedEvaluate();
+ } else {
+ // If Guard is not available then allow transition
+ l_bAllowTransition = TRUE;
+ }
+
+ if (l_bAllowTransition) {
+ l_pActiveState = ExecuteTransition(f_pSourceState, f_pData); // LCOV_EXCL_BR_LINE 11:except branch
+
+ } else {
+ // No state changed
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Guard condition for External Transition "
+ "from state %s to state %s failed"
+ , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
+
+ l_pActiveState = f_pSourceState;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pActiveState;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedExternalTransition::FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard) {
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pGuard);
+ m_pGuard = f_pGuard;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eFrameworkunifiedStatus;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedExternalTransition::ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
+ CFrameworkunifiedState *l_pActiveState = NULL;
+ try {
+ CHKNULL(m_pTargetState);
+ CHKNULL(f_pSourceState);
+ CFrameworkunifiedState *l_pTargetState = m_pTargetState;
+ CFrameworkunifiedState *l_pCurrentState = f_pSourceState;
+
+
+
+
+ // Find the common parent of the source and target state
+ // and then call recursively OnExit on source state and
+ // OnEntry on parent state
+ BOOL l_bFoundCommonParent = FALSE;
+ while (l_pCurrentState->m_pParentState) {
+ while (l_pTargetState->m_pParentState) {
+ // Check if current source state and target state has common parent
+ if (l_pCurrentState->m_pParentState == l_pTargetState->m_pParentState) {
+ l_bFoundCommonParent = TRUE;
+ break;
+ } else {
+ // Set the next target parent state
+ l_pTargetState = l_pTargetState->m_pParentState;
+ }
+ }
+
+ if (l_bFoundCommonParent) {
+ break;
+ } else {
+ // Set the next source parent state
+ l_pCurrentState = l_pCurrentState->m_pParentState;
+ l_pTargetState = m_pTargetState;
+ }
+ }
+
+ if (l_bFoundCommonParent) {
+ // recursively execute the exit on the current state
+ l_pCurrentState->FrameworkunifiedOnHSMStop(f_pData);
+
+ // execute actions associated with the external transition
+ CHKNULL(m_pActionList);
+ TActionListIterator l_itActionList = m_pActionList->begin();
+
+ // iterate action list and execute actions
+ while (m_pActionList->end() != l_itActionList) {
+ CFrameworkunifiedAction *l_pAction = *l_itActionList;
+ CHKNULL(l_pAction);
+
+ l_pAction->FrameworkunifiedAction(f_pSourceState, l_pTargetState, f_pData);
+
+ l_itActionList++;
+ }
+
+ // Set the target state as a active state
+ CFrameworkunifiedState *l_pState = m_pTargetState;
+ while (l_pState->m_pParentState != l_pTargetState->m_pParentState) {
+ CHKNULL(l_pState->m_pParentState);
+
+ l_pState->m_pParentState->m_pActiveState = l_pState;
+ l_pState = l_pState->m_pParentState;
+ }
+
+
+ // recursively execute the entry on the target state
+ l_pActiveState = l_pTargetState->FrameworkunifiedOnHSMStart(f_pData);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "External Transition from state %s to state %s"
+ , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "External Transition from state %s to state %s failed"
+ , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
+ return NULL;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+
+ return l_pActiveState;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedExternalTransition::FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction) {
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pActionList);
+
+ CHKNULL(f_pAction);
+
+ m_pActionList->push_back(f_pAction);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eFrameworkunifiedStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp
new file mode 100644
index 00000000..8b361fa4
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_finalstate.cpp
@@ -0,0 +1,79 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedFinalState class definitions. CFrameworkunifiedFinalState is derived from C
+/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Final
+/// state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <string>
+#include "frameworkunified_sm_finalstate.h"
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedFinalState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedFinalState::~CFrameworkunifiedFinalState() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "CFrameworkunifiedFinalState destructor");
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedFinalState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedFinalState::CFrameworkunifiedFinalState(std::string f_pName): CFrameworkunifiedState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedFinalState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedFinalState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedFinalState::FrameworkunifiedGetActiveState() {
+ return this;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateHistory
+/// This function stores the last active state
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedFinalState::UpdateHistory() {
+ return eFrameworkunifiedStatusOK;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp
new file mode 100644
index 00000000..dfb2d5cd
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_framework_dispatch.cpp
@@ -0,0 +1,485 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_logger_if.h>
+#include <map>
+#include <utility>
+#include "frameworkunified_framework_core.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Registers a single event with the dispatcher for a given service.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventToDispatcher(HANDLE hApp,
+ PCSTR pServiceName,
+ UI_32 iCmd,
+ UI_32 iEvent,
+ HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ EventServices::iterator s_iterator;
+ EventSessionTable::iterator session_iterator;
+
+ UI_32 uiSessionId = 0;
+ if (hSession) {
+ uiSessionId = FrameworkunifiedGetSessionId(hSession);
+ }
+
+ // finding the service
+ s_iterator = pApp->eventservices.find(pServiceName);
+ if (s_iterator == pApp->eventservices.end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (service NOT found): service name [%s]", pApp->cAppName, pServiceName);
+ pApp->eventservices.insert(std::make_pair(pServiceName, EventSessionTable()));
+ }
+
+ session_iterator = pApp->eventservices[pServiceName].find(uiSessionId);
+ if (session_iterator == pApp->eventservices[pServiceName].end()) {
+ pApp->eventservices[pServiceName].insert
+ (std::make_pair(uiSessionId, ServiceEventProtocolTable()));
+ }
+
+ (pApp->eventservices[pServiceName].find(uiSessionId)->second).insert(std::make_pair(iCmd, iEvent));
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachHSMEventsToDispatcher
+/// Registers a multiple event with the dispatcher for a given service.
+////////////////////////////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventsToDispatcher(HANDLE hApp, PCSTR pServiceName,
+ const FrameworkunifiedProtocolEvent *pEventIds, UI_32 uiEventCount, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName && pEventIds) {
+ // setup callbacks
+ for (UI_32 i = 0; i < uiEventCount; ++i) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(hApp,
+ pServiceName,
+ pEventIds[ i ].iCmd,
+ pEventIds[ i ].iEventId,
+ hSession))) {
+ break;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedAttachParentCallbacksToDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachParentHSMEventsToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolEvent *pEventIds,
+ UI_32 uiEventCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
+
+ eStatus = FrameworkunifiedAttachHSMEventsToDispatcher(hChildApp, pApp->cParentAppName, pEventIds, uiEventCount);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachParentCallbacksFromDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachParentHSMEventsFromDispatcher(HANDLE hChildApp,
+ const PUI_32 puiEventArray, UI_32 uiEventCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hChildApp);
+
+ eStatus = FrameworkunifiedDetachHSMEventsFromDispatcher(hChildApp, pApp->cParentAppName, puiEventArray, uiEventCount);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+/////////////////////////////////////////////////////
+// Function : FrameworkunifiedDetachHSMEventsFromDispatcher
+/////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventsFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiEventArray,
+ UI_32 uiEventCount, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) {
+ // setup callbacks
+ for (UI_32 i = 0; i < uiEventCount; ++i) {
+ /**
+ * @todo
+ * When an event-struct pointer is turned NULL, the array is accessed without NULL checking,
+ * and a segmentation fault occurs.
+ */
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachHSMEventFromDispatcher(hApp, pServiceName,
+ puiEventArray[ i ], hSession))) {
+ break;
+ }
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+/////////////////////////////////////////////
+// Function : FrameworkunifiedDetachHSMEventFromDispatcher
+/////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iEvent, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pServiceName) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ EventServices::iterator s_iterator;
+
+ UI_32 uiSessionId = 0;
+ if (hSession) {
+ uiSessionId = FrameworkunifiedGetSessionId(hSession);
+ }
+
+ // finding the service
+ s_iterator = pApp->eventservices.find(pServiceName);
+ if (s_iterator != pApp->eventservices.end()) {
+ EventSessionTable::iterator session_iterator;
+ session_iterator = (s_iterator->second).find(uiSessionId);
+ if (session_iterator != (s_iterator->second).end()) {
+ ServiceEventProtocolTable::iterator spt_iterator;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : (found): service [%s]", pApp->cAppName, pServiceName);
+
+ spt_iterator = (session_iterator->second).find(iEvent);
+ if (spt_iterator != (session_iterator->second).end()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Cmd found [%d] service [%s]",
+ pApp->cAppName, iEvent, pServiceName);
+ (session_iterator->second).erase(spt_iterator);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : Error : Cmd NOT found [%d] service [%s]",
+ pApp->cAppName, iEvent, pServiceName);
+ }
+ }
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find service [%s]", pApp->cAppName, pServiceName);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachNotificationEventsToDispatcher
+/// API to attach a event to the dispatcher on receiving a specific notification.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent,
+ UI_32 uiEventCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyEvent) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ /// Deal with handling batch processing of subscriptions.
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMSubscribeToNotificationsEvents(hApp, pNtfyEvent, uiEventCount))) {
+ for (UI_32 i = 0; i < uiEventCount; ++i) {
+ // service found
+ pApp->notificationevents.insert(std::make_pair(pNtfyEvent[ i ].cNotification, pNtfyEvent[ i ].iEventId));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]", pApp->cAppName,
+ pNtfyEvent[ i ].cNotification);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe "
+ "to batch set of notifications", pApp->cAppName,
+ eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachNotificationEventToDispatcher
+/// API to attach a event to the dispatcher on receiving a specific notification.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification, UI_32 iEventId) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMSubscribeToNotificationEvent(hApp, pNotification))) {
+ // service found
+ pApp->notificationevents.insert(std::make_pair(pNotification, iEventId));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : attaching call-back for notification [%s]",
+ pApp->cAppName, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to Subscribe "
+ "to notification [%s]", pApp->cAppName, eFrameworkunifiedStatusOK, pNotification);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDetachNotificationEventsFromDispatcher
+/// API to detach a notification event from the dispatcher.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent,
+ UI_32 uiEventCount) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNtfyEvent) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ NotificationEventTable::iterator n_iterator;
+ PCSTR pNotification = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(hApp, pNtfyEvent, uiEventCount))) {
+ for (UI_32 l_unCount = 0; l_unCount < uiEventCount; ++l_unCount) {
+ pNotification = pNtfyEvent[ l_unCount ].cNotification;
+ n_iterator = pApp->notificationevents.find(pNotification);
+ if (n_iterator != pApp->notificationevents.end()) {
+ pApp->notificationevents.erase(n_iterator);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]",
+ pApp->cAppName, pNotification);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : detaching call-back for notification [%s]",
+ pApp->cAppName, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notifications ",
+ pApp->cAppName, eFrameworkunifiedStatusOK);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDetachNotificationEventsFromDispatcher
+/// API to detach a notification event from the dispatcher.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ NotificationEventTable::iterator n_iterator;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(hApp, pNotification))) {
+ // \todo : error handling on all map function calls
+ n_iterator = pApp->notificationevents.find(pNotification);
+ if (n_iterator != pApp->notificationevents.end()) {
+ pApp->notificationevents.erase(n_iterator);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_DIS, __FUNCTION__, "%s : removed notification [%s]", pApp->cAppName, pNotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : Cannot find notification [%s]",
+ pApp->cAppName, pNotification);
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "%s : Error : [%d] Unable to UnSubscribe from notification [%s]",
+ pApp->cAppName, eFrameworkunifiedStatusOK, pNotification);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetStateMachine
+/// returns the pointer to the statemachine object
+////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMFramework *FrameworkunifiedGetStateMachine(HANDLE hApp) {
+ CFrameworkunifiedHSMFramework *l_pHSMFramework = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+ l_pHSMFramework = pApp->m_pFrameworkunifiedStateMachine;
+ }
+
+ return l_pHSMFramework;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSetStateMachine
+/// sets the statemachine object
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetStateMachine(HANDLE hApp,
+ CFrameworkunifiedHSM *f_pFrameworkunifiedHSM) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ if (NULL != f_pFrameworkunifiedHSM) {
+ (reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp))->m_pFrameworkunifiedStateMachine =
+ reinterpret_cast<CFrameworkunifiedHSMFramework *>(f_pFrameworkunifiedHSM);
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeToSessionEventWithHSMEvent
+/// This API is used for subscribing to single event of a service.
+/// This API also attaches the session event with HSM events.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithHSMEvent(HANDLE hApp,
+ UI_32 uiEventId,
+ UI_32 uiHSMEventId,
+ HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId,
+ uiHSMEventId, hSession))) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, sizeof(UI_32), (PVOID)&uiEventId);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedAttachCallbackToDispatcher "
+ "for PROTOCOL_REGISTER_EVENTS Failed Status:: %d", eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeToSessionEventsWithHSMEvents
+/// This API is used for subscribing to multiple events of a service.
+/// This API also attaches the session events with hsm events.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithHSMEvents(HANDLE hApp, const FrameworkunifiedProtocolEvent *pEventIds,
+ UI_32 uiEventCount,
+ HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession) && NULL != pEventIds) {
+ eStatus = FrameworkunifiedAttachHSMEventsToDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, pEventIds,
+ uiEventCount, hSession);
+
+ UI_32 l_uiCmdList[uiEventCount]; // NOLINT (readability/nolint)
+ for (UI_32 l_uiCnt = 0; l_uiCnt < uiEventCount; l_uiCnt++) {
+ l_uiCmdList[l_uiCnt] = pEventIds[l_uiCnt].iCmd;
+ }
+
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_REGISTER_EVENTS, static_cast<UI_32>(uiEventCount * sizeof(UI_32)),
+ l_uiCmdList);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeSessionEventWithHSMEvent
+/// API to unsubscribe from event of a service. Also detaches HSM event.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithHSMEvent(HANDLE hApp, UI_32 uiEventId, HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession)) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS, sizeof(uiEventId), (PVOID)&uiEventId);
+
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedDetachHSMEventFromDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, uiEventId, hSession)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents
+/// API to unsubscribe from multiple events of a service. Also detaches HSM events.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents(HANDLE hApp, PUI_32 pEventsArray, UI_32 uiListSize,
+ HANDLE hSession) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && frameworkunifiedCheckValidMsgQ(hSession) && NULL != pEventsArray) {
+ eStatus = FrameworkunifiedSendMsg(hSession, PROTOCOL_UNREGISTER_EVENTS,
+ static_cast<UI_32>(uiListSize * sizeof(uiListSize)), pEventsArray);
+
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedDetachHSMEventsFromDispatcher(hApp,
+ (reinterpret_cast<MsgQInfo *>(hSession))->cMsgQName, pEventsArray,
+ uiListSize)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error : FrameworkunifiedDetachCallbackFromDispatcher failed status:: %d", eStatus);
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp
new file mode 100644
index 00000000..7afabdb6
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_guard.cpp
@@ -0,0 +1,41 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedGuard class definitions. This is an interface that defines the Evaluate
+/// interface for guard condition validation.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_guard.h>
+#include <string>
+CFrameworkunifiedGuard::~CFrameworkunifiedGuard() {
+}
+
+CFrameworkunifiedGuard::CFrameworkunifiedGuard(std::string f_strName): m_strName(f_strName) {
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp
new file mode 100644
index 00000000..96402769
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_historystate.cpp
@@ -0,0 +1,148 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedHistoryState class definitions. CFrameworkunifiedHistoryState is derived from
+/// CFrameworkunifiedState class.This class implements the additional functionality supported by HSM History
+/// state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <native_service/frameworkunified_sm_historystate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedHistoryState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHistoryState::CFrameworkunifiedHistoryState(std::string f_pName): CFrameworkunifiedState(f_pName), m_pLastActiveState(NULL), m_uiEventId(0) { // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedHistoryState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHistoryState::~CFrameworkunifiedHistoryState() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedHistoryState destructor");
+}
+
+CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedGetActiveState() {
+ return this;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHistoryState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ try {
+ CHKNULL(m_pLastActiveState);
+ CHKNULL(m_pEventList);
+
+ CFrameworkunifiedExternalTransition *l_pTrnTargetState = new CFrameworkunifiedExternalTransition(m_pLastActiveState);
+
+ m_pActiveState = l_pTrnTargetState->FrameworkunifiedReaction(this, f_pEventData);
+ CHKNULL(m_pActiveState);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHistoryState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// SetDefaultHistory
+/// This function sets the default active state in history state
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHistoryState::SetDefaultHistory() {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(m_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ m_pLastActiveState = m_pParentState->m_pDefaultState;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus; // LCOV_EXCL_BR_LINE 11: except branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnHSMStart
+/// This function internally calls the Entry function of the current state.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pActiveState = this;
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ // Call Entry method of the current state. Entry method of state is called in the order of
+ // Hierarchy from Outer state to Inner state
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedOnEntry(f_pEventData))) {
+ l_pActiveState = m_pActiveState;
+ } else {
+ // If FrameworkunifiedOnEntry failed then statemachine should report the error
+ // We can throw an exception but for now as a quick fix we are setting
+ // l_pActiveState as NULL which will stop the statemachine
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error:%d in state %s", eStatus,
+ l_pActiveState->m_strStateName.c_str());
+ // l_pActiveState = NULL;
+ /* Commenting it, because it was making state machine inactive. This should not be the expected behavior.
+ * Just log and take no action, if user return non-ok value.
+ * User defined error values should be handled separately */
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pActiveState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnHSMStop
+/// This function internally calls the Exit function of the current state.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedHistoryState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) {
+ return this;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp
new file mode 100644
index 00000000..f6cdb098
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsm.cpp
@@ -0,0 +1,529 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
+/// This class implements interfaces for connecting child states to parent states, connecting events
+/// to state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <native_service/frameworkunified_sm_reaction.h>
+#include <native_service/frameworkunified_sm_state.h>
+#include <native_service/frameworkunified_sm_compositestate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_orthogonalstate.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+#include <cstdio>
+#include <sstream>
+#include <string>
+
+#include "frameworkunified_framework_internal.h"
+#include "frameworkunified_sm_framework_core.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedHSM
+/// Class constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSM::CFrameworkunifiedHSM(PVOID f_pHApp): m_uiCurrentEvent(0), m_pHApp(f_pHApp), m_pActiveState(NULL), m_pRootState(NULL),
+ m_bIsTransitioning(FALSE) {
+ // PostEventList stores the list of events posted in the state
+ m_pPostEventList = new EventInfoList();
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedHSM
+/// Class constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSM::CFrameworkunifiedHSM(): m_uiCurrentEvent(0), m_pHApp(NULL), m_pActiveState(NULL), m_pRootState(NULL),
+ m_bIsTransitioning(FALSE) {
+ // PostEventList stores the list of events posted in the state
+ m_pPostEventList = new EventInfoList();
+ m_pHApp = NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedHSM
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSM::~CFrameworkunifiedHSM() {
+ if (NULL != m_pPostEventList) {
+ delete m_pPostEventList;
+ m_pPostEventList = NULL;
+ }
+
+ if (m_pRootState) {
+ FrameworkunifiedClose();
+ }
+
+ // we are not deleting this pointer because memory pointed by this pointer
+ // had already been deleted in above step.
+ m_pActiveState = NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetActiveState
+/// Returns the active state of the statemachine
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedHSM::FrameworkunifiedGetActiveState() {
+ CFrameworkunifiedState *l_pCurrentState = m_pRootState;
+ CFrameworkunifiedState *l_pActiveState = NULL;
+
+ try {
+ // Iterate till the current state is leafstate or orthogonal state
+ while (l_pCurrentState != l_pActiveState) {
+ l_pActiveState = l_pCurrentState;
+ l_pCurrentState = l_pCurrentState->FrameworkunifiedGetActiveState();
+ CHKNULL(l_pCurrentState);
+ }
+
+ // Set active state
+ m_pActiveState = l_pActiveState;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s "
+ , m_pActiveState->m_strStateName.c_str());
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_pActiveState = NULL;
+ }
+
+
+ return l_pActiveState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedStart
+/// This starts the state machine
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedStart(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ m_bIsTransitioning = TRUE;
+
+ // Start the state machine execution on current state
+ m_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s "
+ , m_pActiveState->m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ // post the event from events list
+ eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ m_bIsTransitioning = FALSE;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedConnect
+/// This connects the reaction to event and add event to child states then add child state
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
+ UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
+ BOOL f_bIsDefaultState, BOOL f_bIsDeferredEventType,
+ std::string f_strEventName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ // attach reaction to event and add it to the child state
+ eStatus = FrameworkunifiedConnect(f_pChildState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEventType);
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ // add child state to parent state
+ eStatus = FrameworkunifiedConnect(f_pParentState, f_pChildState, f_bIsDefaultState);
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedConnect
+/// This add child state to parent state.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
+ BOOL f_bIsDefaultState) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pParentState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(f_pChildState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ // Check if the state is composite state
+ if (f_pParentState->FrameworkunifiedHasSubStates()) {
+ // Check if the child state is default state
+ if (f_bIsDefaultState) {
+ // Add child state as default state
+ (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState,
+ CFrameworkunifiedCompositeState::eFrameworkunifiedDefaultState); // LCOV_EXCL_BR_LINE 11: except branch
+ } else {
+ // Add state as regular state
+ (reinterpret_cast<CFrameworkunifiedCompositeState *>(f_pParentState))->FrameworkunifiedAddState(f_pChildState); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ f_pChildState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11: except branch
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error %s is not a composite state",
+ f_pParentState->m_strStateName.c_str());
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus; //LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedConnect
+/// This connects the reaction to event and add event to child states
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
+ std::string f_strEventName , BOOL f_bIsDeferredEventType) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ // check if the event is deferred event
+ if (f_bIsDeferredEventType) {
+ // Add event as deferred event
+ f_pState->FrameworkunifiedAddDeferredEvent(f_uiEventId, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Deferred Event %d %s is "
+ "associated with Reaction and added to state %s "
+ , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str());
+ // LCOV_EXCL_BR_STOP
+ } else {
+ CHKNULL(f_pReaction); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ // Add event as regular event
+ f_pState->FrameworkunifiedAddEvent(f_uiEventId, f_pReaction, f_strEventName); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Event %d %s is associated with Reaction and added to state %s "
+ , f_uiEventId, f_strEventName.c_str(), (f_pState->m_strStateName).c_str());
+ // LCOV_EXCL_BR_STOP
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d in %s", f_uiEventId,
+ (f_pState->m_strStateName).c_str());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPostEvent
+/// This creates the default event data and sends the event to the active HSM state.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(UI_32 f_uiEventId) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_BR_LINE 11: except branch
+ try {
+ CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch
+ CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ l_eStatus = FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPostEvent
+/// This sends the event to the active HSM state
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ if (m_bIsTransitioning) {
+ eStatus = FrameworkunifiedQueueEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
+ } else {
+ m_bIsTransitioning = TRUE;
+
+ eStatus = ProcessEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11: except branch
+
+ m_bIsTransitioning = FALSE;
+
+ CHKNULL(m_pActiveState);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s ", m_pActiveState->m_strStateName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEvent(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pActiveState->m_pEventName); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ EventNameList::iterator l_itEventName;
+ l_itEventName = m_pActiveState->m_pEventName->find(f_pEventData->m_uiEventId);
+
+ if (m_pActiveState->m_pEventName->end() != l_itEventName) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Posting event %d %s to state %s",
+ f_pEventData->m_uiEventId,
+ l_itEventName->second.c_str(),
+ m_pActiveState->m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ }
+
+ m_uiCurrentEvent = f_pEventData->m_uiEventId;
+
+ // Send event to active state for processing
+ m_pActiveState = m_pActiveState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+
+ CHKNULL(m_pActiveState);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Active state is %s ", m_pActiveState->m_strStateName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ // post the event from events list
+ eStatus = ProcessEventQueue(); // LCOV_EXCL_BR_LINE 11:except branch
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedClose
+/// This stops the state machine and destroys all states and events
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedClose(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pRootState);
+ delete m_pRootState;
+ m_pRootState = NULL;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedConnect
+/// This sets the givens state as root state in the state machine
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ m_pActiveState = f_pRootState;
+ m_pRootState = f_pRootState;
+
+ m_pRootState->FrameworkunifiedSetHSM(this); // LCOV_EXCL_BR_LINE 11:except branch
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPrintAllStates
+/// This prints all states and events associated with every state on console.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintAllStates() {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ // Print the states
+ m_pRootState->FrameworkunifiedPrintStates();
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState,
+ CFrameworkunifiedCompositeState *f_pOrthogonalRegion) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pOrthogonalState) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(f_pOrthogonalRegion) // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ f_pOrthogonalState->FrameworkunifiedAddOrthogonalRegion(f_pOrthogonalRegion);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+HANDLE CFrameworkunifiedHSM::FrameworkunifiedGetAppHandle() {
+ return m_pHApp;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedPrintXML() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ try {
+ std::ostringstream l_strXMLString;
+ l_strXMLString << "<Statemachine>";
+
+ CHKNULL(m_pRootState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ // Write statemachine information in XML stream
+ m_pRootState->FrameworkunifiedPrintXML(l_strXMLString);
+ l_strXMLString << "</Statemachine>";
+
+ // Write a stream to XML file
+ if (m_pHApp) {
+ size_t l_uiLength = static_cast<size_t>(l_strXMLString.str().length());
+
+ PCHAR l_pStream = new CHAR[l_uiLength + 1];
+ if (NULL != l_pStream) {
+ std::FILE *l_pFile = NULL;
+
+ std::memset(l_pStream, 0, l_uiLength + 1);
+ std::strncpy(l_pStream, l_strXMLString.str().c_str(), l_uiLength);
+
+ std::ostringstream l_strFileName;
+
+ l_strFileName << "StatemachineXML_";
+
+ l_strFileName << FrameworkunifiedGetAppName(m_pHApp) << ".xml";
+
+ l_pFile = std::fopen(l_strFileName.str().c_str(), "wbe");
+
+ if (l_pFile) {
+ std::fwrite(l_pStream, l_uiLength, 1, l_pFile);
+ std::fclose(l_pFile);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s File Created"
+ , l_strFileName.str().c_str());
+ }
+ delete[] l_pStream;
+ l_pStream = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: StatemachineXML_%s.xml file not created", FrameworkunifiedGetAppName(m_pHApp));
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, l_strXMLString.str().c_str());
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedHSM::FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ // Push the event in the post event list(FIFO)
+ m_pPostEventList->push_back(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessEventQueue
+/// This post the event from events list
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::ProcessEventQueue() {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(m_pPostEventList); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ if (!m_pPostEventList->empty()) {
+ CEventDataPtr l_pEventData = m_pPostEventList->front(); // LCOV_EXCL_BR_LINE 11:except branch
+ CHKNULL(l_pEventData); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ CHKNULL(m_pActiveState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Processing posted event %d in state %s",
+ l_pEventData->m_uiEventId, m_pActiveState->m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ m_pPostEventList->erase(m_pPostEventList->begin());
+
+ eStatus = ProcessEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveEventFromPostedEventQueue
+/// This API is used to remove the all events of eventId f_uiEventId from event queue of statemachine
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSM::RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID;
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pPostEventList) {
+ int32_t l_siCnt = static_cast<int32_t>(m_pPostEventList->size() - 1);
+
+ for (; l_siCnt >= 0; l_siCnt--) {
+ if (NULL != m_pPostEventList->at(l_siCnt).get()) {
+ if (f_uiEventId == m_pPostEventList->at(l_siCnt).get()->m_uiEventId) {
+ m_pPostEventList->erase(m_pPostEventList->begin() + l_siCnt);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp
new file mode 100644
index 00000000..da060f2a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_hsmframework.cpp
@@ -0,0 +1,1419 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedHSMParentFramework class definitions. CFrameworkunifiedHSMParentFramework is derived from
+/// CFrameworkunifiedHSM class. It defines the states required for NS statemachine framework, it creates the NS
+/// statemachine and implements the reaction associated with the events
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_hsmframework.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_np_service_notification.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <native_service/ns_plogger_if.h>
+
+#include <map>
+#include <string>
+
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+#include "frameworkunified_framework_utility.h"
+#include "frameworkunified_sm_framework_core.h"
+
+extern EFrameworkunifiedStatus FrameworkunifiedHSMOnLoadData(HANDLE hApp) __attribute__((weak));
+extern EFrameworkunifiedStatus FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(HANDLE hApp) __attribute__((weak));
+
+CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(): CFrameworkunifiedHSM() {
+}
+CFrameworkunifiedHSMFramework::CFrameworkunifiedHSMFramework(PVOID f_pHApp): CFrameworkunifiedHSM(f_pHApp) {
+}
+CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(): CFrameworkunifiedHSMFramework() {
+ try {
+ m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedHSMParentFramework
+/// default constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CFrameworkunifiedHSMParentFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) {
+ try {
+ m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedHSMParentFramework
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::~CFrameworkunifiedHSMParentFramework() {
+ // TODO(framework_unifeid) Auto-generated destructor stub
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreate
+/// Statemachine states and events created and connected in this interface.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedCreate(PVOID f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ HSMConfigOptions *l_tHSMConfig = NULL;
+ try {
+ if (f_pEventData) {
+ l_tHSMConfig = reinterpret_cast<HSMConfigOptions *>(f_pEventData);
+ }
+
+ // Create states
+ CREATE_STATE(sFrameworkunifiedRoot)
+ CREATE_STATE(sFrameworkunifiedApp)
+ CREATE_STATE(sFrameworkunifiedInitialization)
+ CREATE_STATE(sFrameworkunifiedLoadData)
+ CREATE_STATE(sFrameworkunifiedRun)
+ CREATE_STATE(sFrameworkunifiedLoadSessions)
+ CREATE_STATE(sFrameworkunifiedReady)
+ CREATE_STATE(sFrameworkunifiedStop)
+ CREATE_STATE(sFrameworkunifiedStopping)
+ CREATE_STATE(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ CREATE_STATE(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+
+ // connect states as per the statemachine
+ CONNECT_DEFAULTSTATE(sFrameworkunifiedRoot, sFrameworkunifiedApp)
+ CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedStop)
+
+ CONNECT_DEFAULTSTATE(sFrameworkunifiedApp, sFrameworkunifiedInitialization)
+ CONNECT_STATE(sFrameworkunifiedApp, sFrameworkunifiedRun)
+
+ CONNECT_DEFAULTSTATE(sFrameworkunifiedInitialization, sFrameworkunifiedLoadData)
+ CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ CONNECT_STATE(sFrameworkunifiedInitialization, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+
+ CONNECT_DEFAULTSTATE(sFrameworkunifiedRun, sFrameworkunifiedLoadSessions)
+ CONNECT_STATE(sFrameworkunifiedRun, sFrameworkunifiedReady)
+
+ CONNECT_DEFAULTSTATE(sFrameworkunifiedStop, sFrameworkunifiedStopping)
+
+ // Create External Transition
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedApp)
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedStop)
+
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedLoadSessions)
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedReady)
+
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+
+ // CREATE_ACTION(aFrameworkunifiedOnStart)
+
+ // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION
+ CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedRunevFrameworkunifiedStart = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedRun);
+
+ // CONNECT_ACTION(sFrameworkunifiedRunevFrameworkunifiedStart,aFrameworkunifiedOnStart)
+
+ // Connecting events to sFrameworkunifiedInitialization state
+ CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedStart, sFrameworkunifiedRunevFrameworkunifiedStart)
+ CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedPreStart, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+ CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedBackgroundStart, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+
+ // Create Local transitions
+ CREATE_LOCALTRANSITION(sFrameworkunifiedInitialization);
+ CREATE_LOCALTRANSITION(sFrameworkunifiedStop);
+
+ // Connect events to state
+
+ // Connecting events to sFrameworkunifiedLoadData state
+ CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedStart)
+ CONNECT_DEFERREDEVENT(sFrameworkunifiedLoadData, evFrameworkunifiedUserChange)
+ CONNECT_LOCAL_EVENT(sFrameworkunifiedLoadData, evFrameworkunifiedLoadComplete, sFrameworkunifiedInitialization)
+
+ // Connecting events to App state
+ CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedStop, sFrameworkunifiedStop)
+ CONNECT_LOCAL_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStopComplete, sFrameworkunifiedStop)
+ CONNECT_DEFERREDEVENT(sFrameworkunifiedStopping, evFrameworkunifiedStart)
+
+ // Connecting events to Connecting state
+ CONNECT_EVENT(sFrameworkunifiedLoadSessions, evFrameworkunifiedReady, sFrameworkunifiedReady)
+ // CONNECT_EVENT(sFrameworkunifiedReady,evFrameworkunifiedLoadSessions,sFrameworkunifiedRun)
+ CONNECT_EVENT(sFrameworkunifiedReady, evFrameworkunifiedLoadSessions, sFrameworkunifiedLoadSessions)
+
+ // Connecting events to Stop state
+ CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedInit, sFrameworkunifiedApp)
+
+ // Create internal transitions
+ CREATE_INTERNALTRANSITION(OnEventStartInStopState)
+ CONNECT_EVENT(sFrameworkunifiedStop, evFrameworkunifiedStart, OnEventStartInStopState)
+
+ CREATE_INTERNALTRANSITION(OnEventStopInStoppingState)
+ CONNECT_EVENT(sFrameworkunifiedStopping, evFrameworkunifiedStop, OnEventStopInStoppingState)
+
+ // Connecting events to sFrameworkunifiedRun state
+ CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedBackgroundStop, sFrameworkunifiedBackground) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+
+ // Connecting events to sFrameworkunifiedBackground state
+ CONNECT_EVENT(sFrameworkunifiedBackground, evFrameworkunifiedPreStop, sFrameworkunifiedPre) // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+
+ if (NULL != l_tHSMConfig) {
+ if (eUserchangeIgnore != l_tHSMConfig->eUserChange) {
+ if (eUserchangeReInit == l_tHSMConfig->eUserChange) {
+ // Create Internal Transition
+ CREATE_INTERNALTRANSITION(OnEventUserChangeInInitializationState)
+ CONNECT_EVENT(sFrameworkunifiedInitialization, evFrameworkunifiedUserChange, OnEventUserChangeInInitializationState)
+
+ // Create Internal Transition
+ CREATE_INTERNALTRANSITION(OnEventUserChangeInRunState)
+ CONNECT_EVENT(sFrameworkunifiedRun, evFrameworkunifiedUserChange, OnEventUserChangeInRunState)
+
+ CREATE_ACTION(aFrameworkunifiedOnStop)
+
+ // this is a patch, this code will be fixed once we change the macro for CONNECT_ACTION
+ CFrameworkunifiedExternalTransition *l_pTrnsFrameworkunifiedAppevFrameworkunifiedInit = new CFrameworkunifiedExternalTransition(l_psFrameworkunifiedApp);
+
+ CONNECT_ACTION(sFrameworkunifiedAppevFrameworkunifiedInit, aFrameworkunifiedOnStop)
+
+ CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedInit, sFrameworkunifiedAppevFrameworkunifiedInit)
+
+ } else if (eUserchangeRetPrevState == l_tHSMConfig->eUserChange) {
+ CREATE_STATE(sFrameworkunifiedUserChange)
+
+ CONNECT_STATE(sFrameworkunifiedRoot, sFrameworkunifiedUserChange)
+
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedUserChange)
+
+ CONNECT_EVENT(sFrameworkunifiedApp, evFrameworkunifiedUserChange, sFrameworkunifiedUserChange)
+ CONNECT_EVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStop, sFrameworkunifiedStop)
+
+ CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedStart)
+ CONNECT_DEFERREDEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChange)
+
+ // add shallow history state in state sFrameworkunifiedApp
+ ADD_SHALLOWHISTORYSTATE(sFrameworkunifiedApp)
+
+ // create transition to shallow history state in state sFrameworkunifiedApp
+ CREATE_SHALLOWHISTORYTRANSITION(sFrameworkunifiedApp)
+
+ // Connecting events to UserChange State
+ CONNECT_SHALLOWHISTORYEVENT(sFrameworkunifiedUserChange, evFrameworkunifiedUserChangeComplete, sFrameworkunifiedApp)
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Incorrect Userchange config option %d", l_tHSMConfig->eUserChange);
+ }
+ }
+ }
+
+ // Connecting FrameworkRoot to statemachine
+ CONNECTROOT(sFrameworkunifiedRoot)
+
+ // Creating the application specific statemachine
+ CHKNULL(m_pHApp);
+ FrameworkunifiedCreateStateMachineInternal(m_pHApp);
+
+ // Print statemachine xml
+ PRINT_HSM();
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedFrameworkConnect
+/// This adds the given state as a sub state of sReady state of the Framework
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pFrameworkunifiedStateList);
+ CHKNULL(f_pAppState);
+
+ if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady) == m_pFrameworkunifiedStateList->end()) {
+ throw CNullPointerException();
+ }
+ CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedReady)->second);
+ CHKNULL(l_pReady);
+
+ eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedFrameworkConnect
+/// This connects the reaction to event and add event to states
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
+ CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName,
+ BOOL f_bIsDeferredEvent) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pFrameworkunifiedStateList);
+
+ if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) {
+ throw CNullPointerException();
+ }
+ CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second);
+
+ CHKNULL(l_pFrameworkunifiedState);
+
+ eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedRoot
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::CsFrameworkunifiedRoot(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedRoot
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::~CsFrameworkunifiedRoot() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// Initializes the application and registers the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization +");
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedOnInitializationInternal(l_pHApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to Initialize application:0x%x ", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnInitialization -");
+
+ // Publish service unavailability
+ if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published");
+ }
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedApp
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::CsFrameworkunifiedApp(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedRoot
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::~CsFrameworkunifiedApp() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// Initializes the application and registers the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedApp::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedUserChange
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::CsFrameworkunifiedUserChange(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedRoot
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::~CsFrameworkunifiedUserChange() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// Initializes the application and registers the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedUserChangeComplete");
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No reaction for loading user specific data ");
+
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete));
+ } else {
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadUserData));
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedUserChange::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedInitialization
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::CsFrameworkunifiedInitialization(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedInitialization
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::~CsFrameworkunifiedInitialization() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedInitialization::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInInitializationState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
+ CEventDataPtr f_pEventData) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInInitializationState");
+ CHKNULL(f_pSourceState);
+
+ // post the event to move to sFrameworkunifiedApp state
+ f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return f_pSourceState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedLoadData
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::CsFrameworkunifiedLoadData(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedLoadData
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::~CsFrameworkunifiedLoadData() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ try {
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CHKNULL(FrameworkunifiedGetStateMachine(l_pHApp));
+
+ UI_32 l_uiCurrentEventId = FrameworkunifiedGetStateMachine(l_pHApp)->m_uiCurrentEvent;
+ if (!(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChangeComplete) == l_uiCurrentEventId)) {
+ if (FrameworkunifiedHSMOnLoadData) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedHSMOnLoadData(l_pHApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to load application data:0x%X ", eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnLoadData not defined by the application");
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent(l_pHApp,
+ NTFY_NPPService_UserChange,
+ FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedUserChange)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithHSMEvent "
+ "NTFY_NPPService_UserChange Failed Status:0x%x ", eStatus);
+ return eStatus;
+ }
+ // Attach callback : Event to start the StateMachine
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedAttachHSMEventToDispatcher(l_pHApp,
+ FRAMEWORKUNIFIED_ANY_SOURCE,
+ NPS_GET_PERS_FILE_ACK,
+ FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher NPS_GET_PERS_FILE_ACK (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ", eStatus);
+ return eStatus;
+ }
+ if (!FrameworkunifiedIsReactionAvailable(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadFileAck))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedLoadFileAck");
+
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete));
+ }
+ } else {
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedLoadComplete));
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadData::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ try {
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pHSM);
+
+ UI_32 l_uiCurrentEventId = l_pHSM->m_uiCurrentEvent;
+
+ if (FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) == l_uiCurrentEventId) {
+ l_pHSM->RemoveEventFromPostedEventQueue(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedPre
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::CsFrameworkunifiedPre(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) // NOLINT(whitespace/line_length)
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedPre
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::~CsFrameworkunifiedPre() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+
+ // Only evFrameworkunifiedPreStart or evFrameworkunifiedPreStop events occur when functions are executed.
+ if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedPreStart)) {
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ eStatus = FrameworkunifiedOnPreStartInternal(l_pHApp);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre start application:0x%x ", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ } else {
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ eStatus = FrameworkunifiedOnPreStopInternal(l_pHApp);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to pre stop application:0x%x ", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnPreStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedPre::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedBackground
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::CsFrameworkunifiedBackground(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others) // NOLINT(whitespace/line_length)
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedBackground
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::~CsFrameworkunifiedBackground() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+ CHKNULL(f_pEventData); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions
+
+ // Only evFrameworkunifiedBackgroundStart or evFrameworkunifiedBackgroundStop events occur when functions are executed.
+ if (f_pEventData->m_uiEventId == FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedBackgroundStart)) {
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+ eStatus = FrameworkunifiedOnBackgroundStartInternal(l_pHApp);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background start application:0x%x ", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStartInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+ } else {
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal +"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+ eStatus = FrameworkunifiedOnBackgroundStopInternal(l_pHApp);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to background stop application:0x%x ", eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("FrameworkunifiedOnBackgroundStopInternal -"); // LCOV_EXCL_BR_LINE 15:Excluded due to inlined functions // NOLINT(whitespace/line_length)
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedBackground::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedRun
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::CsFrameworkunifiedRun(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedRun
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::~CsFrameworkunifiedRun() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// Subscribes for the service availability notification and calls FrameworkunifiedOnStart
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ try {
+ HANDLE hApp = FrameworkunifiedGetAppHandle();
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ FrameworkunifiedOnStartInternal(hApp);
+
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) {
+ ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSubscribeNotificationWithHSMEvent
+ (hApp, objNotification.sNotificationName, objNotification.uiEventId))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to subscribe notification %s"
+ , objNotification.sNotificationName);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully subscribe notification %s"
+ , objNotification.sNotificationName);
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL");
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedRun::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+
+ try {
+ HANDLE hApp = FrameworkunifiedGetAppHandle();
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (frameworkunifiedCheckValidAppHandle(hApp)) {
+ // Let application also handle exit of sFrameworkunifiedRun state
+ if (FrameworkunifiedHSMOnStopInsFrameworkunifiedRun) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(hApp))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun returned: 0x%X ", l_eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning: FrameworkunifiedHSMOnStopInsFrameworkunifiedRun not defined by the application");
+ }
+
+ for (UI_32 l_uiCount = 0; l_uiCount < pApp->servicenotificationlist.size(); l_uiCount++) {
+ ServiceNotificationInfo objNotification = pApp->servicenotificationlist.at(l_uiCount);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithHSMEvent(hApp,
+ objNotification.sNotificationName))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "failed to unsubscribe notification %s",
+ objNotification.sNotificationName);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "successfully unsubscribed from notification %s",
+ objNotification.sNotificationName);
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __PRETTY_FUNCTION__, "Application handle is NULL");
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventUserChangeInRunState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
+ CEventDataPtr f_pEventData) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventUserChangeInRunState");
+ CHKNULL(f_pSourceState);
+
+ // post the event to move to sFrameworkunifiedApp state
+ f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
+
+ CHKNULL(f_pSourceState);
+
+ // post the event to move to sFrameworkunifiedRun state
+ f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+ return f_pSourceState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedLoadSessions
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::CsFrameworkunifiedLoadSessions(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedLoadSessions
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::~CsFrameworkunifiedLoadSessions() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ HANDLE hApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(hApp);
+
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast<CFrameworkunifiedFrameworkApp *>(hApp);
+
+ if (!pApp->servicenotificationlist.size()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, " No Mandatory services set ");
+
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " Wait for service availability of mandatory services ");
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedLoadSessions::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedReady
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::CsFrameworkunifiedReady(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedReady
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::~CsFrameworkunifiedReady() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ try {
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, TRUE))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "warning:Failed to Publish service availability notification:0x%x ",
+ l_eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service available published");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled");
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ try {
+ ServiceSessionTable::iterator session_iterator;
+ SessionHandleTable::iterator session_handle_iterator;
+
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ if (FrameworkunifiedIsAutoPublishServiceAvailableEnabled()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK != (FrameworkunifiedPublishServiceAvailability(l_pHApp, FALSE))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Warning:Failed to set service availability notification:0x%x ", l_eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Service unavailable published");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Auto Service available published feature disabled");
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedStop
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::CsFrameworkunifiedStop(std::string f_pName): CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedStop
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::~CsFrameworkunifiedStop() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ try {
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ // every application need to implement this function
+ // all the resource deallocation like file release,etc should be done in this callback
+ l_eStatus = FrameworkunifiedOnStopInternal(l_pHApp);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: FrameworkunifiedOnStop returned %d", l_eStatus);
+ // We just need to print the error.
+ // Returning this status to state machine is not required.
+ // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead.
+ l_eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok.
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CsFrameworkunifiedStopping
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::CsFrameworkunifiedStopping(std::string f_pName): CFrameworkunifiedLeafState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedStopping
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::~CsFrameworkunifiedStopping() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ try {
+ if (FrameworkunifiedIsWaitInStoppingStateEnabled()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Event evFrameworkunifiedStopComplete not posted. User has to post it.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Reaction not available for evFrameworkunifiedStopAck");
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Posting event evFrameworkunifiedStopComplete");
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStopComplete));
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMParentFramework::CsFrameworkunifiedStopping::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStopInStoppingState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
+ CEventDataPtr f_pEventData) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStopInStoppingState");
+ CHKNULL(f_pSourceState);
+
+ (VOID)f_pSourceState->FrameworkunifiedRemoveEventFromDeferredEventList(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+ return f_pSourceState;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedHSMParentFramework::COnEventStartInStopState::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
+ CEventDataPtr f_pEventData) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Reaction OnEventStartInStopState");
+ CHKNULL(f_pSourceState);
+
+ // post the event to move to sFrameworkunifiedApp state
+ f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedInit));
+
+ CHKNULL(f_pSourceState);
+
+ // post the event to transit to sFrameworkunifiedRun state
+ f_pSourceState->FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart));
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+ return f_pSourceState;
+}
+
+VOID CFrameworkunifiedHSMParentFramework::CaFrameworkunifiedOnStop::FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState,
+ CEventDataPtr f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "In Action %s", m_strName.c_str());
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ if (NULL != l_pHApp) {
+ FrameworkunifiedOnStopInternal(l_pHApp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Application handle is NULL in Action %s", m_strName.c_str());
+ }
+}
+
+CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(): CFrameworkunifiedHSMFramework() {
+}
+
+
+CFrameworkunifiedHSMChildFramework::CFrameworkunifiedHSMChildFramework(PVOID f_pHApp): CFrameworkunifiedHSMFramework(f_pHApp) {
+ try {
+ m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+}
+
+CFrameworkunifiedHSMChildFramework::~CFrameworkunifiedHSMChildFramework() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreate
+/// Statemachine states and events created and connected in this interface.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedCreate(PVOID f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ // Create states
+ CREATE_STATE(sFrameworkunifiedThreadRoot)
+ CREATE_STATE(sFrameworkunifiedThreadIdle)
+ CREATE_STATE(sFrameworkunifiedThreadStart)
+ CREATE_STATE(sFrameworkunifiedThreadReady)
+ CREATE_STATE(sFrameworkunifiedThreadStop)
+
+ // connect states as per the statemachine
+ CONNECT_DEFAULTSTATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadIdle)
+ CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStart)
+ CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadStop)
+ CONNECT_STATE(sFrameworkunifiedThreadRoot, sFrameworkunifiedThreadReady)
+
+ // Create External Transition
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadIdle)
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStart)
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadReady)
+ CREATE_EXTERNALTRANSITION(sFrameworkunifiedThreadStop)
+
+ // Connect events to state
+ CONNECT_EVENT(sFrameworkunifiedThreadIdle, evFrameworkunifiedStart, sFrameworkunifiedThreadStart)
+ CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedReady, sFrameworkunifiedThreadReady)
+ CONNECT_EVENT(sFrameworkunifiedThreadStart, evFrameworkunifiedError, sFrameworkunifiedThreadIdle)
+ CONNECT_EVENT(sFrameworkunifiedThreadReady, evFrameworkunifiedStop, sFrameworkunifiedThreadStop)
+ CONNECT_EVENT(sFrameworkunifiedThreadStop, evFrameworkunifiedStart, sFrameworkunifiedThreadStart)
+
+ // Create Internal Transition
+ CREATE_INTERNALTRANSITION(OnDestroyThread)
+ CONNECT_EVENT(sFrameworkunifiedThreadRoot, evFrameworkunifiedDestroy, OnDestroyThread)
+
+ // Connecting AppRoot to statemachine
+ CONNECTROOT(sFrameworkunifiedThreadRoot)
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// COnDestroyThread::FrameworkunifiedReaction
+/// This reaction is executed when request for terminating the thread is received.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedHSMChildFramework::COnDestroyThread::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState,
+ CEventDataPtr f_pEventData) {
+ // return the NULL to exit the dispatcher loop of thread
+ return NULL;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pFrameworkunifiedStateList);
+ CHKNULL(f_pAppState);
+
+ if (m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady) == m_pFrameworkunifiedStateList->end()) {
+ throw CNullPointerException();
+ }
+ CFrameworkunifiedState *l_pReady = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(esFrameworkunifiedThreadReady)->second);
+ CHKNULL(l_pReady);
+
+ eStatus = FrameworkunifiedConnect(l_pReady, f_pAppState, f_bIsDefaultState);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
+ CFrameworkunifiedReaction *f_pReaction,
+ std::string f_strEventName, BOOL f_bIsDeferredEvent) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pFrameworkunifiedStateList);
+
+ if (m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState) == m_pFrameworkunifiedStateList->end()) {
+ throw CNullPointerException();
+ }
+ CFrameworkunifiedState *l_pFrameworkunifiedState = reinterpret_cast<CFrameworkunifiedCompositeState *>(m_pFrameworkunifiedStateList->find(f_eFrameworkunifiedState)->second);
+
+ CHKNULL(l_pFrameworkunifiedState);
+
+ eStatus = FrameworkunifiedConnect(l_pFrameworkunifiedState, f_uiEventId, f_pReaction, f_strEventName, f_bIsDeferredEvent);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedThreadRoot
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::CsFrameworkunifiedThreadRoot(std::string f_pName)
+ : CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedThreadRoot
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::~CsFrameworkunifiedThreadRoot() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// publishes the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadRoot::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedThreadIdle
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::CsFrameworkunifiedThreadIdle(std::string f_pName)
+ : CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedThreadIdle
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::~CsFrameworkunifiedThreadIdle() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// publishes the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadIdle::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedThreadStart
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::CsFrameworkunifiedThreadStart(std::string f_pName)
+ : CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedThreadStart
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::~CsFrameworkunifiedThreadStart() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// publishes the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >
+ (FrameworkunifiedGetAppHandle());
+ CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine));
+ CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread);
+ if (eFrameworkunifiedStatusOK ==
+ (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread(pApp)) {
+ FrameworkunifiedPostEvent(FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedReady));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Thread start Failed: %s", m_strStateName.c_str());
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStart::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedThreadReady
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::CsFrameworkunifiedThreadReady(std::string f_pName)
+ : CFrameworkunifiedCompositeState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedThreadReady
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::~CsFrameworkunifiedThreadReady() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// publishes the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadReady::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedThreadStop
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::CsFrameworkunifiedThreadStop(std::string f_pName)
+ : CFrameworkunifiedLeafState(f_pName) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CsFrameworkunifiedThreadStop
+/// class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::~CsFrameworkunifiedThreadStop() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// publishes the service availability notification
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+
+ HANDLE hApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(hApp);
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >
+ (hApp);
+ CHKNULL(reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine));
+ CHKNULL((reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread);
+
+ eStatus = (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread(pApp);
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "WARNING: Thread stop function returned %d", eStatus);
+ // We just need to print the error.
+ // Returning this status to state machine is not required.
+ // Currently, If not OK is sent to state machine while FrameworkunifiedOnEntry, then state machine becomes dead.
+ eStatus = eFrameworkunifiedStatusOK; // Therefore assign ok.
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedHSMChildFramework::CsFrameworkunifiedThreadStop::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp
new file mode 100644
index 00000000..6c44ebbb
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_leafstate.cpp
@@ -0,0 +1,78 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedLeafState class definitions. CFrameworkunifiedLeafState is derived from C
+/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Leafstate.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_leafstate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedLeafState::CFrameworkunifiedLeafState(std::string f_pName): CFrameworkunifiedState(f_pName) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedLeafState::~CFrameworkunifiedLeafState() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "CFrameworkunifiedLeafState destructor");
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedLeafState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedLeafState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedLeafState::FrameworkunifiedGetActiveState() {
+ return this;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateHistory
+/// This function stores the last active state
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedLeafState::UpdateHistory() {
+ return eFrameworkunifiedStatusOK;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp
new file mode 100644
index 00000000..b5f9c0ae
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_localtransition.cpp
@@ -0,0 +1,84 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_localtransition.h>
+#include <native_service/frameworkunified_sm_state.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedExternalTransition
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedLocalTransition::CFrameworkunifiedLocalTransition(CFrameworkunifiedState *f_pTargetState): CFrameworkunifiedTransition(f_pTargetState) {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedExternalTransition
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedLocalTransition::~CFrameworkunifiedLocalTransition() {
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedReaction
+/// The reaction for an event is implemented in this function. For local transition from inner
+/// state to outer state exit of the inner state is invoked, but entry of outer state is not
+/// invoked and from outer state to inner state entry of the inner state is invoked but exit of
+/// outer state is not invoked
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedLocalTransition::FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) {
+ CFrameworkunifiedState *l_pActiveState = NULL;
+ CFrameworkunifiedState *l_pCurrentState = NULL;
+ try {
+ CHKNULL(f_pSourceState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pTargetState); // LCOV_EXCL_BR_LINE 15: marco defined in frameworkunified_sm_framework_types.h
+
+ // Local transition from inner state to outer state
+ if (f_pSourceState->m_pParentState == m_pTargetState) {
+ // Source is child of target
+ l_pCurrentState = f_pSourceState->FrameworkunifiedOnHSMStop(f_pData);
+
+ if (l_pCurrentState == f_pSourceState) {
+ l_pActiveState = m_pTargetState;
+
+ } else {
+ l_pActiveState = l_pCurrentState;
+ }
+
+ /**
+ * @todo
+ * If the parent state is registered and OnEvent is performed without OrthogonalReigonList, illegal accesses occur.
+ */
+ l_pActiveState->m_pActiveState = NULL;
+
+ // Local transition from outer state to inner state
+ } else if (f_pSourceState == m_pTargetState->m_pParentState) {
+ // Source is parent to target state
+ l_pActiveState = m_pTargetState->FrameworkunifiedOnHSMStart(f_pData);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Local Transition from state %s to state %s"
+ , f_pSourceState->m_strStateName.c_str(), m_pTargetState->m_strStateName.c_str());
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+
+ return NULL;
+ }
+
+ return l_pActiveState;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp
new file mode 100644
index 00000000..33dab562
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_multithreading.cpp
@@ -0,0 +1,211 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief This file has the function implementation for creating state machine child thread
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+#include <sys/prctl.h>
+
+#include <native_service/frameworkunified_sm_hsmframework.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_utility.hpp>
+#include <native_service/ns_system_mode.h>
+#include <native_service/frameworkunified_sm_multithreading.h>
+#include <native_service/frameworkunified_multithreading.h>
+
+#include <iostream>
+#include <string>
+
+#include "frameworkunified_framework_utility.h"
+#include "frameworkunified_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateHSMDispatcherChild
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateHSMDispatcherChild(PCSTR childName,
+ PCSTR parentName,
+ HANDLE &hChildApp, // NOLINT (readability/nolint)
+ CbFuncPtr pOnThreadStart,
+ CbFuncPtr pOnThreadStop) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((NULL != childName) && (NULL != parentName) && (strlen(childName) <= MAX_NAME_SIZE_APP) &&
+ (strlen(parentName) <= MAX_NAME_SIZE_APP)) {
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcher(childName, hChildApp, TRUE))) {
+ if (frameworkunifiedCheckValidAppHandle(hChildApp)) {
+ CFrameworkunifiedFrameworkApp *pApp = reinterpret_cast< CFrameworkunifiedFrameworkApp * >(hChildApp);
+
+ (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStartThread
+ = pOnThreadStart;
+
+ (reinterpret_cast<CFrameworkunifiedHSMChildFramework *>(pApp->m_pFrameworkunifiedStateMachine))->m_fpStopThread
+ = pOnThreadStop;
+
+ pApp->hParentSndMsgQ = McOpenSender(parentName);
+ if (NULL == pApp->hParentSndMsgQ) {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "McOpenSender failed");
+ return eStatus;
+ }
+ pApp->uiSessionId = THREAD_SESSION_ID;
+
+ memset(pApp->cParentAppName, 0, sizeof(pApp->cParentAppName));
+ memcpy(pApp->cParentAppName, parentName, strlen(parentName));
+ } else {
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hChildApp is NULL");
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcher error, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid Param received"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eStatus;
+}
+
+void *child_hsm_thread_proc(void *args) {
+ if (args == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "args is NULL");
+ return NULL;
+ }
+ PCData pcdata = *reinterpret_cast< PCData * >(args); // Create a local copy of data
+
+ try {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ HANDLE hFrameworkApp = NULL;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedCreateHSMDispatcherChild(pcdata.childName.c_str(),
+ pcdata.parentName.c_str(),
+ hFrameworkApp,
+ pcdata.initFn,
+ pcdata.shdnFn))) {
+ if (NULL != hFrameworkApp) {
+ THApp hChildApp(hFrameworkApp);
+
+ if (pcdata.CbCreateStateMachine) {
+ pcdata.CbCreateStateMachine(hChildApp);
+ FRAMEWORKUNIFIED_PRINT_HSM(hChildApp)
+ }
+ const FrameworkunifiedProtocolEvent pcbhs[] = { { SYSTEM_ON_INITIALIZATION, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStart) },
+ { SYSTEM_ON_SHUTDOWN, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedStop) },
+ { SYSTEM_ON_DESTROY, FRAMEWORKUNIFIED_EVENT(evFrameworkunifiedDestroy) }
+ };
+
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachHSMEventsToDispatcher(hChildApp,
+ pcdata.parentName.c_str(),
+ &pcbhs[ 0 ],
+ static_cast<UI_32>(_countof(pcbhs)),
+ NULL)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to attach hsm events to child thread %s",
+ pcdata.childName.c_str());
+ }
+
+ // set child thread name
+ char thread_name[16];
+ strncpy(thread_name, pcdata.childName.c_str(), sizeof(thread_name));
+ prctl(PR_SET_NAME, thread_name);
+ thread_name[15] = '\0';
+
+ setChildThreadSched(pcdata.schedPolicy, pcdata.schedPriority);
+
+ (FrameworkunifiedGetStateMachine(hChildApp))->FrameworkunifiedStart();
+
+ *pcdata.childStatus = eFrameworkunifiedStatusOK;
+ if (IsValidWaitBarrier(pthread_barrier_wait(pcdata.barrier))) {
+ RunChildDispatcher(hChildApp);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hFrameworkApp is NULL");
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedCreateHSMDispatcherChild error, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+
+ *pcdata.childStatus = eFrameworkunifiedStatusFail;
+ pthread_barrier_wait(pcdata.barrier);
+ }
+ } catch (const THApp::Exception &) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to create child %s", pcdata.childName.c_str());
+ }
+
+ return NULL;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateHSMChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateHSMChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize,
+ CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine) {
+ HANDLE hChildQ = NULL;
+ FrameworkunifiedChildThreadAttr attr;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown &&
+ NULL != CbCreateStateMachine) {
+ CreateChildThreadAttrInit(&attr);
+ hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, CbCreateStateMachine);
+ }
+
+ return hChildQ;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateHSMChildThreadWithPriority
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateHSMChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize,
+ CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine, SI_32 schedPrio) {
+ HANDLE hChildQ = NULL;
+ FrameworkunifiedChildThreadAttr attr;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown &&
+ NULL != CbCreateStateMachine) {
+ CreateChildThreadAttrInit(&attr);
+ CreateChildThreadAttrSetSched(&attr, eFrameworkunifiedSchedPolicyRR, schedPrio);
+ hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, &attr, CbCreateStateMachine);
+ }
+ return hChildQ;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreateHSMChildThreadWithAttribute
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateHSMChildThreadWithAttribute(HANDLE hApp,
+ PCSTR childName,
+ CbFuncPtr CbInitialize,
+ CbFuncPtr CbShutdown,
+ CbFuncPtr CbCreateStateMachine,
+ const FrameworkunifiedChildThreadAttr *attr) {
+ HANDLE hChildQ = NULL;
+
+ if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != childName && NULL != CbInitialize && NULL != CbShutdown &&
+ NULL != CbCreateStateMachine) {
+ hChildQ = CreateChildThread(hApp, childName, CbInitialize, CbShutdown, attr, CbCreateStateMachine);
+ }
+ return hChildQ;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp
new file mode 100644
index 00000000..a8289a0a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_orthogonalstate.cpp
@@ -0,0 +1,337 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedOrthogonalState class definitions. CFrameworkunifiedOrthogonalState is derived from
+/// CFrameworkunifiedCompositeState class.This class implements the additional functionality supported by HSM
+/// Orthogonal state. It provides the standard interfaces for adding orthogonal state machines.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_orthogonalstate.h>
+#include <native_service/frameworkunified_sm_compositestate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <sstream>
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedCompositeState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedOrthogonalState::CFrameworkunifiedOrthogonalState(std::string f_pName): CFrameworkunifiedState(f_pName) {
+ try {
+ m_pOrthogonalReigonList = new OrthogonalRegionList();
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedOrthogonalState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedOrthogonalState::~CFrameworkunifiedOrthogonalState() {
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
+ if (m_pOrthogonalReigonList->at(l_uiCount)) {
+ delete m_pOrthogonalReigonList->at(l_uiCount);
+ }
+ }
+ m_pOrthogonalReigonList->clear();
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "CFrameworkunifiedOrthogonalState destructor");
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEntry
+/// state initialization can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Entering state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnExit
+/// state cleanup can be performed in this function.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedOnExit(CEventDataPtr f_pEventData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, " Leaving state %s ", m_strStateName.c_str());
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedAddOrthogonalRegion(CFrameworkunifiedCompositeState *f_pOrthogonalRegion) {
+ try {
+ CHKNULL(f_pOrthogonalRegion);
+ CHKNULL(m_pOrthogonalReigonList);
+ f_pOrthogonalRegion->m_pParentState = this;
+ m_pOrthogonalReigonList->push_back(f_pOrthogonalRegion);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eFrameworkunifiedStatusOK;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pCurrentState = NULL;
+ CFrameworkunifiedState *l_pActiveState = NULL;
+
+ try {
+ FrameworkunifiedOnEntry(f_pEventData);
+
+ CHKNULL(m_pOrthogonalReigonList);
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
+ if (m_pOrthogonalReigonList->at(l_uiCount)) {
+ l_pActiveState = (m_pOrthogonalReigonList->at(l_uiCount));
+ CHKNULL(l_pActiveState);
+
+ l_pCurrentState = l_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData);
+ CHKNULL(l_pCurrentState);
+
+ if (!IsOrthogonalChildState(l_pCurrentState)) {
+ break;
+ } else {
+ l_pCurrentState = this;
+ }
+ }
+ }
+
+ // set current state as the active state of its parent state to maintain the Hierarchy
+ if (m_pParentState) {
+ m_pParentState->m_pActiveState = l_pCurrentState;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pCurrentState;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pCurrentState = NULL;
+ CFrameworkunifiedState *l_pActiveState = NULL;
+
+ try {
+ CHKNULL(m_pOrthogonalReigonList);
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
+ if (m_pOrthogonalReigonList->at(l_uiCount)) {
+ l_pActiveState = (m_pOrthogonalReigonList->at(l_uiCount));
+ CHKNULL(l_pActiveState);
+
+ l_pCurrentState = l_pActiveState->FrameworkunifiedOnHSMStop(f_pEventData);
+ CHKNULL(l_pCurrentState);
+
+ if (!IsOrthogonalChildState(l_pCurrentState)) {
+ break;
+ } else {
+ l_pCurrentState = this;
+ }
+ }
+ }
+ FrameworkunifiedOnExit(f_pEventData);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pCurrentState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEvent
+/// This function processes the event. If the reaction for event is available in the current
+/// state within eventlist and deferred eventlist then it is consumed in the current state
+/// otherwise forwarded to the parent state. Event forwarding is done recursively till either
+/// event is consumed or the root state has encountered. This also process the events posted
+/// in the reactions recursively till all posted events are cleared.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedOnEvent(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pCurrentState = NULL;
+ CFrameworkunifiedState *l_pStateIterator = NULL;
+ CFrameworkunifiedState *l_pOrthogonalRegion = NULL;
+ BOOL l_bReactionAvailable = FALSE;
+ BOOL l_bIsEventProcessed = FALSE;
+
+ try {
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
+ l_pOrthogonalRegion = m_pOrthogonalReigonList->at(l_uiCount);
+
+ if (l_pOrthogonalRegion) {
+ // get the current active state
+ l_pCurrentState = l_pOrthogonalRegion->FrameworkunifiedGetActiveState();
+ CHKNULL(l_pCurrentState);
+
+ l_pStateIterator = l_pCurrentState;
+
+ // checks whether the reaction for the event is available in this orthogonal region
+ while (this != l_pStateIterator) {
+ if (l_pStateIterator->FrameworkunifiedIsReactionAvailable(f_pEventData->m_uiEventId)) {
+ l_bReactionAvailable = TRUE;
+ l_bIsEventProcessed = TRUE;
+ break;
+ }
+
+ // iterate to parent state in orthogonal region
+ l_pStateIterator = l_pStateIterator->m_pParentState;
+ }
+
+ // if reaction is found, post the event
+ if (l_bReactionAvailable) {
+ l_bReactionAvailable = FALSE;
+
+ l_pCurrentState = l_pCurrentState->FrameworkunifiedOnEvent(f_pEventData);
+ CHKNULL(l_pCurrentState);
+
+ // check whether current active state is within the orthogonal state
+ if (IsOrthogonalChildState(l_pCurrentState)) {
+ l_pCurrentState = this;
+ }
+
+ break;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Reaction not available in orthogonal region %s",
+ l_pOrthogonalRegion->m_strStateName.c_str());
+ l_pCurrentState = this;
+ }
+ }
+ }
+
+ // if event is not processed in any of orthogonal region, post the event to orthogonal state
+ if (!l_bIsEventProcessed) {
+ l_pCurrentState = CFrameworkunifiedState::FrameworkunifiedOnEvent(f_pEventData);
+
+ // check whether current active state is within the orthogonal state
+ if (IsOrthogonalChildState(l_pCurrentState)) {
+ l_pCurrentState = this;
+ }
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pCurrentState;
+}
+
+BOOL CFrameworkunifiedOrthogonalState::FrameworkunifiedHasOrthogoanlRegions() {
+ try {
+ CHKNULL(m_pOrthogonalReigonList);
+
+ if (m_pOrthogonalReigonList->size()) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return FALSE;
+ }
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedPrintStates() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s",
+ (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str());
+
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
+ if (m_pOrthogonalReigonList->at(l_uiCount)) {
+ m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedPrintStates();
+ }
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+BOOL CFrameworkunifiedOrthogonalState::IsOrthogonalChildState(CFrameworkunifiedState *f_pChildState) {
+ CFrameworkunifiedState *l_pParentState = f_pChildState;
+ BOOL l_bIsOrthgonalChild = FALSE;
+ while (l_pParentState) {
+ if (this == l_pParentState) {
+ l_bIsOrthgonalChild = TRUE;
+ break;
+ }
+
+ l_pParentState = l_pParentState->m_pParentState;
+ }
+
+ return l_bIsOrthgonalChild;
+}
+
+CFrameworkunifiedState *CFrameworkunifiedOrthogonalState::FrameworkunifiedGetActiveState() {
+ return this;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(f_pStatemachine);
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size();
+ l_uiCount++) {
+ if (m_pOrthogonalReigonList->at(l_uiCount)) {
+ m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedSetHSM(f_pStatemachine);
+ }
+ }
+ m_pStateMachine = f_pStatemachine;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ f_strXMLString << "<" << m_strStateName.c_str() << ">";
+ f_strXMLString << "<OrthogonalRegions>";
+
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pOrthogonalReigonList->size(); l_uiCount++) {
+ if (m_pOrthogonalReigonList->at(l_uiCount)) {
+ m_pOrthogonalReigonList->at(l_uiCount)->FrameworkunifiedPrintXML(f_strXMLString);
+ }
+ }
+
+ f_strXMLString << "</OrthogonalRegions>";
+ f_strXMLString << "</" << m_strStateName.c_str() << ">";
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateHistory
+/// This function stores the last active state
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedOrthogonalState::UpdateHistory() {
+ return eFrameworkunifiedStatusOK;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp
new file mode 100644
index 00000000..97b6e3bb
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_shallowhistorystate.cpp
@@ -0,0 +1,74 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedShallowHistoryState class definitions. CFrameworkunifiedShallowHistoryState is derived
+/// from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported by
+/// HSM ShallowHistory state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_shallowhistorystate.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <string>
+
+// define static members of class
+const UI_32 CFrameworkunifiedShallowHistoryState::m_suievShallowHistory = 71;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedShallowHistoryState
+/// Parameterized constructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedShallowHistoryState::CFrameworkunifiedShallowHistoryState(std::string f_pName): CFrameworkunifiedHistoryState(f_pName) {
+ m_uiEventId = m_suievShallowHistory;
+ m_cEventName = "evShallowHistory";
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedShallowHistoryState
+/// Class destructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedShallowHistoryState::~CFrameworkunifiedShallowHistoryState() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "CFrameworkunifiedShallowHistoryState destructor");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateHistory
+/// This function stores the last active state
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedShallowHistoryState::UpdateHistory() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(m_pParentState);
+
+ m_pLastActiveState = m_pParentState->m_pActiveState;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp
new file mode 100644
index 00000000..af90583b
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_state.cpp
@@ -0,0 +1,634 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedState class implementation. CFrameworkunifiedState is base class for all types of
+/// state classes.This class implements the basic functionality required for HSM state.
+/// It provides the standard interfaces for entering, exiting and reacting in a state.
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_state.h>
+#include <native_service/frameworkunified_sm_reaction.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <sstream>
+#include <string>
+#include <utility>
+#include "frameworkunified_sm_framework_core.h"
+#include "frameworkunified_framework_internal.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedState
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState::CFrameworkunifiedState(std::string f_pName): m_strStateName(f_pName) {
+ try {
+ // EventList stores the list of events associated with the state
+ m_pEventList = new EventReactionList(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // Deferred eventlist stores the list of deferred events associated
+ // with the state
+ m_pDeferredEventList = new DeferredEventList(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // Deferred PostEventList stores the list of posted deferred events posted
+ // in the state
+ m_pDeferredPostEventList = new EventInfoList(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // EventName map stores the Name of event against event id, The event name is
+ // only used for debugging so this can be disbaled in case of release build
+ m_pEventName = new EventNameList(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ m_pDefaultState = NULL;
+ m_pActiveState = NULL;
+ m_pParentState = NULL;
+ m_pStateMachine = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s state created ", f_pName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed in %s state ", f_pName.c_str());
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedState
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState::~CFrameworkunifiedState() {
+ EventReactionIterator l_objEventIterator;
+ EventReactionIterator l_objDeferredEventIterator;
+
+ try {
+ // Delete the event list
+ CHKNULL(m_pEventList);
+ for (l_objEventIterator = m_pEventList->begin();
+ l_objEventIterator != m_pEventList->end();
+ l_objEventIterator++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, " deleting the event %d in state %s",
+ (*l_objEventIterator).first , m_strStateName.c_str());
+
+ if (NULL != (*l_objEventIterator).second) {
+ (*l_objEventIterator).second->m_ucRefCount--;
+
+ if (0 == ((*l_objEventIterator).second->m_ucRefCount)) {
+ delete(*l_objEventIterator).second;
+ (*l_objEventIterator).second = NULL;
+ }
+ }
+ }
+
+ // Delete the eventlist
+ m_pEventList->clear();
+ delete m_pEventList;
+ m_pEventList = NULL;
+
+ // Delete the deferred eventlist
+ CHKNULL(m_pDeferredEventList);
+ m_pDeferredEventList->clear();
+ delete m_pDeferredEventList;
+ m_pDeferredEventList = NULL;
+
+ // delete deferred Post event list
+ CHKNULL(m_pDeferredPostEventList);
+ m_pDeferredPostEventList->clear();
+ delete m_pDeferredPostEventList;
+ m_pDeferredPostEventList = NULL;
+
+ // delete event name list
+ CHKNULL(m_pEventName);
+ m_pEventName->clear();
+ delete m_pEventName;
+ m_pEventName = NULL;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAddEvent
+/// Associates the event id with the reaction in the state. When the event is posted to the
+/// state the associated reaction is executed. This also adds the event name to the map
+/// which is used for debugging.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedAddEvent(UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pEventName);
+ CHKNULL(m_pEventList);
+ CHKNULL(f_pReaction);
+ // LCOV_EXCL_BR_STOP
+ // associate the eventname with event id (debugging only)
+ m_pEventName->insert(std::pair<UI_32, std::string>(f_uiEventId, f_strEventName));
+
+ f_pReaction->m_ucRefCount++;
+
+ // associate the reaction with event id
+ m_pEventList->insert(std::pair<UI_32, CFrameworkunifiedReaction *>(f_uiEventId, f_pReaction));
+
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Reaction associated with the event %d %s in the state %s "
+ , f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d %s in state %s",
+ f_uiEventId , (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnEvent
+/// This function processes the event. If the reaction for event is available in the current
+/// state within eventlist and deferred eventlist then it is consumed in the current state
+/// otherwise forwarded to the parent state. Event forwarding is done recursively till either
+/// event is consumed or the root state has encountered. This also process the events posted
+/// in the reactions recursively till all posted events are cleared.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnEvent(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pCurrentState = this;
+ CFrameworkunifiedReaction *l_pEventReaction = NULL;
+
+ try {
+ // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pEventList);
+ CHKNULL(m_pDeferredEventList);
+ // LCOV_EXCL_BR_STOP
+ // Find the reaction object for given event id
+
+ /**
+ * @todo
+ * Unauthorized accesses will occur if NULL is specified for the event data.
+ */
+ if (m_pEventList->end() != m_pEventList->find(f_pEventData->m_uiEventId)) {
+ l_pEventReaction = reinterpret_cast<CFrameworkunifiedReaction *>((m_pEventList->find(f_pEventData->m_uiEventId))->second);
+ }
+
+ if (l_pEventReaction) {
+ // execute the reaction associated with the event
+ l_pCurrentState = l_pEventReaction->FrameworkunifiedReaction(this, f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Reaction completed for event %d %s in state %s "
+ , f_pEventData->m_uiEventId, (m_pEventName->find(f_pEventData->m_uiEventId)->second).c_str(),
+ m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ } else if (IsEventDeferred(f_pEventData->m_uiEventId)) {
+ // If given event is deferred event then handle defer event
+ CHKNULL(m_pDeferredPostEventList);
+
+ m_pDeferredPostEventList->push_back(f_pEventData);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s posted to state %s ",
+ f_pEventData->m_uiEventId,
+ (m_pEventName->find(f_pEventData->m_uiEventId)->second).c_str(),
+ m_strStateName.c_str());
+
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_DEV_INFO, __FUNCTION__, "Reaction not available or event %d not found in state %s"
+ , f_pEventData->m_uiEventId, m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ // check if the current state has parent state
+ if (m_pParentState) {
+ // No reaction available fot given event in the current state
+ // then forward event to parent state
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Forwarding an event %d to %s"
+ , f_pEventData->m_uiEventId, m_pParentState->m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ l_pCurrentState = m_pParentState->FrameworkunifiedOnEvent(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+
+ } else {
+ // No parent is available then reached root state,
+ // No reaction available in the statemachine then discard the event
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Discarding an event %d ", f_pEventData->m_uiEventId);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ CHKNULL(l_pCurrentState);
+
+ // This is a recursive function that recurse in parent states till the event is
+ // consumed or discarded So Setting the current state as the active state of the
+ // returned state, as the return state is parent state
+ if (l_pCurrentState->m_pActiveState) {
+ l_pCurrentState = l_pCurrentState->m_pActiveState;
+
+ } else {
+ // do nothing in leaf state, as current state is active state
+ }
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+ return l_pCurrentState;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAddDeferredEvent
+/// When the event is posted to the state the event is deferred and stored in the state.
+/// In case of implicit recall of the deferred events, events are processed before exiting the state.
+/// The deferred events can also be recalled explicitly in the state.
+/// This also adds the event name to the map which is used for debugging.
+//////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedAddDeferredEvent(UI_32 f_uiEventId, std::string f_strEventName) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pEventName);
+
+ CHKNULL(m_pDeferredEventList);
+ // LCOV_EXCL_BR_STOP
+ // associate the deferred eventname with event id (debugging only)
+ m_pEventName->insert(std::pair<UI_32, std::string>(f_uiEventId, f_strEventName));
+
+ // associate the reaction with deferred event id
+ m_pDeferredEventList->push_back(f_uiEventId); // LCOV_EXCL_BR_LINE 11:except branch
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Added deferred event %d %s in the state %s "
+ , f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to add event %d %s in state %s",
+ f_uiEventId, (m_pEventName->find(f_uiEventId)->second).c_str(), m_strStateName.c_str());
+
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPostEvent
+/// This function creates new eventdata object and add the to event queue of the state.
+/// The events are posted in the reaction which are executed in the state.
+/// The event queue is processed once the execution of the reaction is completed.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPostEvent(UI_32 f_uiEventId) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ try {
+ CHKNULL(m_pStateMachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
+
+ CEventDataPtr l_pEventData(new CEventData(f_uiEventId)); // LCOV_EXCL_BR_LINE 11:except branch
+
+ l_eStatus = m_pStateMachine->FrameworkunifiedPostEvent(l_pEventData); // LCOV_EXCL_BR_LINE 11:except branch // LCOV_EXCL_BR_LINE 11:except branch
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPostEvent
+/// This function adds the event queue of the state. The events are posted in the reaction
+/// which are executed in the state. The event queue is processed once the execution of the
+/// reaction is completed.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPostEvent(CEventDataPtr f_pEventData) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(m_pStateMachine);
+ CHKNULL(f_pEventData);
+
+ l_eStatus = m_pStateMachine->FrameworkunifiedPostEvent(f_pEventData);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnHSMStart
+/// This function is called recursively till the leaf state is reached. This internally
+/// calls the Entry function of the current state.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pActiveState = this;
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ // Call Entry method of the current state. Entry method of state is called in the order of
+ // Hierarchy from Outer state to Inner state
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedOnEntry(f_pEventData))) {
+ // If current state has sub states then enter into active state for state entry
+ // active state is same as the default state. In this case the FrameworkunifiedOnStart is called
+ // recursively and recursion breaks when the current state is leafstate that does not have
+ // any active/default state.
+ if (m_pActiveState) {
+ l_pActiveState = m_pActiveState->FrameworkunifiedOnHSMStart(f_pEventData); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ l_pActiveState = this;
+ }
+
+ // set current state as the active state of its parent state to maintain the Hierarchy
+ if (m_pParentState) {
+ m_pParentState->m_pActiveState = this;
+ }
+ } else {
+ // If FrameworkunifiedOnEntry failed then statemachine should report the error
+ // We can throw an exception but for now as a quick fix we are setting
+ // l_pActiveState as NULL which will stop the statemachine
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error:%d in FrameworkunifiedOnEntry of state %s", eStatus,
+ l_pActiveState->m_strStateName.c_str());
+ // LCOV_EXCL_BR_STOP
+ // l_pActiveState = NULL;
+ /* Commenting it, because it was making state machine inactive. This should not be the expected behavior.
+ * Just log and take no action, if user return non-ok value.
+ * User defined error values should be handled separately */
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pActiveState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedOnHSMStop
+/// This function is called recursively till the required parent state is reached. This
+/// internally calls the Exit function of the current state.
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedState *CFrameworkunifiedState::FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData) {
+ CFrameworkunifiedState *l_pActiveState = this;
+ try {
+ // if active state is composite state, update the shallow and deep history state(if exists)
+ UpdateHistory(); // LCOV_EXCL_BR_LINE 11:except branch
+
+ // if current state has active state then recursively call the FrameworkunifiedOnHSMStop till current
+ // state has no active state i.e. current state is leaf state
+ if (m_pActiveState) {
+ m_pActiveState->FrameworkunifiedOnHSMStop(f_pEventData);
+ }
+
+ m_pActiveState = m_pDefaultState;
+
+ // Post deferred events to statemachine event queue
+ CHKNULL(m_pDeferredPostEventList); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
+
+ // recall deferred events till the vector is empty
+ while (!m_pDeferredPostEventList->empty()) {
+ // get the first event list object
+ CEventDataPtr l_pEventData = m_pDeferredPostEventList->front();
+
+ CHKNULL(l_pEventData);
+ CHKNULL(m_pEventName);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Recalling event %d %s in state %s"
+ , l_pEventData->m_uiEventId,
+ (m_pEventName->find(l_pEventData->m_uiEventId)->second).c_str(), m_strStateName.c_str());
+
+ m_pDeferredPostEventList->erase(m_pDeferredPostEventList->begin());
+
+ // recall the event stored in the eventinfo object
+ FrameworkunifiedPostEvent(l_pEventData);
+ }
+
+ FrameworkunifiedOnExit(f_pEventData);
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ return NULL;
+ }
+
+ return l_pActiveState;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// IsEventDeferred
+/// This checks if the given event is marked as deferred in the state.
+///////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFrameworkunifiedState::IsEventDeferred(UI_32 f_uiEventId) {
+ BOOL bStatus = FALSE;
+ try {
+ CHKNULL(m_pDeferredEventList); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
+ if (f_uiEventId == m_pDeferredEventList->at(l_uiCount)) {
+ bStatus = TRUE;
+ break;
+ }
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+
+ return bStatus; // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedRemoveEventFromDeferredEventList
+/// This function removes the event from the posted deferred queue list of the state.
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedRemoveEventFromDeferredEventList(UI_32 f_uiEventId) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldID;
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "+");
+
+ try {
+ CHKNULL(m_pDeferredPostEventList);
+ int32_t l_siCnt = static_cast<int32_t>(m_pDeferredPostEventList->size() - 1);
+
+ for (; l_siCnt >= 0; l_siCnt--) {
+ if (NULL != m_pDeferredPostEventList->at(l_siCnt).get()) {
+ if (f_uiEventId == m_pDeferredPostEventList->at(l_siCnt).get()->m_uiEventId) {
+ m_pDeferredPostEventList->erase(m_pDeferredPostEventList->begin() + l_siCnt);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG_CUT(ZONE_NS_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedRecallEvent
+/// This indicates if the state has sub states. It returns TRUE only in the CompositeState
+/// where this function is overridden
+///////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFrameworkunifiedState::FrameworkunifiedHasSubStates() {
+ return FALSE;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedPrintStates
+/// This logs the state name and events associated with the state
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPrintStates() {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ EventReactionIterator l_objEventIterator;
+ try {
+ CHKNULL(m_pEventList);
+ CHKNULL(m_pDeferredEventList);
+ CHKNULL(m_pEventName);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "%s:%s",
+ (m_pParentState->m_strStateName).c_str(), m_strStateName.c_str());
+
+ // print events
+ for (l_objEventIterator = m_pEventList->begin();
+ l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "event %d %s", ((*l_objEventIterator).first),
+ (m_pEventName->find((*l_objEventIterator).first)->second).c_str());
+ }
+
+ // print deferred events
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "deferred event %d %s", m_pDeferredEventList->at(l_uiCount),
+ (m_pEventName->find(m_pDeferredEventList->at(l_uiCount))->second).c_str());
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str());
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return eStatus;
+}
+
+BOOL CFrameworkunifiedState::FrameworkunifiedHasOrthogoanlRegions() {
+ return FALSE;
+}
+
+BOOL CFrameworkunifiedState::FrameworkunifiedIsReactionAvailable(UI_32 f_uiEventId) {
+ BOOL IsReactionAvailable = FALSE;
+ CFrameworkunifiedReaction *l_pEventReaction = NULL;
+
+ try {
+ // LCOV_EXCL_BR_START 15:marco defined in frameworkunified_sm_framework_types.h
+ CHKNULL(m_pEventList);
+ CHKNULL(m_pDeferredEventList);
+ // LCOV_EXCL_BR_STOP
+ if (m_pEventList->end() != m_pEventList->find(f_uiEventId)) {
+ // Find the reaction object for given event id
+ l_pEventReaction = reinterpret_cast<CFrameworkunifiedReaction *>((m_pEventList->find(f_uiEventId))->second);
+ }
+
+ if (l_pEventReaction) {
+ IsReactionAvailable = TRUE;
+ } else {
+ if (IsEventDeferred(f_uiEventId)) {
+ IsReactionAvailable = TRUE;
+ }
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+
+ return IsReactionAvailable; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(f_pStatemachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
+ m_pStateMachine = f_pStatemachine;
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+HANDLE CFrameworkunifiedState:: FrameworkunifiedGetAppHandle() {
+ HANDLE l_pHApp = NULL;
+ try {
+ CHKNULL(m_pStateMachine); // LCOV_EXCL_BR_LINE 15:marco defined in frameworkunified_sm_framework_types.h
+ l_pHApp = m_pStateMachine->FrameworkunifiedGetAppHandle(); // LCOV_EXCL_BR_LINE 11:except branch
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ }
+ return l_pHApp; // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+EFrameworkunifiedStatus CFrameworkunifiedState::FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EventReactionIterator l_objEventIterator;
+ try {
+ CHKNULL(m_pEventList);
+ CHKNULL(m_pDeferredEventList);
+ CHKNULL(m_pEventName);
+
+ f_strXMLString << "<" << m_strStateName.c_str() << ">";
+
+ f_strXMLString << "<EventList>";
+ // print events
+ for (l_objEventIterator = m_pEventList->begin();
+ l_objEventIterator != m_pEventList->end(); l_objEventIterator++) {
+ std::string l_strEventName =
+ (m_pEventName->find((*l_objEventIterator).first)->second);
+
+ UI_32 l_uiEventId = (*l_objEventIterator).first;
+
+ f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
+
+ f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
+
+ f_strXMLString << "</Event>";
+ }
+ f_strXMLString << "</EventList>";
+
+ // print deferred events
+ f_strXMLString << "<DeferredEventList>";
+ for (UI_32 l_uiCount = 0; l_uiCount < m_pDeferredEventList->size(); l_uiCount++) {
+ UI_32 l_uiEventId = m_pDeferredEventList->at(l_uiCount);
+
+ std::string l_strEventName = (m_pEventName->find(l_uiEventId)->second);
+
+ f_strXMLString << "<Event " << "Id = " << "\"" << l_uiEventId << "\">";
+
+ f_strXMLString << "<Name>" << l_strEventName.c_str() << "</Name>";
+
+ f_strXMLString << "</Event>";
+ }
+
+ f_strXMLString << "</DeferredEventList>";
+ f_strXMLString << "</" << m_strStateName.c_str() << ">";
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Failed to print in state %s", m_strStateName.c_str());
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp
new file mode 100644
index 00000000..1162f61b
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/frameworkunified_sm_transition.cpp
@@ -0,0 +1,57 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NSFramework
+/// .
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the CFrameworkunifiedTransition class definitions.This class provides the interface
+/// for reacting local transition and external transition
+///
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_transition.h>
+#include <native_service/frameworkunified_sm_state.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// CFrameworkunifiedTransition
+/// Parameterized constructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedTransition::CFrameworkunifiedTransition(CFrameworkunifiedState *f_pTargetState): m_pTargetState(f_pTargetState) {
+ if (m_pTargetState) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "Transition created with Target %s ",
+ (m_pTargetState->m_strStateName).c_str());
+ // LCOV_EXCL_BR_STOP
+ }
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// ~CFrameworkunifiedTransition
+/// Class destructor
+///////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedTransition::~CFrameworkunifiedTransition() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
+}
+
diff --git a/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile
new file mode 100644
index 00000000..964a1f50
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_FrameworkCore/src/statemachine/makefile
@@ -0,0 +1,99 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+COMPONENT_NAME = NS_FrameworkCore
+
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG). \
+ $(CC_IFLAG)../../inc \
+ $(CC_IFLAG)../../inc/statemachine \
+ $(DEPENDS_INCLUDES) \
+
+
+## Sources Section
+
+SOURCES = \
+ $(wildcard *.c*)
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard ../../inc/*.h) \
+ $(wildcard ../../inc/NS_Statemachine/*.h) \
+ $(wildcard $(REPOSITORY_ROOT)NativeServices/inc/*.h) \
+
+# Make targets
+# Standard
+all: banner module_dirs local
+
+base: banner module_dirs subdirs local
+
+binary: base
+
+local: $(OBJECTS)
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+# Defines specific for each deliverable
+
+
+# Default source file build rules
+$(OBJECTS): $(HEADERS)
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_Logger/cfg/depends.mk b/nsframework/framework_unified/client/NS_Logger/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Logger/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_Logger/include/frameworkunified_stub.h b/nsframework/framework_unified/client/NS_Logger/include/frameworkunified_stub.h
new file mode 100644
index 00000000..22630385
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Logger/include/frameworkunified_stub.h
@@ -0,0 +1,111 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_LOGGER_INCLUDE_FRAMEWORKUNIFIED_STUB_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_LOGGER_INCLUDE_FRAMEWORKUNIFIED_STUB_H_
+
+/*#include <PosixBasedOS001legacy_types.h>*/ // for _UintXXt
+
+#define _NTO_TRACE_USERFIRST (0x00000000)
+
+// from types.h
+typedef char *__NTO_va_list;
+
+// from sys/platform.h
+#define __CLOCKADJUST \
+ { \
+ unsigned long tick_count; /*NOLINT (readability/nolint)*/\
+ long tick_nsec_inc; /*NOLINT (readability/nolint)*/\
+ }
+
+// from syspage.h
+struct _clockadjust __CLOCKADJUST;
+struct qtime_entry {
+ _Uint64t cycles_per_sec; /* for ClockCycle */
+ _Uint64t volatile nsec_tod_adjust;
+ _Uint64t volatile nsec;
+ unsigned long nsec_inc; // NOLINT (readability/nolint)
+ unsigned long boot_time; /* UTC seconds when machine booted */ // NOLINT (readability/nolint)
+
+ struct _clockadjust adjust;
+ unsigned long timer_rate; /* times 10^timer_scale */ // NOLINT (readability/nolint)
+ long timer_scale; // NOLINT (readability/nolint)
+ unsigned long timer_load; // NOLINT (readability/nolint)
+ long intr; // NOLINT (readability/nolint)
+ unsigned long epoch; // NOLINT (readability/nolint)
+ unsigned long flags; // NOLINT (readability/nolint)
+ unsigned int rr_interval_mul;
+ unsigned long spare0; // NOLINT (readability/nolint)
+ _Uint64t volatile nsec_stable;
+ unsigned long spare[4]; // NOLINT (readability/nolint)
+};
+
+struct syspage_entry *_syspage_ptr;
+
+typedef struct {
+ _Uint16t entry_off;
+ _Uint16t entry_size;
+} syspage_entry_info;
+
+struct syspage_entry {
+ _Uint16t size; /* size of syspage_entry */
+ _Uint16t total_size; /* size of system page */
+ _Uint16t type;
+ _Uint16t num_cpu;
+ syspage_entry_info system_private;
+ syspage_entry_info asinfo;
+ syspage_entry_info meminfo;
+ syspage_entry_info hwinfo;
+ syspage_entry_info cpuinfo;
+ syspage_entry_info cacheattr;
+ syspage_entry_info qtime;
+ syspage_entry_info callout;
+ syspage_entry_info callin;
+ syspage_entry_info typed_strings;
+ syspage_entry_info strings;
+ syspage_entry_info intrinfo;
+ syspage_entry_info smp;
+ syspage_entry_info pminfo;
+ syspage_entry_info mdriver;
+ long spare[2]; // NOLINT (readability/nolint)
+ union {
+#if defined(SYSPAGE_TARGET_ALL) || defined(SYSPAGE_TARGET_X86)
+ struct x86_syspage_entry x86;
+#endif
+#if defined(SYSPAGE_TARGET_ALL) || defined(SYSPAGE_TARGET_PPC)
+ struct ppc_syspage_entry ppc;
+#endif
+#if defined(SYSPAGE_TARGET_ALL) || defined(SYSPAGE_TARGET_MIPS)
+ struct mips_syspage_entry mips;
+#endif
+#if defined(SYSPAGE_TARGET_ALL) || defined(SYSPAGE_TARGET_ARM)
+ struct arm_syspage_entry arm;
+#endif
+#if defined(SYSPAGE_TARGET_ALL) || defined(SYSPAGE_TARGET_SH)
+ struct sh_syspage_entry sh;
+#endif
+ struct {
+ long filler[20]; // NOLINT (readability/nolint)
+ } filler;
+ } un;
+};
+
+#define _SYSPAGE_ENTRY( __base, __field ) /*NOLINT (readability/nolint)*/\
+ ((struct __field##_entry *)reinterpret_cast<void *>(reinterpret_cast<char *>(__base)\
+ + (__base)->__field.entry_off))
+#define SYSPAGE_ENTRY(__field) _SYSPAGE_ENTRY(_syspage_ptr, __field)
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_LOGGER_INCLUDE_FRAMEWORKUNIFIED_STUB_H_
diff --git a/nsframework/framework_unified/client/NS_Logger/include/ns_logger_internal.h b/nsframework/framework_unified/client/NS_Logger/include/ns_logger_internal.h
new file mode 100644
index 00000000..97bde912
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Logger/include/ns_logger_internal.h
@@ -0,0 +1,44 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief API Header for Zone Player Service APIs to be used by senders and
+/// receivers.
+///
+/// Declares the external APIs to Zone Player Service.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_LOGGER_INCLUDE_NS_LOGGER_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_LOGGER_INCLUDE_NS_LOGGER_INTERNAL_H_
+
+// PASA Headers
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void _GetTimeString(PSTR format, UI_16 length);
+void _BuildFormatString(HANDLE hMsgQ, const UI_16 f_uiZoneIndex, PCSTR process_name, PCSTR p_pstrClassName_i,
+ const UI_32 p_lLine_i, PCSTR lpszFormat, PSTR format, UI_16 length);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_LOGGER_INCLUDE_NS_LOGGER_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_Logger/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_Logger/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..25318bee
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Logger/src/makefile_PosixBasedOS001
@@ -0,0 +1,223 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_Logger
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_Logger
+
+#All possible logging options
+#NS_LOG_FORMAT = NS_LCLOCKCYCLES_IN_TIMESTRING
+#NS_LOG_FORMAT = NS_LCLOCKCYCLES_IN_MS
+#NS_LOG_FORMAT = NS_LCURDATETIME
+
+ifndef NS_LOG_FORMAT
+NS_LOG_FORMAT = NS_LCURDATETIME
+endif
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS += -D $(NS_LOG_FORMAT)
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_MessageQueue/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NS_MessageQueue/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NS_Logger/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+# NS_MessageCenter library is added as dependency for logger.
+# This is a temporary solution to support event logger (required by VehicleServices).
+# Fix the problem in proper way so that it should not depend on NS_MessageCenter after PastModel002 delivery.
+ifdef DYNAMIC
+ DYNAMIC_LIBS += \
+ NS_MessageQueue$(DEBUG_EXT) \
+ NS_MessageCenter$(DEBUG_EXT)
+else
+ STATIC_LIBS +=
+endif
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
+
diff --git a/nsframework/framework_unified/client/NS_Logger/src/ns_logger.cpp b/nsframework/framework_unified/client/NS_Logger/src/ns_logger.cpp
new file mode 100644
index 00000000..94f775ce
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Logger/src/ns_logger.cpp
@@ -0,0 +1,2260 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief
+///
+/// Frameworkunified Framework Handlers Logging to log services.
+///////////////////////////////////////////////////////////////////////////////
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/timeb.h>
+#include <time.h>
+#include <sys/syscall.h>
+#include <sys/prctl.h>
+#include <syslog.h>
+#include <boost/algorithm/string.hpp>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <aglpath.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <arpa/inet.h>
+
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_eventlogger.h>
+#include <native_service/cl_lockid.h>
+
+#ifdef AGL_STUB
+#include <other_service/strlcat.h>
+#include <other_service/strlcpy.h>
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#include "frameworkunified_stub.h"
+#else
+#include <sys/neutrino.h>
+#include <sys/trace.h> // trace_nlogf
+#include <sys/slog.h>
+#include <sys/slogcodes.h>
+#include <sys/syspage.h>
+#endif
+
+#include <map>
+#include <vector>
+#include <sstream>
+#include <utility>
+#include <string>
+
+#include "ns_logger_internal.h"
+#include "ns_msg_queue.h"
+#include "mqueue.h"
+
+static HANDLE g_hSSEventLogQ = INVALID_HANDLE;
+#ifndef AGL_STUB
+static HANDLE g_hNSplogMsgQ = INVALID_HANDLE;
+#endif
+static HANDLE g_hNSSysEventLogQ = INVALID_HANDLE;
+static __thread CHAR tls_strProcessName[MAX_NAME_SIZE_APP];
+static __thread pid_t tid = 0;
+static UI_32 g_msgcounter = 0;
+static FRAMEWORKUNIFIEDLOGPARAM g_LocalFrameworkunifiedLogParams;
+static UI_32 syslogopened;
+static int shm_fd = -1;
+static const unsigned int default_log_cfgtbl[] = {
+ // realTimeLog
+ FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF,
+ // flagIdNum
+ 1,
+ // logLevel
+ FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE,
+};
+static void *shm_pmap = reinterpret_cast<void *>(const_cast<unsigned int*>(default_log_cfgtbl));
+#define EXE_STR_LEN 64
+static char exe_link_path[EXE_STR_LEN] = {0};
+
+/// For PLog
+#define PLOG_GAP_FILE "/dev/shmem/Plog.gap"
+#define MAX_GAP_BUFFER_LEN 80
+#define MAX_PLOG_STRING_SIZE 1024
+#define MAX_TIME_FORMATSTR_LEN 3
+#define RETRY_COUNT 5
+FRAMEWORKUNIFIEDLOGPPARAM g_FrameworkunifiedLogPParams = {FALSE, EPLOG_TIME_FORMAT_USEC, 0, EPLOG_MSGQ}; // default values for PLog
+FRAMEWORKUNIFIEDLOGSYSEVENTPARAM g_FrameworkunifiedLogSysEventParams = {FALSE}; // default values for System event log
+
+#define ZONEMASK_MAX BITS_IN_TZONE // ((UI_32)(BITS_IN_TZONE * TZONE_COUNT))
+
+#define FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID (0)
+#define FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__FN "/usr/agl/conf/BS/ns/framework_unified/rodata/ns_logger_frameworkunifiedlog__CWORD84_.cfg"
+#define FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__TMP "ns_logger_frameworkunifiedlog__CWORD84_.tmp"
+#define FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV "ns_logger_frameworkunifiedlog__CWORD84_.cfg"
+
+#define FRAMEWORKUNIFIEDLOG_CONFIG_NV "/nv/BS/ns/framework_unified/rwdata/"
+
+#define FRAMEWORKUNIFIEDLOG_CONFIG_TMP_NV "ns_logger_frameworkunifiedlog_tmp.cfg"
+#ifndef TN_LOGGERRTIME
+#define TN_LOGGERRTIME "LoggerRtime"
+#define PR_LOGGERRTIME_S PR_TSS_S
+#define PR_LOGGERRTIME PR_TSS
+#endif // TN_LOGGERRTIME
+#define USB_REALTIME_MSGMAX 256
+#define USB_REALTIME_SIZMAX 4096
+#define USB_REALTIME_QNAME "/PlRtLogger"
+#define USB_REALTIME_RTRYMAX 10
+static mqd_t g_qid = (mqd_t)(-1);
+
+unsigned int g_FlagIdNum;
+std::vector<std::string> g_flag_name;
+
+typedef struct {
+ CNSRingBuffer *ring_buffer;
+ std::string file_name;
+ UI_32 size;
+ BOOL force_output;
+
+ BOOL real_time_log;
+} FrameworkunifiedLogMapTbl;
+
+typedef struct {
+ TFrameworkunifiedZone zone;
+ FrameworkunifiedLogMapTbl info;
+} FrameworkunifiedLogTbl;
+
+typedef std::map<TFrameworkunifiedZone, FrameworkunifiedLogMapTbl> TFrameworkunifiedLogMap;
+static TFrameworkunifiedLogMap g_FrameworkunifiedLogMap;
+static TFrameworkunifiedLogMap g_FrameworkunifiedLogFlagMap;
+static UI_32 g_FrameworkunifiedLogFlagId = FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID;
+
+static bool g_FrameworkunifiedLogFlagRealTimeLog = TRUE;
+pthread_mutex_t FrameworkunifiedLogMtx = PTHREAD_MUTEX_INITIALIZER;
+
+#ifdef ENABLE_DEBUG_SYSLOG // for FRAMEWORKUNIFIED_SET_ZONES() error
+#define DEB_SYSLOG(fmt, ...) {openlog(0, LOG_PID, LOG_USER); \
+ syslog(LOG_ERR, "[FRAMEWORKUNIFIEDLOG][ERR]EXE_LINK_PATH(%s)[%s:L%d] " fmt, exe_link_path, \
+ __FUNCTION__, __LINE__, ## __VA_ARGS__); \
+ closelog();}
+#else
+#define DEB_SYSLOG(fmt, ...)
+#endif
+
+static UI_32
+GetFrameworkunifiedLogRealtimeUartOutput(CNSConfigReader *cfg_reader) {
+ if (cfg_reader == NULL) {
+ return -1;
+ }
+
+ std::string output_str = cfg_reader->GetString("REALTIME_LOG.Output"); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (output_str.compare("UART") == 0) {
+ return FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART;
+ } else if (output_str.compare("USB") == 0) {
+ return FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB;
+ } else {
+ return FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ }
+}
+
+static EFrameworkunifiedStatus
+GetFrameworkunifiedLogZoneFileInfo(CNSConfigReader *cfg_reader, std::string &name, // NOLINT (readability/nolint)
+ FrameworkunifiedLogMapTbl &tbl, UI_32 &zone) { // NOLINT (readability/nolint)
+ std::string zone_key = name;
+ zone_key.append(".Zone");
+ std::string zone_filename_key = name; // LCOV_EXCL_BR_LINE 11:expect branch
+ zone_filename_key.append(".FileName");
+ std::string zone_filesize_key = name; // LCOV_EXCL_BR_LINE 11:expect branch
+ zone_filesize_key.append(".FileSizeMax");
+ std::string zone_force_output_key = name; // LCOV_EXCL_BR_LINE 11:expect branch
+ zone_force_output_key.append(".ForceOutput");
+
+ if (cfg_reader == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ tbl.ring_buffer = NULL;
+ tbl.file_name = cfg_reader->GetString(zone_filename_key);
+ tbl.size = static_cast<UI_32>(cfg_reader->GetInt(zone_filesize_key));
+ tbl.force_output
+ = (cfg_reader->GetString(zone_force_output_key) == "True") ? TRUE : FALSE;
+
+ tbl.real_time_log = TRUE;
+ zone = ZONEMASK(static_cast<UI_32>(cfg_reader->GetInt(zone_key)));
+ return eFrameworkunifiedStatusOK;
+}
+
+static EFrameworkunifiedStatus
+GetFrameworkunifiedLogFlagFileInfo(CNSConfigReader *cfg_reader, std::string &name, // NOLINT (readability/nolint)
+ FrameworkunifiedLogMapTbl &tbl, UI_32 &loglevel) { // NOLINT (readability/nolint)
+ std::string flag_loglevel_key = name;
+ flag_loglevel_key.append(".LogLevel");
+ std::string flag_filename_key = name; // LCOV_EXCL_BR_LINE 11:expect branch
+ flag_filename_key.append(".FileName");
+ std::string flag_filesize_key = name; // LCOV_EXCL_BR_LINE 11:expect branch
+ flag_filesize_key.append(".FileSizeMax");
+
+ std::string flag_real_time_log_key = name;
+ flag_real_time_log_key.append(".Realtimelog");
+
+ if (cfg_reader == NULL) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+
+ tbl.ring_buffer = NULL;
+ tbl.file_name = cfg_reader->GetString(flag_filename_key); // LCOV_EXCL_BR_LINE 11:expect branch
+ tbl.size = static_cast<UI_32>(cfg_reader->GetInt(flag_filesize_key)); // LCOV_EXCL_BR_LINE 11:expect branch
+ tbl.force_output = FALSE;
+
+ tbl.real_time_log
+ = (cfg_reader->GetString(flag_real_time_log_key) == "False") ? FALSE : TRUE;
+
+
+ std::string loglevel_str = cfg_reader->GetString(flag_loglevel_key); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (loglevel_str.compare("Debug") == 0) {
+ loglevel = FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG;
+ } else {
+ loglevel = FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE;
+ }
+
+ if ((tbl.file_name.empty()) || (tbl.size == 0)) {
+ return eFrameworkunifiedStatusFail;
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+static VOID
+GetFrameworkunifiedLogList(CNSConfigReader *cfg_reader, std::vector<std::string> &list, // NOLINT (readability/nolint)
+ std::string req_list) {
+ if (cfg_reader == NULL) {
+ return;
+ }
+
+ std::string list_str = cfg_reader->GetString(req_list);
+ if (!list_str.empty()) {
+ try {
+ boost::algorithm::split(list, list_str, boost::is_any_of(", "));
+ }
+ /*
+ * @todo
+ * Even if throw is executed by the process called by 'try', it cannot be captured by catch().
+ */
+ catch (...) {
+ fprintf(stderr, "occured exception handling by boost::algorithm::split in ns_logger\n");
+ }
+ }
+}
+
+static BOOL
+CheckMatchFrameworkunifiedLogFlagMap(TFrameworkunifiedLogMap &map, FrameworkunifiedLogMapTbl &check_tbl, // NOLINT (readability/nolint)
+ FrameworkunifiedLogMapTbl &out_tbl) { // NOLINT (readability/nolint)
+ TFrameworkunifiedLogMap::iterator itr;
+ for (itr = map.begin(); itr != map.end(); itr++) {
+ if (itr->second.file_name.compare(check_tbl.file_name) == 0) {
+ out_tbl = itr->second;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static BOOL
+IsDefinedFrameworkunifiedLogFlag(CNSConfigReader *cfg_reader, std::string &flag_name, // NOLINT (readability/nolint)
+ std::string &exe_name) { // NOLINT (readability/nolint)
+ UI_32 cnt = 1;
+ size_t pos1;
+
+ if (cfg_reader == NULL) {
+ return FALSE;
+ }
+
+ while (1) {
+ std::string service_key = flag_name;
+ std::ostringstream service_num; // LCOV_EXCL_BR_LINE 11:expect branch
+ service_num << ".Service" << cnt;
+ service_key.append(service_num.str());
+ std::string service_name = cfg_reader->GetString(service_key);
+ if (service_name.empty()) {
+ break;
+ }
+ pos1 = exe_name.find(service_name);
+ if ((pos1 != std::string::npos)
+ && (exe_name.length() - pos1) == service_name.length()) {
+ return TRUE;
+ }
+ cnt++;
+ }
+ return FALSE;
+}
+
+static VOID
+CreateFrameworkunifiedLogFileTbl(CNSConfigReader *cfg_reader, std::string &exe_str, // NOLINT (readability/nolint)
+ int *realTimeLog, int **logLevelArray) {
+ int *logLevel;
+
+ std::vector<std::string> zone_vector;
+ GetFrameworkunifiedLogList(cfg_reader, zone_vector, "ZONE_LIST.List");
+ for (UI_32 i = 0; i < zone_vector.size(); i++) {
+ FrameworkunifiedLogMapTbl zone_tbl;
+ UI_32 zone;
+ if (GetFrameworkunifiedLogZoneFileInfo(cfg_reader, zone_vector.at(i), zone_tbl, zone)
+ == eFrameworkunifiedStatusOK) {
+ g_FrameworkunifiedLogMap.insert(std::make_pair(zone, zone_tbl));
+ }
+ }
+
+ *realTimeLog = static_cast<int>(GetFrameworkunifiedLogRealtimeUartOutput(cfg_reader));
+
+ FrameworkunifiedLogMapTbl default_tbl;
+ UI_32 default_id = FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID;
+ std::string default_flag = "FLAG_DEFAULT"; // LCOV_EXCL_BR_LINE 11:expect branch
+ UI_32 default_loglevel;
+ if (GetFrameworkunifiedLogFlagFileInfo(cfg_reader, default_flag, default_tbl, default_loglevel)
+ != eFrameworkunifiedStatusOK) {
+ fprintf(stderr, "<WARNING>FRAMEWORKUNIFIEDLOG[%s:L%d]FLAG_DEFAULT is not definition into ns_logger_frameworkunifiedlog.cfg.\n",
+ __FUNCTION__, __LINE__);
+
+ DEB_SYSLOG("<WARNING>FLAG_DEFAULT is not definition into ns_logger_frameworkunifiedlog.cfg.)");
+ default_tbl.ring_buffer = NULL;
+ default_tbl.file_name = "frameworkunified_debug.log";
+ default_tbl.size = 100; // 100bytes
+
+ default_tbl.real_time_log = TRUE;
+ }
+ std::vector<std::string> flag_vector;
+ UI_32 flag_id = FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID + 1;
+ GetFrameworkunifiedLogList(cfg_reader, flag_vector, "FLAG_LIST.List"); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (g_FlagIdNum != (flag_vector.size() + 1)) {
+ if (!g_FrameworkunifiedLogFlagMap.empty()) {
+ TFrameworkunifiedLogMap::iterator delitr;
+ unsigned int delflag_id;
+ for (delflag_id = 0; delflag_id < g_FlagIdNum; delflag_id++) {
+ delitr = g_FrameworkunifiedLogFlagMap.find(delflag_id);
+ if (delitr->second.ring_buffer != NULL) {
+ delete delitr->second.ring_buffer;
+ delitr->second.ring_buffer = NULL;
+ }
+ }
+ g_FrameworkunifiedLogFlagMap.clear();
+ if (!g_flag_name.empty()) {
+ g_flag_name.clear();
+ }
+ }
+ g_FlagIdNum = static_cast<unsigned int>(flag_vector.size() + 1); // +1: [Add Default Flag]
+ g_flag_name.push_back(default_flag); // LCOV_EXCL_BR_LINE 11:expect branch
+ g_FrameworkunifiedLogFlagMap.insert(std::make_pair(default_id, default_tbl)); // LCOV_EXCL_BR_LINE 11:expect branch
+ }
+ logLevel = reinterpret_cast<int *>(malloc(sizeof(int) * g_FlagIdNum));
+ logLevel[0] = default_loglevel;
+
+ for (UI_32 i = 0; i < flag_vector.size(); i++) {
+ FrameworkunifiedLogMapTbl flag_tbl;
+ UI_32 loglevel;
+ if (GetFrameworkunifiedLogFlagFileInfo(cfg_reader, flag_vector.at(i), flag_tbl, loglevel)
+ == eFrameworkunifiedStatusOK) {
+ FrameworkunifiedLogMapTbl check_result_tbl;
+ if (CheckMatchFrameworkunifiedLogFlagMap(g_FrameworkunifiedLogFlagMap, flag_tbl, check_result_tbl)
+ == TRUE) {
+ flag_tbl.file_name = check_result_tbl.file_name;
+ flag_tbl.size = check_result_tbl.size;
+ }
+ if (g_FrameworkunifiedLogFlagMap.find(flag_id) == g_FrameworkunifiedLogFlagMap.end()) {
+ if (IsDefinedFrameworkunifiedLogFlag(cfg_reader, flag_vector.at(i), exe_str)
+ == TRUE) {
+ g_FrameworkunifiedLogFlagId = flag_id;
+
+ g_FrameworkunifiedLogFlagRealTimeLog = flag_tbl.real_time_log;
+ }
+ g_flag_name.push_back(flag_vector.at(i));
+ g_FrameworkunifiedLogFlagMap.insert(std::make_pair(flag_id, flag_tbl));
+ }
+ }
+ logLevel[flag_id] = loglevel;
+ flag_id++;
+ }
+ *logLevelArray = logLevel;
+}
+
+static VOID
+GetFrameworkunifiedLogRingBuffer(const UI_16 zone, CNSRingBuffer **ring_buf) {
+ TFrameworkunifiedLogMap::iterator itr = g_FrameworkunifiedLogMap.find(zone);
+
+ if (ring_buf == NULL) {
+ return;
+ }
+
+ if (itr == g_FrameworkunifiedLogMap.end()) {
+ itr = g_FrameworkunifiedLogFlagMap.find(g_FrameworkunifiedLogFlagId);
+ if (itr == g_FrameworkunifiedLogFlagMap.end()) {
+ // ASSERT
+ *ring_buf = NULL;
+ return;
+ }
+ }
+
+ pthread_mutex_lock(&FrameworkunifiedLogMtx);
+
+ if (itr->second.ring_buffer == NULL) {
+ std::string file_path;
+ int index;
+
+ file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ file_path.append("/"); // LCOV_EXCL_BR_LINE 11:expect branch
+ file_path.append(itr->second.file_name);
+
+ index = NSLogGetFrameworkunifiedlogIndex(file_path.c_str());
+ itr->second.ring_buffer = new(std::nothrow) CNSRingBuffer(file_path, itr->second.size,
+ index + LOCK_NSLOG_ACCES_IF_1); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (itr->second.ring_buffer != NULL) {
+ itr->second.ring_buffer->Open();
+ }
+ }
+ pthread_mutex_unlock(&FrameworkunifiedLogMtx);
+
+ *ring_buf = itr->second.ring_buffer;
+}
+
+static int
+MapShmInfo(int flagId) {
+ int size;
+ void *pmap;
+
+ if (shm_fd != -1) {
+ return -1;
+ }
+ shm_fd = shm_open(FRAMEWORKUNIFIEDLOG_SHARED_MEM_NAME, O_RDONLY, S_IRWXU | S_IRWXO);
+ if (shm_fd == -1) {
+
+ DEB_SYSLOG("shm_open error errno:%d", errno);
+ return -1;
+ }
+ size = static_cast<int>(sizeof(int) * 2); // realTimeLog + flagIdNum
+ size += static_cast<int>(sizeof(int) * (flagId + 1)); // g_FrameworkunifiedLogFlagId + DefaultFlagId
+
+ pmap = reinterpret_cast<int *>(mmap(NULL, size, PROT_READ, MAP_SHARED, shm_fd, 0));
+ if (pmap == MAP_FAILED) {
+
+ DEB_SYSLOG("mmap error errno:%d", errno);
+ close(shm_fd);
+ shm_fd = -1;
+ return -1;
+ }
+ shm_pmap = pmap;
+
+ return 0;
+}
+
+static inline void
+GetShmInfo(int flagId, int *realTimeLog, int *logLevel) {
+ volatile ssize_t *p;
+
+ if ((realTimeLog == NULL) || (logLevel == NULL)) {
+ return;
+ }
+
+ p = static_cast<ssize_t *>(shm_pmap);
+ *realTimeLog = static_cast<int>(p[0]);
+ p += 2;
+ *logLevel = static_cast<int>(p[flagId]);
+}
+
+static BOOL
+IsExistFrameworkunifiedLogCfgShmem(void) {
+ if (shm_pmap == reinterpret_cast<void *>(const_cast<unsigned int*>(default_log_cfgtbl))) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static BOOL
+NsLogIsZonePrintEnable(const UI_16 zone, UI_8 *mode) {
+ int l_realTimeLog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ int l_loglevel = FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE;
+
+ if (mode == NULL) {
+ return FALSE;
+ }
+
+ GetShmInfo(g_FrameworkunifiedLogFlagId, &l_realTimeLog, &l_loglevel);
+ *mode = static_cast<UI_8>(l_realTimeLog);
+ if (l_realTimeLog == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF) {
+ return FALSE;
+ }
+
+ if ((ZONEMASK(96) <= (TFrameworkunifiedZone)zone)
+ && ((TFrameworkunifiedZone)zone <= ZONEMASK(127))) {
+ return FALSE;
+ }
+
+
+ if (g_FrameworkunifiedLogFlagRealTimeLog == FALSE) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static int
+copyFrameworkunifiedLogCfgFile(const char *l_cSrcPath, const char *l_cDestPath) {
+ int fd_in = -1;
+ int fd_ot = -1;
+ char l_buf[8*1024];
+ ssize_t l_nrd, l_nwr;
+
+ fd_in = open(l_cSrcPath, O_RDONLY | O_CLOEXEC);
+ if (fd_in == -1) {
+ return -1;
+ }
+
+ fd_ot = open(l_cDestPath, O_WRONLY | O_CREAT | O_CLOEXEC, 0640);
+ if (fd_ot == -1) {
+ close(fd_in);
+ return -1;
+ }
+
+ while (1) {
+ l_nrd = read(fd_in, l_buf, sizeof(l_buf));
+ if (l_nrd == 0) {
+ break;
+ }
+ if (l_nrd < 0) {
+ close(fd_in);
+ close(fd_ot);
+ return -1;
+ }
+
+ l_nwr = write(fd_ot, l_buf, l_nrd);
+ if (l_nwr < 0) {
+ close(fd_in);
+ close(fd_ot);
+ return -1;
+ }
+ }
+
+ if (fsync(fd_ot) != 0) {
+ close(fd_in);
+ close(fd_ot);
+ return -1;
+ }
+
+ close(fd_in);
+ close(fd_ot);
+
+ return 0;
+}
+
+
+static VOID
+copyFrameworkunifiedLogCfgFileToNv(void) {
+ int fd_in = -1;
+ int fd_ot = -1;
+ int fd_dr = -1;
+ char c[1];
+ ssize_t len;
+
+ // LCOV_EXCL_BR_START 11:Excluded due to gcov constraints (others)
+ std::string config_dirpath = FRAMEWORKUNIFIEDLOG_CONFIG_NV;
+ std::string config_tempname = FRAMEWORKUNIFIEDLOG_CONFIG_NV;
+ std::string config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV;
+ fd_in = open(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__FN, O_RDONLY);
+ config_tempname.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__TMP);
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV);
+ // LCOV_EXCL_BR_STOP 11:Excluded due to gcov constraints (others)
+
+ if (fd_in == -1) {
+ return;
+ }
+
+ unlink(config_tempname.c_str());
+
+ fd_ot = open(config_tempname.c_str(), O_WRONLY | O_CREAT, 0640); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (fd_ot == -1) {
+ DEB_SYSLOG("open error errno:%d", errno);
+ close(fd_in); // LCOV_EXCL_BR_LINE 11:expect branch
+ return;
+ }
+
+ while (1) {
+ len = read(fd_in, c, sizeof(c));
+ if (len == 0) {
+ break;
+ }
+ if (len < 0) {
+ close(fd_in);
+ close(fd_ot);
+ return;
+ }
+ len = write(fd_ot, c, sizeof(c));
+ if (len < 0) {
+ close(fd_in);
+ close(fd_ot);
+ return;
+ }
+ }
+
+ if (fsync(fd_ot) != 0) {
+ close(fd_in);
+ close(fd_ot);
+ return;
+ }
+
+ close(fd_in);
+ close(fd_ot);
+
+ if (rename(config_tempname.c_str(), config_filename.c_str()) != 0) {
+
+ DEB_SYSLOG("rename error errno:%d", errno);
+ return;
+ }
+
+ fd_dr = open(config_dirpath.c_str(), O_RDONLY);
+ if (fd_dr == -1) {
+
+ DEB_SYSLOG("mmap error errno:%d", errno);
+ return;
+ }
+
+ fsync(fd_dr);
+
+ close(fd_dr);
+}
+
+#define WTYPE_NORMAL 0
+#define WTYPE_RTIMELOG 1
+static int
+WriteSharedMem(int flag, int realTimeLog, unsigned int flagIdNum, int *logLevelArray) {
+ int fd;
+ ssize_t *pp;
+ volatile ssize_t *p;
+ int size;
+
+ if ((flag == WTYPE_NORMAL)
+ && (logLevelArray == NULL)) {
+ return -1;
+ }
+
+ size = static_cast<int>(sizeof(int) * 2); // realTimeLog + flagIdNum
+ size += static_cast<int>(sizeof(int) * flagIdNum);
+
+ fd = shm_open(FRAMEWORKUNIFIEDLOG_SHARED_MEM_NAME, O_RDWR | O_CREAT, S_IRWXU | S_IRWXO);
+ if (fd == -1) {
+
+ DEB_SYSLOG("shm_open error errno:%d", errno);
+ return -1;
+ }
+
+ if (ftruncate(fd, size) == -1) {
+
+ DEB_SYSLOG("ftruncate error errno:%d", errno);
+ close(fd);
+ return -1;
+ }
+
+// pp = (int *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ pp = static_cast<ssize_t *>(mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
+ if (pp == MAP_FAILED) {
+
+ DEB_SYSLOG("mmap error errno:%d", errno);
+ close(fd);
+ return -1;
+ }
+
+ p = pp;
+ p[0] = realTimeLog;
+
+ if (flag == WTYPE_NORMAL) {
+ // flagIdNum
+ p[1] = flagIdNum;
+
+ // log level
+ p += 2;
+ for (unsigned int i = 0; i < flagIdNum; i++) {
+ *p = logLevelArray[i];
+ p++;
+ }
+ }
+ close(fd);
+ munmap(pp, size);
+
+ return 0;
+}
+
+static int
+WriteSharedMemForFlagId(int realTimeLog, unsigned int flagIdNum, int flagId,
+ int logLevel) {
+ int fd;
+ volatile ssize_t *p;
+ ssize_t *pp;
+ int size;
+
+ size = static_cast<int>(sizeof(int) * 2); // realTimeLog + flagIdNum
+ size += static_cast<int>(sizeof(int) * flagIdNum);
+
+ fd = shm_open(FRAMEWORKUNIFIEDLOG_SHARED_MEM_NAME, O_RDWR | O_CREAT, S_IRWXU | S_IRWXO);
+ if (fd == -1) {
+
+ DEB_SYSLOG("shm_open error errno:%d", errno);
+ return -1;
+ }
+
+ if (ftruncate(fd, size) == -1) {
+
+ DEB_SYSLOG("ftruncate error errno:%d", errno);
+ close(fd);
+ return -1;
+ }
+
+ pp = static_cast<ssize_t *>(mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
+ if (pp == MAP_FAILED) {
+
+ DEB_SYSLOG("mmap error errno:%d", errno);
+ close(fd);
+ return -1;
+ }
+
+ p = pp;
+ p[0] = realTimeLog;
+
+ // flagIdNum
+ p[1] = flagIdNum;
+
+ // log level
+ p += 2;
+ p[flagId] = logLevel;
+
+ close(fd);
+ munmap(pp, size);
+
+ return 0;
+}
+
+static BOOL
+IsExistFrameworkunifiedLogCfgNv(void) {
+ FILE *fp;
+ // LCOV_EXCL_BR_START 11:Excluded due to gcov constraints (others)
+ std::string config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV;
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV);
+ // LCOV_EXCL_BR_STOP 11:Excluded due to gcov constraints (others)
+
+ fp = fopen(config_filename.c_str(), "re");
+ if (fp == NULL) {
+ return FALSE;
+ }
+
+ fclose(fp);
+ return TRUE;
+}
+
+static int
+get_readlink_path(char *path) {
+ CHAR exe_path[EXE_STR_LEN];
+ CHAR buf[EXE_STR_LEN];
+ ssize_t len;
+
+ if (path == NULL) {
+ return -1;
+ }
+
+ path[0] = 0;
+ if (exe_link_path[0] == 0) {
+ pid_t pid = static_cast<pid_t>(syscall(__NR_getpid));
+ sprintf(exe_path, "/proc/%d/exe", pid); // NOLINT (readability/nolint)
+ memset(buf, 0, sizeof(buf));
+ len = readlink(exe_path, buf, (sizeof(buf) - 1));
+ if (len != -1) { // LCOV_EXCL_BR_LINE 200: exe_path can not non-existent
+ strcpy(exe_link_path, buf); // NOLINT (readability/nolint)
+ } else {
+ // LCOV_EXCL_START 200
+ AGL_ASSERT_NOT_TESTED();
+ fprintf(stderr, "<WARNING>FRAMEWORKUNIFIEDLOG[%s:L%d]Can't get readlink path(%s). errno(%d)\n", __FUNCTION__, __LINE__,
+ exe_path, errno);
+ DEB_SYSLOG("<WARNING>Can't get readlink path(%s)(errno:%d)", exe_path, errno);
+ return 0;
+ // LCOV_EXCL_STOP 200
+ }
+ }
+ strcpy(path, exe_link_path); // NOLINT (readability/nolint)
+ return 1; // OK
+}
+
+static void
+readConfig(int *realTimeLog, int **logLevelArray) {
+ CHAR buf[EXE_STR_LEN];
+
+ if (get_readlink_path(buf)) { // LCOV_EXCL_BR_LINE 200:get_readlink_path can not return false
+ std::string config_filename;
+ std::string exe_str = buf; // LCOV_EXCL_BR_LINE 11:expect branch
+
+ // LCOV_EXCL_BR_START 11:Excluded due to gcov constraints (others)
+ if (IsExistFrameworkunifiedLogCfgNv()) {
+ config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV;
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV);
+ } else {
+ config_filename = FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__FN;
+ }
+ // LCOV_EXCL_BR_STOP 11:Excluded due to gcov constraints (others)
+ CNSConfigReader *config_reader = new CNSConfigReader(); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (config_reader != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ if (config_reader->Parse(config_filename)
+ == eFrameworkunifiedStatusOK) {
+ CreateFrameworkunifiedLogFileTbl(config_reader, exe_str, realTimeLog, logLevelArray); // LCOV_EXCL_BR_LINE 11:expect branch
+ MapShmInfo(g_FrameworkunifiedLogFlagId); // LCOV_EXCL_BR_LINE 11:expect branch
+ } else {
+ DEB_SYSLOG("Parseg error %s", config_filename.c_str());
+ }
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ DEB_SYSLOG("new CNSConfigReader error");
+ // LCOV_EXCL_STOP 5
+ }
+ delete config_reader; // LCOV_EXCL_BR_LINE 11:expect branch1
+ } else {
+ // LCOV_EXCL_START 5: get_readlink_path can not return false
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ DEB_SYSLOG("get_readlink_path error");
+ // LCOV_EXCL_STOP 5
+ }
+}
+
+//////////////////////////////////////////
+// NSLogGetFrameworkunifiedlogFileTotalNum
+//////////////////////////////////////////
+UI_32
+NSLogGetFrameworkunifiedlogFileTotalNum(void) {
+ return static_cast<UI_32>((g_FrameworkunifiedLogMap.size() + g_FrameworkunifiedLogFlagMap.size()));
+}
+
+//////////////////////////////////////////
+// NSLogGetFrameworkunifiedlogFileName
+//////////////////////////////////////////
+PCSTR
+NSLogGetFrameworkunifiedlogFileName(UI_32 index) {
+ PCSTR name = NULL;
+
+ if ((g_FrameworkunifiedLogMap.size() + g_FrameworkunifiedLogFlagMap.size()) <= index) {
+ return NULL;
+ }
+
+ TFrameworkunifiedLogMap::iterator itr;
+ TFrameworkunifiedLogMap::iterator itr_end;
+ UI_32 cnt;
+
+ if (index < g_FrameworkunifiedLogMap.size()) {
+ cnt = 0;
+ itr = g_FrameworkunifiedLogMap.begin();
+ itr_end = g_FrameworkunifiedLogMap.end();
+ } else {
+ cnt = static_cast<UI_32>(g_FrameworkunifiedLogMap.size());
+ itr = g_FrameworkunifiedLogFlagMap.begin();
+ itr_end = g_FrameworkunifiedLogFlagMap.end();
+ }
+
+ for (; itr != itr_end; itr++, cnt++) {
+ if (cnt == index) {
+ name = itr->second.file_name.c_str();
+ break;
+ }
+ }
+ return name;
+}
+
+//////////////////////////////////////////
+// NSLogGetFrameworkunifiedlogIndex
+//////////////////////////////////////////
+int
+NSLogGetFrameworkunifiedlogIndex(PCSTR filename) {
+ TFrameworkunifiedLogMap::iterator itr;
+ TFrameworkunifiedLogMap::iterator itr_end;
+ UI_32 i = 0;
+ /**
+ * @todo
+ * Defining a NULL for arguments results in exceptions.
+ */
+ std::string fname = filename;
+
+ itr = g_FrameworkunifiedLogFlagMap.begin();
+ itr_end = g_FrameworkunifiedLogFlagMap.end();
+ for (; itr != itr_end; itr++, i++) {
+ if (fname.find(itr->second.file_name) != std::string::npos) {
+ return i;
+ }
+ }
+
+ itr = g_FrameworkunifiedLogMap.begin();
+ itr_end = g_FrameworkunifiedLogMap.end();
+ for (; itr != itr_end; itr++, i++) {
+ if (fname.find(itr->second.file_name) != std::string::npos) {
+ return i;
+ }
+ }
+ return 0;
+}
+
+UI_32
+ConvertEndian(UI_32 *pvar) {
+ UI_32 retVal = (UI_32)0;
+
+ if (pvar == NULL) {
+ return retVal;
+ }
+
+ UI_32 var = *pvar;
+ retVal = (((var & 0xFF000000) >> 24) |
+ ((var & 0x00FF0000) >> 8) |
+ ((var & 0x0000FF00) << 8) |
+ ((var & 0x000000FF) << 24));
+ return (retVal);
+}
+
+static void
+check_syslog_opened(void) {
+ if (!syslogopened) {
+ openlog(0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER);
+ syslogopened = 1;
+ }
+}
+
+static time_t
+tick_msec_get(void) {
+ struct timespec tp;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) { // LCOV_EXCL_BR_LINE 5: clock_gettime's error case
+ // LCOV_EXCL_START 5: clock_gettime's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return 0; /* NG */
+ // LCOV_EXCL_STOP 5
+ }
+ return tp.tv_sec * 1000 + tp.tv_nsec / 1000000;
+}
+
+static inline int
+num2string(PSTR buf, int digits, UI_32 num) {
+ PSTR p = NULL;
+ char c;
+
+ switch (digits) {
+ case 5:
+ p = buf;
+ if (num >= 100000) {
+ *p++ = '0';
+ *p++ = '0';
+ *p++ = '0';
+ *p++ = '0';
+ *p = '0';
+ break;
+ }
+ c = static_cast<char>(num / 10000);
+ *p++ = static_cast<char>(c + '0');
+ num = num - (c * 10000);
+ c = static_cast<char>(num / 1000);
+ *p++ = static_cast<char>(c + '0');
+ num = num - (c * 1000);
+ case 3:
+ if (p == NULL) {
+ p = buf;
+ }
+ if (num >= 1000) {
+ *p++ = '0';
+ *p++ = '0';
+ *p = '0';
+ break;
+ }
+ c = static_cast<char>(num / 100);
+ *p++ = static_cast<char>(c + '0');
+ num = num - (c * 100);
+ case 2:
+ if (p == NULL) {
+ p = buf;
+ }
+ if (num >= 100) {
+ *p++ = '0';
+ *p = '0';
+ break;
+ }
+ c = static_cast<char>(num / 10);
+ *p++ = static_cast<char>(c + '0');
+ *p = static_cast<char>(num - (c * 10) + '0');
+ break;
+ default: {
+ int dig = 1;
+ int n = num;
+ p = buf;
+ while (n >= 10) {
+ n /= 10;
+ dig *= 10;
+ }
+ while (dig > 1) {
+ c = static_cast<char>(num / dig);
+ *p++ = static_cast<char>(c + '0');
+ num = num - (c * dig);
+ dig /= 10;
+ }
+ *p = static_cast<char>(num + '0');
+ }
+ break;
+ }
+ return static_cast<int>(p - buf + 1);
+}
+
+static void
+_GetTimeString2(PSTR format) {
+ time_t tick;
+ UI_32 hh, mm, ss, ms;
+
+ // "%02d:%02d:%02d.%03d/"
+ tick = tick_msec_get();
+
+ ms = static_cast<UI_32>(tick % 1000);
+ format[8] = '.';
+ num2string(&format[9], 3, ms);
+ format[12] = '/';
+
+ tick /= 1000;
+ ss = static_cast<UI_32>(tick % 60);
+ format[5] = ':';
+ num2string(&format[6], 2, ss);
+
+ tick /= 60;
+ mm = static_cast<UI_32>(tick % 60);
+ format[2] = ':';
+ num2string(&format[3], 2, mm);
+
+ tick /= 60;
+ hh = static_cast<UI_32>(tick);
+ num2string(&format[0], 2, hh);
+}
+
+// LCOV_EXCL_START 8: dead code
+void
+_GetTimeString(PSTR format, UI_16 length) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 8: dead code
+ time_t tick;
+ UI_32 hh, mm, ss, ms;
+
+ tick = tick_msec_get();
+ ms = static_cast<UI_32>(tick % 1000);
+ tick /= 1000;
+ ss = static_cast<UI_32>(tick % 60);
+ tick /= 60;
+ mm = static_cast<UI_32>(tick % 60);
+ tick /= 60;
+ hh = static_cast<UI_32>(tick);
+
+ snprintf(format, (length - 1), "%02d:%02d:%02d.%03d/", hh, mm, ss, ms);
+}
+// LCOV_EXCL_STOP 8
+
+static UI_64
+ClockCyclesToMs(void) {
+ return ClockCycle() / 1000;
+}
+
+static CHAR *
+_in_NsLog_part1(const UI_16 p_lLine_i, const UI_16 f_uiZoneIndex,
+ PCSTR p_pstrClassName_i, CHAR *format) {
+ CHAR t_name[16]; // thread name (not more than 15 characters)
+ int len;
+ CHAR *p = format;
+
+ if (format == NULL) {
+ return NULL;
+ }
+
+ // fixed format : "%s%ld/%d/%s/%05d/%s/%d/=%s\r\n"
+ // time_string
+ _GetTimeString2(p);
+ p += 13;
+
+ // g_msgcounter
+ g_msgcounter++;
+ len = num2string(p, 0, g_msgcounter);
+ p += len;
+ *p++ = '/';
+
+ // f_uiZoneIndex
+ len = num2string(p, 0, f_uiZoneIndex);
+ p += len;
+ *p++ = '/';
+
+ // Check whether thread name has previously been set
+ t_name[0] = 0;
+ if (tls_strProcessName[0] != 0) {
+ tls_strProcessName[sizeof(t_name) - 1] = '\0';
+ strcpy(t_name, tls_strProcessName); // NOLINT (readability/nolint)
+ } else {
+ if (prctl(PR_GET_NAME, t_name) != 0) {
+ strcpy(t_name, "UNKNOWN"); // NOLINT (readability/nolint)
+ }
+ NsLogSetProcessName(t_name);
+ }
+
+ // t_name
+ strcpy(p, t_name); // NOLINT (readability/nolint)
+ p += strlen(t_name);
+ *p++ = '/';
+
+ // t_id
+ if (tid == 0) {
+ tid = static_cast<pid_t>(syscall(__NR_gettid));
+ }
+ len = num2string(p, 5, tid);
+ p += len;
+ *p++ = '/';
+
+ // p_pstrClassName_i
+ if (p_pstrClassName_i) {
+ strcpy(p, p_pstrClassName_i); // NOLINT (readability/nolint)
+ } else {
+ strcpy(p, "(null)"); // NOLINT (readability/nolint)
+ }
+ p += strlen(p);
+ *p++ = '/';
+
+ // p_lLine_i
+ len = num2string(p, 0, p_lLine_i);
+ p += len;
+ *p++ = '/';
+ *p++ = '=';
+
+ return p;
+}
+
+static void
+_in_NsLog_part2(const UI_16 f_uiZoneIndex, CHAR *p, CHAR *format) {
+ UI_32 l_uiLength;
+
+ if (p == NULL) {
+ return;
+ }
+
+ *p++ = '\r';
+ *p++ = '\n';
+ *p = '\0';
+
+ if (format == NULL) {
+ return;
+ }
+
+ l_uiLength = static_cast<UI_32>(p - format);
+
+ // Write log message
+ if (l_uiLength > 0) {
+ UI_8 l_realTimeLog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ BOOL IsZonePrintEnable = NsLogIsZonePrintEnable(f_uiZoneIndex, &l_realTimeLog);
+ if (l_realTimeLog == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE) {
+ if (g_qid != (mqd_t)(-1)) {
+ mq_close(g_qid);
+ g_qid = (mqd_t)(-1);
+ }
+ return;
+ }
+ if (g_LocalFrameworkunifiedLogParams.uiLogOptions & LPRINT) {
+ ssize_t l_writtenbyte;
+ std::string usb_realtime_filename;
+ std::string ownAdrr;
+ std::string writeAdrr;
+ if (IsZonePrintEnable == TRUE) {
+ switch (l_realTimeLog) {
+ case FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF:
+ // Nothing
+ break;
+ case FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART:
+ // Write console
+ fwrite(format, 1, l_uiLength, stdout);
+ break;
+ case FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB:
+ if (g_qid == (mqd_t)(-1)) {
+ struct mq_attr qattr;
+
+ qattr.mq_flags = 0;
+ qattr.mq_maxmsg = USB_REALTIME_MSGMAX;
+ qattr.mq_msgsize = USB_REALTIME_SIZMAX;
+ qattr.mq_curmsgs = 0;
+ if ((g_qid = mq_open(USB_REALTIME_QNAME, O_WRONLY | O_CREAT, 0666, &qattr)) == (mqd_t)(-1)) {
+ fprintf(stderr, "Failed to create Message Queue %s, errno=%d\n", USB_REALTIME_QNAME, errno);
+ break;
+ }
+ }
+ l_writtenbyte = mq_send(g_qid, format, l_uiLength, 1);
+ if (l_writtenbyte == -1) {
+ fprintf(stderr, "mq_send ERROR, errno=%d\n", errno);
+ mq_close(g_qid);
+ g_qid = (mqd_t)(-1);
+ }
+ break;
+ case FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE:
+ if (g_qid != (mqd_t)(-1)) {
+ mq_close(g_qid);
+ g_qid = (mqd_t)(-1);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (g_LocalFrameworkunifiedLogParams.uiLogOptions & LSLOGGER) {
+ check_syslog_opened();
+ syslog(LOG_ERR, "%s", format);
+ }
+
+ {
+ CNSRingBuffer *ring_buffer = NULL;
+ GetFrameworkunifiedLogRingBuffer(f_uiZoneIndex, &ring_buffer);
+
+ if (ring_buffer != NULL) {
+ if (ring_buffer->IsOpen()) {
+ ring_buffer->Write(format, l_uiLength);
+ }
+ }
+ }
+ }
+}
+
+void
+NsLogTime(const UI_16 f_uiZoneIndex, PCSTR lpszFormat) {
+ CHAR format[MAX_QUEUE_MSG_SIZE];
+ CHAR *p = format;
+ CHAR *q = reinterpret_cast<CHAR *>(const_cast<char *>(lpszFormat));
+ int i;
+
+ // fixed format : "%s/=%s\r\n"
+ // time_string
+ _GetTimeString2(p);
+ p += 13;
+ *p++ = '=';
+
+ /**
+ * @todo
+ * Defining a NULL for the lpszFormat causes a segmentation fault.
+ */
+ for (i = 0; *q && i < MAX_QUEUE_MSG_SIZE - (p - format) - 3; i++) { // '3': '\r''\n''\0'
+ *p++ = *q++;
+ }
+ _in_NsLog_part2(f_uiZoneIndex, p, format);
+}
+
+void
+NsLogData(const UI_16 f_uiZoneIndex, PCSTR data, UI_32 size) {
+ int l_realTimeLog;
+ int l_logLevel;
+
+ GetShmInfo(g_FrameworkunifiedLogFlagId, &l_realTimeLog, &l_logLevel);
+ if (l_realTimeLog == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE) {
+ return;
+ }
+
+ if (size > 0) {
+ CNSRingBuffer *ring_buffer = NULL;
+ GetFrameworkunifiedLogRingBuffer(f_uiZoneIndex, &ring_buffer); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (ring_buffer != NULL) {
+ if (ring_buffer->IsOpen()) {
+ ring_buffer->Write(data, size);
+ }
+ }
+ }
+}
+
+void
+NsLog0(const UI_16 p_lLine_i, // Line number where message was generated
+ const UI_16 f_uiZoneIndex,
+ PCSTR p_pstrClassName_i,
+ PCSTR lpszFormat) {
+ CHAR format[MAX_QUEUE_MSG_SIZE];
+ CHAR *p;
+ CHAR *q = reinterpret_cast<CHAR *>(const_cast<char *>(lpszFormat));
+ int i;
+
+ p = _in_NsLog_part1(p_lLine_i, f_uiZoneIndex, p_pstrClassName_i, format);
+ /**
+ * @todo
+ * Setting p_pstrClassName_i to NULL results in a segmentation fault.
+ */
+ for (i = 0; *q && i < MAX_QUEUE_MSG_SIZE - (p - format) - 3; i++) { // '3': '\r''\n''\0'
+ *p++ = *q++;
+ }
+ _in_NsLog_part2(f_uiZoneIndex, p, format);
+}
+
+void
+NsLog(const UI_16 p_lLine_i, // Line number where message was generated
+ const UI_16 f_uiZoneIndex,
+ PCSTR p_pstrClassName_i,
+ PCSTR lpszFormat,
+ ...) {
+ va_list argList;
+ CHAR format[MAX_QUEUE_MSG_SIZE];
+ CHAR *p;
+ int num;
+ int size;
+
+ va_start(argList, lpszFormat);
+
+ p = _in_NsLog_part1(p_lLine_i, f_uiZoneIndex, p_pstrClassName_i, format);
+ size = static_cast<int>(MAX_QUEUE_MSG_SIZE - (p - format) - 3);
+ num = vsnprintf(p, size, lpszFormat, argList);
+ if (num >= size) {
+ num = size - 1;
+ } else if (num < 0) {
+ num = 0;
+ }
+ p += num;
+ _in_NsLog_part2(f_uiZoneIndex, p, format);
+
+ va_end(argList);
+}
+
+void
+NsLogSetFrameworkunifiedLogParams(FRAMEWORKUNIFIEDLOGPARAM *p_FrameworkunifiedLogParams) {
+ int l_realTimeLog = 0;
+ int *l_logLevelArray = NULL;
+ CHAR buf[EXE_STR_LEN];
+
+ if (p_FrameworkunifiedLogParams == NULL) {
+ return;
+ }
+
+ get_readlink_path(buf);
+ if (g_flag_name.empty()) { // LCOV_EXCL_BR_LINE 200:get_readlink_path can not return false
+ std::string config_filename;
+ CHAR buf[EXE_STR_LEN];
+
+ if (IsExistFrameworkunifiedLogCfgNv()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV); // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ } else {
+ config_filename = FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__FN; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ }
+ if (get_readlink_path(buf)) {
+ std::string exe_str = buf; // LCOV_EXCL_BR_LINE 11:expect branch
+ CNSConfigReader *config_reader = new CNSConfigReader(); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (config_reader != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ if (config_reader->Parse(config_filename)
+ == eFrameworkunifiedStatusOK) {
+ CreateFrameworkunifiedLogFileTbl(config_reader, exe_str, &l_realTimeLog, &l_logLevelArray); // LCOV_EXCL_BR_LINE 11:expect branch
+ MapShmInfo(g_FrameworkunifiedLogFlagId); // LCOV_EXCL_BR_LINE 11:expect branch
+ } else {
+ DEB_SYSLOG("Parse error %s", config_filename.c_str());
+ }
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ DEB_SYSLOG("new CNSConfigReader error");
+ // LCOV_EXCL_STOP 5
+ }
+ delete config_reader; // LCOV_EXCL_BR_LINE 11:expect branch
+ } else {
+ // LCOV_EXCL_START 5: get_readlink_path can not return false
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ DEB_SYSLOG("get_readlink_path error");
+ // LCOV_EXCL_STOP 5
+ }
+ } else {
+ // already read
+ // do nothing
+ }
+
+ if (!IsExistFrameworkunifiedLogCfgShmem()) {
+ if (l_logLevelArray == NULL) {
+ readConfig(&l_realTimeLog, &l_logLevelArray);
+ }
+ WriteSharedMem(WTYPE_NORMAL, l_realTimeLog, g_FlagIdNum, l_logLevelArray);
+ MapShmInfo(g_FrameworkunifiedLogFlagId);
+ }
+ if (l_logLevelArray != NULL) {
+ free(l_logLevelArray);
+ }
+
+ /**
+ * @tood
+ * Segmentation faults occur when NULL is defined as arguments.
+ */
+ memcpy(&g_LocalFrameworkunifiedLogParams, p_FrameworkunifiedLogParams, sizeof(FRAMEWORKUNIFIEDLOGPARAM));
+
+ // Force Output ZONE_NS_WAR(8),ZONE_NS_ERR(9)
+ TFrameworkunifiedZone l_uiZoneMask = g_LocalFrameworkunifiedLogParams.uiZoneMask[0];
+ l_uiZoneMask = l_uiZoneMask | GET_ZONE_BIT_MASK(ZONE_NS_WAR) | GET_ZONE_BIT_MASK(ZONE_NS_ERR);
+ g_LocalFrameworkunifiedLogParams.uiZoneMask[0] = l_uiZoneMask;
+
+ // Force Output Zones
+ {
+ TFrameworkunifiedLogMap::iterator itr = g_FrameworkunifiedLogMap.begin();
+ TFrameworkunifiedLogMap::iterator itr_end = g_FrameworkunifiedLogMap.end();
+ for (; itr != itr_end; itr++) {
+ if (itr->second.force_output) {
+ UI_16 zone = static_cast<UI_16>(itr->first);
+ TFrameworkunifiedZone *pl_uiZoneMask = &g_LocalFrameworkunifiedLogParams.uiZoneMask[GET_ZONE_INDEX(zone)];
+ *pl_uiZoneMask |= GET_ZONE_BIT_MASK(zone);
+ }
+ }
+ }
+}
+
+void
+NsLogSetProcessName(PCSTR p_strProcessName_i) {
+ if ((p_strProcessName_i != NULL) && (strlen(p_strProcessName_i) < _countof(tls_strProcessName))) {
+ strcpy(tls_strProcessName, p_strProcessName_i); // NOLINT (readability/nolint)
+ }
+}
+
+void
+NsLogSetControlMask(TFrameworkunifiedZoneMask p_NSLogControl_i) {
+ for (UI_32 zoneIndex = 0; zoneIndex < ZONE_MASK_ARRAY_ELTS; zoneIndex++) {
+ /**
+ * @todo
+ * Setting NULL to arguments terminates abnormally
+ */
+ g_LocalFrameworkunifiedLogParams.uiZoneMask[zoneIndex] = p_NSLogControl_i[zoneIndex];
+ }
+}
+
+void
+NsLogGetControlMask(TFrameworkunifiedZoneMask p_Zonemask_i) {
+ for (UI_32 zoneIndex = 0; zoneIndex < ZONE_MASK_ARRAY_ELTS; zoneIndex++) {
+ /**
+ * @todo
+ * Setting NULL to arguments terminates abnormally
+ */
+ p_Zonemask_i[zoneIndex] = g_LocalFrameworkunifiedLogParams.uiZoneMask[zoneIndex];
+ }
+}
+
+BOOL
+NsLogIsZoneSet(UI_32 set_zone) {
+ int realTimeLog;
+ int logLevel = 0;
+
+ GetShmInfo(g_FrameworkunifiedLogFlagId, &realTimeLog, &logLevel);
+
+ if (logLevel == FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG)
+ {
+ return TRUE;
+ }
+
+ if (set_zone >= BITS_IN_ZONE_MASK) {
+ return FALSE;
+ }
+
+ if (0 != (g_LocalFrameworkunifiedLogParams.uiZoneMask[ GET_ZONE_INDEX(set_zone) ] & GET_ZONE_BIT_MASK(set_zone))) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+NsLogSetLogMethod(UI_8 p_eMethod_i) {
+ g_LocalFrameworkunifiedLogParams.uiLogOptions = p_eMethod_i;
+}
+
+UI_8
+NsLogGetLogMethod(void) {
+ return g_LocalFrameworkunifiedLogParams.uiLogOptions;
+}
+
+void
+NsLogSetSeverity(TFrameworkunifiedLoggerSeverity p_eLogSeverity_i) {
+ g_LocalFrameworkunifiedLogParams.eSeverity = p_eLogSeverity_i;
+}
+
+TFrameworkunifiedLoggerSeverity
+NsLogGetSeverity(void) {
+ return g_LocalFrameworkunifiedLogParams.eSeverity;
+}
+
+UI_8
+NsLogDetermineLogMethod(PCSTR output_type) {
+ PSTR p = NULL;
+ const CHAR delims[] = "|";
+ UI_8 outmask = 0;
+ PSTR parse = NULL;
+ PSTR saveptr = NULL;
+
+ if (output_type != NULL) {
+ // since strtok modifies the var. we
+ // must create a copy of the string.
+ parse = strdup(output_type);
+ p = strtok_r (parse, delims, &saveptr); // NOLINT (readability/nolint)
+ while (p != NULL) {
+ // slogger|msgq|console
+#ifdef AGL_STUB
+ if (!strcasecmp(p, "slogger")) {
+#else
+ if (!strcmpi(p, "slogger")) {
+#endif
+ outmask |= LSLOGGER;
+#ifdef AGL_STUB
+ } else if (!strcasecmp(p, "msgq")) {
+#else
+ } else if (!strcmpi(p, "msgq")) {
+#endif
+ outmask |= LMSGQ;
+#ifdef AGL_STUB
+ } else if (!strcasecmp(p, "console")) {
+#else
+ } else if (!strcmpi(p, "console")) {
+#endif
+ outmask |= LPRINT;
+#ifdef AGL_STUB
+ } else if (!strcasecmp(p, "shmem")) {
+#else
+ } else if (!strcmpi(p, "shmem")) {
+#endif
+ outmask |= LSHAREDMEM;
+ } else {
+ // do nothing
+ }
+
+ p = strtok_r (NULL, delims, &saveptr); // NOLINT (readability/nolint)
+ }
+
+ // since we made dup of the char * passed we need to free it!
+ if (parse != NULL) {
+ free(parse);
+ parse = NULL;
+ }
+ }
+ return outmask;
+}
+
+void
+NsLogSetZones(UI_32 f_uiZoneCount, ...) {
+ va_list l_tArguments;
+
+ // Initialize the variable argument list
+ va_start(l_tArguments, f_uiZoneCount);
+
+ // Iterate the variable argument list
+ for (UI_32 l_uiArgumentCount = 0; l_uiArgumentCount < f_uiZoneCount; l_uiArgumentCount++) {
+ // get zone value
+ UI_32 l_uiZone = va_arg(l_tArguments, UI_32); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (l_uiZone < BITS_IN_ZONE_MASK) {
+ // add zone value to existing mask
+ UI_32 l_uiZoneMask = g_LocalFrameworkunifiedLogParams.uiZoneMask[GET_ZONE_INDEX(l_uiZone)];
+ l_uiZoneMask = l_uiZoneMask | GET_ZONE_BIT_MASK(l_uiZone);
+ g_LocalFrameworkunifiedLogParams.uiZoneMask[GET_ZONE_INDEX(l_uiZone)] = l_uiZoneMask;
+ }
+ }
+
+ va_end(l_tArguments);
+}
+
+void
+NsLogParseZones(FRAMEWORKUNIFIEDLOGPARAM *p_FrameworkunifiedLogParams, UI_32 f_uiZoneCount, ...) {
+ va_list l_tArguments;
+
+ if (p_FrameworkunifiedLogParams == NULL) {
+ return;
+ }
+
+ // Initialize the variable argument list
+ va_start(l_tArguments, f_uiZoneCount);
+
+ // Iterate the variable argument list
+ for (UI_32 l_uiArgumentCount = 0; l_uiArgumentCount < f_uiZoneCount; l_uiArgumentCount++) {
+ // get zone value
+ UI_32 l_uiZone = va_arg(l_tArguments, UI_32); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (l_uiZone < BITS_IN_ZONE_MASK) {
+ // add zone
+ UI_32 l_uiZoneMask = p_FrameworkunifiedLogParams->uiZoneMask[GET_ZONE_INDEX(l_uiZone)];
+ l_uiZoneMask = l_uiZoneMask | GET_ZONE_BIT_MASK(l_uiZone);
+ p_FrameworkunifiedLogParams->uiZoneMask[GET_ZONE_INDEX(l_uiZone)] = l_uiZoneMask;
+ }
+ }
+
+ va_end(l_tArguments);
+}
+
+void
+NsLog_EvtCnt(UI_16 Cnt_Id, UI_16 Evt_Id, UI_8 nu, ...) {
+ st_LogEvent log;
+ va_list EC_list;
+ va_start(EC_list, nu);
+ UI_8 i = 0;
+ UI_32 ts = (UI_32)ClockCyclesToMs();
+
+ memset(&log, 0, sizeof(log));
+
+ log.ts = ConvertEndian(&ts);
+ log.event_id = (UI_8)Evt_Id;
+ log.grp_ID = (UI_8)(Evt_Id >> 8);
+ log.cnt_ID = Cnt_Id;
+
+ switch (nu) {
+ case 1:
+ log.data[0] = (UI_8)va_arg(EC_list, int);
+ log.phase = NORMAL;
+ log.typeofdata = COMMON;
+ break;
+ case 2:
+ log.data[0] = (UI_8)va_arg(EC_list, int);;
+ log.phase = (SystemPhase)va_arg(EC_list, int);
+ log.typeofdata = COMMON;
+ break;
+ case 4:
+ for (i = 0; i < nu; i++) {
+ log.data[i] = (UI_8)va_arg(EC_list, int);
+ }
+ log.phase = NORMAL;
+ log.typeofdata = EVENT_SPECIFIC;
+ break;
+ case 5:
+ for (i = 0; i < (nu - 1); i++) {
+ log.data[i] = (UI_8)va_arg(EC_list, int);
+ }
+ log.phase = (SystemPhase)va_arg(EC_list, int);
+ log.typeofdata = EVENT_SPECIFIC;
+ break;
+ default:
+ memset(&log, 0, sizeof(log));
+ break;
+ }
+
+ if (log.cnt_ID != 0 && log.grp_ID != 0) {
+ if (g_hSSEventLogQ == INVALID_HANDLE) {
+ g_hSSEventLogQ = McOpenSender(EVENTLOG_MSGQ_NAME);
+ }
+ McSend(g_hSSEventLogQ, tls_strProcessName, SS_MSG_LOGGER_CNT_EVTLOG, sizeof(log), &log);
+ }
+ va_end(EC_list);
+}
+
+
+void
+NsLog_Evt(UI_16 Evt_Id, UI_8 nu, ...) {
+ st_LogEvent log_Evt;
+ va_list E_list;
+ va_start(E_list, nu);
+ UI_32 ts = (UI_32)ClockCyclesToMs();
+
+ memset(&log_Evt, 0, sizeof(st_LogEvent));
+
+ log_Evt.ts = ConvertEndian(&ts);
+ log_Evt.grp_ID = (UI_8)(Evt_Id >> 8);
+ log_Evt.event_id = (UI_8)Evt_Id;
+
+ UI_8 i;
+ switch (nu) {
+ case 1:
+ log_Evt.data[0] = (UI_8)va_arg(E_list, int); // LCOV_EXCL_BR_LINE 11:expect branch
+ log_Evt.typeofdata = COMMON;
+ break;
+ case 4:
+ for (i = 0; i < nu; i++) {
+ log_Evt.data[i] = (UI_8)va_arg(E_list, int); // LCOV_EXCL_BR_LINE 11:expect branch
+ }
+ log_Evt.typeofdata = EVENT_SPECIFIC;
+ break;
+ default:
+ memset(&log_Evt, 0, sizeof(st_LogEvent));
+ break;
+ }
+ if (log_Evt.grp_ID != 0) {
+ if (g_hSSEventLogQ == INVALID_HANDLE) {
+ g_hSSEventLogQ = McOpenSender(EVENTLOG_MSGQ_NAME);
+ }
+
+ McSend(g_hSSEventLogQ, tls_strProcessName, SS_MSG_EVTLOG, sizeof(log_Evt), &log_Evt);
+ }
+ va_end(E_list);
+}
+
+
+void
+NsLog_Cnt(UI_16 Cnt_Id, UI_8 nu, ...) {
+ st_LogCount log_Cnt;
+ va_list C_list;
+ va_start(C_list, nu);
+
+ memset(&log_Cnt, 0, sizeof(st_LogCount));
+ log_Cnt.cnt_id = Cnt_Id;
+
+ switch (nu) {
+ case 0:
+ log_Cnt.phase = NORMAL;
+ break;
+ case 1:
+ log_Cnt.phase = (SystemPhase)va_arg(C_list, int); // LCOV_EXCL_BR_LINE 11:expect branch
+ break;
+ default:
+ memset(&log_Cnt, 0, sizeof(st_LogCount));
+ break;
+ }
+ if (log_Cnt.cnt_id != 0) {
+ if (g_hSSEventLogQ == INVALID_HANDLE) {
+ g_hSSEventLogQ = McOpenSender(EVENTLOG_MSGQ_NAME);
+ }
+ McSend(g_hSSEventLogQ, tls_strProcessName, SS_MSG_LOGGERCNT, sizeof(log_Cnt), &log_Cnt);
+ }
+ va_end(C_list);
+}
+
+//////////////////////////////////////////
+// NSPrintPerformanceLog
+//////////////////////////////////////////
+VOID
+NSLogPrintPerformanceLog(const UI_16 f_ui16Line, PCSTR f_cFuncName, PCSTR __format, ...) {
+#ifndef AGL_STUB
+ va_list arg;
+ CHAR l_cFormat[MAX_PLOG_STRING_SIZE] = {};
+ CHAR l_cTimeFormat[MAX_TIME_FORMATSTR_LEN] = {};
+ UI_64 l_ui64CurrentTime = 0;
+
+ if (g_hNSplogMsgQ == INVALID_HANDLE) {
+ g_hNSplogMsgQ = OpenSender(NS_PLOGQ);
+ }
+
+ if (g_FrameworkunifiedLogPParams.ui64GapInuS == 0) {
+ FILE *l_fpPLogGap = NULL;
+ l_fpPLogGap = fopen(PLOG_GAP_FILE, "re");
+ if (l_fpPLogGap != NULL) {
+ CHAR l_cBuffer[MAX_GAP_BUFFER_LEN] = {};
+ if (fgets(l_cBuffer, MAX_GAP_BUFFER_LEN, l_fpPLogGap) != NULL) {
+ g_FrameworkunifiedLogPParams.ui64GapInuS = (unsigned)atoll(l_cBuffer);
+ }
+ fclose(l_fpPLogGap);
+ }
+ }
+
+ if (g_FrameworkunifiedLogPParams.eTimeFormat == EPLOG_TIME_FORMAT_USEC) {
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ l_ui64CurrentTime = ClockCycle() + g_FrameworkunifiedLogPParams.ui64GapInuS;
+#endif
+ snprintf(l_cTimeFormat, MAX_TIME_FORMATSTR_LEN, "%s", "us");
+ } else if (g_FrameworkunifiedLogPParams.eTimeFormat == EPLOG_TIME_FORMAT_MSEC) {
+ l_ui64CurrentTime = ClockCyclesToMs() + (g_FrameworkunifiedLogPParams.ui64GapInuS / 1000);
+ snprintf(l_cTimeFormat, MAX_TIME_FORMATSTR_LEN, "%s", "ms");
+ } else if (g_FrameworkunifiedLogPParams.eTimeFormat == EPLOG_TIME_FORMAT_SEC) {
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ l_ui64CurrentTime = (ClockCycle() / 1000000) + (g_FrameworkunifiedLogPParams.ui64GapInuS / 1000000);
+#endif
+ snprintf(l_cTimeFormat, MAX_TIME_FORMATSTR_LEN, "%s", "s");
+ } else {
+ // do nothing
+ }
+
+ va_start(arg, __format);
+ vsnprintf(l_cFormat, MAX_PLOG_STRING_SIZE - 1, __format, arg);
+ l_cFormat[MAX_PLOG_STRING_SIZE - 1] = '\0';
+ va_end(arg);
+
+ CHAR l_cMsg[MAX_QUEUE_MSG_SIZE] = {};
+ snprintf(l_cMsg, MAX_QUEUE_MSG_SIZE - 1, "PLog: %12llu[%s]:%s %s: %s: %s",
+ l_ui64CurrentTime, l_cTimeFormat, (g_FrameworkunifiedLogPParams.ui64GapInuS > 0) ? ("o") : ("x"),
+ tls_strProcessName, f_cFuncName, l_cFormat);
+
+ if (g_FrameworkunifiedLogPParams.uiLogOutputOptions & EPLOG_SLOG) {
+ // send to system logger
+ check_syslog_opened();
+ syslog(LOG_INFO, "%s", l_cMsg);
+ }
+
+ if (g_FrameworkunifiedLogPParams.uiLogOutputOptions & EPLOG_TRACEEVENT) {
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ (VOID)trace_nlogf(_NTO_TRACE_USERFIRST, MAX_QUEUE_MSG_SIZE - 1, l_cMsg);
+#endif
+ }
+
+ if (g_FrameworkunifiedLogPParams.uiLogOutputOptions & EPLOG_MSGQ) {
+ // send to message queue /NSplog
+ if (g_hNSplogMsgQ != INVALID_HANDLE) {
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcat(l_cMsg, "\n", sizeof(l_cMsg)); // insert new line... user may not have.
+#endif
+ if (SendMessage(g_hNSplogMsgQ, strlen(l_cMsg),
+ reinterpret_cast<void *>(const_cast<char *>(l_cMsg))) != eFrameworkunifiedStatusOK) {
+ // Note: Nothing will be printed on a failure.
+ }
+ }
+ }
+#endif
+}
+
+//////////////////////////////////////////
+// NSLogEnablePLog
+//////////////////////////////////////////
+VOID
+NSLogEnablePLog(BOOL f_bEnable) {
+ g_FrameworkunifiedLogPParams.bIsPLogEnabled = f_bEnable;
+}
+
+//////////////////////////////////////////
+// NsLogIsPLogEnabled
+//////////////////////////////////////////
+BOOL
+NsLogIsPLogEnabled(void) {
+ return g_FrameworkunifiedLogPParams.bIsPLogEnabled;
+}
+
+//////////////////////////////////////////
+// NSLogSetPlogTimeFormat
+//////////////////////////////////////////
+VOID
+NSLogSetPlogTimeFormat(EPLOG_TIME_FORMAT f_ePlogTimeFormat) {
+ g_FrameworkunifiedLogPParams.eTimeFormat = f_ePlogTimeFormat;
+}
+
+//////////////////////////////////////////
+// NSLogSetPlogOutputOptions
+//////////////////////////////////////////
+VOID
+NSLogSetPlogOutputOptions(UI_8 f_uiPlogOutputOption) {
+ g_FrameworkunifiedLogPParams.uiLogOutputOptions = f_uiPlogOutputOption;
+}
+
+//////////////////////////////////////////
+// NsLogInitialize for Diag Method
+//////////////////////////////////////////
+VOID
+NsLogInitialize(void) {
+ std::string config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ int l_realTimelog;
+ int *l_logLevelArray = NULL;
+
+ if (unlink(config_filename.c_str()) != 0) {
+ // error TODO wirte log, bit, not use frameworkunifiedlog
+ }
+
+ readConfig(&l_realTimelog, &l_logLevelArray); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (l_logLevelArray == NULL) {
+ return;
+ }
+ WriteSharedMem(WTYPE_NORMAL, l_realTimelog, g_FlagIdNum, l_logLevelArray); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (l_logLevelArray != NULL) {
+ free(l_logLevelArray);
+ }
+}
+
+static void writeUpdateConfigForString(std::string &name, // NOLINT (readability/nolint)
+ std::string set_key,
+ std::string value) {
+ std::string flag_loglevel_key = name;
+ flag_loglevel_key.append(set_key);
+
+ std::string config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV; // LCOV_EXCL_BR_LINE 11:expect branch
+ std::string config_tmpfilename = FRAMEWORKUNIFIEDLOG_CONFIG_NV; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ config_tmpfilename.append(FRAMEWORKUNIFIEDLOG_CONFIG_TMP_NV);
+
+ unlink(config_tmpfilename.c_str());
+ if (copyFrameworkunifiedLogCfgFile(config_filename.c_str(), config_tmpfilename.c_str()) != 0) {
+ DEB_SYSLOG("fail to copy file. no update config.");
+ return;
+ }
+
+// CNSConfigWriter *l_pConfigWriter = new(std::nothrow) CNSConfigWriter(config_filename.c_str());
+ CNSConfigWriter *l_pConfigWriter = new(std::nothrow) CNSConfigWriter(config_tmpfilename.c_str()); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (l_pConfigWriter != NULL) {
+ try {
+ // l_iReturnState = ConfigWriterUpdateValue(l_hHandle, l_sKeyValue.c_str(), actualOutput.c_str());
+ l_pConfigWriter->Set(flag_loglevel_key, value);
+ } catch (...) {
+ // error TODO
+ }
+ // ConfigWriterClose(l_hHandle);
+ l_pConfigWriter->Save();
+ delete l_pConfigWriter;
+ l_pConfigWriter = NULL;
+
+ if (rename(config_tmpfilename.c_str(), config_filename.c_str()) != 0) {
+ DEB_SYSLOG("rename error errno:%d", errno);
+ }
+
+ }
+}
+
+static void
+writeUpdateConfig(std::string set_key, std::string value) {
+ std::string config_filename = FRAMEWORKUNIFIEDLOG_CONFIG_NV; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ std::string config_tmpfilename = FRAMEWORKUNIFIEDLOG_CONFIG_NV; // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ config_filename.append(FRAMEWORKUNIFIEDLOG_CONFIG__CWORD84__NV); // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ config_tmpfilename.append(FRAMEWORKUNIFIEDLOG_CONFIG_TMP_NV);
+
+ unlink(config_tmpfilename.c_str());
+ if (copyFrameworkunifiedLogCfgFile(config_filename.c_str(), config_tmpfilename.c_str())) {
+ DEB_SYSLOG("fail to copy file. no update config.");
+ return;
+ }
+
+// CNSConfigWriter *l_pConfigWriter = new(std::nothrow) CNSConfigWriter(config_filename.c_str());
+ CNSConfigWriter *l_pConfigWriter = new(std::nothrow) CNSConfigWriter(config_tmpfilename.c_str()); // LCOV_EXCL_BR_LINE 11:expect branch
+
+
+ if (l_pConfigWriter != NULL) {
+ l_pConfigWriter->Set(set_key.c_str(), value); // LCOV_EXCL_BR_LINE 11:expect branch
+ l_pConfigWriter->Save(); // LCOV_EXCL_BR_LINE 11:expect branch
+ delete l_pConfigWriter; // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (rename(config_tmpfilename.c_str(), config_filename.c_str()) != 0) {
+ DEB_SYSLOG("rename error errno:%d", errno);
+ }
+ }
+}
+
+//////////////////////////////////////////
+// NsLogSetFrameworkunifiedLogFlag for Diag Method
+//////////////////////////////////////////
+VOID
+NsLogSetFrameworkunifiedLogFlag(UI_8 flag_id, UI_8 mode) {
+ std::string l_key = ".LogLevel";
+ int l_realTimelog;
+ int *l_logLevelArray;
+ std::string l_value;
+
+ if (mode != FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG
+ && mode != FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE) {
+ return;
+ }
+
+ if (!IsExistFrameworkunifiedLogCfgNv()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ copyFrameworkunifiedLogCfgFileToNv(); // LCOV_EXCL_BR_LINE 11:expect branch
+ }
+
+ l_realTimelog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ l_logLevelArray = NULL;
+
+ readConfig(&l_realTimelog, &l_logLevelArray); // for make ramd data
+ if (l_logLevelArray == NULL) {
+ return;
+ }
+
+ if (!IsExistFrameworkunifiedLogCfgShmem()) {
+ WriteSharedMem(WTYPE_NORMAL, l_realTimelog, g_FlagIdNum, l_logLevelArray);
+ MapShmInfo(g_FrameworkunifiedLogFlagId);
+ }
+
+ if (flag_id >= g_FlagIdNum) {
+ if (l_logLevelArray != NULL) {
+ free(l_logLevelArray);
+ }
+ return;
+ }
+
+ if (mode == FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG) {
+ l_value = "Debug";
+ l_logLevelArray[flag_id] = FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG;
+ } else {
+ l_value = "Release";
+ l_logLevelArray[flag_id] = FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE;
+ }
+ writeUpdateConfigForString(g_flag_name[flag_id], l_key, l_value); // LCOV_EXCL_BR_LINE 11:expect branch
+ WriteSharedMemForFlagId(l_realTimelog, g_FlagIdNum, flag_id, l_logLevelArray[flag_id]); // LCOV_EXCL_BR_LINE 11:expect branch
+
+ free(l_logLevelArray);
+}
+
+//////////////////////////////////////////
+// NsLogGetFrameworkunifiedLogFlag for Diag Method
+//////////////////////////////////////////
+EFrameworkunifiedStatus
+NsLogGetFrameworkunifiedLogFlag(UI_8 flag_id, UI_8 *mode) {
+ int l_realTimeLog;
+ int l_logLevel = 0;
+ int *l_logLevelArray;
+
+ if (mode == NULL) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ l_realTimeLog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ l_logLevelArray = NULL;
+
+ readConfig(&l_realTimeLog, &l_logLevelArray); // for make ramd data
+ if (l_logLevelArray == NULL) {
+ *mode = FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE;
+ return eFrameworkunifiedStatusFail;
+ }
+
+ if (!IsExistFrameworkunifiedLogCfgShmem()) {
+ WriteSharedMem(WTYPE_NORMAL, l_realTimeLog, g_FlagIdNum, l_logLevelArray);
+ MapShmInfo(g_FrameworkunifiedLogFlagId);
+ }
+
+ if (l_logLevelArray != NULL) {
+ free(l_logLevelArray);
+ }
+
+ if ((flag_id >= g_FlagIdNum)) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ GetShmInfo(flag_id, &l_realTimeLog, &l_logLevel);
+ *mode = static_cast<UI_8>(l_logLevel);
+
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// NsLogSetRealtimeLog for Diag Method
+//////////////////////////////////////////
+VOID
+NsLogSetRealtimeLog(UI_8 mode) {
+ int l_realTimelog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ int *l_logLevelArray;
+ std::string l_key = "REALTIME_LOG.Output";
+ std::string l_value = "OFF"; // LCOV_EXCL_BR_LINE 11:expect branch
+
+ if (mode == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE) {
+ WriteSharedMem(WTYPE_RTIMELOG, FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE, g_FlagIdNum, NULL); // LCOV_EXCL_BR_LINE 11:expect branch
+ return;
+ }
+
+ if ((mode >= FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_MAX)
+ && (mode != FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE)) {
+ return;
+ }
+
+ if (!IsExistFrameworkunifiedLogCfgNv()) { // LCOV_EXCL_BR_LINE 11:Excluded due to gcov constraints (others)
+ copyFrameworkunifiedLogCfgFileToNv(); // LCOV_EXCL_BR_LINE 11:expect branch
+ }
+
+ l_logLevelArray = NULL;
+ readConfig(&l_realTimelog, &l_logLevelArray); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (l_logLevelArray == NULL) {
+ return;
+ }
+
+ if (!IsExistFrameworkunifiedLogCfgShmem()) {
+ WriteSharedMem(WTYPE_NORMAL, l_realTimelog, g_FlagIdNum, l_logLevelArray);
+ MapShmInfo(g_FrameworkunifiedLogFlagId);
+ }
+
+ if (mode == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART) {
+ l_value = "UART";
+ l_realTimelog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART;
+ } else if ((mode == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB)
+ || (mode == FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE)) {
+ l_value = "USB";
+ l_realTimelog = mode;
+ } else {
+ l_value = "OFF";
+ l_realTimelog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ }
+
+ writeUpdateConfig(l_key, l_value); // LCOV_EXCL_BR_LINE 11:expect branch
+ if (l_logLevelArray != NULL) {
+ WriteSharedMemForFlagId(l_realTimelog, g_FlagIdNum, FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID,
+ l_logLevelArray[FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID]); // LCOV_EXCL_BR_LINE 11:expect branch
+ free(l_logLevelArray);
+ }
+}
+
+//////////////////////////////////////////
+// NsLogGetRealtimeLog for Diag
+//////////////////////////////////////////
+VOID
+NsLogGetRealtimeLog(UI_8 *mode) {
+ int l_realTimelog;
+ int l_logLevel;
+ int *l_logLevelArray;
+
+ if (mode == NULL) {
+ return;
+ }
+ l_realTimelog = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ l_logLevelArray = NULL;
+
+ readConfig(&l_realTimelog, &l_logLevelArray); // for make ramd data
+ if (l_logLevelArray == NULL) {
+ *mode = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF;
+ return;
+ }
+ if (!IsExistFrameworkunifiedLogCfgShmem()) {
+ WriteSharedMem(WTYPE_NORMAL, l_realTimelog, g_FlagIdNum, l_logLevelArray);
+ MapShmInfo(g_FrameworkunifiedLogFlagId);
+ }
+ if (l_logLevelArray != NULL) {
+ free(l_logLevelArray);
+ }
+
+ GetShmInfo(g_FrameworkunifiedLogFlagId, &l_realTimelog, &l_logLevel);
+ *mode = static_cast<UI_8>(l_realTimelog);
+}
+
+//////////////////////////////////////////
+// NSLogPrintSysEventLog
+//////////////////////////////////////////
+VOID NSLogSysEvent(const UI_16 f_ui16Line, PCSTR f_cFuncName, PCSTR __format, ...) {
+ va_list arg;
+ CHAR l_cFormat[MAX_QUEUE_MSG_SIZE] = {};
+ CHAR l_cTimeFormat[MAX_TIME_FORMATSTR_LEN] = {};
+ UI_64 l_ui64CurrentTime = 0;
+ static UI_64 cps = 0;
+ static UI_64 l_ui64GapInUS = 0;
+
+ if (cps == 0) {
+ cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
+ }
+ if (g_hNSSysEventLogQ == INVALID_HANDLE) {
+ g_hNSSysEventLogQ = OpenSender(NS_SYSEVENTLOGQ);
+ }
+ if (l_ui64GapInUS == 0) {
+ FILE *l_fpPLogGap = NULL;
+ l_fpPLogGap = fopen(PLOG_GAP_FILE, "re");
+ if (l_fpPLogGap != NULL) {
+ CHAR l_cBuffer[MAX_GAP_BUFFER_LEN] = {};
+ if (fgets(l_cBuffer, MAX_GAP_BUFFER_LEN, l_fpPLogGap) != NULL) {
+ l_ui64GapInUS = static_cast<UI_64>(atoll(l_cBuffer));
+ }
+ fclose(l_fpPLogGap);
+ }
+ }
+
+ if (g_hNSSysEventLogQ != INVALID_HANDLE) {
+ CHAR l_cMsg[MAX_QUEUE_MSG_SIZE] = {};
+ // build a format string
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ l_ui64CurrentTime = (ClockCycle() / (cps / 1000000)) + l_ui64GapInUS;
+#endif
+ snprintf(l_cTimeFormat, MAX_TIME_FORMATSTR_LEN, "%s", "us");
+
+ va_start(arg, __format);
+ vsnprintf(l_cFormat, MAX_PLOG_STRING_SIZE - 1, __format, arg);
+ l_cFormat[MAX_PLOG_STRING_SIZE - 1] = '\0';
+ va_end(arg);
+ UI_32 l_uiCharsWritten =
+ snprintf(l_cMsg, MAX_QUEUE_MSG_SIZE - 1,
+ "%12llu[%s]:%s %s: %s: %s\n",
+ static_cast<long long unsigned int>(l_ui64CurrentTime), // NOLINT (readability/nolint)
+ l_cTimeFormat,
+ (l_ui64GapInUS > 0) ? ("o") : ("x"),
+ tls_strProcessName != 0 ? tls_strProcessName : NULL,
+ f_cFuncName != 0 ? f_cFuncName : NULL, l_cFormat);
+
+ if (SendMessage(g_hNSSysEventLogQ, l_uiCharsWritten + 1,
+ reinterpret_cast<void *>(const_cast<char *>(l_cMsg)))
+ != eFrameworkunifiedStatusOK) {
+ // Note: Nothing will be printed on a failure.
+ }
+ }
+}
+
+/////////////////////////////////////////
+// NSLogEnableSysEventLog
+//////////////////////////////////////////
+VOID
+NSLogEnableSysEventLog(BOOL f_bEnable) {
+ g_FrameworkunifiedLogSysEventParams.bIsSysEventLogEnabled = f_bEnable;
+}
+
+//////////////////////////////////////////
+// NSLogIsSysEventLogEnabled
+//////////////////////////////////////////
+BOOL
+NSLogIsSysEventLogEnabled(void) {
+ return g_FrameworkunifiedLogSysEventParams.bIsSysEventLogEnabled;
+}
+
+//////////////////////////////////////////
+// NsLogGetZoneTextList
+//////////////////////////////////////////
+VOID
+NsLogGetZoneTextList(CHAR f_cZoneList[][ZONE_TEXT_SIZE]) {
+ if (f_cZoneList != NULL) {
+ UI_32 l_ui32CharsToWrite = ZONE_TEXT_SIZE - 1;
+ // first fill ns zone text list
+ strncpy(f_cZoneList[0], ZONE_TEXT_0, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[1], ZONE_TEXT_1, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[2], ZONE_TEXT_2, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[3], ZONE_TEXT_3, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[4], ZONE_TEXT_4, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[5], ZONE_TEXT_5, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[6], ZONE_TEXT_6, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[7], ZONE_TEXT_7, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[8], ZONE_TEXT_8, l_ui32CharsToWrite);
+ strncpy(f_cZoneList[9], ZONE_TEXT_9, l_ui32CharsToWrite);
+
+ // fill user zone text list
+ UI_32 l_ui32Count = 10; // start of user zones
+ UI_32 l_ui32ZoneListCount = 0;
+ for (; l_ui32Count < BITS_IN_ZONE_MASK; l_ui32Count++, l_ui32ZoneListCount++) {
+ strncpy(f_cZoneList[l_ui32Count], g_LocalFrameworkunifiedLogParams.cZones[l_ui32ZoneListCount], l_ui32CharsToWrite);
+ }
+ }
+}
+
+VOID
+NsForceClose(void) {
+ if (!syslogopened) {
+ closelog();
+ syslogopened = 0;
+ }
+
+ if (shm_pmap != reinterpret_cast<void *>(const_cast<unsigned int*>(default_log_cfgtbl))) {
+ int size;
+ size = static_cast<int>(sizeof(int) * 2); // realTimeLog + flagIdNum
+ size += static_cast<int>(sizeof(int) * g_FlagIdNum);
+ munmap(shm_pmap, size);
+ shm_pmap = reinterpret_cast<void *>(const_cast<unsigned int*>(default_log_cfgtbl));
+ }
+
+ if (shm_fd != -1) {
+ close(shm_fd);
+ shm_fd = -1;
+ }
+
+ if (g_qid != (mqd_t)(-1)) {
+ mq_close(g_qid);
+ g_qid = (mqd_t)(-1);
+ }
+
+ TFrameworkunifiedLogMap::iterator itr;
+ TFrameworkunifiedLogMap::iterator itr_end;
+ UI_32 i = 0;
+ unsigned int flag_id;
+ if (!g_FrameworkunifiedLogMap.empty()) {
+ itr = g_FrameworkunifiedLogMap.begin();
+ itr_end = g_FrameworkunifiedLogMap.end();
+ for (; itr != itr_end; itr++, i++) {
+ if (itr->second.ring_buffer != NULL) {
+ delete itr->second.ring_buffer; // LCOV_EXCL_BR_LINE 11:expect branch
+ itr->second.ring_buffer = NULL;
+ }
+ }
+ g_FrameworkunifiedLogMap.clear();
+ }
+
+ if (!g_FrameworkunifiedLogFlagMap.empty()) {
+ for (flag_id = 0; flag_id < g_FlagIdNum; flag_id++) {
+ itr = g_FrameworkunifiedLogFlagMap.find(flag_id);
+ if (itr->second.ring_buffer != NULL) {
+ delete itr->second.ring_buffer; // LCOV_EXCL_BR_LINE 11:expect branch
+ itr->second.ring_buffer = NULL;
+ }
+ }
+ g_FrameworkunifiedLogFlagMap.clear();
+ }
+
+ if (!g_flag_name.empty()) {
+ g_flag_name.clear();
+ }
+ g_FrameworkunifiedLogFlagId = FRAMEWORKUNIFIEDLOG_DEFAULT_FLAG_ID;
+ g_FlagIdNum = 0;
+} // LCOV_EXCL_BR_LINE 10:The final line
diff --git a/nsframework/framework_unified/client/NS_Logger/tool/nslogsw.cpp b/nsframework/framework_unified/client/NS_Logger/tool/nslogsw.cpp
new file mode 100644
index 00000000..b81b4a6e
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Logger/tool/nslogsw.cpp
@@ -0,0 +1,114 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/ns_version.h>
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+_CWORD78_LOGPARAM g__CWORD78_LogParams = {
+ _CWORD78_LOGOPTIONS,
+ {
+ ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31
+ },
+ _CWORD78_LOGZONES
+};
+
+C_CWORD78_Version g__CWORD78_Version(MAJORNO, MINORNO, REVISION);
+
+static void
+Usage(char *exec) {
+ fprintf(stderr, "Usage: %s options\n", exec != 0 ? exec : NULL);
+ fprintf(stderr, " options\n");
+ fprintf(stderr, " -0 : REALTIMELOG_MODE_OFF\n");
+ fprintf(stderr, " -1 : REALTIMELOG_MODE_UART\n");
+ fprintf(stderr, " -2 : REALTIMELOG_MODE_USB\n");
+ fprintf(stderr, " -3 : REALTIMELOG_MODE_ETHER\n");
+ fprintf(stderr, " (none) print current status\n");
+}
+
+int
+main(int argc, char **argv) {
+ int c;
+
+ if (argc < 2) {
+ UI_8 realtimelog;
+ NsLogGetRealtimeLog(&realtimelog);
+ fprintf(stderr, "current status : -%d\n", realtimelog);
+ fprintf(stderr, " refer '%s -h'\n", argv[0] != 0 ? argv[0] : NULL);
+ return 0;
+ }
+
+ while ((c = getopt(argc, argv, "0123h")) != -1) {
+ switch (c) {
+ case '0':
+ fprintf(stderr, "set REALTIMELOG_MODE_OFF\n");
+ NsLogSetRealtimeLog(_CWORD78_LOG_REALTIMELOG_MODE_OFF);
+ return 0;
+ case '1':
+ fprintf(stderr, "set REALTIMELOG_MODE_UART\n");
+ NsLogSetRealtimeLog(_CWORD78_LOG_REALTIMELOG_MODE_UART);
+ return 0;
+ case '2':
+ fprintf(stderr, "set REALTIMELOG_MODE_USB\n");
+ NsLogSetRealtimeLog(_CWORD78_LOG_REALTIMELOG_MODE_USB);
+ return 0;
+ case '3':
+ fprintf(stderr, "set REALTIMELOG_MODE_ETHER\n");
+ NsLogSetRealtimeLog(_CWORD78_LOG_REALTIMELOG_MODE_ETHER);
+ return 0;
+ default:
+ Usage(argv[0]);
+ return 0;
+ }
+ }
+ Usage(argv[0]);
+ return 0;
+}
diff --git a/nsframework/framework_unified/client/NS_MessageCenter/cfg/depends.mk b/nsframework/framework_unified/client/NS_MessageCenter/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageCenter/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_MessageCenter/include/ns_mc_internal.h b/nsframework/framework_unified/client/NS_MessageCenter/include/ns_mc_internal.h
new file mode 100644
index 00000000..2b6dae89
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageCenter/include/ns_mc_internal.h
@@ -0,0 +1,93 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_MessageCenter
+/// \brief Declares the internal methods of message center
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MC_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MC_INTERNAL_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetData
+/// Get the message data, this may be from a queue or shared memory.
+/// Deletes the data based on the value of BOOL retain, if it is stored in shared memory.
+///
+/// \param [in] data
+/// PVOID - pointer to the data received from the McReceive Call
+/// \param [in] to
+/// PVOID - pointer to the data to be received
+/// \param [in] retain
+/// BOOL - TRUE to retain the data in shared memory
+/// FALSE to release the data
+///
+/// \return EFrameworkunifiedStatus
+/// EFrameworkunifiedStatus - status indicating success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetData(PVOID data, PVOID to, BOOL retain);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// McLogTransmitLoggingMsgProcessed
+///
+/// \param [in] p_sysHdr
+/// PVOID - Header of the received message. Passed as PVOID since Frameworkunified layer doesn't have
+/// knowledge about the header.
+/// \param [in] bMsgProcessed
+/// BOOL - TRUE - If any action was taken on the received message else FALSE
+///
+/// \return none
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID McLogTransmitLoggingMsgProcessed(PVOID p_sysHdr, BOOL bMsgProcessed);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Get the session id.
+///
+/// \param [in] data
+/// PVOID - pointer to the data was received from the McReceive Call
+///
+/// \return UI_32
+/// sessionId - session id
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 mcGetMsgSsessionId(PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Gets the is type of sync from message header.
+///
+/// \param [in] pData
+/// void* - pointer to the data was received from the McReceive Call
+///
+/// \return BOOL
+/// isTypeOfSync -
+/// if message type is sync, return TRUE. or not return FALSE.
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL mcGetIsTypeOfSync(PVOID data);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MC_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_MessageCenter/include/ns_message_center_internal.h b/nsframework/framework_unified/client/NS_MessageCenter/include/ns_message_center_internal.h
new file mode 100644
index 00000000..a99e8119
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageCenter/include/ns_message_center_internal.h
@@ -0,0 +1,185 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MESSAGE_CENTER_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MESSAGE_CENTER_INTERNAL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_shared_mem_if.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcOpenMonitor
+/// for Server API
+///
+/// \param [in] name
+/// PCSTR - Service name
+///
+/// \return int
+/// -1 - error
+/// >0 - Listen socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcOpenMonitor(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcCloseMonitor
+/// for Server API
+///
+/// \param [in] name
+/// PCSTR - Service name
+///
+/// \return int
+/// -1 - error
+/// 0 - success
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcCloseMonitor(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcSetConnectKey
+/// for Common API
+///
+/// \param [out] buf
+/// char * - buffer
+/// \param [in] size
+/// int - buffer size
+/// \param [in] serverName
+/// PCSTR - Server name
+/// \param [in] clientName
+/// PCSTR - Client name
+///
+/// \return int
+/// -1 - error
+/// >0 - Connect socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcSetConnectKey(char *buf, size_t size, PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcConnectMonitor
+/// for Client API
+///
+/// \param [in] serverName
+/// PCSTR - server name
+/// \param [in] clientName
+/// PCSTR - client name
+///
+/// \return int
+/// -1 - error
+/// >0 - Connect socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcConnectMonitor(PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcCloseConnectMonitor
+/// for Client API
+///
+/// \param [in] serverName
+/// PCSTR - server name
+/// \param [in] clientName
+/// PCSTR - client name
+///
+/// \return int
+/// -1 - error
+/// >0 - Connect socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcCloseConnectMonitor(PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcAcceptMonitor
+/// for Server API
+///
+/// \param [in] serverName
+/// PCSTR - server name
+/// \param [in] listenMonitorFd
+/// int - Listen socket FD
+///
+/// \return int
+/// -1 - error
+/// >0 - Accept socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcAcceptMonitor(PCSTR serverName, int listenMonitorFd);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcGetAcceptMonitor
+/// for Server API
+///
+/// \param [in] serverName
+/// PCSTR - server name
+/// \param [in] clientName
+/// PCSTR - client name
+///
+/// \return int
+/// -1 - error
+/// >0 - Accept socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcGetAcceptMonitor(PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcCloseAcceptMonitor
+/// for Server API
+///
+/// \param [in] serverName
+/// PCSTR - server name
+/// \param [in] clientName
+/// PCSTR - client name
+///
+/// \return int
+/// -1 - error
+/// >0 - Accept socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcCloseAcceptMonitor(PCSTR serverName, PCSTR clientName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcGetClientNameFromConnectKey
+/// for Server API
+///
+/// \param [in] connectKey
+/// PCSTR - connect key
+/// \param [out] clientName
+/// PCHAR - client name
+/// \param [out] len
+/// size_t - clientname buffer length
+///
+/// \return int
+/// -1 - error
+/// >0 - Accept socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcGetClientNameFromConnectKey(PCSTR connectKey, PCHAR clientName, size_t len);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// mcGetServerNameFromConnectKey
+/// for Client API
+///
+/// \param [in] connectKey
+/// PCSTR - connect key
+/// \param [out] serverName
+/// PCHAR - client name
+/// \param [out] len
+/// size_t - serverName buffer length
+///
+/// \return int
+/// -1 - error
+/// >0 - Accept socket FD
+////////////////////////////////////////////////////////////////////////////////////////////
+int mcGetServerNameFromConnectKey(PCSTR connectKey, PCHAR serverName, size_t len);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MESSAGE_CENTER_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_MessageCenter/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_MessageCenter/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..c654ef76
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageCenter/src/makefile_PosixBasedOS001
@@ -0,0 +1,214 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_MessageCenter
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_MessageCenter
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_MessageQueue/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_SharedMemIf/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/native/*.h) \
+ $(wildcard $(TEAM_ROOT)NS_MessageQueue/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NS_SharedMemIf/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+ifdef DYNAMIC
+ DYNAMIC_LIBS += \
+ NS_SharedMemIf$(DEBUG_EXT) \
+ NS_MessageQueue$(DEBUG_EXT)
+else
+ STATIC_LIBS +=
+endif
+
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+module_dirs: build_dirs
+
diff --git a/nsframework/framework_unified/client/NS_MessageCenter/src/ns_message_center.c b/nsframework/framework_unified/client/NS_MessageCenter/src/ns_message_center.c
new file mode 100644
index 00000000..fe841285
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageCenter/src/ns_message_center.c
@@ -0,0 +1,1269 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageCenter
+/// \brief
+///
+/// APIs to Open\Close and Send\Receive on message queues and shared memory.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns_message_center_if.h>
+#include <ns_message_center_internal.h>
+#include "ns_msg_queue.h"
+#include <ns_mq_internal.h>
+#include <ns_mc_internal.h>
+#include <native_service/ns_msgs.h>
+#include <string.h>
+#include <stdarg.h>
+#include <native_service/ns_shared_mem_if.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/timeb.h>
+#include <time.h>
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stddef.h>
+#include <sys/epoll.h>
+#include <native_service/ns_transmit_log.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_resource_controler.h>
+#include <native_service/nsfw_message.h>
+#include <limits.h>
+
+#include <other_service/strlcpy.h>
+
+#define assert_static(e) \
+ do { \
+ enum { assert_static__ = 1/(e) }; \
+ } while (0)
+
+#define MC_INVOKE_SYNC_TIMEOUT (60 * 1000)
+
+typedef struct {
+ UI_32 seq_id;
+ EFrameworkunifiedStatus ret_val;
+ UI_32 res_size;
+} ResponseHeader;
+
+static unsigned int mcSeed[4];
+
+HANDLE McOpenReceiverNotBlocked(PCSTR name) {
+ return OpenReceiverNotBlocked(name);
+}
+
+HANDLE McOpenReceiver(PCSTR name) {
+ return OpenReceiver(name);
+}
+
+HANDLE McOpenSyncReceiver(PCSTR name) {
+ return openSyncReceiver(name);
+}
+
+
+HANDLE McOpenSender(PCSTR name) {
+ return OpenSender(name);
+}
+
+HANDLE McOpenSenderNotBlocked(PCSTR name) {
+ return OpenSender(name);
+}
+
+HANDLE McOpenSyncSender(PCSTR name) {
+ return openSyncSender(name);
+}
+
+static int mcSetMonitorName(char *str, PCSTR name) {
+ int len;
+ if (str == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "str is NULL");
+ return -1;
+ }
+ *str = '\0';
+ len = sprintf(str + 1, "monitorS_%s", name != 0 ? name : NULL);
+ return len + 1;
+}
+
+static int OpenMonitor(PCSTR name) {
+ int monitor_sock = -1;
+ int monitor_sa_len;
+ struct sockaddr_un monitor_sa_un;
+
+ if ((monitor_sock = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "socket:%s", strerror(errno));
+ goto error;
+ }
+
+ memset(&monitor_sa_un, 0, sizeof(monitor_sa_un));
+ monitor_sa_un.sun_family = AF_UNIX;
+ monitor_sa_len = mcSetMonitorName(monitor_sa_un.sun_path, name);
+ monitor_sa_len += (int)offsetof(struct sockaddr_un, sun_path);
+
+ if (bind(monitor_sock, (struct sockaddr *)&monitor_sa_un, (socklen_t)monitor_sa_len) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "bind:%s:%s", name, strerror(errno)); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ goto error;
+ }
+
+ if (listen(monitor_sock, SOMAXCONN) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "listen:%s", strerror(errno)); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ goto error;
+ }
+ return monitor_sock;
+
+error:
+ if (monitor_sock >= 0) {
+ close(monitor_sock);
+ }
+ return -1;
+}
+
+int mcOpenMonitor(PCSTR name) {
+ long monitor_sock;
+
+ if (frameworkunifiedAcquireResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, name, &monitor_sock) < 0) {
+ if ((monitor_sock = OpenMonitor(name)) != -1) {
+ if (frameworkunifiedRegistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, name, monitor_sock, 1) < 0) {
+ close(monitor_sock);
+ monitor_sock = -1;
+ }
+ }
+ }
+
+ return (int)monitor_sock;
+}
+
+int mcCloseMonitor(PCSTR name) {
+ long monitor_sock;
+
+ if (frameworkunifiedGetResource(FRAMEWORKUNIFIED_RES_ABNMLMON, name, &monitor_sock) < 0) {
+ return -1;
+ }
+
+ frameworkunifiedUnregistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, name);
+ close((int)monitor_sock);
+
+ return 0;
+}
+
+static int mcSetClientName(char *str, PCSTR serverName, PCSTR clientName) {
+ int len;
+ if (str == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "str is NULL");
+ return -1;
+ }
+ *str = '\0';
+ len = sprintf(str + 1, "monitorC_%s:%s", serverName != 0 ? serverName : NULL, clientName != 0 ? clientName : NULL);
+ return len + 1;
+}
+
+static int ConnectMonitor(PCSTR serverName, PCSTR clientName) {
+ int client_sock = -1;
+ int client_sa_len, monitor_sa_len;
+ struct sockaddr_un client_sa_un, monitor_sa_un;
+
+ if ((client_sock = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) { // LCOV_EXCL_BR_LINE 5: socket's error case
+ // LCOV_EXCL_START 5:socket's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "socket:%s", strerror(errno));
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ memset(&client_sa_un, 0, sizeof(client_sa_un));
+ client_sa_un.sun_family = AF_UNIX;
+ client_sa_len = mcSetClientName(client_sa_un.sun_path, serverName, clientName);
+ client_sa_len += (int)offsetof(struct sockaddr_un, sun_path);
+
+ if (bind(client_sock, (struct sockaddr *)&client_sa_un, (socklen_t)client_sa_len) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "bind:%s:%s", client_sa_un.sun_path + 1, strerror(errno));
+ goto error;
+ }
+
+ memset(&monitor_sa_un, 0, sizeof(monitor_sa_un));
+ monitor_sa_un.sun_family = AF_UNIX;
+ monitor_sa_len = mcSetMonitorName(monitor_sa_un.sun_path, serverName);
+ monitor_sa_len += (int)offsetof(struct sockaddr_un, sun_path);
+
+ if (connect(client_sock, (struct sockaddr *)&monitor_sa_un, (socklen_t)monitor_sa_len) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "connect:%s", strerror(errno));
+ goto error;
+ }
+ return client_sock;
+
+error:
+ close(client_sock);
+ return -1;
+}
+
+int mcSetConnectKey(char *buf, size_t size, PCSTR serverName, PCSTR clientName) {
+ int len = snprintf(buf, size, "%s:%s", serverName != 0 ? serverName : NULL, clientName != 0 ? clientName : NULL);
+ if (buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "buf is NULL");
+ return -1;
+ }
+ buf[size - 1] = '\0';
+ return len;
+}
+
+int mcConnectMonitor(PCSTR serverName, PCSTR clientName) {
+ long client_sock;
+ char connect_key[32];
+
+ mcSetConnectKey(connect_key, sizeof(connect_key), serverName, clientName);
+
+ if (frameworkunifiedAcquireResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key, &client_sock) < 0) {
+ if ((client_sock = ConnectMonitor(serverName, clientName)) != -1) {
+ if (frameworkunifiedRegistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key, client_sock, 1) < 0) {
+ close(client_sock);
+ client_sock = -1;
+ }
+ }
+ }
+
+ return (int)client_sock;
+}
+
+int mcCloseConnectMonitor(PCSTR serverName, PCSTR clientName) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ long client_sock;
+ char connect_key[32];
+
+ mcSetConnectKey(connect_key, sizeof(connect_key), serverName, clientName);
+
+ if (frameworkunifiedGetResource(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key, &client_sock) == -1) {
+ return -1;
+ }
+
+ if (frameworkunifiedReleaseResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key) == 0) {
+ frameworkunifiedUnregistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key);
+ close((int)client_sock);
+ }
+
+ return 0;
+}
+// LCOV_EXCL_STOP
+static void mcGetClientName(const char *str, char *client_name, size_t size, int pathlen) {
+ size_t len = size - 1;
+ size_t str_len;
+ if (str == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "str is NULL");
+ return;
+ }
+ char *p_div = strchr(str + 1, ':');
+ if (p_div == NULL) {
+ return;
+ }
+ str_len = (size_t)(pathlen - (p_div - str + 1));
+ if (len > str_len) {
+ len = str_len;
+ }
+ if (client_name == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "client_name is NULL");
+ return;
+ }
+ strncpy(client_name, p_div + 1, len);
+ client_name[len] = '\0';
+}
+
+int mcAcceptMonitor(PCSTR serverName, int listenMonitorFd) {
+ int accept_sock = -1;
+ struct sockaddr_un client_sa_un;
+ socklen_t client_sa_len = sizeof(client_sa_un);
+ char client_name[16];
+ char connect_key[32];
+
+ if ((accept_sock = accept4(listenMonitorFd, (struct sockaddr *)&client_sa_un, &client_sa_len, SOCK_CLOEXEC)) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "accept:%s", strerror(errno));
+ return -1;
+ }
+
+ mcGetClientName(client_sa_un.sun_path, client_name, sizeof(client_name), (int)(client_sa_len - offsetof(struct sockaddr_un,
+ sun_path)));
+ mcSetConnectKey(connect_key, sizeof(connect_key), serverName, client_name);
+
+ frameworkunifiedRegistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key, accept_sock, 0);
+ return accept_sock;
+}
+
+int mcGetAcceptMonitor(PCSTR serverName, PCSTR clientName) {
+ long accept_sock;
+ char connect_key[32];
+
+ mcSetConnectKey(connect_key, sizeof(connect_key), serverName, clientName);
+
+ if (frameworkunifiedAcquireResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key, &accept_sock) < 0) {
+ return -1;
+ }
+
+ return (int)accept_sock;
+}
+
+int mcGetClientNameFromConnectKey(PCSTR connectKey, PCHAR clientName, size_t len) {
+ char *p_div = strchr(connectKey, ':');
+ if (p_div == NULL) {
+ return -1;
+ }
+
+ strncpy(clientName, p_div + 1, len);
+ clientName[len - 1] = '\0';
+ return 0;
+}
+
+int mcGetServerNameFromConnectKey(PCSTR connectKey, PCHAR serverName, size_t len) {
+ char *p_div = strchr(connectKey, ':');
+ size_t min_len;
+
+ if (p_div == NULL) {
+ return -1;
+ }
+
+ min_len = ((len - 1) < (p_div - connectKey)) ? len - 1 : (size_t)(p_div - connectKey);
+ strncpy(serverName, connectKey, min_len);
+ serverName[min_len] = '\0';
+ return 0;
+}
+
+/////////////////////////////////////////
+HANDLE McOpenSenderChild(PCSTR name, pthread_t childid) {
+ return OpenSenderChild(name, childid);
+}
+
+EFrameworkunifiedStatus McJoinChild(HANDLE hChildApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (INVALID_HANDLE != hChildApp) { // LCOV_EXCL_BR_LINE 6: impossible to confirm because hChildApp checked is passed in the FrameworkunifiedDestroyChildThread function of the frameworkunified_multithreading.cpp
+ eStatus = JoinChild(hChildApp);
+ } else {
+ // LCOV_EXCL_START 6: impossible to confirm because hChildApp checked is passed in the FrameworkunifiedDestroyChildThread function of the frameworkunified_multithreading.cpp
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus McGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (INVALID_HANDLE != hChildApp) {
+ eStatus = GetChildThreadPriority(hChildApp, threadPrio);
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ return eStatus;
+}
+
+/// endhack...
+/////////////////////////////////////////
+
+static EFrameworkunifiedStatus mcReceiveInternal(HANDLE hMessage, PSTR source, UI_32 *cmd, UI_32 *sessionid, UI_32 length,
+ PVOID data) {
+ PSSystemMsgHeader sysHdr = NULL;
+
+ // check if handle is valid
+ if (hMessage == INVALID_HANDLE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // check if buffer is null
+ if (data == NULL) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ // check for invalid length.
+ if (length <= 0) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ // check if the source is null
+ if (source == NULL) {
+ return eFrameworkunifiedStatusInvldQName;
+ }
+
+ if (cmd == NULL) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ if (-1 != ReceiveMessage(hMessage, length, data)) {
+ sysHdr = (PSSystemMsgHeader)data;
+ if (strlen(sysHdr->info.source) < MAX_QUEUE_NAME_SIZE) {
+ *cmd = sysHdr->info.command;
+ if (sessionid) {
+ *sessionid = sysHdr->info.sessionid;
+ }
+ strlcpy(source, sysHdr->info.source, MAX_NAME_SIZE_APP);
+ return eFrameworkunifiedStatusOK;
+ } else {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+ } else {
+ return TranslateError(errno);
+ }
+
+ return eFrameworkunifiedStatusFail;
+}
+
+EFrameworkunifiedStatus McReceive(HANDLE hMessage, PSTR source, UI_32 *cmd, UI_32 length, PVOID data) {
+ return mcReceiveInternal(hMessage, source, cmd, NULL, length, data);
+}
+
+EFrameworkunifiedStatus McReceiveWithSession(HANDLE hMessage, PSTR source, UI_32 *cmd, UI_32 *sessionid, UI_32 length, PVOID data) {
+ if (sessionid == NULL) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ return mcReceiveInternal(hMessage, source, cmd, sessionid, length, data);
+}
+
+static EFrameworkunifiedStatus mcSendInternal(HANDLE hMessage, PCSTR source, UI_32 cmd, PCSTR sysInfo, UI_32 length, PCVOID data,
+ EFrameworkunifiedMessagePriorties priority, UI_32 sessionid, BOOL is_sync) {
+ assert_static(_NSFW_MSG_LEN_ == sizeof(SSystemMsgHeader));
+ assert_static(_NSFW_SYSINFO_SIZE_ == MAX_SYS_INFO_SIZE);
+ assert_static(_NSFW_SYSINFO_FLAG_ == MC_EMSGT_SYSINFO_MASK);
+
+ // check if handle is valid
+ if (mqCheckValidHandle(hMessage) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // check if buffer is null
+ if (data == NULL && length > 0) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ // check if the source is null
+ if (source == NULL) {
+ return eFrameworkunifiedStatusInvldQName;
+ }
+
+ // check if the source length exceeds than expected
+ /**
+ * @todo
+ * Although a send message queue handle can be created using a 19-byte message queue name, messages cannot be sent using the created send message queue handle.
+ * Because "/" is added to the queue name in the send message queue handle, a judgment error of MAX_QUEUE_NAME_SIZE (20 bytes) occurs during transmission and transmission cannot be performed.
+ */
+ if (strlen(source) >= MAX_QUEUE_NAME_SIZE) {
+ return eFrameworkunifiedStatusInvldQName;
+ }
+
+ // notification name size should be less than MAX_SYS_INFO_SIZE
+ // data length check
+ UI_32 max_length = 0;
+ if (NULL != sysInfo) {
+ if (strlen(sysInfo) >= MAX_SYS_INFO_SIZE) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ // If there is an sysInfo, the maximum send data length is the maximum send data length of UI_32 minus (header + sysInfo size).
+ max_length = 0xFFFFFFFF - sizeof(SSystemMsgHeader) - sizeof(TSysMsgSystemInfo);
+ } else {
+ // If there is no sysInfo, the maximum send data length is the maximum value of UI_32 minus the headers.
+ max_length = 0xFFFFFFFF - sizeof(SSystemMsgHeader);
+ }
+
+ if (length > max_length) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ EFrameworkunifiedStatus rtnStatus = eFrameworkunifiedStatusOK;
+
+ UI_8 sndBuf[ MAX_QUEUE_MSG_SIZE ];
+ SQhandle *sndHndl = (SQhandle *)hMessage;
+ SSystemMsgHeader *msgHdr = (SSystemMsgHeader *)sndBuf;
+ UI_32 send_length = 0;
+ UI_32 offset = sizeof(SSystemMsgHeader);
+
+ if (NULL == sndHndl->q_name) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // check if the dest length exceeds than expected
+ if (strlen(sndHndl->q_name) >= MAX_QUEUE_NAME_SIZE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // compose header
+ strcpy(msgHdr->info.source, source);
+ msgHdr->info.length = length; // this is length of the messages data...
+ msgHdr->info.command = cmd;
+ msgHdr->info.sessionid = sessionid;
+
+ msgHdr->eType = (UI_32)MC_EMSGT_VALID_TOKEN;
+ msgHdr->memId = 0; // not set...
+ if (NULL != sysInfo) {
+ msgHdr->eType |= MC_EMSGT_SYSINFO_MASK;
+ strcpy((char *)(sndBuf + offset), sysInfo);
+ offset += (UI_32)sizeof(TSysMsgSystemInfo);
+ }
+ if (is_sync) {
+ msgHdr->eType |= MC_EMSGT_SYNC_MASK;
+ }
+
+ // Build buffer to send...
+
+ // copy to buffer
+ /*
+ * @todo
+ * Do not throw an error even if the data size of the argument is set to 0.
+ * When "length + offset" is MAX_QUEUE_MSG_SIZE (4096) or more, the length becomes 0 in the process that is executed cannot be checked.
+ * Sizeof(SSystemMsgHeader) is 40, sizeof(TSysMsgSystemInfo) is 64, maximal. offset is 104, min. is 40
+ */
+ if ((length + offset) >= MAX_QUEUE_MSG_SIZE) {
+ // set the shared mem info in header....
+ msgHdr->eType |= MC_EMSGT_SHM_MASK;
+
+ // send data to shm
+ msgHdr->memId = SetDataToShared(data, length, source, sndHndl->q_name);
+
+ if (BAD_MEM_ID != msgHdr->memId) {
+ // update the send length
+ send_length += offset;
+ } else {
+ rtnStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else { // was less than the max
+ // update the send length
+ send_length += offset;
+
+ /**
+ * @todo
+ * If UINT_MAX (4294967295) is specified in the iLength of FrameworkunifiedNPPublishNotification,
+ * the comparison by (length + offset) >= MAX_QUEUE_MSG_SIZE fails to compare correctly because of an overflow,
+ * and the comparison is judged to be less than the max.
+ * Once in the else block, the data is treated as a sysHeader block of up to 4096 bytes,
+ * and the memcpy is performed again without size checking, resulting in a segmentation fault.
+ * Maximum message length that can be sent by FrameworkunifiedNPPublishNotification must be specified and the maximum message length must be checked.
+ */
+ // copy the msg to send buffer
+ memcpy(&sndBuf[0] + offset, data, length);
+
+ // update the send length
+ send_length += length;
+ }
+
+ if (eFrameworkunifiedStatusOK == rtnStatus) {
+ rtnStatus = SendMessageWithPriority(hMessage, send_length, (PVOID)&sndBuf[0], priority);
+ }
+
+ if (rtnStatus != eFrameworkunifiedStatusOK) {
+ // remove the shared mem since this failed.
+ McClearData(msgHdr);
+ }
+
+ return rtnStatus;
+}
+
+EFrameworkunifiedStatus McSendPrioWithSysInfo(HANDLE hMessage, PCSTR source, UI_32 cmd, PCSTR sysInfo, UI_32 length, PCVOID data,
+ EFrameworkunifiedMessagePriorties priority, UI_32 sessionid) {
+ if (NULL == sysInfo) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ return mcSendInternal(hMessage, source, cmd, sysInfo, length, data, priority, sessionid, FALSE);
+}
+
+EFrameworkunifiedStatus McSendWithSysInfo(HANDLE hMessage, PCSTR source, UI_32 cmd, PCSTR sysInfo, UI_32 length, PCVOID data,
+ UI_32 sessionid) {
+ if (NULL == sysInfo) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ return mcSendInternal(hMessage, source, cmd, sysInfo, length, data, eFrameworkunifiedMsgPrioNormal, sessionid, FALSE);
+}
+
+EFrameworkunifiedStatus McSend(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data) {
+ return mcSendInternal(hMessage, source, cmd, NULL, length, data, eFrameworkunifiedMsgPrioNormal, 0, FALSE);
+}
+
+EFrameworkunifiedStatus McSendWithPriority(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data,
+ EFrameworkunifiedMessagePriorties priority, UI_32 sessionid) {
+ return mcSendInternal(hMessage, source, cmd, NULL, length, data, priority, sessionid, FALSE);
+}
+
+EFrameworkunifiedStatus McSendWithSession(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data, UI_32 sessionid) {
+ return mcSendInternal(hMessage, source, cmd, NULL, length, data, eFrameworkunifiedMsgPrioNormal, sessionid, FALSE);
+}
+
+EFrameworkunifiedStatus McSendSyncResponse(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 seq_id, EFrameworkunifiedStatus ret_val, UI_32 length,
+ PCVOID data) {
+ EFrameworkunifiedStatus eStatus;
+ ResponseHeader *resHdr;
+ UI_8 *res_data;
+
+ if ((UINT_MAX - sizeof(ResponseHeader)) < length) {
+ return eFrameworkunifiedStatusInvldBufSize;
+ }
+
+ // check if buffer is null
+ if (data == NULL && length > 0) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ if ((res_data = calloc(length + sizeof(ResponseHeader), 1)) == NULL) { // LCOV_EXCL_BR_LINE 5: calloc's error case
+ // LCOV_EXCL_START 5: calloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+
+ resHdr = (ResponseHeader *)res_data;
+ resHdr->seq_id = seq_id;
+ resHdr->ret_val = ret_val;
+ resHdr->res_size = length;
+
+ memcpy(res_data + sizeof(ResponseHeader), data, length);
+
+ eStatus = mcSendInternal(hMessage, source, cmd, NULL, (UI_32)(length + sizeof(ResponseHeader)), res_data, eFrameworkunifiedMsgPrioNormal, 0,
+ TRUE);
+
+exit:
+ free(res_data);
+ res_data = NULL;
+ resHdr = NULL;
+
+ return eStatus;
+}
+
+/*
+ * Xorshift
+ */
+static inline unsigned int xor128(void) {
+ unsigned int t;
+ t = (mcSeed[0] ^ (mcSeed[0] << 11));
+ mcSeed[0] = mcSeed[1];
+ mcSeed[1] = mcSeed[2];
+ mcSeed[2] = mcSeed[3];
+ return (mcSeed[3] = (mcSeed[3] ^ (mcSeed[3] >> 19)) ^ (t ^ (t >> 8)));
+}
+
+static inline char *ultoa(unsigned long value, char *buf, int radix) {
+ const static char c[] = "0123456789abcdef";
+ char b[65];
+ char *p = b + sizeof(b);
+
+ *--p = '\0';
+ do {
+ *--p = c[value % (unsigned long)radix];
+ value /= (unsigned long)radix;
+ } while (value);
+ if (buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "buf is NULL");
+ return NULL;
+ }
+ strcpy(buf, p);
+
+ return buf;
+}
+
+EFrameworkunifiedStatus McInvokeSync(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 msgLength, PCVOID msgData, UI_32 sessionid,
+ HANDLE hRcvMessage, UI_32 responseLength, PVOID responseData, UI_32 *receivedLength) {
+ EFrameworkunifiedStatus eStatus;
+ TSysMsgSystemInfo sysInfo;
+ UI_32 seq_id;
+ ResponseHeader *resHdr;
+ UI_8 *rcv_buf = NULL;
+ CHAR resSource[MAX_NAME_SIZE_APP];
+ int efd = -1;
+ struct epoll_event events[2];
+ struct epoll_event ev;
+ int connect_sock = -1;
+ SQhandle *sndHndl = (SQhandle *)hMessage;
+
+ if (mqCheckValidHandle(hMessage) == FALSE || mqCheckValidHandle(hRcvMessage) == FALSE || (responseLength != 0 &&
+ responseData == NULL)) {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+
+ /**
+ * @todo
+ * The system performs rcv_buf free without NULL determination.
+ */
+ goto exit;
+ }
+
+ if (NULL == receivedLength) {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ }
+ if ((rcv_buf = malloc(MAX_QUEUE_MSG_SIZE)) == NULL) { // LCOV_EXCL_BR_LINE 5: malloc's error case.
+ // LCOV_EXCL_START 5: malloc's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+
+ if (mcSeed[0] == 0) {
+ int fd;
+ if ((fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC)) < 0) {
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ }
+
+ if (read(fd, &mcSeed, sizeof(mcSeed)) < 0) {
+ close(fd);
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ }
+ close(fd);
+ }
+ seq_id = xor128();
+
+ sysInfo[0] = '0';
+ sysInfo[1] = 'x';
+ ultoa(seq_id, &sysInfo[2], 16);
+
+ Flush(hRcvMessage);
+
+ eStatus = mcSendInternal(hMessage, source, cmd, sysInfo, msgLength, msgData, eFrameworkunifiedMsgPrioNormal, sessionid, TRUE);
+ if (eStatus != eFrameworkunifiedStatusOK) {
+ goto exit;
+ }
+
+ if ((connect_sock = mcConnectMonitor(sndHndl->q_name + 1, source)) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "connect:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ }
+
+ if ((efd = epoll_create1(EPOLL_CLOEXEC)) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_create1's error case.
+ // LCOV_EXCL_START 5: epoll_create1's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_create1:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+ ev.events = EPOLLIN;
+ ev.data.fd = McGetQueueFD(hRcvMessage);
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, ev.data.fd, &ev) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_ctl's error case.
+ // LCOV_EXCL_START 5: epoll_ctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_ctl:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+ ev.events = EPOLLRDHUP;
+ ev.data.fd = connect_sock;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, ev.data.fd, &ev) < 0) { // LCOV_EXCL_BR_LINE 5: epoll_ctl's error case.
+ // LCOV_EXCL_START 5: epoll_ctl's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_ctl:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+
+ while (1) {
+ int nfds, n;
+
+ nfds = epoll_wait(efd, events, 2, MC_INVOKE_SYNC_TIMEOUT);
+ if (nfds == -1) { // LCOV_EXCL_BR_LINE 5: epoll_wait's error case.
+ // LCOV_EXCL_START 5: epoll_wait's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == EINTR) {
+ continue;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_wait:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ // LCOV_EXCL_STOP
+ } else if (nfds == 0) { // LCOV_EXCL_BR_LINE 5: epoll_wait return value equal 0.
+ // LCOV_EXCL_START 5: epoll_wait return value equal 0.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_wait:time out");
+ eStatus = eFrameworkunifiedStatusAccessError;
+ goto exit;
+ // LCOV_EXCL_STOP
+ }
+
+ for (n = 0; n < nfds; n++) {
+ if (events[n].data.fd == connect_sock) {
+ /*
+ * connection fail
+ */
+ char connect_key[32];
+ mcSetConnectKey(connect_key, sizeof(connect_key), sndHndl->q_name + 1, source);
+
+ if (epoll_ctl(efd, EPOLL_CTL_DEL, connect_sock, events) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_ctl:%s", strerror(errno));
+ }
+ if (close(connect_sock) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "close:%s", strerror(errno));
+ }
+ frameworkunifiedUnregistResouce(FRAMEWORKUNIFIED_RES_ABNMLMON, connect_key);
+
+ if ((connect_sock = mcConnectMonitor(sndHndl->q_name + 1, source)) < 0) {
+ eStatus = eFrameworkunifiedStatusBadConnection;
+ goto exit;
+ }
+ ev.events = EPOLLRDHUP;
+ ev.data.fd = connect_sock;
+ if (epoll_ctl(efd, EPOLL_CTL_ADD, ev.data.fd, &ev) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "epoll_ctl:%s", strerror(errno));
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ }
+ } else {
+ /*
+ * response receive
+ */
+ if ((eStatus = McReceive(hRcvMessage, resSource, &cmd, MAX_QUEUE_MSG_SIZE, rcv_buf)) != eFrameworkunifiedStatusOK) {
+ goto exit;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)rcv_buf;
+ if (MC_EMSGT_IS_SHM(sysHdr->eType)) {
+ UI_32 shmLength = GetLengthOfDataFromShared(sysHdr->memId);
+ TMemID memId = sysHdr->memId;
+
+ if (shmLength == 0) {
+ eStatus = eFrameworkunifiedStatusErrOther;
+ goto exit;
+ }
+
+ free(rcv_buf);
+ if ((rcv_buf = calloc(shmLength, 1)) == NULL) {
+ eStatus = eFrameworkunifiedStatusFail;
+ goto exit;
+ }
+
+ if ((eStatus = GetDataFromShared(memId, rcv_buf, shmLength)) != eFrameworkunifiedStatusOK) {
+ eStatus = eFrameworkunifiedStatusErrOther;
+ goto exit;
+ }
+
+ DiscardDataFromShared(memId);
+ resHdr = (ResponseHeader *)rcv_buf;
+ } else {
+ resHdr = (ResponseHeader *)(rcv_buf + sizeof(SSystemMsgHeader));
+ }
+
+ if (resHdr->seq_id == seq_id) {
+ if (resHdr->res_size > 0 && responseLength > 0)
+ memcpy(responseData, (const void *)((char *)resHdr + sizeof(ResponseHeader)),
+ resHdr->res_size > responseLength ? responseLength : resHdr->res_size);
+
+ *receivedLength = resHdr->res_size;
+ eStatus = resHdr->ret_val;
+ goto exit; // success
+ }
+ }
+ }
+ }
+
+exit:
+ free(rcv_buf);
+ rcv_buf = NULL;
+ resHdr = NULL;
+
+ if (efd >= 0) {
+ close(efd);
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus McCreateInvokerName(PCSTR source, UI_32 sessionid, PSTR invokerName, UI_32 size) {
+ if (source == NULL || invokerName == NULL) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ // When the size of the synchronous communication message queue name storage area is 0.
+ if (0 == size) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ snprintf(invokerName, size - 1, "%s_r0", source);
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus McForward(HANDLE hMessage, PCSTR source, UI_32 iCmd, TMemID USID) {
+ // check if handle is valid
+ if (mqCheckValidHandle(hMessage) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // check if the source is null
+ if (source == NULL) {
+ return eFrameworkunifiedStatusInvldQName;
+ }
+
+ // check the shared memory id
+ if (USID == BAD_MEM_ID) {
+ return eFrameworkunifiedStatusErrOther;
+ }
+
+ // check if the source length exceeds than expected
+ if (strlen(source) >= MAX_QUEUE_NAME_SIZE) {
+ return eFrameworkunifiedStatusInvldQName;
+ }
+
+ UI_8 sndBuf[ MAX_QUEUE_MSG_SIZE ] = {};
+ SQhandle *sndHndl = (SQhandle *)hMessage;
+ SSystemMsgHeader msgHdr = {};
+
+ // check if the dest length exceeds than expected
+ if (strlen(sndHndl->q_name) >= MAX_QUEUE_NAME_SIZE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // compose header
+ strlcpy(msgHdr.info.source, source, sizeof(msgHdr.info.source));
+ msgHdr.info.length = GetLengthOfDataFromShared(USID); // this is length of the messages data...
+ msgHdr.info.command = iCmd;
+ msgHdr.eType = (UI_32)(MC_EMSGT_VALID_TOKEN | MC_EMSGT_SHM_MASK);
+ msgHdr.memId = USID;
+ msgHdr.info.sessionid = 0;
+
+ // copy to buffer
+ UI_8 offset = sizeof(SSystemMsgHeader);
+ // write header to send buffer
+ memcpy(&sndBuf[0], &msgHdr, offset);
+
+ return SendMessage(hMessage, MAX_QUEUE_MSG_SIZE, (PVOID)&sndBuf[0]);
+}
+
+PCSTR McGetMsgSrc(PVOID data) {
+ // check if buffer is null
+ if (data == NULL) {
+ return NULL; // The data is invalid return zero length.
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+ return (PCSTR)sysHdr->info.source;
+}
+
+UI_32 mcGetMsgSsessionId(PVOID data) {
+ // check if buffer is null
+ if (data == NULL) {
+ return 0; // The data is invalid return zero.
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+ return sysHdr->info.sessionid;
+}
+
+UI_32 McGetLength(PVOID data) {
+ // check if buffer is null
+ if (data == NULL) {
+ return 0; // The data is invalid return zero length.
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+ return sysHdr->info.length;
+}
+
+PVOID McGetDataPointer(PVOID data) {
+ if (data == NULL) {
+ return NULL;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+ int offset = sizeof(SSystemMsgHeader);
+
+ if (MC_EMSGT_HAS_SYSINFO(sysHdr->eType)) {
+ offset += (int)sizeof(TSysMsgSystemInfo);
+ }
+
+ return (PVOID)((long)data + offset);
+}
+
+EFrameworkunifiedStatus McGetSysInfoData(PVOID data, PVOID to) {
+ // check if buffers are null
+ if (data == NULL || to == NULL) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+ if (MC_EMSGT_VALID((int)sysHdr->eType)) {
+ if (MC_EMSGT_HAS_SYSINFO(sysHdr->eType)) {
+ strlcpy(to, (char *)data + sizeof(SSystemMsgHeader), MAX_SYS_INFO_SIZE);
+ } else {
+ *(char *)to = '\0';
+ }
+ return eFrameworkunifiedStatusOK;
+ }
+
+ return eFrameworkunifiedStatusInvldHandle;
+}
+
+EFrameworkunifiedStatus McGetDataOfSize(PVOID data, PVOID to, UI_32 uiSize) {
+ if (McGetLength(data) > uiSize) {
+ return eFrameworkunifiedStatusInvldBufSize;
+ }
+ return GetData(data, to, FALSE);
+}
+
+EFrameworkunifiedStatus McGetDataOfSizeWithSMRetain(PVOID data, PVOID to, UI_32 uiSize) {
+ if (McGetLength(data) > uiSize) {
+ return eFrameworkunifiedStatusInvldBufSize;
+ }
+ return GetData(data, to, TRUE);
+}
+
+BOOL mcGetIsTypeOfSync(PVOID data) {
+ if (data == NULL) {
+ return FALSE;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+
+ if (MC_EMSGT_VALID((int)sysHdr->eType)) {
+ if (MC_EMSGT_IS_SYNC(sysHdr->eType)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+EFrameworkunifiedStatus McClearData(PVOID data) {
+ // check if buffers are null
+ if (data == NULL) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+
+ if (MC_EMSGT_VALID((int)sysHdr->eType)) {
+ if (MC_EMSGT_IS_SHM(sysHdr->eType)) {
+ return DiscardDataFromShared(sysHdr->memId);
+ } else {
+ return eFrameworkunifiedStatusOK;
+ }
+ }
+
+ return eFrameworkunifiedStatusInvldParam;
+}
+
+EFrameworkunifiedStatus McClose(HANDLE hMessage) {
+ EFrameworkunifiedStatus rtnStatus = eFrameworkunifiedStatusInvldHandle;
+
+ if (NULL != hMessage) {
+ EQType qType = GetQueueType(hMessage);
+
+ if (eQTypeSender == qType) {
+ rtnStatus = CloseSender(hMessage);
+ } else if (eQTypeReveiver == qType) {
+ rtnStatus = CloseReceiver(hMessage);
+ }
+ }
+
+ return rtnStatus;
+}
+
+
+void McFlushReceiver(HANDLE hMessage) {
+ if (hMessage != INVALID_HANDLE) {
+ // proxy to the real function in msg queue
+ Flush(hMessage);
+ }
+}
+
+TMemID McGetDataUSID(PVOID pData) {
+ // check if buffer is null
+ if (pData == NULL) {
+ return BAD_MEM_ID;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)pData;
+
+ if (MC_EMSGT_VALID((int)sysHdr->eType)) {
+ if (MC_EMSGT_IS_SHM(sysHdr->eType)) {
+ return sysHdr->memId;
+ } else {
+ return BAD_MEM_ID;
+ }
+ }
+
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetData
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetData(PVOID data, PVOID to, BOOL retain) {
+ EFrameworkunifiedStatus rtnStatus = eFrameworkunifiedStatusInvldHandle;
+
+ // check if buffers are null
+ if (data == NULL || to == NULL) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ PSSystemMsgHeader sysHdr = (PSSystemMsgHeader)data;
+ int offset = sizeof(SSystemMsgHeader);
+
+ if (MC_EMSGT_VALID((int)sysHdr->eType)) {
+ if (MC_EMSGT_HAS_SYSINFO(sysHdr->eType)) {
+ offset += (int)sizeof(TSysMsgSystemInfo);
+ }
+
+ if (MC_EMSGT_IS_SHM(sysHdr->eType)) {
+ // need to get the message from shared memory
+
+ // get the length based on the memId
+ UI_32 shmLength = GetLengthOfDataFromShared(sysHdr->memId);
+ /*
+ * todo
+ * When a eFrameworkunifiedStatusInvldID error occurs in GetDataFromShared, the abnormal values are also returned in eFrameworkunifiedStatusErrOther.
+ */
+ if (0 != shmLength && eFrameworkunifiedStatusOK == GetDataFromShared(sysHdr->memId, to, shmLength)) {
+ if (!retain) {
+ // now that the data has been retrieved we may now discard it.
+ McClearData(data);
+ }
+ rtnStatus = eFrameworkunifiedStatusOK;
+ } else {
+ rtnStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ // memcpy the data to the buffer provided.
+ memcpy(to, (PVOID)((long)data + offset), sysHdr->info.length);
+ rtnStatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ rtnStatus = eFrameworkunifiedStatusInvldHndlType;
+ }
+
+ return rtnStatus;
+}
+
+PCSTR McGetQueueName(HANDLE hMessage) {
+ PCSTR name = NULL;
+
+ if (NULL != hMessage) {
+ name = GetQueueName(hMessage);
+ }
+
+ return name;
+}
+
+int McGetQueueFD(HANDLE hMessage) {
+ int fd = -1;
+
+ if (NULL != hMessage) {
+ fd = GetQueueFD(hMessage);
+ }
+
+ return fd;
+}
+
+EFrameworkunifiedStatus McTranslateError(int error) {
+ return TranslateError(error);
+}
+
+EFrameworkunifiedStatus McZcSetParam(HANDLE handle, UI_32 cmd, UI_32 length) {
+ if (handle == NULL) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ SQhandle *sndHndl = (SQhandle *)handle;
+ SSystemMsgHeader *msgHdr = (SSystemMsgHeader *)(sndHndl->sendbuf);
+
+ // QueueType checking
+ EQType qType = GetQueueType(handle);
+ if (eQTypeSender != qType) {
+ return eFrameworkunifiedStatusInvldHndlType;
+ }
+
+ if (mqCheckValidHandle(handle) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+ if (sndHndl->sendbuf == NULL) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+ if (length > (MAX_QUEUE_MSG_SIZE - sizeof(SSystemMsgHeader))) {
+ return eFrameworkunifiedStatusInvldBufSize;
+ }
+
+ msgHdr->info.command = cmd;
+ msgHdr->info.length = length;
+ return eFrameworkunifiedStatusOK;
+}
+
+PVOID McZcGetBuf(HANDLE handle) {
+ if (handle == NULL) {
+ return NULL;
+ }
+
+ SQhandle *sndHndl = (SQhandle *)handle;
+
+ // QueueType checking
+ EQType qType = GetQueueType(handle);
+ if (eQTypeSender != qType) {
+ return NULL;
+ }
+
+ if (mqCheckValidHandle(handle) == FALSE) {
+ return NULL;
+ }
+ if (sndHndl->sendbuf == NULL) {
+ return NULL;
+ }
+ return (char *)(sndHndl->sendbuf) + sizeof(SSystemMsgHeader);
+}
+
+EFrameworkunifiedStatus McZcSend(HANDLE hMessage) {
+ if (hMessage == NULL) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ // QueueType checking
+ EQType qType = GetQueueType(hMessage);
+ if (eQTypeSender != qType) {
+ return eFrameworkunifiedStatusInvldHndlType;
+ }
+
+ SQhandle *sndHndl = (SQhandle *)hMessage;
+
+ SSystemMsgHeader *msgHdr = (SSystemMsgHeader *)(sndHndl->sendbuf);
+
+ if (mqCheckValidHandle(hMessage) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+ if (sndHndl->sendbuf == NULL) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ return SendMessageWithPriority(hMessage, (UI_32)(msgHdr->info.length + sizeof(SSystemMsgHeader)), sndHndl->sendbuf,
+ eFrameworkunifiedMsgPrioNormal);
+}
+
+HANDLE McZcOpenSender(PCSTR source) {
+ HANDLE handle = openSenderZc(source);
+
+ if (handle != NULL) {
+ SQhandle *sndHndl = (SQhandle *)handle;
+ SSystemMsgHeader *msgHdr = (SSystemMsgHeader *)(sndHndl->sendbuf);
+
+ strlcpy(msgHdr->info.source, source, sizeof(msgHdr->info.source));
+ msgHdr->info.command = 0;
+ msgHdr->info.length = 0;
+ msgHdr->info.sessionid = 0;
+ msgHdr->eType = (UI_32)MC_EMSGT_VALID_TOKEN;
+ msgHdr->memId = 0;
+ }
+
+ return handle;
+}
+
+EFrameworkunifiedStatus McZcClose(HANDLE handle) {
+ return CloseSender(handle);
+}
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/cfg/depends.mk b/nsframework/framework_unified/client/NS_MessageQueue/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_anomaly.h b/nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_anomaly.h
new file mode 100644
index 00000000..5b02e2b2
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_anomaly.h
@@ -0,0 +1,35 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MQ_ANOMALY_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MQ_ANOMALY_H_
+
+#include <native_service/frameworkunified_types.h>
+
+typedef struct {
+ CHAR name[18];
+ UI_32 maxMsg;
+} mq_anomaly_t;
+
+mq_anomaly_t mq_anomaly_list[] = {
+ { "/NS_NPPService", 256 },
+ { "/NS_NPPWriteWkr", 256 },
+ { "/NS_NPPReadWkr", 256 },
+ { "/NS_NPPIPWkr", 256 },
+ { "/audio_app", 256 },
+};
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MQ_ANOMALY_H_
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_internal.h b/nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_internal.h
new file mode 100644
index 00000000..ca022181
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/include/ns_mq_internal.h
@@ -0,0 +1,58 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageQueue
+/// \brief API Header for Logger.
+///
+/// Declares the external APIs to Logger.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MQ_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MQ_INTERNAL_H_
+
+/////////////////////////////////////////
+#include <pthread.h>
+/////////////////////////////////////////
+
+
+/// \brief Struct that defines internal handle object
+typedef struct tQHandle {
+ UI_32 check_code;
+ SI_32 fd;
+ PSTR q_name;
+ EQType q_type;
+ void *sendbuf;
+
+ /////////////////////////////////////////
+ pthread_t threadid; // thread id of child thread (may be NULL)
+ /////////////////////////////////////////
+} SQhandle;
+
+#define MQ_CHECK_CODE (0xC0D1F1ED)
+
+static inline BOOL mqCheckValidHandle(HANDLE hMessage) {
+ if (INVALID_HANDLE != hMessage) {
+ SQhandle *sndHndl = (SQhandle *)hMessage; // NOLINT (readability/nolint)
+ if (sndHndl->check_code == MQ_CHECK_CODE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MQ_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/include/ns_msg_queue.h b/nsframework/framework_unified/client/NS_MessageQueue/include/ns_msg_queue.h
new file mode 100644
index 00000000..111b5bec
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/include/ns_msg_queue.h
@@ -0,0 +1,295 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_msg_queue.h
+ * @brief \~english TestFramework provides interface for implementing functional test classes.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MSG_QUEUE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MSG_QUEUE_H_
+
+#include <native_service/frameworkunified_types.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// \brief Enum that defines the value Q Types
+typedef enum eQType {
+ eQTypeReveiver,
+ eQTypeSender,
+ eQTypeInvld
+} EQType;
+
+// PASA CCR IPC Framework API
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// OpenReceiver
+/// The opens a handle to a Receiver message queue.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to receiver messages on
+///
+/// \return HANDLE
+/// handle - to a recevier's message queue
+/// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
+/// INVALID_HANDLE - or an error occurred while opening a queue
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE OpenReceiver(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// OpenReceiverNotBlocked
+/// The opens a handle to a Receiver message queue. Operations on this queue
+/// are non-blocking if queue is empty or full.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to receiver messages on
+///
+/// \return HANDLE
+/// handle - to a recevier's message queue
+/// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
+/// INVALID_HANDLE - or an error occurred while opening a queue
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE OpenReceiverNotBlocked(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// OpenSyncReceiver
+/// The opens a handle to a response Receiver message queue.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to receiver messages on
+///
+/// \return HANDLE
+/// handle - to a recevier's message queue
+/// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
+/// INVALID_HANDLE - or an error occurred while opening a queue
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE openSyncReceiver(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// OpenSender
+/// The opens a handle for sending messages to another message queue.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to send messages too
+///
+/// \return HANDLE
+/// handle - senders message queue handle
+/// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
+/// INVALID_HANDLE - or an error occurred while opening a queue
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE OpenSender(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// openSyncSender
+/// The opens a handle for sending response to another message queue.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to send messages too
+///
+/// \return HANDLE
+/// handle - senders message queue handle
+/// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
+/// INVALID_HANDLE - or an error occurred while opening a queue
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE openSyncSender(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// openSenderZc
+/// The opens a handle for sending response to another message queue.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to send messages too
+///
+/// \return HANDLE
+/// handle - senders message queue handle
+/// INVALID_HANDLE - Either message name is NULL or length is >= MAX_QUEUE_NAME_SIZE
+/// INVALID_HANDLE - or an error occurred while opening a queue
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE openSenderZc(PCSTR name);
+
+/////////////////////////////////////////
+#include <pthread.h>
+HANDLE OpenSenderChild(PCSTR name, pthread_t threadid);
+/////////////////////////////////////////
+
+/////////////////////////////////////////
+EFrameworkunifiedStatus JoinChild(HANDLE hChildApp);
+/////////////////////////////////////////
+
+/////////////////////////////////////////
+EFrameworkunifiedStatus GetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio);
+/////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendMessage
+/// The function sends a message to a queue.
+///
+/// \param [in] hMessage
+/// Handle - handle to the sendMessage, OpenSender
+/// \param [in] length
+/// UI_32 - length of the data to be sent
+/// \param [in] data
+/// const void* - pointer to the data that needs to be transmitted
+///
+/// \return EFrameworkunifiedaStatus
+/// status - status of the message(error)
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendMessage(HANDLE hMessage, UI_32 length, PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendMessageWithPriority
+/// The function sends a message to a queue.
+///
+/// \param [in] hMessage
+/// Handle - handle to the sendMessage, OpenSender
+/// \param [in] length
+/// UI_32 - length of the data to be sent
+/// \param [in] data
+/// const void* - pointer to the data that needs to be transmitted
+/// \param [in] priority
+/// EFrameworkunifiedMessagePriorties - priority at which the message should be sent at!
+///
+/// \return EFrameworkunifiedaStatus
+/// status - status of the message(error)
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendMessageWithPriority(HANDLE hMessage, UI_32 length, PVOID data, EFrameworkunifiedMessagePriorties priority);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ReceiveMessage
+/// The function blocks on a message queue waiting for data to be received.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the recvMessage, OpenReceiver
+/// \param [in] length
+/// UI_32 - length of the data buffer provided
+/// \param [in] data
+/// void* - pointer to the data to be received
+///
+/// \return SI_32
+/// length read - indicates the number of bytes that were read from the queue (eFrameworkunifiedStatusErrOther) error
+////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 ReceiveMessage(HANDLE hMessage, UI_32 length, PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CloseReceiver
+/// The closes a connection to a Receiver message queue.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the recvMessage that will be closed
+///
+/// \return EFrameworkunifiedaStatus
+/// status - indicates if the close was successfully (eFrameworkunifiedStatusOK) or not (anything else)
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CloseReceiver(HANDLE handle);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CloseReceiver
+/// The closes a connection to a Receiver message queue.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the recvMessage that will be closed
+///
+/// \return EFrameworkunifiedaStatus
+/// status - indicates if the close was successfully (eFrameworkunifiedStatusOK) or not (anything else)
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CloseSender(HANDLE handle);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Flush
+/// Flush all data on HANDLE's Receiver message queue.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the recvMessage queue that will be flushed
+///
+/// \return void
+////////////////////////////////////////////////////////////////////////////////////////////
+void Flush(HANDLE hMessage);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetQueueType
+/// Get the handle's queue type.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the Message queue
+///
+/// \return EQType
+/// EQType - queue type of handle
+////////////////////////////////////////////////////////////////////////////////////////////
+EQType GetQueueType(HANDLE hMessage);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// Function : TranslateError
+// Translates global error variables into FW EFrameworkunifiedStatus
+///
+/// \param [in] error
+/// int - error variable
+///
+/// \return EFrameworkunifiedStatus
+/// EFrameworkunifiedStatus - frameworkunified error type
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus TranslateError(int error);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetQueueName
+/// This gets the name of the message queue
+///
+/// \param [in] hMessage
+/// HANDLE - handle of the message queue
+/// (handle created with McOpenReceiver or McOpenSender)
+///
+/// \return PCSTR
+/// name - name of the message queue if handle is valid else NULL
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR GetQueueName(HANDLE hMessage);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetQueueFD
+/// This gets the fd of the message queue
+///
+/// \param [in] hMessage
+/// HANDLE - handle of the message queue
+/// (handle created with McOpenReceiver or McOpenSender)
+///
+/// \return int
+/// fd - fd of the message queue if handle is valid else -1
+////////////////////////////////////////////////////////////////////////////////////////////
+int GetQueueFD(HANDLE hMessage);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGEQUEUE_INCLUDE_NS_MSG_QUEUE_H_
+
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_MessageQueue/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..054db6dc
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/src/makefile_PosixBasedOS001
@@ -0,0 +1,207 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_MessageQueue
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_MessageQueue
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+# mqS is not available for x86
+ifneq ($(TARGET),x86)
+ # Link mqS only to PastModel003*1!
+ ifeq ($(PRODUCT_NAME),PastModel004)
+ STATIC_LIBS += mqS
+ LD_OFLAG := -Wl,-Bsymbolic $(LD_OFLAG)
+ endif
+endif
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/src/ns_mq_string.c b/nsframework/framework_unified/client/NS_MessageQueue/src/ns_mq_string.c
new file mode 100644
index 00000000..8749a990
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/src/ns_mq_string.c
@@ -0,0 +1,60 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <native_service/ns_logger_if.h>
+
+size_t strlcpy(char *dst, const char *src, size_t siz) {
+ if (dst == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "dst is NULL");
+ return 0;
+ }
+ if (src == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "src is NULL");
+ return 0;
+ }
+ size_t ret = strlen(src);
+
+ if (siz) {
+ size_t len = (ret >= siz) ? siz - 1 : ret;
+ memcpy(dst, src, len);
+ dst[len] = '\0';
+ }
+ return ret;
+}
+
+size_t strlcat(char *dst, const char *src, size_t siz) {
+ if (dst == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "dst is NULL");
+ return 0;
+ }
+ if (src == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "src is NULL");
+ return 0;
+ }
+ size_t dsiz = strlen(dst);
+ size_t len = strlen(src);
+ size_t res = dsiz + len;
+
+ dst += dsiz;
+ siz -= dsiz;
+ if (len >= siz) {
+ len = siz - 1;
+ }
+ memcpy(dst, src, len);
+ dst[len] = '\0';
+ return res;
+}
diff --git a/nsframework/framework_unified/client/NS_MessageQueue/src/ns_msg_queue.c b/nsframework/framework_unified/client/NS_MessageQueue/src/ns_msg_queue.c
new file mode 100644
index 00000000..19900617
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_MessageQueue/src/ns_msg_queue.c
@@ -0,0 +1,596 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageQueue
+/// \brief API Header for Zone Player Service APIs to be used by senders and
+/// receivers.
+///
+/// APIs to register/unregister notifications and add/remove recievers to the notifications.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include "ns_msg_queue.h"
+#include <malloc.h>
+#include <mqueue.h>
+#include <ns_mq_internal.h>
+#include <errno.h>
+#include "ns_mq_anomaly.h"
+
+#include <other_service/strlcpy.h>
+#include <other_service/strlcat.h>
+
+const UI_32 DEFAULT_MSG_PRIORITY = 10;
+const UI_32 MAX_MESSAGES_STORED_IN_QUEUE = 256;
+const UI_32 MAX_SYNC_RESPONSE_STORED_IN_QUEUE = 2;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : TranslateError
+// Translates global error variables into FW EFrameworkunifiedStatus
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus TranslateError(int error) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ switch (error) {
+ case EOK:
+ eStatus = eFrameworkunifiedStatusOK;
+ break;
+ case EBUSY:
+ eStatus = eFrameworkunifiedStatusThreadBusy;
+ break;
+ case EDEADLK:
+ eStatus = eFrameworkunifiedStatusThreadSelfJoin;
+ break;
+ case EFAULT:
+ eStatus = eFrameworkunifiedStatusFault;
+ break;
+ case EINVAL:
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ case ESRCH:
+ eStatus = eFrameworkunifiedStatusThreadNotExist;
+ break;
+ case EBADF:
+ eStatus = eFrameworkunifiedStatusErrNoEBADF;
+ break;
+ case EAGAIN:
+ eStatus = eFrameworkunifiedStatusErrNoEAGAIN;
+ break;
+ case EINTR:
+ eStatus = eFrameworkunifiedStatusErrNoEINTR;
+ break;
+ case EMSGSIZE:
+ eStatus = eFrameworkunifiedStatusInvldBufSize;
+ break;
+ case ENOTSUP:
+ eStatus = eFrameworkunifiedStatusNotImplemented;
+ break;
+ case EPERM:
+ eStatus = eFrameworkunifiedStatusAccessError;
+ break;
+ default:
+ eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+
+ return eStatus;
+}
+
+static UI_8 GetNormalizedMqName(PSTR normalized_mqname , PCSTR name, size_t size) {
+ if ((NULL != name) && (NULL != normalized_mqname)) {
+ if (name[0] != '/') {
+ strlcpy(normalized_mqname, "/", size);
+ strlcat(normalized_mqname, name, size);
+ } else {
+ strlcpy(normalized_mqname, name, size);
+ }
+
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+HANDLE OpenReceiverNotBlocked(PCSTR name) {
+ HANDLE rtnHandle = INVALID_HANDLE; // invalid until made valid.
+ PSTR normalized_qname = NULL;
+ SI_32 q_fd = -1; // fd to mqueue
+ SQhandle *rcvHndl = NULL;
+ struct mq_attr mqattr;
+ size_t norm_qname_size = 0;
+
+ // Check for invalid name
+ if (name == NULL) {
+ return INVALID_HANDLE;
+ }
+
+ if (strlen(name) >= MAX_QUEUE_NAME_SIZE) {
+ return INVALID_HANDLE;
+ }
+
+ norm_qname_size = strlen(name) + 2;
+ normalized_qname = (PSTR)malloc(norm_qname_size);
+
+ if (0 != GetNormalizedMqName(normalized_qname, name, norm_qname_size)) {
+ if (strlen(normalized_qname) > LIMIT_QUEUE_NAME_SIZE) {
+ free(normalized_qname);
+ return INVALID_HANDLE;
+ }
+
+ mqattr.mq_flags = 0;
+ mqattr.mq_maxmsg = (__syscall_slong_t)MAX_MESSAGES_STORED_IN_QUEUE;
+ mqattr.mq_msgsize = MAX_QUEUE_MSG_SIZE;
+
+ q_fd = mq_open(normalized_qname, O_RDONLY | O_CREAT | O_NONBLOCK | O_CLOEXEC , 0666, &mqattr);
+
+ if (q_fd != -1) {
+ rcvHndl = (SQhandle *)malloc(sizeof(SQhandle));
+ if (rcvHndl != NULL) {
+ rcvHndl->check_code = MQ_CHECK_CODE;
+ rcvHndl->fd = q_fd;
+ rcvHndl->q_name = normalized_qname;
+ rcvHndl->q_type = eQTypeReveiver;
+
+ /////////////////////////////////////////
+ rcvHndl->threadid = 0;
+ /////////////////////////////////////////
+
+ // Set the return handle to rcvHndl
+ rtnHandle = rcvHndl;
+ }
+ }
+ }
+
+ if (INVALID_HANDLE == rtnHandle) {
+ // couldn't connect the queue,
+ // release the memory to normalized queue name
+ if (normalized_qname != NULL) {
+ free(normalized_qname);
+ normalized_qname = NULL; // mb20110108 item 11
+ }
+ }
+
+ return rtnHandle;
+}
+
+static HANDLE openReceiverInternal(PCSTR name, UI_32 mq_maxmsg, UI_32 mq_msgsize, BOOL is_internal) {
+ HANDLE rtnHandle = INVALID_HANDLE; // invalid until made valid.
+ PSTR normalized_qname = NULL;
+ SI_32 q_fd = -1; // fd to mqueue
+ SQhandle *rcvHndl = NULL;
+ struct mq_attr mqattr;
+ size_t norm_qname_size = 0;
+
+ // Check for invalid name
+ if (name == NULL) {
+ return INVALID_HANDLE;
+ }
+
+ if (strlen(name) >= MAX_QUEUE_NAME_SIZE) {
+ return INVALID_HANDLE;
+ }
+
+ norm_qname_size = strlen(name) + 2;
+ normalized_qname = (PSTR)malloc(norm_qname_size);
+
+ if (0 != GetNormalizedMqName(normalized_qname, name, norm_qname_size)) {
+ int i;
+
+ if (!is_internal && strlen(normalized_qname) > LIMIT_QUEUE_NAME_SIZE) {
+ free(normalized_qname);
+ return INVALID_HANDLE;
+ }
+
+ mqattr.mq_flags = 0;
+ mqattr.mq_maxmsg = (__syscall_slong_t)mq_maxmsg;
+ mqattr.mq_msgsize = (__syscall_slong_t)mq_msgsize;
+
+ for (i = 0; i < (sizeof(mq_anomaly_list) / sizeof(mq_anomaly_list[0])); i++) {
+ if (strcmp(normalized_qname, mq_anomaly_list[i].name) == 0) {
+ mqattr.mq_maxmsg = (__syscall_slong_t)mq_anomaly_list[i].maxMsg;
+ break;
+ }
+ }
+
+
+ q_fd = mq_open(normalized_qname, O_RDONLY | O_CREAT | O_CLOEXEC, 0666, &mqattr);
+
+ if (q_fd != -1) {
+ rcvHndl = (SQhandle *)malloc(sizeof(SQhandle));
+ if (rcvHndl != NULL) {
+ rcvHndl->check_code = MQ_CHECK_CODE;
+ rcvHndl->fd = q_fd;
+ rcvHndl->q_name = normalized_qname;
+ rcvHndl->q_type = eQTypeReveiver;
+
+ /////////////////////////////////////////
+ rcvHndl->threadid = 0;
+ /////////////////////////////////////////
+
+ // Set the return handle to rcvHndl
+ rtnHandle = rcvHndl;
+ }
+
+ }
+ }
+
+ if (INVALID_HANDLE == rtnHandle) {
+ // couldn't connect the queue,
+ // release the memory to normalized queue name
+ if (normalized_qname != NULL) {
+ free(normalized_qname);
+ normalized_qname = NULL; // mb20110108 item 11
+ }
+ }
+
+ return rtnHandle;
+}
+
+HANDLE OpenReceiver(PCSTR name) {
+ return openReceiverInternal(name, MAX_MESSAGES_STORED_IN_QUEUE, MAX_QUEUE_MSG_SIZE, FALSE);
+}
+
+HANDLE openSyncReceiver(PCSTR name) {
+ return openReceiverInternal(name, MAX_SYNC_RESPONSE_STORED_IN_QUEUE , MAX_QUEUE_MSG_SIZE, TRUE);
+}
+
+static HANDLE openSenderInternal(PCSTR name, UI_32 mq_maxmsg, UI_32 mq_msgsize, BOOL is_internal, BOOL zero_copy) {
+ HANDLE rtnHandle = INVALID_HANDLE; // invalid until made valid.
+ SI_32 q_fd = -1; // fd to queue
+ SQhandle *sndHndl = NULL;
+ PSTR normalized_qname = NULL;
+ size_t norm_qname_size = 0;
+
+ struct mq_attr mqattr;
+
+ // Check for invalid name
+ if (name == NULL) {
+ return rtnHandle;
+ }
+
+ if (strlen(name) >= MAX_QUEUE_NAME_SIZE) {
+ return rtnHandle;
+ }
+
+ norm_qname_size = strlen(name) + 2;
+ normalized_qname = (PSTR)malloc(norm_qname_size);
+
+ if (NULL == normalized_qname) {
+ return rtnHandle;
+ }
+
+ if (0 != GetNormalizedMqName(normalized_qname, name, norm_qname_size)) {
+ int i;
+
+
+ if (!is_internal && strlen(normalized_qname) > LIMIT_QUEUE_NAME_SIZE) {
+ free(normalized_qname);
+ return INVALID_HANDLE;
+ }
+
+ mqattr.mq_flags = 0;
+ mqattr.mq_maxmsg = (__syscall_slong_t)mq_maxmsg;
+ mqattr.mq_msgsize = (__syscall_slong_t)mq_msgsize;
+
+ for (i = 0; i < (sizeof(mq_anomaly_list) / sizeof(mq_anomaly_list[0])); i++) {
+ if (strcmp(normalized_qname, mq_anomaly_list[i].name) == 0) {
+ mqattr.mq_maxmsg = (__syscall_slong_t)mq_anomaly_list[i].maxMsg;
+ break;
+ }
+ }
+
+ q_fd = mq_open(normalized_qname, O_WRONLY | O_CREAT | O_NONBLOCK | O_CLOEXEC, 0666, &mqattr);
+
+ if (q_fd != -1) {
+ sndHndl = (SQhandle *)malloc(sizeof(SQhandle));
+ if (NULL != sndHndl) {
+ sndHndl->check_code = MQ_CHECK_CODE;
+ sndHndl->fd = q_fd;
+ sndHndl->q_name = normalized_qname;
+ sndHndl->q_type = eQTypeSender;
+
+ sndHndl->threadid = 0;
+
+
+ // Set the return handle to sndHndl
+ rtnHandle = sndHndl;
+
+ if (zero_copy) {
+ sndHndl->sendbuf = malloc(MAX_QUEUE_MSG_SIZE);
+ if (sndHndl->sendbuf == NULL) {
+ // LCOV_EXCL_START 5: malloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ free(sndHndl);
+ rtnHandle = INVALID_HANDLE;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ sndHndl->sendbuf = NULL;
+ }
+ }
+ }
+ }
+
+ if (INVALID_HANDLE == rtnHandle) {
+ // couldn't connect the queue,
+ // release the memory to normalized queue name
+ if (normalized_qname != NULL) {
+ free(normalized_qname);
+ normalized_qname = NULL; // mb20110108 item 11
+ }
+ if (q_fd != -1) {
+ mq_close(q_fd);
+ }
+ }
+
+ return rtnHandle; // invalid until made valid.
+}
+
+HANDLE OpenSender(PCSTR name) {
+ return openSenderInternal(name, MAX_MESSAGES_STORED_IN_QUEUE, MAX_QUEUE_MSG_SIZE, FALSE, FALSE);
+}
+
+
+HANDLE OpenSenderChild(PCSTR name, pthread_t threadid) {
+ HANDLE h = OpenSender(name);
+ if (INVALID_HANDLE != h) {
+ SQhandle *sq = (SQhandle *)h;
+ sq->threadid = threadid;
+ }
+ return h;
+}
+
+
+HANDLE openSyncSender(PCSTR name) {
+ return openSenderInternal(name, MAX_SYNC_RESPONSE_STORED_IN_QUEUE, MAX_QUEUE_MSG_SIZE, TRUE, FALSE);
+}
+
+HANDLE openSenderZc(PCSTR name) {
+ return openSenderInternal(name, MAX_MESSAGES_STORED_IN_QUEUE, MAX_QUEUE_MSG_SIZE, FALSE, TRUE);
+}
+
+
+EFrameworkunifiedStatus JoinChild(HANDLE hChildApp) {
+ // mb20110108 Code re-structured per comments 24 & 25
+ if (mqCheckValidHandle(hChildApp)) {
+ SQhandle *sq = (SQhandle *)hChildApp;
+ return TranslateError(pthread_join(sq->threadid, NULL));
+ } else {
+ return eFrameworkunifiedStatusFail;
+ }
+}
+
+EFrameworkunifiedStatus GetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 6:GetChildThreadPriority is called by McGetChildThreadPriority, and hChildApp will check there.
+ if (mqCheckValidHandle(hChildApp)) {
+ // LCOV_EXCL_BR_STOP
+ SQhandle *sq = (SQhandle *)hChildApp;
+ SI_32 schedPolicy; // this is needed according to syntax of pthread_getschedparam. api not available to get prio directly.
+ struct sched_param schedParam;
+ eStatus = TranslateError(pthread_getschedparam(sq->threadid, &schedPolicy, &schedParam));
+
+ *threadPrio = schedParam.sched_priority;
+ } else {
+ // LCOV_EXCL_START 6:GetChildThreadPriority is called by McGetChildThreadPriority, and hChildApp will check there.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+ return eStatus;
+}
+
+/// endhack...
+/////////////////////////////////////////
+
+EFrameworkunifiedStatus SendMessage(HANDLE hMessage, UI_32 length, PVOID data) {
+ return SendMessageWithPriority(hMessage, length, data, eFrameworkunifiedMsgPrioNormal);
+}
+
+EFrameworkunifiedStatus SendMessageWithPriority(HANDLE hMessage, UI_32 length, PVOID data, EFrameworkunifiedMessagePriorties priority) {
+ // define a Q handle structure
+ SQhandle *sndHndl = NULL;
+
+ // mb20110108 Added per comments 27 & 28
+ if (length > 0 && NULL == data) {
+ return eFrameworkunifiedStatusInvldBuf;
+ }
+
+ // check handle for null case...
+ if (mqCheckValidHandle(hMessage) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ sndHndl = (SQhandle *)hMessage;
+
+ // check to see if this is a sender handle
+ if (sndHndl->q_type != eQTypeSender) {
+ return eFrameworkunifiedStatusInvldHndlType;
+ }
+
+ if (-1 == mq_send((mqd_t)sndHndl->fd, (PCSTR)data, (size_t)length, (unsigned int)priority)) {
+ if (errno == EAGAIN) {
+ return eFrameworkunifiedStatusMsgQFull;
+ } else {
+ return TranslateError(errno);
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+SI_32 ReceiveMessage(HANDLE hMessage, UI_32 length, PVOID data) {
+ // define a Q handle structure
+ SQhandle *rcvHndl = NULL;
+
+ // check handle for null case...
+ if (mqCheckValidHandle(hMessage) == FALSE) {
+ errno = ENODATA;
+ return -1;
+ }
+
+ rcvHndl = (SQhandle *)hMessage;
+
+ // check to see if this is a receiver handle
+ if (rcvHndl->q_type != eQTypeReveiver) {
+ errno = ENODATA;
+ return -1;
+ }
+
+
+ return (SI_32)mq_receive((mqd_t)rcvHndl->fd, (char *)data, (size_t)length, NULL);
+}
+
+EFrameworkunifiedStatus CloseReceiver(HANDLE handle) {
+ SQhandle *rcvHndl = NULL;
+ SI_32 q_fd;
+
+ // check handle for null case...
+ if (mqCheckValidHandle(handle) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ rcvHndl = (SQhandle *)handle;
+
+ // check to see if this is a receiver handle
+ if (rcvHndl->q_type != eQTypeReveiver) {
+ return eFrameworkunifiedStatusInvldHndlType;
+ }
+
+ rcvHndl->check_code = 0;
+ q_fd = rcvHndl->fd;
+
+ if (NULL != rcvHndl->q_name) {
+ free(rcvHndl->q_name); // remove the memory to the name
+ rcvHndl->q_name = NULL;
+ }
+ free((void *)handle); // remove handle.. now..
+ handle = INVALID_HANDLE;
+
+ return ((-1 == mq_close((mqd_t)q_fd)) ? eFrameworkunifiedStatusInvldHandle : eFrameworkunifiedStatusOK);
+}
+
+EFrameworkunifiedStatus CloseSender(HANDLE handle) {
+ SQhandle *sndHndl = NULL;
+ SI_32 q_fd;
+
+ // check handle for null case...
+ if (mqCheckValidHandle(handle) == FALSE) {
+ return eFrameworkunifiedStatusInvldHandle;
+ }
+
+ sndHndl = (SQhandle *)handle;
+
+ // check to see if this is a sender handle
+ if (sndHndl->q_type != eQTypeSender) {
+ return eFrameworkunifiedStatusInvldHndlType;
+ }
+
+ sndHndl->check_code = 0;
+ q_fd = sndHndl->fd; // copy the fd, need it to close the queues....
+
+ if (NULL != sndHndl->q_name) {
+ free(sndHndl->q_name); // remove the memory to the name
+ sndHndl->q_name = NULL;
+ }
+ if (NULL != sndHndl->sendbuf) {
+ free(sndHndl->sendbuf);
+ sndHndl->sendbuf = NULL;
+ }
+ free((void *)handle); // remove handle.. now..
+ handle = INVALID_HANDLE; // invalidate handle so user doesn't reuse...
+
+ return (-1 == mq_close((mqd_t)q_fd)) ? eFrameworkunifiedStatusInvldHandle : eFrameworkunifiedStatusOK;
+}
+
+static UI_8 IsMessageAvailable(SI_32 fd) {
+ struct mq_attr sMqStatus;
+ if (-1 == mq_getattr(fd, &sMqStatus)) {
+ // Error Detected.
+ return 0;
+ } else {
+ if (0 < sMqStatus.mq_curmsgs) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+}
+
+void Flush(HANDLE hMessage) {
+ SQhandle *rcvHndl = NULL;
+
+ if (mqCheckValidHandle(hMessage)) {
+ rcvHndl = (SQhandle *)hMessage;
+
+ if (rcvHndl->q_type != eQTypeReveiver) {
+ return;
+ }
+
+ // check there is anything on the queue before going into the loop....
+ if (IsMessageAvailable(rcvHndl->fd)) {
+ CHAR l_pReceiveBuffer_o[MAX_QUEUE_MSG_SIZE];
+
+ // read till there isn't anything on the queue.
+ while (IsMessageAvailable(rcvHndl->fd)) {
+ mq_receive((mqd_t)rcvHndl->fd, l_pReceiveBuffer_o, (size_t)MAX_QUEUE_MSG_SIZE, NULL);
+ }
+ }
+ }
+}
+
+EQType GetQueueType(HANDLE hMessage) {
+ EQType qType = eQTypeInvld;
+
+ if (mqCheckValidHandle(hMessage)) {
+ SQhandle *handle = (SQhandle *)hMessage;
+ qType = handle->q_type;
+ }
+
+ return qType;
+}
+
+PCSTR GetQueueName(HANDLE hMessage) {
+ PCSTR name = NULL;
+
+ if (mqCheckValidHandle(hMessage)) {
+ SQhandle *hMsgQ = (SQhandle *)hMessage;
+
+ if (hMsgQ->q_type == eQTypeSender ||
+ hMsgQ->q_type == eQTypeReveiver) {
+ name = hMsgQ->q_name;
+ }
+ }
+
+ return name;
+}
+
+int GetQueueFD(HANDLE hMessage) {
+ int fd = -1;
+
+ if (mqCheckValidHandle(hMessage)) {
+ SQhandle *hMsgQ = (SQhandle *)hMessage;
+
+ if (hMsgQ->q_type == eQTypeSender ||
+ hMsgQ->q_type == eQTypeReveiver) {
+ fd = hMsgQ->fd;
+ }
+ }
+
+ return fd;
+}
diff --git a/nsframework/framework_unified/client/NS_NPServiceIf/cfg/depends.mk b/nsframework/framework_unified/client/NS_NPServiceIf/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_NPServiceIf/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_NPServiceIf/include/ns_np_service_internal.h b/nsframework/framework_unified/client/NS_NPServiceIf/include/ns_np_service_internal.h
new file mode 100644
index 00000000..469b4c03
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_NPServiceIf/include/ns_np_service_internal.h
@@ -0,0 +1,75 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_np_service_internal.h
+ * @brief \~english TestFramework provides interface for implementing functional test classes.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_SERVICE_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_SERVICE_INTERNAL_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendStopToNSNPP
+/// To be used by System Manager Service only. This API would push NPP Service to persist
+/// the data/files. Ideally this should be sent during system shutdown by System Manager Service
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of the requesters message queue
+/// \param [in] eShutdownType
+/// EFrameworkunifiedShutdownType - shutdown type
+/// \param [in] uiStopMsgData
+/// UI_32 - Flag representing which data to persist and which data to delete
+/// from persistent memory
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendStopToNSNPP(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_SERVICE_INTERNAL_H_
+/** @}*/
+/** @}*/
+/** @}*/
+
+// EOF
diff --git a/nsframework/framework_unified/client/NS_NPServiceIf/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_NPServiceIf/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..cbfc140f
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_NPServiceIf/src/makefile_PosixBasedOS001
@@ -0,0 +1,208 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_NPServiceIf
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_NPServiceIf
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_UtilityCenter/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(PRJ_ROOT)../$(COMPONENT_NAME)/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+ifdef DYNAMIC
+ DYNAMIC_LIBS += \
+ NS_MessageCenter$(DEBUG_EXT)
+else
+ STATIC_LIBS +=
+endif
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_api.c b/nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_api.c
new file mode 100644
index 00000000..d41514d1
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_api.c
@@ -0,0 +1,1001 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPService
+/// \brief APIs to be used by clients while invoking Notification Service.
+///
+/// Implementation of APIs for Publishers and Subscribers of notifications.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_mc_system_info.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <limits.h>
+#include <other_service/strlcpy.h>
+
+// define user name as blank for global persistence file
+#define GLOBAL_PERSISTENCE ""
+
+// this is the maximum number of notifications that can be registered/ unregistered at once
+const UI_32 maxNotification = UINT_MAX / sizeof(NC_register_notif_msg);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPRegisterNotifications
+/// API to send message to Notification Service to register a set of notifications
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \param [in] numNotifications
+/// PCSTR - Name of Notification
+/// \param [in] pNotificationArray
+/// NotificationInfo - Array of notifications
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
+ NotificationInfo *pNotificationArray) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (maxNotification < numNotifications) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ size_t sizeOfMsg = (sizeof(NC_register_notif_msg) * numNotifications) + sizeof(UI_32);
+ if (NULL == pNotificationArray) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
+
+ if (NULL == pMsgBuffer) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ NC_register_multiple_notif_msg *pNotifMsg = (NC_register_multiple_notif_msg *)pMsgBuffer;
+
+ pNotifMsg->numNotifications = numNotifications;
+ memcpy(&pNotifMsg->notifierList[0], pNotificationArray, sizeof(NC_register_notif_msg) * numNotifications);
+
+ for(UI_32 i = 0; i < numNotifications; i++) {
+ // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
+ strlcpy(pNotifMsg->notifierList[i].notificationName,
+ pNotificationArray[i].notificationName,
+ sizeof(pNotificationArray[i].notificationName));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_REGISTER_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pNotifMsg) ;
+
+ free(pMsgBuffer);
+ pMsgBuffer = NULL;
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPUnRegisterNotifications
+/// API to send message to Notification Service to remove a set of notifications
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \param [in] numNotifications
+/// PCSTR - Name of Notification
+/// \param [in] pNotificationArray
+/// NotificationInfo - Array of notifications
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPUnRegisterNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
+ NotificationInfo *pNotificationArray) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (maxNotification < numNotifications) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ size_t sizeOfMsg = (sizeof(NC_unregister_notif_msg) * numNotifications) + sizeof(UI_32);
+ UI_32 i = 0;
+ if (NULL == pNotificationArray) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
+
+ if (NULL == pMsgBuffer) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ NC_unregister_multiple_notif_msg *pNotifMsg = (NC_unregister_multiple_notif_msg *)pMsgBuffer;
+
+ pNotifMsg->numNotifications = numNotifications;
+
+ for (i = 0; i < numNotifications; ++i) {
+ strlcpy(pNotifMsg->notificationList[i].notificationName, pNotificationArray[i].notificationName,
+ sizeof(pNotifMsg->notificationList[i].notificationName));
+ }
+
+ // mb20110110 Fixed issue 135
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_UNREGISTER_EV_REQ, (UI_32)sizeOfMsg, (VOID *)pMsgBuffer) ;
+
+ free(pMsgBuffer);
+ pMsgBuffer = NULL; // mb20110110 issue 134
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPRegisterNotification
+/// API to send message to Notification Service to register a notification
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \param [in] notif_name
+/// PCSTR - Name of Notification
+/// \param [in] max_length
+/// const UI_32 - Max size of the notification message
+/// \param [in] bIsPersistent
+/// const UI_8 - Flag to indicate if it has to be persistent
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR notificationName,
+ const UI_32 maxLength, const EFrameworkunifiedNotificationType perstype)
+
+{
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != notificationName) {
+ if (strlen(pPublisherName) && strlen(notificationName)) {
+ NotificationInfo data = {};
+ strlcpy(data.notificationName, notificationName, sizeof(data.notificationName));
+ data.persType = perstype;
+ data.maxLength = maxLength;
+
+ eFrameworkunifiedStatus = NPRegisterNotifications(hNPMsgQ, pPublisherName, 1, &data);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPUnRegisterNotification
+/// API to send message to Notification Service to remove a notification
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPUnRegisterNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification) {
+
+ NotificationInfo data = {};
+ strlcpy(data.notificationName, pNotification, sizeof(data.notificationName));
+ return (NPUnRegisterNotifications(hNPMsgQ, pPublisherName, 1, &data));
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPPublishNotification
+/// API to send message to Notification Service to notify subscribers
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+/// \param [in] pData
+/// VOID * - Data buffer
+/// \param [in] iLength
+/// const UI_32 - Size of data buffer
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPPublishNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
+ PCVOID pData, const UI_32 iLength) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pNotification) {
+ if (strlen(pPublisherName) && strlen(pNotification)) {
+ if (strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
+ // Insert \0 at the end of characters (up to 64bytes) by copying pNotification to local variables with strlcpy.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
+ eFrameworkunifiedStatus = McSendWithSysInfo(hNPMsgQ, pPublisherName, NPS_PUBLISH_EV_REQ,
+ tmp_notification, iLength, pData, 0);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSubscribeToNotification
+/// API to send message to Notification Service to add to subscription list for
+/// that notification
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pSubscriberName
+/// PCSTR - Name of subscriber message queue
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSubscribeToNotification(HANDLE hNPMsgQ, PCSTR pSubscriberName, PCSTR pNotification) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ if (NULL != hNPMsgQ && NULL != pSubscriberName && NULL != pNotification) {
+ if (strlen(pSubscriberName) && strlen(pNotification)) {
+ NC_subscribe_msg data;
+ snprintf(data.notificationName, sizeof(data.notificationName), "%s", pNotification);
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pSubscriberName, NPS_SUBSCRIBE_TO_EV_REQ, sizeof(NC_subscribe_msg), (PVOID)&data);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// NPSubscribeToNotifications
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSubscribeToNotifications(HANDLE hNPMsgQ, PCSTR pSubscriberName, UI_32 numNotifications,
+ SubscribeInfo *pSubscribeInfoArray) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (maxNotification < numNotifications) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ size_t sizeOfMsg = (sizeof(NC_subscribe_msg) * numNotifications) + sizeof(UI_32);
+ if (NULL == pSubscribeInfoArray) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
+
+ if (NULL == pMsgBuffer) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ NC_subscribe_multiple_notif_msg *pSubscribeMsg = (NC_subscribe_multiple_notif_msg *)pMsgBuffer;
+
+ pSubscribeMsg->numNotifications = numNotifications;
+ memcpy(&pSubscribeMsg->notificationList[0], pSubscribeInfoArray, sizeof(NC_subscribe_msg) * numNotifications);
+
+ for(UI_32 i = 0; i < numNotifications; i++) {
+ // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
+ strlcpy(pSubscribeMsg->notificationList[i].notificationName,
+ pSubscribeInfoArray[i].notificationName,
+ sizeof(pSubscribeInfoArray[i].notificationName));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pSubscriberName, NPS_BATCH_SUBSCRIBE_TO_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pSubscribeMsg) ;
+
+ free(pMsgBuffer);
+ pMsgBuffer = NULL;
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPUnsubscribeFromNotification
+/// API to send message to Notification Service to remove from subscription list for
+/// that notification
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pSubscriberName
+/// PCSTR - Name of subscriber message queue
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPUnsubscribeFromNotification(HANDLE hNPMsgQ, PCSTR pSubscriberName, PCSTR pNotification) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pSubscriberName && NULL != pNotification) {
+ if (strlen(pSubscriberName) && strlen(pNotification)) {
+ NC_unsubscribe_frm_notif_msg data;
+ snprintf(data.notificationName, sizeof(data.notificationName), "%s", pNotification);
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pSubscriberName, NPS_UNSUBSCRIBE_FROM_EV_REQ, sizeof(NC_unsubscribe_frm_notif_msg),
+ (PVOID)&data);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// NPUnsubscribeToNotifications
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPUnsubscribeFromNotifications(HANDLE hNPMsgQ, PCSTR pUnSubscriberName, UI_32 numNotifications,
+ SubscribeInfo *pUnSubscribeInfoArray) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pUnSubscriberName) {
+ if (strlen(pUnSubscriberName)) {
+ if (maxNotification < numNotifications) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ size_t sizeOfMsg = (sizeof(NC_subscribe_msg) * numNotifications) + sizeof(UI_32);
+ if (NULL == pUnSubscribeInfoArray) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
+
+ if (NULL == pMsgBuffer) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ NC_unsubscribe_multiple_notif_msg *pUnSubscribeMsg = (NC_unsubscribe_multiple_notif_msg *)pMsgBuffer;
+
+ pUnSubscribeMsg->numNotifications = numNotifications;
+ memcpy(&pUnSubscribeMsg->notificationList[0], pUnSubscribeInfoArray, sizeof(NC_subscribe_msg) * numNotifications);
+
+ for(UI_32 i = 0; i < numNotifications; i++) {
+ // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
+ strlcpy(pUnSubscribeMsg->notificationList[i].notificationName,
+ pUnSubscribeInfoArray[i].notificationName,
+ sizeof(pUnSubscribeInfoArray[i].notificationName));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pUnSubscriberName, NPS_BATCH_UNSUBSCRIBE_FROM_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pUnSubscribeMsg) ;
+
+ free(pMsgBuffer);
+ pMsgBuffer = NULL;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPReadPersistedData
+/// API to requested the persistent data corresponding to specified notification if available
+/// The caller recieves an acknowledgement once NPS completes data retrieval and sends it.
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of publisher message queue
+/// \param [in] notification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPReadPersistedData(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR notification) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != notification) {
+ if (strlen(pPublisherName) && strlen(notification)) {
+ NC_get_pers_data_msg msg;
+
+ snprintf(msg.notificationName, sizeof(msg.notificationName), "%s", notification);
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_GET_PERS_DATA_REQ, sizeof(msg), (PVOID)&msg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSavePersistentData
+/// API to send message to Notification Service to save all persisted data that in Ram
+/// to the filesystem via a file write.
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of publisher message queue
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSavePersistentData(HANDLE hNPMsgQ, PCSTR pPublisherName) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SAVE_PERS_DATA_REQ, 0, NULL) ;
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPRegisterPersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterPersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pTag,
+ BOOL bIsUserFile) { // EFrameworkunifiedRegisterType eRegisterType)
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
+ if (strlen(pPublisherName) && strlen(pTag)) {
+ NC_RegisterPersistentFileMsg tMsg;
+
+ snprintf(tMsg.cFileTag, sizeof(tMsg.cFileTag), "%s", pTag);
+ tMsg.bIsUserFile = bIsUserFile;
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SET_PERSIST_FILE_PATH_REQ, sizeof(tMsg),
+ (PVOID)&tMsg);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPLoadPersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPLoadPersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pDstFilePath,
+ PCSTR pTag, HANDLE hUser) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName &&
+ NULL != pDstFilePath && NULL != pTag) {
+ if (strlen(pPublisherName) && strlen(pDstFilePath) && strlen(pTag)) {
+ NC_LoadPersistedFileMsg tMsg = {};
+
+ snprintf(tMsg.cFilePath, sizeof(tMsg.cFilePath), "%s", pDstFilePath);
+ snprintf(tMsg.cFileTag, sizeof(tMsg.cFileTag), "%s", pTag);
+
+ if (hUser) {
+ NC_User *pUser = (NC_User *) hUser;
+ snprintf(tMsg.cUsername, sizeof(tMsg.cUsername), "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
+ } else {
+ strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_GET_PERS_FILE_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPReleasePersistentFile
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPReleasePersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType, PCSTR pTag,
+ PCSTR pFullFilePath, HANDLE hUser) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName &&
+ NULL != pTag && NULL != pFullFilePath) {
+ if (strlen(pPublisherName) && strlen(pTag) && strlen(pFullFilePath)) {
+ NC_ReleasePersistentFileMsg tMsg = {eFrameworkunifiedReleaseType, {0}, {0}};
+
+ snprintf(tMsg.cFilePath, sizeof(tMsg.cFilePath), "%s", pFullFilePath);
+ snprintf(tMsg.cFileTag, sizeof(tMsg.cFileTag), "%s", pTag);
+
+ if (hUser) {
+ NC_User *pUser = (NC_User *) hUser;
+ snprintf(tMsg.cUsername, sizeof(tMsg.cUsername), "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
+ } else {
+ strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_RELEASE_PERS_FILE_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPPersistentSync
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPPersistentSync(PCSTR SrcName, HANDLE hNPMsgQ, UI_32 sessionid, PCSTR pPublisherName) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ CHAR data[4];
+ UI_32 length;
+ HANDLE hResponse;
+ char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
+
+ McCreateInvokerName(SrcName, sessionid, mc_invoker_name, sizeof(mc_invoker_name));
+ hResponse = McOpenSyncReceiver(&mc_invoker_name[0]);
+ if (hResponse != NULL) {
+ eFrameworkunifiedStatus = McInvokeSync(hNPMsgQ, pPublisherName, NPS_NPP_SYNC_REQ , sizeof(data), data, sessionid,
+ hResponse, 0, NULL, &length);
+ McClose(hResponse);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ return eFrameworkunifiedStatus;
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSetPersonality
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetPersonality(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pUserName) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pUserName) {
+ if (strlen(pPublisherName) && strlen(pUserName)) {
+ // NC_SetPersonalityMsg tMsg;
+ NC_User tMsg;
+
+ snprintf(tMsg.cUsername, sizeof(tMsg.cUsername), "%s", pUserName);
+
+ // eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SET_PERSONALITY_REQ, sizeof(tMsg), (PVOID)&tMsg ) ;
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_CHANGE_PERSONALITY_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPRegisterPersistentFolder
+/// API to register persistence tag to folder that need to persist
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of publisher message queue
+/// \param [in] pTag
+/// PCSTR - Tag associated to folder that need to persist
+/// \param [in] bIsUserFolder
+/// BOOL - TRUE - user specific folder
+/// FALSE - global file
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterPersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pTag, BOOL bIsUserFolder) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
+ if (strlen(pPublisherName) && strlen(pTag)) {
+ NC_RegisterPersistentFolderMsg tMsg;
+
+ snprintf(tMsg.cFolderTag, sizeof(tMsg.cFolderTag), "%s", pTag);
+ tMsg.bIsUserFolder = bIsUserFolder;
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SET_PERSIST_FOLDER_PATH_REQ, sizeof(tMsg),
+ (PVOID)&tMsg);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPLoadPersistentFolder
+/// API to load folder to given path and associated with given tag from persistent memory
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of publisher message queue
+/// \param [in] pDstFolderPath
+/// PCSTR - Destination where folder needs to be loaded
+/// \param [in] pTag
+/// PCSTR - Tag associated to folder that need to loaded from persistent memory
+/// \param [in] hUser
+/// HANDLE - Handle of the user
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPLoadPersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pDstFolderPath,
+ PCSTR pTag, HANDLE hUser) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName &&
+ NULL != pDstFolderPath && NULL != pTag) {
+ if (strlen(pPublisherName) && strlen(pDstFolderPath) && strlen(pTag)) {
+ NC_LoadPersistedFolderMsg tMsg;
+
+ snprintf(tMsg.cFolderPath, sizeof(tMsg.cFolderPath), "%s", pDstFolderPath);
+ snprintf(tMsg.cFolderTag, sizeof(tMsg.cFolderTag), "%s", pTag);
+
+ if (hUser) {
+ NC_User *pUser = (NC_User *) hUser;
+ snprintf(tMsg.cUsername, sizeof(tMsg.cUsername), "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
+ } else {
+ strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_GET_PERS_FOLDER_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPReleasePersistentFolder
+/// API to release folder for saving with tag name to persistent memory
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of publisher message queue
+/// \param [in] eFrameworkunifiedReleaseType
+/// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease :not on release
+/// eFrameworkunifiedPersistOnShutdown:persist on shutdown
+/// eFrameworkunifiedPersistInstantly :persist instantly
+/// \param [in] pTag
+/// PCSTR - Tag associated to folder that need to persist
+/// \param [in] pFullFolderPath
+/// PCSTR - full folder path of folder that need to be stored in persistent memory
+/// \param [in] hUser
+/// HANDLE - Handle of the user
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPReleasePersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType,
+ PCSTR pTag, PCSTR pFullFolderPath, HANDLE hUser) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName &&
+ NULL != pTag && NULL != pFullFolderPath) {
+ if (strlen(pPublisherName) && strlen(pFullFolderPath) && strlen(pTag)) {
+ NC_ReleasePersistentFolderMsg tMsg = {eFrameworkunifiedReleaseType, {0}, {0}};
+
+ snprintf(tMsg.cFolderPath, sizeof(tMsg.cFolderPath), "%s", pFullFolderPath);
+ snprintf(tMsg.cFolderTag, sizeof(tMsg.cFolderTag), "%s", pTag);
+
+ if (hUser) {
+ NC_User *pUser = (NC_User *) hUser;
+ snprintf(tMsg.cUsername, sizeof(tMsg.cUsername), "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
+ } else {
+ strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_RELEASE_PERS_FOLDER_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPChangePersonality
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPChangePersonality(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pUserName) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != pUserName && 0 != strlen(pUserName)) {
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_CHANGE_PERSONALITY_REQ, sizeof(pUserName), (PVOID)&pUserName) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SendStopToNSNPP
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SendStopToNSNPP(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != pPublisherName && 0 != strlen(pPublisherName)) {
+ NC_StopMsgData tMsg;
+ tMsg.eShutdownType = eShutdownType;
+ tMsg.uiStopMsgData = uiStopMsgData;
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_NPP_STOP_REQ, sizeof(tMsg), (PVOID)&tMsg);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPGetReadyStatusOfNPP
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPGetReadyStatusOfNPP(HANDLE hNPMsgQ, PCSTR pRequesterName) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != pRequesterName && 0 != strlen(pRequesterName)) {
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pRequesterName, NPS_GET_READYSTATUS_REQ, 0, NULL);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPRegisterImmediateNotifications
+/// API to send message to Notification Service to register a set of notifications
+///
+/// \param [in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \param [in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \param [in] numNotifications
+/// PCSTR - Name of Notification
+/// \param [in] pNotificationArray
+/// ImmediateNotificationInfo - Array of notifications
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterImmediateNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
+ ImmediateNotificationInfo *pNotificationArray) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (maxNotification < numNotifications) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ size_t sizeOfMsg = (sizeof(NC_register_immediate_notif_msg) * numNotifications) + sizeof(UI_32);
+ if (NULL == pNotificationArray) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
+
+ if (NULL == pMsgBuffer) {
+ return eFrameworkunifiedStatusFail;
+ }
+
+ NC_register_multiple_immediate_notif_msg *pNotifMsg = (NC_register_multiple_immediate_notif_msg *)pMsgBuffer;
+
+ if (NULL != pNotifMsg) {
+ pNotifMsg->numNotifications = numNotifications;
+ }
+
+ memcpy(&pNotifMsg->notifierList[0], pNotificationArray, sizeof(NC_register_immediate_notif_msg) * numNotifications);
+
+ for(UI_32 i = 0; i < numNotifications; i++ ) {
+ // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
+ strlcpy(pNotifMsg->notifierList[i].notificationName,
+ pNotificationArray[i].notificationName,
+ sizeof(pNotificationArray[i].notificationName));
+ }
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_REGISTER_NOR_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pNotifMsg) ;
+
+ if (NULL != pMsgBuffer) {
+ free(pMsgBuffer);
+ pMsgBuffer = NULL;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPClearPersistedData
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPClearPersistedData(HANDLE hNPMsgQ, PCSTR pRequesterName, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if ((NULL != hNPMsgQ) && (NULL != pRequesterName) && (0 != strlen(pRequesterName))) {
+ NC_ClearPersistedDataReq tMsg = {};
+ tMsg.ePersistenceData = eFrameworkunifiedClearPersistenceScope;
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ,
+ pRequesterName,
+ NPS_DELETE_PERSISTED_DATA_REQ,
+ sizeof(tMsg),
+ &tMsg);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSetPersistNotfnDefaultValue
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetPersistNotfnDefaultValue(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification, PCVOID pData,
+ const UI_32 iLength) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pNotification) {
+ if ((0 != strlen(pPublisherName)) && (0 != strlen(pNotification))) {
+
+ // Insert \0 at the end of characters (up to 64bytes) by copying pNotification to local variables with strlcpy.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
+
+ eFrameworkunifiedStatus = McSendWithSysInfo(hNPMsgQ,
+ pPublisherName,
+ NPS_SET_DEFAULT_PERS_DATA,
+ (PCHAR)tmp_notification,
+ iLength,
+ pData,
+ 0);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSetPersistentNotfnType
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetPersistentNotfnType(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
+ EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pNotification) {
+ if ((0 != strlen(pPublisherName)) && (0 != strlen(pNotification))) {
+
+ // Insert \0 at the end of characters (up to 64bytes) by copying pNotification to local variables with strlcpy.
+ char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
+ strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
+
+ eFrameworkunifiedStatus = McSendWithSysInfo(hNPMsgQ,
+ pPublisherName,
+ NPS_SET_NOTFN_PERSISTENT_TYPE,
+ (PCHAR)tmp_notification,
+ sizeof(ePersistCategory),
+ &ePersistCategory,
+ 0);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSetFilePersistentType
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetFilePersistentType(HANDLE hNPMsgQ, PCSTR pPublisherName,
+ PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
+ if ((0 != strlen(pPublisherName)) && (0 != strlen(pTag))) {
+ NC_SetFilePersistType tMsg = {};
+
+ tMsg.ePersistType = ePersistCategory;
+
+ snprintf(tMsg.cTag, sizeof(tMsg.cTag), "%s", pTag);
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ,
+ pPublisherName,
+ NPS_SET_FILE_PERSISTENT_TYPE,
+ sizeof(tMsg),
+ (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSetFolderPersistentType
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetFolderPersistentType(HANDLE hNPMsgQ, PCSTR pPublisherName,
+ PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
+ if ((0 != strlen(pPublisherName)) && (0 != strlen(pTag))) {
+ NC_SetFolderPersistType tMsg = {};
+
+ tMsg.ePersistType = ePersistCategory;
+ snprintf(tMsg.cTag, sizeof(tMsg.cTag), "%s", pTag);
+
+ eFrameworkunifiedStatus = McSend(hNPMsgQ,
+ pPublisherName,
+ NPS_SET_FOLDER_PERSISTENT_TYPE,
+ sizeof(tMsg),
+ (PVOID)&tMsg) ;
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+// EOF
diff --git a/nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_nor_persistence.cpp b/nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_nor_persistence.cpp
new file mode 100644
index 00000000..a7777432
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_NPServiceIf/src/ns_np_service_nor_persistence.cpp
@@ -0,0 +1,498 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPService
+/// \brief This file contains the API to store and retrieve immediate
+/// notification data from and to persistent storage.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <semaphore.h>
+#include <aglpath.h>
+
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_util_directory.h>
+#include <native_service/ns_np_service_nor_persistence.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+#include <string>
+
+#include <native_service/ns_np_service_nor_persistence_internal.h>
+#include <native_service/ns_np_types.h>
+#include <native_service/ns_mc_system_info.h>
+
+sem_t g_FileAccessSemaphore;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSynchronousReadPersistentData
+/// Read immediate persistent data from the persistent memory
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousReadPersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ UI_32 uiDataSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ NC_NorPersistentData l_tNorPersistentData = {};
+
+ if (NULL != pAppName && NULL != notif_name && NULL != pData) {
+ if (eFrameworkunifiedStatusOK != NPSynchronousGetPersistentData(pAppName, notif_name, pData, uiDataSize, l_tNorPersistentData,
+ ePersistCategory)) {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSynchronousGetPersistentData
+/// Get the notification data from the persistent storage
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousGetPersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ UI_32 uiDataSize,
+ NC_NorPersistentData &ptImmediatePersistentData, // NOLINT (readability/nolint)
+ const EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != notif_name && NULL != pData && 0 < uiDataSize) {
+ FILE *l_fFilePtr = NULL;
+
+ if (0 == sem_init(&g_FileAccessSemaphore, 1, 1)) { // LCOV_EXCL_BR_LINE 5: sem_init's error case
+ if (sem_wait(&g_FileAccessSemaphore) == 0) { // LCOV_EXCL_BR_LINE 5: sem_wait's error case
+ // Create unique filename
+ std::string l_cTempPath = notif_name;
+ size_t l_uiTempPathSize = 0;
+
+ std::string l_cPath = "";
+ std::string l_cNewPath = IMMEDIATE_PERSISTENCE_STORAGE_V2;
+ std::string l_cOldPath = IMMEDIATE_PERSISTENCE_STORAGE_V1;
+
+ // replace all '/' by '_'
+ l_uiTempPathSize = l_cTempPath.find_first_of("/");
+ while (std::string::npos != l_uiTempPathSize) {
+ l_cTempPath[l_uiTempPathSize] = '_';
+ l_uiTempPathSize = l_cTempPath.find_first_of("/", l_uiTempPathSize + 1);
+ }
+
+ switch (ePersistCategory) {
+ case eFrameworkunifiedFactoryData: {
+ l_cNewPath.append(FACTORYDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedFactoryCustomerData: {
+ l_cNewPath.append(FACTORYCUSTOMERDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedDealerData: {
+ l_cNewPath.append(DEALERDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedUserData:
+ default: {
+ l_cNewPath.append(USERDATADIR);
+ l_cNewPath.append(ALLUSERAPPDATADIR);
+ }
+ break;
+ }
+
+ l_cNewPath.append(IMMEDIATEDATADIR);
+ l_cNewPath.append(l_cTempPath);
+
+ if (NULL != pAppName) { // LCOV_EXCL_BR_LINE 6: pAppName was checed in NPSynchronousReadPersistentData
+ l_cNewPath.append(pAppName);
+ }
+
+ if (0 == access(l_cNewPath.c_str(), F_OK)) {
+ l_cPath.assign(l_cNewPath);
+ } else {
+ l_cOldPath.append(l_cTempPath);
+ if (NULL != pAppName) { // LCOV_EXCL_BR_LINE 6: pAppName was checed in NPSynchronousReadPersistentData
+ l_cOldPath.append(pAppName);
+ }
+
+ if (0 == access(l_cOldPath.c_str(), F_OK)) {
+ l_cPath.assign(l_cOldPath);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == eFrameworkunifiedStatus) {
+ size_t PersistData;
+ // Open and read from a file
+ l_fFilePtr = fopen(l_cPath.c_str(), "re");
+ if (NULL != l_fFilePtr) {
+ // read notification info structure
+ if (fread(&ptImmediatePersistentData, 1, sizeof(ptImmediatePersistentData),
+ l_fFilePtr) == sizeof(ptImmediatePersistentData)) {
+ if (0 == feof(l_fFilePtr)) {
+ // read data
+ PersistData = fread(pData, 1, uiDataSize, l_fFilePtr);
+ if (PersistData != uiDataSize) {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ fclose(l_fFilePtr);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ sem_post(&g_FileAccessSemaphore);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusErrOther;
+ }
+ sem_destroy(&g_FileAccessSemaphore);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSynchronousWritePersistentData
+/// Store the notification data on the persistent memory
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousWritePersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ const UI_32 uiDataSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ HANDLE l_hReceiverMq = NULL;
+
+ // if this API is used to write the data directly then max data size will be same as data write size
+ l_eStatus = SynchronousWritePersistentData(pAppName, notif_name, pData, uiDataSize, 0, uiDataSize, ePersistCategory);
+
+ l_hReceiverMq = McOpenSender(FRAMEWORKUNIFIED_NS_NPSERVICE);
+
+ if (NULL != l_hReceiverMq) {
+ (VOID)McSendWithSysInfo(l_hReceiverMq,
+ pAppName,
+ NPS_SYNCHRONOUS_WRITE_NOTIFY_REQ,
+ (PCHAR)notif_name,
+ uiDataSize,
+ pData,
+ 0);
+
+ McClose(l_hReceiverMq);
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SynchronousWritePersistentData
+/// Store the notification data on the persistent memory
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SynchronousWritePersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ const UI_32 uiDataSize,
+ const UI_32 uiDelay,
+ const UI_32 uiMaxSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ FILE *l_fFilePtr = NULL;
+ NC_NorPersistentData l_tImmediatePersistentData = {};
+
+ if (NULL != notif_name && NULL != pAppName && NULL != pData) {
+ if (strlen(notif_name) < MAX_STRING_SIZE_NOTIFICATION && strlen(pAppName) < MAX_NAME_SIZE_APP) {
+ // Create unique filename
+ std::string l_cTempPath = notif_name;
+ size_t l_uiTempPathSize = 0;
+
+ // replace all '/' by '_'
+ l_uiTempPathSize = l_cTempPath.find_first_of("/");
+ while (std::string::npos != l_uiTempPathSize) {
+ l_cTempPath[l_uiTempPathSize] = '_';
+ l_uiTempPathSize = l_cTempPath.find_first_of("/", l_uiTempPathSize + 1);
+ }
+
+ strncpy(l_tImmediatePersistentData.notificationName, notif_name,
+ sizeof(l_tImmediatePersistentData.notificationName) - 1);
+ strncpy(l_tImmediatePersistentData.pPublisherName, pAppName,
+ sizeof(l_tImmediatePersistentData.pPublisherName) - 1);
+ l_tImmediatePersistentData.dataSize = uiDataSize;
+ l_tImmediatePersistentData.uiDelay = uiDelay;
+ l_tImmediatePersistentData.uiMaxSize = uiMaxSize;
+
+ if (0 == sem_init(&g_FileAccessSemaphore, 1, 1)) { // LCOV_EXCL_BR_LINE 5: sem_init's error case
+ if (sem_wait(&g_FileAccessSemaphore) == 0) { // LCOV_EXCL_BR_LINE 5: sem_wait's error case
+ std::string l_cPath = IMMEDIATE_PERSISTENCE_STORAGE_V2;
+
+ switch (ePersistCategory) {
+ case eFrameworkunifiedFactoryData: {
+ l_cPath.append(FACTORYDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedFactoryCustomerData: {
+ l_cPath.append(FACTORYCUSTOMERDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedDealerData: {
+ l_cPath.append(DEALERDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedUserData:
+ default: {
+ l_cPath.append(USERDATADIR);
+ l_cPath.append(ALLUSERAPPDATADIR);
+ }
+ break;
+ }
+
+ l_cPath.append(IMMEDIATEDATADIR);
+
+ if (!DoesDirecotryExist(l_cPath)) {
+ eFrameworkunifiedStatus = CreateDirectory(l_cPath);
+ }
+
+ if (eFrameworkunifiedStatusOK == eFrameworkunifiedStatus) {
+ l_cPath.append(l_cTempPath);
+
+ l_cPath.append(pAppName);
+
+ l_fFilePtr = fopen(l_cPath.c_str(), "we");
+ if (NULL != l_fFilePtr) {
+ // write header
+ fwrite(&l_tImmediatePersistentData , 1 , sizeof(l_tImmediatePersistentData) , l_fFilePtr);
+ if (0 == ferror(l_fFilePtr)) {
+ // write data
+ fwrite(pData , 1 , uiDataSize , l_fFilePtr);
+ if (0 != ferror(l_fFilePtr)) {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ fsync(fileno(l_fFilePtr));
+ fclose(l_fFilePtr);
+ }
+ }
+
+ sem_post(&g_FileAccessSemaphore);
+ }
+ sem_destroy(&g_FileAccessSemaphore);
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ return eFrameworkunifiedStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSynchronousGetPersistentDataSize
+/// Get the size of the notification data stored in the persistent memory
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousGetPersistentDataSize(PCSTR notif_name, PUI_32 uiDataSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != notif_name && NULL != uiDataSize) {
+ FILE *l_fFilePtr = NULL;
+ NC_NorPersistentData l_ptImmediatePersistentData = {};
+
+ *uiDataSize = 0;
+
+ if (0 == sem_init(&g_FileAccessSemaphore, 1, 1)) { // LCOV_EXCL_BR_LINE 5: sem_init's error case
+ if (sem_wait(&g_FileAccessSemaphore) == 0) { // LCOV_EXCL_BR_LINE 5: sem_wait's error case
+ // Create unique filename
+ std::string l_cTempPath = notif_name;
+ size_t l_uiTempPathSize = 0;
+
+ std::string l_cPath = "";
+ std::string l_cNewPath = IMMEDIATE_PERSISTENCE_STORAGE_V2;
+ std::string l_cOldPath = IMMEDIATE_PERSISTENCE_STORAGE_V1;
+
+ // replace all '/' by '_'
+ l_uiTempPathSize = l_cTempPath.find_first_of("/");
+ while (std::string::npos != l_uiTempPathSize) {
+ l_cTempPath[l_uiTempPathSize] = '_';
+ l_uiTempPathSize = l_cTempPath.find_first_of("/", l_uiTempPathSize + 1);
+ }
+
+ switch (ePersistCategory) {
+ case eFrameworkunifiedFactoryData: {
+ l_cNewPath.append(FACTORYDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedFactoryCustomerData: {
+ l_cNewPath.append(FACTORYCUSTOMERDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedDealerData: {
+ l_cNewPath.append(DEALERDATADIR);
+ }
+ break;
+
+ case eFrameworkunifiedUserData:
+ default: {
+ l_cNewPath.append(USERDATADIR);
+ l_cNewPath.append(ALLUSERAPPDATADIR);
+ }
+ break;
+ }
+
+ l_cNewPath.append(IMMEDIATEDATADIR);
+ l_cNewPath.append(l_cTempPath);
+
+ if (0 == access(l_cNewPath.c_str(), F_OK)) {
+ l_cPath.assign(l_cNewPath);
+ } else {
+ l_cOldPath.append(l_cTempPath);
+
+ if (0 == access(l_cOldPath.c_str(), F_OK)) {
+ l_cPath.assign(l_cOldPath);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ size_t PersistData;
+ // Open and read from a file
+ l_fFilePtr = fopen(l_cPath.c_str(), "re");
+ if (NULL != l_fFilePtr) {
+ // read notification info structure
+ PersistData = fread(&l_ptImmediatePersistentData, 1, sizeof(l_ptImmediatePersistentData), l_fFilePtr);
+ if (PersistData == sizeof(l_ptImmediatePersistentData)) {
+ *uiDataSize = l_ptImmediatePersistentData.dataSize;
+ } else {
+ *uiDataSize = static_cast<UI_32>(PersistData);
+ }
+ fclose(l_fFilePtr);
+ }
+ }
+
+ sem_post(&g_FileAccessSemaphore);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ }
+
+ sem_destroy(&g_FileAccessSemaphore);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SynchronousMovePersistentData
+/// API to move all the immediate notification data from f_cSrcDir directory to
+/// f_cDestDir directory
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SynchronousMovePersistentData(PCSTR f_cSrcDir,
+ PCSTR f_cDestDir) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != f_cSrcDir && NULL != f_cDestDir) {
+ if (0 == sem_init(&g_FileAccessSemaphore, 1, 1)) {
+ if (sem_wait(&g_FileAccessSemaphore) == 0) { // LCOV_EXCL_BR_LINE 5: sem_init's error case
+ if (DoesDirecotryExist(f_cSrcDir)) { // LCOV_EXCL_BR_LINE 5: sem_wait's error case
+ if (!DoesDirecotryExist(f_cDestDir)) {
+ l_eStatus = CreateDirectory(f_cDestDir);
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ DIR *l_pDir = NULL;
+ struct dirent *l_pdirent = NULL;
+
+ std::string l_cSrcPath = "";
+ std::string l_cDestPath = "";
+
+ if (NULL != (l_pDir = opendir(f_cSrcDir))) {
+ while (NULL != (l_pdirent = readdir(l_pDir))) {
+ if (0 != std::strcmp(l_pdirent->d_name, ".") &&
+ 0 != std::strcmp(l_pdirent->d_name, "..")) {
+ l_cSrcPath.assign(f_cSrcDir);
+ l_cSrcPath.append(l_pdirent->d_name);
+
+ l_cDestPath.assign(f_cDestDir);
+ l_cDestPath.append(l_pdirent->d_name);
+
+ // move the old app user data to the UserData fodler
+ if (0 != rename(l_cSrcPath.c_str(), l_cDestPath.c_str())) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ closedir(l_pDir);
+
+ sync();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ }
+ }
+
+ sem_post(&g_FileAccessSemaphore);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ sem_destroy(&g_FileAccessSemaphore);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_ResourceControler/src/ns_resource_controler.cpp b/nsframework/framework_unified/client/NS_ResourceControler/src/ns_resource_controler.cpp
new file mode 100644
index 00000000..5122e39d
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_ResourceControler/src/ns_resource_controler.cpp
@@ -0,0 +1,168 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <pthread.h>
+
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_resource_controler.h>
+
+#include <map>
+#include <string>
+#include <utility>
+
+struct frameworkunifiedResource {
+ int ref_counter;
+ long resource; // NOLINT (readability/nolint)
+};
+
+typedef std::map<std::string, frameworkunifiedResource> frameworkunifiedResourceTable_t;
+typedef std::map<long, std::string> frameworkunifiedResourceTableR_t; // NOLINT (readability/nolint)
+
+struct frameworkunifiedResourceTable {
+ frameworkunifiedResourceTable_t resTable;
+ frameworkunifiedResourceTableR_t resTableR;
+};
+
+typedef std::map<std::string, frameworkunifiedResourceTable> frameworkunifiedResourceModuleTable_t;
+
+static __thread frameworkunifiedResourceModuleTable_t *frameworkunifiedResourceModuleTable;
+
+static frameworkunifiedResource *frameworkunifiedSearchResourse(const char *mod, const char *key) {
+ if (frameworkunifiedResourceModuleTable == NULL) {
+ frameworkunifiedResourceModuleTable = new frameworkunifiedResourceModuleTable_t;
+ /*
+ * @todo
+ * There is no release processing for "new frameworkunifiedResourceModuleTable_t" created under McOpenMonitor() (Valgrind pointed).
+ */
+ }
+ frameworkunifiedResourceModuleTable_t::iterator mod_it = frameworkunifiedResourceModuleTable->find(mod);
+ if (mod_it == frameworkunifiedResourceModuleTable->end()) {
+ return NULL;
+ }
+
+ frameworkunifiedResourceTable_t::iterator res_it = mod_it->second.resTable.find(key);
+ if (res_it == mod_it->second.resTable.end()) {
+ return NULL;
+ }
+
+ return &res_it->second;
+}
+
+int frameworkunifiedGetResource(const char *mod, const char *key, long *resource) { // NOLINT (readability/nolint)
+ frameworkunifiedResource *r = frameworkunifiedSearchResourse(mod, key);
+ if (r == NULL) {
+ return -1;
+ }
+ if (resource == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "resource is NULL");
+ return -1;
+ }
+ *resource = r->resource;
+ return 0;
+}
+
+int frameworkunifiedAcquireResouce(const char *mod, const char *key, long *resource) { // NOLINT (readability/nolint)
+ frameworkunifiedResource *r = frameworkunifiedSearchResourse(mod, key);
+ if (r == NULL) {
+ return -1;
+ }
+ *resource = r->resource;
+ return ++(r->ref_counter);
+}
+
+int frameworkunifiedReleaseResouce(const char *mod, const char *key) {
+ frameworkunifiedResource *r = frameworkunifiedSearchResourse(mod, key);
+ if (r == NULL) {
+ return -1;
+ }
+ return --(r->ref_counter);
+}
+
+int frameworkunifiedSearchResourseKey(const char *mod, long resource, const char **key) { // NOLINT (readability/nolint)
+ if (frameworkunifiedResourceModuleTable == NULL) {
+ frameworkunifiedResourceModuleTable = new frameworkunifiedResourceModuleTable_t;
+ }
+ frameworkunifiedResourceModuleTable_t::iterator mod_it = frameworkunifiedResourceModuleTable->find(mod);
+ if (mod_it == frameworkunifiedResourceModuleTable->end()) {
+ return -1;
+ }
+
+ frameworkunifiedResourceTableR_t::iterator resR_it = mod_it->second.resTableR.find(resource);
+ if (resR_it == mod_it->second.resTableR.end()) {
+ return -1;
+ }
+
+ *key = (resR_it->second).c_str();
+ return 0;
+}
+
+int frameworkunifiedRegistResouce(const char *mod, const char *key, long resource, // NOLINT (readability/nolint)
+ int init_counter) {
+ int ret = 0;
+
+ if (frameworkunifiedResourceModuleTable == NULL) {
+ frameworkunifiedResourceModuleTable = new frameworkunifiedResourceModuleTable_t;
+ }
+ frameworkunifiedResourceModuleTable_t::iterator mod_it = frameworkunifiedResourceModuleTable->find(mod);
+
+ if (mod_it == frameworkunifiedResourceModuleTable->end()) {
+ frameworkunifiedResourceTable mod_res;
+ frameworkunifiedResourceModuleTable->insert(std::make_pair(mod, mod_res)); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ mod_it = frameworkunifiedResourceModuleTable->find(mod); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ if (mod_it->second.resTable.find(key) == mod_it->second.resTable.end()) {
+ frameworkunifiedResource regist_res;
+ regist_res.ref_counter = init_counter;
+ regist_res.resource = resource;
+ mod_it->second.resTable.insert(std::make_pair(key, regist_res));
+ mod_it->second.resTableR.insert(std::make_pair(resource, key));
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Key(%s) already regist", key != 0 ? key : NULL);
+ // LCOV_EXCL_BR_STOP
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int frameworkunifiedUnregistResouce(const char *mod, const char *key) {
+ if (frameworkunifiedResourceModuleTable == NULL) {
+ frameworkunifiedResourceModuleTable = new frameworkunifiedResourceModuleTable_t;
+ }
+ frameworkunifiedResourceModuleTable_t::iterator mod_it = frameworkunifiedResourceModuleTable->find(mod);
+
+ if (mod_it == frameworkunifiedResourceModuleTable->end()) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Mod(%s) undefined", mod != 0 ? mod : NULL);
+ // LCOV_EXCL_BR_STOP
+ } else {
+ frameworkunifiedResourceTable_t::iterator res_it = mod_it->second.resTable.find(key);
+ if (res_it != mod_it->second.resTable.end()) {
+ long resource = res_it->second.resource; // NOLINT (readability/nolint)
+ mod_it->second.resTable.erase(key);
+
+ if (mod_it->second.resTableR.find(resource) != mod_it->second.resTableR.end()) {
+ mod_it->second.resTableR.erase(resource);
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __func__, "Key(%s) no regist", key != 0 ? key : NULL);
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ return 0;
+}
diff --git a/nsframework/framework_unified/client/NS_RingBuffer/src/ns_ringbuffer.cpp b/nsframework/framework_unified/client/NS_RingBuffer/src/ns_ringbuffer.cpp
new file mode 100644
index 00000000..1fbc5b57
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_RingBuffer/src/ns_ringbuffer.cpp
@@ -0,0 +1,1029 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSRingBuffer
+/// \brief This file contains implementation of class CNSRingBuffer.
+/// This class provides API to open, read, write and close ring buffer
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/cl_lock.h>
+
+#include <string>
+
+#define RBUF_HEADER_EXT "Hdr"
+#define RBUF_RETRY_SLEEP (1000)
+#define RBUF_RETRY_COUNT (8)
+#define RBUF_PAGE_SIZE (4096)
+#define RBUF_PAGE_ALIGN(p) ((p / RBUF_PAGE_SIZE) * RBUF_PAGE_SIZE)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSRingBuffer
+/// Parameterized Constructor of CNSRingBuffer class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSRingBuffer::CNSRingBuffer(const std::string &f_cMappedFilePath, const UI_32 f_uiSize, int f_lid):
+ m_cMappedFilePath(f_cMappedFilePath), m_uiRingBuffSize(f_uiSize), m_pRbufMtx(NULL), m_pRbufHdr(NULL), m_pRbuf(NULL),
+ m_lid(f_lid), m_pLockAddr(NULL), m_siProcessLastWrtPage(-1) { // LCOV_EXCL_BR_LINE 11: except branch
+ m_cMappedFileHdrPath = f_cMappedFilePath;
+ m_cMappedFileHdrPath.append(RBUF_HEADER_EXT); // LCOV_EXCL_BR_LINE 11: except branch
+
+ m_cRbufMtxName = f_cMappedFilePath;
+ std::size_t found = m_cRbufMtxName.find_first_of('/');
+ while (found != std::string::npos) {
+ m_cRbufMtxName[found] = '_';
+ found = m_cRbufMtxName.find_first_of('/', found + 1);
+ }
+ m_cRbufMtxName[0] = '/';
+ pthread_mutex_init(&m_tOpenMutex, NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSRingBuffer
+/// Constructor of CNSRingBuffer class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSRingBuffer::CNSRingBuffer():
+ m_cMappedFilePath(""), m_uiRingBuffSize(0), m_pRbufMtx(NULL), m_pRbufHdr(NULL), m_pRbuf(NULL), m_lid(-1),
+ m_pLockAddr(NULL), m_siProcessLastWrtPage(-1) {
+ pthread_mutex_init(&m_tOpenMutex, NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNSRingBuffer
+/// Destructor of CNSRingBuffer class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSRingBuffer::~CNSRingBuffer() {
+ if (NULL != m_pRbufHdr) {
+ // un-map the ring buffer object
+ Close();
+
+ m_pRbufHdr = NULL;
+ m_pRbufMtx = NULL;
+ }
+ pthread_mutex_destroy(&m_tOpenMutex);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Open
+/// This function opens and maps the ring buffer object.
+/// It creates the ring buffer if it does not exists.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::Open() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusErrOther;
+
+ pthread_mutex_lock(&m_tOpenMutex);
+
+ if (NULL == m_pRbufMtx) {
+ // Open ring buffer mutex
+ if (eFrameworkunifiedStatusOK != (l_eStatus = MapSM(reinterpret_cast<PVOID *>(&m_pRbufMtx),
+ m_cRbufMtxName, sizeof(NSRingBufferMtx)))) {
+ if (ENOENT == errno) {
+ errno = EOK;
+
+
+// if (eFrameworkunifiedStatusOK == CreateRBMutex()) {
+ EFrameworkunifiedStatus l_eStatus1 = CreateRBMutex();
+ if ((l_eStatus1 == eFrameworkunifiedStatusOK) || (l_eStatus1 == eFrameworkunifiedStatusDuplicate)) {
+
+ l_eStatus = MapSM(reinterpret_cast<PVOID *>(&m_pRbufMtx), m_cRbufMtxName, sizeof(NSRingBufferMtx));
+ }
+ }
+ } else {
+ if (m_pRbufMtx->m_lid != m_lid) {
+ // Different Lock ID in constructor parameter and mutex object
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (m_lid >= 0 && NULL == m_pLockAddr) {
+ CL_LockProcessInit();
+ if ((m_pLockAddr = CL_LockMap(m_lid)) == MAP_FAILED) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (NULL == m_pRbufHdr) {
+ // Open header ring buffer
+ if (eFrameworkunifiedStatusOK != (l_eStatus = Map(reinterpret_cast<PVOID *>(&m_pRbufHdr),
+ m_cMappedFileHdrPath, sizeof(NSRingBufferHdr)))) {
+ if (ENOENT == errno) { // ring buffer is not created yet
+ errno = EOK;
+
+ // Create ring buffer
+
+// if (eFrameworkunifiedStatusOK == CreateRBHeader()) {
+ EFrameworkunifiedStatus l_eStatus1 = CreateRBHeader();
+ if ((l_eStatus1 == eFrameworkunifiedStatusOK) || (l_eStatus1 == eFrameworkunifiedStatusDuplicate)) {
+
+ // Retry to open
+ l_eStatus = Map(reinterpret_cast<PVOID *>(&m_pRbufHdr),
+ m_cMappedFileHdrPath, sizeof(NSRingBufferHdr));
+
+// }
+ } else {
+ l_eStatus = l_eStatus1;
+ }
+
+ }
+ } else {
+
+#if 0
+ LockMtx();
+
+ struct stat st;
+ int ret = stat(m_cMappedFilePath.c_str(), &st);
+
+ if (m_uiRingBuffSize == 0) {
+ if (ret == 0) { // LCOV_EXCL_BR_LINE 5:stat's error case.
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if ((UI_32)st.st_size != m_pRbufHdr->m_uiRingBufferSize || (UI_32)st.st_size < m_pRbufHdr->m_uiReadPtr
+ || (UI_32)st.st_size < m_pRbufHdr->m_uiWritePtr) {
+ memset(m_pRbufHdr, 0, sizeof(NSRingBufferHdr));
+ m_pRbufHdr->m_uiRingBufferSize = static_cast<UI_32>(st.st_size);
+ unlink(m_cMappedFilePath.c_str());
+ }
+ m_uiRingBuffSize = static_cast<UI_32>(st.st_size);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ if (m_uiRingBuffSize != m_pRbufHdr->m_uiRingBufferSize || m_uiRingBuffSize < m_pRbufHdr->m_uiReadPtr
+ || m_uiRingBuffSize < m_pRbufHdr->m_uiWritePtr || (ret == 0 && m_uiRingBuffSize != (UI_32)st.st_size)) {
+ memset(m_pRbufHdr, 0, sizeof(NSRingBufferHdr));
+ m_pRbufHdr->m_uiRingBufferSize = m_uiRingBuffSize;
+ unlink(m_cMappedFilePath.c_str());
+ }
+ }
+
+ UnlockMtx();
+#endif
+ int ret;
+ if ( (ret = LockMtx()) == 0) {
+ struct stat st;
+ int ret = stat(m_cMappedFilePath.c_str(), &st);
+
+ if (m_uiRingBuffSize == 0) {
+ if (ret == 0) {
+ if ((UI_32)st.st_size != m_pRbufHdr->m_uiRingBufferSize || (UI_32)st.st_size < m_pRbufHdr->m_uiReadPtr ||
+ (UI_32)st.st_size < m_pRbufHdr->m_uiWritePtr) {
+ memset(m_pRbufHdr, 0, sizeof(NSRingBufferHdr));
+ m_pRbufHdr->m_uiRingBufferSize = static_cast<UI_32>(st.st_size);
+ unlink(m_cMappedFilePath.c_str());
+ }
+ m_uiRingBuffSize = static_cast<UI_32>(st.st_size);
+ }
+ } else {
+ if (m_uiRingBuffSize != m_pRbufHdr->m_uiRingBufferSize || m_uiRingBuffSize < m_pRbufHdr->m_uiReadPtr ||
+ m_uiRingBuffSize < m_pRbufHdr->m_uiWritePtr || (ret == 0 && m_uiRingBuffSize != (UI_32)st.st_size)) {
+ memset(m_pRbufHdr, 0, sizeof(NSRingBufferHdr));
+ m_pRbufHdr->m_uiRingBufferSize = m_uiRingBuffSize;
+ unlink(m_cMappedFilePath.c_str());
+ }
+ }
+
+ UnlockMtx();
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ munmap(m_pRbufHdr, sizeof(NSRingBufferHdr));
+ m_pRbufHdr = NULL;
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus && 0 != m_uiRingBuffSize) {
+ if (NULL == m_pRbuf) {
+ // Open ring buffer data buffer, create if not exists
+ if (eFrameworkunifiedStatusOK != (l_eStatus = Map(reinterpret_cast<PVOID *>(&m_pRbuf),
+ m_cMappedFilePath, m_uiRingBuffSize))) {
+ if (ENOENT == errno) { // ring buffer is not created yet
+ // Create ring buffer
+
+// if (eFrameworkunifiedStatusOK == CreateRBDataBuffer()) {
+ EFrameworkunifiedStatus l_eStatus1 = CreateRBDataBuffer();
+ if ((l_eStatus1 == eFrameworkunifiedStatusOK) || (l_eStatus1 == eFrameworkunifiedStatusDuplicate)) {
+
+ // Retry to open
+ l_eStatus = Map(reinterpret_cast<PVOID *>(&m_pRbuf),
+ m_cMappedFilePath, m_uiRingBuffSize);
+ }
+ }
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&m_tOpenMutex);
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsOpen
+/// This function is used to check whether the ring buffer is opened or not.
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CNSRingBuffer::IsOpen() {
+ return NULL == m_pRbufHdr ? FALSE : TRUE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Close
+/// This function closes the ring buffer object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::Close() {
+ if (NULL != m_pLockAddr) {
+ CL_LockUnmap(m_pLockAddr);
+ }
+
+ EFrameworkunifiedStatus l_eStatus1 = UnMap(m_pRbufHdr, sizeof(NSRingBufferHdr));
+ m_pRbufHdr = NULL;
+
+ EFrameworkunifiedStatus l_eStatus2 = eFrameworkunifiedStatusOK;
+ if (0 != m_uiRingBuffSize) {
+ l_eStatus2 = UnMap(m_pRbuf, m_uiRingBuffSize);
+ m_pRbuf = NULL;
+ }
+
+ EFrameworkunifiedStatus l_eStatus3 = UnMap(m_pRbufMtx, sizeof(NSRingBufferMtx));
+ m_pRbufMtx = NULL;
+
+ return (eFrameworkunifiedStatusOK != l_eStatus1 || eFrameworkunifiedStatusOK != l_eStatus2 ||
+ eFrameworkunifiedStatusOK != l_eStatus3) ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Read
+/// This function reads data from the ring buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSRingBuffer::Read(PSTR f_pBuffer, const UI_32 f_uilength) {
+ SI_32 l_iReadSize = -1;
+
+ if ((NULL != f_pBuffer) && (NULL != m_pRbufHdr) && (0 != f_uilength)) {
+ UI_32 l_uiDataSizeToRead = 0;
+
+ // Remaining buffer size from read pointer to end of the buffer
+ UI_32 l_uiRemainSize = 0;
+
+
+#if 0
+ LockMtx();
+
+ // if ring buffer size is changed by some other process, remap the updated buffer size in this process
+ // ring buffer size can only be changed if the initial size is 0.
+ if (m_uiRingBuffSize != m_pRbufHdr->m_uiRingBufferSize) {
+ if (eFrameworkunifiedStatusOK == Map(reinterpret_cast<PVOID *>(&m_pRbuf),
+ m_cMappedFilePath, m_pRbufHdr->m_uiRingBufferSize)) {
+ m_uiRingBuffSize = m_pRbufHdr->m_uiRingBufferSize;
+ }
+ }
+
+ if (NULL != m_pRbuf) {
+ l_uiRemainSize = m_uiRingBuffSize - m_pRbufHdr->m_uiReadPtr;
+
+ // Round read data size depending on un-read data size in the buffer
+ l_uiDataSizeToRead = m_pRbufHdr->m_uiUnReadSize < f_uilength ? m_pRbufHdr->m_uiUnReadSize : f_uilength;
+
+ if (l_uiRemainSize < l_uiDataSizeToRead) {
+ // Wrapping read
+ memcpy(f_pBuffer, m_pRbuf + m_pRbufHdr->m_uiReadPtr, l_uiRemainSize);
+ memcpy(f_pBuffer + l_uiRemainSize, m_pRbuf, l_uiDataSizeToRead - l_uiRemainSize);
+ m_pRbufHdr->m_uiReadPtr = l_uiDataSizeToRead - l_uiRemainSize;
+ } else {
+ memcpy(f_pBuffer, m_pRbuf + m_pRbufHdr->m_uiReadPtr, l_uiDataSizeToRead);
+
+ m_pRbufHdr->m_uiReadPtr += l_uiDataSizeToRead;
+
+ // Read pointer is the end of the buffer
+ if (m_pRbufHdr->m_uiReadPtr == m_uiRingBuffSize) {
+ m_pRbufHdr->m_uiReadPtr = 0;
+ }
+ }
+
+ m_pRbufHdr->m_uiUnReadSize -= l_uiDataSizeToRead; // Update un-read data size
+
+ l_iReadSize = l_uiDataSizeToRead;
+ }
+
+ UnlockMtx();
+#endif
+ int ret;
+ if ( (ret = LockMtx()) == 0) {
+ // if ring buffer size is changed by some other process, remap the updated buffer size in this process
+ // ring buffer size can only be changed if the initial size is 0.
+ if (m_uiRingBuffSize != m_pRbufHdr->m_uiRingBufferSize) {
+ if (eFrameworkunifiedStatusOK == Map(reinterpret_cast<PVOID *>(&m_pRbuf),
+ m_cMappedFilePath, m_pRbufHdr->m_uiRingBufferSize)) {
+ m_uiRingBuffSize = m_pRbufHdr->m_uiRingBufferSize;
+ }
+ }
+
+ if (NULL != m_pRbuf) {
+ l_uiRemainSize = m_uiRingBuffSize - m_pRbufHdr->m_uiReadPtr;
+
+ // Round read data size depending on un-read data size in the buffer
+ l_uiDataSizeToRead = m_pRbufHdr->m_uiUnReadSize < f_uilength ? m_pRbufHdr->m_uiUnReadSize : f_uilength;
+
+ if (l_uiRemainSize < l_uiDataSizeToRead) {
+ // Wrapping read
+ memcpy(f_pBuffer, m_pRbuf + m_pRbufHdr->m_uiReadPtr, l_uiRemainSize);
+ memcpy(f_pBuffer + l_uiRemainSize, m_pRbuf, l_uiDataSizeToRead - l_uiRemainSize);
+ m_pRbufHdr->m_uiReadPtr = l_uiDataSizeToRead - l_uiRemainSize;
+ } else {
+ memcpy(f_pBuffer, m_pRbuf + m_pRbufHdr->m_uiReadPtr, l_uiDataSizeToRead);
+
+ m_pRbufHdr->m_uiReadPtr += l_uiDataSizeToRead;
+
+ // Read pointer is the end of the buffer
+ if (m_pRbufHdr->m_uiReadPtr == m_uiRingBuffSize) {
+ m_pRbufHdr->m_uiReadPtr = 0;
+ }
+ }
+
+ m_pRbufHdr->m_uiUnReadSize -= l_uiDataSizeToRead; // Update un-read data size
+
+ l_iReadSize = l_uiDataSizeToRead;
+ }
+
+ UnlockMtx();
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ l_iReadSize = 0;
+ }
+
+ }
+
+ return l_iReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Write
+/// This function writes the data into the ring buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSRingBuffer::Write(PCSTR f_pBuffer, const UI_32 f_uilength) {
+ SI_32 l_iWriteSize = -1;
+
+ // size available in buffer
+ UI_32 l_uiRemainSize = 0;
+
+ if (NULL != m_pRbufHdr && NULL != m_pRbuf && NULL != f_pBuffer && f_uilength <= m_uiRingBuffSize) { // LCOV_EXCL_BR_LINE 11:except branch
+#if 0
+ LockMtx();
+
+ UI_32 l_uiLastPage = RBUF_PAGE_ALIGN(m_pRbufHdr->m_uiWritePtr);
+ l_uiRemainSize = m_uiRingBuffSize - m_pRbufHdr->m_uiWritePtr;
+
+ if (m_siProcessLastWrtPage >= 0) {
+ if ((UI_32)m_siProcessLastWrtPage != l_uiLastPage) {
+ if (madvise(m_pRbuf + m_siProcessLastWrtPage, RBUF_PAGE_SIZE, MADV_DONTNEED) < 0) {
+ fprintf(stderr, "[CNSRingBuffer::Write] madvise(%p) error: %s\n",
+ m_pRbuf + m_siProcessLastWrtPage, strerror(errno));
+ }
+ }
+ }
+
+ // Write data to the buffer
+ if (l_uiRemainSize < f_uilength) {
+ // Wrapping write
+ memcpy(m_pRbuf + m_pRbufHdr->m_uiWritePtr, f_pBuffer, l_uiRemainSize);
+ memcpy(m_pRbuf, f_pBuffer + l_uiRemainSize, f_uilength - l_uiRemainSize);
+
+ // Update the write pointer
+ m_pRbufHdr->m_uiWritePtr = f_uilength - l_uiRemainSize;
+
+ // The buffer is full of valid data
+ m_pRbufHdr->m_bIsFull = TRUE;
+ } else {
+ memcpy(m_pRbuf + m_pRbufHdr->m_uiWritePtr, f_pBuffer, f_uilength);
+
+ // Update the write pointer
+ m_pRbufHdr->m_uiWritePtr += f_uilength;
+
+ // Write pointer is the end of the buffer
+ if (m_pRbufHdr->m_uiWritePtr == m_uiRingBuffSize) {
+ m_pRbufHdr->m_uiWritePtr = 0;
+
+ // The buffer is full of valid data
+ m_pRbufHdr->m_bIsFull = TRUE;
+ }
+ }
+
+ // Update un-read data size
+ m_pRbufHdr->m_uiUnReadSize += f_uilength;
+
+ // Set read pointer to be same as write pointer if write pointer exceeds the read pointer
+ if (m_uiRingBuffSize < m_pRbufHdr->m_uiUnReadSize) {
+ m_pRbufHdr->m_uiReadPtr = m_pRbufHdr->m_uiWritePtr;
+ m_pRbufHdr->m_uiUnReadSize = m_uiRingBuffSize;
+ }
+
+ while (l_uiLastPage != RBUF_PAGE_ALIGN(m_pRbufHdr->m_uiWritePtr)) {
+ if (madvise(m_pRbuf + l_uiLastPage, RBUF_PAGE_SIZE, MADV_DONTNEED) < 0) {
+ fprintf(stderr, "[CNSRingBuffer::Write] madvise(%p) error: %s\n", m_pRbuf + l_uiLastPage, strerror(errno));
+ }
+ l_uiLastPage += RBUF_PAGE_SIZE;
+ if (l_uiLastPage >= m_uiRingBuffSize) {
+ l_uiLastPage = 0;
+ }
+ }
+ m_siProcessLastWrtPage = (SI_32)l_uiLastPage;
+
+ UnlockMtx();
+
+ l_iWriteSize = f_uilength;
+#endif
+ int ret;
+ if ( (ret = LockMtx()) == 0) {
+ UI_32 l_uiLastPage = RBUF_PAGE_ALIGN(m_pRbufHdr->m_uiWritePtr);
+ l_uiRemainSize = m_uiRingBuffSize - m_pRbufHdr->m_uiWritePtr;
+
+ if (m_siProcessLastWrtPage >= 0) {
+ if ((UI_32)m_siProcessLastWrtPage != l_uiLastPage) {
+ if (madvise(m_pRbuf + m_siProcessLastWrtPage, RBUF_PAGE_SIZE, MADV_DONTNEED) < 0) {
+ fprintf(stderr, "[CNSRingBuffer::Write] madvise(%p) error: %s\n",
+ m_pRbuf + m_siProcessLastWrtPage, strerror(errno));
+ }
+ }
+ }
+
+ // Write data to the buffer
+ if (l_uiRemainSize < f_uilength) {
+ // Wrapping write
+ memcpy(m_pRbuf + m_pRbufHdr->m_uiWritePtr, f_pBuffer, l_uiRemainSize);
+ memcpy(m_pRbuf, f_pBuffer + l_uiRemainSize, f_uilength - l_uiRemainSize);
+
+ // Update the write pointer
+ m_pRbufHdr->m_uiWritePtr = f_uilength - l_uiRemainSize;
+
+ // The buffer is full of valid data
+ m_pRbufHdr->m_bIsFull = TRUE;
+ } else {
+ memcpy(m_pRbuf + m_pRbufHdr->m_uiWritePtr, f_pBuffer, f_uilength);
+
+ // Update the write pointer
+ m_pRbufHdr->m_uiWritePtr += f_uilength;
+
+ // Write pointer is the end of the buffer
+ if (m_pRbufHdr->m_uiWritePtr == m_uiRingBuffSize) {
+ m_pRbufHdr->m_uiWritePtr = 0;
+
+ // The buffer is full of valid data
+ m_pRbufHdr->m_bIsFull = TRUE;
+ }
+ }
+
+ // Update un-read data size
+ m_pRbufHdr->m_uiUnReadSize += f_uilength;
+
+ // Set read pointer to be same as write pointer if write pointer exceeds the read pointer
+ if (m_uiRingBuffSize < m_pRbufHdr->m_uiUnReadSize) {
+ m_pRbufHdr->m_uiReadPtr = m_pRbufHdr->m_uiWritePtr;
+ m_pRbufHdr->m_uiUnReadSize = m_uiRingBuffSize;
+ }
+
+ while (l_uiLastPage != RBUF_PAGE_ALIGN(m_pRbufHdr->m_uiWritePtr)) {
+ if (madvise(m_pRbuf + l_uiLastPage, RBUF_PAGE_SIZE, MADV_DONTNEED) < 0) {
+ fprintf(stderr, "[CNSRingBuffer::Write] madvise(%p) error: %s\n",
+ m_pRbuf + l_uiLastPage, strerror(errno));
+ }
+ l_uiLastPage += RBUF_PAGE_SIZE;
+ if (l_uiLastPage >= m_uiRingBuffSize) {
+ l_uiLastPage = 0;
+ }
+ }
+ m_siProcessLastWrtPage = (SI_32)l_uiLastPage;
+
+ UnlockMtx();
+
+ l_iWriteSize = f_uilength;
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ l_iWriteSize = 0;
+ }
+
+ }
+
+ return l_iWriteSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// DumpToFile
+/// This function writes all the data in the buffer into provided file f_pPath.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::DumpToFile(PCSTR f_pPath, PUI_32 f_uiDumpSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ ssize_t l_iSize = 0;
+
+ SI_32 fd = -1;
+
+ if (NULL == f_uiDumpSize) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ *f_uiDumpSize = 0;
+
+ if (NULL != f_pPath) {
+ if (NULL != m_pRbufHdr) {
+ // Open file
+ if (-1 != (fd = open(f_pPath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640))) {
+ if (NULL != m_pRbuf && 0 != m_uiRingBuffSize) {
+
+#if 0
+ LockMtx();
+ // Write buffer data to file
+ if (m_pRbufHdr->m_bIsFull) {
+ // Buffer has full of data (read data from write pointer)
+ if (-1 != (l_iSize = write(fd, m_pRbuf + m_pRbufHdr->m_uiWritePtr,
+ m_uiRingBuffSize - m_pRbufHdr->m_uiWritePtr))) {
+ *f_uiDumpSize += static_cast<UI_32>(l_iSize);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+
+ if (-1 != (l_iSize = write(fd, m_pRbuf, m_pRbufHdr->m_uiWritePtr))) {
+ *f_uiDumpSize += static_cast<UI_32>(l_iSize);
+ }
+
+ UnlockMtx();
+#endif
+ int ret;
+ if ( (ret = LockMtx()) == 0) {
+ // Write buffer data to file
+ if (m_pRbufHdr->m_bIsFull) {
+ // Buffer has full of data (read data from write pointer)
+ if (-1 != (l_iSize = write(fd, m_pRbuf + m_pRbufHdr->m_uiWritePtr,
+ m_uiRingBuffSize - m_pRbufHdr->m_uiWritePtr))) {
+
+// *f_uiDumpSize += l_iSize;
+ *f_uiDumpSize += static_cast<UI_32>(l_iSize);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+
+ if (-1 != (l_iSize = write(fd, m_pRbuf, m_pRbufHdr->m_uiWritePtr))) {
+
+// *f_uiDumpSize += l_iSize;
+ *f_uiDumpSize += static_cast<UI_32>(l_iSize);
+ }
+
+ UnlockMtx();
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ }
+
+ } else if (NULL == m_pRbuf && 0 != m_uiRingBuffSize) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // do nothing
+ }
+
+ // Sync the file to force I/O operation completed
+ fsync(fd);
+
+ close(fd);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetSize
+/// This function returns the number of unread bytes which can be read by Read().
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSRingBuffer::GetSize() {
+ SI_32 l_uiReadSize = -1;
+
+ if (NULL != m_pRbufHdr) {
+ l_uiReadSize = m_pRbufHdr->m_uiUnReadSize;
+ }
+
+ return l_uiReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ClearBuf
+/// This function clears the buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::ClearBuf() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pRbufHdr) {
+
+#if 0
+ LockMtx();
+
+ // Initialize the r/w pointers
+ m_pRbufHdr->m_uiReadPtr = 0;
+ m_pRbufHdr->m_uiWritePtr = 0;
+ m_pRbufHdr->m_uiUnReadSize = 0;
+ m_pRbufHdr->m_bIsFull = FALSE;
+
+ UnlockMtx();
+#endif
+ int ret;
+ if ((ret = LockMtx()) == 0) {
+ // Initialize the r/w pointers
+ m_pRbufHdr->m_uiReadPtr = 0;
+ m_pRbufHdr->m_uiWritePtr = 0;
+ m_pRbufHdr->m_uiUnReadSize = 0;
+ m_pRbufHdr->m_bIsFull = FALSE;
+
+ UnlockMtx();
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ }
+
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetReadPtrToWritePtr
+/// This function sets the position of read ptr to write ptr in buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::SetReadPtrToWritePtr() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pRbufHdr) {
+
+#if 0
+ LockMtx();
+
+ // Initialize the r/w pointers
+ m_pRbufHdr->m_uiReadPtr = m_pRbufHdr->m_uiWritePtr;
+ m_pRbufHdr->m_uiUnReadSize = 0;
+
+ UnlockMtx();
+#endif
+ int ret;
+ if ( (ret = LockMtx()) == 0) {
+ // Initialize the r/w pointers
+ m_pRbufHdr->m_uiReadPtr = m_pRbufHdr->m_uiWritePtr;
+ m_pRbufHdr->m_uiUnReadSize = 0;
+
+ UnlockMtx();
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ }
+
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+//
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateRBMutex
+/// This function creates the shared memory object for mutex.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::CreateRBMutex() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of shared memory
+ SI_32 l_siId = -1;
+
+ // ring buffer mutex
+ NSRingBufferMtx *l_pRbufMtx = NULL;
+
+ if ((!m_cRbufMtxName.empty()) || (m_cRbufMtxName.size() <= NAME_MAX)) {
+ // Try to create shared memory
+ l_siId = shm_open(m_cRbufMtxName.c_str(), O_CREAT | O_EXCL | O_RDWR, 0640);
+
+ if (-1 != l_siId) {
+ // Set the size of shared memory
+ if (-1 != ftruncate(l_siId, sizeof(NSRingBufferMtx))) {
+ // Map the shared memory
+ l_pRbufMtx = reinterpret_cast<NSRingBufferMtx *>(mmap(NULL,
+ sizeof(NSRingBufferMtx), (PROT_READ | PROT_WRITE), MAP_SHARED, l_siId, 0));
+
+ if (MAP_FAILED != l_pRbufMtx) {
+ if (m_lid == -1) {
+ // mutex attribute
+ pthread_mutexattr_t l_tMtxAttr = {};
+
+ // Initialize mutex
+ pthread_mutexattr_init(&l_tMtxAttr);
+ pthread_mutexattr_setpshared(&l_tMtxAttr, PTHREAD_PROCESS_SHARED);
+ pthread_mutex_init(&l_pRbufMtx->m_tBufMutex, &l_tMtxAttr);
+ pthread_mutexattr_destroy(&l_tMtxAttr);
+
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ // CL_Lock
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ l_pRbufMtx->m_lid = m_lid;
+
+ // Once initialized un-map the shared memory
+ munmap(l_pRbufMtx, sizeof(NSRingBufferMtx));
+ }
+ }
+
+ close(l_siId);
+ } else if (EEXIST == errno) {
+ // Shared memory is already created
+ l_eStatus = eFrameworkunifiedStatusDuplicate;
+ } else {
+ // do nothing
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateRBHeader
+/// This function creates the ring buffer object for header.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::CreateRBHeader() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of ring buffer
+ SI_32 l_siFd = -1;
+
+ // ring buffer headers
+ NSRingBufferHdr *l_pRbufHdr = NULL;
+
+ if (!m_cMappedFileHdrPath.empty()) { // LCOV_EXCL_BR_LINE 11: except branch
+ // Try to create ring buffer
+ l_siFd = open(m_cMappedFileHdrPath.c_str(), O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0640);
+
+ if (-1 != l_siFd) {
+ // Set the size of ring buffer
+ if (-1 != ftruncate(l_siFd, sizeof(NSRingBufferHdr))) {
+ // Map the ring buffer
+ l_pRbufHdr = reinterpret_cast<NSRingBufferHdr *>(mmap(NULL,
+ sizeof(NSRingBufferHdr), (PROT_READ | PROT_WRITE), MAP_SHARED, l_siFd, 0));
+
+ if (MAP_FAILED != l_pRbufHdr) {
+
+#if 0
+ LockMtx();
+
+ // Initialize the r/w pointers
+ l_pRbufHdr->m_uiReadPtr = 0;
+ l_pRbufHdr->m_uiWritePtr = 0;
+ l_pRbufHdr->m_uiUnReadSize = 0;
+ l_pRbufHdr->m_bIsFull = FALSE;
+ l_pRbufHdr->m_uiRingBufferSize = m_uiRingBuffSize;
+
+ UnlockMtx();
+#endif
+ int ret;
+ if ( (ret = LockMtx()) == 0) {
+ // Initialize the r/w pointers
+ l_pRbufHdr->m_uiReadPtr = 0;
+ l_pRbufHdr->m_uiWritePtr = 0;
+ l_pRbufHdr->m_uiUnReadSize = 0;
+ l_pRbufHdr->m_bIsFull = FALSE;
+ l_pRbufHdr->m_uiRingBufferSize = m_uiRingBuffSize;
+
+ UnlockMtx();
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ fprintf(stderr, "[%s] LockMtx error: %s\n", __PRETTY_FUNCTION__, strerror(ret));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+
+ // Once initialized un-map the ring buffer
+ munmap(l_pRbufHdr, sizeof(NSRingBufferHdr));
+ }
+ }
+
+ close(l_siFd);
+ } else if (EEXIST == errno) {
+ // ring buffer is already created
+ l_eStatus = eFrameworkunifiedStatusDuplicate;
+ } else {
+ // do nothing
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateRBDataBuffer
+/// This function creates the ring buffer object for data buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::CreateRBDataBuffer() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of ring buffer
+ SI_32 l_siFd = -1;
+
+ if (!m_cMappedFilePath.empty()) {
+ // Try to create ring buffer
+ l_siFd = open(m_cMappedFilePath.c_str(), O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0640);
+
+ if (-1 != l_siFd) {
+ // Set the size of ring buffer
+ if (-1 != ftruncate(l_siFd, m_uiRingBuffSize)) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ close(l_siFd);
+ } else if (EEXIST == errno) {
+ // ring buffer is already created
+ l_eStatus = eFrameworkunifiedStatusDuplicate;
+ } else {
+ // do nothing
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// MapRBHeader
+/// This function open and maps in process space.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::Map(PVOID *f_pRbuf, const std::string &f_cMappedFile, const UI_32 f_uiRbufSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of ring buffer
+ SI_32 l_siFd = -1;
+
+ // ring buffer headers
+ PVOID l_pRbuf = NULL;
+
+ // Open ring buffer
+ l_siFd = open(f_cMappedFile.c_str(), O_RDWR | O_CLOEXEC, NULL);
+
+ if (-1 != l_siFd) {
+ if (CheckSize(l_siFd, f_uiRbufSize) == eFrameworkunifiedStatusOK) {
+ // Map the ring buffer into its memory space
+ l_pRbuf = mmap(NULL, f_uiRbufSize, (PROT_READ | PROT_WRITE), MAP_SHARED, l_siFd, 0);
+
+ if (MAP_FAILED != l_pRbuf) {
+ *f_pRbuf = l_pRbuf;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+
+ close(l_siFd);
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CheckSize
+/// This function check mmap size
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::CheckSize(int fd, off_t size) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ struct stat st;
+ int i;
+
+ for (i = 0; i < RBUF_RETRY_COUNT; i++) {
+ if (fstat(fd, &st) < 0) {
+ fprintf(stderr, "[CNSRingBuffer::CheckSize] fstat error: %s\n", strerror(errno));
+ goto out;
+ }
+ if (st.st_size == size) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+ }
+ usleep(RBUF_RETRY_SLEEP);
+ }
+ if (i >= RBUF_RETRY_COUNT) {
+ errno = ENOMEM;
+ }
+
+out:
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// MapSM
+/// This function shm_open and maps the shared memory in process space.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::MapSM(PVOID *f_pShMem, const std::string &f_cShmName, const UI_32 f_uiShmSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of shared memory
+ SI_32 l_siId = -1;
+
+ // shared memory buffer headers
+ PVOID l_pShmBuf = NULL;
+
+ // Open shared memory
+ l_siId = shm_open(f_cShmName.c_str(), O_RDWR, 0640);
+
+ if (-1 != l_siId) {
+ if (CheckSize(l_siId, f_uiShmSize) == eFrameworkunifiedStatusOK) {
+ // Map the shared memory into its memory space
+ l_pShmBuf = mmap(NULL, f_uiShmSize, (PROT_READ | PROT_WRITE), MAP_SHARED, l_siId, 0);
+
+ if (MAP_FAILED != l_pShmBuf) {
+ *f_pShMem = l_pShmBuf;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+
+ close(l_siId);
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// UnMap
+/// This function unmaps object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSRingBuffer::UnMap(PVOID f_pRbuf, const UI_32 f_uiRbufSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // Un-map the ring buffer
+ if (NULL != f_pRbuf) {
+ if (0 != munmap(f_pRbuf, f_uiRbufSize)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+
+//void CNSRingBuffer::LockMtx() {
+// if (m_lid == -1) {
+// pthread_mutex_lock(&m_pRbufMtx->m_tBufMutex);
+// } else {
+// CL_LockGet(m_pLockAddr);
+// }
+//}
+int CNSRingBuffer::LockMtx() {
+ int ret = 0;
+
+ if (m_lid == -1) {
+ ret = pthread_mutex_lock(&m_pRbufMtx->m_tBufMutex);
+ } else {
+ ret = CL_LockGet(m_pLockAddr);
+ }
+
+ return ret;
+}
+
+
+void CNSRingBuffer::UnlockMtx() {
+ if (m_lid == -1) {
+ pthread_mutex_unlock(&m_pRbufMtx->m_tBufMutex);
+ } else {
+ CL_LockRelease(m_pLockAddr);
+ }
+}
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/api/nsapi_sharedmem.cpp b/nsframework/framework_unified/client/NS_SharedMemIf/api/nsapi_sharedmem.cpp
new file mode 100644
index 00000000..89c7421b
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/api/nsapi_sharedmem.cpp
@@ -0,0 +1,431 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*************************************************************************
+ *
+ * FILENAME : nsapi_sharedmem.cpp
+ *
+ * DESCRIPTION : TestApp - NS_SharedMem
+ *
+ ************************************************************************/
+
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_shared_mem_if.h>
+#include <native_service/ns_transmit_log.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ss_version.h"
+#include "ns_unittest_internal.h"
+
+#define AVAILABLE_API
+#if defined(AVAILABLE_API)
+static CNSSharedMem *g_pTransmitLogSharedBuf = NULL;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemTransmitLogOpen
+/// Open the shared memory for transmit logging
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemTransmitLogOpen() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == g_pTransmitLogSharedBuf) {
+ // Create the instance
+ g_pTransmitLogSharedBuf = new(std::nothrow) CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ }
+
+ if (NULL != g_pTransmitLogSharedBuf) {
+ if (!g_pTransmitLogSharedBuf->IsOpen()) {
+ // maps the shared memory buffer
+ l_eStatus = g_pTransmitLogSharedBuf->Open();
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemTransmitLogClose
+/// Close the transmit logging shared memory
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemTransmitLogClose() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != g_pTransmitLogSharedBuf) {
+ // un-map the shared memory object
+ l_eStatus = g_pTransmitLogSharedBuf->Close();
+
+ delete g_pTransmitLogSharedBuf;
+ g_pTransmitLogSharedBuf = NULL;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemReadTransmitLog
+/// Reads transmit log from the shared memory buffer.
+////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 NSSharedMemReadTransmitLog(PSTR f_pBuffer, const UI_32 f_uiLength, const BOOL f_bBlock) {
+ // no. of bytes read
+ SI_32 l_iReadSize = NS_SHM_ERROR;
+
+ if (NULL != g_pTransmitLogSharedBuf && NULL != f_pBuffer) {
+ // Writes log data into shared memory buffer
+ l_iReadSize = g_pTransmitLogSharedBuf->Read(f_pBuffer, f_uiLength, f_bBlock);
+ }
+
+ return l_iReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemWriteTransmitLog
+/// Write transmit log into the shared memory buffer.
+////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 NSSharedMemWriteTransmitLog(PCSTR f_pBuffer, const UI_32 f_uiLength) {
+ // no. of bytes read
+ SI_32 l_iWriteSize = NS_SHM_ERROR;
+
+ if (NULL != g_pTransmitLogSharedBuf && NULL != f_pBuffer) {
+ // Writes log data into shared memory buffer
+ l_iWriteSize = g_pTransmitLogSharedBuf->Write(f_pBuffer, f_uiLength);
+ }
+
+ return l_iWriteSize;
+}
+#endif
+
+
+// For NsLog
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_INFO, ZONE_WARN, ZONE_ERR
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
+ LPRINT,
+ {
+ "Init", "Function", "Memory",
+ "", "", "",
+ "", "", "",
+ "", "", "",
+ "", "", "",
+ "", "", "",
+ "",
+ "Info", "Warning", "Error"
+ },
+ FRAMEWORKUNIFIEDLOGZONES
+};
+
+/** sleep */
+static int
+sleep_msec(int msec) {
+ struct timespec ts, rem;
+ ts.tv_sec = msec / 1000;
+ ts.tv_nsec = (msec % 1000) * 1000000;
+ int ret;
+ for (;;) {
+ ret = nanosleep(&ts, &rem);
+ if (ret == 0 || (ret < 0 && errno != EINTR)) {
+ break;
+ }
+ ts = rem;
+ }
+ return ret;
+}
+
+/** usage */
+void usage(void) {
+ printf("nsapi_sharedmem [command] [option]\n");
+ printf(" command: preset\n");
+#if !defined(AVAILABLE_API)
+ printf(" preset service_write\n");
+ printf(" preset service_write_read n\n");
+#endif
+ printf(" preset sharedmem_write\n");
+ printf(" preset sharedmem_write_read n\n");
+ printf(" preset write_6_A\n");
+ printf(" preset write_6_B\n");
+ printf(" preset write_7_A\n");
+ printf(" preset write_7_B\n");
+ printf(" command: manual\n");
+ printf(" manual ***\n");
+}
+
+/** main */
+int main(int argc, char *argv[]) {
+ int status = 0;
+
+ FRAMEWORKUNIFIED_SET_ZONES();
+
+ if (argc < 2) {
+ usage();
+ return 0;
+ } else {
+ char *command = argv[1];
+ int option = 0;
+
+ /* Execute command */
+ if (strcmp(command, "preset") == 0) {
+ if (argc > 2) {
+ char *preset = argv[2];
+ if (argc > 3) {
+ option = atoi(argv[3]);
+ }
+
+#if defined(AVAILABLE_API)
+ if (strcmp(preset, "sharedmem_write") == 0) {
+ NSUT_ASSERT(NSSharedMemTransmitLogOpen() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogOpen() error.");
+ SI_32 size = NSSharedMemWriteTransmitLog(argv[2], static_cast<UI_32>(strlen(argv[2]) + 1));
+ NSUT_ASSERT(size == (SI_32)(strlen(argv[2]) + 1), "NSSharedMemWriteTransmitLog() error.");
+ NSUT_ASSERT(NSSharedMemTransmitLogClose() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogClose() error.");
+ if (size != (SI_32)(strlen(argv[2]) + 1)) {
+ return -1;
+ }
+ } else if (strcmp(preset, "sharedmem_write_read") == 0) {
+ for (int i = 0; i < option; i++) {
+ NSUT_ASSERT(NSSharedMemTransmitLogOpen() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogOpen() error.");
+ SI_32 size = NSSharedMemWriteTransmitLog(argv[2], static_cast<UI_32>(strlen(argv[2]) + 1));
+ NSUT_ASSERT(size == (SI_32)(strlen(argv[2]) + 1), "NSSharedMemWriteTransmitLog() error.");
+ char f_pBuffer[100] = {0};
+ NSSharedMemReadTransmitLog(f_pBuffer, sizeof(f_pBuffer), FALSE);
+ NSUT_ASSERT(NSSharedMemTransmitLogClose() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogClose() error.");
+ }
+ }
+#else
+ if (strcmp(preset, "service_write") == 0) {
+ TMemID id = SetDataToShared(argv[2], strlen(argv[2]) + 1);
+ NSUT_ASSERT(id != BAD_MEM_ID, "SetDataToShared() error.");
+ if (id == BAD_MEM_ID) {
+ return -1;
+ }
+ } else if (strcmp(preset, "service_write_read") == 0) {
+ for (int i = 0; i < option; i++) {
+ EFrameworkunifiedStatus status;
+ TMemID id = SetDataToShared(argv[2], strlen(argv[2]) + 1);
+ NSUT_ASSERT(id != BAD_MEM_ID, "SetDataToShared() error.");
+ UI_32 size = GetLengthOfDataFromShared(id);
+ NSUT_ASSERT(size == (strlen(argv[2]) + 1), "NSSharedMemWriteTransmitLog() error.");
+ void *data[100] = { 0 };
+ status = GetDataFromShared(id, data, sizeof(data));
+ NSUT_ASSERT(eFrameworkunifiedStatusOK == status, "GetDataFromShared()");
+ status = DiscardDataFromShared(id);
+ NSUT_ASSERT(eFrameworkunifiedStatusOK == status, "DiscardDataFromShared()");
+ }
+ } else if (strcmp(preset, "sharedmem_write") == 0) {
+ NSUT_ASSERT(NSSharedMemTransmitLogOpen() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogOpen() error.");
+ SI_32 size = NSSharedMemWriteTransmitLog(argv[2], strlen(argv[2]) + 1);
+ NSUT_ASSERT(size == (SI_32)(strlen(argv[2]) + 1), "NSSharedMemWriteTransmitLog() error.");
+ NSUT_ASSERT(NSSharedMemTransmitLogClose() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogClose() error.");
+ if (size != (SI_32)(strlen(argv[2]) + 1)) {
+ return -1;
+ }
+ } else if (strcmp(preset, "sharedmem_write_read") == 0) {
+ for (int i = 0; i < option; i++) {
+ NSUT_ASSERT(NSSharedMemTransmitLogOpen() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogOpen() error.");
+ SI_32 size = NSSharedMemWriteTransmitLog(argv[2], strlen(argv[2]) + 1);
+ NSUT_ASSERT(size == (SI_32)(strlen(argv[2]) + 1), "NSSharedMemWriteTransmitLog() error.");
+ char f_pBuffer[100] = {0};
+ NSSharedMemReadTransmitLog(f_pBuffer, sizeof(f_pBuffer), FALSE);
+ NSUT_ASSERT(NSSharedMemTransmitLogClose() == eFrameworkunifiedStatusOK, "NSSharedMemTransmitLogClose() error.");
+ }
+ }
+#endif
+ else if (strcmp(preset, "write_6_A") == 0) { // NOLINT (readability/nolint)
+ CNSSharedMem *testObj = new CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ if (testObj->Open() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ sleep(2);
+ char f_pBuffer[100] = {0};
+ if (testObj->Read(f_pBuffer, sizeof(f_pBuffer), FALSE) != 7) {
+ status = -1;
+ }
+ if (memcmp(f_pBuffer, "ABCDEFG", 7) != 0) {
+ printf("memcmp() error.");
+ return -1;
+ }
+ if (testObj->Close() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ delete testObj;
+ } else if (strcmp(preset, "write_6_B") == 0) {
+ CNSSharedMem *testObj = new CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ if (testObj->Open() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ if (testObj->Write("ABCDEFG", static_cast<UI_32>(strlen("ABCDEFG"))) != 7) {
+ status = -1;
+ }
+ if (testObj->Close() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ delete testObj;
+ } else if (strcmp(preset, "write_7_A") == 0) {
+ CNSSharedMem *testObj = new CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ if (testObj->Open() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ sleep(2);
+ char f_pBuffer[100] = {0};
+ if (testObj->Read(f_pBuffer, sizeof(f_pBuffer), FALSE) == 7) {
+ status = -1;
+ }
+ if (testObj->Close() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ delete testObj;
+ } else if (strcmp(preset, "write_7_B") == 0) {
+ CNSSharedMem *testObj = new CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ if (testObj->Open() == eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ if (testObj->Write("ABCDEFG", static_cast<UI_32>(strlen("ABCDEFG"))) == 7) {
+ status = -1;
+ }
+ if (testObj->Close() == eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ delete testObj;
+ } else if (strcmp(preset, "stress_4") == 0) {
+ int i;
+ char *writeBuffer = new char[0x400]();
+ for (i = 0; i < 0x400; i++) {
+ writeBuffer[i] = static_cast<char>(i);
+ }
+
+ CNSSharedMem *testObj = new CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ if (testObj->Open() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ int timeout = 0;
+ int test_count = 0;
+ while ((timeout < 10) && (test_count < option)) {
+ if (testObj->GetSize() > (SI_32)(TRANSMIT_LOG_SHAREDMEM_SIZE - 0x800)) {
+ sleep_msec(100);
+ timeout++;
+ // printf("timeout = %d\n", timeout);
+ continue;
+ }
+ if (testObj->ClearBuf() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ if (testObj->SetReadPtrToWritePtr() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ if (testObj->Write(writeBuffer, 0x400) != 0x400) {
+ status = -1;
+ }
+ timeout = 0;
+ test_count++;
+ }
+ if (testObj->Close() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ delete testObj;
+
+ delete[] writeBuffer;
+ } else if (strcmp(preset, "stress_5") == 0) {
+ int i;
+ char *writeBuffer = new char[0x100]();
+ for (i = 0; i < 0x100; i++) {
+ writeBuffer[i] = static_cast<char>(0xff - i);
+ }
+
+ CNSSharedMem *testObj = new CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ if (testObj->Open() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ int timeout = 0;
+ int count = 0;
+ while (timeout < 10) {
+ int size = (count % 0xff) + 1;
+ if (testObj->GetSize() > (SI_32)(TRANSMIT_LOG_SHAREDMEM_SIZE - 0x800)) {
+ sleep_msec(100);
+ timeout++;
+ continue;
+ }
+ if (testObj->Write(&writeBuffer[0xff - size], size) != size) {
+ status = -1;
+ }
+ timeout = 0;
+ count++;
+ }
+ if (testObj->Close() != eFrameworkunifiedStatusOK) {
+ status = -1;
+ }
+ delete testObj;
+
+ delete[] writeBuffer;
+ } else {
+ usage();
+ }
+ } else {
+ usage();
+ }
+ } else if (strcmp(command, "manual") == 0) {
+ int testno;
+ char buf[32];
+ INT8 active = 1;
+
+ while (active) {
+ printf(" ----- imageapi ----------\n");
+ printf(" 0: debug_test()\n");
+ printf(" 1: gfx_ut_image_api()\n");
+ printf(" 2: gfx_ut_image_csv()\n");
+ printf(" q: quit\n");
+ printf(" -------------------------\n");
+
+ fgets(buf, sizeof(buf), stdin);
+ if (buf[0] == '\n') {
+ continue;
+ } else if (buf[0] == 'q' || buf[0] == 'Q') {
+ active = 0;
+ continue;
+ }
+ testno = atoi(buf);
+
+ switch (testno) {
+ case 0:
+ // debug_test();
+ break;
+ case 1:
+ // gfx_ut_image_api();
+ break;
+ case 2:
+ // gfx_ut_image_csv((char *)"it_image.csv");
+ break;
+ default:
+ break;
+ }
+ }
+ } else {
+ usage();
+ }
+ }
+ return status;
+}
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/cfg/depends.mk b/nsframework/framework_unified/client/NS_SharedMemIf/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_SharedMemIf/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..dc225c4a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/src/makefile_PosixBasedOS001
@@ -0,0 +1,190 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_SharedMemIf
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_SharedMemIf
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS += -Wstrict-aliasing
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_SharedMem/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_UtilityCenter/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(PRJ_ROOT)../$(COMPONENT_NAME)/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_shared_mem_if.cpp b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_shared_mem_if.cpp
new file mode 100644
index 00000000..e60a4047
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_shared_mem_if.cpp
@@ -0,0 +1,254 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief SharedMemIf implementation
+///
+/// Implements interface functions to SharedMem service
+//////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_shared_mem_if.h> ///< Shared mem source interface file
+#include <native_service/ns_logger_if.h>
+
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#define NS_SHM_HEADER_SIZE (48)
+
+/////////////////////////////////////////////////////////////////////////////
+/// Utility functions and classes
+
+static TMemID getclock(void) {
+ struct timespec tp;
+ if (clock_gettime(CLOCK_MONOTONIC_RAW, &tp) < 0) { // LCOV_EXCL_BR_LINE 5: clock_gettime's error case.
+ return 0;
+ }
+ return (TMemID)(((uint64_t)tp.tv_sec * 1000 * 1000 * 1000 + tp.tv_nsec) >> 8);
+}
+
+static size_t uitoa(unsigned int value, char *buf) {
+ static const char c[] = "0123456789abcdef";
+ int i;
+
+ if (buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "buf is NULL");
+ return 0;
+ }
+ for (i = 0; i < 8; i++) {
+ buf[i] = c[(value >> ((7 - i) * 4)) & 0xf];
+ }
+ buf[i] = '\0';
+
+ return i;
+}
+
+static inline void create_shmname(char *buf, TMemID id) {
+ if (buf == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "buf is NULL");
+ return;
+ }
+ strcpy(buf, "nsshm_"); // NOLINT (readability/nolint)
+ buf += sizeof("nsshm_") - 1;
+ uitoa(id, buf);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+// Public interface function definitions
+
+TMemID SetDataToShared(const void *data, UI_32 dataBytes, const char *from, const char *to) {
+ TMemID id;
+ char shmname[16];
+ int fd;
+ void *addr = MAP_FAILED;
+
+ if (data == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "data is NULL");
+ return BAD_MEM_ID;
+ }
+ if (from == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "from is NULL");
+ return BAD_MEM_ID;
+ }
+ if (to == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "to is NULL");
+ return BAD_MEM_ID;
+ }
+
+ if (dataBytes == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "DataSize is invalied(%d)", dataBytes);
+ return BAD_MEM_ID;
+ }
+
+ while (1) {
+ id = getclock();
+ create_shmname(shmname, id);
+
+ if ((fd = shm_open(shmname, O_CREAT | O_EXCL | O_RDWR, 0666)) < 0) {
+ if (errno == EEXIST) {
+ continue;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "shm_open: %s", strerror(errno));
+ return BAD_MEM_ID;
+ }
+ break;
+ }
+
+ if (ftruncate(fd, dataBytes + NS_SHM_HEADER_SIZE) < 0) { // LCOV_EXCL_BR_LINE 5: ftruncate's error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "ftruncate: %s", strerror(errno));
+ id = BAD_MEM_ID;
+ goto exit;
+ }
+
+ if ((addr = mmap(NULL, dataBytes + NS_SHM_HEADER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "mmap: %s", strerror(errno));
+ id = BAD_MEM_ID;
+ goto exit;
+ }
+
+ strcpy(reinterpret_cast<char *>(addr), from); // NOLINT (readability/nolint)
+ strcpy(reinterpret_cast<char *>(addr) + (NS_SHM_HEADER_SIZE / 2), to); // NOLINT (readability/nolint)
+ /**
+ * @todo
+ * Specifying a large number (4097 or higher) for the Session Data Size for transmission results in a segmentation fault.
+ */
+ memcpy(reinterpret_cast<char *>(addr) + NS_SHM_HEADER_SIZE, data, dataBytes);
+
+exit:
+ close(fd);
+ if (addr != MAP_FAILED) {
+ munmap(addr, dataBytes + NS_SHM_HEADER_SIZE);
+ }
+ if (id == BAD_MEM_ID) {
+ shm_unlink(shmname);
+ }
+ return id;
+}
+
+EFrameworkunifiedStatus GetDataFromShared(TMemID id, void *data, UI_32 dataMaxBytes) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ char shmname[16];
+ int fd;
+ void *addr = MAP_FAILED;
+ struct stat sb;
+
+ if (id == BAD_MEM_ID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "ShMemID is invalied(%u)", id);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ if (data == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "data is NULL");
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ if (dataMaxBytes == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "DataSize is invalied(%d)", dataMaxBytes);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ create_shmname(shmname, id);
+
+ if ((fd = shm_open(shmname, O_RDONLY, 0)) < 0) {
+ if (errno == ENOENT) {
+ eStatus = eFrameworkunifiedStatusInvldID;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "shm_open: %s", strerror(errno));
+ return eStatus;
+ }
+
+ if (fstat(fd, &sb) < 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "fstat: %s", strerror(errno));
+ goto exit;
+ }
+ if (sb.st_size - NS_SHM_HEADER_SIZE > static_cast<SI_64>(dataMaxBytes)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "DataSize is invalied(%d-%d)", dataMaxBytes, (int)sb.st_size);
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ goto exit;
+ }
+
+ if ((addr = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { // LCOV_EXCL_BR_LINE 5: mmap's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "mmap: %s", strerror(errno)); // LCOV_EXCL_LINE 5: mmap's error case.
+ goto exit;
+ }
+
+ memcpy(data, reinterpret_cast<char *>(addr) + NS_SHM_HEADER_SIZE, sb.st_size - NS_SHM_HEADER_SIZE);
+ eStatus = eFrameworkunifiedStatusOK;
+
+exit:
+ close(fd);
+ if (addr != MAP_FAILED) {
+ munmap(addr, sb.st_size);
+ }
+ return eStatus;
+}
+
+UI_32 GetLengthOfDataFromShared(TMemID id) {
+ UI_32 size = 0;
+ char shmname[16];
+ int fd;
+ struct stat sb;
+
+ if (id == BAD_MEM_ID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "ShMemID is invalied(%u)", id); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return 0;
+ }
+
+ create_shmname(shmname, id);
+
+ if ((fd = shm_open(shmname, O_RDWR, 0)) < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "shm_open: %s", strerror(errno));
+ return 0;
+ }
+
+ if (fstat(fd, &sb) < 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "fstat: %s", strerror(errno)); // LCOV_EXCL_LINE 5: mmap's error case.
+ goto exit;
+ }
+
+ size = static_cast<UI_32>(sb.st_size - NS_SHM_HEADER_SIZE);
+
+exit:
+ close(fd);
+ return size;
+}
+
+EFrameworkunifiedStatus DiscardDataFromShared(TMemID id) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ char shmname[16];
+
+ if (id == BAD_MEM_ID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "ShMemID is invalied(%u)", id);
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ create_shmname(shmname, id);
+
+ if (shm_unlink(shmname) < 0) {
+ if (errno == ENOENT) {
+ eStatus = eFrameworkunifiedStatusInvldID;
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "shm_unlink: %s", strerror(errno));
+ }
+
+ return eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem.cpp b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem.cpp
new file mode 100644
index 00000000..fe1e9bc4
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem.cpp
@@ -0,0 +1,697 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains implementation of class CNSSharedMem.
+/// This class provides API to open, read, write and close shared memory
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <unistd.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_transmit_log.h>
+
+#include <string>
+
+static CNSSharedMem *g_pTransmitLogSharedBuf = NULL;
+
+#define SHM_HEADER_EXT "Hdr"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemTransmitLogOpen
+/// Open the shared memory for transmit logging
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemTransmitLogOpen() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == g_pTransmitLogSharedBuf) {
+ // Create the instance
+ g_pTransmitLogSharedBuf = new(std::nothrow) CNSSharedMem(TRANSMIT_LOG_SHAREDMEM_NAME, TRANSMIT_LOG_SHAREDMEM_SIZE);
+ }
+
+ if (NULL != g_pTransmitLogSharedBuf) {
+ if (!g_pTransmitLogSharedBuf->IsOpen()) {
+ // maps the shared memory buffer
+ l_eStatus = g_pTransmitLogSharedBuf->Open();
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemTransmitLogClose
+/// Close the transmit logging shared memory
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemTransmitLogClose() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != g_pTransmitLogSharedBuf) {
+ // un-map the shared memory object
+ l_eStatus = g_pTransmitLogSharedBuf->Close();
+
+ delete g_pTransmitLogSharedBuf;
+ g_pTransmitLogSharedBuf = NULL;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemReadTransmitLog
+/// Reads transmit log from the shared memory buffer.
+////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 NSSharedMemReadTransmitLog(PSTR f_pBuffer, const UI_32 f_uiLength, const BOOL f_bBlock) {
+ // no. of bytes read
+ SI_32 l_iReadSize = NS_SHM_ERROR;
+
+ if (NULL != g_pTransmitLogSharedBuf && NULL != f_pBuffer) {
+ // Writes log data into shared memory buffer
+ l_iReadSize = g_pTransmitLogSharedBuf->Read(f_pBuffer, f_uiLength, f_bBlock);
+ }
+
+ return l_iReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemWriteTransmitLog
+/// Write transmit log into the shared memory buffer.
+////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 NSSharedMemWriteTransmitLog(PCSTR f_pBuffer, const UI_32 f_uiLength) {
+ // no. of bytes read
+ SI_32 l_iWriteSize = NS_SHM_ERROR;
+
+ if (NULL != g_pTransmitLogSharedBuf && NULL != f_pBuffer) {
+ // Writes log data into shared memory buffer
+ l_iWriteSize = g_pTransmitLogSharedBuf->Write(f_pBuffer, f_uiLength);
+ }
+
+ return l_iWriteSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemDumpTransmitLogToFile
+/// Dump transmit log from the shared memory buffer into file.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemDumpTransmitLogToFile(PCSTR f_pPath, PUI_32 f_puiDumpSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (NULL != g_pTransmitLogSharedBuf && NULL != f_pPath) {
+ // Writes log data into shared memory buffer
+ l_eStatus = g_pTransmitLogSharedBuf->DumpToFile(f_pPath, f_puiDumpSize);
+ }
+
+ return l_eStatus;
+}
+
+// Used only in nstest_sharedmem.
+#if defined(SHM_UNITTEST_ENABLE)
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSSharedMemTransmitLogIsOpen
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL NSSharedMemTransmitLogIsOpen() {
+ if (g_pTransmitLogSharedBuf != NULL) {
+ return g_pTransmitLogSharedBuf->IsOpen();
+ } else {
+ return FALSE;
+ }
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSSharedMem
+/// Parameterized Constructor of CNSSharedMem class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMem::CNSSharedMem(const std::string &f_cSharedMemName, const UI_32 f_uiSize):
+ m_cShmName(f_cSharedMemName), m_uiShmBuffSize(f_uiSize), m_pShmHdr(NULL), m_pShmBuff(NULL) {
+ m_cShmHdrName = f_cSharedMemName;
+ m_cShmHdrName.append(SHM_HEADER_EXT);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSSharedMem
+/// Constructor of CNSSharedMem class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMem::CNSSharedMem():
+ m_cShmName(""), m_uiShmBuffSize(0), m_pShmHdr(NULL), m_pShmBuff(NULL) {
+ // do nothing
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNSSharedMem
+/// Destructor of CNSSharedMem class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMem::~CNSSharedMem() {
+ if (NULL != m_pShmHdr) {
+ // un-map the shared memory object
+ Close();
+
+ m_pShmHdr = NULL;
+ }
+
+ // TODO(framework_unified): currently shared memory is not being unlinked,
+ // we need to find a method where we can unlink the sharedmem
+ // shm_unlink(m_cShmName.c_str());
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Open
+/// This function opens and maps the shared memory object.
+/// It creates the shared memory if it does not exists.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::Open() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusErrOther;
+
+// Used only in nstest_sharedmem.
+#if defined(SHM_UNITTEST_ENABLE)
+ if (getenv(NSTEST_FAIL_SHAREDMEM_OPEN) != NULL) {
+ return l_eStatus;
+ }
+#endif
+
+ if (NULL == m_pShmHdr) {
+ // Open header shared memory
+ if (eFrameworkunifiedStatusOK != (l_eStatus = MapSM(reinterpret_cast<PVOID *>(&m_pShmHdr),
+ m_cShmHdrName, sizeof(NSSharedBufferHdr)))) {
+ if (ENOENT == errno) { // Shared memory is not created yet
+ errno = EOK;
+
+ // Create shared memory
+ if (eFrameworkunifiedStatusOK == CreateSMHeader()) {
+ // Retry to open
+ l_eStatus = MapSM(reinterpret_cast<PVOID *>(&m_pShmHdr), m_cShmHdrName, sizeof(NSSharedBufferHdr));
+ }
+ }
+ } else {
+ pthread_mutex_lock(&m_pShmHdr->m_tBufMutex);
+
+ // if shared memory buffer is created with size 0, then set new size in header if any change
+ if (0 == m_pShmHdr->m_uiShMemSize && 0 < m_uiShmBuffSize) {
+ m_pShmHdr->m_uiShMemSize = m_uiShmBuffSize;
+ } else if (0 < m_pShmHdr->m_uiShMemSize && 0 == m_uiShmBuffSize) {
+ m_uiShmBuffSize = m_pShmHdr->m_uiShMemSize;
+ } else {
+ // do nothing
+ }
+
+ pthread_mutex_unlock(&m_pShmHdr->m_tBufMutex);
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus && 0 != m_uiShmBuffSize) {
+ if (NULL == m_pShmBuff) {
+ // Open shared memory data buffer, create if not exists
+ if (eFrameworkunifiedStatusOK != (l_eStatus = MapSM(reinterpret_cast<PVOID *>(&m_pShmBuff), m_cShmName, m_uiShmBuffSize))) {
+ if (ENOENT == errno) { // Shared memory is not created yet
+ // Create shared memory
+ if (eFrameworkunifiedStatusOK == CreateSMDataBuffer()) {
+ // Retry to open
+ l_eStatus = MapSM(reinterpret_cast<PVOID *>(&m_pShmBuff), m_cShmName, m_uiShmBuffSize);
+ }
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsOpen
+/// This function is used to check whether the shared memory buffer is opened or not.
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CNSSharedMem::IsOpen() {
+ return NULL == m_pShmHdr ? FALSE : TRUE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Close
+/// This function closes the shared memory object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::Close() {
+ EFrameworkunifiedStatus l_eStatus1 = UnMapSM(m_pShmHdr, sizeof(NSSharedBufferHdr));
+ m_pShmHdr = NULL;
+
+ EFrameworkunifiedStatus l_eStatus2 = eFrameworkunifiedStatusOK;
+ if (0 != m_uiShmBuffSize) {
+ l_eStatus2 = UnMapSM(m_pShmBuff, m_uiShmBuffSize);
+ m_pShmBuff = NULL;
+ }
+ /*
+ * todo
+ * Even if an error occurs due to eFrameworkunifiedStatusNullPointer when UnMapSM fails,
+ * the error type cannot be determined by the caller because it is rounded to eFrameworkunifiedStatusFail
+ * if the API final determination is not OK.
+ */
+ return (eFrameworkunifiedStatusOK != l_eStatus1 || eFrameworkunifiedStatusOK != l_eStatus2) ? eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Read
+/// This function reads data from the shared memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSSharedMem::Read(PSTR f_pBuffer, const UI_32 f_uilength, const BOOL f_bBlock) {
+ SI_32 l_iReadSize = NS_SHM_ERROR;
+
+ if ((NULL != f_pBuffer) && (NULL != m_pShmHdr) && (0 != f_uilength)) {
+ UI_32 l_uiDataSizeToRead = 0;
+
+ // Remaining buffer size from read pointer to end of the buffer
+ UI_32 l_uiRemainSize = 0;
+
+ if (0 == pthread_mutex_lock(&m_pShmHdr->m_tBufMutex)) {
+ if ((TRUE == f_bBlock) && (0 == m_pShmHdr->m_uiUnReadSize)) {
+ pthread_cond_wait(&m_pShmHdr->m_tCondVar, &m_pShmHdr->m_tBufMutex);
+ }
+
+ // if shared memory buffer size is changed by some other process, remap the updated buffer size in this process
+ // shared memory buffer size can only be changed if the initial size is 0.
+ if (m_uiShmBuffSize != m_pShmHdr->m_uiShMemSize) {
+ if (eFrameworkunifiedStatusOK == MapSM(reinterpret_cast<PVOID *>(&m_pShmBuff), m_cShmName, m_pShmHdr->m_uiShMemSize)) {
+ m_uiShmBuffSize = m_pShmHdr->m_uiShMemSize;
+ }
+ }
+
+ if (NULL != m_pShmBuff) {
+ l_uiRemainSize = m_uiShmBuffSize - m_pShmHdr->m_uiReadPtr;
+
+ // Round read data size depending on un-read data size in the buffer
+ l_uiDataSizeToRead = m_pShmHdr->m_uiUnReadSize < f_uilength ? m_pShmHdr->m_uiUnReadSize : f_uilength;
+
+ if (l_uiRemainSize < l_uiDataSizeToRead) {
+ // Wrapping read
+ memcpy(f_pBuffer, m_pShmBuff + m_pShmHdr->m_uiReadPtr, l_uiRemainSize);
+ memcpy(f_pBuffer + l_uiRemainSize, m_pShmBuff, l_uiDataSizeToRead - l_uiRemainSize);
+ m_pShmHdr->m_uiReadPtr = l_uiDataSizeToRead - l_uiRemainSize;
+ } else {
+ memcpy(f_pBuffer, m_pShmBuff + m_pShmHdr->m_uiReadPtr, l_uiDataSizeToRead);
+
+ m_pShmHdr->m_uiReadPtr += l_uiDataSizeToRead;
+
+ // Read pointer is the end of the buffer
+ if (m_pShmHdr->m_uiReadPtr == m_uiShmBuffSize) {
+ m_pShmHdr->m_uiReadPtr = 0;
+ }
+ }
+
+ m_pShmHdr->m_uiUnReadSize -= l_uiDataSizeToRead; // Update un-read data size
+
+ l_iReadSize = l_uiDataSizeToRead;
+ }
+
+ pthread_mutex_unlock(&m_pShmHdr->m_tBufMutex);
+ }
+ }
+
+ return l_iReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Write
+/// This function writes the data into the shared memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSSharedMem::Write(PCSTR f_pBuffer, const UI_32 f_uilength) {
+ SI_32 l_iWriteSize = NS_SHM_ERROR;
+
+ // size available in buffer
+ UI_32 l_uiRemainSize = 0;
+
+ if (NULL != m_pShmHdr && NULL != m_pShmBuff && NULL != f_pBuffer && f_uilength <= m_uiShmBuffSize) {
+ if (0 == pthread_mutex_lock(&m_pShmHdr->m_tBufMutex)) {
+ l_uiRemainSize = m_uiShmBuffSize - m_pShmHdr->m_uiWritePtr;
+
+ // Write data to the buffer
+ if (l_uiRemainSize < f_uilength) {
+ // Wrapping write
+ memcpy(m_pShmBuff + m_pShmHdr->m_uiWritePtr, f_pBuffer, l_uiRemainSize);
+ memcpy(m_pShmBuff, f_pBuffer + l_uiRemainSize, f_uilength - l_uiRemainSize);
+
+ // Update the write pointer
+ m_pShmHdr->m_uiWritePtr = f_uilength - l_uiRemainSize;
+
+ // The buffer is full of valid data
+ m_pShmHdr->m_bIsFull = TRUE;
+ } else {
+ memcpy(m_pShmBuff + m_pShmHdr->m_uiWritePtr, f_pBuffer, f_uilength);
+
+ // Update the write pointer
+ m_pShmHdr->m_uiWritePtr += f_uilength;
+
+ // Write pointer is the end of the buffer
+ if (m_pShmHdr->m_uiWritePtr == m_uiShmBuffSize) {
+ m_pShmHdr->m_uiWritePtr = 0;
+
+ // The buffer is full of valid data
+ m_pShmHdr->m_bIsFull = TRUE;
+ }
+ }
+
+ // Update un-read data size
+ m_pShmHdr->m_uiUnReadSize += f_uilength;
+
+ // Set read pointer to be same as write pointer if write pointer exceeds the read pointer
+ if (m_uiShmBuffSize < m_pShmHdr->m_uiUnReadSize) {
+ m_pShmHdr->m_uiReadPtr = m_pShmHdr->m_uiWritePtr;
+ m_pShmHdr->m_uiUnReadSize = m_uiShmBuffSize;
+ }
+
+ pthread_cond_signal(&m_pShmHdr->m_tCondVar);
+
+ pthread_mutex_unlock(&m_pShmHdr->m_tBufMutex);
+
+ l_iWriteSize = f_uilength;
+ }
+ }
+
+ return l_iWriteSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// DumpToFile
+/// This function writes all the data in the buffer into provided file f_pPath.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::DumpToFile(PCSTR f_pPath, PUI_32 f_uiDumpSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ ssize_t l_iSize = 0;
+
+ SI_32 fd = -1;
+
+ if (NULL == f_uiDumpSize) {
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ *f_uiDumpSize = 0;
+
+ if (NULL != f_pPath) {
+ if (NULL != m_pShmHdr) {
+ // Open file
+ if (-1 != (fd = open(f_pPath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRWXU | S_IRWXG | S_IRWXO))) {
+ if (NULL != m_pShmBuff && 0 != m_uiShmBuffSize) {
+ if (0 == pthread_mutex_lock(&m_pShmHdr->m_tBufMutex)) {
+ // Write buffer data to file
+ if (m_pShmHdr->m_bIsFull) {
+ // Buffer has full of data (read data from write pointer)
+ if (-1 != (l_iSize = write(fd, m_pShmBuff + m_pShmHdr->m_uiWritePtr,
+ m_uiShmBuffSize - m_pShmHdr->m_uiWritePtr))) {
+ *f_uiDumpSize += static_cast<UI_32>(l_iSize);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+
+ if (-1 != (l_iSize = write(fd, m_pShmBuff, m_pShmHdr->m_uiWritePtr))) {
+ *f_uiDumpSize += static_cast<UI_32>(l_iSize);
+ }
+
+ if (0 != pthread_mutex_unlock(&m_pShmHdr->m_tBufMutex)) {
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusSemLockFail;
+ }
+ } else if (NULL == m_pShmBuff && 0 != m_uiShmBuffSize) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // do nothing
+ }
+
+ // Sync the file to force I/O operation completed
+ fsync(fd);
+
+ close(fd);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetSize
+/// This function returns the number of unread bytes which can be read by Read().
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSSharedMem::GetSize() {
+ SI_32 l_uiReadSize = NS_SHM_ERROR;
+
+ if (NULL != m_pShmHdr) {
+ l_uiReadSize = m_pShmHdr->m_uiUnReadSize;
+ }
+
+ return l_uiReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ClearBuf
+/// This function clears the buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::ClearBuf() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmHdr) {
+ if (0 == pthread_mutex_lock(&m_pShmHdr->m_tBufMutex)) {
+ // Initialize the r/w pointers
+ m_pShmHdr->m_uiReadPtr = 0;
+ m_pShmHdr->m_uiWritePtr = 0;
+ m_pShmHdr->m_uiUnReadSize = 0;
+ m_pShmHdr->m_bIsFull = FALSE;
+
+ if (0 != pthread_mutex_unlock(&m_pShmHdr->m_tBufMutex)) {
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusSemLockFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetReadPtrToWritePtr
+/// This function sets the position of read ptr to write ptr in buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::SetReadPtrToWritePtr() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmHdr) {
+ if (0 == pthread_mutex_lock(&m_pShmHdr->m_tBufMutex)) { // LCOV_EXCL_BR_LINE 5: pthread_mutex_lock's error case
+ // Initialize the r/w pointers
+ m_pShmHdr->m_uiReadPtr = m_pShmHdr->m_uiWritePtr;
+ m_pShmHdr->m_uiUnReadSize = 0;
+
+ if (0 != pthread_mutex_unlock(&m_pShmHdr->m_tBufMutex)) { // LCOV_EXCL_BR_LINE 5: pthread_mutex_unlock's error
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusSemLockFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateSMHeader
+/// This function creates the shared memory object for header.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::CreateSMHeader() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of shared memory
+ SI_32 l_siId = -1;
+
+ // shared memory buffer headers
+ NSSharedBufferHdr *l_pShmHdr = NULL;
+
+ if ((!m_cShmHdrName.empty()) && (m_cShmHdrName.size() <= NAME_MAX)) {
+ // Try to create shared memory
+ l_siId = shm_open(m_cShmHdrName.c_str(), O_CREAT | O_EXCL | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ if (-1 != l_siId) {
+ // Set the size of shared memory
+ if (-1 != ftruncate(l_siId, sizeof(NSSharedBufferHdr))) {
+ // Map the shared memory
+ l_pShmHdr = reinterpret_cast<NSSharedBufferHdr *>(mmap(NULL, sizeof(NSSharedBufferHdr),
+ (PROT_READ | PROT_WRITE), MAP_SHARED, l_siId, 0));
+
+ if (MAP_FAILED != l_pShmHdr) {
+ // mutex attribute
+ pthread_mutexattr_t l_tMtxAttr = {};
+ pthread_condattr_t l_tCondAttr = {};
+
+ // Initialize mutex
+ pthread_mutexattr_init(&l_tMtxAttr);
+ pthread_mutexattr_setpshared(&l_tMtxAttr, PTHREAD_PROCESS_SHARED);
+ pthread_mutex_init(&l_pShmHdr->m_tBufMutex, &l_tMtxAttr);
+ pthread_mutexattr_destroy(&l_tMtxAttr);
+
+ pthread_condattr_init(&l_tCondAttr);
+ pthread_condattr_setpshared(&l_tCondAttr, PTHREAD_PROCESS_SHARED);
+ pthread_cond_init(&l_pShmHdr->m_tCondVar, &l_tCondAttr);
+ pthread_condattr_destroy(&l_tCondAttr);
+
+ pthread_mutex_lock(&l_pShmHdr->m_tBufMutex);
+
+ // Initialize the r/w pointers
+ l_pShmHdr->m_uiReadPtr = 0;
+ l_pShmHdr->m_uiWritePtr = 0;
+ l_pShmHdr->m_uiUnReadSize = 0;
+ l_pShmHdr->m_bIsFull = FALSE;
+ l_pShmHdr->m_uiShMemSize = m_uiShmBuffSize;
+
+ pthread_mutex_unlock(&l_pShmHdr->m_tBufMutex);
+
+ // Once initialized un-map the shared memory
+ munmap(l_pShmHdr, sizeof(NSSharedBufferHdr));
+
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+
+ close(l_siId);
+ } else if (EEXIST == errno) {
+ // Shared memory is already created
+ l_eStatus = eFrameworkunifiedStatusDuplicate;
+ } else {
+ // do nothing
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateSMDataBuffer
+/// This function creates the shared memory object for data buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::CreateSMDataBuffer() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of shared memory
+ SI_32 l_siId = -1;
+
+ if ((!m_cShmName.empty()) && (m_cShmName.size() <= NAME_MAX)) {
+ // Try to create shared memory
+ l_siId = shm_open(m_cShmName.c_str(), O_CREAT | O_EXCL | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ if (-1 != l_siId) {
+ // Set the size of shared memory
+ if (-1 != ftruncate(l_siId, m_uiShmBuffSize)) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ close(l_siId);
+ } else if (EEXIST == errno) {
+ // Shared memory is already created
+ l_eStatus = eFrameworkunifiedStatusDuplicate;
+ } else {
+ // do nothing
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// MapSMHeader
+/// This function open and maps the shared memory header in process space.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::MapSM(PVOID *f_pShMem, const std::string &f_cShmName, const UI_32 f_uiShmSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ // file descriptor of shared memory
+ SI_32 l_siId = -1;
+
+ // shared memory buffer headers
+ PVOID l_pShmBuf = NULL;
+
+ // Open shared memory
+ l_siId = shm_open(f_cShmName.c_str(), O_RDWR, 0);
+
+ if (-1 != l_siId) {
+ // Map the shared memory into its memory space
+ l_pShmBuf = mmap(NULL, f_uiShmSize, (PROT_READ | PROT_WRITE), MAP_SHARED, l_siId, 0);
+
+ if (MAP_FAILED != l_pShmBuf) {
+ *f_pShMem = l_pShmBuf;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ close(l_siId);
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// UnMapSM
+/// This function unmaps the shared memory object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMem::UnMapSM(PVOID f_pShMem, const UI_32 f_uiShmSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // Un-map the shared memory
+ if (NULL != f_pShMem) {
+ if (0 != munmap(f_pShMem, f_uiShmSize)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_reader.cpp b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_reader.cpp
new file mode 100644
index 00000000..79f9f543
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_reader.cpp
@@ -0,0 +1,169 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains implementation of class CNSSharedMemReader.
+/// This class provides API to open, close and perform read operation on shared memory.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_reader.h>
+#include <string>
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSSharedMemReader
+/// Constructor of CNSSharedMemReader class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMemReader::CNSSharedMemReader(): m_pShmReader(NULL), m_bBlock(TRUE) {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSSharedMemReader
+/// Parameterized Constructor of CNSSharedMemReader class
+/// This creates the shared memory object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMemReader::CNSSharedMemReader(const std::string &f_cSharedMemName, const BOOL f_bBlock): m_bBlock(f_bBlock) {
+ m_pShmReader = new(std::nothrow) CNSSharedMem(f_cSharedMemName, 0);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNSSharedMemReader
+/// Destructor of CNSSharedMemReader class.
+/// Closes the shared memory, if it is open.
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMemReader::~CNSSharedMemReader() {
+ if (NULL != m_pShmReader) {
+ if (m_pShmReader->IsOpen()) {
+ m_pShmReader->Close();
+ }
+
+ delete m_pShmReader;
+ m_pShmReader = NULL;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Open
+/// This function opens and maps the shared memory object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemReader::Open() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmReader) {
+ l_eStatus = m_pShmReader->Open();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsOpen
+/// This function is used to check whether the shared memory buffer is opened or not.
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CNSSharedMemReader::IsOpen() {
+ BOOL l_bOpen = FALSE;
+
+ if (NULL != m_pShmReader) {
+ l_bOpen = m_pShmReader->IsOpen();
+ }
+
+ return l_bOpen;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Close
+/// This function unmaps the shared memory object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemReader::Close() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmReader) {
+ l_eStatus = m_pShmReader->Close();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Read
+/// This function reads data from the shared memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSSharedMemReader::Read(PSTR buffer, const UI_32 f_uilength) {
+ SI_32 l_iReadSize = NS_SHM_ERROR;
+
+ if (NULL != m_pShmReader) {
+ l_iReadSize = m_pShmReader->Read(buffer, f_uilength, m_bBlock);
+ }
+
+ return l_iReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// DumpToFile
+/// This function writes all the data in the buffer into provided file f_pPath.
+/// This function does not changes the unread buffer.
+/// This function overwrites the file if it exists.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemReader::DumpToFile(PCSTR f_pPath, PUI_32 f_uiDumpSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmReader) {
+ l_eStatus = m_pShmReader->DumpToFile(f_pPath, f_uiDumpSize);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetSize
+/// This function returns the number of unread bytes which can be read by Read().
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSSharedMemReader::GetSize() {
+ UI_32 l_uiReadSize = NS_SHM_ERROR;
+
+ if (NULL != m_pShmReader) {
+ l_uiReadSize = m_pShmReader->GetSize();
+ }
+
+ return l_uiReadSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetReadPtrToWritePtr
+/// This function sets the position of read ptr to write ptr in buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemReader::SetReadPtrToWritePtr() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmReader) {
+ l_eStatus = m_pShmReader->SetReadPtrToWritePtr();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_writer.cpp b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_writer.cpp
new file mode 100644
index 00000000..25614157
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_SharedMemIf/src/ns_sharedmem_writer.cpp
@@ -0,0 +1,137 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains implementation of class CNSSharedMemReader.
+/// This class provides API to open, close and perform read operation on shared memory.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_writer.h>
+#include <string>
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSSharedMemWriter
+/// Constructor of CNSSharedMemWriter class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMemWriter::CNSSharedMemWriter(): m_pShmWriter(NULL) {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSSharedMemWriter
+/// Parameterized Constructor of CNSSharedMemWriter class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMemWriter::CNSSharedMemWriter(const std::string &f_cSharedMemName, const UI_32 f_uiSize) {
+ m_pShmWriter = new(std::nothrow) CNSSharedMem(f_cSharedMemName, f_uiSize);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNSSharedMemWriter
+/// Destructor of CNSSharedMemWriter class.
+/// Closes the shared memory, if it is open.
+////////////////////////////////////////////////////////////////////////////////////////////////
+CNSSharedMemWriter::~CNSSharedMemWriter() {
+ if (NULL != m_pShmWriter) {
+ if (m_pShmWriter->IsOpen()) {
+ m_pShmWriter->Close();
+ }
+
+ delete m_pShmWriter;
+ m_pShmWriter = NULL;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Open
+/// This function opens and maps the shared memory object.
+/// It creates the shared memory if it does not exists.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemWriter::Open() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmWriter) {
+ l_eStatus = m_pShmWriter->Open();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsOpen
+/// This function is used to check whether the shared memory buffer is opened or not.
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CNSSharedMemWriter::IsOpen() {
+ BOOL l_bOpen = FALSE;
+
+ if (NULL != m_pShmWriter) {
+ l_bOpen = m_pShmWriter->IsOpen();
+ }
+
+ return l_bOpen;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Close
+/// This function unmaps the shared memory object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemWriter::Close() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmWriter) {
+ l_eStatus = m_pShmWriter->Close();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Write
+/// This function writes the data into the shared memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CNSSharedMemWriter::Write(PCSTR buffer, const UI_32 f_uilength) {
+ SI_32 l_iWriteSize = NS_SHM_ERROR;
+
+ if ((NULL != m_pShmWriter) && (NULL != buffer) && (0 != f_uilength)) {
+ l_iWriteSize = m_pShmWriter->Write(buffer, f_uilength);
+ }
+
+ return l_iWriteSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ClearBuf
+/// This function clears the shared memory buffer.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSSharedMemWriter::ClearBuf() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pShmWriter) {
+ l_eStatus = m_pShmWriter->ClearBuf();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_Timer/cfg/depends.mk b/nsframework/framework_unified/client/NS_Timer/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_Timer/include/ns_timer_handle.h b/nsframework/framework_unified/client/NS_Timer/include/ns_timer_handle.h
new file mode 100644
index 00000000..7d082e78
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/include/ns_timer_handle.h
@@ -0,0 +1,48 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSTimer
+/// \brief Contains the internal structures that used by ns_timer
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_TIMER_INCLUDE_NS_TIMER_HANDLE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_TIMER_INCLUDE_NS_TIMER_HANDLE_H_
+#include <stdio.h>
+#include <time.h>
+#include <signal.h>
+#include <native_service/frameworkunified_types.h>
+
+typedef void (*pfCb)(UI_16 cmd);
+
+/// \brief Struct that defines internal function callback for a timer
+typedef struct _TimerNotifyInfo {
+ UI_16 iCmd;
+ PSTR q_name;
+} TTimerInfo, *PTimerInfo;
+
+/// \brief Struct that defines internal handle object for a timer
+typedef struct _NSTimerHandle {
+ int timerfd;
+ struct itimerspec itime;
+ PTimerInfo tTimerInfo;
+ UI_8 timerState;
+} NSTimerHandle, *PNSTimerHandle;
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_TIMER_INCLUDE_NS_TIMER_HANDLE_H_
diff --git a/nsframework/framework_unified/client/NS_Timer/include/ns_timer_internal.h b/nsframework/framework_unified/client/NS_Timer/include/ns_timer_internal.h
new file mode 100644
index 00000000..43418a22
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/include/ns_timer_internal.h
@@ -0,0 +1,28 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSTimer
+/// \brief Contains the internal APIs that used by NS_Timer
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_TIMER_INCLUDE_NS_TIMER_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_TIMER_INCLUDE_NS_TIMER_INTERNAL_H_
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_TIMER_INCLUDE_NS_TIMER_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_Timer/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_Timer/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..b3eb74da
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/src/makefile_PosixBasedOS001
@@ -0,0 +1,206 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_Timer
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_Timer
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(PRJ_ROOT)../$(COMPONENT_NAME)/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+ifdef DYNAMIC
+ DYNAMIC_LIBS += \
+ NS_MessageCenter$(DEBUG_EXT)
+else
+ STATIC_LIBS +=
+endif
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_Timer/src/mod_version.c b/nsframework/framework_unified/client/NS_Timer/src/mod_version.c
new file mode 100644
index 00000000..c6e28eb5
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/src/mod_version.c
@@ -0,0 +1,51 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_ModVersion
+/// \brief Identifies module version
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <native_service/frameworkunified_types.h>
+
+#define MOD_VERSION_LENGTH 12
+
+
+
+static CHAR s_ModVersion[MOD_VERSION_LENGTH + 1] = "0.0.0";
+
+SI_8 GetModuleVersion(CHAR *pRetBuf, UI_8 nBufLen) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ UI_8 CopyLen = 0;
+ SI_8 RetVal = -1;
+
+ if (NULL != pRetBuf) {
+ CopyLen = MIN_VAL(nBufLen, MOD_VERSION_LENGTH);
+ strncpy(pRetBuf, s_ModVersion, CopyLen);
+ pRetBuf[CopyLen] = '\0';
+ RetVal = 0;
+ }
+ return RetVal;
+}
+// LCOV_EXCL_STOP
+
diff --git a/nsframework/framework_unified/client/NS_Timer/src/ns_timer.c b/nsframework/framework_unified/client/NS_Timer/src/ns_timer.c
new file mode 100644
index 00000000..d24264b1
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/src/ns_timer.c
@@ -0,0 +1,514 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSTimer
+/// \brief Native Services Timer Interface code
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <unistd.h>
+#include <string.h>
+#include <malloc.h>
+#include <errno.h>
+#include <sys/epoll.h>
+#include <sys/eventfd.h>
+#include <sys/timerfd.h>
+#include <sys/prctl.h>
+
+#include <native_service/ns_timer_if.h>
+#include <ns_timer_handle.h>
+#include <native_service/ns_message_center_if.h>
+#include <ns_timer_internal.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_resource_controler.h>
+
+#define INVALID_TIMERFD -1
+
+#define RUNNING_STATE 0
+#define DELETING_STATE 1
+#define DELETED_STATE 2
+
+#define MAX_FD_EPOLL 10
+
+int epollFd; // To listen to multiple timerfd events.
+int eventFd; // To use not complete at epoll_wait
+pthread_t timerTh_id = 0; // Thread ID of the TimerMonitoringThread
+pthread_mutex_t m_mtx = PTHREAD_MUTEX_INITIALIZER;
+
+const UI_32 MS_IN_SEC = 1000;
+const UI_64 NS_IN_MS = 1000000;
+
+BOOL DebugFlag = FALSE;
+
+static PVOID TimerMonitoringThread(PVOID args) {
+ struct epoll_event events[MAX_FD_EPOLL];
+ int nfds; // The number of events received
+ int n; // Loop counter
+ PNSTimerHandle hTimer;
+ char *p, name[32];
+ uint64_t exp;
+
+ // Thread naming
+#define NSTIMER_APPEND_NAME "_T"
+#ifndef NSTIMER_SIZE_PROCESSNAME
+#define NSTIMER_SIZE_PROCESSNAME 15 // Profiler analysis tool name length limitations
+#endif
+ prctl(PR_GET_NAME, name);
+ name[NSTIMER_SIZE_PROCESSNAME] = '\0';
+ if (strlen(name) + strlen(NSTIMER_APPEND_NAME) > NSTIMER_SIZE_PROCESSNAME) {
+ p = name + NSTIMER_SIZE_PROCESSNAME - strlen(NSTIMER_APPEND_NAME);
+ } else {
+ p = name + strlen(name);
+ }
+ strcpy(p, NSTIMER_APPEND_NAME);
+ prctl(PR_SET_NAME, name);
+
+ for (;;) {
+ nfds = epoll_wait(epollFd, events, MAX_FD_EPOLL, -1);
+ if (-1 != nfds) {
+ for (n = 0; n < nfds; ++n) {
+ hTimer = (PNSTimerHandle)events[n].data.ptr;
+ if (NULL != hTimer) {
+ if (-1 == read(hTimer->timerfd, &exp, sizeof(uint64_t))) {
+ if (errno != EAGAIN) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Failed to read in timeout : fd=%d, errno=%d",
+ hTimer->timerfd, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ continue;
+ }
+
+ if (RUNNING_STATE == hTimer->timerState) {
+ if (NULL != hTimer->tTimerInfo) {
+ EFrameworkunifiedStatus eStatus;
+ HANDLE hReceiver = NULL;
+ if (frameworkunifiedAcquireResouce(FRAMEWORKUNIFIED_RES_TIMER, hTimer->tTimerInfo->q_name, (long *)&hReceiver) < 0) {
+ if ((hReceiver = McOpenSender(hTimer->tTimerInfo->q_name)) == NULL) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : McOpenSender is Failed");
+ // LCOV_EXCL_BR_STOP
+ continue;
+ } else {
+ if (frameworkunifiedRegistResouce(FRAMEWORKUNIFIED_RES_TIMER, hTimer->tTimerInfo->q_name, (long)hReceiver, 1) < 0) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : frameworkunifiedRegistResouce is Failed : q_name=%s",
+ hTimer->tTimerInfo->q_name);
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ }
+
+ eStatus = McSendWithPriority(hReceiver,
+ TIMER_QUE,
+ hTimer->tTimerInfo->iCmd,
+ 0,
+ NULL,
+ eFrameworkunifiedMsgPrioEmergency,
+ 0);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : McSendWithPriority to %s is Failed, eStatus=%d", hTimer->tTimerInfo->q_name,
+ eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR(RUNNING_STATE) : tTimerInfo is NULL");
+ // LCOV_EXCL_BR_STOP
+ }
+ } else if (DELETED_STATE == hTimer->timerState) {
+ if (-1 == epoll_ctl(epollFd, EPOLL_CTL_DEL, hTimer->timerfd, events)) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(DEL) Failed, fd=%d, errno=%d",
+ hTimer->timerfd, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ if (-1 == close(hTimer->timerfd)) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : close(fd=%d) Failed, errno=%d", hTimer->timerfd, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ hTimer->timerfd = INVALID_TIMERFD;
+
+ if (NULL != hTimer->tTimerInfo) {
+ HANDLE hReceiver;
+ if (frameworkunifiedAcquireResouce(FRAMEWORKUNIFIED_RES_TIMER, hTimer->tTimerInfo->q_name, (long *)&hReceiver) >= 0) {
+ if (frameworkunifiedReleaseResouce(FRAMEWORKUNIFIED_RES_TIMER, hTimer->tTimerInfo->q_name) <= 0) {
+ frameworkunifiedUnregistResouce(FRAMEWORKUNIFIED_RES_TIMER, hTimer->tTimerInfo->q_name);
+ McClose(hReceiver);
+ }
+ }
+ free(hTimer->tTimerInfo->q_name);
+ free(hTimer->tTimerInfo); // delete the timer info
+ hTimer->tTimerInfo = NULL;
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR(DELETED_STATE) : tTimerInfo is NULL");
+ // LCOV_EXCL_BR_STOP
+ }
+
+ free(hTimer); // delete the handle
+ events[n].data.ptr = NULL;
+ } else {
+ // do nothing
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : hTimer is NULL");
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ } else {
+ if (errno == EINTR) {
+ // signal interrupt
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_wait Failed, errno=%d", errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ }
+ }
+ return NULL;
+}
+
+static EFrameworkunifiedStatus CreateTimerMonitoringThread() {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ struct epoll_event ev; // Info struct to associate with multiwaiting FD
+ int ret;
+
+ pthread_mutex_lock(&m_mtx);
+
+ // Create the TimerMonitoringThread If the thread has not been generated.
+ if (0 == timerTh_id) {
+ epollFd = epoll_create1(EPOLL_CLOEXEC);
+ if (-1 != epollFd) {
+ eventFd = eventfd(0, EFD_CLOEXEC);
+ if (-1 != eventFd) {
+ ev.events = EPOLLIN;
+ ev.data.fd = eventFd;
+ if (-1 != epoll_ctl(epollFd, EPOLL_CTL_ADD, eventFd, &ev)) {
+ if (0 != (ret = pthread_create(&timerTh_id, NULL, TimerMonitoringThread, NULL))) {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Failed to pthread_create : errno %d", ret);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(eventFd=%d, ADD) Failed, status=%d, errno=%d", eventFd, eStatus,
+ errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR :eventfd Failed, status=%d, errno=%d", eStatus, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_create1 Failed, status=%d, errno=%d",
+ eStatus, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ }
+
+ if (TRUE == DebugFlag) { // LCOV_EXCL_BR_LINE 7: debug code
+ // LCOV_EXCL_START 7: debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "[DEBUG] sleep 3 Sec START.");
+ sleep(3);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "[DEBUG] sleep 3 Sec END.");
+ // LCOV_EXCL_STOP
+ }
+ pthread_mutex_unlock(&m_mtx);
+
+ return eStatus;
+}
+
+HANDLE NS_TimerCreate(NSTimerInfo timer_info, eNSTimerCallbackMechanism cbMech, HANDLE sndMqHndl) {
+ PNSTimerHandle hTimer = NULL;
+
+ if ((NULL != sndMqHndl) && (cbMech == CALLBACK_MESSAGE)) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ PTimerInfo pTimerInfo = NULL;
+ struct epoll_event ev; // Info struct to associate with multiwaiting FD
+ int timerfd = INVALID_TIMERFD;
+
+ eStatus = CreateTimerMonitoringThread();
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ hTimer = (PNSTimerHandle)malloc(sizeof(NSTimerHandle));
+ if (NULL != hTimer) { // LCOV_EXCL_BR_LINE 5: malloc's error case
+ pTimerInfo = (PTimerInfo)malloc(sizeof(TTimerInfo));
+
+ if (NULL != pTimerInfo) { // LCOV_EXCL_BR_LINE 5: malloc's error case
+ hTimer->timerState = RUNNING_STATE;
+
+ // set the timer info structure
+ PCSTR pName = McGetQueueName(sndMqHndl);
+ if (NULL != pName) {
+ pTimerInfo->q_name = strdup(pName);
+ } else {
+ pTimerInfo->q_name = NULL;
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : McGetQueueName(sndMqHndl) Failed, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ pTimerInfo->iCmd = timer_info.iCmd;
+
+ hTimer->tTimerInfo = pTimerInfo;
+ if (INVALID_TIMERFD != (timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC|TFD_NONBLOCK))) {
+ ev.events = EPOLLIN;
+ ev.data.ptr = hTimer;
+ if (-1 != epoll_ctl(epollFd, EPOLL_CTL_ADD, timerfd, &ev)) {
+ hTimer->timerfd = timerfd;
+ if (eFrameworkunifiedStatusOK == NS_TimerSetTime(hTimer, timer_info)) {
+ // set the interval in timer handle
+ hTimer->itime.it_value.tv_sec = (__time_t)timer_info.t_sec;
+ hTimer->itime.it_value.tv_nsec = (__syscall_slong_t)timer_info.t_nsec;
+ hTimer->itime.it_interval.tv_sec = (__time_t)timer_info.rpt_sec;
+ hTimer->itime.it_interval.tv_nsec = (__syscall_slong_t)timer_info.rpt_nsec;
+
+ } else {
+ eStatus = eFrameworkunifiedStatusErrOther;
+
+ // if timer interval is not set or memory is not allocated for hTimer
+ close(timerfd);
+ timerfd = INVALID_TIMERFD;
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : epoll_ctl(timerfd=%d, ADD) Failed, status=%d, errno=%d", timerfd, eStatus,
+ errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusErrOther;
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : (PTimerInfo)malloc(sizeof(TTimerInfo)) Failed, status=%d", eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ if (NULL != pTimerInfo) {
+ if (NULL != pTimerInfo->q_name) {
+ free(pTimerInfo->q_name);
+ pTimerInfo->q_name = NULL;
+ }
+
+ free(pTimerInfo);
+ pTimerInfo = NULL;
+ }
+
+ if (NULL != hTimer) {
+ free(hTimer);
+ hTimer = NULL;
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : malloc(sizeof(NSTimerHandle)) Failed");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : CreateTimerMonitoringThread Failed, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Invalid param");
+ // LCOV_EXCL_BR_STOP
+ }
+
+ return hTimer;
+}
+
+EFrameworkunifiedStatus NS_TimerDelete(HANDLE hTimer) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (NULL != hTimer) {
+ PNSTimerHandle tTimerHndl = (PNSTimerHandle)hTimer;
+ /**
+ * @todo
+ * Dropping by typing the service handle instead of the timer handle
+ */
+ if (DELETED_STATE != tTimerHndl->timerState) {
+ if (NULL != tTimerHndl->tTimerInfo) {
+ tTimerHndl->timerState = DELETING_STATE;
+ NSTimerInfo timer_info = {1, 0, tTimerHndl->tTimerInfo->iCmd, 0, 0};
+
+ if (eFrameworkunifiedStatusOK != (eStatus = NS_TimerSetTime(tTimerHndl, timer_info))) {
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "ERROR : NS_TimerSetTime for Timer delete Failed, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ tTimerHndl->timerState = DELETED_STATE;
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : tTimerInfo is NULL, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Timer is not RUNNING State, timerStatus=%d, status=%d",
+ tTimerHndl->timerState, eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : hTimer is NULL, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus NS_TimerSetTime(HANDLE hTimer, NSTimerInfo timer_info) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hTimer) {
+ PNSTimerHandle tTimerHndl = (PNSTimerHandle)hTimer;
+ struct itimerspec itime;
+
+ if (DELETED_STATE != tTimerHndl->timerState) {
+ // set periodic interval values
+ itime.it_value.tv_sec = (__time_t)timer_info.t_sec;
+ itime.it_value.tv_nsec = (__syscall_slong_t)timer_info.t_nsec;
+
+ // set periodic interval values
+ itime.it_interval.tv_sec = (__time_t)timer_info.rpt_sec;
+ itime.it_interval.tv_nsec = (__syscall_slong_t)timer_info.rpt_nsec;
+
+ if (-1 != timerfd_settime(tTimerHndl->timerfd, 0, &itime, NULL)) {
+ // updated the value of the timer values in the handler
+ tTimerHndl->itime = itime;
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : timerfd_settime is failed, status=%d, errno=%d", eStatus, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Timer is not RUNNING State, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : hTimer is NULL, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus NS_TimerGetTime(HANDLE hTimer, NSTimerInfo *timer_info) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if ((NULL != hTimer) && (NULL != timer_info)) {
+ PNSTimerHandle tTimerHndl = (PNSTimerHandle)hTimer;
+ struct itimerspec itime;
+
+ if (DELETED_STATE != tTimerHndl->timerState) {
+ if (-1 != timerfd_gettime(tTimerHndl->timerfd, &itime)) {
+ // set periodic interval values
+
+// timer_info->t_sec = (UI_32)itime.it_value.tv_sec;
+ timer_info->t_sec = itime.it_value.tv_sec;
+ timer_info->t_nsec = (UI_64)itime.it_value.tv_nsec;
+
+ // set periodic interval values
+
+// timer_info->rpt_sec = (UI_32)itime.it_interval.tv_sec;
+ timer_info->rpt_sec = itime.it_interval.tv_sec;
+ timer_info->rpt_nsec = (UI_64)itime.it_interval.tv_nsec;
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : timerfd_gettime is failed, status=%d, errno=%d", eStatus, errno);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Timer is not RUNNING State, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "ERROR : Invalid param, status=%d", eStatus);
+ // LCOV_EXCL_BR_STOP
+ }
+
+ return eStatus;
+}
+
+
+//UI_32 WholeSeconds(UI_32 ms) {
+// return ms / MS_IN_SEC;
+//}
+time_t WholeSeconds(UI_32 ms) {
+ return (time_t)(ms / MS_IN_SEC);
+}
+
+
+UI_32 RemainderMs(UI_32 ms) {
+ return ms % MS_IN_SEC;
+}
+
+UI_64 MSToNS(UI_32 ms) {
+ return (UI_64)ms * NS_IN_MS;
+}
+
+void NS_TimerDebugOn(BOOL FlagState) { // LCOV_EXCL_START 7: debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (DebugFlag != FlagState) {
+ DebugFlag = FlagState;
+ if (TRUE == DebugFlag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "NS_Timer debugging is enabled.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_IMP_INFO, __FUNCTION__, "NS_Timer debugging is disabled.");
+ }
+ }
+}
+// LCOV_EXCL_STOP
diff --git a/nsframework/framework_unified/client/NS_Timer/src/ns_timer_class.cpp b/nsframework/framework_unified/client/NS_Timer/src/ns_timer_class.cpp
new file mode 100644
index 00000000..47b41e9a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Timer/src/ns_timer_class.cpp
@@ -0,0 +1,177 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSTimer
+/// \brief
+///
+/// Timer class for setting timers.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns_timer_if.hpp>
+#include <native_service/ns_message_center_if.h>
+#include <string.h>
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// Constructor
+//////////////////////////////////////////////////////////////////////////////////////////////
+NSTimer::NSTimer():
+ m_hTimer(NULL),
+ m_u64TimeInterval(0),
+ m_bRepeatTimer(FALSE) {
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// Destructor
+//////////////////////////////////////////////////////////////////////////////////////////////
+NSTimer::~NSTimer() {
+ if (NULL != m_hTimer) {
+ NS_TimerDelete(m_hTimer);
+ m_hTimer = NULL;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// SetNotifyMethod
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSTimer::SetNotifyMethod(UI_16 notifyCmdId, PCSTR notifyToAppName) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ NSTimerInfo l_tTimerInfo = {};
+
+ if ((NULL != notifyToAppName) && (strlen(notifyToAppName) <= MAX_SERVICE_NAME)) {
+ HANDLE l_hSenderHandle = McOpenSender(notifyToAppName);
+
+ if (NULL != l_hSenderHandle) { // reset previous notify method, and set new
+ // resets previous timer timeout action if any
+ if (NULL != m_hTimer) {
+ NS_TimerDelete(m_hTimer);
+ m_hTimer = NULL;
+ }
+
+ l_tTimerInfo.iCmd = notifyCmdId;
+ // Create timer. Do not start.
+ if (NULL == (m_hTimer = NS_TimerCreate(l_tTimerInfo, CALLBACK_MESSAGE, l_hSenderHandle))) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ McClose(l_hSenderHandle);
+ } else {
+ // just return fail. Don't reset any previous notify method
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// SetRepeatTimer
+//////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSTimer::SetRepeatTimer(BOOL repeatTimer) {
+ m_bRepeatTimer = repeatTimer;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// SetTime
+//////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSTimer::SetTime(UI_32 seconds, UI_64 msecs) {
+ m_u64TimeInterval = msecs + seconds * 1000ULL; // internally, set interval as milliseconds
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// SetTime
+//////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSTimer::SetTime(UI_32 hrs, UI_32 mins, UI_32 seconds, UI_64 msecs) {
+ // internally, set interval as milliseconds
+ m_u64TimeInterval = msecs + seconds * 1000ULL + mins * 60000ULL + hrs * 3600000ULL;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// Start
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSTimer::Start(UI_32 seconds, UI_64 msecs) {
+ this->SetTime(seconds, msecs);
+ return (this->Start());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// Start
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSTimer::Start() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (NULL != m_hTimer) {
+ NSTimerInfo l_tTimerInfo = {};
+
+ l_tTimerInfo.t_sec = WholeSeconds(static_cast<UI_32>(m_u64TimeInterval)); /// Converts to seconds
+ l_tTimerInfo.t_nsec = MSToNS(RemainderMs(static_cast<UI_32>(m_u64TimeInterval))); /// Converts to nano seconds
+
+ if (TRUE == m_bRepeatTimer) {
+ l_tTimerInfo.rpt_sec = l_tTimerInfo.t_sec;
+ l_tTimerInfo.rpt_nsec = l_tTimerInfo.t_nsec;
+ }
+ l_eStatus = NS_TimerSetTime(m_hTimer, l_tTimerInfo);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// Stop
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSTimer::Stop() {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_hTimer) {
+ NSTimerInfo l_tTimerInfo = {};
+ l_eStatus = NS_TimerSetTime(m_hTimer, l_tTimerInfo);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// IsRunning
+//////////////////////////////////////////////////////////////////////////////////////////////
+BOOL NSTimer::IsRunning() {
+ BOOL l_bIsRunning = FALSE;
+
+ if (NULL != m_hTimer) {
+ NSTimerInfo l_tTimerInfo = {};
+ NS_TimerGetTime(m_hTimer, &l_tTimerInfo);
+ if ((0 != l_tTimerInfo.t_sec) || (0 != l_tTimerInfo.t_nsec) || (0 != l_tTimerInfo.rpt_sec) ||
+ (0 != l_tTimerInfo.rpt_nsec)) {
+ l_bIsRunning = TRUE;
+ }
+ }
+ return l_bIsRunning;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///// GetInterval
+//////////////////////////////////////////////////////////////////////////////////////////////
+UI_64 NSTimer::GetInterval() {
+ return m_u64TimeInterval;
+}
+
+// EOF
diff --git a/nsframework/framework_unified/client/NS_Utility/Makefile b/nsframework/framework_unified/client/NS_Utility/Makefile
new file mode 100644
index 00000000..2f4dfef6
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Utility/Makefile
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS = buildversioncheck
+
+include ../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_Utility/buildversioncheck/Makefile b/nsframework/framework_unified/client/NS_Utility/buildversioncheck/Makefile
new file mode 100644
index 00000000..03ca87c1
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Utility/buildversioncheck/Makefile
@@ -0,0 +1,21 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := library
+
+
+
+include ../../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/Makefile b/nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/Makefile
new file mode 100644
index 00000000..e1b0a6d5
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/Makefile
@@ -0,0 +1,62 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+
+
+######### installed library(*.a) #############
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libNS_BuildVersionCheck
+
+######### install headers(*.h) #############
+
+######### compiled sources #############
+libNS_BuildVersionCheck_SRCS = NS_BuildVersionCheck.cpp
+
+######### add source path #############
+VPATH += ./src
+
+######### add include path #############
+CPPFLAGS += -I./../../../include/
+
+######### add compile option #############
+CPPFLAGS += -DLINUX -fdata-sections -ffunction-sections -DFLG_LEGACY
+
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+CPPFLAGS += -DBUILD_VERSION=PastModel002_stable_c1_I20130701-0000
+
+CPPFLAGS += -Wl,--no-undefined
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+LDFLAGS += -Wl,--no-as-needed
+LDFLAGS += -g -Wl,--gc-sections -shared
+
+LDLIBS += -Wl,-Bdynamic -lstdc++
+
+######### linked library #############
+
+######### linked library (dynamic) #############
+
+######### add library path #############
+
+include ../../../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/src/NS_BuildVersionCheck.cpp b/nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/src/NS_BuildVersionCheck.cpp
new file mode 100644
index 00000000..633797bf
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_Utility/buildversioncheck/library/src/NS_BuildVersionCheck.cpp
@@ -0,0 +1,85 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// Interfaces
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_buildversioncheck.hpp>
+#include <cstdlib>
+#include <cstring>
+
+namespace {
+
+namespace frameworkunified_ns_bvc {
+
+const UI_32 kMaxBuildVersionLength = 32;
+PCSTR g_build_version_env_var_name = "BUILD_VERSION";
+PCSTR g_build_version = _BUILD_VERSION; // Should be defined when library is built
+
+bool isEmptyString(PCSTR str) { // NOLINT (readability/nolint)
+ return 0 == std::strncmp("", str, 1);
+}
+
+} // namespace frameworkunified_ns_bvc
+
+} // namespace
+
+namespace frameworkunified {
+
+namespace ns {
+
+namespace utility {
+
+BOOL buildVersionsMatch(PCSTR build_version) { // NOLINT (readability/nolint)
+ PCSTR env_build_version = getEnvironmentBuildVersion();
+ PCSTR lib_build_version = getLibraryBuildVersion();
+ return 0 == std::strncmp(env_build_version, build_version, frameworkunified_ns_bvc::kMaxBuildVersionLength) &&
+ 0 == std::strncmp(lib_build_version, build_version, frameworkunified_ns_bvc::kMaxBuildVersionLength) &&
+ !frameworkunified_ns_bvc::isEmptyString(build_version) &&
+ !frameworkunified_ns_bvc::isEmptyString(env_build_version) &&
+ !frameworkunified_ns_bvc::isEmptyString(lib_build_version);
+}
+
+PCSTR getEnvironmentBuildVersion() { // NOLINT (readability/nolint)
+ static PCSTR env_version = std::getenv(frameworkunified_ns_bvc::g_build_version_env_var_name);
+ return env_version != NULL ? env_version : "";
+}
+
+PCSTR getLibraryBuildVersion() { // NOLINT (readability/nolint)
+ return frameworkunified_ns_bvc::g_build_version;
+}
+
+namespace utility_private {
+
+PCSTR niceBuildVersion(PCSTR build_version) { // NOLINT (readability/nolint)
+ return frameworkunified_ns_bvc::isEmptyString(build_version) ? "<Not defined>" : build_version;
+}
+
+} // namespace utility_private
+
+} // namespace utility
+
+} // namespace ns
+
+} // namespace frameworkunified
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/cfg/depends.mk b/nsframework/framework_unified/client/NS_UtilityCenter/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_if_internal.h b/nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_if_internal.h
new file mode 100644
index 00000000..fc0b7616
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_if_internal.h
@@ -0,0 +1,193 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief This file contains declaration of common APIs for NS_UtilityCenter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_utility_if_internal.h
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_UTILITYCENTER_INCLUDE_NS_UTILITY_IF_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_UTILITYCENTER_INCLUDE_NS_UTILITY_IF_INTERNAL_H_
+
+#include <native_service/frameworkunified_types.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the number of leading zeros in a given 16bit value.
+/// \~english @param [in] f_ui_val
+/// UI_16 - the value to be counted
+/// \~english @retval the number of leading zeros
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the number of leading zeros in a given 16bit value.
+/// \~english @see NS_CountLeadingZeros_32Bit NS_CountLeadingZeros_64Bit
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 NS_CountLeadingZeros_16Bit(UI_16 f_ui_val); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the number of leading zeros in a given 32bit value.
+/// \~english @param [in] f_ui_val
+/// UI_32 - the value to be counted
+/// \~english @retval the number of leading zeros
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the number of leading zeros in a given 32bit value.
+/// \~english @see NS_CountLeadingZeros_16Bit NS_CountLeadingZeros_64Bit
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 NS_CountLeadingZeros_32Bit(UI_32 f_ui_val); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the number of leading zeros in a given 64bit value.
+/// \~english @param [in] f_ui_val
+/// UI_64 - the value to be counted
+/// \~english @retval the number of leading zeros
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the number of leading zeros in a given 64bit value.
+/// \~english @see NS_CountLeadingZeros_16Bit NS_CountLeadingZeros_32Bit
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 NS_CountLeadingZeros_64Bit(UI_64 f_ui_val); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the number of trailing zeros in a given 16bit value.
+/// \~english @param [in] f_ui_val
+/// UI_16 - the value to be counted
+/// \~english @retval the number of trailing zeros
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the number of trailing zeros in a given 16bit value.
+/// \~english @see NS_CountTrailingZeros_32Bit NS_CountTrailingZeros_64Bit
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 NS_CountTrailingZeros_16Bit(UI_16 f_ui_val); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the number of trailing zeros in a given 32bit value.
+/// \~english @param [in] f_ui_val
+/// UI_32 - the value to be counted
+/// \~english @retval the number of trailing zeros
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the number of trailing zeros in a given 32bit value.
+/// \~english @see NS_CountTrailingZeros_16Bit NS_CountTrailingZeros_64Bit
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 NS_CountTrailingZeros_32Bit(UI_32 f_ui_val); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the number of trailing zeros in a given 64bit value.
+/// \~english @param [in] f_ui_val
+/// UI_64 - the value to be counted
+/// \~english @retval the number of trailing zeros
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the number of trailing zeros in a given 64bit value.
+/// \~english @see NS_CountTrailingZeros_16Bit NS_CountTrailingZeros_32Bit
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 NS_CountTrailingZeros_64Bit(UI_64 f_ui_val); // NOLINT (readability/nolint)
+
+/** @}*/ // end of framework_unified
+
+/** @}*/ // end of native_service
+
+/** @}*/ // end of BaseSystem
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_UTILITYCENTER_INCLUDE_NS_UTILITY_IF_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_sys_internal.hpp b/nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_sys_internal.hpp
new file mode 100644
index 00000000..8c71ace2
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/include/ns_utility_sys_internal.hpp
@@ -0,0 +1,353 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// @file ns_utility_sys_internal.hpp
+/// @brief This file contains declaration of common APIs for NS_UtilityCenter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_UTILITYCENTER_INCLUDE_NS_UTILITY_SYS_INTERNAL_HPP_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_UTILITYCENTER_INCLUDE_NS_UTILITY_SYS_INTERNAL_HPP_
+
+#include <native_service/frameworkunified_types.h>
+#include <pthread.h>
+#include <errno.h>
+
+#include <native_service/ns_utility.hpp>
+
+UI_32 utility_sys_rand(); // NOLINT (readability/nolint)
+
+// Random Functions //////////////////////////////////////////////////////////
+
+template< class T>
+T randomValue(T min, T max) {
+ const int32_t lmin = static_cast< int32_t >(min);
+ const int32_t range = static_cast< int32_t >(max) - lmin + 1;
+ if (range > 0) {
+ return static_cast< T >(utility_sys_rand() % range + lmin);
+ } else {
+ return min;
+ }
+}
+
+template< class T, UI_32 N >
+T randomItem(const T(&arr)[ N ]) {
+ return arr[ randomValue< UI_32 >(0, N - 1) ];
+}
+
+
+template< class T, class Lock > class CLockedData;
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &, // NOLINT (readability/nolint)
+ typename FSig< Fn >::TArg2); // NOLINT (readability/nolint)
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5,
+ typename FSig< Fn >::TArg6);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5,
+ typename FSig< Fn >::TArg6, typename FSig< Fn >::TArg7);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &); // NOLINT (readability/nolint)
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5,
+ typename FSig< Fn >::TArg6);
+template< class T, class Lock, class Fn > typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T, Lock > &,
+ typename FSig< Fn >::TArg2, typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5,
+ typename FSig< Fn >::TArg6, typename FSig< Fn >::TArg7);
+
+
+template< class T, class Lock >
+class CWithReadLock {
+ public:
+ typedef const T TData;
+
+ CWithReadLock(CLockedData< T, Lock > &);
+ ~CWithReadLock();
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5, typename FSig< Fn >::TArg6);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithReadLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5, typename FSig< Fn >::TArg6,
+ typename FSig< Fn >::TArg7);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CWithReadLock);
+
+ const TData &data() const; // NOLINT (readability/nolint)
+ CLockedData< T, Lock > &m_LockedData;
+};
+
+template< class T, class Lock >
+class CWithWriteLock {
+ public:
+ typedef T TData;
+
+ CWithWriteLock(CLockedData< T, Lock > &);
+ ~CWithWriteLock();
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5, typename FSig< Fn >::TArg6);
+
+ template< class T1, class Lock1, class Fn >
+ friend typename FSig< Fn >::RType WithWriteLock(Fn, CLockedData< T1, Lock1 > &, typename FSig< Fn >::TArg2,
+ typename FSig< Fn >::TArg3, typename FSig< Fn >::TArg4, typename FSig< Fn >::TArg5, typename FSig< Fn >::TArg6,
+ typename FSig< Fn >::TArg7);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CWithWriteLock);
+
+ TData &data(); // NOLINT (readability/nolint)
+ CLockedData< T, Lock > &m_LockedData;
+};
+
+/// \brief Represents a piece of data protected by a lock
+///
+/// Data wrapped with Can only be accessed using helper functions
+/// WithReadLock and WithWriteLock
+///
+/// Example usage:
+///
+/// void ModifySharedData( int& n ) { ... modify n ... };
+/// int ReadSharedData( const int& n ){ ... read n ... };
+///
+/// void DoSomething()
+/// {
+/// CLocked< int > my_data( -1 ); // initialize value to -1
+/// WithWriteLock( ModifySharedData, my_data );
+/// int val = WithReadLock( ReadSharedData, my_data );
+/// }
+///
+/// NOTE: that data is locked for the duration of the time that helper functions
+/// ModifySharedData, and ReadSharedData are called - once they return, the data becomes
+/// unlocked automatically.
+template< class T, class Lock = CMutex >
+class CLockedData {
+ public:
+ typedef CWithReadLock< T, Lock > TReadLock;
+ typedef CWithWriteLock< T, Lock > TWriteLock;
+
+ CLockedData() {}
+ template< class T1 > CLockedData(T1 t1) : m_data(t1) {}
+ template< class T1, class T2 > CLockedData(T1 t1, T2 t2) : m_data(t1, t2) {}
+ template< class T1, class T2, class T3 > CLockedData(T1 t1, T2 t2, T3 t3) : m_data(t1, t2, t3) {}
+ template< class T1, class T2, class T3, class T4 > CLockedData(T1 t1, T2 t2, T3 t3, T4 t4) : m_data(t1, t2, t3,
+ t4) {}
+ template< class T1, class T2, class T3, class T4, class T5 > CLockedData(T1 t1, T2 t2, T3 t3, T4 t4,
+ T5 t5) : m_data(t1, t2, t3, t4, t5) {}
+ template< class T1, class T2, class T3, class T4, class T5, class T6 > CLockedData(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5,
+ T6 t6) : m_data(t1, t2, t3, t4, t5, t6) {}
+ template< class T1, class T2, class T3, class T4, class T5, class T6, class T7 > CLockedData(T1 t1, T2 t2, T3 t3,
+ T4 t4, T5 t5, T6 t6, T7 t7) : m_data(t1, t2, t3, t4, t5, t6, t7) {}
+
+ friend class CWithReadLock< T, Lock >;
+ friend class CWithWriteLock< T, Lock >;
+
+ private:
+ T m_data;
+ Lock m_lock;
+};
+
+// CWithReadLock and CWithWriteLock implementation //////////////////////////////////////////////
+
+template< class T, class Lock >
+CWithReadLock< T, Lock >::CWithReadLock(CLockedData< T, Lock > &ld) : m_LockedData(ld) {
+ m_LockedData.m_lock.ReadLock();
+}
+
+template< class T, class Lock >
+CWithReadLock< T, Lock >::~CWithReadLock() {
+ m_LockedData.m_lock.Unlock();
+}
+
+template< class T, class Lock >
+const typename CWithReadLock< T, Lock >::TData &CWithReadLock< T, Lock >::data() const { // NOLINT (readability/nolint)
+ return m_LockedData.m_data;
+}
+
+template< class T, class Lock >
+CWithWriteLock< T, Lock >::CWithWriteLock(CLockedData< T, Lock > &ld) : m_LockedData(ld) {
+ m_LockedData.m_lock.WriteLock();
+}
+
+template< class T, class Lock >
+CWithWriteLock< T, Lock >::~CWithWriteLock() {
+ m_LockedData.m_lock.Unlock();
+}
+
+template< class T, class Lock >
+typename CWithWriteLock< T, Lock >::TData &CWithWriteLock< T, Lock >::data() { // NOLINT (readability/nolint)
+ return m_LockedData.m_data;
+}
+
+// WithReadLock / WithWriteLock ///////////////////////////////////////////////
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data());
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data(), t2);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data(), t2, t3);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data(), t2, t3, t4);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4, typename FSig< Fn >::TArg5 t5) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data(), t2, t3, t4, t5);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4, typename FSig< Fn >::TArg5 t5,
+ typename FSig< Fn >::TArg6 t6) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data(), t2, t3, t4, t5, t6);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithReadLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4, typename FSig< Fn >::TArg5 t5,
+ typename FSig< Fn >::TArg6 t6, typename FSig< Fn >::TArg7 t7) {
+ typename CLockedData< T, Lock >::TReadLock rl(data);
+ return f(rl.data(), t2, t3, t4, t5, t6, t7);
+}
+
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data());
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data(), t2);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data(), t2, t3);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data(), t2, t3, t4);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4, typename FSig< Fn >::TArg5 t5) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data(), t2, t3, t4, t5);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4, typename FSig< Fn >::TArg5 t5,
+ typename FSig< Fn >::TArg6 t6) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data(), t2, t3, t4, t5, t6);
+}
+
+template< class T, class Lock, class Fn >
+typename FSig< Fn >::RType WithWriteLock(Fn f, CLockedData< T, Lock > &data, typename FSig< Fn >::TArg2 t2,
+ typename FSig< Fn >::TArg3 t3, typename FSig< Fn >::TArg4 t4, typename FSig< Fn >::TArg5 t5,
+ typename FSig< Fn >::TArg6 t6, typename FSig< Fn >::TArg7 t7) {
+ typename CLockedData< T, Lock >::TWriteLock wl(data);
+ return f(wl.data(), t2, t3, t4, t5, t6, t7);
+}
+
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_UTILITYCENTER_INCLUDE_NS_UTILITY_SYS_INTERNAL_HPP_
+//@}
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/src/frameworkunified_version.cpp b/nsframework/framework_unified/client/NS_UtilityCenter/src/frameworkunified_version.cpp
new file mode 100644
index 00000000..3ee907f3
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/src/frameworkunified_version.cpp
@@ -0,0 +1,236 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NativeServices
+/// \brief Implementation of CFrameworkunifiedVersion class
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns_version_if.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <time.h>
+#include <string>
+
+
+// defaults - top level makefile for entire system will provide an override
+#ifndef FRAMEWORKUNIFIED_SIGNATURE
+#define FRAMEWORKUNIFIED_SIGNATURE 0xE0344333
+#endif
+
+#ifndef FRAMEWORKUNIFIED_STRUC_VER
+#define FRAMEWORKUNIFIED_STRUC_VER 0x02
+#endif
+
+#ifndef FRAMEWORKUNIFIED_PRODUCT_VER
+#define FRAMEWORKUNIFIED_PRODUCT_VER 0x01
+#endif
+
+#ifndef PRODUCT_LABEL
+#define PRODUCT_LABEL "undefined"
+#endif
+
+#ifndef FRAMEWORKUNIFIED_BUILD_VER
+#define FRAMEWORKUNIFIED_BUILD_VER "undefined"
+#endif
+
+/* For future use */
+#define YEAR ((((__DATE__[7] - '0') * 10 + (__DATE__[8] - '0')) * 10 \
++ (__DATE__[9] - '0')) * 10 + (__DATE__[10] - '0'))
+
+#define MONTH (__DATE__[2] == 'n' ? 0 \
+: __DATE__[2] == 'b' ? 1 \
+: __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 2 : 3) \
+: __DATE__[2] == 'y' ? 4 \
+: __DATE__[2] == 'n' ? 5 \
+: __DATE__[2] == 'l' ? 6 \
+: __DATE__[2] == 'g' ? 7 \
+: __DATE__[2] == 'p' ? 8 \
+: __DATE__[2] == 't' ? 9 \
+: __DATE__[2] == 'v' ? 10 : 11)
+
+#define DAY ((__DATE__[4] == ' ' ? 0 : __DATE__[4] - '0') * 10 \
++ (__DATE__[5] - '0'))
+
+#define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)
+
+#define HOUR (((__TIME__[0] - '0') * 10 + (__TIME__[1] - '0')))
+
+#define MIN (((__TIME__[3] - '0') * 10 + (__TIME__[4] - '0')))
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Default Constructor
+////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedVersion::CFrameworkunifiedVersion():
+ m_tVersionInfo(const_cast<PSTR>(PRODUCT_LABEL),
+ FRAMEWORKUNIFIED_SIGNATURE,
+ FRAMEWORKUNIFIED_STRUC_VER,
+ FRAMEWORKUNIFIED_PRODUCT_VER,
+ DATE_AS_INT,
+ 0,
+ 0,
+ const_cast<PSTR>(FRAMEWORKUNIFIED_BUILD_VER),
+ 0),
+ m_u32Month(MONTH + 1),
+ m_u32Year(YEAR),
+ m_u32Day(DAY) {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Parametrized constructor
+////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedVersion::CFrameworkunifiedVersion(UI_16 major, UI_16 minor, UI_16 revision) :
+ m_tVersionInfo(const_cast<PSTR>(PRODUCT_LABEL),
+ FRAMEWORKUNIFIED_SIGNATURE,
+ FRAMEWORKUNIFIED_STRUC_VER,
+ FRAMEWORKUNIFIED_PRODUCT_VER,
+ DATE_AS_INT,
+ major,
+ minor,
+ const_cast<PSTR>(FRAMEWORKUNIFIED_BUILD_VER),
+ revision),
+ m_u32Month(MONTH + 1),
+ m_u32Year(YEAR),
+ m_u32Day(DAY) {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Destructor
+////////////////////////////////////////////////////////////////////////////////////////////
+CFrameworkunifiedVersion::~CFrameworkunifiedVersion() {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Compares two version instances
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL operator == (CFrameworkunifiedVersion &a, CFrameworkunifiedVersion &b) { // NOLINT (readability/nolint)
+ return a.operator == (b);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Compares two version instances
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFrameworkunifiedVersion::operator == (const CFrameworkunifiedVersion &f_test_i) {
+ if (!strcmp(m_tVersionInfo.p_str_product, f_test_i.m_tVersionInfo.p_str_product) &&
+ !strcmp(m_tVersionInfo.p_str_build, f_test_i.m_tVersionInfo.p_str_build) &&
+ (m_tVersionInfo.u16_major == f_test_i.m_tVersionInfo.u16_major) &&
+ (m_tVersionInfo.u16_minor == f_test_i.m_tVersionInfo.u16_minor) &&
+ (m_tVersionInfo.u16_revision == f_test_i.m_tVersionInfo.u16_revision) &&
+ (m_tVersionInfo.u32_date == f_test_i.m_tVersionInfo.u32_date) &&
+ (m_tVersionInfo.u32_product_version == f_test_i.m_tVersionInfo.u32_product_version) &&
+ (m_tVersionInfo.u32_signature == f_test_i.m_tVersionInfo.u32_signature) &&
+ (m_tVersionInfo.u32_struc_version == f_test_i.m_tVersionInfo.u32_struc_version)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the version string
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR CFrameworkunifiedVersion::VersionStr() {
+ static char version[30] = {};
+
+ snprintf(version, sizeof(version) - 1, "%s_%s_%02d.%02d.%02d",
+ m_tVersionInfo.p_str_product,
+ m_tVersionInfo.p_str_build,
+ m_tVersionInfo.u16_major,
+ m_tVersionInfo.u16_minor,
+ m_tVersionInfo.u16_revision);
+
+ return version;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the date when the new version of the app was created
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR CFrameworkunifiedVersion::DateStr() {
+ static char date[30] = {};
+
+ snprintf(date, sizeof(date) - 1, "%d-%02d-%02d",
+ m_u32Year,
+ m_u32Month,
+ m_u32Day);
+
+ return date;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the Signature
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CFrameworkunifiedVersion::Signature() const {
+ return m_tVersionInfo.u32_signature;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns a new structure version
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CFrameworkunifiedVersion::StrucVersion() const {
+ return m_tVersionInfo.u32_struc_version;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the product version
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CFrameworkunifiedVersion::ProductVersion() const {
+ return m_tVersionInfo.u32_product_version;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the date
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CFrameworkunifiedVersion::Date() const {
+ return m_tVersionInfo.u32_date;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the major number
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_16 CFrameworkunifiedVersion::Major() const {
+ return m_tVersionInfo.u16_major;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the minor number
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_16 CFrameworkunifiedVersion::Minor() const {
+ return m_tVersionInfo.u16_minor;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the unique product identifier
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR CFrameworkunifiedVersion::Product() const {
+ return m_tVersionInfo.p_str_product;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the unique build identifier number
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR CFrameworkunifiedVersion::Build() const {
+ return m_tVersionInfo.p_str_build;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Function: Returns the revision number
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_16 CFrameworkunifiedVersion::Revision() const {
+ return m_tVersionInfo.u16_revision;
+}
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_UtilityCenter/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..14ad4d80
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/src/makefile_PosixBasedOS001
@@ -0,0 +1,194 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_UtilityCenter
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_UtilityCenter
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for utility functions
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(PRJ_ROOT)../$(COMPONENT_NAME)/inc/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_endianess.cpp b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_endianess.cpp
new file mode 100644
index 00000000..3dea53cb
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_endianess.cpp
@@ -0,0 +1,52 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <native_service/ns_endianess.h>
+
+UI_16 ConvertEndian_UI16(UI_16 f_value) { // NOLINT (readability/nolint)
+ UI_16 l_ret = static_cast<UI_16>((f_value << 8) | (f_value >> 8));
+ return l_ret;
+}
+
+
+SI_16 ConvertEndian_SI16(SI_16 f_value) { // NOLINT (readability/nolint)
+ SI_16 l_ret = static_cast<SI_16>((f_value << 8) | ((f_value >> 8) & 0xFF));
+ return l_ret;
+}
+
+
+UI_32 ConvertEndian_UI32(UI_32 f_value) { // NOLINT (readability/nolint)
+ UI_32 l_ret = ((f_value << 8) & 0xFF00FF00) | ((f_value >> 8) & 0xFF00FF);
+ return (l_ret << 16) | (l_ret >> 16);
+}
+
+SI_32 ConvertEndian_SI32(SI_32 f_value) { // NOLINT (readability/nolint)
+ SI_32 l_ret = ((f_value << 8) & 0xFF00FF00) | ((f_value >> 8) & 0xFF00FF);
+ return (l_ret << 16) | ((l_ret >> 16) & 0xFFFF);
+}
+
+UI_64 ConvertEndian_UI64(UI_64 f_value) { // // NOLINT (readability/nolint)
+ UI_64 l_ret = ((f_value << 8) & 0xFF00FF00FF00FF00ULL) | ((f_value >> 8) & 0x00FF00FF00FF00FFULL);
+ l_ret = ((l_ret << 16) & 0xFFFF0000FFFF0000ULL) | ((l_ret >> 16) & 0x0000FFFF0000FFFFULL);
+ return (l_ret << 32) | (l_ret >> 32);
+}
+
+SI_64 ConvertEndian_SI64(SI_64 f_value) { // NOLINT (readability/nolint)
+ SI_64 l_ret = ((f_value << 8) & 0xFF00FF00FF00FF00ULL) | ((f_value >> 8) & 0x00FF00FF00FF00FFULL);
+ l_ret = ((l_ret << 16) & 0xFFFF0000FFFF0000ULL) | ((l_ret >> 16) & 0x0000FFFF0000FFFFULL);
+ return (l_ret << 32) | ((l_ret >> 32) & 0xFFFFFFFFULL);
+}
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_crc.cpp b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_crc.cpp
new file mode 100644
index 00000000..af823648
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_crc.cpp
@@ -0,0 +1,125 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_UtilityCenter
+/// \brief This file contains implementation of APIs to calcuate 16-bit and 32-bit CRC checksum of file.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_util_crc.h>
+#include <stdio.h>
+
+// buffer size for reading from file
+#define MAX_BUFFER_SIZE 4096
+
+// Static 32 bit CRC lookup table
+UI_16 g_arr_crc16_table[256] = {
+};
+
+// Static 32 bit CRC lookup table
+UI_32 g_arr_crc32_table[256] = {
+};
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CalculateCRC16
+/// This API calculates the 16 bit CRC checksum of a file
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CalculateCRC16(PCSTR f_c_file_name, UI_16 &f_ui_check_sum) { // NOLINT (readability/nolint)
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ CHAR l_c_buffer[MAX_BUFFER_SIZE] = {0};
+ size_t l_ui_bytes_read = 0;
+ FILE *l_p_file = NULL;
+
+ if (NULL != f_c_file_name) {
+ f_ui_check_sum = 0xFFFF;
+
+ // Open the file
+ l_p_file = fopen(f_c_file_name, "rbe");
+
+ if (NULL == l_p_file) {
+ l_e_status = eFrameworkunifiedStatusFileLoadError;
+ } else {
+ l_ui_bytes_read = fread(l_c_buffer, 1, sizeof(l_c_buffer), l_p_file);
+
+ while (0 != l_ui_bytes_read) { // LCOV_EXCL_BR_LINE 11: not a branch
+ for (UI_32 l_ui_bytes_cnt = 0; l_ui_bytes_cnt < l_ui_bytes_read; l_ui_bytes_cnt++) { // LCOV_EXCL_BR_LINE 11: not a branch
+ f_ui_check_sum = static_cast<UI_16>(
+ g_arr_crc16_table[((f_ui_check_sum >> 8) ^ l_c_buffer[l_ui_bytes_cnt]) & 0xFF] ^ (f_ui_check_sum << 8));
+ }
+
+ l_ui_bytes_read = fread(l_c_buffer, 1, sizeof(l_c_buffer), l_p_file);
+ }
+
+ fclose(l_p_file);
+ l_p_file = NULL;
+ }
+
+ f_ui_check_sum = static_cast<UI_16>(~f_ui_check_sum);
+ } else {
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_e_status;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CalculateCRC32
+/// This API calculates the 32 bit CRC checksum of a file
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CalculateCRC32(PCSTR f_c_file_name, UI_32 &f_ui_check_sum) { // NOLINT (readability/nolint)
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ CHAR l_c_buffer[MAX_BUFFER_SIZE] = {0};
+ size_t l_ui_bytes_read = 0;
+ FILE *l_p_file = NULL;
+
+ if (NULL != f_c_file_name) {
+ f_ui_check_sum = 0xFFFFFFFF;
+
+ // Open the file
+ l_p_file = fopen(f_c_file_name, "rbe");
+
+ if (NULL == l_p_file) {
+ l_e_status = eFrameworkunifiedStatusFileLoadError;
+ } else {
+ l_ui_bytes_read = fread(l_c_buffer, 1, sizeof(l_c_buffer), l_p_file);
+
+ while (0 != l_ui_bytes_read) { // LCOV_EXCL_BR_LINE 11: not a branch
+ for (UI_32 l_ui_bytes_cnt = 0; l_ui_bytes_cnt < l_ui_bytes_read; l_ui_bytes_cnt++) { // LCOV_EXCL_BR_LINE 11: not a branch
+ f_ui_check_sum = (f_ui_check_sum >> 8)
+ ^ g_arr_crc32_table[(l_c_buffer[l_ui_bytes_cnt] ^ f_ui_check_sum) & 0xFF];
+ }
+
+ l_ui_bytes_read = fread(l_c_buffer, 1, sizeof(l_c_buffer), l_p_file);
+ }
+
+ fclose(l_p_file);
+ l_p_file = NULL;
+ }
+
+ f_ui_check_sum = ~f_ui_check_sum;
+ } else {
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_e_status;
+}
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_directory.cpp b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_directory.cpp
new file mode 100644
index 00000000..a8b4263d
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_util_directory.cpp
@@ -0,0 +1,145 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_UtilityCenter
+/// \brief This file contains API implementation for handling file and folder functionalities.
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns_util_directory.h>
+
+#include <dirent.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <cstring>
+#include <string>
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetFileList
+/// Get list of files present in a specific directory
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetFileList(TFileList *f_pv_tfile_list, PCSTR f_pc_path) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ DIR *l_p_dir = NULL;
+ struct dirent *l_pt_dirent = NULL;
+
+ if (NULL != f_pc_path && NULL != f_pv_tfile_list) {
+ if (NULL != (l_p_dir = opendir(f_pc_path))) {
+ PCHAR l_c_file_name = NULL;
+ size_t l_ui_str_length = 0;
+ while (NULL != (l_pt_dirent = readdir(l_p_dir))) { // LCOV_EXCL_BR_LINE 11: not a branch
+ if (!((std::strcmp(l_pt_dirent->d_name, ".") == 0) || (std::strcmp(l_pt_dirent->d_name, "..") == 0))) {
+ l_ui_str_length = std::strlen(l_pt_dirent->d_name);
+
+ l_c_file_name = new(std::nothrow) CHAR[l_ui_str_length + 1];
+
+ if (NULL != l_c_file_name) { // LCOV_EXCL_BR_LINE 11: new's error case(c++)
+ std::memset(l_c_file_name, 0, (sizeof(CHAR) * (l_ui_str_length + 1)));
+
+ std::strncpy(l_c_file_name, l_pt_dirent->d_name, l_ui_str_length);
+
+ f_pv_tfile_list->push_back(l_c_file_name); // LCOV_EXCL_BR_LINE 11: not a branch
+
+ delete[] l_c_file_name; // LCOV_EXCL_BR_LINE 11: not a branch
+ l_c_file_name = NULL;
+ } else {
+ l_e_status = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ }
+ closedir(l_p_dir);
+ } else {
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_e_status = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_e_status;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDirectory
+/// Method to create a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateDirectory(std::string f_c_dir_path) {
+ EFrameworkunifiedStatus l_e_status = eFrameworkunifiedStatusOK;
+
+ if (!f_c_dir_path.empty()) {
+ PSTR l_c_temp_dir_path;
+ PSTR l_c_parsed_dir_path;
+ PCSTR l_c_copy_path = f_c_dir_path.c_str();
+
+ l_c_temp_dir_path = const_cast<PSTR >(f_c_dir_path.c_str());
+ // LCOV_EXCL_BR_START 11: not a branch
+ while (l_e_status == eFrameworkunifiedStatusOK && (l_c_parsed_dir_path = std::strchr(l_c_temp_dir_path, '/')) != 0) {
+ // LCOV_EXCL_BR_STOP
+ if (l_c_parsed_dir_path != l_c_temp_dir_path) {
+ /* Neither root nor double slash in path */
+ *l_c_parsed_dir_path = '\0';
+ if (0 != mkdir(l_c_copy_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (EEXIST != errno) { // LCOV_EXCL_BR_LINE 11: not a branch
+ l_e_status = eFrameworkunifiedStatusFail;
+ } else {
+ // file already exist
+ if (TRUE != DoesDirecotryExist(f_c_dir_path)) { // LCOV_EXCL_BR_LINE 5: DoesDirecotryExist's error case
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ *l_c_parsed_dir_path = '/';
+ }
+ l_c_temp_dir_path = l_c_parsed_dir_path + 1;
+ }
+ if (eFrameworkunifiedStatusOK == l_e_status) { // LCOV_EXCL_BR_LINE 11: not a branch
+ if (0 != mkdir(l_c_copy_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (EEXIST != errno) { // LCOV_EXCL_BR_LINE 11: not a branch
+ l_e_status = eFrameworkunifiedStatusFail;
+ } else {
+ // file already exist
+ if (TRUE != DoesDirecotryExist(f_c_dir_path)) { // LCOV_EXCL_BR_LINE 5: DoesDirecotryExist's error case
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ }
+ } else {
+ l_e_status = eFrameworkunifiedStatusFail;
+ }
+ return l_e_status;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DoesDirecotryExist
+/// Method to check if a directory exists.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL DoesDirecotryExist(std::string f_c_dir_path) {
+ BOOL l_b_directory_status = FALSE;
+
+ DIR *l_p_dir_descriptor = opendir(f_c_dir_path.c_str());
+ if (NULL != l_p_dir_descriptor) {
+ closedir(l_p_dir_descriptor);
+ l_b_directory_status = TRUE;
+ }
+ return l_b_directory_status;
+}
+
diff --git a/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_utility.cpp b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_utility.cpp
new file mode 100644
index 00000000..d9e6776c
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_UtilityCenter/src/ns_utility.cpp
@@ -0,0 +1,144 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <native_service/ns_utility_if.h>
+#include <native_service/ns_utility_sys.hpp>
+#include <stdlib.h>
+#include <ctime>
+#include <cstring>
+#include "ns_utility_sys_internal.hpp"
+#include "ns_utility_if_internal.h"
+// Random functions ////////////////////////////////////////////////////
+void utility_sys_seedrand() { // NOLINT (readability/nolint)
+ static bool s_seeded = false;
+ if (!s_seeded) {
+ s_seeded = true;
+ srand48(std::time(NULL));
+ }
+}
+
+UI_32 utility_sys_rand() { // NOLINT (readability/nolint)
+ utility_sys_seedrand();
+ return static_cast< UI_32 >(mrand48());
+}
+
+// Lock wrapper implementation /////////////////////////////////////
+
+///////////////////////////////////////////
+// Implements locking policy for mutexes //
+///////////////////////////////////////////
+
+// CMutex helper function
+template< class TErr >
+void MutexLock(pthread_mutex_t *mtx) {
+ if (EOK != pthread_mutex_lock(mtx)) {
+ throw TErr("");
+ }
+}
+
+CMutex::CMutex() {
+ pthread_mutex_t mtx_tmp = PTHREAD_MUTEX_INITIALIZER;
+ std::memcpy(&m_mtx, &mtx_tmp, sizeof(m_mtx));
+ if (EOK != pthread_mutex_init(&m_mtx, NULL)) {
+ throw lock_creation_error();
+ }
+}
+
+CMutex::~CMutex() {
+ pthread_mutex_destroy(&m_mtx);
+}
+
+void CMutex::ReadLock() {
+ MutexLock< lock_acquireread_error >(&m_mtx);
+}
+
+void CMutex::WriteLock() {
+ MutexLock< lock_acquirewrite_error >(&m_mtx);
+}
+
+void CMutex::Unlock() {
+ if (EOK != pthread_mutex_unlock(&m_mtx)) {
+ throw lock_release_error("");
+ }
+}
+
+
+/////////////////////////////////////////////////////////
+// implements locking policy for reader / writer locks //
+/////////////////////////////////////////////////////////
+CRWLock::CRWLock() {
+ pthread_rwlock_t rw_tmp = PTHREAD_RWLOCK_INITIALIZER;
+ std::memcpy(&m_rwl, &rw_tmp, sizeof(m_rwl));
+ if (EOK != pthread_rwlock_init(&m_rwl, NULL)) {
+ throw lock_creation_error();
+ }
+}
+
+CRWLock::~CRWLock() {
+ pthread_rwlock_destroy(&m_rwl);
+}
+
+void CRWLock::ReadLock() {
+ if (EOK != pthread_rwlock_rdlock(&m_rwl)) {
+ throw lock_acquireread_error();
+ }
+}
+
+void CRWLock::WriteLock() {
+ if (EOK != pthread_rwlock_wrlock(&m_rwl)) {
+ throw lock_acquirewrite_error();
+ }
+}
+
+void CRWLock::Unlock() {
+ if (EOK != pthread_rwlock_unlock(&m_rwl)) {
+ throw lock_release_error();
+ }
+}
+
+/////////////////////////////////////////////////////////
+// implements GNU Builtins for counting leading zeros //
+/////////////////////////////////////////////////////////
+
+// returns the number of leading zeros in a given 16bit value
+SI_16 NS_CountLeadingZeros_16Bit(UI_16 f_ui_val) { // NOLINT (readability/nolint)
+ return static_cast<SI_16>((f_ui_val == 0) ? NS_INVALID_RETURN : __builtin_clz(f_ui_val)); // NOLINT (readability/nolint)
+}
+
+// returns the number of leading zeros in a given 32bit value
+SI_16 NS_CountLeadingZeros_32Bit(UI_32 f_ui_val) { // NOLINT (readability/nolint)
+ return static_cast<SI_16>((f_ui_val == 0) ? NS_INVALID_RETURN : __builtin_clzl(f_ui_val)); // NOLINT (readability/nolint)
+}
+
+// returns the number of leading zeros in a given 64bit value
+SI_16 NS_CountLeadingZeros_64Bit(UI_64 f_ui_val) { // NOLINT (readability/nolint)
+ return static_cast<SI_16>((f_ui_val == 0) ? NS_INVALID_RETURN : __builtin_clzll(f_ui_val)); // NOLINT (readability/nolint)
+}
+
+// returns the number of trailing zeros in a given 16bit value
+SI_16 NS_CountTrailingZeros_16Bit(UI_16 f_ui_val) { // NOLINT (readability/nolint)
+ return static_cast<SI_16>((f_ui_val == 0) ? NS_INVALID_RETURN : __builtin_ctz(f_ui_val)); // NOLINT (readability/nolint)
+}
+
+// returns the number of trailing zeros in a given 32bit value
+SI_16 NS_CountTrailingZeros_32Bit(UI_32 f_ui_val) { // NOLINT (readability/nolint)
+ return static_cast<SI_16>((f_ui_val == 0) ? NS_INVALID_RETURN : __builtin_ctzl(f_ui_val)); // NOLINT (readability/nolint)
+}
+
+// returns the number of trailing zeros in a given 64bit value
+SI_16 NS_CountTrailingZeros_64Bit(UI_64 f_ui_val) { // NOLINT (readability/nolint)
+ return static_cast<SI_16>((f_ui_val == 0) ? NS_INVALID_RETURN : __builtin_ctzll(f_ui_val)); // NOLINT (readability/nolint)
+}
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/Makefile b/nsframework/framework_unified/client/NS_XMLConfigeParser/Makefile
new file mode 100644
index 00000000..1cc5e18b
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/Makefile
@@ -0,0 +1,20 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS :=library
+
+
+include ../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/Makefile b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/Makefile
new file mode 100644
index 00000000..520b5f72
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/Makefile
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS = src
+
+include ../../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/cfg/depends.mk b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_XML.h b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_XML.h
new file mode 100644
index 00000000..4186f095
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_XML.h
@@ -0,0 +1,113 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup MY 14 Platfom Software Team
+/// \brief Internal Header for ns_config_parser_XML.c
+///
+/// These functions are used to read from and write to XML file.
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_XML_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_XML_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <ns_config_parser_internal.h>
+#define BUFFERSIZE 200
+#define ZERO 0
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// XMLGetValue:
+/// Function : get value for given key.
+///
+/// \param [in] pCurrNode
+/// xmlNodePtr - pCurrNode is a Pointer to node of XML tree.
+/// \param [in] pNodePath
+/// const char * - pNodePath is a Pointer to path of Current XML node.
+/// \param [in] pUserKey
+/// const char * - pUserKey is a Pointer to Key provided by user.
+/// \param [in] pReturnValue
+/// char * - pReturnValue is a Pointer to value to be returned corresponding to Key.
+/// \param [in] pReturnState
+/// int * - pReturnState is updated depending upon user provided Key\n
+/// returns 0 if user passed valid key.\n
+/// returns 1 if user passed invalid key.\n
+/// \return status
+/// void
+///////////////////////////////////////////////////////////////////////////////////////////
+void XMLGetValue(xmlNodePtr pcurrnode , const char *pnodepath, const char *puserkey, char *preturnvalue,
+ int *preturnstate);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// XMLUpdateOldValue:
+/// Function : update value corresponding to given user key.
+///
+/// \param [in] pCurrNode
+/// xmlNodePtr - pCurrNode is a Pointer to node of XML tree.
+/// \param [in] pNodePath
+/// const char * - pNodePath is a Pointer to path of Current XML node.
+/// \param [in] pUserKey
+/// const char * - pUserKey is a Pointer to Key provided by user.
+/// \param [in] pValue
+/// const char * - pValue is a Pointer to the new value for attribute or text.
+/// \param [in] pReturnState
+/// int * - returns 0 if user passed valid key.\n
+/// returns -6 if old value is not updated with new value.\n
+/// \return status
+/// void
+///////////////////////////////////////////////////////////////////////////////////////////
+void XMLUpdateOldValue(xmlNodePtr pcurrnode , const char *pnodepath, const char *puserkey, const char *preturnvalue,
+ int *preturnstate);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// XMLUpdateOldValueWithNewValue:
+/// Function : Traverse all nodes of XML tree read value to given node,compare with old value,\n
+/// if old value matched then write new value in place of old value.
+///
+/// \param [in] pCurrNode
+/// xmlNodePtr - pCurrNode is a Pointer to node of XML tree.
+/// \param [in] pNodePath
+/// const char * -pNodePath is a Pointer to path of Current XML node.
+/// \param [in] pUserKey
+/// const char * -pUserKey is a Pointer to Key provided by user.
+/// \param [in] pOldValue
+/// const char * - pOldValue is a Pointer to the old value for attribute or text of key passed.
+/// \param [in] pNewValue
+/// const char * -pNewValue is a Pointer to the new value for attribute or text to be assigned to the key.
+/// \param [in] pReturnState
+/// int * - returns 0 if user passed valid key.\n
+/// returns -6 if old value is not updated with new value.\n
+/// \return status
+/// void
+///////////////////////////////////////////////////////////////////////////////////////////
+void XMLUpdateOldValueWithNewValue(xmlNodePtr pcurrnode , const char *pnodepath, const char *puserkey,
+ const char *poldvalue, const char *pnewvalue, int *preturnstate);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_XML_H_
+
+// EOF
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_cfg.h b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_cfg.h
new file mode 100644
index 00000000..6dcf11ad
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_cfg.h
@@ -0,0 +1,104 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup MY 14 Platform Software Team
+/// \brief Internal Header for ns_config_parser_cfg.c
+///
+/// These functions are used to read from and write to cfg file.
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <ns_config_parser_internal.h>
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CFGGetValue:
+/// Function : Traverse cfg file and read value corresponding to key.
+///
+/// \param [in] filePtr
+/// FILE * - filePtr is a Pointer to a file descriptor.
+/// \param [in] pKey
+/// const char * -pKey is a Pointer to user key.
+/// \param [in] pRetValue
+/// char * - pRetValue is a Pointer to value or values to be returned corresponding to user key.
+/// \return status
+/// int - value returned depending upon user provided Key is valid or not.\n
+/// returns 1 if user passed invalid key.\n
+/// returns 0 if user passed valid key.\n
+///
+///////////////////////////////////////////////////////////////////////////////////////////
+int CFGGetValue(FILE *file_ptr, const char *p_key, char *p_ret_value);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CFGUpdateOldValue:
+/// Function : Traverse the cfg file and update the value corresponding to given key.
+///
+/// \param [in] hConfigFile
+/// HANDLE - hConfigFile is a handle to given file.
+/// \param [in] pKey
+/// const char * - pKey is a Pointer to user key.
+/// \param [in] pValue
+/// const char * - pValue is a Pointer to new value corresponding to user key.
+/// \return status
+/// int - returns 1 if user passed invalid key.\n
+/// returns 0 if user passed valid key.\n
+/// returns -1 if memory allocation fail.\n
+/// returns -6 if value not updated in file.\n
+///
+///////////////////////////////////////////////////////////////////////////////////////////
+int CFGUpdateOldValue(HANDLE h_config_file, const char *p_key, const char *p_value);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CFGUpdateOldValueWithNewValue
+/// Function : Traverse the cfg file read value to given node,compare with old value,\n
+/// if old value matched then write new value in place of old value.\n
+///
+/// \param [in] hConfigFile
+/// HANDLE - hConfigFile is a handle to given file.
+/// \param [in] pKey
+/// const char * - pKey is a Pointer to user key.
+/// \param [in] pOldValue
+/// const char * - pOldValue is a Pointer to Old Value corresponding to user key.
+/// \param [in] pNewValue
+/// const char * - pNewValue is a Pointer to New Value corresponding to user key.
+/// \return status
+/// int - returns 1 if user passed invalid key.\n
+/// returns 0 if user passed valid key.\n
+/// returns -1 if memory allocation fail.\n
+/// returns -6 if value not updated in file.\n
+///
+///////////////////////////////////////////////////////////////////////////////////////////
+
+int CFGUpdateOldValueWithNewValue(HANDLE h_config_file, const char *p_key,
+ const char *p_old_value, const char *p_new_value);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_CFG_H_
+
+// EOF
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_internal.h b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_internal.h
new file mode 100644
index 00000000..97c9be68
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_config_parser_internal.h
@@ -0,0 +1,60 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup MY 14 Platform Software Team
+/// \brief Internal Header for ns_config_parser_cfg.c
+///
+/// These structures are file handler structure.
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_INTERNAL_H_
+
+#include <libxml/tree.h>
+#include <ns_config_parser.h>
+
+
+// defines enum for MODE
+// in which file is opened
+typedef enum MODE {
+ kReadMode = 0, kWriteMode, kAppend
+} MODE;
+
+// defines enum for STATUS
+typedef enum STATUS {
+ kSuccess = 0, kFailure
+} STATUS;
+
+// defines enum for Filetype
+// i.e .cfg or .xml or other type of file
+typedef enum Filetype {
+ kCfg = 0, kXml, kOther
+} Filetype;
+
+// FILE STRUCTURE
+typedef struct FILESTRUCT {
+ char *filename;
+ Filetype filetype;
+ MODE mode;
+ xmlDocPtr doc;
+ FILE *fileptr;
+} FILESTRUCT;
+
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_CONFIG_PARSER_INTERNAL_H_
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_xmlconfig_parser_frameworkunifiedlog.h b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_xmlconfig_parser_frameworkunifiedlog.h
new file mode 100644
index 00000000..05874893
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/include/ns_xmlconfig_parser_frameworkunifiedlog.h
@@ -0,0 +1,88 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_XMLCONFIG_PARSER_FRAMEWORKUNIFIEDLOG_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_XMLCONFIG_PARSER_FRAMEWORKUNIFIEDLOG_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGZONES
+// #define FRAMEWORKUNIFIEDLOGZONES (ZONE_WARN|ZONE_ERR)
+#define FRAMEWORKUNIFIEDLOGZONES (ZONE_INIT|ZONE_FUNC|ZONE_INFO|ZONE_WARN|ZONE_ERR|ZONE_NS_WAR|ZONE_NS_ERR)
+#endif
+
+extern const CHAR kAppName[];
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_XMLCONFIGEPARSER_LIBRARY_INCLUDE_NS_XMLCONFIG_PARSER_FRAMEWORKUNIFIEDLOG_H_
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/Makefile b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/Makefile
new file mode 100644
index 00000000..9ec700c3
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/Makefile
@@ -0,0 +1,57 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+
+
+######### installed library(*.a) #############
+
+
+######### installed shared library(*.so) #############
+INST_SHLIBS = libNS_XMLConfigParser
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+libNS_XMLConfigParser_SRCS = ns_xml_reader.cpp ns_xml_writer.cpp ns_xmlparser.cpp ns_xmlparser_attributes.cpp ns_xmlparser_node.cpp
+
+######### add source path #############
+
+######### add include path #############
+
+CPPFLAGS += -I$(SDKTARGETSYSROOT)/usr/include/libxml2
+CPPFLAGS += -I../../../include
+CPPFLAGS += -I../include
+CPPFLAGS += -I../../../include
+#inc_dummy
+CPPFLAGS += -I../../../NS_ConfigParser/include
+
+######### add compile option #############
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+
+######### add library path #############
+LDFLAGS += -L../../../
+LDFLAGS += -Wl,--no-as-needed
+######### linked library (dynamic) #############
+LDFLAGS += -Wl,--no-as-needed
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lxml2
+LDLIBS += -Wl,-Bdynamic -lm
+
+LINK_SHLIB_CXX = Y
+
+include ../../../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..cdf3238e
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/makefile_PosixBasedOS001
@@ -0,0 +1,208 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS_XMLConfigParser
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS_XMLConfigParser
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NS_ConfigParser/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/native/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+DYNAMIC_LIBS += \
+ xml2 \
+ m
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+module_dirs: build_dirs
+
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_reader.cpp b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_reader.cpp
new file mode 100644
index 00000000..01abb973
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_reader.cpp
@@ -0,0 +1,522 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CXMLReader class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_xml_reader.h>
+#include <string>
+#include "ns_xmlconfig_parser_frameworkunifiedlog.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CXMLReader *GetCXMLReaderObject(CHAR *f_cfilepath) {
+ CXMLReader *l_p_xml_reader = NULL;
+ if (NULL != f_cfilepath) {
+ l_p_xml_reader = new(std::nothrow) CXMLReader(f_cfilepath); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ return l_p_xml_reader;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+CXMLReader::CXMLReader(): m_pXmlDoc(NULL) {
+}
+
+CXMLReader::CXMLReader(const std::string &f_cFilePath): m_pXmlDoc(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_cFilePath.c_str());
+
+ // create document object structure
+ m_pXmlDoc = xmlParseFile(f_cFilePath.c_str()); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (!m_pXmlDoc) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Pointer to document structure is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+}
+
+CXMLReader::~CXMLReader() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Destructor");
+
+ if (NULL != m_pXmlDoc) {
+ xmlFreeDoc(m_pXmlDoc); // LCOV_EXCL_BR_LINE 11: except branch
+ m_pXmlDoc = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CXMLReader::ParseFile(const std::string &f_cFilePath) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // create document object structure
+ m_pXmlDoc = xmlParseFile(f_cFilePath.c_str());
+
+ if (NULL == m_pXmlDoc) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Pointer to document structure is NULL");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+PVOID CXMLReader::GetDataPtr() {
+ return m_pXmlDoc;
+}
+
+std::string CXMLReader::GetValue(const std::string &f_cKey) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Key %s", f_cKey.c_str());
+
+ std::string l_cValue = "";
+
+ if (NULL != m_pXmlDoc && (!f_cKey.empty())) {
+ std::string l_cUserKey = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ l_cUserKey.assign(f_cKey);
+
+ // get the root node element
+ xmlNodePtr l_pCurrNode = xmlDocGetRootElement(m_pXmlDoc); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (NULL != l_pCurrNode) {
+ // remove the root node name from key
+ size_t l_uiLength = l_cUserKey.find('.'); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (std::string::npos != l_uiLength) {
+ l_cUserKey = l_cUserKey.substr(l_uiLength + 1); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // if root node name matches with the name in received key
+ if (!(f_cKey.substr(0, l_uiLength)).compare((PCSTR)l_pCurrNode->name)) {
+ l_cValue = XMLGetValue(l_pCurrNode,
+ l_cUserKey);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Parsed Value :: %s", l_cValue.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Document structure pointer m_pXmlDoc is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+
+ return l_cValue;
+}
+
+std::string CXMLReader::XMLGetValue(xmlNodePtr f_pCurrNode,
+ const std::string &f_cUserKey) {
+ std::string l_cReturnValue = "";
+
+ if (NULL != f_pCurrNode && (!f_cUserKey.empty())) {
+ std::string l_cKey = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // result of previous attribute of same node
+ BOOL l_bResult = TRUE;
+
+ // this parameter specifies whether to AND or OR the current result with previous result
+ // TRUE means AND while FALSE means OR
+ BOOL l_bOperation = FALSE;
+
+ // position of "@" in user key if exists
+ size_t l_uiAttrLen = 0;
+
+ // get the single attribute from list of attributes of node
+ std::string l_cAttr = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ std::string l_cNodeName = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // contains the single attribute key, value
+ std::string l_cAttrOpt = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // l_cAttrId of the attribute
+ std::string l_cAttrId = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ // value of the attribute
+ std::string l_cAttrValue = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ size_t l_uiSplitProp = 0;
+ size_t l_uiAttrSplit = 0;
+ BOOL l_bCurrentResult = FALSE;
+
+ l_cKey.assign(f_cUserKey);
+
+ // position of first "." in user key
+ size_t l_uiLength = l_cKey.find('.'); // LCOV_EXCL_BR_LINE 11: except branch
+ if (std::string::npos != l_uiLength) {
+ // get the current node name string with node attributes
+ l_cKey = l_cKey.substr(0, l_uiLength); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ l_cNodeName.assign(l_cKey);
+
+ // get children of current node
+ f_pCurrNode = f_pCurrNode->children;
+
+ while (NULL != f_pCurrNode) {
+ // check whether current node is an element node.
+ if (XML_ELEMENT_NODE == f_pCurrNode->type) {
+ l_bResult = TRUE;
+ l_bOperation = FALSE;
+ l_uiAttrLen = 0;
+ l_cAttr.clear();
+
+ // check whether key contains attribute for current node
+ if (std::string::npos != (l_uiAttrLen = l_cKey.find('@'))) {
+ // get the attribute string from node key
+ l_cAttr.assign(l_cKey, (l_uiAttrLen + 1), std::string::npos); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // remove the attribute string from key string
+ l_cKey = l_cKey.substr(0, l_uiAttrLen); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ // check whether node name string matches with the current node name
+ if (!l_cKey.compare((PCSTR)f_pCurrNode->name)) {
+ l_cAttrOpt.assign(l_cAttr);
+
+ while (0 < l_cAttr.length()) {
+ // initialize variables
+ l_cAttrId.clear();
+ l_cAttrValue.clear();
+ l_uiSplitProp = 0;
+ l_uiAttrSplit = 0;
+ l_bCurrentResult = FALSE;
+
+ // check whether node have multiple attributes
+ if (std::string::npos != (l_uiSplitProp = l_cAttr.find('|'))) {
+ l_cAttrOpt = l_cAttr.substr(0, l_uiSplitProp);
+
+ if (std::string::npos != (l_uiAttrSplit = l_cAttrOpt.find('='))) {
+ l_cAttrId = l_cAttrOpt.substr(0, l_uiAttrSplit);
+ l_cAttrValue = l_cAttrOpt.substr(l_uiAttrSplit + 1);
+ }
+ } else if (std::string::npos != (l_uiSplitProp = l_cAttr.find('&'))) {
+ l_cAttrOpt = l_cAttr.substr(0, l_uiSplitProp);
+
+ if (std::string::npos != (l_uiAttrSplit = l_cAttrOpt.find('='))) {
+ l_cAttrId = l_cAttrOpt.substr(0, l_uiAttrSplit);
+ l_cAttrValue = l_cAttrOpt.substr(l_uiAttrSplit + 1);
+ }
+ } else {
+ l_uiSplitProp = l_cAttr.length() - 1;
+ if (std::string::npos != (l_uiAttrSplit = l_cAttr.find('='))) {
+ l_cAttrId = l_cAttr.substr(0, l_uiAttrSplit); // LCOV_EXCL_BR_LINE 11: except branch
+ l_cAttrValue = l_cAttr.substr(l_uiAttrSplit + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ }
+
+ // compare the value of attributes
+ xmlChar *l_pAttrValue = xmlGetProp(f_pCurrNode, (const xmlChar *)l_cAttrId.c_str()); // LCOV_EXCL_BR_LINE 11: except branch
+ if (NULL != l_pAttrValue) {
+ if (!l_cAttrValue.compare((PCSTR)l_pAttrValue)) {
+ l_bCurrentResult = TRUE;
+ }
+ }
+ xmlFree(l_pAttrValue); // LCOV_EXCL_BR_LINE 11: except branch
+ l_pAttrValue = NULL;
+
+ // combine the result of all attributes
+ if (!l_bOperation) {
+ l_bResult = l_bResult && l_bCurrentResult;
+ } else {
+ l_bResult = l_bResult || l_bCurrentResult;
+ }
+
+ if ('|' == l_cAttr[l_uiSplitProp]) {
+ l_bOperation = TRUE;
+ } else {
+ l_bOperation = FALSE;
+ }
+
+ if ((!l_bResult) && (!l_bOperation)) {
+ // break from current while loop
+ break;
+ }
+
+ l_cAttr = l_cAttr.substr(l_uiSplitProp + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ // if attributes not matched move to next node
+ if (!l_bResult) {
+ // search for the same node name in next child nodes
+ l_cKey.assign(l_cNodeName);
+ } else {
+ // read text of current node
+ if ((NULL != f_pCurrNode->children) &&
+ (XML_TEXT_NODE == f_pCurrNode->children->type) &&
+ (NULL == f_pCurrNode->children->next)) {
+ // append the result in string
+ l_cReturnValue.append((PCSTR) f_pCurrNode->children->content); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ }
+ } else {
+ l_bResult = FALSE;
+ }
+
+ if (l_bResult) {
+ // parse children and next nodes of current node
+ if (std::string::npos != l_uiLength) {
+ l_cKey = f_cUserKey.substr(l_uiLength + 1); // LCOV_EXCL_BR_LINE 11: except branch
+
+ std::string l_cValue = XMLGetValue(f_pCurrNode, l_cKey); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (!l_cReturnValue.empty() && !l_cValue.empty()) {
+ l_cReturnValue.append("\n");
+ }
+
+ // append the received string
+ l_cReturnValue.append(l_cValue);
+ }
+
+ l_cKey = l_cNodeName;
+ }
+ }
+
+ f_pCurrNode = f_pCurrNode->next;
+ }
+ }
+
+ return l_cReturnValue;
+}
+
+EFrameworkunifiedStatus CXMLReader::GetValue(const std::string &f_cKey, std::string &f_cValue) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pXmlDoc && (!f_cKey.empty())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Key is %s", f_cKey.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ std::string l_cUserKey = "";
+ l_cUserKey.assign(f_cKey);
+
+ // get the root node element
+ xmlNodePtr l_pCurrNode = xmlDocGetRootElement(m_pXmlDoc);
+
+ if (NULL != l_pCurrNode) {
+ // remove the root node name from key
+ size_t l_uiLength = l_cUserKey.find('.'); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (std::string::npos != l_uiLength) {
+ l_cUserKey = l_cUserKey.substr(l_uiLength + 1); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // if root node name matches with the name in received key
+ if (!(f_cKey.substr(0, l_uiLength)).compare((PCSTR)l_pCurrNode->name)) {
+ BOOL l_bKeyFound = FALSE;
+
+ XMLGetValue(l_pCurrNode, l_cUserKey, f_cValue, l_bKeyFound);
+
+ if (!l_bKeyFound) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Root Node ptr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Parsed Value :: %s", f_cValue.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Document structure pointer m_pXmlDoc is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CXMLReader::XMLGetValue(xmlNodePtr f_pCurrNode, const std::string &f_cUserKey, std::string &f_cValue,
+ BOOL &f_bKeyFound) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != f_pCurrNode && (!f_cUserKey.empty())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Key :: %s", f_cUserKey.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ std::string l_cKey = "";
+
+ // result of previous attribute of same node
+ BOOL l_bResult = TRUE;
+
+ // this parameter specifies whether to AND or OR the current result with previous result
+ // TRUE means AND while FALSE means OR
+ BOOL l_bOperation = FALSE;
+
+ // position of "@" in user key if exists
+ size_t l_uiAttrLen = 0;
+
+ // get the single attribute from list of attributes of node
+ std::string l_cAttr = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ std::string l_cNodeName = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // contains the single attribute key, value
+ std::string l_cAttrOpt = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // l_cAttrId of the attribute
+ std::string l_cAttrId = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ // value of the attribute
+ std::string l_cAttrValue = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ size_t l_uiSplitProp = 0;
+ size_t l_uiAttrSplit = 0;
+ BOOL l_bCurrentResult = FALSE;
+
+ l_cKey.assign(f_cUserKey);
+
+ // position of first "." in user key
+ size_t l_uiLength = l_cKey.find('.'); // LCOV_EXCL_BR_LINE 11: except branch
+ if (std::string::npos != l_uiLength) {
+ // get the current node name string with node attributes
+ l_cKey = l_cKey.substr(0, l_uiLength); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ l_cNodeName.assign(l_cKey);
+
+ // get children of current node
+ f_pCurrNode = f_pCurrNode->children;
+
+ while (NULL != f_pCurrNode) {
+ // check whether current node is an element node.
+ if (XML_ELEMENT_NODE == f_pCurrNode->type) {
+ l_bResult = TRUE;
+ l_bOperation = FALSE;
+ l_uiAttrLen = 0;
+ l_cAttr.clear();
+
+ // check whether key contains attribute for current node
+ if (std::string::npos != (l_uiAttrLen = l_cKey.find('@'))) {
+ // get the attribute string from node key
+ l_cAttr.assign(l_cKey, (l_uiAttrLen + 1), std::string::npos); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // remove the attribute string from key string
+ l_cKey = l_cKey.substr(0, l_uiAttrLen); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ // check whether node name string matches with the current node name
+ if (!l_cKey.compare((PCSTR)f_pCurrNode->name)) {
+ l_cAttrOpt.assign(l_cAttr);
+
+ while (0 < l_cAttr.length()) {
+ // initialize variables
+ l_cAttrId.clear();
+ l_cAttrValue.clear();
+ l_uiSplitProp = 0;
+ l_uiAttrSplit = 0;
+ l_bCurrentResult = FALSE;
+
+ // check whether node have multiple attributes
+ if (std::string::npos != (l_uiSplitProp = l_cAttr.find('|'))) {
+ l_cAttrOpt = l_cAttr.substr(0, l_uiSplitProp);
+
+ if (std::string::npos != (l_uiAttrSplit = l_cAttrOpt.find('='))) {
+ l_cAttrId = l_cAttrOpt.substr(0, l_uiAttrSplit);
+ l_cAttrValue = l_cAttrOpt.substr(l_uiAttrSplit + 1);
+ }
+ } else if (std::string::npos != (l_uiSplitProp = l_cAttr.find('&'))) {
+ l_cAttrOpt = l_cAttr.substr(0, l_uiSplitProp);
+
+ if (std::string::npos != (l_uiAttrSplit = l_cAttrOpt.find('='))) {
+ l_cAttrId = l_cAttrOpt.substr(0, l_uiAttrSplit);
+ l_cAttrValue = l_cAttrOpt.substr(l_uiAttrSplit + 1);
+ }
+ } else {
+ l_uiSplitProp = l_cAttr.length() - 1;
+ if (std::string::npos != (l_uiAttrSplit = l_cAttr.find('='))) {
+ l_cAttrId = l_cAttr.substr(0, l_uiAttrSplit); // LCOV_EXCL_BR_LINE 11: except branch
+ l_cAttrValue = l_cAttr.substr(l_uiAttrSplit + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ }
+
+ // compare the value of attributes
+ xmlChar *l_pAttrValue = xmlGetProp(f_pCurrNode, (const xmlChar *)l_cAttrId.c_str()); // LCOV_EXCL_BR_LINE 11: except branch
+ if (NULL != l_pAttrValue) {
+ if (!l_cAttrValue.compare((PCSTR)l_pAttrValue)) {
+ l_bCurrentResult = TRUE;
+ }
+
+ xmlFree(l_pAttrValue); // LCOV_EXCL_BR_LINE 11: except branch
+ l_pAttrValue = NULL;
+ }
+
+ // combine the result of all attributes
+ if (!l_bOperation) {
+ l_bResult = l_bResult && l_bCurrentResult;
+ } else {
+ l_bResult = l_bResult || l_bCurrentResult;
+ }
+
+ if ('|' == l_cAttr[l_uiSplitProp]) {
+ l_bOperation = TRUE;
+ } else {
+ l_bOperation = FALSE;
+ }
+
+ if ((!l_bResult) && (!l_bOperation)) {
+ // break from current while loop
+ break;
+ }
+
+ l_cAttr = l_cAttr.substr(l_uiSplitProp + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ // if attributes not matched move to next node
+ if (!l_bResult) {
+ // search for the same node name in next child nodes
+ l_cKey.assign(l_cNodeName);
+ } else {
+ // read text of current node
+ if ((NULL != f_pCurrNode->children) &&
+ (XML_TEXT_NODE == f_pCurrNode->children->type) &&
+ (NULL == f_pCurrNode->children->next)) {
+ if (!f_cValue.empty()) {
+ f_cValue.append("\n");
+ }
+
+ // append the result in string
+ f_cValue.append((PCSTR) f_pCurrNode->children->content); // LCOV_EXCL_BR_LINE 11: except branch
+
+ f_bKeyFound = TRUE;
+ }
+ }
+ } else {
+ l_bResult = FALSE;
+ }
+
+ if (l_bResult) {
+ // parse children and next nodes of current node
+ if (std::string::npos != l_uiLength) {
+ l_cKey = f_cUserKey.substr(l_uiLength + 1); // LCOV_EXCL_BR_LINE 11: except branch
+
+ l_eStatus = XMLGetValue(f_pCurrNode, l_cKey, f_cValue, f_bKeyFound);
+ }
+
+ l_cKey = l_cNodeName;
+ }
+ }
+
+ f_pCurrNode = f_pCurrNode->next;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_writer.cpp b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_writer.cpp
new file mode 100644
index 00000000..2876e228
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xml_writer.cpp
@@ -0,0 +1,338 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains implementation of CXMLWriter class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_xml_writer.h>
+#include <string>
+#include "ns_xmlconfig_parser_frameworkunifiedlog.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CXMLWriter *GetCXMLWriterObject(CHAR *f_cfilepath) {
+ CXMLWriter *l_p_xml_writer = NULL;
+ if (NULL != f_cfilepath) {
+ l_p_xml_writer = new(std::nothrow) CXMLWriter(f_cfilepath); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ return l_p_xml_writer;
+}
+
+CXMLWriter *GetCXMLWriterObjectNoParam() {
+ return (new(std::nothrow) CXMLWriter()); // LCOV_EXCL_BR_LINE 11: except branch
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+CXMLWriter::CXMLWriter(): m_pXmlDoc(NULL), m_cFilePath("") {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+}
+
+CXMLWriter::CXMLWriter(const std::string &f_cFilePath): m_pXmlDoc(NULL), m_cFilePath(f_cFilePath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "File Path %s", f_cFilePath.c_str());
+
+ // create document object structure
+ m_pXmlDoc = xmlParseFile(m_cFilePath.c_str()); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (!m_pXmlDoc) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Pointer to document structure is NULL");
+ }
+}
+
+CXMLWriter::~CXMLWriter() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Destructor");
+
+ if (NULL != m_pXmlDoc) {
+ xmlFreeDoc(m_pXmlDoc); // LCOV_EXCL_BR_LINE 11: except branch
+ m_pXmlDoc = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CXMLWriter::ParseFile(const std::string &f_cFilePath) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_eStatus = SetPath(f_cFilePath);
+
+ if (NULL != m_pXmlDoc) {
+ xmlFreeDoc(m_pXmlDoc);
+ m_pXmlDoc = NULL;
+ }
+
+ // create document object structure
+ m_pXmlDoc = xmlParseFile(f_cFilePath.c_str());
+
+ if (NULL == m_pXmlDoc) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Pointer to document structure is NULL");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CXMLWriter::SetPath(const std::string &f_cPath) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (!f_cPath.empty()) {
+ // set the file path
+ m_cFilePath.assign(f_cPath);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+VOID CXMLWriter::SetDataPtr(PVOID f_pData) {
+ m_pXmlDoc = NULL;
+ if (NULL != f_pData) {
+ // set the doc pointer
+ m_pXmlDoc = static_cast<xmlDocPtr>(f_pData);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Data Pointer not set in xml writer"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+}
+
+EFrameworkunifiedStatus CXMLWriter::SetValue(const std::string &f_cKey, std::string f_cValue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Key %s", f_cKey.c_str());
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pXmlDoc && (!f_cKey.empty())) {
+ std::string l_cUserKey = "";
+ l_cUserKey.assign(f_cKey);
+
+ // get the root node element
+ xmlNodePtr l_pCurrNode = xmlDocGetRootElement(m_pXmlDoc);
+
+ if (NULL != l_pCurrNode) {
+ // remove the root node name from key
+ size_t l_uiLength = l_cUserKey.find('.'); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (std::string::npos != l_uiLength) {
+ l_cUserKey = l_cUserKey.substr(l_uiLength + 1); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // if root node name matches with the name in received key
+ if (!(f_cKey.substr(0, l_uiLength)).compare((PCSTR)l_pCurrNode->name)) {
+ BOOL l_bKeyFound = FALSE;
+ l_eStatus = XMLSetValue(l_pCurrNode, l_cUserKey, f_cValue, l_bKeyFound);
+
+ if (!l_bKeyFound) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Document structure pointer m_pXmlDoc is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CXMLWriter::XMLSetValue(xmlNodePtr f_pCurrNode,
+ const std::string &f_cUserKey,
+ std::string &f_cValue,
+ BOOL &f_bKeyFound) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (!f_cUserKey.empty() && NULL != f_pCurrNode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Key :: %s", f_cUserKey.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ std::string l_cKey = "";
+
+ // result of previous attribute of same node
+ BOOL l_bResult = TRUE;
+
+ // this parameter specifies whether to AND or OR the current result with previous result
+ // TRUE means AND while FALSE means OR
+ BOOL l_bOperation = FALSE;
+
+ // position of "@" in user key if exists
+ size_t l_uiAttrLen = 0;
+
+ // get the single attribute from list of attributes of node
+ std::string l_cAttr = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ std::string l_cNodeName = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // contains the single attribute key, value
+ std::string l_cAttrOpt = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ // l_cAttrId of the attribute
+ std::string l_cAttrId = ""; // LCOV_EXCL_BR_LINE 11: except branch
+ // value of the attribute
+ std::string l_cAttrValue = ""; // LCOV_EXCL_BR_LINE 11: except branch
+
+ size_t l_uiSplitProp = 0;
+ size_t l_uiAttrSplit = 0;
+ BOOL l_bCurrentResult = FALSE;
+
+ l_cKey.assign(f_cUserKey);
+
+ // position of first "." in user key
+ size_t l_uiLength = l_cKey.find('.'); // LCOV_EXCL_BR_LINE 11: except branch
+ if (std::string::npos != l_uiLength) {
+ // get the current node name string with node attributes
+ l_cKey = l_cKey.substr(0, l_uiLength); // LCOV_EXCL_BR_LINE 11: except branch
+
+ l_cNodeName.assign(l_cKey);
+ }
+
+ // get children of current node
+ f_pCurrNode = f_pCurrNode->children;
+
+ while (NULL != f_pCurrNode) {
+ // check whether current node is an element node.
+ if (XML_ELEMENT_NODE == f_pCurrNode->type) {
+ l_bResult = TRUE;
+ l_bOperation = FALSE;
+ l_uiAttrLen = 0;
+ l_cAttr.clear();
+
+ // check whether key contains attribute for current node
+ if (std::string::npos != (l_uiAttrLen = l_cKey.find('@'))) {
+ // get the attribute string from node key
+ l_cAttr.assign(l_cKey, (l_uiAttrLen + 1), std::string::npos); // LCOV_EXCL_BR_LINE 11: except branch
+
+ // remove the attribute string from key string
+ l_cKey = l_cKey.substr(0, l_uiAttrLen); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ // check whether node name string matches with the current node name
+ if (!l_cKey.compare((PCSTR)f_pCurrNode->name)) {
+ l_cAttrOpt.assign(l_cAttr);
+
+ while (0 < l_cAttr.length()) {
+ // initialize variables
+ l_cAttrId.clear();
+ l_cAttrValue.clear();
+ l_uiSplitProp = 0;
+ l_uiAttrSplit = 0;
+ l_bCurrentResult = FALSE;
+
+ // check whether node have multiple attributes
+ if (std::string::npos != (l_uiSplitProp = l_cAttr.find('|'))) {
+ l_cAttrOpt = l_cAttr.substr(0, l_uiSplitProp);
+
+ if (std::string::npos != (l_uiAttrSplit = l_cAttrOpt.find('='))) {
+ l_cAttrId = l_cAttrOpt.substr(0, l_uiAttrSplit);
+ l_cAttrValue = l_cAttrOpt.substr(l_uiAttrSplit + 1);
+ }
+ } else if (std::string::npos != (l_uiSplitProp = l_cAttr.find('&'))) {
+ l_cAttrOpt = l_cAttr.substr(0, l_uiSplitProp);
+
+ if (std::string::npos != (l_uiAttrSplit = l_cAttrOpt.find('='))) {
+ l_cAttrId = l_cAttrOpt.substr(0, l_uiAttrSplit);
+ l_cAttrValue = l_cAttrOpt.substr(l_uiAttrSplit + 1);
+ }
+ } else {
+ l_uiSplitProp = l_cAttr.length() - 1;
+ if (std::string::npos != (l_uiAttrSplit = l_cAttr.find('='))) {
+ l_cAttrId = l_cAttr.substr(0, l_uiAttrSplit); // LCOV_EXCL_BR_LINE 11: except branch
+ l_cAttrValue = l_cAttr.substr(l_uiAttrSplit + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ }
+
+ // compare the value of attributes
+ xmlChar *l_pAttrValue = xmlGetProp(f_pCurrNode, (const xmlChar *)l_cAttrId.c_str()); // LCOV_EXCL_BR_LINE 11: except branch
+ if (NULL != l_pAttrValue) {
+ if (!l_cAttrValue.compare((PCSTR)l_pAttrValue)) {
+ l_bCurrentResult = TRUE;
+ }
+ }
+ xmlFree(l_pAttrValue);
+ l_pAttrValue = NULL;
+
+ // combine the result of all attributes
+ if (!l_bOperation) {
+ l_bResult = l_bResult && l_bCurrentResult;
+ } else {
+ l_bResult = l_bResult || l_bCurrentResult;
+ }
+
+ if ('|' == l_cAttr[l_uiSplitProp]) {
+ l_bOperation = TRUE;
+ } else {
+ l_bOperation = FALSE;
+ }
+
+ if ((!l_bResult) && (!l_bOperation)) {
+ // break from current while loop
+ break;
+ }
+
+ l_cAttr = l_cAttr.substr(l_uiSplitProp + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ // if attributes not matched move to next node
+ if (!l_bResult) {
+ // search for the same node name in next child nodes
+ l_cKey.assign(l_cNodeName);
+ } else {
+ // read text of current node
+ if ((NULL != f_pCurrNode->children) &&
+ (XML_TEXT_NODE == f_pCurrNode->children->type) &&
+ (NULL == f_pCurrNode->children->next)) {
+ // set the value
+ xmlNodeSetContent(f_pCurrNode, (const xmlChar *)f_cValue.c_str());
+
+ f_bKeyFound = TRUE;
+ }
+ }
+ }
+
+ if (l_bResult) {
+ // parse children and next nodes of current node
+ l_cKey = f_cUserKey.substr(l_uiLength + 1); // LCOV_EXCL_BR_LINE 11: except branch
+ l_eStatus = XMLSetValue(f_pCurrNode, l_cKey, f_cValue, f_bKeyFound);
+ }
+ }
+
+ f_pCurrNode = f_pCurrNode->next;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CXMLWriter::SaveData() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // save the doc structure to the file
+ if (-1 == xmlSaveFileEnc(m_cFilePath.c_str(), m_pXmlDoc, "UTF-8")) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser.cpp b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser.cpp
new file mode 100644
index 00000000..cb058658
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser.cpp
@@ -0,0 +1,354 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_XmlParser
+/// \brief This file contains implementation of CXmlParser class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_xmlparser_if.h>
+#include <fstream>
+#include <string>
+#include "ns_xmlconfig_parser_frameworkunifiedlog.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CXmlParser
+/// Constructor
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlParser::CXmlParser(): m_pXmlDoc(NULL), m_cFileName(""), m_pRootNode(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // for maintaining indentation
+ xmlKeepBlanksDefault(0); // LCOV_EXCL_BR_LINE 11: except branch
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CXmlParser
+/// Destructor
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlParser::~CXmlParser() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // clears the document structure
+ ClearDocument(); // LCOV_EXCL_BR_LINE 11: except branch
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ParseXml
+/// Parses the xml file and creates a document structure
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlParser::ParseXml(std::string f_cFileName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // clears the document structure
+ ClearDocument(); // LCOV_EXCL_BR_LINE 11: except branch
+
+ m_cFileName = f_cFileName;
+
+ if (IsReadable(m_cFileName)) {
+ // create document object structure
+ m_pXmlDoc = xmlParseFile(m_cFileName.c_str());
+
+ if (NULL != m_pXmlDoc) {
+ // sets the root node in class
+ m_pRootNode.SetXmlNodePtr(xmlDocGetRootElement(m_pXmlDoc));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Document not parsed successfully :: %s", f_cFileName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "File not exists :: %s", f_cFileName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateNewXmlDoc
+/// Creates a new xml document with f_cRootNodeName as root node
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlParser::CreateNewXmlDoc(std::string f_cRootNodeName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ xmlNodePtr l_pRootNodePtr = NULL;
+
+ // clears the document structure
+ ClearDocument();
+
+ if (0 < f_cRootNodeName.length()) {
+ // creates new document structure
+ m_pXmlDoc = xmlNewDoc((const xmlChar *)"1.0");
+ if (NULL != m_pXmlDoc) {
+ // create new node(root)
+ l_pRootNodePtr = xmlNewNode(NULL,
+ (const xmlChar *)f_cRootNodeName.c_str());
+ if (NULL != l_pRootNodePtr) {
+ // sets the root node in document structure
+ xmlDocSetRootElement(m_pXmlDoc, l_pRootNodePtr);
+
+ // sets the root node in class
+ m_pRootNode.SetXmlNodePtr(l_pRootNodePtr);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error creating new root node"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Unable to create new xml document structure"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid root node name :: %s", f_cRootNodeName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SaveXml
+/// Saves the document structure in an xml file
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlParser::SaveXml(std::string f_cFileName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_cFileName = "";
+
+ // if user explicitly provides file name
+ if (0 < f_cFileName.length()) {
+ l_cFileName.assign(f_cFileName);
+ } else { // takes the file name from the CXmlParser object
+ l_cFileName.assign(m_cFileName);
+ }
+
+ if (NULL != m_pXmlDoc) {
+ if (IsReadable(l_cFileName)) {
+ // save the doc structure to the file
+ if (-1 == xmlSaveFormatFileEnc(l_cFileName.c_str(), m_pXmlDoc, "UTF-8", 1)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "File not exists :: %s", f_cFileName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "m_pXmlDoc is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRootNode
+/// Gets the root node object of xml
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlParser::GetRootNode() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return m_pRootNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddNewNode
+/// Adds the new node to the parent node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlParser::AddNewNode(CXmlNode m_pParentNode, std::string f_cNewNodeName, std::string f_cContent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (!m_pParentNode.IsNull()) {
+ l_pXmlNode = m_pParentNode.AddChildNode(f_cNewNodeName, f_cContent); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveNode
+/// Removes the node from the xml
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlParser::RemoveNode(CXmlNode m_pNode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (!m_pNode.IsNull()) {
+ xmlUnlinkNode(m_pNode.m_pXmlNodePtr);
+ xmlFreeNode(m_pNode.m_pXmlNodePtr);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// FindNode
+/// Finds the first matching node, by tag name or path
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlParser::FindNode(std::string f_cNodePath, CXmlNode f_pCurrentNode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ xmlXPathObjectPtr l_pXpathObj = GetNodeSet(f_cNodePath, f_pCurrentNode); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (NULL != l_pXpathObj) {
+ if (NULL != l_pXpathObj->nodesetval && 0 < l_pXpathObj->nodesetval->nodeNr) {
+ l_pXmlNode.SetXmlNodePtr(l_pXpathObj->nodesetval->nodeTab[0]); // LCOV_EXCL_BR_LINE 11: except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NodeSetVal is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ xmlXPathFreeObject(l_pXpathObj); // LCOV_EXCL_BR_LINE 11: except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "xmlXPathObjectPtr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// FindAllNodes
+/// Finds all the matching node, by tag name or path
+////////////////////////////////////////////////////////////////////////////////////////////////
+TNodeList CXmlParser::FindAllNodes(std::string f_cNodePath, CXmlNode f_pCurrentNode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TNodeList l_pNodeList;
+
+ xmlXPathObjectPtr l_pXpathObj = GetNodeSet(f_cNodePath, f_pCurrentNode); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (NULL != l_pXpathObj) {
+ if (NULL != l_pXpathObj->nodesetval && 0 < l_pXpathObj->nodesetval->nodeNr) {
+ for (UI_8 l_uiSize = 0;
+ l_uiSize < l_pXpathObj->nodesetval->nodeNr;
+ l_uiSize++) {
+ if (NULL != l_pXpathObj->nodesetval->nodeTab[l_uiSize]) {
+ CXmlNode l_pNode(l_pXpathObj->nodesetval->nodeTab[l_uiSize]); // LCOV_EXCL_BR_LINE 11: except branch
+ l_pNodeList.push_back(l_pNode);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "node pointer is NULL");
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NodeSetVal is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ xmlXPathFreeObject(l_pXpathObj); // LCOV_EXCL_BR_LINE 11: except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "xmlXPathObjectPtr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pNodeList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetNodeSet
+/// Gets the node set resulting from search of nodepath using XPath
+////////////////////////////////////////////////////////////////////////////////////////////////
+xmlXPathObjectPtr CXmlParser::GetNodeSet(std::string f_cNodePath, CXmlNode f_pCurrentNode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ xmlXPathObjectPtr l_pXpathObj = NULL;
+
+ xmlXPathContextPtr l_pXpathCtx = NULL;
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlDoc) {
+ if (!f_pCurrentNode.IsNull()) {
+ l_pXmlNode = f_pCurrentNode;
+ }
+
+ // Create xpath evaluation context
+ l_pXpathCtx = xmlXPathNewContext(m_pXmlDoc); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (NULL != l_pXpathCtx) {
+ // set the current node in path context
+ l_pXpathCtx->node = l_pXmlNode.m_pXmlNodePtr;
+
+ // Evaluate xpath expression
+ l_pXpathObj = xmlXPathEvalExpression((const xmlChar *)f_cNodePath.c_str(), l_pXpathCtx); // LCOV_EXCL_BR_LINE 11: except branch
+
+ if (NULL == l_pXpathObj) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to evaluate nodepath :: \"%s\"", f_cNodePath.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ // Cleanup of XPath data
+ xmlXPathFreeContext(l_pXpathCtx); // LCOV_EXCL_BR_LINE 11: except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to create new XPath context"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "document object is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXpathObj;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ClearDocument
+/// Clears the document structure and resets the root node
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CXmlParser::ClearDocument() {
+ if (NULL != m_pXmlDoc) {
+ // free the document
+ xmlFreeDoc(m_pXmlDoc);
+ m_pXmlDoc = NULL;
+
+ // free the global variables that may have been allocated by the parser
+ xmlCleanupParser();
+ }
+
+ m_pRootNode = NULL;
+ m_cFileName.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsReadable
+/// Checks whether the file exists or not
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CXmlParser::IsReadable(const std::string &filename) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReadable = FALSE;
+
+ std::ifstream l_ifstream(filename.c_str());
+
+ if (l_ifstream.good()) {
+ l_bReadable = TRUE;
+ l_ifstream.close(); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReadable;
+}
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_attributes.cpp b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_attributes.cpp
new file mode 100644
index 00000000..27b6badc
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_attributes.cpp
@@ -0,0 +1,55 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_XmlParser
+/// \brief This file contains implementation of CXmlAttr class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_xmlparser_if.h>
+#include <string>
+#include "ns_xmlconfig_parser_frameworkunifiedlog.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CXmlAttr
+/// Constructor of CXmlAttr class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlAttr::CXmlAttr(): m_cKey(""), m_cValue("") {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CXmlAttr
+/// Parameterized constructor of CXmlAttr class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlAttr::CXmlAttr(std::string f_cKey, std::string f_cValue): m_cKey(f_cKey), m_cValue(f_cValue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CXmlAttr
+/// Destructor of CXmlAttr class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlAttr::~CXmlAttr() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
diff --git a/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_node.cpp b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_node.cpp
new file mode 100644
index 00000000..47f6caa8
--- /dev/null
+++ b/nsframework/framework_unified/client/NS_XMLConfigeParser/library/src/ns_xmlparser_node.cpp
@@ -0,0 +1,658 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_XmlParser
+/// \brief This file contains implementation of CXmlNode class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_xmlparser_if.h>
+#include <string>
+#include "ns_xmlconfig_parser_frameworkunifiedlog.h"
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CXmlNode
+/// Constructor
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode::CXmlNode(): m_pXmlNodePtr(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CXmlNode
+/// Parameterized Constructor
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode::CXmlNode(xmlNodePtr f_pXmlNodePtr): m_pXmlNodePtr(f_pXmlNodePtr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CXmlNode
+/// Destructor
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode::~CXmlNode() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetXmlNodePtr
+/// Sets the xmlNodePtr in class
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CXmlNode::SetXmlNodePtr(xmlNodePtr f_pXmlNodePtr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_pXmlNodePtr = f_pXmlNodePtr;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsNull
+/// Checks whether the node is valid or not
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CXmlNode::IsNull() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bNull = FALSE;
+
+ if (NULL == m_pXmlNodePtr) {
+ l_bNull = TRUE;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bNull;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Type
+/// Gets the type of node
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedXmlNodeTypes CXmlNode::Type() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedXmlNodeTypes l_eNodeType = FRAMEWORKUNIFIED_XML_NODE_NONE;
+
+ if (NULL != m_pXmlNodePtr) {
+ switch (m_pXmlNodePtr->type) {
+ case XML_ELEMENT_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ELEMENT_NODE;
+ break;
+ case XML_ATTRIBUTE_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ATTRIBUTE_NODE;
+ break;
+ case XML_TEXT_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_TEXT_NODE;
+ break;
+ case XML_CDATA_SECTION_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_CDATA_SECTION_NODE;
+ break;
+ case XML_ENTITY_REF_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ENTITY_REF_NODE;
+ break;
+ case XML_ENTITY_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ENTITY_NODE;
+ break;
+ case XML_PI_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_PI_NODE;
+ break;
+ case XML_COMMENT_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_COMMENT_NODE;
+ break;
+ case XML_DOCUMENT_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_DOCUMENT_NODE;
+ break;
+ case XML_DOCUMENT_TYPE_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_DOCUMENT_TYPE_NODE;
+ break;
+ case XML_DOCUMENT_FRAG_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_DOCUMENT_FRAG_NODE;
+ break;
+ case XML_NOTATION_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_NOTATION_NODE;
+ break;
+ case XML_HTML_DOCUMENT_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_HTML_DOCUMENT_NODE;
+ break;
+ case XML_DTD_NODE:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_DTD_NODE;
+ break;
+ case XML_ELEMENT_DECL:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ELEMENT_DECL;
+ break;
+ case XML_ATTRIBUTE_DECL:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ATTRIBUTE_DECL;
+ break;
+ case XML_ENTITY_DECL:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_ENTITY_DECL;
+ break;
+ case XML_NAMESPACE_DECL:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_NAMESPACE_DECL;
+ break;
+ case XML_XINCLUDE_START:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_XINCLUDE_START;
+ break;
+ case XML_XINCLUDE_END:
+ l_eNodeType = FRAMEWORKUNIFIED_XML_XINCLUDE_END;
+ break;
+ default:
+ break;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eNodeType;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Name
+/// Gets the name of node
+////////////////////////////////////////////////////////////////////////////////////////////////
+std::string CXmlNode::Name() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_cNodeName = "";
+
+ if (NULL != m_pXmlNodePtr && NULL != m_pXmlNodePtr->name) {
+ l_cNodeName = std::string((PCSTR)m_pXmlNodePtr->name); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_cNodeName;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetContent
+/// Gets the content of node
+////////////////////////////////////////////////////////////////////////////////////////////////
+std::string CXmlNode::GetContent() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_cText = "";
+
+ if ((NULL != m_pXmlNodePtr) &&
+ (NULL != m_pXmlNodePtr->children) &&
+ (XML_TEXT_NODE == m_pXmlNodePtr->children->type) &&
+ (NULL == m_pXmlNodePtr->children->next)) {
+ xmlChar * p_xmlText = xmlNodeGetContent(m_pXmlNodePtr);
+ l_cText = std::string((PCSTR)p_xmlText); // LCOV_EXCL_BR_LINE 11: except branch
+ xmlFree(p_xmlText); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_cText;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetContent
+/// Sets or updates the content of current node.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::SetContent(std::string f_cUpdatedText) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pXmlNodePtr) {
+ xmlNodeSetContent(m_pXmlNodePtr, (const xmlChar *)f_cUpdatedText.c_str());
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetAttributeValue
+/// Gets the attribute's value for the key.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::GetAttributeValue(std::string f_cKey, std::string &f_cAttributeValue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pXmlNodePtr) {
+ xmlChar *l_pAttrValue = xmlGetProp(m_pXmlNodePtr,
+ (const xmlChar *)f_cKey.c_str());
+ if (NULL != l_pAttrValue) {
+ f_cAttributeValue.assign((PCSTR)l_pAttrValue);
+
+ xmlFree(l_pAttrValue);
+ l_pAttrValue = NULL;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Attribute key :: %s not found", f_cKey.c_str());
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Node ptr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetAttributeValue
+/// Sets the attribute's value for the key
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::SetAttributeValue(std::string f_cKey, std::string f_cValue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "SetAttributeValue feature is not available,"
+ "Reason: This API is not supported by libxml2 present in PosixBasedOS001"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddNewAttribute
+/// Add new attribute to the node
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::AddNewAttribute(std::string f_cKey, std::string f_cAttributeValue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ xmlChar* p_key = reinterpret_cast<xmlChar*>(const_cast<char*>(f_cKey.c_str()));
+ xmlChar* p_value = reinterpret_cast<xmlChar*>(const_cast<char*>(f_cAttributeValue.c_str()));
+ if (NULL != m_pXmlNodePtr) {
+ if (NULL == xmlNewNsProp(m_pXmlNodePtr,
+ NULL,
+ p_key,
+ p_value)) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Unable to add new property :: %s", f_cKey.c_str());
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Node ptr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveAttribute
+/// Removes the attribute from the node with the specified key
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::RemoveAttribute(std::string f_cKey) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "RemoveAttribute feature is not available,"
+ "Reason: This API is not supported by libxml2 present in PosixBasedOS001"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetAttributeItems
+/// Gets the list of all the attribute's key and value of the node
+////////////////////////////////////////////////////////////////////////////////////////////////
+TAttrList CXmlNode::GetAttributeItems() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TAttrList l_cAttrList;
+ std::string l_cKey;
+ std::string l_cValue;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlAttrPtr l_pAttr = m_pXmlNodePtr->properties;
+ l_pAttr != NULL;
+ l_pAttr = l_pAttr->next) {
+ l_cKey = (PCSTR)l_pAttr->name;
+ l_cValue = "";
+
+ if (NULL != l_pAttr->children) {
+ l_cValue = (PCSTR)l_pAttr->children->content;
+ }
+
+ CXmlAttr l_pXmlAttr(l_cKey, l_cValue);
+ l_cAttrList.push_back(l_pXmlAttr); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_cAttrList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Parent
+/// Gets the parent node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::Parent() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlNodePtr && NULL != m_pXmlNodePtr->parent) {
+ if (XML_ELEMENT_NODE == m_pXmlNodePtr->parent->type) {
+ l_pXmlNode.SetXmlNodePtr(m_pXmlNodePtr->parent); // LCOV_EXCL_BR_LINE 11: except branch
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// FirstChild
+/// Gets the first child of node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::FirstChild() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->children;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->next) {
+ if (XML_ELEMENT_NODE == l_pNodePtr->type) {
+ l_pXmlNode.SetXmlNodePtr(l_pNodePtr); // LCOV_EXCL_BR_LINE 11: except branch
+ break;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// LastChild
+/// Gets the last child of node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::LastChild() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->last;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->prev) {
+ if (XML_ELEMENT_NODE == l_pNodePtr->type) {
+ l_pXmlNode.SetXmlNodePtr(l_pNodePtr); // LCOV_EXCL_BR_LINE 11: except branch
+ break;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// Children
+/// Gets the list of all the child node of current node
+////////////////////////////////////////////////////////////////////////////////////////////////
+TNodeList CXmlNode::Children() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TNodeList l_pNodeList;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->children;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->next) {
+ if (XML_ELEMENT_NODE == l_pNodePtr->type) {
+ CXmlNode l_pXmlNode(l_pNodePtr);
+ l_pNodeList.push_back(l_pXmlNode);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pNodeList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NextSibling
+/// Gets the next sibling node of current node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::NextSibling() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->next;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->next) {
+ if (XML_ELEMENT_NODE == l_pNodePtr->type) {
+ l_pXmlNode.SetXmlNodePtr(l_pNodePtr); // LCOV_EXCL_BR_LINE 11: except branch
+ break;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// PrevSibling
+/// Gets the previous sibling node of current node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::PrevSibling() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->prev;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->prev) {
+ if (XML_ELEMENT_NODE == l_pNodePtr->type) {
+ l_pXmlNode.SetXmlNodePtr(l_pNodePtr); // LCOV_EXCL_BR_LINE 11: except branch
+ break;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// FindChildNode
+/// Finds the first immediate sub node matching tag as f_cNodeName.
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::FindChildNode(std::string f_cNodeName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CXmlNode l_pXmlNode;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->children;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->next) {
+ if ((XML_ELEMENT_NODE == m_pXmlNodePtr->type) &&
+ (0 == f_cNodeName.compare((PCSTR)l_pNodePtr->name))) {
+ l_pXmlNode.SetXmlNodePtr(l_pNodePtr); // LCOV_EXCL_BR_LINE 11: except branch
+ break;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pXmlNode;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// FindAllChildNodes
+/// Gets the list of all the immediate sub node matching tag as f_cNodeName.
+////////////////////////////////////////////////////////////////////////////////////////////////
+TNodeList CXmlNode::FindAllChildNodes(std::string f_cNodeName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ TNodeList l_pNodeList;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pNodePtr = m_pXmlNodePtr->children;
+ l_pNodePtr != NULL;
+ l_pNodePtr = l_pNodePtr->next) {
+ if ((XML_ELEMENT_NODE == m_pXmlNodePtr->type) &&
+ (0 == f_cNodeName.compare((PCSTR)l_pNodePtr->name))) {
+ CXmlNode l_pXmlNode(l_pNodePtr);
+ l_pNodeList.push_back(l_pXmlNode);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pNodeList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetContentOfChildNode
+/// Finds the first level sub node matching tag as f_cNodeName.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::GetContentOfChildNode(std::string f_cNodeName, std::string &f_cContent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ CXmlNode l_pXmlNode = FindChildNode(f_cNodeName);
+
+ if (!l_pXmlNode.IsNull()) {
+ f_cContent.assign(l_pXmlNode.GetContent());
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddChildNode
+/// Adds sub node to the current node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::AddChildNode(std::string f_cNodeName, std::string f_cText) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // pointer of child node
+ xmlNodePtr l_pChildNode = NULL;
+
+ // content of child node
+ xmlChar *l_cNodeContent = NULL;
+
+ // validate the node name
+ if (NULL != m_pXmlNodePtr && 0 < f_cNodeName.length()) {
+ if (0 < f_cText.length()) {
+ xmlChar* p_text = reinterpret_cast<xmlChar*>(const_cast<char*>(f_cText.c_str()));
+ l_cNodeContent = p_text;
+ }
+
+ if (NULL == (l_pChildNode = xmlNewDocNode(m_pXmlNodePtr->doc,
+ m_pXmlNodePtr->ns,
+ (const xmlChar *)f_cNodeName.c_str(),
+ l_cNodeContent))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error creating child node");
+ } else {
+ l_pChildNode->type = XML_ELEMENT_NODE;
+ l_pChildNode->parent = m_pXmlNodePtr;
+ l_pChildNode->doc = m_pXmlNodePtr->doc;
+
+ // if there is no other child to the parent
+ if (m_pXmlNodePtr->children == NULL) {
+ m_pXmlNodePtr->children = l_pChildNode;
+ m_pXmlNodePtr->last = l_pChildNode;
+ } else { // else add the new child to the end of children list
+ // temp node
+ xmlNodePtr l_pTempNode = m_pXmlNodePtr->last;
+ l_pTempNode->next = l_pChildNode;
+ l_pChildNode->prev = l_pTempNode;
+
+ m_pXmlNodePtr->last = l_pChildNode;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return CXmlNode(l_pChildNode);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddSiblingNode
+/// Adds new node as sibling to the current node
+////////////////////////////////////////////////////////////////////////////////////////////////
+CXmlNode CXmlNode::AddSiblingNode(std::string f_cNodeName, std::string f_cText) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ xmlNodePtr l_pNewNode = NULL;
+ xmlNodePtr l_pSiblingNode = NULL;
+
+ if (NULL != m_pXmlNodePtr &&
+ !this->Parent().IsNull()) { // check whether the node is root node
+ if (NULL != (l_pNewNode = xmlNewNode(NULL,
+ (const xmlChar *)f_cNodeName.c_str()))) {
+ if (0 < f_cText.length()) {
+ xmlChar* p_text = reinterpret_cast<xmlChar*>(const_cast<char*>(f_cText.c_str()));
+ xmlNodeSetContent(l_pNewNode, p_text);
+ }
+
+ l_pSiblingNode = xmlAddSibling(m_pXmlNodePtr,
+ l_pNewNode);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return CXmlNode(l_pSiblingNode);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveChildNode
+/// Removes the child node from current node
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::RemoveChildNode(std::string f_cNodeName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ CXmlNode l_pXmlNode = FindChildNode(f_cNodeName);
+ if (!l_pXmlNode.IsNull()) {
+ xmlUnlinkNode(l_pXmlNode.m_pXmlNodePtr);
+ xmlFreeNode(l_pXmlNode.m_pXmlNodePtr);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ClearNode
+/// Clears the contents, attributes of node
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CXmlNode::ClearNode() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != m_pXmlNodePtr) {
+ for (xmlNodePtr l_pXmlNode = m_pXmlNodePtr->children;
+ l_pXmlNode != NULL;
+ l_pXmlNode = m_pXmlNodePtr->children) {
+ xmlUnlinkNode(l_pXmlNode);
+ xmlFreeNode(l_pXmlNode);
+ }
+
+ for (xmlAttrPtr l_pXmlAttr = m_pXmlNodePtr->properties;
+ l_pXmlAttr != NULL;
+ l_pXmlAttr = m_pXmlNodePtr->properties) {
+ xmlRemoveProp(l_pXmlAttr);
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/cfg/depends.mk b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/cfg/depends.mk
new file mode 100644
index 00000000..93b9f97a
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/cfg/depends.mk
@@ -0,0 +1,25 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+# Utilizing Base Domain Dependency File. Can override at any point
+include $(PRJ_ROOT)/../NativeServices/cfg/depends.mk
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__service_if.cpp b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__service_if.cpp
new file mode 100644
index 00000000..39657831
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__service_if.cpp
@@ -0,0 +1,367 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified__CWORD77__service_if.h>
+#include <native_service/ns__CWORD77__data_pool_if.h>
+#include <other_service/strlcpy.h>
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "ns__CWORD77__data_pool_internal.h"
+#include "ns__CWORD77__common_internal.h"
+
+#define NS__CWORD77__MAX_SESSION_RETRY_COUNT 10
+
+//////////////////////////////////////////
+/// Function : CFrameworkunified_CWORD77_Service
+//////////////////////////////////////////
+CFrameworkunified_CWORD77_Service::CFrameworkunified_CWORD77_Service()
+ : m_cbResponse(NULL),
+ m_cbSessionACK(NULL),
+ m_pSession(NULL),
+ m_cServiceName(""),
+ m_bServiceAvailable(FALSE),
+ m_ui8SessionRetryCount(0),
+ m_hApp(NULL) { // LCOV_EXCL_BR_LINE 11:except branch
+ m_SessTypeToSessObj.clear();
+}
+//////////////////////////////////////////
+/// Function : ~CFrameworkunified_CWORD77_Service
+//////////////////////////////////////////
+CFrameworkunified_CWORD77_Service::~CFrameworkunified_CWORD77_Service() { // LCOV_EXCL_BR_LINE 11:except branch
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.begin();
+ while (l_iter != m_SessTypeToSessObj.end()) {
+ CFrameworkunified_CWORD77_Session *l_pTemp = l_iter->second;
+ DELETEPTR(l_pTemp); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns__CWORD77__common.h"
+ l_iter++;
+ }
+}
+//////////////////////////////////////////
+/// Function : SetResponseCallback
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::SetResponseCallback(ResponseServiceTo_CWORD77_ cbResponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ m_cbResponse = cbResponse;
+ if (m_cbResponse == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __PRETTY_FUNCTION__, "Call back function ptr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.begin();
+ while (l_iter != m_SessTypeToSessObj.end()) {
+ if (l_iter->second != NULL) {
+ l_iter->second->SetResponseCallback(m_cbResponse);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Object ptr for session type[%d] is NULL ", l_iter->first);
+ }
+ l_iter++;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+//////////////////////////////////////////
+/// Function : SetSession
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::SetSession(CFrameworkunified_CWORD77_Session *f_pSessionObj) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ m_SessTypeToSessObj[f_pSessionObj->GetSessionType()] = f_pSessionObj;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+//////////////////////////////////////////
+/// Function : SendMessageToSession
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::SendMessageToSession(UI_32 f_uiSessionType, UI_32 f_uiSrvProtocol) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.begin();
+ l_iter = m_SessTypeToSessObj.find(f_uiSessionType);
+ if (l_iter != m_SessTypeToSessObj.end()) {
+ if (l_iter->second != NULL) {
+ if (eFrameworkunifiedStatusSessionErr == l_iter->second->HandleSessionMessage(f_uiSrvProtocol)) {
+ if (m_bServiceAvailable) {
+ if (NS__CWORD77__MAX_SESSION_RETRY_COUNT < m_ui8SessionRetryCount) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Unable to send cmd 0x%X."
+ " But, service is available. Open session req max limit reached [%s].",
+ f_uiSrvProtocol, m_cServiceName.c_str());
+ // TODO(framework_unified): what to do in case of max limit reached?
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Unable to send cmd 0x%X."
+ " But, service is available. Re-sending open session req [%s].",
+ f_uiSrvProtocol, m_cServiceName.c_str());
+ // send open session request
+ OpenSessionRetry(f_uiSessionType);
+ m_ui8SessionRetryCount++;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__, "Unable to send cmd 0x%X."
+ " Service not yet available.", f_uiSrvProtocol);
+ }
+ } else {
+ // ignore error, already printed by HandleSessionMessage
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Object ptr for session type[%d] is NULL ", l_iter->first);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Object is not there in Map for session type %d ", f_uiSessionType);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+//////////////////////////////////////////
+/// Function : OpenSession
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::OpenSession(HANDLE f_hApp, const std::string &f_sServiceName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __PRETTY_FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ m_cServiceName = f_sServiceName;
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.begin();
+ while (l_iter != m_SessTypeToSessObj.end()) {
+ if (l_iter->second != NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, " Sent open session request for session %d ", l_iter->first); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_iter->second->OpenSession(f_hApp, f_sServiceName); // LCOV_EXCL_BR_LINE 11:except branch
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Object ptr for session type[%d] is NULL ", l_iter->first);
+ }
+ l_iter++;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __PRETTY_FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+//////////////////////////////////////////
+/// Function : CloseSession
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::CloseSession(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.begin();
+ while (l_iter != m_SessTypeToSessObj.end()) {
+ if (l_iter->second != NULL) {
+ l_iter->second->CloseSession(f_hApp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Object ptr for session type[%d] is NULL ", l_iter->first);
+ }
+ l_iter++;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+//////////////////////////////////////////
+/// Function : OpenSessionAcks
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::OpenSessionAcks(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ OpenSessionAck tOpenSessAck;
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_ui8SessionRetryCount = 0;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &tOpenSessAck, sizeof(tOpenSessAck)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __PRETTY_FUNCTION__, "/***********************************************************************/");
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_,
+ __PRETTY_FUNCTION__,
+ "Open session ACK obtained for service: [%s] with session type: [%d]",
+ tOpenSessAck.cSessionName != 0 ? tOpenSessAck.cSessionName : NULL,
+ tOpenSessAck.sessionType);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __PRETTY_FUNCTION__, "/***********************************************************************/");
+ // LCOV_EXCL_BR_STOP
+ UI_32 l_uisessionType = tOpenSessAck.sessionType;
+ /// Session Acks
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.begin();
+ while (l_iter != m_SessTypeToSessObj.end()) {
+ if (l_iter->second != NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __PRETTY_FUNCTION__, "Get session type = %d", l_iter->second->GetSessionType()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ if (l_uisessionType == l_iter->second->GetSessionType()) {
+ l_iter->second->OpenSessionAcknowledge(f_hApp);
+
+ if (m_cbSessionACK != NULL) {
+ (VOID)m_cbSessionACK(f_hApp, m_cServiceName, tOpenSessAck.cSessionName, tOpenSessAck.sessionType,
+ tOpenSessAck.eStatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR,
+ __FUNCTION__,
+ "Unexpected Session_Type from service [%s]. Obtained Session_Type: [%d] != Expected Session_Type: [%d]",
+ tOpenSessAck.cSessionName != 0 ? tOpenSessAck.cSessionName : NULL,
+ l_uisessionType,
+ l_iter->second->GetSessionType()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Object ptr for session type[%d] is NULL ", l_iter->first);
+ }
+ l_iter++;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+//////////////////////////////////////////
+/// Function : OpenServiceOnAvailability
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Service::OpenServiceOnAvailability(HANDLE f_hApp, const std::string &f_sServiceName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ m_hApp = f_hApp;
+ m_bServiceAvailable = TRUE;
+ m_ui8SessionRetryCount = 0;
+ AttachOpenSessionAckCallback(f_hApp);
+ OpenSession(f_hApp, f_sServiceName);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return eStatus;
+}
+//////////////////////////////////////////
+/// Function : CloseServiceOnUnavailability
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Service::CloseServiceOnUnavailability(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ m_bServiceAvailable = FALSE;
+ m_ui8SessionRetryCount = 0;
+ CloseSession(f_hApp);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return eStatus;
+}
+
+//////////////////////////////////////////
+/// Function : AddNotification
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::AddNotification(PCSTR f_pNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ FrameworkunifiedNotificationCallbackHandler tNotifyStruct = {};
+ /**
+ * @todo
+ * Defining a NULL for argument f_pNotification results in a segmentation fault.
+ */
+ strlcpy(tNotifyStruct.cNotification, f_pNotification, sizeof(tNotifyStruct.cNotification)); // LCOV_EXCL_BR_LINE 11:except branch
+ tNotifyStruct.callBack = CCallback< CFrameworkunified_CWORD77_Service, &CFrameworkunified_CWORD77_Service::OnServiceNtf >::set(this); // LCOV_EXCL_BR_LINE 11:except branch
+ m_vServiceNotifications.push_back(tNotifyStruct); // LCOV_EXCL_BR_LINE 11:except branch
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+
+//////////////////////////////////////////
+/// Function : SubscribeNotifications
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Service::SubscribeNotifications(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t Size = m_vServiceNotifications.size();
+ for (size_t i = 0; i < Size; i++) {
+ if (m_vServiceNotifications[i].callBack != NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "Before subscribing notifications"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSubscribeNotificationWithCallback(f_hApp, m_vServiceNotifications[i].cNotification,
+ m_vServiceNotifications[i].callBack)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSubscribeNotificationWithCallback fail"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : UnSubscribeNotifications
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Service::UnSubscribeNotifications(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t Size = m_vServiceNotifications.size();
+ for (size_t i = 0; i < Size; i++) {
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedUnsubscribeNotificationWithCallback(f_hApp, m_vServiceNotifications[i].cNotification)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedUnsubscribeNotificationWithCallback fail");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+/// Function : OnServiceNtf
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Service::OnServiceNtf(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // CHAR l_cNotificationName[MAX_SYS_INFO_SIZE] = {};
+ PCSTR l_cNotificationName = FrameworkunifiedGetLastNotification(hApp);
+ // retrieve notification name
+ // FrameworkunifiedGetSystemInfo(hApp, l_cNotificationName);
+
+ UI_32 l_uiLength = FrameworkunifiedGetMsgLength(hApp);
+ if (l_uiLength != 0) {
+ std::vector<char> data;
+ data.resize(l_uiLength);
+ if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &data[0], l_uiLength))) {
+ SetRespNotfnDataIn_CWORD77_DataPool(l_cNotificationName, static_cast<UI_32>(data.size()), &data[0]);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Error, "
+ "Resp Notfn Data not set in _CWORD77_ data pool, status: 0x%x", l_eStatus);
+ }
+ } else {
+ SetRespNotfnDataIn_CWORD77_DataPool(l_cNotificationName, 0, NULL);
+ }
+
+ m_cbResponse(hApp, NOTIFICATION, m_cServiceName);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+/// Function : OpenSessionRetry
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::OpenSessionRetry(UI_32 f_ui32SessionType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_FUNC, __FUNCTION__, "+");
+ if (!m_cServiceName.empty() && (NULL != m_hApp)) {
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *>::iterator l_iter;
+ l_iter = m_SessTypeToSessObj.find(f_ui32SessionType);
+ if (l_iter != m_SessTypeToSessObj.end()) {
+ if (NULL != l_iter->second) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "Re-sending open session req for session type %d ", l_iter->first);
+ l_iter->second->OpenSession(m_hApp, m_cServiceName);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Object ptr for session type[%d] is NULL ", l_iter->first);
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Can't retry for open session req. Service name: [%s], hApp:[%p].",
+ m_cServiceName.c_str(),
+ m_hApp);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_FUNC, __FUNCTION__, "-");
+}
+
+//////////////////////////////////////////
+/// Function : Set_CWORD77_OpenSessionACK
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Service::Set_CWORD77_OpenSessionACK(SessionAckTo_CWORD77_ cbResponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ m_cbSessionACK = cbResponse;
+ if (NULL == m_cbSessionACK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __PRETTY_FUNCTION__, "Call back function ptr is NULL"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__session_if.cpp b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__session_if.cpp
new file mode 100644
index 00000000..1211f915
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified__CWORD77__session_if.cpp
@@ -0,0 +1,325 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified__CWORD77__session_if.h>
+#include <native_service/ns__CWORD77__data_pool_if.h>
+#include <boost/bind.hpp>
+#include <utility>
+#include <vector>
+#include "ns__CWORD77__data_pool_internal.h"
+#include "ns__CWORD77__common_internal.h"
+
+//////////////////////////////////////////
+/// Function : CFrameworkunified_CWORD77_Session
+//////////////////////////////////////////
+CFrameworkunified_CWORD77_Session::CFrameworkunified_CWORD77_Session() {
+ m_hSession = NULL;
+ m_hApp = NULL;
+ m_hService = NULL;
+ m_uiSessionType = 0;
+}
+//////////////////////////////////////////
+/// Function : ~CFrameworkunified_CWORD77_Session
+//////////////////////////////////////////
+CFrameworkunified_CWORD77_Session::~CFrameworkunified_CWORD77_Session() { // LCOV_EXCL_BR_LINE 11:except branch
+}
+
+void CFrameworkunified_CWORD77_Session::SetSessionType(const UI_32 &sessioType) {
+ m_uiSessionType = sessioType;
+}
+
+//////////////////////////////////////////
+/// Function : GetSessionType
+//////////////////////////////////////////
+UI_32 CFrameworkunified_CWORD77_Session::GetSessionType() {
+ return m_uiSessionType;
+}
+//////////////////////////////////////////
+/// Function : SetResponseCallback
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Session::SetResponseCallback(ResponseServiceTo_CWORD77_ f_cbResponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ m_ResponseTo_CWORD77_ = f_cbResponse;
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+//////////////////////////////////////////
+/// Function : AddProtocolHandler
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Session::AddProtocolHandler(UI_32 f_uiCmdId, CbFuncPtr f_cbFuncPtr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ FrameworkunifiedProtocolCallbackHandler l_tProtocolCallback;
+ l_tProtocolCallback.iCmd = f_uiCmdId;
+ l_tProtocolCallback.callBack = f_cbFuncPtr;
+ m_vSessionProtocolHanlder.push_back(l_tProtocolCallback);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+//////////////////////////////////////////
+/// Function : AddEventHandler
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Session::AddEventHandler(UI_32 f_uiCmdId, CbFuncPtr f_cbFuncPtr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ FrameworkunifiedProtocolCallbackHandler l_tProtocolCallback;
+ l_tProtocolCallback.iCmd = f_uiCmdId;
+ l_tProtocolCallback.callBack = f_cbFuncPtr;
+ m_vSessionEventHandler.push_back(l_tProtocolCallback);
+ m_vEventVector.push_back(f_uiCmdId); // Code added by Shyam
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+//////////////////////////////////////////
+/// Function : AttachProtocolwithDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::AttachProtocolwithDispatcher(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_uiSize = m_vSessionProtocolHanlder.size();
+ PCSTR l_pRequester = FrameworkunifiedGetMsgSrc(f_hApp);
+ for (size_t i = 0; i < l_uiSize; i++) {
+ FrameworkunifiedAttachCallbackToDispatcher(f_hApp, l_pRequester, m_vSessionProtocolHanlder[i].iCmd,
+ m_vSessionProtocolHanlder[i].callBack, m_hSession);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : DetachProtocolwithDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::DetachProtocolwithDispatcher(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_uiSize = m_vSessionProtocolHanlder.size();
+ PCSTR l_pRequester = FrameworkunifiedGetMsgSrc(f_hApp);
+ for (size_t i = 0; i < l_uiSize; i++) {
+ FrameworkunifiedDetachCallbackFromDispatcher(f_hApp, l_pRequester, m_vSessionProtocolHanlder[i].iCmd,
+ m_hSession);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : AttachEventswithDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::AttachEventswithDispatcher(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_uiSize = m_vEventVector.size();
+
+ for (size_t i = 0; i < l_uiSize; i++) {
+ l_eStatus = FrameworkunifiedRegisterEvent(m_hSession, m_vEventVector[i]);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : AttachEventswithDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::RegisterEvents(HANDLE f_hApp) {
+ // Function: added by Shyam to overcome the naming conflict in registering the event
+ return AttachEventswithDispatcher(f_hApp);
+}
+
+//////////////////////////////////////////
+/// Function : AttachEventHandlerswithDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::AttachEventHandlerswithDispatcher(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_uiSize = m_vSessionEventHandler.size();
+ PCSTR l_pRequester = FrameworkunifiedGetMsgSrc(f_hApp);
+ for (size_t i = 0; i < l_uiSize; i++) {
+ FrameworkunifiedAttachCallbackToDispatcher(f_hApp, l_pRequester, m_vSessionEventHandler[i].iCmd,
+ m_vSessionEventHandler[i].callBack, m_hSession);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+//////////////////////////////////////////
+/// Function : DetachEventHandlerswithDispatcher
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::DetachEventHandlerswithDispatcher(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_uiSize = m_vSessionEventHandler.size();
+ PCSTR l_pRequester = FrameworkunifiedGetMsgSrc(f_hApp);
+ for (size_t i = 0; i < l_uiSize; i++) {
+ FrameworkunifiedDetachCallbackFromDispatcher(f_hApp, l_pRequester, m_vSessionEventHandler[i].iCmd,
+ m_hSession);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+/// Function : HandleSessionMessage
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::HandleSessionMessage(UI_32 cmdID) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ UI_32 size = 0;
+ PVOID data = NULL;
+
+ if (NULL != m_hSession && NULL != m_hService) {
+ eStatus = GetReqDataFrom_CWORD77_DataPool(std::make_pair(cmdID, FrameworkunifiedGetSessionName(m_hService)), size, data);
+
+ if (eFrameworkunifiedStatusOK == eStatus) {
+ eStatus = FrameworkunifiedSendMsg(m_hSession, cmdID, size, data);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg() returned %d", eStatus);
+ }
+ } else if (eFrameworkunifiedStatusDbRecNotFound == eStatus) {
+ // FIXME: This is added to help, if there is any command with no data. So, that services
+ // don't need to provide _CWORD77_ interfaces for such command.
+ // Correct way to solve the problem is, let services provide one _CWORD77_ interface
+ // which will write 0 length in data pool.
+ // Impact: This may have one impact that, service is expecting some data, but
+ // _CWORD77_ sends data with 0 length because it didn't find anything in the data pool.
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_WAR, __FUNCTION__,
+ "GetReqDataFrom_CWORD77_DataPool() returned %d. But, still sending cmd 0x%X to service %s with length 0.",
+ eStatus, cmdID, FrameworkunifiedGetSessionName(m_hService));
+ eStatus = FrameworkunifiedSendMsg(m_hSession, cmdID, 0, NULL);
+ if (eFrameworkunifiedStatusOK != eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg() returned %d", eStatus);
+ }
+ // end fixme
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "GetReqDataFrom_CWORD77_DataPool() returned %d. Can't send cmd 0x%X to service %s.",
+ eStatus, cmdID, FrameworkunifiedGetSessionName(m_hService));
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Error: HandleSessionMessage: Error sending cmd 0x%X request to service."
+ " Session handle %p Service Handle %p", cmdID, m_hSession, m_hService);
+ if (NULL == m_hSession) {
+ eStatus = eFrameworkunifiedStatusSessionErr;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "- %d", eStatus);
+ return eStatus;
+}
+
+//////////////////////////////////////////
+/// Function : AttachResponseCallbacks
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Session::AttachResponseCallbacks(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ UI_32 l_uiCount = 0;
+ PCSTR l_pRequester = FrameworkunifiedGetMsgSrc(f_hApp);
+
+ // attach response protocols
+ UI_32 const *l_uiResponseProtocol = GetResponseProtocolArray();
+ if (NULL != l_uiResponseProtocol) {
+ for (; l_uiCount < GetResponseProtocolArrayLength(); l_uiResponseProtocol++, l_uiCount++) {
+ FrameworkunifiedAttachCallbackToDispatcher(f_hApp, l_pRequester, *l_uiResponseProtocol,
+ boost::bind(&CFrameworkunified_CWORD77_Session::OnResponse, this, f_hApp), m_hSession);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "No Response protocols available for session with %s",
+ FrameworkunifiedGetSessionName(m_hService));
+ }
+
+ // attach events
+ l_uiCount = 0;
+ UI_32 const *l_uiEvents = GetEventArray();
+ if (NULL != l_uiEvents) {
+ for (; l_uiCount < GetEventArrayLength(); l_uiEvents++, l_uiCount++) {
+ // attach callback
+ FrameworkunifiedAttachCallbackToDispatcher(f_hApp, l_pRequester, *l_uiEvents,
+ boost::bind(&CFrameworkunified_CWORD77_Session::OnResponse, this, f_hApp), m_hSession); // LCOV_EXCL_BR_LINE 11:except branch
+ // register event
+ FrameworkunifiedRegisterEvent(m_hSession, *l_uiEvents);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "No event protocols available for session with %s",
+ FrameworkunifiedGetSessionName(m_hService));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+
+//////////////////////////////////////////
+/// Function : DetachResponseCallbacks
+//////////////////////////////////////////
+void CFrameworkunified_CWORD77_Session::DetachResponseCallbacks(HANDLE f_hApp) {
+ if (NULL != m_hSession) {
+ UI_32 l_uiCount = 0;
+ PCSTR l_cSessionName = FrameworkunifiedGetSessionName(m_hSession);
+ // detach response protocols
+ UI_32 const *l_uiResponseProtocol = GetResponseProtocolArray();
+ if (NULL != l_uiResponseProtocol) {
+ for (; l_uiCount < GetResponseProtocolArrayLength(); l_uiResponseProtocol++, l_uiCount++) {
+ FrameworkunifiedDetachCallbackFromDispatcher(f_hApp, l_cSessionName, *l_uiResponseProtocol, m_hSession);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "No Response protocols available for session with %s",
+ FrameworkunifiedGetSessionName(m_hService));
+ }
+
+ // detach and unregister events
+ l_uiCount = 0;
+ UI_32 const *l_uiEvents = GetEventArray();
+ if (NULL != l_uiEvents) {
+ for (; l_uiCount < GetEventArrayLength(); l_uiEvents++, l_uiCount++) {
+ FrameworkunifiedDetachCallbackFromDispatcher(f_hApp, l_cSessionName, *l_uiEvents, m_hSession);
+ FrameworkunifiedUnRegisterEvent(m_hSession, *l_uiEvents);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "No event protocols available for session with %s",
+ FrameworkunifiedGetSessionName(m_hService));
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Detach not required. Session not yet available");
+ }
+}
+
+//////////////////////////////////////////
+/// Function : OnResponse
+//////////////////////////////////////////
+EFrameworkunifiedStatus CFrameworkunified_CWORD77_Session::OnResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ UI_32 length = FrameworkunifiedGetMsgLength(f_hApp);
+ UI_32 cmdId = FrameworkunifiedGetMsgProtocol(f_hApp);
+ PCSTR l_cMsgSourceName = FrameworkunifiedGetMsgSrc(f_hApp);
+ if (NULL != l_cMsgSourceName) {
+ if (length != 0) {
+ std::vector<char> data;
+ data.resize(length);
+ eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &data[0], length);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "OnResponse from %s cmdId:%d", l_cMsgSourceName, cmdId);
+ SetRespDataIn_CWORD77_DataPool(std::make_pair(cmdId, l_cMsgSourceName), static_cast<UI_32>(data.size()), &data[0]);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "OnResponse from %s cmdId:[%d], Value: [NULL]", l_cMsgSourceName, cmdId);
+ SetRespDataIn_CWORD77_DataPool(std::make_pair(cmdId, l_cMsgSourceName), 0, NULL);
+ }
+
+ m_ResponseTo_CWORD77_(f_hApp, RESPONSE, l_cMsgSourceName);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error: Setting response value of cmd 0x%X in data pool.", cmdId);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "- %d", eStatus);
+ return eStatus;
+}
+
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified_stub.h b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified_stub.h
new file mode 100644
index 00000000..68efb44c
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/frameworkunified_stub.h
@@ -0,0 +1,20 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS__CWORD77__SERVICEIF_SRC_FRAMEWORKUNIFIED_STUB_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS__CWORD77__SERVICEIF_SRC_FRAMEWORKUNIFIED_STUB_H_
+extern size_t strlcpy(char *destination, const char *source, size_t size);
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS__CWORD77__SERVICEIF_SRC_FRAMEWORKUNIFIED_STUB_H_
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/makefile_PosixBasedOS001
new file mode 100644
index 00000000..88693cd7
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/makefile_PosixBasedOS001
@@ -0,0 +1,208 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Module Makefile version 2.0
+#
+
+# Name of the componet (team/domain prefix '_' component name)
+COMPONENT_NAME = NS__CWORD77__ServiceIf
+
+ifndef PRJ_ROOT
+export PRJ_ROOT = $(CURDIR)/../
+endif
+include $(PRJ_ROOT)cfg/depends.mk
+
+# Name of the componet (team/domain prefix '_' component name)
+# This must be the same as the RTC Component name and Eclipse Project Name
+COMPONENT_NAME = NS__CWORD77__ServiceIf
+
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS +=
+
+# Set local includes and then the reference includes (priority order determines search path)
+# Default pattern are any configuration includes (which would be things like PosixBasedOS001), local (Team) component directories,
+# dependencies includes (other teams)
+# Local (current component references should be in the form of
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/directory
+# Example your public include directory would be
+# $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+# Team references should only be to other's public includes such as
+# $(CC_IFLAG)$(TEAM_ROOT)NS_MessageCenter/inc
+# Global (non-team) references should be only to other's public includes such
+# these are found in the depends include file and captured in the (DEPENDS_INCLUDES) variable
+INCLUDES = \
+ $(CFG_INCS) \
+ $(CC_IFLAG)./ \
+ $(DEPENDS_INCLUDES) \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_NAME)/inc
+
+
+# Do the same if you need to include library paths as well
+# Do an incremental in case additional library paths are defined
+# at the top-level make. Use similar guidelines as for includes
+# for example to include a team component library it would be
+# $(TEAM_ROOT)NS_MessageCenter/lib/NS_MessageCenter/
+LIB_PATHS += \
+ $(DEPENDS_LIB_PATHS) \
+
+
+
+# Define binary outputs. These can be libraries or executables.
+# Name a variable for each deliverable. Suffixes should be
+# EXEC - For Executables -> output to the bin directory
+#TIME_EXEC = $(BIN_PATH)time
+# LIB - For Static Libraries -> output to lib directory with specific naming
+#MATH_LIB = $(LIB_PATH)$(LIB_PREFIX)math.$(LIB_EXT)
+# SLIB - For Shared Objects
+#FRMWRK_SLIB = $(SLIB_PATH)frmwrk.$(SO_EXT)
+# LIB - Define the static library for Message Queue
+#
+#
+ifdef DYNAMIC
+ COMPONENT_LIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+else
+ COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+endif
+
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.c) \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+
+#
+# Convert the source files to object files with correct folder location.
+#
+#
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+
+
+# All headers that are dependencies. Wildcard is easy to pickup local headers.
+# This is only to automate the rebuilding, all builds on the servers are cleans
+# So this is not a huge deal when building on a component level.
+HEADERS = \
+ $(wildcard *.h) \
+ $(wildcard $(TEAM_ROOT)$(COMPONENT_NAME)/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/native/*.h) \
+ $(wildcard $(TEAM_ROOT)NativeServices/inc/_CWORD77_/*.h) \
+
+
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+#DYNAMIC_LIBS += \
+# xml2 \
+# m
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+debug:
+ $(MAKE) TARGET=arm DEBUG=TRUE all
+
+base: banner module_dirs subdirs local
+
+# Standard Building of Source Files (Default builds for all objects defined above)
+$(C_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CC_CMD)
+
+$(CPP_LANG_OBJECTS): $(SOURCES) $(HEADERS)
+ $(CPP_CMD)
+
+local: $(OBJECTS)
+
+# Defines specific for each deliverable
+
+# For a static library
+$(COMPONENT_LIB): $(OBJECTS)
+ifdef DYNAMIC
+# For a dynamic library
+ $(SLIB_CMD)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --only-keep-debug $(@) $(@).debug
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --strip-all $(@)
+ $(HIDE_ECHO_FLAG)$(OBJCPY) --add-gnu-debuglink=$(@).debug $(@)
+else
+# For a static library
+ $(AR_CMD)
+endif
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(COMPONENT_LIB).map
+ -rm -f $(COMPONENT_LIB).debug
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+module_dirs: build_dirs
+
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__common_internal.h b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__common_internal.h
new file mode 100644
index 00000000..78f96a75
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__common_internal.h
@@ -0,0 +1,51 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// @defgroup tag_HMI_CWORD77_Controller HMI _CWORD77_ Controller
+/// @file ns__CWORD77__common_internal.h
+/// @brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef NS_NS__CWORD77__SERVICEIF_SRC_NS__CWORD77__COMMON_INTERNAL_H_ // NOLINT (readability/nolint)
+#define NS_NS__CWORD77__SERVICEIF_SRC_NS__CWORD77__COMMON_INTERNAL_H_
+
+#include <native_service/ns__CWORD77__types.h>
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+EFrameworkunifiedStatus Set_CWORD77_DataPoolKeyValue(std::string Key, std::string Value);
+std::string Get_CWORD77_DataPoolKeyValue(std::string Key);
+
+template <typename T>
+UI_32 _CWORD77_GetMsgLength(HANDLE hApp) {
+ UI_32 uiLength = FrameworkunifiedGetMsgLength(hApp);
+ return (uiLength / sizeof(T));
+}
+
+template <typename T>
+EFrameworkunifiedStatus _CWORD77_GetMsgData(HANDLE hApp, T *pData) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_8 *pTemp = reinterpret_cast<UI_8 *>(pData);
+ eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, pTemp, sizeof(T));
+ return eStatus;
+}
+
+#endif // NS_NS__CWORD77__SERVICEIF_SRC_NS__CWORD77__COMMON_INTERNAL_H_ // NOLINT (readability/nolint)
+//@}
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_internal.h b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_internal.h
new file mode 100644
index 00000000..1ad792ed
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_internal.h
@@ -0,0 +1,64 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// @file ns__CWORD77__data_pool_internal.h
+/// @brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef NS_NS__CWORD77__SERVICEIF_SRC_NS__CWORD77__DATA_POOL_INTERNAL_H_ // NOLINT (readability/nolint)
+#define NS_NS__CWORD77__SERVICEIF_SRC_NS__CWORD77__DATA_POOL_INTERNAL_H_
+
+#include <native_service/ns__CWORD77__types.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRespDataIn_CWORD77_DataPool
+/// API to set data associated with response into _CWORD77_ Data Pool
+///
+/// \param [in] f_DataPoolKey
+/// _CWORD77_DataPoolKey - Data pool key
+/// \param [in] f_uiSize
+/// UI_32 - size of the data
+/// \param [in] f_pData
+/// PVOID - void pointer to data
+///
+/// \return VOID - None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID SetRespDataIn_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 f_uiSize, const PVOID f_pData);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetReqDataIn_CWORD77_DataPool
+/// API to get data associated with request from _CWORD77_ Data Pool
+///
+/// \param [in] f_DataPoolKey
+/// _CWORD77_DataPoolKey - Data pool key
+/// \param [in] f_uiSize
+/// UI_32 - size of the data
+/// \param [in] f_pData
+/// PVOID - void pointer to data
+///
+/// \return EFrameworkunifiedStatus - Succes or Error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetReqDataFrom_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData); // NOLINT (readability/nolint)
+
+#endif // NS_NS__CWORD77__SERVICEIF_SRC_NS__CWORD77__DATA_POOL_INTERNAL_H_ // NOLINT (readability/nolint)
+//@}
diff --git a/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_table.cpp b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_table.cpp
new file mode 100644
index 00000000..b48062ae
--- /dev/null
+++ b/nsframework/framework_unified/client/NS__CWORD77__ServiceIf/src/ns__CWORD77__data_pool_table.cpp
@@ -0,0 +1,538 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns__CWORD77__data_pool_table.h>
+#include <native_service/ns__CWORD77__data_pool_if.h>
+#include <vector>
+#include <string>
+#include <map>
+#include <utility>
+#include "ns__CWORD77__data_pool_internal.h"
+#include "ns__CWORD77__common_internal.h"
+
+C_CWORD77_DataPool g__CWORD77_DataPool;
+C_CWORD77_DataPool *C_CWORD77_DataPool::m_p_CWORD77_DataPoolInstance = NULL;
+
+// For getting/setting notification data from data pool,
+// data key will be pair<g_uiNotificationDataPoolId,"NotificationName">
+static const UI_32 g_uiNotificationDataPoolId = 0;
+
+/////////////////////////////////////////////////////////////////////////////////
+/// NoOfElementsinData
+/////////////////////////////////////////////////////////////////////////////////
+UI_32 NoOfElementsinData(std::string Input) {
+ std::string first = "";
+ std::istringstream ss(Input);
+ int i = 0;
+ while (!ss.eof()) {
+ getline(ss, first, ',');
+ if (first != "") {
+ i++;
+ }
+ }
+ return i;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// ConvertArrayStringsToString
+/////////////////////////////////////////////////////////////////////////////////
+std::string ConvertArrayStringsToString(std::string *strArr, int Size) {
+ int length = 0;
+ std::string Result;
+ if (strArr == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "strArr is NULL");
+ Result.append("");
+ return Result;
+ }
+ while (length < Size) {
+ Result.append(strArr[length]);
+ Result.append(",");
+ length++;
+ }
+ Result.append("");
+ return Result;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// ConvertStringToArrString
+/////////////////////////////////////////////////////////////////////////////////
+void ConvertStringToArrString(std::string Input, std::string *strArr,
+ UI_32 &ArraySize) { // NOLINT (readability/nolint)
+ if (strArr == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "strArr is NULL");
+ return;
+ }
+ int i = 0;
+ std::string first = "";
+ std::istringstream ss(Input);
+ while (!ss.eof()) {
+ getline(ss, first, ',');
+ if (first != "") {
+ strArr[i] = first;
+ i++;
+ }
+ }
+ ArraySize = i;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// C_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+C_CWORD77_DataPool::C_CWORD77_DataPool() {
+ m__CWORD77_DataRequestTable.clear();
+ m__CWORD77_DataResponseTable.clear();
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// ~C_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+C_CWORD77_DataPool::~C_CWORD77_DataPool() {
+ m__CWORD77_DataRequestTable.clear();
+ m__CWORD77_DataResponseTable.clear();
+}
+
+//////////////////////////////////////////
+/// Function : GetInstance
+//////////////////////////////////////////
+C_CWORD77_DataPool *C_CWORD77_DataPool::GetInstance() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "GetInstance");
+ if (m_p_CWORD77_DataPoolInstance == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "Before creating object");
+ m_p_CWORD77_DataPoolInstance = new C_CWORD77_DataPool();
+ }
+ return m_p_CWORD77_DataPoolInstance;
+}
+
+//////////////////////////////////////////
+/// Function : DeleteInstance
+//////////////////////////////////////////
+void C_CWORD77_DataPool::DeleteInstance() {
+ DELETEPTR(m_p_CWORD77_DataPoolInstance);
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetValueFromMap
+/////////////////////////////////////////////////////////////////////////////////
+void C_CWORD77_DataPool::GetValueFromMap(ETableType TableType, UI_32 VarName, EDataType &DataType, std::string &Strvalue) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::map<UI_32, _CWORD77_Data>::iterator iter;
+ std::string temp;
+
+ if (TableType == REQUEST_TABLE) {
+ iter = m__CWORD77_DataRequestTable.begin();
+ iter = m__CWORD77_DataRequestTable.find(VarName);
+ if (iter != m__CWORD77_DataRequestTable.end()) {
+ DataType = iter->second.DataType;
+ temp = iter->second.DataValue;
+ }
+ } else {
+ iter = m__CWORD77_DataResponseTable.begin();
+ iter = m__CWORD77_DataResponseTable.find(VarName);
+ if (iter != m__CWORD77_DataResponseTable.end()) {
+ DataType = iter->second.DataType;
+ temp = iter->second.DataValue;
+ }
+ }
+ Strvalue.assign(temp);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetValueinMap
+/////////////////////////////////////////////////////////////////////////////////
+void C_CWORD77_DataPool::SetValueinMap(ETableType TableType, UI_32 VarName, EDataType VarType, std::string Result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ _CWORD77_Data t_CWORD77_Data;
+ t_CWORD77_Data.DataType = VarType;
+ t_CWORD77_Data.DataValue = Result;
+ if (TableType == REQUEST_TABLE) {
+ m__CWORD77_DataRequestTable[VarName] = t_CWORD77_Data;
+ } else {
+ m__CWORD77_DataResponseTable[VarName] = t_CWORD77_Data;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetNoofElementsofData
+/////////////////////////////////////////////////////////////////////////////////
+UI_32 C_CWORD77_DataPool::GetNoofElementsofData(ETableType TableType, UI_32 KeyName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EDataType DataType = UNKNOWNTYPE;
+ std::string Result = "";
+ GetValueFromMap(TableType, KeyName, DataType, Result);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return NoOfElementsinData(Result);
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetDataType
+/////////////////////////////////////////////////////////////////////////////////
+EDataType C_CWORD77_DataPool::GetDataType(ETableType TableType, UI_32 KeyName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EDataType DataType = UNKNOWNTYPE;
+ std::string Result = "";
+ GetValueFromMap(TableType, KeyName, DataType, Result);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return DataType;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetArrayStringData
+/////////////////////////////////////////////////////////////////////////////////
+void C_CWORD77_DataPool::SetArrayStringData(ETableType TableType, UI_32 VarName, EDataType VarType,
+ std::string DataValue[], UI_32 size) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::string Result = ConvertArrayStringsToString(DataValue, size);
+ SetValueinMap(TableType, VarName, VarType, Result);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetArrayStringData
+/////////////////////////////////////////////////////////////////////////////////
+void C_CWORD77_DataPool::GetArrayStringData(ETableType TableType, UI_32 VarName, std::string DataValue[], UI_32 &size) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::string Result = "";
+ EDataType DataType = UNKNOWNTYPE;
+ GetValueFromMap(TableType, VarName, DataType, Result);
+ ConvertStringToArrString(Result, DataValue, size);
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRequestArrayStringData
+/////////////////////////////////////////////////////////////////////////////////
+void SetRequestArrayStringData(UI_32 VarName, EDataType VarType, std::string DataValue[], UI_32 size) {
+ g__CWORD77_DataPool.SetReqArrayStringData(VarName, VarType, DataValue, size);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// SetResponseArrayStringData
+/////////////////////////////////////////////////////////////////////////////////
+void SetResponseArrayStringData(UI_32 VarName, EDataType VarType, std::string DataValue[], UI_32 size) {
+ g__CWORD77_DataPool.SetRespArrayStringData(VarName, VarType, DataValue, size);
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRequestArrayStringData
+/////////////////////////////////////////////////////////////////////////////////
+void GetRequestArrayStringData(UI_32 VarName, std::string DataValue[],
+ UI_32 &size) { // NOLINT (readability/nolint)
+ g__CWORD77_DataPool.GetReqArrayStringData(VarName, DataValue, size);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetResponseArrayStringData
+/////////////////////////////////////////////////////////////////////////////////
+void GetResponseArrayStringData(UI_32 VarName, std::string DataValue[],
+ UI_32 &size) { // NOLINT (readability/nolint)
+ g__CWORD77_DataPool.GetRespArrayStringData(VarName, DataValue, size);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRequestStringData
+/////////////////////////////////////////////////////////////////////////////////
+
+void SetRequestStringData(UI_32 VarName, EDataType VarType, std::string DataValue) {
+ g__CWORD77_DataPool.SetReqStringData(VarName, VarType, DataValue);
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetResponseStringData
+/////////////////////////////////////////////////////////////////////////////////
+void SetResponseStringData(UI_32 VarName, EDataType VarType, std::string DataValue) {
+ g__CWORD77_DataPool.SetRespStringData(VarName, VarType, DataValue);
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRequestStringData
+/////////////////////////////////////////////////////////////////////////////////
+std::string GetRequestStringData(UI_32 VarName) {
+ return g__CWORD77_DataPool.GetReqStringData(VarName);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRequestDataSize
+/////////////////////////////////////////////////////////////////////////////////
+UI_32 GetRequestDataSize(UI_32 Key) {
+ return g__CWORD77_DataPool.GetReqDataSize(Key);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetResponseDataSize
+/////////////////////////////////////////////////////////////////////////////////
+UI_32 GetResponseDataSize(UI_32 Key) {
+ return g__CWORD77_DataPool.GetRespDataSize(Key);
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRequestDataType
+/////////////////////////////////////////////////////////////////////////////////
+EDataType GetRequestDataType(UI_32 Key) {
+ return g__CWORD77_DataPool.GetReqDataType(Key);
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetResponseDataType
+/////////////////////////////////////////////////////////////////////////////////
+EDataType GetResponseDataType(UI_32 Key) {
+ return g__CWORD77_DataPool.GetRespDataType(Key);
+}
+
+
+
+C_CWORD77_Data *C_CWORD77_Data::m_p_CWORD77_DataInstance = NULL;
+
+/////////////////////////////////////////////////////////////////////////////////
+/// Constructor
+/////////////////////////////////////////////////////////////////////////////////
+C_CWORD77_Data::C_CWORD77_Data() {
+ m__CWORD77_RequestDataTable.clear();
+ m__CWORD77_ResponseDataTable.clear();
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// Destructor
+/////////////////////////////////////////////////////////////////////////////////
+C_CWORD77_Data::~C_CWORD77_Data() {
+ m__CWORD77_RequestDataTable.clear();
+ m__CWORD77_ResponseDataTable.clear();
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetInstacne
+/////////////////////////////////////////////////////////////////////////////////
+C_CWORD77_Data *C_CWORD77_Data::GetInstance() {
+ if (m_p_CWORD77_DataInstance == NULL) {
+ m_p_CWORD77_DataInstance = new C_CWORD77_Data(); // LCOV_EXCL_BR_LINE 11:except branch
+ }
+ return m_p_CWORD77_DataInstance;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// DeleteInstance
+/////////////////////////////////////////////////////////////////////////////////
+void C_CWORD77_Data::DeleteInstance() {
+ delete m_p_CWORD77_DataInstance;
+ m_p_CWORD77_DataInstance = NULL;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRequData
+/////////////////////////////////////////////////////////////////////////////////
+VOID C_CWORD77_Data::SetRequData(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 f_uiSize, PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::vector<CHAR> &DataVector = m__CWORD77_RequestDataTable[f_DataPoolKey];
+ CHAR *l_pTemp = static_cast<CHAR *>(f_pData);
+ DataVector.assign(l_pTemp, (l_pTemp + f_uiSize));
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRequData
+/////////////////////////////////////////////////////////////////////////////////
+VOID C_CWORD77_Data::SetRequData(UI_32 f_uiMsgId, UI_32 f_uiSize, PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::vector<CHAR> &DataVector = m__CWORD77_RequestDataTableOrig[f_uiMsgId];
+ CHAR *l_pTemp = static_cast<CHAR *>(f_pData);
+ DataVector.assign(l_pTemp, (l_pTemp + f_uiSize));
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRespoData
+/////////////////////////////////////////////////////////////////////////////////
+VOID C_CWORD77_Data::SetRespoData(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 f_uiSize, const PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ std::vector<CHAR> &DataVector = m__CWORD77_ResponseDataTable[f_DataPoolKey];
+ CHAR *l_pTemp = static_cast<CHAR *>(f_pData);
+ DataVector.assign(l_pTemp, (l_pTemp + f_uiSize));
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRespoData
+/////////////////////////////////////////////////////////////////////////////////
+VOID C_CWORD77_Data::SetRespoData(UI_32 f_uiMsgId, UI_32 f_uiSize, const PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ std::vector<CHAR> &DataVector = m__CWORD77_ResponseDataTableOrig[f_uiMsgId];
+ CHAR *l_pTemp = static_cast<CHAR *>(f_pData);
+ DataVector.assign(l_pTemp, (l_pTemp + f_uiSize));
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRequData
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus C_CWORD77_Data::GetRequData(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 &f_uiSize, PVOID &f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusDbRecNotFound; // data not found in data pool
+ T_CWORD77_DataPool::iterator l_iter;
+
+ l_iter = m__CWORD77_RequestDataTable.find(f_DataPoolKey);
+ if (l_iter != m__CWORD77_RequestDataTable.end()) {
+ f_uiSize = static_cast<UI_32>(l_iter->second.size());
+ if (f_uiSize > 0) {
+ f_pData = &l_iter->second[0];
+ } else {
+ f_pData = NULL;
+ }
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRequData
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus C_CWORD77_Data::GetRequData(UI_32 f_uiMsgId, UI_32 &f_uiSize, PVOID &f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusDbRecNotFound; // data not found in data pool
+ std::map<UI_32, std::vector<CHAR> >::iterator l_iter;
+
+ l_iter = m__CWORD77_RequestDataTableOrig.find(f_uiMsgId);
+ if (l_iter != m__CWORD77_RequestDataTableOrig.end()) {
+ f_uiSize = static_cast<UI_32>(l_iter->second.size());
+ if (f_uiSize > 0) {
+ f_pData = &l_iter->second[0];
+ } else {
+ f_pData = NULL;
+ }
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRespoData
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus C_CWORD77_Data::GetRespoData(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 &f_uiSize, PVOID &f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ T_CWORD77_DataPool::iterator l_iter;
+ l_iter = m__CWORD77_ResponseDataTable.find(f_DataPoolKey);
+ if (l_iter != m__CWORD77_ResponseDataTable.end()) {
+ f_uiSize = static_cast<UI_32>(l_iter->second.size());
+ if (f_uiSize > 0) {
+ /**
+ * @todo
+ * If *f_pData is set to NULL, a segmentation fault occurs.
+ */
+ f_pData = &l_iter->second[0];
+ } else {
+ f_pData = NULL;
+ }
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return l_eStatus;
+}
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRespoData
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus C_CWORD77_Data::GetRespoData(UI_32 f_uiMsgId,
+ UI_32 &f_uiSize, PVOID &f_pData) { // NOLINT (readability/nolint)
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::map<UI_32, std::vector<CHAR> >::iterator l_iter;
+ l_iter = m__CWORD77_ResponseDataTableOrig.find(f_uiMsgId);
+ if (l_iter != m__CWORD77_ResponseDataTableOrig.end()) {
+ f_uiSize = static_cast<UI_32>(l_iter->second.size());
+ if (f_uiSize > 0) {
+ f_pData = &l_iter->second[0];
+ } else {
+ f_pData = NULL;
+ }
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// SetReqDataIn_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+VOID SetReqDataIn_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 f_uiSize, PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ if (C_CWORD77_Data::GetInstance()) {
+ C_CWORD77_Data::GetInstance()->SetRequData(f_DataPoolKey, f_uiSize, f_pData);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRespDataIn_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+VOID SetRespDataIn_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 f_uiSize, const PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ if (C_CWORD77_Data::GetInstance()) {
+ C_CWORD77_Data::GetInstance()->SetRespoData(f_DataPoolKey, f_uiSize, f_pData);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// SetRespNotfnDataIn_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+VOID SetRespNotfnDataIn_CWORD77_DataPool(const std::string &f_cNotificationName, // NOLINT (readability/nolint)
+ UI_32 f_uiSize, const PVOID f_pData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ if (C_CWORD77_Data::GetInstance()) {
+ // LCOV_EXCL_BR_START 11:except branch
+ C_CWORD77_Data::GetInstance()->SetRespoData(std::make_pair(g_uiNotificationDataPoolId, f_cNotificationName), f_uiSize, // LCOV_EXCL_BR_LINE 11:except branch
+ f_pData);
+ // LCOV_EXCL_BR_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetReqDataFrom_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetReqDataFrom_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData) { // NOLINT (readability/nolint)
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if (C_CWORD77_Data::GetInstance()) {
+ l_eStatus = C_CWORD77_Data::GetInstance()->GetRequData(f_DataPoolKey, f_uiSize, f_pData);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRespDataFrom_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetRespDataFrom_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData) { // NOLINT (readability/nolint)
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if (C_CWORD77_Data::GetInstance()) {
+ l_eStatus = C_CWORD77_Data::GetInstance()->GetRespoData(f_DataPoolKey, f_uiSize, f_pData);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+/// GetRespDataFrom_CWORD77_DataPool
+/////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetRespNotfnDataFrom_CWORD77_DataPool(const std::string &f_cNotificationName, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData) { // NOLINT (readability/nolint)
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if (C_CWORD77_Data::GetInstance()) {
+ // LCOV_EXCL_BR_START 11:except branch
+ l_eStatus = C_CWORD77_Data::GetInstance()->GetRespoData(std::make_pair(g_uiNotificationDataPoolId, f_cNotificationName),
+ f_uiSize, f_pData);
+ // LCOV_EXCL_BR_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NS__CWORD77_, __FUNCTION__, "-"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ return l_eStatus;
+}
diff --git a/nsframework/framework_unified/client/NativeServices/Makefile b/nsframework/framework_unified/client/NativeServices/Makefile
new file mode 100644
index 00000000..c346b289
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/Makefile
@@ -0,0 +1,29 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+SUBDIRS = src
+
+
+all:
+
+install-data:install_cfg
+
+install_cfg:
+ install -d -m 775 $(SDKTARGETSYSROOT)/usr/agl/conf/ns_logger
+ install -m 644 -t $(SDKTARGETSYSROOT)/usr/agl/conf/ns_logger scfg/ns_logger_frameworkunifiedlog__CWORD84_.cfg
+
+include ../../../native_service.mk
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_arm.mk b/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_arm.mk
new file mode 100644
index 00000000..3baa0f25
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_arm.mk
@@ -0,0 +1,88 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# QCC arm COMPILER SETTINGS
+# Standard form of tool.mk file configured for PosixBasedOS001 vmware
+
+# Tools and Options
+LIB_EXT = a
+SO_EXT = so
+LIB_PREFIX = lib
+OBJ_EXT = o
+BIN_EXT =
+CC = qcc -c
+CPP = qcc -c
+AS = ntoarm-as
+AR = ntoarm-ar
+LD = qcc
+# Add addtion Linker Flags....
+# If your application contains c++ code you will need
+# the -lang-c++
+LD_CPP = -lang-c++
+
+# Compile options and commands
+TARGET_FLG = -Vgcc_ntoarmle
+
+# Set Debug Flag
+ifdef DEBUG
+CC_DEBUG_FLG = -g
+DEBUG_EXT=_g
+endif
+
+# Set Profiling Flag
+ifdef PROFILING
+CC_PROFILING_FLG = -p
+endif
+
+# Set Optimization Flag
+ifeq ($(OPTIMIZATION),OPTIMIZE)
+CC_OPT_FLG = -O2
+else
+ifeq ($(OPTIMIZATION),FULL_OPTIMIZE)
+CC_OPT_FLG = -O3
+else
+ifeq ($(OPTIMIZATION),NONE)
+CC_OPT_FLG =
+endif
+endif
+endif
+
+
+# Compiler Options
+CC_OFLAG = -o
+CC_IFLAG = -I
+CC_FLAGS = $(TARGET_FLG) -w9 -Wc,-Wall -shared $(CC_OPT_FLG) $(CC_PROFILING_FLG) $(CC_DEBUG_FLG)
+CC_TARGET = $(@)
+CC_CMD = $(CC) $(CC_FLAGS) $(DEFS) $(INCLUDES) $(@F:.$(OBJ_EXT)=.c) -o $(@)
+CPP_CMD = $(CPP) $(CC_FLAGS) $(DEFS) $(INCLUDES) $(@F:.$(OBJ_EXT)=.cpp) -o $(@)
+
+# Archive Options (Static Library)
+AR_OFLAG =
+AR_FLAGS = -r
+AR_CMD = $(AR) $(AR_FLAGS) $(AR_OFLAG)$(@) $^
+
+# Linker Options
+# Executable
+# Used in the form of $(LD_CMD) -L[Library Paths] -l[libraries] [objects] $(LD_OFLAG) executable_name.$(BIN_EXT)
+LD_FLAGS = $(TARGET_FLG) $(CC_PROFILING_FLG) $(CC_DEBUG_FLG) $(LD_CPP)
+LD_OFLAG = -o
+LD_CMD = $(LD) -L$(LIB_PATH) $(LD_FLAGS)
+EXEC_CMD = $(LD_CMD) $(LD_OFLAG) $(@) $(OBJECTS) $(addprefix -L , $(LIB_PATHS)) -Bstatic $(addprefix -l , $(STATIC_LIBS)) -Bdynamic $(addprefix -l , $(DYNAMIC_LIBS))
+
+# To create shared objects use the linker command but add -shared
+SO_CMD = $(LD) $(LD_FLAGS) -shared
+SLIB_CMD = $(SO_CMD) $^ $(LD_OFLAG) $(@) $(addprefix -L, $(LIB_PATHS)) \
+ -Bstatic $(addprefix -l,$(STATIC_LIBS)) -Bdynamic $(addprefix -l,$(DYNAMIC_LIBS))
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_armv7.mk b/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_armv7.mk
new file mode 100644
index 00000000..68d15dad
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_armv7.mk
@@ -0,0 +1,96 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# QCC arm COMPILER SETTINGS
+# Standard form of tool.mk file configured for PosixBasedOS001 arm v7
+# Note: Make sure PosixBasedOS001_HOST is set to install version desired
+
+# Tools and Options
+LIB_EXT = a
+SO_EXT = so
+LIB_PREFIX = lib
+OBJ_EXT = o
+BIN_EXT =
+CC = ${PosixBasedOS001_HOST}/usr/bin/qcc -c
+CPP = ${PosixBasedOS001_HOST}/usr/bin/qcc -c
+AS = ${PosixBasedOS001_HOST}/usr/bin/ntoarmv7-as
+AR = ${PosixBasedOS001_HOST}/usr/bin/ntoarmv7-ar
+OBJCPY := ${PosixBasedOS001_HOST}/usr/bin/ntoarmv7-objcopy
+LD = qcc
+# Add addtion Linker Flags....
+# If your application contains c++ code you will need
+# the -lang-c++
+LD_CPP = -lang-c++ #-lm
+
+# Compile options and commands
+TARGET_FLG = -Vgcc_ntoarmv7le
+
+# Define Map file Option
+MAP_FILE_FLG=-M
+
+# Set Debug Flag
+ifdef DEBUG
+CC_DEBUG_FLG = -g
+DEBUG_EXT=_g
+endif
+
+# Set Profiling Flag
+ifdef PROFILING
+CC_PROFILING_FLG = -p
+endif
+
+# Set Optimization Flag (precident to force none, force full, force basic, or default remain as defined)
+ifeq ($(OPTIMIZATION),OPTIMIZE)
+CC_OPT_FLG = -O2
+else
+ifeq ($(OPTIMIZATION),FULL_OPTIMIZE)
+CC_OPT_FLG = -O3
+else
+ifeq ($(OPTIMIZATION),NONE)
+CC_OPT_FLG =
+endif
+endif
+endif
+
+
+# Compiler Options
+CC_OFLAG = -o
+CC_IFLAG = -I
+CC_FLAGS = $(TARGET_FLG) -w9 -Wc,-Wall -shared $(CC_OPT_FLG) $(CC_PROFILING_FLG) $(CC_DEBUG_FLG)
+CC_TARGET = $(@)
+CC_CMD = $(CC) $(CC_FLAGS) $(DEFS) $(INCLUDES) $(@F:.$(OBJ_EXT)=.c) -o $(@)
+CPP_CMD = $(CPP) $(CC_FLAGS) $(DEFS) $(INCLUDES) $(@F:.$(OBJ_EXT)=.cpp) -o $(@)
+CPP_D_CMD = arm-unknown-nto-PosixBasedOS001.5.0eabi-gcc.exe -c $(DEFS) $(INCLUDES) -MM -MP $< > $(@:.o=.d)
+
+# Archive Options (Static Library)
+AR_OFLAG =
+AR_FLAGS = -r
+AR_CMD = $(AR) $(AR_FLAGS) $(AR_OFLAG)$(@) $^
+
+# Linker Options
+# Executable
+# Used in the form of $(LD_CMD) -L[Library Paths] -l[libraries] [objects] $(LD_OFLAG) executable_name.$(BIN_EXT)
+LD_FLAGS = $(TARGET_FLG) $(CC_PROFILING_FLG) $(CC_DEBUG_FLG) $(LD_CPP)
+LD_OFLAG = -o
+LD_CMD = $(LD) -L$(LIB_PATH) $(LD_FLAGS) $(MAP_FILE_FLG)
+EXEC_CMD = $(LD_CMD) $(LD_OFLAG) $(@) $(OBJECTS) $(addprefix -L , $(LIB_PATHS)) \
+ -Bstatic $(addprefix -l , $(STATIC_LIBS)) -Bdynamic $(addprefix -l , $(DYNAMIC_LIBS))
+
+# To create shared objects use the linker command but add -shared
+SO_CMD = $(LD) $(LD_FLAGS) -shared $(MAP_FILE_FLG)
+SLIB_CMD = $(SO_CMD) $^ $(LD_OFLAG) $(@) $(addprefix -L, $(LIB_PATHS)) \
+ -Bstatic $(addprefix -l,$(STATIC_LIBS)) -Bdynamic $(addprefix -l,$(DYNAMIC_LIBS))
+
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_x86.mk b/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_x86.mk
new file mode 100644
index 00000000..528e7eab
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/PosixBasedOS001_x86.mk
@@ -0,0 +1,89 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# QCC x86 COMPILER SETTINGS
+# Standard form of tool.mk file configured for PosixBasedOS001 vmware
+
+# Tools and Options
+LIB_EXT = a
+SO_EXT = so
+LIB_PREFIX = lib
+OBJ_EXT = o
+BIN_EXT =
+CC = qcc -c
+CPP = qcc -c
+AS = qcc -c
+AR = qcc -a
+LD = qcc
+LD_CPP = -lang-c++ #-lm
+OBJCPY := ${PosixBasedOS001_HOST}/usr/bin/ntox86-objcopy
+
+# Compile options and commands
+TARGET_FLG = -Vgcc_ntox86
+
+# Set Debug Flag
+ifdef DEBUG
+CC_DEBUG_FLG = -g
+DEBUG_EXT=_g
+endif
+
+# Define Map file Option
+MAP_FILE_FLG=-M
+
+# Set Profiling Flag
+ifdef PROFILING
+CC_PROFILING_FLG = -p
+endif
+
+# Set Optimization Flag (precident to force none, force full, force basic, or default remain as defined)
+ifeq ($(OPTIMIZATION),OPTIMIZE)
+CC_OPT_FLG = -O2
+else
+ifeq ($(OPTIMIZATION),FULL_OPTIMIZE)
+CC_OPT_FLG = -O3
+else
+ifeq ($(OPTIMIZATION),NONE)
+CC_OPT_FLG =
+endif
+endif
+endif
+
+
+# Compiler Options
+CC_OFLAG = -o
+CC_IFLAG = -I
+CC_FLAGS = $(TARGET_FLG) -w9 -Wc,-Wall -shared $(CC_OPT_FLG) $(CC_PROFILING_FLG) $(CC_DEBUG_FLG) $(CC_OPT_FLG)
+CC_TARGET = $(@)
+CC_CMD = $(CC) $(CC_FLAGS) $(DEFS) $(INCLUDES) $(@F:.$(OBJ_EXT)=.c*) -o $(@)
+CPP_CMD = $(CPP) $(CC_FLAGS) $(DEFS) $(INCLUDES) $(@F:.$(OBJ_EXT)=.cpp) -o $(@)
+CPP_D_CMD = i486-pc-nto-PosixBasedOS001.5.0-gcc.exe $(DEFS) $(INCLUDES) -MM $< > $(@:.o=.d)
+
+# Archive Options (Static Library)
+AR_OFLAG =
+AR_FLAGS =
+AR_CMD = $(AR) $(AR_FLAGS) $(AR_OFLAG)$(@) $^
+
+# Linker Options
+# Executable
+# Used in the form of $(LD_CMD) -L[Library Paths] -l[libraries] [objects] $(LD_OFLAG) executable_name.$(BIN_EXT)
+LD_FLAGS = $(TARGET_FLG) $(CC_PROFILING_FLG) $(CC_DEBUG_FLG) $(LD_CPP)
+LD_OFLAG = -o
+LD_CMD = $(LD) -L$(LIB_PATH) $(LD_FLAGS) $(MAP_FILE_FLG)
+
+# To create shared objects use the linker command but add -shared
+SO_CMD = $(LD) $(LD_FLAGS) -shared $(MAP_FILE_FLG)
+SLIB_CMD = $(SO_CMD) $^ $(LD_OFLAG) $(@) $(addprefix -L, $(LIB_PATHS)) \
+ -Bstatic $(addprefix -l,$(STATIC_LIBS)) -Bdynamic $(addprefix -l,$(DYNAMIC_LIBS))
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/analysis.mk b/nsframework/framework_unified/client/NativeServices/cfg/analysis.mk
new file mode 100644
index 00000000..c1e14fd5
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/analysis.mk
@@ -0,0 +1,73 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# QCC arm COMPILER SETTINGS
+# Standard form of tool.mk file configured for PosixBasedOS001 vmware
+
+#Add PosixBasedOS001 binary tools to path
+PATH := $(PosixBasedOS001_HOME)/usr/bin/;$(PATH)
+
+# include the compiler definitions in which we are linting against
+include $(PRJ_ROOT)/cfg/PosixBasedOS001_armv7.mk
+
+# Tools and Options
+CODE_COUNT = surveyor
+LINT = lint-nt
+CC_IFLAG = -i
+
+CC_DEFS = -D__LANGUAGE_C -D_LANGUAGE_C -D__PosixBasedOS001__ -D__PosixBasedOS001__ \
+ -D__GNUC__=4 -D__GNUC_MINOR__=4 -D__GNUC_PATCHLEVEL__=2 \
+ -D__unix__ -D__unix -D__ELF__ -D__ARM__ -D__arm__ \
+ -D__ARM_ARCH_4__ -D__APCS_32__ -D__LITTLEENDIAN__ -D__ARMEL__ -D_MUDFLAPTH
+
+CPP_DEFS = -D__cplusplus -D__PosixBasedOS001__ -D__PosixBasedOS001__ \
+ -D__GNUC__=4 -D__GNUC_MINOR__=4 -D__GNUC_PATCHLEVEL__=2 \
+ -D__NO_INLINE__ -D__DEPRECATED -D__EXCEPTIONS \
+ -D__unix__ -D__unix -D__ELF__ -D__ARM__ -D__arm__ \
+ -D__ARM_ARCH_4__ -D__APCS_32__ -D__LITTLEENDIAN__ -D__ARMEL__ -D_MUDFLAPTH
+
+LINT_C_INCLUDES = \
+ $(CC_IFLAG)C:/lint.PosixBasedOS001 \
+ $(CC_IFLAG)$(PosixBasedOS001_TARGET)/usr/include \
+
+LINT_CPP_INCLUDES = \
+ $(CC_IFLAG)C:/lint.PosixBasedOS001 \
+ $(CC_IFLAG)$(PosixBasedOS001_TARGET)/usr/include \
+ $(CC_IFLAG)$(PosixBasedOS001_HOST)/usr/lib/gcc/arm-unknown-nto-PosixBasedOS001.5.0/4.4.2/include \
+ $(CC_IFLAG)$(PosixBasedOS001_TARGET)/usr/include/cpp/c \
+ $(CC_IFLAG)$(PosixBasedOS001_TARGET)/usr/include/cpp \
+
+LINT_SOURCES := $(shell find .. -iname "*.c" -or -iname "*.cc" -or -iname "*.cpp")
+LINT_IMPLIED_DIRS := $(addprefix $(CC_IFLAG), $(sort $(dir $(shell find .. -iname "*.c" -or -iname "*.cc" -or -iname "*.cpp"))))
+
+# Metric Rule
+metrics:
+ @echo --------------------
+ @echo Start metrics on $(COMPONENT_NAME)
+ @echo --------------------
+ -@mkdir -p $(PRJ_ROOT)/ana/metrics
+ -@$(CODE_COUNT) -detailed -progress -out $(PRJ_ROOT)/ana/metrics/metrics_$(COMPONENT_NAME).csv ..
+
+# Static Analysis Rule
+lint:
+ @echo --------------------
+ @echo Performing Lint on $(COMPONENT_NAME)
+ @echo --------------------
+ @echo includes the following files:
+ @echo $(LINT_SOURCES)
+ @echo --------------------
+ -@c:/lint/$(LINT) $(PRJ_ROOT)cfg/options.lnt C:/lint.PosixBasedOS001/co-gcc.lnt $(CC_DEFS) $(LINT_C_INCLUDES) $(INCLUDES) $(LINT_IMPLIED_DIRS) $(filter %.c ,$(LINT_SOURCES))
+ -@c:/lint/$(LINT) $(PRJ_ROOT)cfg/options.lnt C:/lint.PosixBasedOS001/co-gcc.lnt $(CPP_DEFS) $(LINT_CPP_INCLUDES) $(INCLUDES) $(LINT_IMPLIED_DIRS) $(filter %.cpp %.cc %.cxx,$(LINT_SOURCES) )
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/common.mk b/nsframework/framework_unified/client/NativeServices/cfg/common.mk
new file mode 100644
index 00000000..10a9a6bb
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/common.mk
@@ -0,0 +1,175 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+####################################################################
+# DO NOT EDIT THIS FILE
+# Common Project Makefile definitions shared by all types of makefiles
+#
+#
+# Please use project.mk in your build folder to customize your build
+#######################################################################
+
+include $(PRJ_ROOT)cfg/depends.mk
+
+ifndef COMPONENT_ROOT
+export COMPONENT_ROOT=$(COMPONENT_NAME)
+endif
+
+# Additive Compile Flags (Flags from initiating make process will still apply)
+DEFS += $(PROJECT_FLAGS)
+
+# Set local includes and then the reference includes (priority order determines search path)
+INCLUDES = \
+ $(CC_IFLAG)./ \
+ $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_ROOT)/inc \
+ $(addprefix $(CC_IFLAG),$(PROJECT_INCLUDE_PATHS)) \
+ $(DEPENDS_INCLUDES) \
+
+
+# Do the same if you need to include library paths as well
+LIB_PATHS += \
+ $(PROJECT_LIB_PATHS) \
+ $(DEPENDS_LIB_PATHS) \
+
+
+LD_STATIC_LIBS += \
+ $(PROJECT_STATIC_LIBS)
+
+LD_DYNAMIC_LIBS += \
+ $(PROJECT_DYNAMIC_LIBS)
+
+## Sources Section
+
+# Define Library & Executable Sources (on a per deliverable basis)
+# This includes sources located in subdirectories.
+
+# Define generic line that pulls all c, cc, cpp files
+# since your in the src folder is pull only files from there
+COMPONENT_SRCS = \
+ $(wildcard *.cpp)
+
+# Define sources that my not be local to your component
+# here, you can define indivial files or wildcard from
+# a different folder.
+NON_LOCAL_SRCS = \
+
+
+# List of all sources to be built. Can be assembled from the other defintitions.
+# This only defines sources for the current directory, so if there are subdirectories
+# those are not included. (Those are found in simple subdirectory makefiles that only
+# direct the building of sources, but no linking into a binary)
+SOURCES = \
+ $(COMPONENT_SRCS) \
+ $(NON_LOCAL_SRCS) \
+
+
+# Convert the source files to object files with correct folder location.
+C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
+CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
+
+
+# List of all sources to be generated. Can be assembled from the other defintitions.
+OBJECTS = \
+ $(C_LANG_OBJECTS) \
+ $(CPP_LANG_OBJECTS)
+
+D_FILES = $(OBJECTS:.o=.d)
+
+# pull in dependency info for existing .o files
+-include $(D_FILES)
+
+
+ifeq ($(BUILDTYPE),APP)
+COMPONENT_EXEC = $(BIN_PATH)$(COMPONENT_NAME)$(DEBUG_EXT)
+BINARIES = \
+ $(COMPONENT_EXEC)
+
+$(COMPONENT_EXEC): $(OBJECTS)
+ $(LD_CMD) $(LD_OFLAG) $(@) $(OBJECTS) $(addprefix -L , $(LIB_PATHS)) -Bstatic $(addprefix -l , $(LD_STATIC_LIBS)) -Bdynamic $(addprefix -l , $(LD_DYNAMIC_LIBS))
+
+endif
+
+ifeq ($(BUILDTYPE),DLL)
+COMPONENT_SOLIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
+LIBRARIES = \
+ $(COMPONENT_SOLIB) \
+
+$(COMPONENT_SOLIB): $(OBJECTS)
+ $(SO_CMD) $(OBJECTS) $(LD_OFLAG) $(@) $(addprefix -L, $(LIB_PATHS)) \
+ -Bstatic $(addprefix -l,$(STATIC_LIBS)) -Bdynamic $(addprefix -l,$(DYNAMIC_LIBS))
+
+endif
+
+ifeq ($(BUILDTYPE),LIB)
+COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
+LIBRARIES = \
+ $(COMPONENT_LIB) \
+
+$(COMPONENT_LIB): $(OBJECTS)
+ $(AR_CMD)
+
+endif
+
+
+
+# Make targets
+# Standard
+all: banner module_dirs subdirs local library binary
+
+base: banner module_dirs subdirs local
+
+
+$(BLD_PATH)/%.o: %.cpp
+ $(CPP_CMD)
+ $(CPP_D_CMD)
+ @mv -f $(@:.o=.d) $(@:.o=.d).tmp
+ @sed -e 's|.*: |$@: |' < $(@:.o=.d).tmp > $(@:.o=.d)
+ @rm -f $(@:.o=.d).tmp
+
+local: $(OBJECTS)
+
+# Standard set of derived targets
+library: base \
+ $(LIBRARIES)
+ @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
+
+binary: base \
+ $(BINARIES)
+
+# Subdirs should be to jump to subdirectories
+# standard form is of
+# $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
+subdirs:
+
+clean:
+ -rm -f $(BINARIES)
+ -rm -f $(LIBRARIES)
+ -rm -f $(OBJECTS)
+ -rm -f $(D_FILES)
+
+-v:
+ @echo "objs: --> $(OBJECTS)"
+ @echo "sources: --> $(SOURCES)"
+ @echo "headers: --> $(HEADERS)"
+ @echo "includes: --> $(INCLUDES)"
+ @echo "lib paths: --> $(LIB_PATHS)"
+ @echo "static libs: --> $(LD_STATIC_LIBS)"
+ @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
+ @echo "lib: --> $(LIBRARIES)"
+ @echo "bin: --> $(BINARIES)"
+
+
+module_dirs: build_dirs
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/config.mk b/nsframework/framework_unified/client/NativeServices/cfg/config.mk
new file mode 100644
index 00000000..5eb23f4f
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/config.mk
@@ -0,0 +1,115 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Configuration Makefile version 2.0
+#
+
+.SUFFIXES:
+
+# Setup configuration exports to make sure other "subprojects" have the correct configuration settings.
+# Export shared variables
+export DEFS
+export LIBS
+export LIB_PATHS
+
+# Export setup
+export MAKE_DEPS := $(PRJ_ROOT)cfg/depends.mk
+export MAKE_CFG := $(TOOLS_CFG)config.mk
+
+# Set the location of build files. By default all build files become local to the initating location of the build so
+# one doesn't impact a referenced project
+# Alteratively a directed path can also be supported.
+ifndef PRJ_OUTPUT_ROOT
+PRJ_OUTPUT_ROOT = $(PRJ_ROOT)
+endif
+
+# Select Compiler Tool by name and select the tool configuration file
+# default behavior is to generate for arm
+ifeq ($(TARGET),analysis)
+export MAKE_TOOLS := $(TOOLS_CFG)analysis.mk
+else
+ifeq ($(TARGET),x86)
+export MAKE_TOOLS := $(TOOLS_CFG)PosixBasedOS001_x86.mk
+else
+ifeq ($(TARGET),armle)
+export MAKE_TOOLS := $(TOOLS_CFG)PosixBasedOS001_arm.mk
+else
+export MAKE_TOOLS := $(TOOLS_CFG)PosixBasedOS001_armv7.mk
+TARGET = armle-v7
+endif
+endif
+endif
+
+
+# Set specific flags as path suffixes to make sure the right build options are picked up
+ifdef DEBUG
+BUILD_CFG+=/debug
+endif
+ifdef PROFILING
+BUILD_CFG+=/profile
+endif
+ifndef BUILD_CFG
+BUILD_CFG=/release
+endif
+
+# Set File Paths
+export BIN_PATH := $(PRJ_OUTPUT_ROOT)bin/$(TARGET)$(BUILD_CFG)/
+export BLD_PATH := $(PRJ_OUTPUT_ROOT)bld/$(TARGET)$(BUILD_CFG)/$(COMPONENT_NAME)/
+export LIB_PATH := $(PRJ_OUTPUT_ROOT)lib/$(TARGET)$(BUILD_CFG)/
+export SLIB_PATH := $(PRJ_OUTPUT_ROOT)dll/$(TARGET)$(BUILD_CFG)/
+export BUILD_DIRS = $(BIN_PATH) $(LIB_PATH) $(SLIB_PATH) $(BLD_PATH)
+export BUILD_ROOTS := $(addprefix $(PRJ_OUTPUT_ROOT), bin bld lib dll)
+
+# Set Staging Location - set to a default location to prevent accidents
+ifndef STAGE_LOCATION
+export STAGE_LOCATION = C:/temp/stage/
+endif
+
+# Now include the defintions that have been exported
+include $(MAKE_TOOLS)
+
+# Add additional configuration includes reflective of project and decisions expressed in include makefiles.
+# So local includes, base infrastructure, and target platform.
+# This is also the variable to add local overriding header file locations for configuration in makefiles
+# prior to spawning to subprojects. Which means if you want to utilize different header files than those
+# the project you are going to build this will force an early search path to override with.
+ifndef CFG_INCS
+ export CFG_INCS +=
+endif
+
+# Standard Targets (and defaults)
+all:
+
+subdirs:
+
+# Building necessary directories
+build_dirs: $(BUILD_DIRS)
+
+$(BUILD_DIRS):
+ -mkdir -p $(@)
+
+# Stage "public" directories
+stage:
+ -rm -r $(STAGE_LOCATION)/$(COMPONENT_NAME)
+ mkdir -p $(STAGE_LOCATION)/$(COMPONENT_NAME)
+ cp -r ../bin ../dll ../lib ../inc ../cfg ../doc $(STAGE_LOCATION)/$(COMPONENT_NAME)/
+
+
+# Debug Headers
+banner:
+ @echo Making $(COMPONENT_NAME)
+ @echo Bld Roots $(BLD_ROOTS)
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/depends.mk b/nsframework/framework_unified/client/NativeServices/cfg/depends.mk
new file mode 100644
index 00000000..57ecd9b2
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/depends.mk
@@ -0,0 +1,115 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Standard Dependency Makefile Version 2.0
+#
+# Dependency file dictates not only what other modules the project is dependent on, but
+# also where to get that dependent element which logically includes versioning or
+# baselining information
+
+
+# Begin User Build Location Definition
+# This is the prefixing information which dictates the versioning of dependant projects
+# Typically path statements will include some set of versioning information.
+
+# The Repository Root is the base location of where a build is put in context
+# By default this is up a directory from the project root. This is based on
+# the default local build where a component where a project is started to build is
+# on the same level as other components in the repository. Otherwise a value can
+# be forced by setting the value before operating on the configuration file.
+#
+# Example would be to setting the Repository Root to a baseline label name
+# where the contents of the baseline lable are exported to the filesystem.
+ifndef REPOSITORY_ROOT
+export REPOSITORY_ROOT = $(PRJ_ROOT)../
+endif
+
+# The Team Root is akin to the Repository Root. It sets the location of
+# the root for other components in the same stream. It is very rare to
+# modify the value of the team root. However it is entirely possible that
+# the repository root and the team root are pointed to the same location.
+# By default the Team Root is set to the workspace location of your project
+ifndef TEAM_ROOT
+export TEAM_ROOT = $(PRJ_ROOT)../
+endif
+
+# Setup the include paths for project functional dependencies by component.
+# This is a list of include paths that should be done with relative locations
+# that are relative to the repository root for all elements external to the
+# component. All Dependency includes should be based on the $(REPOSITORY_ROOT)
+# all local (team/local) dependencies should be handled in the main makefile.
+# Note: Internal include locations should be simply in the makefile directly using
+# the './' as the notation for referencing location.
+# EXCEPTION: The first include is a TEAM_ROOT for the locally "globally" visible
+# module(s) of the Domain. (When doing the product release this is overridden)
+DEPENDS_INCLUDES = \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/framework \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/_CWORD77_ \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/services \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/utility \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/native \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/framework/statemachine \
+ $(CC_IFLAG)$(TEAM_ROOT)SystemServices/inc \
+ $(CC_IFLAG)$(TEAM_ROOT)NativeServices/inc/testautomationframework \
+ $(CC_IFLAG)$(REPOSITORY_ROOT)OpenSource/inc \
+
+DEPENDS_LIB_PATHS = \
+ $(TEAM_ROOT)NativeServices/lib/$(TARGET)$(BUILD_CFG)/ \
+ $(TEAM_ROOT)NativeServices/dll/$(TARGET)$(BUILD_CFG)/
+
+# BSP is required for PastModel002 because of mq (libmqS.a)
+ifneq ($(TARGET),x86)
+ ifeq ($(PRODUCT_NAME),PastModel004)
+ ifdef TARGET_BSP
+ ifndef BSP
+ BSP = $(TARGET_BSP)
+ endif
+ endif
+ ifndef BSP
+ ifneq ($(findstring all,$(MAKECMDGOALS)),)
+$(error \
+$(\n) \
+$(\n)***************************************************************************************** \
+$(\n)!!!ERROR!!! BSP not defined. Please, define TARGET_BSP variable in your make environment \
+$(\n)***************************************************************************************** \
+$(\n))
+ endif
+ else
+ DEPENDS_LIB_PATHS += $(REPOSITORY_ROOT)/$(BSP)/prebuilt/armle-v7/usr/lib
+ endif
+ endif
+endif
+
+
+# $(REPOSITORY_ROOT)SystemServices/lib/$(TARGET)$(BUILD_CFG)/ \
+
+# Setup library definintions. Same rules
+include $(TEAM_ROOT)NativeServices/cfg/nativeserviceslibraries.mk
+
+# Setup the include location for the tools configuration. This sets the
+# standard tool definition locations. By default these are local, but
+# long term will be a standard component for a project to include. This
+# definition is inherited in cases that this is a recursive call.
+
+# Set tools location
+ifndef TOOLS_CFG
+TOOLS_CFG = $(TEAM_ROOT)NativeServices/cfg/
+endif
+
+# Include the configuration
+include $(TOOLS_CFG)config.mk
diff --git a/nsframework/framework_unified/client/NativeServices/cfg/nativeserviceslibraries.mk b/nsframework/framework_unified/client/NativeServices/cfg/nativeserviceslibraries.mk
new file mode 100644
index 00000000..67205f11
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/cfg/nativeserviceslibraries.mk
@@ -0,0 +1,54 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# TODO make this more functionally oriented.
+# That is to make them more like the types ... so client libraries, etc.
+
+#NATIVE_SERVICES_DYNAMIC_LIBS = \
+# NS_FrameworkCore$(DEBUG_EXT) \
+# NS_Logger$(DEBUG_EXT) \
+# NS_Timer$(DEBUG_EXT)\
+# NS_MessageCenter$(DEBUG_EXT) \
+# NS_MessageQueue$(DEBUG_EXT) \
+# NS_SharedMemIf$(DEBUG_EXT) \
+# NS_NPServiceIf$(DEBUG_EXT) \
+# NS_UtilityCenter$(DEBUG_EXT) \
+# NS_ConfigParser$(DEBUG_EXT) \
+# NS__CWORD77__ServiceIf$(DEBUG_EXT) \
+
+# For improving startup performance, all libraries are merged into one
+# Other modules can still use individual libraries if required. Other NS libraries are also available.
+#NATIVE_SERVICES_DYNAMIC_LIBS = \
+# NS_Storage$(DEBUG_EXT) \
+# sqlite3 \
+# z \
+# NS_FrameworkUnified$(DEBUG_EXT) \
+
+NATIVE_SERVICES_DYNAMIC_LIBS = \
+ NS_FrameworkUnified$(DEBUG_EXT) \
+
+NATIVE_SERVICES_IMAGE_STORE_DYNAMIC_LIBS = \
+ sqlite3 \
+ z \
+ NS_Storage$(DEBUG_EXT) \
+ NS_ImageStorage$(DEBUG_EXT) \
+
+NATIVE_SERVICES_DYNAMIC_LIBS_CORE = \
+ NS_CoreUnified$(DEBUG_EXT) \
+
+TEST_AUTOMATION_FRAMEWORK_STATIC_LIBS = \
+ NS_TestAutomationFramework$(DEBUG_EXT) \
+
diff --git a/nsframework/framework_unified/client/NativeServices/makefile_PosixBasedOS001 b/nsframework/framework_unified/client/NativeServices/makefile_PosixBasedOS001
new file mode 100644
index 00000000..9b512f43
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/makefile_PosixBasedOS001
@@ -0,0 +1,55 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Top level makefile triggered to export all options
+
+# Set Optimization on for all lower makefiles
+#export OPTIMIZATION=OPTIMIZE
+
+all interface clean clean_interface clean_test:
+ $(MAKE) -C src OPTIMIZATION=FULL_OPTIMIZE DYNAMIC=TRUE $(MAKECMDGOALS)
+ $(MAKE) -C src DEBUG=TRUE OPTIMIZATION=NONE DYNAMIC=TRUE $(MAKECMDGOALS)
+ $(MAKE) -C src TARGET=x86 DYNAMIC=TRUE $(MAKECMDGOALS)
+ $(MAKE) -C src TARGET=x86 DEBUG=TRUE DYNAMIC=TRUE $(MAKECMDGOALS)
+
+# doxygen and graphviz tools must be in path of Jazz Build Engine
+# tested with doxygen 1.7.2 and graphviz 2.26.3
+docs:
+ $(MAKE) -C dox all
+
+lint:
+ $(MAKE) -C src TARGET=analysis lint
+
+# unit tests require main libraries -- typically not run directly, but part of a build engine
+unittest:
+ #$(MAKE) -C src OPTIMIZATION=FULL_OPTIMIZE $(MAKECMDGOALS)
+ #$(MAKE) -C src TARGET=x86 $(MAKECMDGOALS)
+ $(MAKE) -C src TARGET=x86 DYNAMIC=TRUE $(MAKECMDGOALS)
+ $(MAKE) -C src TARGET=x86 DEBUG=TRUE DYNAMIC=TRUE $(MAKECMDGOALS)
+
+functionaltest misc:
+ #$(MAKE) -C src OPTIMIZATION=FULL_OPTIMIZE DYNAMIC=TRUE $(MAKECMDGOALS)
+ #$(MAKE) -C src DEBUG=TRUE OPTIMIZATION=NONE DYNAMIC=TRUE $(MAKECMDGOALS)
+ $(MAKE) -C src TARGET=x86 DYNAMIC=TRUE $(MAKECMDGOALS)
+ #$(MAKE) -C src TARGET=x86 DEBUG=TRUE DYNAMIC=TRUE $(MAKECMDGOALS)
+
+
+# Stage is a forced clean, build, export
+# Expectation is that the user sets the STAGE_LOCATION in initiating the makefile
+stage:
+ $(MAKE) clean
+ $(MAKE) all
+ $(MAKE) -C src stage
diff --git a/nsframework/framework_unified/client/NativeServices/scfg/ns_filestorage.sql b/nsframework/framework_unified/client/NativeServices/scfg/ns_filestorage.sql
new file mode 100644
index 00000000..b6aa172a
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/scfg/ns_filestorage.sql
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS IMAGE(
+ METAUID VARCHAR NOT NULL,
+ FORMAT VARCHAR NULL,
+ PATH VARCHAR NULL,
+ CRC BIGINT NOT NULL,
+ FILEID BIGINT NOT NULL,
+ TIMESTAMP DATETIME NOT NULL,
+ PRIMARY KEY ( METAUID,FILEID )
+);
diff --git a/nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog.cfg b/nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog.cfg
new file mode 100644
index 00000000..729fe2fd
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog.cfg
@@ -0,0 +1,278 @@
+[REALTIME_LOG]
+Output=OFF
+
+[ZONE_LIST]
+List=ZONE_PERFORMANCE,ZONE_SCREEN_TRANS,ZONE_SWDL,ZONE_SYSTEMDATA,ZONE_LOG_SH,ZONE_LOG_SYS,ZONE_LOG__CWORD52_,ZONE_SECURE,ZONE_CAN_FILTER,ZONE_COMM_PROCESS,ZONE_CONNECT_DEVICE,ZONE_COMM_SYS,ZONE_COMM_SH,ZONE_COMM_USB
+
+[ZONE_PERFORMANCE]
+Zone=64
+FileName=frameworkunified_performance.log
+FileSizeMax=1048576
+
+[ZONE_SCREEN_TRANS]
+Zone=65
+FileName=frameworkunified_screen_trans.log
+FileSizeMax=20480
+
+[ZONE_SWDL]
+Zone=66
+FileName=frameworkunified_swdl.log
+FileSizeMax=10240
+
+[ZONE_SYSTEMDATA]
+Zone=67
+FileName=frameworkunified_systemdata.log
+FileSizeMax=655360
+
+[ZONE_LOG_SH]
+Zone=68
+FileName=frameworkunified_sh.log
+FileSizeMax=65536
+
+[ZONE_LOG_SYS]
+Zone=69
+FileName=frameworkunified_sys.log
+FileSizeMax=131072
+
+[ZONE_LOG__CWORD52_]
+Zone=70
+FileName=frameworkunified__CWORD52_.log
+FileSizeMax=4096
+
+[ZONE_SECURE]
+Zone=71
+FileName=frameworkunified_secure.log
+FileSizeMax=4096
+
+[ZONE_CAN_FILTER]
+Zone=72
+FileName=frameworkunified_can_filter.log
+FileSizeMax=40960
+
+[ZONE_COMM_PROCESS]
+Zone=73
+FileName=frameworkunified_comm_process.log
+FileSizeMax=1048576
+
+[ZONE_CONNECT_DEVICE]
+Zone=74
+FileName=frameworkunified_connect_device.log
+FileSizeMax=20480
+
+[ZONE_COMM_SYS]
+Zone=96
+FileName=frameworkunified_comm_sys.log
+FileSizeMax=1048576
+
+[ZONE_COMM_SH]
+Zone=97
+FileName=frameworkunified_comm_sh.log
+FileSizeMax=1048576
+
+[ZONE_COMM_USB]
+Zone=98
+FileName=frameworkunified_comm_usb.log
+FileSizeMax=1048576
+
+[FLAG_DEFAULT]
+LogLevel=Release
+FileName=frameworkunified_debug.log
+FileSizeMax=3419136
+
+[FLAG_LIST]
+List=FLAG_UIAPP,FLAG_RADIO,FLAG_MEDIA,FLAG_VEHICLE,FLAG_NETWORK,FLAG_CONNECTIVITY,FLAG_APPFW,FLAG_BTTEL,FLAG_VR,FLAG_NAVI,FLAG_SYSTEM,FLAG_BASEPF,FLAG_COMMUNICATION
+
+[FLAG_UIAPP]
+LogLevel=Release
+FileName=frameworkunified_debug_uiapp.log
+FileSizeMax=10485760
+Service1=proxy_app
+Service2=audio_app
+Service3=connect_app
+Service4=diag_app
+Service5=home_app
+Service6=repro_app
+Service7=vui_app
+Service8=VehicleInfoSrv
+Service9=InfoSettingSrv
+Service10=MenuService
+Service11=DelPersonalSrv
+
+[FLAG_RADIO]
+LogLevel=Release
+FileName=frameworkunified_debug_radio.log
+FileSizeMax=81920
+Service1=RadioService
+Service2=RadioHDArbiter
+Service3=hrds_manager
+
+[FLAG_MEDIA]
+LogLevel=Release
+FileName=frameworkunified_debug_media.log
+FileSizeMax=81920
+Service1=DtvService
+Service2=PlaybackService
+Service3=DiscService
+Service4=_CWORD8_Srv
+Service5=DtvVupService
+
+[FLAG_VEHICLE]
+LogLevel=Release
+FileName=frameworkunified_debug_vehicle.log
+FileSizeMax=81920
+Service1=DiagService
+Service2=vehicle_app
+Service3=VS_ACNSrv
+Service4=VS_CMRSrv
+Service5=VS_DMSSrv
+Service6=VS_ENMSrv
+Service7=VS_FUCSrv
+Service8=VS_METSrv
+Service9=VS_NMSSrv
+Service10=VS_VSDSrv
+
+[FLAG_NETWORK]
+LogLevel=Release
+FileName=frameworkunified_debug_network.log
+FileSizeMax=81920
+Service1=NetworkManager
+Service2=ComArb_CWORD84_
+
+[FLAG_CONNECTIVITY]
+LogLevel=Release
+FileName=frameworkunified_debug_connectivity.log
+FileSizeMax=81920
+Service1=_CWORD57_DTService
+Service2=_CWORD57_UtilService
+Service3=MisinkService
+Service4=MisinkMiddle
+Service5=_CWORD27_Service
+Service6=RemoteService
+Service7=_CWORD76_Service
+Service8=_CWORD58_Service
+Service9=SDLService
+Service10=_CWORD89_Service
+Service11=SPCService
+Service12=eOMService
+Service13=LSP
+Service14=AwtPrimary
+Service15=TFFProxy
+Service16=EnformService
+
+[FLAG_APPFW]
+LogLevel=Release
+FileName=frameworkunified_debug_appfw.log
+FileSizeMax=81920
+
+[FLAG_BTTEL]
+LogLevel=Release
+FileName=frameworkunified_debug_bttel.log
+FileSizeMax=81920
+Service1=BT_BLLSrv
+Service2=BT_CnctSrv
+Service3=BT_PhoneSrv
+Service4=DCM_PhoneSrv
+Service5=BT_PbkSrv
+Service6=BT_MsgSrv
+Service7=WlanMiddle
+Service8=wlan_controller
+Service9=DCMService
+Service10=HELPService
+Service11=hciattach_qca
+
+[FLAG_VR]
+LogLevel=Release
+FileName=frameworkunified_debug_vr.log
+FileSizeMax=81920
+Service1=vrmanager_area1
+Service2=vrmanager_area2
+Service3=vrmanager_area3
+Service4=vrmanager_area4
+Service5=contentsmgr
+Service6=vrmanager_area1_t
+Service7=vrmanager_area1__CWORD84__t
+Service8=vrmanager_area1__CWORD84_
+Service9=vrmanager_area2__CWORD84_
+
+[FLAG_NAVI]
+LogLevel=Release
+FileName=frameworkunified_debug_navi.log
+FileSizeMax=1024
+
+[FLAG_SYSTEM]
+LogLevel=Release
+FileName=frameworkunified_debug_system.log
+FileSizeMax=81920
+Service1=ReproService
+Service2=Positioning
+
+[FLAG_BASEPF]
+LogLevel=Release
+FileName=frameworkunified_debug_base_pf.log
+FileSizeMax=1126400
+Service1=AS_AudioManager
+Service2=graphics
+Service3=CANGW_M
+Service4=CANGW_S
+Service5=DummyRead
+Service6=ExtUnitAuth
+Service7=LockManager
+Service8=Mounter
+Service9=MounterEx
+Service10=NS_BackupMgr
+Service11=NS_NPPService
+Service12=NS_RemoteCtrlService
+Service13=NS_SharedMem
+Service14=NW_MicService
+Service15=PS_CDR
+Service16=PS_CommSH4A
+Service17=PS_CommUSB
+Service18=PS_IPC
+Service19=PS_IPC_MP_Shadow
+Service20=PS_LanServer
+Service21=PS_LoggerShadow
+Service22=PS_PSMShadow
+Service23=PS_SwitchHandler
+Service24=ProxyService
+Service25=SS_DeviceDetectionService
+Service26=SS_GroupLaunchTrigger
+Service27=SS_LoggerService
+Service28=SS_PartitionRemount
+Service29=SS_PowerService
+Service30=SS_ScrShot
+Service31=SS_SystemManager
+Service32=SS_WinSys
+Service33=Sound
+Service34=StartUpBgm
+Service35=ViewerApp
+Service36=_CWORD52_vup
+Service37=clock
+Service38=communication
+Service39=dcmDevNotify
+Service40=dsrcDevNotify
+Service41=fatfsck
+Service42=hubDevNotify
+Service43=mkfatfs
+Service44=mscDevNotify
+Service45=nandupdate
+Service46=ncmDevNotify
+Service47=norvup
+Service48=nsprofileutil
+Service49=nsverutil
+Service50=resm
+Service51=rootfsvup
+Service52=sdDevNotify
+Service53=sysupdate
+Service54=sysvup
+Service55=tskmgr
+Service56=updateservice
+Service57=usbDevNotify
+Service58=vehicle
+Service59=vupprogressui
+Service60=vupservice
+Service61=webdavmgr
+
+[FLAG_COMMUNICATION]
+LogLevel=Release
+FileName=frameworkunified_debug_communication.log
+FileSizeMax=81920
diff --git a/nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog__CWORD84_.cfg b/nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog__CWORD84_.cfg
new file mode 100644
index 00000000..0ca29e52
--- /dev/null
+++ b/nsframework/framework_unified/client/NativeServices/scfg/ns_logger_frameworkunifiedlog__CWORD84_.cfg
@@ -0,0 +1,427 @@
+[REALTIME_LOG]
+Output=OFF
+
+[ZONE_LIST]
+
+#List=ZONE_PERFORMANCE,ZONE_SCREEN_TRANS,ZONE_SWDL,ZONE_SYSTEMDATA,ZONE_LOG_SH,ZONE_LOG_SYS,ZONE_LOG__CWORD52_,ZONE_SECURE,ZONE_CAN_FILTER,ZONE_COMM_PROCESS,ZONE_CONNECT_DEVICE,ZONE_COMM_SYS,ZONE_COMM_SH,ZONE_COMM_USB,ZONE_POS_SYS_IN,ZONE_POS_GPS_IN,ZONE_POS_CMD_IN,ZONE_ALSA,ZONE_WINSYS,ZONE_SOC_TEMP,ZONE_VERSION,ZONE_COMM_SYS_STS,ZONE_HDARBITER
+
+#List=ZONE_PERFORMANCE,ZONE_SCREEN_TRANS,ZONE_SWDL,ZONE_SYSTEMDATA,ZONE_LOG_SH,ZONE_LOG_SYS,ZONE_LOG__CWORD52_,ZONE_SECURE,ZONE_CAN_FILTER,ZONE_COMM_PROCESS,ZONE_CONNECT_DEVICE,ZONE_COMM_SYS,ZONE_COMM_SH,ZONE_COMM_USB,ZONE_POS_SYS_IN,ZONE_POS_GPS_IN,ZONE_POS_CMD_IN,ZONE_ALSA,ZONE_WINSYS,ZONE_SOC_TEMP,ZONE_VERSION,ZONE_COMM_SYS_STS,ZONE_HDARBITER,ZONE_TOUCH
+List=ZONE_PERFORMANCE,ZONE_SCREEN_TRANS,ZONE_SWDL,ZONE_SYSTEMDATA,ZONE_LOG_SH,ZONE_LOG_SYS,ZONE_LOG__CWORD52_,ZONE_CAN_FILTER,ZONE_COMM_PROCESS,ZONE_CONNECT_DEVICE,ZONE_COMM_SYS,ZONE_COMM_SH,ZONE_COMM_USB,ZONE_POS_SYS_IN,ZONE_POS_GPS_IN,ZONE_POS_CMD_IN,ZONE_ALSA,ZONE_WINSYS,ZONE_SOC_TEMP,ZONE_VERSION,ZONE_COMM_SYS_STS,ZONE_HDARBITER,ZONE_TOUCH
+
+[ZONE_PERFORMANCE]
+Zone=64
+FileName=frameworkunified_performance.log
+FileSizeMax=131072
+
+[ZONE_SCREEN_TRANS]
+Zone=65
+FileName=frameworkunified_screen_trans.log
+FileSizeMax=20480
+
+[ZONE_SWDL]
+Zone=66
+FileName=frameworkunified_swdl.log
+FileSizeMax=10240
+
+[ZONE_SYSTEMDATA]
+Zone=67
+FileName=frameworkunified_systemdata.log
+FileSizeMax=655360
+
+[ZONE_LOG_SH]
+Zone=68
+FileName=frameworkunified_sh.log
+FileSizeMax=65536
+
+[ZONE_LOG_SYS]
+Zone=69
+FileName=frameworkunified_sys.log
+FileSizeMax=131072
+
+[ZONE_LOG__CWORD52_]
+Zone=70
+FileName=frameworkunified__CWORD52_.log
+FileSizeMax=4096
+
+
+#[ZONE_SECURE]
+#Zone=71
+#FileName=frameworkunified_secure.log
+#FileSizeMax=4096
+
+
+[ZONE_CAN_FILTER]
+Zone=72
+FileName=frameworkunified_can_filter.log
+FileSizeMax=40960
+
+[ZONE_COMM_PROCESS]
+Zone=73
+FileName=frameworkunified_comm_process.log
+FileSizeMax=1024
+
+[ZONE_CONNECT_DEVICE]
+Zone=74
+FileName=frameworkunified_connect_device.log
+FileSizeMax=20480
+
+[ZONE_COMM_SYS]
+Zone=96
+FileName=frameworkunified_comm_sys.log
+FileSizeMax=1048576
+
+[ZONE_COMM_SH]
+Zone=97
+FileName=frameworkunified_comm_sh.log
+FileSizeMax=1048576
+
+[ZONE_COMM_USB]
+Zone=98
+FileName=frameworkunified_comm_usb.log
+FileSizeMax=1048576
+
+[ZONE_POS_SYS_IN]
+Zone=99
+FileName=frameworkunified_pos_sys_in.log
+FileSizeMax=102400
+
+[ZONE_POS_GPS_IN]
+Zone=100
+FileName=frameworkunified_pos_gps_in.log
+FileSizeMax=20480
+
+[ZONE_POS_CMD_IN]
+Zone=101
+FileName=frameworkunified_pos_cmd_in.log
+FileSizeMax=10240
+
+[ZONE_ALSA]
+Zone=103
+FileName=frameworkunified_alsa.log
+FileSizeMax=450560
+ForceOutput=True
+
+[ZONE_WINSYS]
+Zone=105
+FileName=frameworkunified_winsys.log
+FileSizeMax=512000
+ForceOutput=True
+
+[ZONE_SOC_TEMP]
+Zone=104
+FileName=frameworkunified_soc_temp.log
+FileSizeMax=2048
+
+[ZONE_VERSION]
+Zone=106
+FileName=frameworkunified_version.log
+FileSizeMax=8192
+
+[ZONE_COMM_SYS_STS]
+Zone=107
+FileName=frameworkunified_comm_sys_sts.log
+FileSizeMax=102400
+
+[ZONE_HDARBITER]
+Zone=108
+FileName=frameworkunified_hdarbiter.log
+FileSizeMax=102400
+
+
+[ZONE_TOUCH]
+Zone=109
+FileName=frameworkunified_touch_display.log
+FileSizeMax=32768
+
+
+[FLAG_DEFAULT]
+LogLevel=Release
+FileName=frameworkunified_debug.log
+FileSizeMax=2097152
+
+Realtimelog=True
+
+[FLAG_LIST]
+
+#List=FLAG_UIAPP,FLAG_RADIO,FLAG_MEDIA,FLAG_VEHICLE,FLAG_DIAG,FLAG_NETWORK,FLAG_CONNECTIVITY,FLAG_APPFW,FLAG_BTTEL,FLAG_VR,FLAG_NAVI,FLAG_SYSTEM,FLAG_BASEPF,FLAG_COMMUNICATION,FLAG_LSP,FLAG__CWORD76_,FLAG_MISINK,FLAG_CONNPROXY
+List=FLAG_UIAPP,FLAG_RADIO,FLAG_MEDIA,FLAG_VEHICLE,FLAG_DIAG,FLAG_NETWORK,FLAG_CONNECTIVITY,FLAG_APPFW,FLAG_BTTEL,FLAG_VR,FLAG_NAVI,FLAG_SYSTEM,FLAG_BASEPF,FLAG_COMMUNICATION,FLAG_LSP,FLAG__CWORD76_,FLAG_MISINK,FLAG_CONNPROXY,FLAG_CPAA
+
+[FLAG_UIAPP]
+LogLevel=Release
+FileName=frameworkunified_debug_uiapp.log
+FileSizeMax=5242880
+
+Realtimelog=True
+Service1=proxy_app
+Service2=audio_app
+Service3=connect_app
+Service4=diag_app
+Service5=home_app
+Service6=repro_app
+Service7=vui_app
+Service8=VehicleInfoSrv
+Service9=InfoSettingSrv
+Service10=MenuService
+Service11=DelPersonalSrv
+Service12=vehicle_app
+
+[FLAG_RADIO]
+LogLevel=Release
+FileName=frameworkunified_debug_radio.log
+FileSizeMax=1249280
+
+Realtimelog=True
+Service1=RadioService
+Service2=RadioHDArbiter
+Service3=hrds_manager
+
+[FLAG_MEDIA]
+LogLevel=Release
+FileName=frameworkunified_debug_media.log
+FileSizeMax=81920
+
+Realtimelog=True
+Service1=DtvService
+Service2=PlaybackService
+Service3=DiscService
+Service4=_CWORD8_Srv
+Service5=DtvVupService
+
+[FLAG_VEHICLE]
+LogLevel=Release
+FileName=frameworkunified_debug_vehicle.log
+FileSizeMax=6553600
+
+Realtimelog=True
+Service1=VS_ACNSrv
+Service2=VS_CMRSrv
+Service3=VS_DMSSrv
+Service4=VS_ENMSrv
+Service5=VS_FUCSrv
+Service6=VS_METSrv
+Service7=VS_NMSSrv
+Service8=VS_VSDSrv
+Service9=VS_TMCSrv
+Service10=VS_DASSrv
+
+[FLAG_DIAG]
+LogLevel=Release
+FileName=frameworkunified_debug_diag.log
+FileSizeMax=6553600
+
+[FLAG_NETWORK]
+LogLevel=Release
+FileName=frameworkunified_debug_network.log
+FileSizeMax=81920
+
+Realtimelog=True
+Service1=NetworkManager
+Service2=ComArb_CWORD84_
+
+[FLAG_CONNECTIVITY]
+LogLevel=Release
+FileName=frameworkunified_debug_connectivity.log
+FileSizeMax=81920
+
+#Service1=_CWORD27_Service
+#Service2=eOMService
+#Service3=_CWORD57_DTService
+#Service4=_CWORD57_UtilService
+#Service5=SPCService
+Realtimelog=True
+Service1=eOMService
+Service2=_CWORD57_DTService
+Service3=_CWORD57_UtilService
+Service4=SPCService
+
+
+[FLAG_APPFW]
+LogLevel=Release
+FileName=frameworkunified_debug_appfw.log
+FileSizeMax=1048576
+
+Realtimelog=True
+Service1=modemanager
+Service2=acmsrv
+
+[FLAG_BTTEL]
+LogLevel=Release
+FileName=frameworkunified_debug_bttel.log
+
+#FileSizeMax=6291456
+FileSizeMax=6023168
+Realtimelog=True
+
+Service1=TEL_BLLSrv
+Service2=BT_CnctSrv
+Service3=BT_PhoneSrv
+Service4=DCM_PhoneSrv
+Service5=BT_PbkSrv
+Service6=BT_MsgSrv
+Service7=WlanMiddle
+Service8=wlan_controller
+Service9=DCMService
+Service10=HELPService
+Service11=hciattach_qca
+
+[FLAG_VR]
+LogLevel=Release
+FileName=frameworkunified_debug_vr.log
+FileSizeMax=81920
+
+Realtimelog=True
+Service1=vrmanager_area1
+Service2=vrmanager_area2
+Service3=vrmanager_area3
+Service4=contentsmgr
+Service5=vrmanager_area1_t
+Service6=vrmanager_area1__CWORD84__t
+Service7=vrmanager_area1__CWORD84_
+Service8=vrmanager_area2__CWORD84_
+Service9=vrmanager_area3__CWORD84_
+Service10=vrmanager_area5__CWORD84_
+
+[FLAG_NAVI]
+LogLevel=Release
+FileName=frameworkunified_debug_navi.log
+FileSizeMax=1024
+
+Realtimelog=True
+
+[FLAG_SYSTEM]
+LogLevel=Release
+FileName=frameworkunified_debug_system.log
+FileSizeMax=81920
+
+Realtimelog=True
+Service1=ReproService
+Service2=Positioning
+
+[FLAG_BASEPF]
+LogLevel=Release
+FileName=frameworkunified_debug_base_pf.log
+FileSizeMax=5017600
+
+Realtimelog=True
+Service1=AS_AudioManager
+Service2=graphics
+Service3=CANGW_M
+Service4=CANGW_S
+Service5=DummyRead
+Service6=ExtUnitAuth
+Service7=LockManager
+Service8=Mounter
+Service9=MounterEx
+Service10=NS_BackupMgr
+Service11=NS_NPPService
+Service12=NS_RemoteCtrlService
+Service13=NS_SharedMem
+Service14=NW_MicService
+Service15=PS_CDR
+Service16=PS_CommSH4A
+Service17=PS_CommUSB
+Service18=PS_IPC
+Service19=PS_IPC_MP_Shadow
+Service20=PS_LanServer
+Service21=PS_LoggerShadow
+Service22=PS_PSMShadow
+Service23=PS_SwitchHandler
+Service24=ProxyService
+Service25=SS_DeviceDetectionService
+Service26=SS_GroupLaunchTrigger
+Service27=SS_LoggerService
+Service28=SS_PartitionRemount
+Service29=SS_PowerService
+Service30=SS_ScrShot
+Service31=SS_SystemManager
+Service32=SS_WinSys
+Service33=Sound
+Service34=StartUpBgm
+Service35=ViewerApp
+Service36=_CWORD52_vup
+Service37=clock
+Service38=communication
+Service39=dcmDevNotify
+Service40=dsrcDevNotify
+Service41=fatfsck
+Service42=hubDevNotify
+Service43=mkfatfs
+Service44=mscDevNotify
+Service45=nandupdate
+Service46=ncmDevNotify
+Service47=norvup
+Service48=nsprofileutil
+Service49=nsverutil
+Service50=resm
+Service51=rootfsvup
+Service52=sdDevNotify
+Service53=sysupdate
+Service54=sysvup
+Service55=tskmgr
+Service56=updateservice
+Service57=usbDevNotify
+Service58=vehicle
+Service59=vupprogressui
+Service60=vupservice
+Service61=webdavmgr
+Service62=drop_caches
+
+Service63=ASND_Server
+
+[FLAG_COMMUNICATION]
+LogLevel=Release
+FileName=frameworkunified_debug_communication.log
+FileSizeMax=81920
+
+Realtimelog=True
+
+[FLAG_LSP]
+LogLevel=Release
+FileName=frameworkunified_debug_lsp.log
+FileSizeMax=1048576
+
+Realtimelog=True
+Service1=LSP
+Service2=ConnUtilSlave
+Service3=ServiceFlagMgr
+Service4=ConnMgr
+
+[FLAG__CWORD76_]
+LogLevel=Release
+FileName=frameworkunified_debug__CWORD76_.log
+FileSizeMax=245760
+
+Realtimelog=True
+Service1=_CWORD76_Service
+Service2=_CWORD58_Service
+Service3=SDLService
+Service4=_CWORD89_Service
+
+[FLAG_MISINK]
+LogLevel=Release
+FileName=frameworkunified_debug_misink.log
+FileSizeMax=81920
+
+Realtimelog=True
+Service1=MisinkService
+Service2=misink
+Service3=MlinkService
+Service4=mlink
+
+[FLAG_CONNPROXY]
+LogLevel=Release
+FileName=frameworkunified_debug_connproxy.log
+FileSizeMax=81920
+
+Realtimelog=True
+Service1=TFFProxySlave
+
+
+[FLAG_CPAA]
+LogLevel=Release
+FileName=frameworkunified_debug_cpaa.log
+FileSizeMax=81920
+Realtimelog=True
+Service1=_CWORD27_Service
+Service2=_CWORD28_AutoService
+
diff --git a/nsframework/framework_unified/client/include/native_service/XMLParser.h b/nsframework/framework_unified/client/include/native_service/XMLParser.h
new file mode 100644
index 00000000..36467ba4
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/XMLParser.h
@@ -0,0 +1,289 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup MY 14 Platform Software Team
+/// \brief Xml parser used to extract and update data from Xml file
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file XMLParser.h
+ * @brief \~english Xml parser used to extract and update data from Xml file
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef XMLPARSER_H_ // NOLINT (build/header_guard)
+#define XMLPARSER_H_
+
+#include <libxml/tree.h>
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_logger_if.h>
+
+#include <vector>
+#include <list>
+#include <string>
+#include <map>
+#include <sstream>
+
+////////////////////////////////////////////////////////////////////////
+/// CTestCaseData : Class used to fill testcase data from XML
+////////////////////////////////////////////////////////////////////////
+
+
+class CTestCaseData {
+ public:
+ std::string key;
+
+ // Delay for testCase
+ SI_32 m_testDelaySec;
+ SI_32 m_testDelayMSec;
+ SI_32 m_testDelayUSec;
+ // TestLoop Count
+ SI_32 m_testLoop;
+
+ SI_32 m_testReset;
+ SI_32 m_testPrintResult;
+ std::string m_testCategory;
+ std::string m_testResultType;
+
+ std::vector<std::string> macroVector;
+ // Delay for TestMacros
+ std::string m_macroDelaySecVal;
+ std::string m_macroDelayMsecVal;
+ std::string m_macroDelayUsecVal;
+
+ std::list<std::string> expOut;
+
+
+ CTestCaseData(const xmlChar *name, std::string testDelaySec, std::string testDelayMSec, std::string testDelayUSec,
+ std::string testLoopVal, std::string testReset, std::string testPrintResult, std::string testCategory,
+ std::string testResultType, std::vector<std::string> paramMacroVector, std::string macroDelaySecVal,
+ std::string macroDelayMSecVal, std::string macroDelayUSecVal,
+ std::list<std::string> expOutputVector);
+
+ CTestCaseData(const CTestCaseData &value);
+
+ ~CTestCaseData();
+};
+
+class XMLParser {
+ private:
+ struct FindByName {
+ std::string l_sName;
+ FindByName(const std::string &name) : l_sName(name) {} // NOLINT (readability/nolint)
+ bool operator()(const xmlNodePtr &xmlNode) {
+ std::stringstream l_sStream;
+ l_sStream << xmlNode->name;
+ std::string l_sStr = l_sStream.str();
+ return l_sStr == l_sName;
+ }
+ };
+
+ public:
+ static std::string xmlCharToString(const xmlChar *value);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// XMLParser
+ /// Class Constructor
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ XMLParser();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// XMLParser
+ /// Class Destructor
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ ~XMLParser();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// readAllXml
+ /// read all XML files from xmlInputFile
+ ///
+ /// \param [in] xmlInputFile
+ /// string
+ /// xmlList
+ /// string
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void readAllXml(const std::string &xmlInputFile, std::list<std::string> &xmlList); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// getChildNodeList
+ ///
+ /// \param [in] node
+ /// xmlNodePtr
+ /// nodeVector
+ /// vector<xmlNodePtr>
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void getChildNodeList(xmlNodePtr node, std::vector<xmlNodePtr> &nodeVector); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// fillMacroVector
+ ///
+ /// \param [in] node
+ /// xmlFileHandle
+ /// xmlDocPtr
+ /// macroNodeVector
+ /// vector<xmlNodePtr>
+ /// expOutValue
+ /// string
+ /// expOutputVector
+ /// list<std::string>
+ /// macroDelayVal
+ /// string
+ /// paramMacroVector
+ /// vector<std::string>
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void fillMacroVector(xmlDocPtr &xmlFileHandle, // NOLINT (readability/nolint)
+ std::vector<xmlNodePtr> &macroNodeVector, // NOLINT (readability/nolint)
+ std::string &expOutValue, // NOLINT (readability/nolint)
+ std::list<std::string> &expOutputVector, // NOLINT (readability/nolint)
+ std::string &macroSecDelayVal, // NOLINT (readability/nolint)
+ std::string &macroMSecDelayVal, // NOLINT (readability/nolint)
+ std::string &macroUSecDelayVal, // NOLINT (readability/nolint)
+ std::vector<std::string> &paramMacroVector); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// StringToNumber
+ /// Convert the string to number
+ ///
+ /// \param [in]
+ /// Text
+ /// string
+ ///
+ /// \return number value
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static int StringToNumber(const std::string &Text) { // NOLINT (readability/nolint)
+ std::istringstream ss(Text, std::istringstream::in);
+ int result;
+ return ss >> result ? result : 0;
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// createTestCaseVector
+ ///
+ /// \param [in]
+ /// testCaseNodeVector
+ /// vector<xmlNodePtr>
+ /// xmlFileHandle
+ /// xmlDocPtr
+ /// testCaseDataVector
+ /// vector<CTestCaseData>
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void createTestCaseVector(std::vector<xmlNodePtr> &testCaseNodeVector, xmlDocPtr &xmlFileHandle, // NOLINT (readability/nolint)
+ std::vector<CTestCaseData> &testCaseDataVector); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetXmlNodeAttributeValueToString
+ ///
+ /// \param [in]
+ /// arg
+ /// void *
+ /// str
+ /// const char *
+ /// xmlFileHandle
+ /// xmlDocPtr
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetXmlNodeAttributeValueToString(void *arg, const char *str, xmlDocPtr xmlFileHandle);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// populateTestCaseMap
+ ///
+ /// \param [in]
+ /// testCaseDataVector
+ /// vector<CTestCaseData>
+ /// xmlFileHandle
+ /// xmlDocPtr
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void populateTestCaseMap(std::vector<CTestCaseData> &testCaseDataVector, xmlDocPtr xmlFileHandle) ; // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// updateXmlActualOutput
+ ///
+ /// \param [in]
+ /// xmlName
+ /// string
+ /// testCaseName
+ /// string
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void updateXmlActualOutput(const std::string &xmlName, // NOLINT (readability/nolint)
+ std::string &testCaseName, // NOLINT (readability/nolint)
+ std::string &actualOutput); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetXmlExpectedOutput
+ ///
+ /// \param [in]
+ /// pKey
+ /// string
+ /// pValue
+ /// string
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void GetXmlExpectedOutput(std::string pKey, std::string pValue);
+
+ private:
+ xmlDocPtr m_xmlFileHandle;
+ static const std::string EXPECTEDOUTPUT;
+ static const std::string VALUE;
+ static const std::string DELAYSEC;
+ static const std::string DELAYMSEC;
+ static const std::string DELAYUSEC;
+ static const std::string TESTLOOP;
+ static const std::string TESTRESET;
+ static const std::string TESTPRINTRESULT;
+ static const std::string TESTCATEGORY;
+ static const std::string TESTCASEDATA;
+ static const std::string MACRODELAYSEC;
+ static const std::string MACRODELAYMSEC;
+ static const std::string MACRODELAYUSEC;
+ static const std::string LOOPPVAL;
+ static const std::string ACTUALOUTOUT;
+ static const std::string OUTPUT_SEPARATOR;
+ static const std::string ACCESS_OPERATOR;
+ static const std::string TERMINATE_STR;
+ static const SI_32 LOOP_DEFAULT_VALUE;
+ static const std::string DEFAULT_VALUE;
+ static const std::string PARAMETER_SEPARATOR;
+ static const std::string TESTRESULTTYPE;
+ static const std::string RESULT_AUTOMATIC;
+ static const std::string RESULT_MANUAL;
+};
+
+#endif /* XMLPARSER_H_ */ // NOLINT (build/header_guard)
+
+// EOF
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/framework_unified.h b/nsframework/framework_unified/client/include/native_service/framework_unified.h
new file mode 100644
index 00000000..b3c2f295
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/framework_unified.h
@@ -0,0 +1,130 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file framework_unified.h
+ * @brief \~english include all framework_unified head files
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef NATIVESERVICE_FRAMEWORKUNIFIED_H_ // NOLINT (build/header_guard)
+#define NATIVESERVICE_FRAMEWORKUNIFIED_H_
+
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/ns_eventlogger.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_np_service_nor_persistence.h>
+#include <native_service/ns_np_service_notification.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_plogger_if.h>
+#include <native_service/ns_shared_mem.h>
+#include <native_service/ns_shared_mem_if.h>
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_reader.h>
+#include <native_service/ns_sharedmem_writer.h>
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/ns_system_mode.h>
+#include <native_service/ns_timer_if.h>
+#include <native_service/ns_timer_if.hpp>
+#include <native_service/ns_transmit_log.h>
+#include <native_service/ns_utility.hpp>
+#include <native_service/ns_utility_if.h>
+#include <native_service/ns_utility_sys.hpp>
+#include <native_service/ns_util_directory.h>
+#include <native_service/ns_util_crc.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/ns_resource_controler.h>
+#include <native_service/ns_version.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/wpf_legacy.h>
+#include <native_service/ns_rcs_data_handler.hpp>
+#include <native_service/ns_rcs_logger_types.h>
+#include <native_service/ns_rcs_plugin.hpp>
+#include <native_service/ns__CWORD77__common.h>
+#include <native_service/ns__CWORD77__data_pool_if.h>
+#include <native_service/ns__CWORD77__data_pool_key.h>
+#include <native_service/ns__CWORD77__data_pool_table.h>
+#include <native_service/ns__CWORD77__notifications.h>
+#include <native_service/ns__CWORD77__types.h>
+#include <native_service/frameworkunified__CWORD77__service_if.h>
+#include <native_service/frameworkunified__CWORD77__session_if.h>
+#include <native_service/ns_buildversioncheck.hpp>
+#include <native_service/ns_endianess.h>
+#include <native_service/nslogutil_cmd_if.h>
+#include <native_service/nsfw_message.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_framework_sync.h>
+#include <native_service/frameworkunified_framework_system_if.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/frameworkunified_service_if.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <native_service/frameworkunified_timer.h>
+#include <native_service/frameworkunified_sm_action.h>
+#include <native_service/frameworkunified_sm_compositestate.h>
+#include <native_service/frameworkunified_sm_conditionconnector.h>
+#include <native_service/frameworkunified_sm_deephistorystate.h>
+#include <native_service/frameworkunified_sm_dispatcher.h>
+#include <native_service/frameworkunified_sm_eventdata.h>
+#include <native_service/frameworkunified_sm_eventfactory.h>
+#include <native_service/frameworkunified_sm_externaltransition.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <native_service/frameworkunified_sm_framework_if.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_guard.h>
+#include <native_service/frameworkunified_sm_historystate.h>
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <native_service/frameworkunified_sm_hsmframework.h>
+#include <native_service/frameworkunified_sm_internaltransition.h>
+#include <native_service/frameworkunified_sm_leafstate.h>
+#include <native_service/frameworkunified_sm_localtransition.h>
+#include <native_service/frameworkunified_sm_multithreading.h>
+#include <native_service/frameworkunified_sm_orthogonalstate.h>
+#include <native_service/frameworkunified_sm_reaction.h>
+#include <native_service/frameworkunified_sm_shallowhistorystate.h>
+#include <native_service/frameworkunified_sm_state.h>
+#include <native_service/frameworkunified_sm_transition.h>
+#include <native_service/XMLParser.h>
+#include <native_service/ns_xml_reader.h>
+#include <native_service/ns_xml_wrter.h>
+#include <native_service/ns_xmlparser_if.h>
+#include <native_service/ns_reader.h>
+#include <native_service/ns_writer.h>
+
+#endif // NATIVESERVICE_FRAMEWORKUNIFIED_H_ NOLINT (build/header_guard)
+/**@}*/ // end of inc
+/**@}*/ // end of framework_unified
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__service_if.h b/nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__service_if.h
new file mode 100644
index 00000000..823257f6
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__service_if.h
@@ -0,0 +1,554 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified__CWORD77__service_if.h
+ * @brief \~english This file contains a interface class for all services classes.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIED__CWORD77_SERVICE_H_ // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIED__CWORD77_SERVICE_H_
+
+#include <native_service/ns__CWORD77__common.h>
+#include <native_service/frameworkunified__CWORD77__session_if.h>
+#include <string>
+#include <map>
+#include <vector>
+
+///////////////////////////////////////////////////////////////////////////
+/// class: CFrameworkunified_CWORD77_Service
+/// Description: This is interface class for all services classes.
+///
+////////////////////////////////////////////////////////////////////////////
+
+class CFrameworkunified_CWORD77_Service {
+ protected:
+ std::map<UI_32, CFrameworkunified_CWORD77_Session *> m_SessTypeToSessObj; ///< Map of session type to session object
+ ResponseServiceTo_CWORD77_ m_cbResponse; ///< Call back function pointer
+ SessionAckTo_CWORD77_ m_cbSessionACK; // Call back function pointer for session ACK
+ std::vector<FrameworkunifiedNotificationCallbackHandler> m_vServiceNotifications; ///< vector of Frameworkunifiednotification callbacks
+ CFrameworkunified_CWORD77_Session *m_pSession; ///< Pointer to an instance of I_CWORD77_Session
+ std::string m_cServiceName;
+ BOOL m_bServiceAvailable;
+ UI_8 m_ui8SessionRetryCount;
+ HANDLE m_hApp; ///> application framework handle
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Function to send message to a session
+ /// \~english @param[in] f_uiSessionType
+ /// UI_32 - session type
+ /// \~english @param[in] f_uiSrvProtocol
+ /// UI_32 - Protocol ID
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// CFrameworkunified_CWORD77_Service::SetSession()
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Send specified sessionType message by FrameworkunifiedSendMsg().
+ /// \~english @par
+ /// If the session object corresponding to the session Public specified by the arguments is not registered,
+ /// the system terminates normally without sending the object.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see SetSession,FrameworkunifiedSendMsg
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SendMessageToSession(UI_32 f_uiSessionType, UI_32 f_uiSrvProtocol);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Function to open sessions with specified Service Name
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle to the Framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @param [in] f_sServiceName
+ /// f_sServiceName - Service Name
+ /// \~english @par
+ /// f_sServiceName - const std::string&
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - Save service name into member variable.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Function to open sessions with specified Service Name
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void OpenSession(HANDLE f_hApp, const std::string &f_sServiceName);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Function to close sessions
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle to the Framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Function to close sessions
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ void CloseSession(HANDLE f_hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Function to add notification
+ /// \~english @param[in] f_pNotification
+ /// PCSTR - Notification name
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Session obeject is declared in CFrameworkunified_CWORD77_Service::SetSession()
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// -Bind Notification name declared in parameter with callbak function in OnServiceNtf()
+ /// \~english @par Detail
+ /// -subscribed notifications will transfor into subscribe instance in SubscribeNotifications()
+ /// \~english @par Detail
+ /// -Process will not commit when notification parameter name is null
+ /// \~english @par Classification
+ /// -public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see SetSession,OnServiceNtf,SubscribeNotifications,UnSubscribeNotifications
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void AddNotification(PCSTR f_pNotification);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AttachOpenSessionAckCallback
+ /// virtual function to attche open session ack callback
+ ///
+ /// \param [in] hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus AttachOpenSessionAckCallback(HANDLE hApp) = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// OpenSessionRetry
+ /// This function sends open session request to the service m_cServiceName
+ ///
+ /// \param [in] f_ui32SessionType
+ /// UI_32 - Session type to open
+ /// \return none
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ void OpenSessionRetry(UI_32 f_ui32SessionType);
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Constructor for CFrameworkunified_CWORD77_Service
+ /// \~english @retval none
+ /// \~english @par Preconditions
+ /// -No preconditions
+ /// \~english @par Change of internal status
+ /// -The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// -Create CFrameworkunified_CWORD77_Service class instance
+ /// -Initialize class member variable(m_cbResponse, m_cbSessionACK, m_pSession, m_cServiceName,\n
+ /// m_bServiceAvailable, m_ui8SessionRetryCount, m_hApp, m_SessTypeToSessObj).\n
+ /// \~english @par Classification
+ /// -public
+ /// \~english @par type
+ /// -None
+ /// \~english @see ~CFrameworkunified_CWORD77_Service
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunified_CWORD77_Service();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunified_CWORD77_Service
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// -CFrameworkunified_CWORD77_Service instance is decleared in Constructor
+ /// \~english @par Change of internal status
+ /// -The internal status is not changed
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// -Release the CFrameworkunified_CWORD77_Service class instance
+ /// \~english @par Classification
+ /// -Pubulic
+ /// \~english @par Type
+ /// -None
+ /// \~english @see CFrameworkunified_CWORD77_Service
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunified_CWORD77_Service();
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// HandleMessage
+ /// virtual function to process message coming from _CWORD77_
+ /// \~english @param [in] cmdID
+ /// cmdID - Request ID
+ /// \~english @par
+ /// cmdID UI_32
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or Error
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// - none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus HandleServiceMessage(UI_32 cmdID) = 0;
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// function to open session with specified Service name when service available.
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle to the Framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @param [in] f_sServiceName
+ /// f_sServiceName - service name
+ /// \~english @par
+ /// f_sServiceName - const std::string &
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or Error
+ /// \~english @par Preconditions
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - save Framework handler into m_hApp.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// function to open session with specified Service name
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see AttachOpenSessionAckCallback, OpenSession
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OpenServiceOnAvailability(HANDLE f_hApp, const std::string &f_sServiceName);
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// function to close session when service unavailable.
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle to the Framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or Error
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - set m_bServiceAvailable FALSE.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// function to close session when service unavailable.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CloseSession
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CloseServiceOnUnavailability(HANDLE hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Set Call back function into Sessions.
+ /// \~english @param [in] fptr
+ /// fptr - Pointer to call back function
+ /// \~english @par
+ /// fptr ResponseServiceTo_CWORD77_*
+ /// \~english @retval
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - set m_cbResponse with fptr.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Set Call back function into Sessions.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetResponseCallback(ResponseServiceTo_CWORD77_ fptr);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// API to set session objects in service.
+ /// \~english @param [in] f_pSessionObj
+ /// f_pSessionObj - Pointer to an instance of session object.
+ /// \~english @par
+ /// f_pSessionObj CFrameworkunified_CWORD77_Session*
+ /// \~english @retval
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - set sessionobj into m_SessTypeToSessObj.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Set session objects in service.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetSession(CFrameworkunified_CWORD77_Session *f_pSessionObj);
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Subscribe notifications.
+ /// \~english @param [in] hApp
+ /// hApp - Handle to the Framework.
+ /// \~english @par
+ /// hApp HANDLE*
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or eFrameworkunifiedStatusInvldParam
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - save pointer of notifications into framework handler.
+ /// \~english @par Conditions of processing failure
+ /// - FrameworkunifiedSubscribeNotificationWithCallback() failed [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Detail
+ /// Send subscribe message to NPPService for Subscribe notifications.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedSubscribeNotificationWithCallback
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SubscribeNotifications(HANDLE hApp);
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// unsubscribe notifications
+ /// \~english @param [in] hApp
+ /// hApp - Handle to the Framework.
+ /// \~english @par
+ /// hApp HANDLE*
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or eFrameworkunifiedStatusInvldParam
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - delete notifications from framework handler.
+ /// \~english @par Conditions of processing failure
+ /// - FrameworkunifiedNPUnsubscribeFromNotifications() failed [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Detail
+ /// Send unsubscribe message to NPPService for delete subscribe notifications.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedSubscribeNotificationWithCallback
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UnSubscribeNotifications(HANDLE hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// virtual function to enable session in service
+ /// \~english @param [in] f_uiNum
+ /// f_uiNum - Number of arguments
+ /// \~english @par
+ /// f_uiNum UI_32
+ /// \~english @param [in] f_uiFirst
+ /// f_uiFirst - first argument
+ /// \~english @par
+ /// f_uiFirst UI_32
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// -
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// None
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// None
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual void EnableSession(UI_32 f_uiNum, UI_32 f_uiFirst, ...) = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// unsubscribe notifications
+ /// \~english @param [in] hApp
+ /// hApp - Handle to the Framework.
+ /// \~english @par
+ /// hApp HANDLE*
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or eFrameworkunifiedStatusNullPointer
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none.
+ /// \~english @par Conditions of processing failure
+ /// - FrameworkunifiedGetMsgDataOfSize() failed [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Call register subscribe notification.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedGetMsgDataOfSize, SetRespNotfnDataIn_CWORD77_DataPool
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnServiceNtf(HANDLE hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Acknowledgement process of open session
+ /// \~english @param[in] f_hApp
+ /// HANDLE - Handle to the Application
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Set Session object in CFrameworkunified_CWORD77_Service::SetSession()
+ /// - Set Callback function in CFrameworkunified_CWORD77_Service::Set_CWORD77_OpenSessionACK()
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Set the application handle as Parameter when receiving acknowledgement for open session process.
+ /// Call OpenSessionAcknowledge() in session object which has same session type.
+ /// Call the callback function for open session acknowledgement.
+ /// \~english @par
+ /// Message sending process will be stoped in reguler when the session type of open session process is not
+ /// declared.
+ /// \~english @par
+ /// Callback function will be stoped in reguler when callback function is not declared.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see SetSession,Set_CWORD77_OpenSessionACK
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void OpenSessionAcks(HANDLE f_hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Service
+ /// \~english @par Brief
+ /// Attach open session ack callback function to service.
+ /// \~english @param [in] fptr
+ /// fptr - Callback Function pointer of notify open session ack.
+ /// \~english @par
+ /// fptr SessionAckTo_CWORD77_*
+ /// \~english @retval
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - set callback function into m_cbSessionACK..
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Attach open session ack callback function to service.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void Set_CWORD77_OpenSessionACK(SessionAckTo_CWORD77_ fptr);
+};
+
+#endif // _FRAMEWORKUNIFIED__CWORD77_SERVICE_H_ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__session_if.h b/nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__session_if.h
new file mode 100644
index 00000000..2c189a70
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified__CWORD77__session_if.h
@@ -0,0 +1,495 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified__CWORD77__session_if.h
+ * @brief \~english This file provides API for operating session
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIED__CWORD77_SESSION_H_ // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIED__CWORD77_SESSION_H_
+
+#include <native_service/ns__CWORD77__common.h>
+#include <string>
+#include <vector>
+
+class CFrameworkunified_CWORD77_Session {
+ protected:
+ HANDLE m_hSession; ///< Handle to session
+ HANDLE m_hApp; ///< Handle to Framework
+ HANDLE m_hService; ///< Handle to Service
+ UI_32 m_uiSessionType; ///< Session Type
+ ResponseServiceTo_CWORD77_ m_ResponseTo_CWORD77_; ///< Call back function pointer
+ std::vector<FrameworkunifiedProtocolCallbackHandler> m_vSessionProtocolHanlder;
+ std::vector<UI_32> m_vEventVector;
+ std::vector<FrameworkunifiedProtocolCallbackHandler> m_vSessionEventHandler;
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddProtocol
+ /// Function to add notification
+ ///
+ /// \param[in] f_uiCmdId
+ /// UI_32 - Command id
+ /// \param[in] f_cbFuncPtr
+ /// CbFuncPtr - Callback function pointer
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void AddProtocolHandler(UI_32 f_uiCmdId, CbFuncPtr f_cbFuncPtr);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AttachProtocolwithDispatcher
+ /// API to Register Session 1 of Service A protocols with Dispatcher
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AttachProtocolwithDispatcher(HANDLE f_hApp);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// DetachProtocolwithDispatcher
+ /// API to Un Register Session 1 of Service A protocols with Dispatcher
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DetachProtocolwithDispatcher(HANDLE f_hApp);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AttachEventswithDispatcher
+ /// Function to register events with dispatcher
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AttachEventswithDispatcher(HANDLE f_hApp);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// RegisterEvents
+ /// Function to register events
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RegisterEvents(HANDLE f_hApp); // Function: added by Shyam to overcome
+ /// the naming conflict in registering the event
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AttachEventHandlerswithDispatcher
+ /// API to Register Session 1 of Service A protocols with Dispatcher
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AttachEventHandlerswithDispatcher(HANDLE f_hApp);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// DetachEventHandlerswithDispatcher
+ /// API to Un Register Session 1 of Service A protocols with Dispatcher
+ ///
+ /// \param [in] f_hApp
+ /// HANDLE - Handle to the Framework
+ /// \return status
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DetachEventHandlerswithDispatcher(HANDLE f_hApp);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddEventHandler
+ /// Function to add event handler
+ ///
+ /// \param[in] f_uiCmdId
+ /// UI_32 - Command id
+ /// \param[in] f_cbFuncPtr
+ /// CbFuncPtr - Callback function pointer
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void AddEventHandler(UI_32 f_uiCmdId, CbFuncPtr f_cbFuncPtr);
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// Constructor for CFrameworkunified_CWORD77_Session
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// no preconditions
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Create CFrameworkunified_CWORD77_Session instance and initialize the member parameter(m_hSession, m_hApp,m_hService,\n
+ /// m_uiSessionType)
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see ~CFrameworkunified_CWORD77_Session
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunified_CWORD77_Session();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunified_CWORD77_Session
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// CFrameworkunified_CWORD77_Session is decleared in constructor
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Release CFrameworkunified_CWORD77_Session class instance
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunified_CWORD77_Session
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunified_CWORD77_Session();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// send specific command by session
+ /// \~english @param [in] cmdID
+ /// cmdID - commond id
+ /// \~english @par
+ /// cmdID UI_32
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK or failed
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - GetReqDataFrom_CWORD77_DataPool() failed [eFrameworkunifiedStatusDbRecNotFound]
+ /// - FrameworkunifiedSendMsg() failed
+ /// - if m_hSession is NULL. [eFrameworkunifiedStatusSessionErr]
+ /// \~english @par Detail
+ /// send specified commond by session.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see GetReqDataFrom_CWORD77_DataPool
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ // virtual EFrameworkunifiedStatus HandleSessionMessage(UI_32 cmdID);
+ EFrameworkunifiedStatus HandleSessionMessage(UI_32 cmdID);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// Set Call back function in Session
+ /// \~english @param [in] fptr
+ /// fptr - Pointer to call back function
+ /// \~english @par
+ /// fptr ResponseServiceTo_CWORD77_*
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - set callback into m_ResponseTo_CWORD77_.
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Set Call back function in Session
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetResponseCallback(ResponseServiceTo_CWORD77_ fptr);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// function to Open Session.(pure virtual function)
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle of framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @param [in] f_sServiceName
+ /// f_sServiceName - Service Name
+ /// \~english @par
+ /// f_sServiceName std::string
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus OpenSession(HANDLE f_hApp, std::string f_sServiceName) = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// function to close Session.(pure virtual function)
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle of framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// - none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus CloseSession(HANDLE f_hApp) = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// Open Session acknowledge.(pure virtual function)
+ /// \~english @param [in] f_hApp
+ /// f_hApp - Handle of framework
+ /// \~english @par
+ /// f_hApp HANDLE*
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// -none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus OpenSessionAcknowledge(HANDLE f_hApp) = 0;
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetSessionType
+ /// API to get session type
+ ///
+ /// \return UI_32 - Session type
+ /// EFrameworkunifiedStatus - Success or Error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// API to get session type
+ /// \~english @param none
+ /// \~english @retval UI_32 - Session type
+ /// \~english @par Preconditons
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// API to get session type.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetSessionType();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// API to set session type into class CFrameworkunified_CWORD77_Session object.
+ /// \~english @param[in] sessioType
+ /// const UI_32& - Session type
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// none
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// API to set session type into class CFrameworkunified_CWORD77_Session object.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ /// none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetSessionType(const UI_32 &sessioType);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// declear callback funcion into Dispatcher
+ /// \~english @param[in] hApp
+ /// HANDLE - Handle to Application
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// no precondition
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// declear OnResponse() of callback function by calling FrameworkunifiedAttachCallbackToDispatcher()\n
+ /// get decleared protocol ID through GetResponseProtocolArray()\n
+ /// get decleared event ID through GetEventArray() and regist event-sending instance in FrameworkunifiedRegisterEvent
+ /// \~english @par
+ /// cautions in using this API:\n
+ /// -Registrition will fail without msg When Application handle is uncorrect set by parameter\n
+ /// -Registrition process in FrameworkunifiedAttachCallbackToDispatcher() will not commit when
+ /// GetResponseProtocolArray()\n
+ /// or GetEventArray() returns NULL or NULL list
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedRegisterEvent,
+ /// GetResponseProtocolArray, GetEventArray, OnResponse
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void AttachResponseCallbacks(HANDLE hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// unscrible dispatcher callback function
+ /// \~english @param[in] hApp
+ /// HANDLE - Handle to Application
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// no preconditions
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// declear OnResponse() of callback function by calling FrameworkunifiedDetachCallbackFromDispatcher()\n
+ /// get unregistrition protocol ID through GetResponseProtocolArray()\n
+ /// get unregistrition event ID through GetEventArray() and unregist event-sending instance in \n
+ /// FrameworkunifiedUnRegisterEvent()
+ /// \~english @par Detail
+ /// cautions in using this API:\n
+ /// -Unregistrition will fail without msg When Application handle is uncorrect set by parameter\n
+ /// -Unregistrition process in FrameworkunifiedDetachCallbackFromDispatcher() will not commit when
+ /// GetResponseProtocolArray()\n
+ /// or GetEventArray() returns NULL or NULL list
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedUnRegisterEvent,
+ /// GetResponseProtocolArray, GetEventArray
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void DetachResponseCallbacks(HANDLE hApp);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnResponse
+ /// Callback function on receiving response protocol or event specified in the list, returned
+ /// by either \ref GetResponseProtocolArray or \ref GetEventArray
+ ///
+ /// \param [in] hApp
+ /// HANDLE - Handle to framework
+ /// \return None
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunified_CWORD77_Session
+ /// \~english @par Brief
+ /// Callback function on receiving response protocol or event specified in the list, returned
+ /// by either \ref GetResponseProtocolArray or \ref GetEventArray
+ /// \~english @param [in] f_hApp
+ /// HANDLE - Handle of framework
+
+ /// \~english @retval EFrameworkunifiedStatus
+ /// SuceFrameworkunifiedStatusOK or eFrameworkunifiedStatusNullPointer
+ /// \~english @par Preconditions
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - framework handler is invalid handler.[eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Callback function on receiving response protocol or event specified in the list, returned
+ /// by either \ref GetResponseProtocolArray or \ref GetEventArray
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedGetMsgDataOfSize
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnResponse(HANDLE hApp);
+
+ // FIXME: Following set of functions should be pure virtual functions.
+ // But, in order to avoid build errors for HMI__CWORD77_, it is defined as virtual functions only.
+ // Because nobody who is currently deriving off of frameworkunified__CWORD77__session_if.h has these functions implemented.
+ virtual UI_32 const *GetResponseProtocolArray() = 0;
+ virtual UI_32 const GetResponseProtocolArrayLength() = 0;
+ virtual UI_32 const *GetEventArray() = 0;
+ virtual UI_32 const GetEventArrayLength() = 0;
+};
+
+#endif // _FRAMEWORKUNIFIED__CWORD77_SESSION_H_ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_application.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_application.h
new file mode 100644
index 00000000..9d967515
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_application.h
@@ -0,0 +1,376 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief System callbacks that applications should address.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_application.h
+ * @brief \~english This file contains the base api of an application that must be provided.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_APPLICATION_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_APPLICATION_H__
+
+#include <native_service/frameworkunified_types.h>
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup IsNull
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton initialize
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp);
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton WaleUp
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp); /// << deprecated
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton shutdown
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp); /// << deprecated
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton EShutdown
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE hApp); /// << deprecated
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton start
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp);
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton stop
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOnPreStart
+/// \~english @par Brief
+/// callback of Application Life cycle event
+/// \~english @param [in] hApp
+/// HANDLE - Application Handle
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// Depend on the implementation in the inheriting class
+/// \~english @par Change of internal state
+/// Depend on the implementation in the inheriting class
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// callback of Application Pre start
+/// \~english @par
+/// - include frameworkunified_application.h
+/// - Library libNS_FrameworkUnified.so
+/// - Set compile option for "-DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND" when this API in the each application implements.
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOnPreStop
+/// \~english @par Brief
+/// callback of Application Life cycle event
+/// \~english @param [in] hApp
+/// HANDLE - Application Handle
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// Depend on the implementation in the inheriting class
+/// \~english @par Change of internal state
+/// Depend on the implementation in the inheriting class
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// callback of Application Pre stop
+/// \~english @par
+/// - include frameworkunified_application.h
+/// - Library libNS_FrameworkUnified.so
+/// - Set compile option for "-DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND" when this API in the each application implements.
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOnBackgroundStart
+/// \~english @par Brief
+/// callback of Application Life cycle event
+/// \~english @param [in] hApp
+/// HANDLE - Application Handle
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// Depend on the implementation in the inheriting class
+/// \~english @par Change of internal state
+/// Depend on the implementation in the inheriting class
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// callback of Application Background start
+/// \~english @par
+/// - include frameworkunified_application.h
+/// - Library libNS_FrameworkUnified.so
+/// - Set compile option for "-DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND" when this API in the each application implements.
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOnBackgroundStop
+/// \~english @par Brief
+/// callback of Application Life cycle event
+/// \~english @param [in] hApp
+/// HANDLE - Application Handle
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// Depend on the implementation in the inheriting class
+/// \~english @par Change of internal state
+/// Depend on the implementation in the inheriting class
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// callback of Application Background stop
+/// \~english @par
+/// - include frameworkunified_application.h
+/// - Library libNS_FrameworkUnified.so
+/// - Set compile option for "-DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND" when this API in the each application implements.
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp);
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton reinit
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnReinit(HANDLE hApp);
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton destroy
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp);
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval EFrameworkunifiedStatus depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of applicaiton debugdump
+////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp); // << Used for CCR Debugging
+
+
+/// \~english @par Brief
+/// Base class of application
+/// \~english @param None
+/// \~english @retval PCSTR depends on the implement of derived class
+/// \~english @par Prerequisite
+/// - depends on the implement of derived class
+/// \~english @par Inside state change
+/// - depends on the implement of derived class
+/// \~english @par None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The callback of get applicaiton servcice avaible
+////////////////////////////////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetServiceAvailabilityNotification(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOnDummy
+/// \~english @par Brief
+/// dummy callback of Application Life cycle event
+/// \~english @param [in] hApp
+/// HANDLE - Application Handle
+/// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK
+/// \~english @par Prerequisite
+/// Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// Registered dummy callback when not processing
+/// \~english @par
+/// - include frameworkunified_application.h
+/// - Library libNS_FrameworkUnified.so
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDummy(HANDLE hApp);
+
+#endif /* __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_APPLICATION_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_dispatcher.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_dispatcher.h
new file mode 100644
index 00000000..8aa45725
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_dispatcher.h
@@ -0,0 +1,803 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Application dispatch interface functions
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_dispatcher.h
+ * @brief \~english This file contains the base class of application.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_DISPATCHER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_DISPATCHER_H__
+
+#include <native_service/frameworkunified_framework_types.h>
+// #include <native_service/frameworkunified_sm_hsmframework.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDispatcher
+/// \~english @par Brief
+/// This API creates, initializes the dispatcher and runs mainloop for event handling.
+/// \~english @param [in] cAppName
+/// PCSTR - Pointer to application thread name
+/// \~english @param [in] CbHandler
+/// const FrameworkunifiedDefaultCallbackHandler* - Pointer to default callback functions.
+/// \~english @par
+/// FrameworkunifiedDefaultCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedDefaultCallbackHandler
+/// {
+/// CbFuncPtr onInitilization; /* Function is called when a Dispatcher is created.
+/// */
+/// CbFuncPtr onDestroy; /* Function is called when the Dispatcher is
+/// released. */
+/// CbFuncPtr onStart; /* Function is called when the Dispatcher is started.
+/// */
+/// CbFuncPtr onStop; /* Function is called when the Dispatcher is stopped.
+/// */
+/// CbFuncPtr onPreStart; /* Function is called when the Dispatcher is pre started. */
+/// CbFuncPtr onPreStop; /* Function is called when the Dispatcher is pre stoped. */
+/// CbFuncPtr onBackgroundStart; /* Function is called when the Dispatcher is Background started. */
+/// CbFuncPtr onBackgroundStop; /* Function is called when the Dispatcher is Background stopped. */
+/// CbFuncPtr onDebugDump; /* Function is called when the Dispatcher detects
+/// abnormal state. */
+/// CbFuncPtr createStateMachine; /* Set dummy function that does nothing.
+/// */
+/// CbFuncPtr ssFrameworkInterface; /* Function to connect to SystemManager
+/// */
+/// } FrameworkunifiedDefaultCallbackHandler;
+/// @endcode
+/// \~english @par
+/// About setting of default callback functions(FrameworkunifiedDefaultCallbackHandler)
+/// - Use FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK when initialize of FrameworkunifiedDefaultCallbackHandler structure as argument CbHandler.
+/// - Application that run this API need to define functions below.(allow to dummy function that does nothing.)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+/// - If application is resident service, link library libSS_SystemIfUnified
+/// (This library provides the function FrameworkunifiedSSFrameworkInterface to connect to SystemManager.).
+/// - If application is nonresident service, define function that does nothing below.
+/// - EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp)
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusDuplicate Duplication error of entry
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Application thread name specified in the argument (cAppName) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - Pointer to default callback functions specified in the argument (CbHandler) is NULL.
+/// [eFrameworkunifiedStatusNullPointer]
+/// - One of members in default callback functions specified in the argument (CbHandler) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Application thread name specified in the argument (cAppName) is not appropriate(The name is more than
+/// 15byte). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to open message queue (mq_open). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to get memory (malloc) of message queue info area. [eFrameworkunifiedStatusNullPointer]
+/// - Failed to initialize socket for monitoring abnormal state (socket, bind, listen). [eFrameworkunifiedStatusFail]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for
+/// the NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - Failed to create of epoll instance (epoll_create1). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register of a descriptor of the message queue to the epoll instance (epoll_ctl).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to create file descriptor for receive event (eventfd). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a descriptor for receive event to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a socket for detect abnormal state to the epoll instance (epoll_ctl).
+/// [eFrameworkunifiedStatusFail]
+/// - The result of FrameworkunifiedOnInitialization is not eFrameworkunifiedStatusOK. [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// This API creates and initializes the dispatcher.\n
+/// It starts to mainloop that receives request or notification, and runs registered callback to dispatcher.
+/// When success starting mainloop, never return.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedDispatcherWithArguments
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatcher(PCSTR cAppName, const FrameworkunifiedDefaultCallbackHandler *CbHandler);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDispatcherWithArguments
+/// \~english @par Brief
+/// This API creates, initializes the dispatcher and runs loop with command-line options.
+/// \~english @param [in] cAppName
+/// PCSTR - Pointer to application thread name
+/// \~english @param [in] argc
+/// int - Number of command-line options
+/// \~english @param [in] argv
+/// char *[] - Array of pointer to command-line options
+/// \~english @param [in] CbHandler
+/// const FrameworkunifiedDefaultCallbackHandler* - Pointer to default callback functions.
+/// \~english @param [in] cmdLineOptions
+/// CustomCommandLineOptions* - Parser setting of command-line options(Optional. When don't use, set NULL.)
+/// \~english @par
+/// FrameworkunifiedDefaultCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedDefaultCallbackHandler
+/// {
+/// CbFuncPtr onInitilization; /* Function is called when a Dispatcher is created.
+/// */
+/// CbFuncPtr onDestroy; /* Function is called when the Dispatcher is
+/// released. */
+/// CbFuncPtr onStart; /* Function is called when the Dispatcher is started.
+/// */
+/// CbFuncPtr onStop; /* Function is called when the Dispatcher is stopped.
+/// */
+/// CbFuncPtr onPreStart; /* Function is called when the Dispatcher is pre started. */
+/// CbFuncPtr onPreStop; /* Function is called when the Dispatcher is pre stoped. */
+/// CbFuncPtr onBackgroundStart; /* Function is called when the Dispatcher is Background started. */
+/// CbFuncPtr onBackgroundStop; /* Function is called when the Dispatcher is Background stopped. */
+/// CbFuncPtr onDebugDump; /* Function is called when the Dispatcher detects
+/// abnormal state. */
+/// CbFuncPtr createStateMachine; /* Set dummy function that does nothing.
+/// */
+/// CbFuncPtr ssFrameworkInterface; /* Function to connect to SystemManager
+/// */
+/// } FrameworkunifiedDefaultCallbackHandler;
+/// @endcode
+/// \~english @par
+/// CustomCommandLineOptions Structure
+/// \~english @code
+/// typedef struct _CustomCommandLineOptions
+/// {
+/// PCSTR cShortOptions; /* Short options list. */
+/// PCHAR cLongOptions; /* Reserved. Set to NULL. */
+/// CbArgumentParser callback; /* Pointer to callback function to parse command-line
+/// options. */
+/// } CustomCommandLineOptions;
+/// @endcode
+/// \~english @par
+/// About setting of default callback functions(FrameworkunifiedDefaultCallbackHandler)
+/// - Use FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK when initialize of FrameworkunifiedDefaultCallbackHandler structure as argument CbHandler.
+/// - Application that run this API need to define functions below.(allow to dummy function that does nothing.)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+/// - If application is resident service, link library libSS_SystemIfUnified
+/// (This library provides the function FrameworkunifiedSSFrameworkInterface to connect to SystemManager.).
+/// - If application is nonresident service, define function that does nothing below.
+/// - EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp)
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusDuplicate Duplication error of entry
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Application thread name specified in the argument (cAppName) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - Pointer to default callback functions specified in the argument (CbHandler) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - One of members in default callback functions specified in the argument (CbHandler) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Application thread name specified in the argument (cAppName) is not appropriate(The name is more than
+/// 15byte). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to open message queue (mq_open). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to get memory (malloc) of message queue info area. [eFrameworkunifiedStatusNullPointer]
+/// - Failed to initialize socket for monitoring abnormal state (socket, bind, listen). [eFrameworkunifiedStatusFail]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - Failed to create of epoll instance (epoll_create1). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register of a descriptor of the message queue to the epoll instance (epoll_ctl).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to create file descriptor for receive event (eventfd). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a descriptor for receive event to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a socket for detect abnormal state to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - The result of FrameworkunifiedOnInitialization is not eFrameworkunifiedStatusOK. [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// This API creates and initializes the dispatcher with command-line options.\n
+/// It starts to mainloop that receives request or notification, and runs registered callback to dispatcher.
+/// When success starting mainloop, never return.
+/// Use this API to take over a command-line options to the dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedDispatcher, FrameworkunifiedCreateDispatcher, FrameworkunifiedDispatchBlock,
+/// FrameworkunifiedDispatchProcess, FrameworkunifiedCloseDispatcher,
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[],
+ const FrameworkunifiedDefaultCallbackHandler *CbHandler,
+ CustomCommandLineOptions *cmdLineOptions = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSimpleDispatcher
+/// \~english @par none
+/// Generatings/intializes a Dispatcher and executs main loops for handling events.
+/// \~english @param [in] cAppName
+/// PCSTR - Pointer to the application thread name
+/// \~english @param [in] CbHandler
+/// const FrameworkunifiedDefaultCallbackHandler* - Pointer to a default-defined callback function
+/// \~english @param [in] CbShutdown
+/// CbFuncPtr - Pointer to the callack function o be called when the main loop is exited
+/// \~english @param [in] isChildThread
+/// BOOL - Whether the child thread is a dispatcher (Default:TRUE)
+/// \~english @par
+/// FrameworkunifiedDefaultCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedDefaultCallbackHandler
+/// {
+/// CbFuncPtr onInitilization; /* Callback function to run when creating dispatcher instance */
+/// CbFuncPtr onDestroy; /* Callback function to run when releasing dispatcher instance */
+/// CbFuncPtr onStart; /* Callback function executed when dispatcher starts processing */
+/// CbFuncPtr onStop; /* Callback function to be executed when dispatcher termination is requested */
+/// CbFuncPtr onPreStart; /* Callback function executed when dispatcher requestes activation */
+/// CbFuncPtr onPreStop; /* Callback function to be executed when an-request is made to the dispatcher on board status */
+/// CbFuncPtr onBackgroundStart; /* Callback function executed when dispatcher parking is requested */
+/// CbFuncPtr onBackgroundStop; /* Callback function executed when requesting termination of a dispatcher's parking status */
+/// CbFuncPtr onDebugDump; /* Callback function to be executed when an error is detected */
+/// CbFuncPtr createStateMachine; /* Specify an empty function */
+/// CbFuncPtr ssFrameworkInterface; /* Callback function for connecting to the systemManager */
+/// } FrameworkunifiedDefaultCallbackHandler;
+/// @endcode
+/// \~english @par
+/// About setting the default definition callback function (FrameworkunifiedDefaultCallbackHandler)
+/// The FrameworkunifiedDefaultCallbackHandler structure passed as argument CbHandler must be initialized using the FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK macro.
+/// - The application that executes this API must define a function with the following name. (Can also be an functio)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+/// If the applicatio is a resident service, link the library libSS_SystemIfUnified
+/// (which provides the function FrameworkunifiedSSFrameworkInterface that performs connection processin with SystemManager).
+/// - If the applicatio is a nonresident service, define the following names with empy function.
+/// - EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp)
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifiying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusFail User-specific continuation.
+/// \~english @retval eFrameworkunifiedStatusDuplicate Duplicate entry error
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Category Type
+/// \~english @retval eFrameworkunifiedStatusErrOther Shared-memory accesses for sending message for NPP Service fail.
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF If the timers fail,...
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Service does not exist
+/// \~english @par Failed to acquire
+/// -
+/// \~english @par Log output string
+/// - The internal state is not changed.
+/// \~english @par You do not use.
+/// - When the pointer (CbHandler) to the default-definition callback function specified by the arguments is NULL [eFrameworkunifiedStatusNullPointer]
+/// - If any of the member of the default-defined callback-function sruct specified in he arguments is NULL [eFrameworkunifiedStatusInvldParam]
+/// - When the pointer (CbShutdown) to the callback fuction to be called when the main loop specified by the arguments exits is NULL [eFrameworkunifiedStatusFail]
+/// - When the pointer (cAppName) to the threade name of the application specified by the arguments is NULL [eFrameworkunifiedStatusNullPointer]
+/// - When the application name (cAppName) specified in the parameter exceeds 15 byte [eFrameworkunifiedStatusNullPointer]
+/// - Failed to open a message queue (mq_open) [eFrameworkunifiedStatusNullPointer]
+/// - When acquisition (malloc) of the message queue management information area fails, [eFrameworkunifiedStatusNullPointer]
+/// - If the creation (socket, bind, listen) of sockets for error monitoring fails,... [eFrameworkunifiedStatusFail]
+/// - Application handles and callback function cannot be added to Notification lists [eFrameworkunifiedStatusDuplicate]
+/// - When the Notification name specified in the arguments has already been registred i the Dispatcher [eFrameworkunifiedStatusDuplicate]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending session-specific messages for NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for the NPP Service.... [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages for sessions for NPP Service [eFrameworkunifiedStatusErrOther]
+/// - Failed to create epoll instances (epoll_create1) [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register Dispatcher message queue descriptor for epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - Failed to create file descriptor for receiving events to Dispatcher (eventfd) [eFrameworkunifiedStatusFail]
+/// - Failed to register file descriptor for receiving Dispatcher events to epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - Failed to register socket for monitoring Dispatcher error in epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - If FrameworkunifiedOnInitialization of result is not eFrameworkunifiedStatusOK [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Type
+/// Creats or initializes a Dispatcher, receives requests and notifications to the Dispatcher, and starts a main loop that executes the registred callback functions.\n
+/// When the main loop is started normally, this API does not retur until the hread terminates.\n
+/// At thread termination, the callback function specified by the third argument is called, and the processing result is returned.\n
+/// \n
+/// This API can be used for both main and child threads.\n
+/// However, since this API is an API for chid threads created without going through the API of NS framework such as \ref FrameworkunifiedCreateChildThread,
+/// it is recommended to use \ref FrameworkunifiedDispatcherWithArguments or other API to create Dispatcher in the main thread.\n
+/// \~english @par Immediate
+/// Brief
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Not applicable
+/// \~english @see
+/// FrameworkunifiedDispatcherWithArguments
+///
+/// \~english @par Brief
+/// Generatings/intializes a Dispatcher and executs main loops for handling events
+/// \~english @param [in] cAppName
+/// PCSTR - Application/ thread name
+/// \~english @param [in] CbHandler
+/// const FrameworkunifiedDefaultCallbackHandler* - Function that primes the dispatch pump. i.e. start function
+/// \~english @param [in] CbShutdown
+/// CbFuncPtr * - Shutdown function. Functions gets called if the dispatcher loop exits.
+/// \~English @param[in] isChildThread
+/// BOOL - Default value is TRUE. TRUE - child thread dispatcher else main thread dispatcher
+/// \~english @retval Never does. Unless any callback function returns eFrameworkunifiedStatusExit
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer
+/// \~english @retval eFrameworkunifiedStatusFail Invalid Parameter
+/// \~english @retval eFrameworkunifiedStatusErrOther Unknown Error
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - cAppName is NULL[eFrameworkunifiedStatusNullPointer]
+/// - Length of cAppName is longer than MAX_NAME_SIZE_APP[eFrameworkunifiedStatusNullPointer]
+/// - NativeService has some issues [eFrameworkunifiedStatusNullPointer]
+/// - When the pointer (CbHandler) to the default-definition callback function specified by the arguments is NULL [eFrameworkunifiedStatusNullPointer]
+/// - If any of the member of the default-defined callback-function sruct specified in he arguments is NULL [eFrameworkunifiedStatusInvldParam]
+/// - When the pointer (CbShutdown) to the callback fuction to be called when the main loop specified by the arguments exits is NULL [eFrameworkunifiedStatusFail]
+/// - Failed to open a message queue (mq_open) [eFrameworkunifiedStatusNullPointer]
+/// - When acquisition (malloc) of the message queue management information area fails, [eFrameworkunifiedStatusNullPointer]
+/// - If the creation (socket, bind, listen) of sockets for error monitoring fails,... [eFrameworkunifiedStatusFail]
+/// - Application handles and callback function cannot be added to Notification lists [eFrameworkunifiedStatusDuplicate]
+/// - When the Notification name specified in the arguments has already been registred i the Dispatcher [eFrameworkunifiedStatusDuplicate]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for the NPP Service.... [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// - When an interrupt by a system call (signal) occurs while sending Service session-specific messages. [eFrameworkunifiedStatusErrOther]
+/// - Failed to create epoll instances (epoll_create1) [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register Dispatcher message queue descriptor for epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - Failed to create file descriptor for receiving events to Dispatcher (eventfd) [eFrameworkunifiedStatusFail]
+/// - Failed to register file descriptor for receiving Dispatcher events to epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - Failed to register socket for monitoring Dispatcher error in epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - If FrameworkunifiedOnInitialization of result is not eFrameworkunifiedStatusOK [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// Creates, initializes and runs the dispatcher. This dispatcher function can be used with child thread or main
+/// thread. <BR>
+/// But, recommended to use for child thread. For main thread use \ref FrameworkunifiedDispatcherWithArguments<BR>
+/// Intention to provide this API is for child threads created from dynamically loaded plugin, where thread wants
+/// to <BR>
+/// subscribe to PASA notification, attach callbacks. This can be done in the start function specified with this
+/// API.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedDispatcherWithArguments
+/// \~english @todo not enough inforamtion need readon why this API is for child thread.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSimpleDispatcher(PCSTR cAppName, const FrameworkunifiedDefaultCallbackHandler *CbHandler, CbFuncPtr CbShutdown,
+ BOOL isChildThread = TRUE);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateDispatcherWithoutLoop
+/// \~english @par Brief
+/// This API creates and initializes the dispatcher with command-line options.
+/// \~english @param [in] cAppName
+/// PCSTR - Pointer to application thread name
+/// \~english @param [out] hApp
+/// HANDLE - Handle for Application
+/// \~english @param [in] argc
+/// int - Number of command-line options
+/// \~english @param [in] argv
+/// char *[] - Array of pointer to command-line options
+/// \~english @param [in] CbHandler
+/// const FrameworkunifiedDefaultCallbackHandler* - Pointer to default callback functions.
+/// \~english @param [in] bIsConnectSM
+/// BOOL - whether or not connect with System Manager(TRUE/FALSE)
+/// \~english @param [in] cmdLineOptions
+/// CustomCommandLineOptions* - Parser setting of command-line options(Optional. When don't use, set NULL.)
+/// \~english @par
+/// FrameworkunifiedDefaultCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedDefaultCallbackHandler
+/// {
+/// CbFuncPtr onInitilization; /* Function is called when a Dispatcher is created.
+/// */
+/// CbFuncPtr onDestroy; /* Function is called when the Dispatcher is
+/// released. */
+/// CbFuncPtr onStart; /* Function is called when the Dispatcher is started.
+/// */
+/// CbFuncPtr onStop; /* Function is called when the Dispatcher is stopped.
+/// */
+/// CbFuncPtr onPreStart; /* Function is called when the Dispatcher is pre started. */
+/// CbFuncPtr onPreStop; /* Function is called when the Dispatcher is pre stoped. */
+/// CbFuncPtr onBackgroundStart; /* Function is called when the Dispatcher is Background started. */
+/// CbFuncPtr onBackgroundStop; /* Function is called when the Dispatcher is Background stopped. */
+/// CbFuncPtr onDebugDump; /* Function is called when the Dispatcher detects
+/// abnormal state. */
+/// CbFuncPtr createStateMachine; /* Set dummy function that does nothing.
+/// */
+/// CbFuncPtr ssFrameworkInterface; /* Function to connect to SystemManager
+/// */
+/// } FrameworkunifiedDefaultCallbackHandler;
+/// @endcode
+/// \~english @par
+/// CustomCommandLineOptions Structure
+/// \~english @code
+/// typedef struct _CustomCommandLineOptions
+/// {
+/// PCSTR cShortOptions; /* Short options list. */
+/// PCHAR cLongOptions; /* Reserved. Set to NULL. */
+/// CbArgumentParser callback; /* Pointer to callback function to parse command-line
+/// options. */
+/// } CustomCommandLineOptions;
+/// @endcode
+/// \~english @par
+/// About setting of default callback functions(FrameworkunifiedDefaultCallbackHandler)
+/// - Use FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK when initialize of FrameworkunifiedDefaultCallbackHandler structure as argument CbHandler.
+/// - Application that run this API need to define functions below.(allow to dummy function that does nothing.)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+/// - If application is resident service, link library libSS_SystemIfUnified
+/// (This library provides the function FrameworkunifiedSSFrameworkInterface to connect to SystemManager.).
+/// - If application is nonresident service, define function that does nothing below.
+/// - EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusDuplicate Duplication error of entry
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Application thread name specified in the argument (cAppName) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - Pointer to default callback functions specified in the argument (CbHandler) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - One of members in default callback functions specified in the argument (CbHandler) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Application thread name specified in the argument (cAppName) is not appropriate(The name is more than
+/// 15byte). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to open message queue (mq_open). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to get memory (malloc) of message queue info area. [eFrameworkunifiedStatusNullPointer]
+/// - Failed to initialize socket for monitoring abnormal state (socket, bind, listen). [eFrameworkunifiedStatusFail]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - Failed to create of epoll instance (epoll_create1). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register of a descriptor of the message queue to the epoll instance (epoll_ctl).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to create file descriptor for receive event (eventfd). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a descriptor for receive event to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a socket for detect abnormal state to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API creates and initializes the dispatcher with command-line options without running main loop.\n
+/// Use this, if application control some contexts(include NS framework).\n
+/// when the dispatcher generated by this API, Application need to handle event.\n
+/// Use FrameworkunifiedGetDispatcherFD and FrameworkunifiedDispatchProcessWithoutLoop for event handling.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// FrameworkunifiedCreateDispatcherWithoutLoop, FrameworkunifiedDestroyDispatcherWithoutLoop, FrameworkunifiedGetDispatcherFD
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherWithoutLoop(PCSTR cAppName, HANDLE &hApp, int argc, char *argv[], // NOLINT (readability/nolint)
+ const FrameworkunifiedDefaultCallbackHandler *CbHandler,
+ BOOL bIsConnectSM, CustomCommandLineOptions *cmdLineOptions = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDispatchProcessWithoutLoop
+/// \~english @par Brief
+/// Receive request or notification, and run registered callback to dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedCreateDispatcherWithoutLoop has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - If the waiting message (epoll_wait) , was terminated with an error other than interrupt (EINTR)
+/// [eFrameworkunifiedStatusFail]
+/// - Service name that has been set in the received message exceeds the 20byte. [eFrameworkunifiedStatusFail]
+/// - Message queue in the HANDLE specified in the argument (hApp) is not for receive. [eFrameworkunifiedStatusFail]
+/// - Message queue for receive is empty. [eFrameworkunifiedStatusFail]
+/// - File descriptor of message queue for receive is invalid. [eFrameworkunifiedStatusFail]
+/// - Interruption by the system call (signal) has occurred during the message receiving. [eFrameworkunifiedStatusFail]
+/// - Size of the receive buffer of the message is illegal. [eFrameworkunifiedStatusFail]
+/// - Any errors occur during the message receiving. [eFrameworkunifiedStatusFail]
+/// - Service name in the received message is not appropriate(The name is NULL, Length is 0byte) [eFrameworkunifiedStatusFail]
+/// - The received message data length is more than data length in the received message header. [eFrameworkunifiedStatusFail]
+/// - The received message is not appropriate. [eFrameworkunifiedStatusFail]
+/// - Shared memory ID for receiving message is invalid. [eFrameworkunifiedStatusFail]
+/// - Failed to access to shared memory for receive message. [eFrameworkunifiedStatusFail]
+/// - Data size of shared memory for receiving message is more than destination buffer size. [eFrameworkunifiedStatusFail]
+/// - Message queue of the processing result destination is invalid. [eFrameworkunifiedStatusFail]
+/// - The transmission data that is the received request processing result is NULL. [eFrameworkunifiedStatusFail]
+/// - Service name of the processing result destination is not appropriate(The name is NULL, more than 20byte).
+/// [eFrameworkunifiedStatusFail]
+/// - Failed to access to shared memory for send message. [eFrameworkunifiedStatusFail]
+/// - Message queue type is not for sending. [eFrameworkunifiedStatusFail]
+/// - Message queue for sending is full. [eFrameworkunifiedStatusFail]
+/// - File descriptor of message queue for sending is invalid. [eFrameworkunifiedStatusFail]
+/// - Interruption by the system call (signal) has occurred during the message sending. [eFrameworkunifiedStatusFail]
+/// - Size of the send buffer of the message is illegal. [eFrameworkunifiedStatusFail]
+/// - Any errors occur during the message sending. [eFrameworkunifiedStatusFail]
+/// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusFail]
+/// - Failed to get memory buffer for message receiving. [eFrameworkunifiedStatusFail]
+/// - Failed to read data from file descriptor that is set from application. [eFrameworkunifiedStatusFail]
+/// - Failed to run callback that is set from application. [eFrameworkunifiedStatusFail]
+/// - The callback that is set from application returned error. [eFrameworkunifiedStatusFail]
+/// - I could not found callback function associated with file descriptor that is set from application.
+/// [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// If the Dispatcher was created by FrameworkunifiedCreateDispatcherWithoutLoop, \n
+/// you use this API to receive request or notification, and run registered callback to dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedCreateDispatcherWithoutLoop, FrameworkunifiedDestroyDispatcherWithoutLoop, FrameworkunifiedGetDispatcherFD
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDispatchProcessWithoutLoop(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDestroyDispatcherWithoutLoop
+/// \~english @par Brief
+/// This API destroy the dispatcher created by FrameworkunifiedCreateDispatcherWithoutLoop.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedCreateDispatcherWithoutLoop has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to release memory referenced by HANDLE specified in the argument (hApp). [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// This API destroy the dispatcher created by FrameworkunifiedCreateDispatcherWithoutLoop.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see
+/// FrameworkunifiedCreateDispatcherWithoutLoop
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDestroyDispatcherWithoutLoop(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetDispatcherFD
+/// \~english @par Brief
+/// Get the Dispatcher file descriptor corresponding to the given application handle.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @param [out] efd
+/// int* - Dispatcher file descriptor
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedCreateDispatcherWithoutLoop has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - The argument efd is NULL. [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// This API gets the Dispatcher file descriptor corresponding to the given application handle.\n
+/// The application can use file descriptor to detect event of NS Framework.\n
+/// When events detected, run FrameworkunifiedDispatchProcessWithoutLoop to handling events.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see FrameworkunifiedDispatchProcessWithoutLoop
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetDispatcherFD(HANDLE hApp, SI_32 *efd); // Replace int with SI_32
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetDefaultCbHandler
+/// \~english @par Brief
+/// Get default callback handler table
+/// \~english @param [out] CbHandler
+/// FrameworkunifiedGetDefaultCbHandler * - Default callback handler table pointer
+/// \~english @par
+/// FrameworkunifiedDefaultCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedDefaultCallbackHandler
+/// {
+/// CbFuncPtr onInitilization; /* Function is called when a Dispatcher is created.
+/// */
+/// CbFuncPtr onDestroy; /* Function is called when the Dispatcher is
+/// released. */
+/// CbFuncPtr onStart; /* Function is called when the Dispatcher is started.
+/// */
+/// CbFuncPtr onStop; /* Function is called when the Dispatcher is stopped.
+/// */
+/// CbFuncPtr onPreStart; /* Function is called when the Dispatcher is pre started. */
+/// CbFuncPtr onPreStop; /* Function is called when the Dispatcher is pre stoped. */
+/// CbFuncPtr onBackgroundStart; /* Function is called when the Dispatcher is Background started. */
+/// CbFuncPtr onBackgroundStop; /* Function is called when the Dispatcher is Background stopped. */
+/// CbFuncPtr onDebugDump; /* Function is called when the Dispatcher detects
+/// abnormal state. */
+/// CbFuncPtr createStateMachine; /* Set dummy function that does nothing.
+/// */
+/// CbFuncPtr ssFrameworkInterface; /* Function to connect to SystemManager
+/// */
+/// } FrameworkunifiedDefaultCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedCreateDispatcherWithoutLoop has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer to default callback functions specified in the argument (CbHandler) is NULL.
+/// [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// Gets the default defined callback fuction set by FrameworkunifiedDispatcherWithArguments, FrameworkunifiedSimpleDispatcher, and FrameworkunifiedCreateDispatcherWithoutLoop.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see FrameworkunifiedDispatchProcessWithoutLoop
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetDefaultCbHandler(FrameworkunifiedDefaultCallbackHandler *CbHandler);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachLostSessionCallbackToDispatcher
+/// \~english Register
+/// abnormal session disconnect callback
+/// \~english @param[in] hApp
+/// HANDLE - Application framework handle
+/// \~english @param[in] fpLostSession
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedCreateDispatcherWithoutLoop has been
+/// done.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid Parameter
+/// \~english @par Preconditions
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedCreateDispatcherWithoutLoop has been
+/// done.
+/// \~english @par Change of internal status
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - hApp is NULL [eFrameworkunifiedStatusInvldParam]
+/// - hApp is invalid [eFrameworkunifiedStatusInvldParam]
+/// - fpLostSession is NULL [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Registers a callback fuction to be called when a session disconnection occurs in the specified application handle.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see FrameworkunifiedCreateDispatcherWithoutLoop, FrameworkunifiedDispatcherWithArguments, FrameworkunifiedSimpleDispatcher
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachLostSessionCallbackToDispatcher(HANDLE hApp, CbFuncPtr fpLostSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetLostSessionData
+/// \~english @par Brief
+/// Get last lost session data
+/// \~english @param [in] hApp
+/// HANDLE - Application framework handle
+/// \~english @param [out] pServiceName
+/// PSTR - Disconnect service name
+/// \~english @param [out] puiSessionId
+/// PUI_32 - Disconnect session ID
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid Parameter
+/// \~english @retval eFrameworkunifiedStatusAccessError Error when accessing resource
+/// \~english @par Preconditions
+/// - Generation/Initialization of Dispatcher for the Application
+/// by FrameworkunifiedCreateDispatcherWithoutLoop has been done.
+/// \~english @par Change of internal status
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - hApp is invalid [eFrameworkunifiedStatusInvldParam]
+/// - pServiceName is NULL [eFrameworkunifiedStatusInvldParam]
+/// - puiSessionId is NULL [eFrameworkunifiedStatusInvldParam]
+/// - Lost session queue is empty [eFrameworkunifiedStatusAccessError]
+/// \~english @par Detail
+/// Gets the service name and session ID disconnected from the hadle for the specified application.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedCreateDispatcherWithoutLoop, FrameworkunifiedDispatcherWithArguments, FrameworkunifiedSimpleDispatcher
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetLostSessionData(HANDLE hApp, PSTR pServiceName, PUI_32 puiSessionId);
+
+#endif /* __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_DISPATCHER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_error.hpp b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_error.hpp
new file mode 100644
index 00000000..8c8e3f5a
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_error.hpp
@@ -0,0 +1,77 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief This file provides framework's API which are used by system services.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_framework_error.hpp
+ * @brief \~english This file provides framework's API which are used by system services.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <stdexcept>
+
+namespace frameworkunified {
+namespace framework {
+namespace error {
+
+class error : public std::runtime_error {
+ public:
+ explicit error(EFrameworkunifiedStatus error, PCSTR errorMsg);
+ private:
+ const EFrameworkunifiedStatus m_error;
+};
+
+}
+}
+}
+
+#define DEFINE_FRAMEWORKUNIFIED_ERROR( name ) \
+class name : public framework_unified::framework::error::error \
+{ \
+public: \
+ explicit name ( EFrameworkunifiedStatus error, PCSTR str ) \
+ : framework_unified::framework::error::error ( error, str ) \
+ {} \
+}
+
+#endif // __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_ERROR_H__ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_if.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_if.h
new file mode 100644
index 00000000..44ef8542
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_if.h
@@ -0,0 +1,6007 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+// tag_NSFramework
+// Application framework's interface header file.
+//
+// The interfaces exposed here are
+// - Application framework Dispatcher
+// - attaching/detaching service protocol callbacks
+// - attaching/detaching notification callbacks
+// - Message Center
+// - send messaging to services/clients
+// - read the incoming message information
+// - Service Directory
+// - open and close a service
+// - register/unregister a service
+// - Notification & Persistence Service
+// - register/unregister and publish a notification
+// - subscribe/unsubscribe to a notification
+//
+/////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_framework_if.h
+ * @brief \~english Application framework's interface header file.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup Native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/ns_shared_mem_if.h>
+#include <native_service/ns_np_service.h>
+///////////////////////////////////
+// To avoid integration build break: removing dependency on SM framework.
+// #include <native_service/frameworkunified_sm_hsmframework.h>
+
+// QUICK FIX Files added here, which was included by frameworkunified_sm_hsmframework.h
+// if we simply comment frameworkunified_sm_hsmframework.h inclusion, then other modules build may
+// break, if they are not including below files explicitly and was relying of frameworkunified_framework_if.h.
+#include <native_service/ns_timer_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_logger_if.h>
+#include <map>
+#include <string>
+#include <vector>
+///////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// Dispatcher functions
+////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachCallbacksToDispatcher
+/// \~english @par Brief
+/// API to register multiple Callback-informations to the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pServiceName
+/// PCSTR - Pointer to the service name
+/// \~english @param [in] pMsgHandler
+/// FrameworkunifiedProtocolCallbackHandler* - Pointer to the Message Handler structure
+/// \~english @param [in] uiHandlerCount
+/// UI_32 - Message Handler count(1 to 4294967295)
+/// \~english @param [in] hSession
+/// HANDLE - Session handle (Default:NULL)
+/// \~english @par
+/// FrameworkunifiedProtocolCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedProtocolCallbackHandler
+/// {
+/// /* Command ID/request ID/approval ID of protocol on the service */
+/// UI_32 iCmd;
+/// /* Pointer to Callback function that would be called on receiving iCmd from pServiceName. */
+/// CbFuncPtr callBack;
+/// }FrameworkunifiedProtocolCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(pServiceName) is NULL to the service name specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// - Message Handler number specified in the argument is 0. [eFrameworkunifiedStatusInvldParam]
+/// - NULL Callback function pointer of the Message Handler structure specified by the argument.
+/// [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Register multiple Callback-informations(iCmd,CbFuncPtr) of the service that has been specified by the argument
+/// \n
+/// to the Dispatcher.\n
+/// Thus, if the iCmd is requested from the service, so the appropriate Callback function is called. \n
+/// When multiple registration, if an error occurs in the second and subsequent, becomes effective only \n
+/// information that has been registered so far. \n
+/// For number of upper limit of the registration possible message handler, depending on \n
+/// the securable size as the area of the message handler structure. Therefore, note to ensure \n
+/// the size of the area of the message handler structure at the call side of API, and define \n
+/// the number of message handler.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the handle (hSession) for the session specified by the arguments is not appropriate (disabled),
+/// the system assumes that the session ID = MAX_SESSION_ID_VAL(0xFFFF) is specified.\n
+/// - It is not possible to register more than one callback with the same command ID (iCmd) for the same service/session ID,
+/// and the callback function will win.
+/// - Operatio is not guaranteed if the number of elements of the array indicated by the address of the pointer (pMsgHandler)
+/// to the message handler structure does not match the number of arrays specified by the number of
+/// party-specified message hadlers (uiHandlerCount).
+/// - The callback information is registered to the heap.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedAttachParentCallbacksToDispatcher, FrameworkunifiedDetachParentCallbacksFromDispatcher,
+/// FrameworkunifiedDetachServiceFromDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbacksToDispatcher(HANDLE hApp, PCSTR pServiceName,
+ const FrameworkunifiedProtocolCallbackHandler *pMsgHandler,
+ UI_32 uiHandlerCount, HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachCallbackToDispatcher
+/// \~english @par Brief
+/// API to register a Callback-information to the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @param [in] pServiceName
+/// PCSTR - Pointer to the service name
+/// \~english @param [in] iCmd
+/// UI_32 - Command ID/request ID/approval ID of protocol on the service
+/// \~english @param [in] fpOnCmd
+/// CbFuncPtr - Pointer to Callback function that would be called on receiving iCmd from pServiceName.
+/// \~english @param [in] hSession
+/// HANDLE - Session handle (Default:NULL)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(pServiceName) is NULL to the service name specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// - Pointer (fpOnCmd) is NULL to the Callback function specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Register a Callback-information(iCmd,CbFuncPtr) of the service that has been specified by the argument \n
+/// to the Dispatcher.\n
+/// Thus, if the iCmd is requested from the service, so the appropriate Callback function is called.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the handle (hSession) for the session specified by the arguments is not appropriate (disabled),
+/// the system assumes that the session ID = MAX_SESSION_ID_VAL(0xFFFF) is specified.
+/// - The callback information is registered to the heap.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedAttachParentCallbacksToDispatcher, FrameworkunifiedDetachParentCallbacksFromDispatcher,
+/// FrameworkunifiedDetachServiceFromDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbackToDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, CbFuncPtr fpOnCmd,
+ HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachCallbacksToDispatcherWithFd
+/// \~english @par Brief
+/// API to register multiple Callback and file descriptor set to the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] handlers
+/// FrameworkunifiedFdProtocolCallbackHandler* - Pointer to the Message Handler structure to be registered
+/// \~english @param [in] handlerCount
+/// UI_32 - Message Handler Count(1 to 4294967295)
+/// \~english @par
+/// FrameworkunifiedFdProtocolCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedFdProtocolCallbackHandler
+/// {
+/// int fd; /* File descriptor for message waiting control */
+/// CbFuncPtr callBack; /* Pointer to Callback function */
+/// }FrameworkunifiedFdProtocolCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer (handlers) to the Message Handler structure of the registration object specified in the argument is
+/// NULL. [eFrameworkunifiedStatusInvldParam]
+/// - Message Handler number of registered specified by the argument is 0. [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor in the Message Handler structure(FrameworkunifiedFdProtocolCallbackHandler) specified in the argument is
+/// incorrect(If fd is less than or equal to 0). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(fpOnCmd) to the Callback function in the Message Handler structure(FrameworkunifiedFdProtocolCallbackHandler)
+/// specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor specified in the argument is incorrect(If fd is less than or equal to 0).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Pointer (fpOnCmd) is NULL to the Callback function specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// - Monitoring file descriptor for epoll managed by the HANDLE(hApp) specified in the argument is not
+/// appropriate. [eFrameworkunifiedStatusFail]
+/// - File descriptor in the Message Handler structure(FrameworkunifiedFdProtocolCallbackHandler) specified in the argument is
+/// already registered to the monitoring control(epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - It failed to add the file descriptor of the message waiting control to the monitoring of epoll_ctl().
+/// [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Register multiple callbacks that link to file descriptor that has been specified by the argument to
+/// the Dispatcher.\n
+/// For epoll_ctl() of Dispatcher, add multiple file descriptor for the specified message waiting control \n
+/// by the argument.\n
+/// Thus, for the file descriptor registered in the message waiting control, when receiving a message, \n
+/// so the appropriate Callback function is called. \n
+/// When multiple registration, if an error occurs in the second and subsequent, becomes effective only \n
+/// information that has been registered so far. \n
+/// For number of upper limit of the registration possible message handler, depending on \n
+/// the securable size as the area of the message handler structure. Therefore, note to ensure \n
+/// the size of the area of the message handler structure at the call side of API, and define \n
+/// the number of message handler.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - The operation cannot be guaranteed if the number of elements of the array entity indicated by the address of the pointer (handlers)
+/// to the message handler structure to be registered does not match the number of arrays specified in the number of message handlers o be registered (handlerCount).\n
+/// - The callback information is registered to the heap.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbackToDispatcherWithFd, FrameworkunifiedDetachCallbackFromDispatcherWithFd,
+/// FrameworkunifiedDetachCallbacksFromDispatcherWithFd
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbacksToDispatcherWithFd(HANDLE hApp, const FrameworkunifiedFdProtocolCallbackHandler *handlers,
+ UI_32 handlerCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachCallbackToDispatcherWithFd
+/// \~english @par Brief
+/// API to register a callback that link to a single file descriptor to the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] fd
+/// int - File descriptor for message waiting control
+/// \~english @param [in] fpOnCmd
+/// CbFuncPtr - Pointer to Callback function
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor specified in the argument is incorrect(If fd is less than or equal to 0).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Pointer (fpOnCmd) is NULL to the Callback function specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// - Monitoring file descriptor for epoll managed by the HANDLE(hApp) specified in the argument is not
+/// appropriate. [eFrameworkunifiedStatusFail]
+/// - File descriptor(fd) specified in the argument is already registered to the monitoring control(epoll_ctl).
+/// [eFrameworkunifiedStatusFail]
+/// - It failed to add the file descriptor(fd) of the message waiting control to the monitoring of epoll_ctl().
+/// [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Register a callback that link to a file descriptor that has been specified by the argument to
+/// the Dispatcher.\n
+/// For epoll_ctl() of Dispatcher, add a file descriptor(fd) for the specified message waiting control \n
+/// by the argument.\n
+/// Thus, for the file descriptor registered in the message waiting control, when receiving a message, \n
+/// so the appropriate Callback function is called.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - The callback information is registered to the heap.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedDetachCallbackFromDispatcherWithFd,
+/// FrameworkunifiedDetachCallbacksFromDispatcherWithFd
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachCallbackToDispatcherWithFd(HANDLE hApp, int fd, CbFuncPtr fpOnCmd);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachParentCallbacksToDispatcher
+/// \~english @par Brief
+/// API to register multiple callback information for the parent thread to the Dispatcher.
+/// \~english @param [in] hChildApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pMsgHandler
+/// FrameworkunifiedProtocolCallbackHandler* - Pointer to the Message Handler structure
+/// \~english @param [in] uiHandlerCount
+/// UI_32 - Message Handler count(1 to 4294967295)
+/// \~english @par
+/// FrameworkunifiedProtocolCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedProtocolCallbackHandler
+/// {
+/// /* Command ID/request ID/approval ID of protocol on the service */
+/// UI_32 iCmd;
+/// /* Pointer to Callback function that would be called on receiving iCmd from pServiceName. */
+/// CbFuncPtr callBack;
+/// }FrameworkunifiedProtocolCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE(hApp) specified in the argument is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Parent service name in the HANDLE(hApp) specified in the argument is NULL . [eFrameworkunifiedStatusInvldParam]
+/// - Message Handler number specified in the argument is 0. [eFrameworkunifiedStatusInvldParam]
+/// - NULL Callback function pointer of the Message Handler structure specified by the argument.
+/// [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Register multiple Callback-informations(iCmd,CbFuncPtr) to the Dispatcher to process \n
+/// the message from the parent thread. \n
+/// Thus, if the iCmd is requested from the parent service(application), so the appropriate \n
+/// Callback function is called. \n
+/// When multiple registration, if an error occurs in the second and subsequent, becomes \n
+/// effective only information that has been registered so far.\n
+/// For number of upper limit of the registration possible message handler, depending on \n
+/// the securable size as the area of the message handler structure. Therefore, note to ensure \n
+/// the size of the area of the message handler structure at the call side of API, and define \n
+/// the number of message handler.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation is not guaranteed if the number of elements of the array indicated by the address of the pointer (pMsgHandler)
+/// to the message handler structure does not match the number of arrays specified by the number of
+/// party-specified message hadlers (uiHandlerCount).
+/// - The callback information is registered to the heap.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedAttachParentCallbacksToDispatcher, FrameworkunifiedDetachParentCallbacksFromDispatcher,
+/// FrameworkunifiedDetachServiceFromDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachParentCallbacksToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolCallbackHandler *pMsgHandler,
+ UI_32 uiHandlerCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachCallbacksFromDispatcher
+/// \~english @par Brief
+/// API to cancel multiple Callback-informations from the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pServiceName
+/// PCSTR - Pointer to the service name
+/// \~english @param [in] puiCmdArray
+/// PUI_32 - Pointer to Command ID/request ID/approval ID of protocol on the service
+/// \~english @param [in] uiCommandCount
+/// UI_32 - Cancel handler count
+/// \~english @param [in] hSession
+/// HANDLE - Session handle (Default:NULL)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(pServiceName) is NULL to the service name specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(puiCmdArray) to cancel target ID specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - The number(uiCommandCount) of handlers to cancel specified by the argument is 0. [eFrameworkunifiedStatusInvldParam]
+/// - Specified service (ServiceName) in the argument is not present. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Cancel a Callback-information(iCmd,CbFuncPtr) of the service that has been specified by the argument \n
+/// from the Dispatcher.\n
+/// Thus, if the iCmd is requested from the service, so the appropriate Callback function is not called. \n
+/// If you have already specified the iCmd of revocation has been subject, to return the eFrameworkunifiedStatusOK.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the iCmad to be canceled is specified, the eFrameworkunifiedStatusOK is returned.
+/// - Event if an error occurs during deletion of two or more iCmd, the subsequent iCmd is deleted.
+/// - If a iCmd larger than the iCmd array is specified eFrameworkunifiedStatusOK is returned and all iCmd is deleted.\n
+/// - If the hade (hSession) for the session specified by the arguments is not appropriate (disabled),
+/// the system assumes that the session ID = MAX_SESSION_ID_VAL(0xFFFF) is specified.\n
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedDetachCallbackFromDispatcher,
+/// FrameworkunifiedAttachParentCallbacksToDispatcher, FrameworkunifiedDetachParentCallbacksFromDispatcher,
+/// FrameworkunifiedDetachServiceFromDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbacksFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiCmdArray,
+ UI_32 uiCommandCount, HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachCallbackFromDispatcher
+/// \~english @par Brief
+/// API to cancel a Callback-information from the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pServiceName
+/// PCSTR - Pointer to the service name
+/// \~english @param [in] iCmd
+/// UI_32 - Command ID/request ID/approval ID of protocol on the service
+/// \~english @param [in] hSession
+/// HANDLE - Session handle (Default:NULL)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(pServiceName) is NULL to the service name specified in the argument. [eFrameworkunifiedStatusInvldParam]
+/// - Specified service (ServiceName) in the argument is not present. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Cancel a Callback-information(iCmd,CbFuncPtr) of the service that has been specified by the argument \n
+/// from the Dispatcher.\n
+/// Thus, if the iCmd is requested from the service, so the appropriate Callback function is not called. \n
+/// If you have already specified the cancellation has been the subject or unregistered iCmd, to return \n
+/// the eFrameworkunifiedStatusOK.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the handle (hSession) for the session specified by the arguments is not appropriate (disabled),
+/// the system assumes that the session ID = MAX_SESSION_ID_VAL(0xFFFF) is specified.\n
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedAttachParentCallbacksToDispatcher, FrameworkunifiedDetachParentCallbacksFromDispatcher,
+/// FrameworkunifiedDetachServiceFromDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbackFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachCallbacksFromDispatcherWithFd
+/// \~english @par Brief
+/// API to cancel multiple Callback and file descriptor set from the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] fdArray
+/// int* - Pointer to cancel the target file descriptor array
+/// \~english @param [in] handlerCount
+/// UI_32 - Handler count of cancellation
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(fdArray) is NULL to cancel the target file descriptor array specified in the argument.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Handler count(handlerCount) of canceled specified by the argument is 0. [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor of the file descriptor in the array(fdArray) specified by the argument is incorrect(If fd is
+/// less than or equal to 0). [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor in the file descriptor array(fdArray) specified in the argument is already deleted from the
+/// management table, and can not search. [eFrameworkunifiedStatusFail]
+/// - There is no file descriptor management table of the specified HANDLE(hApp) in argument. [eFrameworkunifiedStatusFail]
+/// - Monitoring file descriptor for epoll managed by the HANDLE(hApp) specified in the argument is not
+/// appropriate. [eFrameworkunifiedStatusFail]
+/// - It failed to delete the file descriptor(fd) of the message waiting control from the monitoring of
+/// epoll_ctl(). [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Cancel Callback and file descriptor set that has been specified by the argument from the Dispatcher.\n
+/// For epoll_ctl() of Dispatcher, delete multiple file descriptor for the specified message waiting control \n
+/// by the argument.\n
+/// Thus, for the file descriptor became cancellation target, when receiving the message, the appropriate \n
+/// Callback function is not called.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation cannot be guaranteed if the number of elements of the array specified by the address of the pointer
+/// to the file descriptor array to be canceled (fdArray) does not match the number of arrays specified by the number of
+/// file descriptors to be canceled (uiCommandCount).
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedAttachCallbackFromDispatcherWithFd,
+/// FrameworkunifiedDetachCallbackFromDispatcherWithFd
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbacksFromDispatcherWithFd(HANDLE hApp, const int *fdArray, UI_32 uiCommandCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachCallbackFromDispatcherWithFd
+/// \~english @par Brief
+/// API to cancel a Callback and file descriptor from the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] fd
+/// int - Cancel the target file descriptor
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE(hApp) specified in the argument is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor(fd) specified in the argument is incorrect(If fd is less than or equal to 0).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - File descriptor specified in the argument is already deleted from the management table, and can not search.
+/// [eFrameworkunifiedStatusFail]
+/// - There is no file descriptor management table of the specified HANDLE(hApp) in argument. [eFrameworkunifiedStatusFail]
+/// - Monitoring file descriptor for epoll managed by the HANDLE(hApp) specified in the argument is not
+/// appropriate. [eFrameworkunifiedStatusFail]
+/// - It failed to delete the file descriptor(fd) of the message waiting control from the monitoring of
+/// epoll_ctl(). [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Cancel a Callback and file descriptor that has been specified by the argument from the Dispatcher.\n
+/// For epoll_ctl() of Dispatcher, delete a file descriptor(fd) for the specified message waiting control \n
+/// by the argument.\n
+/// Thus, for the file descriptor became cancellation target, when receiving the message, the appropriate \n
+/// Callback function is not called.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedAttachCallbackFromDispatcherWithFd,
+/// FrameworkunifiedDetachCallbacksFromDispatcherWithFd
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachCallbackFromDispatcherWithFd(HANDLE hApp, int fd);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachParentCallbacksFromDispatcher
+/// \~english @par Brief
+/// API to cancel the multiple of Callback information for the parent thread from Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] puiCmdArray
+/// PUI_32 - Pointer to an array of command/request on the service protocol
+/// \~english @param [in] uiCommandCount
+/// UI_32 - Handler count of cancellation
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE(hApp) specified in the argument is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer(puiCmdArray) to an array of command/request that you specified in the argument is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Handler count(uiCommandCount) of canceled specified by the argument is 0. [eFrameworkunifiedStatusInvldParam]
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Parent service name in the HANDLE(hApp) specified in the argument is NULL . [eFrameworkunifiedStatusInvldParam]
+/// - There is no parent service of the target in the HANDLE(hApp) specified in the argument. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Cancel multiple Callback-informations(iCmd,CbFuncPtr) from the Dispatcher to process \n
+/// the message from the parent thread. \n
+/// Thus, if iCmd has been requested from the parent service (application), the corresponding \n
+/// Callback function is no longer referred to. \n
+/// If you have already specified the iCmd of revocation has been subject, to return the eFrameworkunifiedStatusOK.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation cannot be guaranteed if the number of elements of the array specified by the address of the pointer (puiCmdArray)
+/// to the array of commands/requests on the service protocol does not match the number of arrays specified by the number of hadles to cancel (uiCommandCount).
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedAttachParentCallbacksToDispatcher, FrameworkunifiedDetachParentCallbacksFromDispatcher,
+/// FrameworkunifiedDetachServiceFromDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachParentCallbacksFromDispatcher(HANDLE hApp, const PUI_32 puiCmdArray, UI_32 uiCommandCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachServiceFromDispatcher
+/// \~english @par Brief
+/// Disconnect the service from Dispatcher, and API to cancel all the associated callbacks.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pServiceName
+/// PCSTR - Pointer to the service name
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE(hApp) specified in the argument is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Pointer (pServiceName) to the service name specified in the argument is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - Information corresponding to the service name(pServiceName) specified in the argument is not registered in
+/// Dispatcher. [eFrameworkunifiedStatusFail]
+/// - Callback information(Event information) of the service name(pServiceName) specified in the argument is not
+/// registered. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Cancel the entry of service information from Dispatcher, and cancel all callback \n
+/// information(event information) related to the service.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Service registration available/API processing when an event is registered:delete service, delete event, return eFrameworkunifiedStatusOK
+/// - Service registration available/API processing when an event is registered:delete service, return eFrameworkunifiedStatusOK
+/// - Service registration available/API processing when an event is registered:delete event, return eFrameworkunifiedStatusOK
+/// - Service registration available/API processing when an event is registered:nothing, return eFrameworkunifiedStatusFail
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedAttachParentCallbacksToDispatcher
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachServiceFromDispatcher(HANDLE hApp, PCSTR pServiceName);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSubscribeNotificationsWithCallback
+/// \~english @par Brief
+/// API to send a message to the notification service in order to register multiple Notification of list format.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pNtfyHandler
+/// FrameworkunifiedNotificationCallbackHandler - Pointer to a structure of the Notification Handler
+/// \~english @param [in] uiHandlerCount
+/// UI_32 - Notification Handler number
+/// \~english @par
+/// FrameworkunifiedNotificationCallbackHandler Structure
+/// \~english @code
+/// #define MAX_STRING_SIZE_NOTIFICATION 64
+/// typedef struct _FrameworkunifiedNotificationCallbackHandler
+/// {
+/// CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION]; /* Notification Name */
+/// CbFuncPtr callBack; /* Callback function pointer */
+/// }FrameworkunifiedNotificationCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNtfyHandler) is NULL to the structure of the Notification Handler specified in the argument.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Notification Handler number specified in the argument (uiHandlerCount) 0. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Notification Handler number specified in the argument (uiHandlerCount) has exceeded the maximum number of
+/// Notification. [eFrameworkunifiedStatusFail]
+/// - The acquisition of the buffer for storing a plurality of information of Notification Handler specified by
+/// the argument has failed. [eFrameworkunifiedStatusInvldParam]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// The Callback information of multiple Notification upon receipt that is specified in the form of a list, \n
+/// set to the notification service (NS_NPPService). \n
+/// In addition, collectively set the Callback information at the time of multiple Notification received that \n
+/// have been specified in the list format to Dispatcher.\n
+/// When the notification service receives the public message of the Notification, it sends a NPS_NOTIFY_EV_REQ \n
+/// message to the client that has registered the Notification. The client having received the NPS_NOTIFY_EV_REQ
+/// \n
+/// message, based on the Callback information registered in the Dispatcher, call a Callback corresponding to the
+/// \n
+/// Notification.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation is not guaranteed if the number of elemets of the array entity indicated by the address of the pointer (pNtfyHandler)
+/// to the Notification Handler structure does not match the number of arrays specified by the Notification Handler number (uiHandlerCount).
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithCallback(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pNtfyHandler,
+ UI_32 uiHandlerCount);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSubscribeNotificationWithCallback
+/// \~english @par Brief
+/// API to set the Callback information at the time of Notification received Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - Application handle
+/// \~english @param [in] pNotification
+/// PCSTR - Notification String.
+/// \param [in] fpOnCmd
+/// CbFuncPtr - Callback function that will be called on receiving pNotification.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusDuplicate Duplication error of entry
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNotification) is NULL to the Notification name specified. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - CbFuncPtr specified in the argument (fpOnCmd) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Can not add HANDLE specified in the argument (hApp) and CbFuncPtr specified in the argument (fpOnCmd) to
+/// notification list [eFrameworkunifiedStatusDuplicate]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Notification name specified by the argument has already been registered in the Dispatcher.
+/// [eFrameworkunifiedStatusDuplicate]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// The Callback information at the time of Notification received that has been specified by the argument, \n
+/// set in the notification service (NS_NPPService).\n
+/// Also, it sets the Callback information at the time of Notification received that has been specified by \n
+/// the argument to the Dispatcher.\n
+/// When the notification service receives the public message of the Notification, it sends a NPS_NOTIFY_EV_REQ \n
+/// message to the client that has registered the Notification. The client having received the NPS_NOTIFY_EV_REQ
+/// \n
+/// message, based on the Callback information registered in the Dispatcher, call a Callback corresponding to the
+/// \n
+/// Notification.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedUnsubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback, FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithCallback(HANDLE hApp, PCSTR pNotification, CbFuncPtr fpOnCmd);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnsubscribeNotificationsWithCallback
+/// \~english @par Brief
+/// API to bulk delete the Callback information at the time of multiple Notification received from the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pNtfyHandler
+/// FrameworkunifiedNotificationCallbackHandler - Pointer to a structure of the Notification Handler
+/// \~english @param [in] uiHandlerCount
+/// UI_32 - Notification Handler number
+/// \~english @par
+/// FrameworkunifiedNotificationCallbackHandler Structure
+/// \~english @code
+/// #define MAX_STRING_SIZE_NOTIFICATION 64
+/// typedef struct _FrameworkunifiedNotificationCallbackHandler
+/// {
+/// CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION]; /* Notification Name */
+/// CbFuncPtr callBack; /* Callback function pointer */
+/// }FrameworkunifiedNotificationCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNtfyHandler) is NULL to the structure of the Notification Handler specified in the argument.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Notification Handler number specified in the argument (uiHandlerCount) 0. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Notification Handler number specified in the argument (uiHandlerCount) has exceeded the maximum number of
+/// Notification. [eFrameworkunifiedStatusFail]
+/// - In Notification name in the structure of the Notification Handler specified in the argument, there is not
+/// applicable in those registered as Callback information. [eFrameworkunifiedStatusFail]
+/// - The acquisition of the buffer for storing a plurality of information of Notification Handler specified by
+/// the argument has failed. [eFrameworkunifiedStatusInvldParam]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// The Callback information of multiple Notification upon receipt that is specified in the form of a list, \n
+/// collectively removed from the notification service (NS_NPPService). \n
+/// In addition, the bulk delete the Callback information at the time of multiple Notification received that \n
+/// are specified in the form of a list from the Dispatcher.\n
+/// By bulk delete the Callback information, if the notification services receives the public message
+/// Notification, \n
+/// because the Notification information applicable also been deleted, Callback does not occur.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPRegisterNotifications,
+/// FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithCallback(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pNtfyHandler,
+ UI_32 uiHandlerCount);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnsubscribeNotificationWithCallback
+/// \~english @par Brief
+/// API to detach a notification callback from the dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - Application handle
+/// \~english @param [in] pNotification
+/// PCSTR - Notification String.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNotification) is NULL to the Notification name specified. [eFrameworkunifiedStatusInvldParam]
+/// - Length of pointer (pNotification) is 0 to the Notification name specified. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Missing HANDLE specified in the argument (hApp) in notification list [eFrameworkunifiedStatusFail]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// The Callback information at the time of Notification received that has been specified by the argument, \n
+/// to remove from the notification service (NS_NPPService).\n
+/// Also, delete the Callback information of Notification upon receipt, which is specified by the argument \n
+/// from the Dispatcher.
+/// By bulk delete the Callback information, if the notification services receives the public message
+/// Notification, \n
+/// because the Notification information applicable also been deleted, Callback does not occur.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPRegisterNotifications,
+/// FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithCallback(HANDLE hApp, PCSTR pNotification);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetAppName
+/// \~english @par Brief
+/// Get the application thread name that is registered with the dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval PCSTR Pointer to application thread name
+/// \~english @retval NULL NULL pointer (Failed to get application name)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// \~english @par Detail
+/// Get the application thread name that was registered at initialization of dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedDispatcherWithArguments, FrameworkunifiedDispatcher, FrameworkunifiedCreateDispatcherWithoutLoop
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetAppName(HANDLE hApp);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetThreadSpecificData
+/// \~english @par Brief
+/// Set pointer to the application-specific data to the application HANDLE.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] data
+/// PVOID - Pointer to the application-specific data
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// This API sets application-specific data to internal pointer inside application framwork HANDLE.\n
+/// You can share data in callback function or thread.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedGetThreadSpecificData
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetThreadSpecificData(HANDLE hApp, PVOID data);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetThreadSpecificData
+/// \~english @par Brief
+/// Get pointer to the application-specific data from the application HANDLE.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @retval PVOID pointer to application-specific data.
+/// \~english @retval NULL NULL pointer(failed to get data)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// \~english @par Detail
+/// This API gets application-specific data that set with FrameworkunifiedSetThreadSpecificData from internal pointer inside
+/// application framwork HANDLE.\n
+/// You can share data in callback function or thread.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedSetThreadSpecificData
+////////////////////////////////////////////////////////////////////////////////////////////
+PVOID FrameworkunifiedGetThreadSpecificData(HANDLE hApp);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOpenService
+/// \~english @par Brief
+/// API to acquire a service HANDLE.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pServiceName
+/// PCSTR - Pointer to service name
+/// \~english @retval HANDLE Handle to the service
+/// \~english @retval NULL NULL pointer (Failed to get service handle)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// - Only when will open the session by FrameworkunifiedOpenSession, you can use the handle obtained by this API.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Service name specified in the argument (pServiceName) is NULL. [NULL]
+/// - Service name specified in the argument (pServiceName) is not appropriate (NULL, over 20byte). [NULL]
+/// - Normalized service name for message queue is not appropriate (over 15byte). [NULL]
+/// - Can not be acquired memory for message queue infomation(malloc). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+/// \~english @par Detail
+/// Create a communication resource for communicating with the specified service , return the HANDLE.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedCloseService, FrameworkunifiedOpenSession
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedOpenService(HANDLE hApp, PCSTR pServiceName);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCloseService
+/// \~english @par Brief
+/// API to close service HANDLE.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService HANDLE acquired in)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hService) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hService) is mismatch.(eQTypeSender or
+/// eQTypeReveiver) [eFrameworkunifiedStatusInvldHndlType]
+/// - Failed to close message queue specified in the argument (hService). [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// This API closes service HANDLE specified by argument.\n
+/// And close message queue of the service.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenService
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseService(HANDLE hApp, HANDLE hService);
+
+//////////////////////////////////////////////////
+// message center functions
+//////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedMcOpenSender
+/// \~english @par Brief
+/// Generate a handle to the message queue for sending.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @param [in] pName
+/// PCSTR - Message queue name of destination service
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (pName) is NULL. [NULL]
+/// - Message queue name specified in the argument (pName) is not appropriate (NULL, over 20byte). [NULL]
+/// - Normalized message queue name is not appropriate (over 15byte). [NULL]
+/// - Can not be acquired memory for message queue infomation(malloc). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+/// \~english @par Detail
+/// This API generates and returns a handle to the message queue for sending of service.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedMcClose
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedMcOpenSender(HANDLE hApp, PCSTR pName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedMcClose
+/// \~english @par Brief
+/// API for closing a message queue handle
+/// \~english @param [in] hService
+/// HANDLE - Handle for services (handle obtained by FrameworkunifiedMcOpenSender)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hService specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hService specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle in the handle (hService) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hService) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the message queue types of the handles (hService) specified in the arguments do not match, [eFrameworkunifiedStatusInvldHandle]
+/// - Closing the message queue for the handle (hService) specified in the arguments fails, [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Closes the message queue for the specified service.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedMcOpenSender
+///
+/// To close message queue handle to a service
+///
+/// \param [in] hService
+/// HANDLE - Handle to a service
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedMcClose(HANDLE hService);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSendMsg
+/// \~english @par Brief
+/// Asynchronous API that sends messages to the service
+/// \~english @param [in] hService
+/// HANDLE - Handle for services (handle acquired by FrameworkunifiedMcOpenSender, etc.)
+/// \~english @param [in] uiCmd
+/// UI_32 - Command ID, Request ID, and Authorization ID on the service's protocol
+/// \~english @param [in] uiLength
+/// UI_32 - Data size to be sent (0 to 4294967255)
+/// \~english @param [in] pData
+/// PCVOID - Pointer to the data to send
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Handles for services must be acquired (FrameworkunifiedMcOpenSender, etc.).
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hService specified in the arguments is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - If the hService specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue name of the handle (hService) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue of the handle (hService) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle in the handle (hService) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hService) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the send data (pData) specified in the parameter is NULL and the data length (uiLength) is not 0, [eFrameworkunifiedStatusInvldBuf]
+/// - When the name of the message queue handle in the handle (hService) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldQName]
+/// - If the name of the message queue handle (hService) specified in the argument exceeds 20 bytes, [eFrameworkunifiedStatusInvldQName]
+/// - When the message queue type of the handle (hService) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sessions for services is full [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptor for sending messages for sessions intended for the service [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending session-specific messages for services [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of send buffers for sessions intended for services [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for the services [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages for sessions for services [eFrameworkunifiedStatusErrOther]
+/// - When the size (uiLength) of the data to be sent specified in the parameter is out of range, [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Messages are sent to the service using the message queue associated with the service handle.\n
+/// A destination is a service specified as arguments such as FrameworkunifiedMcOpenSender when a service handle was created.\n
+/// This API operates asynchronously.
+/// \~english @par
+/// - The consistency between the size of the data to be sent and the size of the area indicated by the pointer to the data to be sent is ensure by the caller.
+/// - The maximum data size (uiLength) described above is a theoretical value. The maximum data size that can be actually used depends on the environment requirements.\n
+/// The maximum value is the upper limit of the type (UINT_MAX) minus the following size.\n
+/// Message header section\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method
+/// \~english @see FrameworkunifiedMcOpenSender, FrameworkunifiedOpenService
+///
+/// Send message to the service.
+///
+/// \param [in] hService
+/// HANDLE - Handle to the service.
+/// \param [in] uiCmd
+/// UI_32 - Protocol message id.
+/// \param [in] uiLength
+/// UI_32 - Length of the data to be send.
+/// \param [in] pData
+/// PVOID - Pointer to the data.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendMsg(HANDLE hService, UI_32 uiCmd, UI_32 uiLength, PCVOID pData);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendPriorityMsg
+/// Send message to a service. It places your message at the top of the services message queue.
+/// \b Applications should not use this unless absolutely required - use cases must be reviewed by
+/// \b Framework Team.
+///
+/// \param [in] hService
+/// HANDLE - Handle to the service.
+/// \param [in] uiCmd
+/// UI_32 - Protocol message id.
+/// \param [in] uiLength
+/// UI_32 - Length of the data to be send.
+/// \param [in] pData
+/// PVOID - Pointer to the data.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendPriorityMsg(HANDLE hService, UI_32 uiCmd, UI_32 uiLength, PCVOID pData);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSendSelf
+/// \~english @par Brief
+/// Asynchronous APIs that send messages to the application's own Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] iCmd
+/// UI_32 - Command ID, Request ID, and Authorization ID on the service's protocol
+/// \~english @param [in] length
+/// UI_32 - Data size to be sent (0 to 4294967255)
+/// \~english @param [in] data
+/// PCVOID - Pointer to the data to send
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hService specified in the arguments is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - If the hService specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle for the own Dispatcher in the handle (hService) specified by the arguments is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - Invalid message queue handle for its own Dispatcher in the handle (hService) specified by the arguments [eFrameworkunifiedStatusInvldHandle]
+/// - When the send data (data) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldBuf]
+/// - When the service name of the handle (hService) specified in the arguments is not appropriate (when the service name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue handle for the own Dispatcher in the handle (hService) specified in the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - Failed to access shared memory for sending messages for its own Dispatcher [eFrameworkunifiedStatusErrOther]
+/// - When the message queue type for the own Dispatcher of the handle (hService) specified in the parameter is not the send type [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue for your Dispatcher is full [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptor for sending messages for own Dispatcher [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending messages for the Dispatcher itself [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of send buffers for sessions intended for services [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for your Dispatcher [eFrameworkunifiedStatusFail]
+/// - When the size (length) of the data to be sent specified in the parameter is out of range, [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Send messages to the application's own Dispatcher.\n
+/// This API operates asynchronously.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - The maximum data size (length) described above is a theoretical value. The maximum data size that can be actually used depends on the environment requirements.\n
+/// The maximum value is the upper limit of the type (UINT_MAX) minus the following size.\n
+/// Message header section\n
+/// - Operation cannot be guaranteed when the size of the allocated area indicated by the address of the pointer (data) to the data buffer does not match the size specified by the size of the data buffer (length).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method
+/// \~english @see FrameworkunifiedSendMsg
+///
+/// Send message to the hApp.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the dispatcher to receive message
+/// \param [in] iCmd
+/// UI_32 - Protocol message id.
+/// \param [in] length
+/// UI_32 - Length of the data to be send.
+/// \param [in] data
+/// PVOID - Pointer to the data.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendSelf(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedInvokeSync
+/// \~english @par Brief
+/// API for synchronous communication of the message.
+/// \~english @param [in] hService
+/// HANDLE - Handle for the message queue
+/// \~english @param [in] iCmd
+/// UI_32 - Command ID
+/// \~english @param [in] msgLenght
+/// UI_32 - Data length of the send message
+/// \~english @param [in] msgData
+/// PCVOID - Pointer to send the message
+/// \~english @param [in] responseLength
+/// UI_32 - Size of the received message storage buffer
+/// \~english @param [out] responseData
+/// PVOID - Pointer to the received message storage buffer
+/// \~english @param [out] receivedLength
+/// UI_32 * - Data length of the received message
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusBadConnection It can not be a socket connection
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// - Handles for message queue must be acquired (FrameworkunifiedMcOpenSender, etc.).
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hService) specified in the argument is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE(hService) specified in the argument is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - It failed to open the message queue for the response received [eFrameworkunifiedStatusFail]
+/// - Send message queue HANDLE in HANDLE(hService) specified in the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Send message queue HANDLE in HANDLE(hService) specified in the argument is not appropriate (which is
+/// invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE for the response received is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE for the response received is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - The size of the received message storage buffer specified by the argument is not 0, and the pointer is NULL
+/// to the received message storage buffer. [eFrameworkunifiedStatusInvldHandle]
+/// - It fails to get the message storage buffer for the response received. [eFrameworkunifiedStatusFail]
+/// - Random number generation to fail for the sequence ID of the message for transmission. [eFrameworkunifiedStatusFail]
+/// - Message queue name of HANDLE(hService) specified in the argument is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue name of HANDLE(hService) specified in the argument exceeds 20byte. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE(hService) specified in the argument is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE(hService) specified in the argument exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE(hService) specified in the argument is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmit and receive file descriptor of the session message. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) occurs during the transmission and reception of the session
+/// message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the sending and receiving of a session message. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for the session message to be sent to service failed. [eFrameworkunifiedStatusErrOther]
+/// - It failed to Socket connection of the response message for the reception. [eFrameworkunifiedStatusFail]
+/// - The wait control of the response message received failed. [eFrameworkunifiedStatusFail]
+/// - Interruption by the system call (signal) to wait in the response message received has occurred.
+/// [eFrameworkunifiedStatusFail]
+/// - In response message at the time of failure to receive, it failed to re-connection of the Socket.
+/// [eFrameworkunifiedStatusBadConnection]
+/// \~english @par Detail
+/// Under the following procedure, perform synchronous communication of the message.
+/// - During the first call, it generates a message queue name for the response message received by the
+/// McCreateInvokerName(),
+/// and to open the message queue for the response message received by the McOpenSyncReceiver ().
+/// - By the McInvokeSync(), perform synchronous communication of the message.
+/// \~english @par
+/// If the received response message is greater than the storage buffer, to store up to store buffer length.\n
+/// The user is able to detect an abnormality by comparing store buffer length and a received message length.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedSendMsg
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedInvokeSync(HANDLE hService, UI_32 iCmd, UI_32 msgLenght, PCVOID msgData, UI_32 responseLength,
+ PVOID responseData, UI_32 *receivedLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetSyncResponseData
+/// \~english @par Brief
+/// API to set the response data of the synchronization communication.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @param [in] data
+/// PVOID - Pointer to the response data
+/// \~english @param [in] size
+/// UI_32 - The response data size
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE(hApp) specified in the argument is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - Pointer to the response data(data) specified in the argument is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - If the size (size) of the response data specified in the arguments cannot be allocated, [eFrameworkunifiedStatusFail]
+/// - When the response data size (size) specified in the parameter is out of range, [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Store the response data specified in the storage area of the response data \n
+/// in the handle specified by the argument.
+/// \~english @par
+/// Response data set by this PROCESS is automatically sent by the Dispatcher after the callback function completes execution, so the API does not need to send the response data.
+/// \~english @par
+/// - The response data is registered to the heap.
+/// - If the pointer (data) to the response data is normal (not NULL) and 0 is specified for the size (size) of the response data, the response data is set to empty.
+/// - The maximum size (size) of the response data described above is a theoretical value. The maximum size that can be used is environment-dependent.\n
+/// The maximum value is the upper limit of the type (UINT_MAX) minus the following size.\n
+/// Message header section and response message header section\n
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedInvokeSync
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetSyncResponseData(HANDLE hApp, PVOID data, UI_32 size);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetMsgLength
+/// \~english @par Brief
+/// API to retrieve the data length of the received message.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval UI_32 The data length of the received message
+/// \~english @retval 0 Error or No data
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [0]
+/// - HANDLE(hApp) specified in the argument is not appropriate (which is invalid). [0]
+/// \~english @par Detail
+/// To return the data length of the received messages in the handle(hApp) \n
+/// that you specified in the argument as a return value. \n
+/// It is possible to get by to use when the message was received. \n
+/// If the return value is 0, there is a need for caution because of either \n
+/// error or no data.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetMsgLength(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetMsgProtocol
+/// \~english @par Brief
+/// API to get the Command ID/Request ID/Approval ID on the protocol.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval UI_32 Command ID/Request ID/Approval ID
+/// \~english @retval 0 Error
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE(hApp) specified in the argument is NULL. [0]
+/// - HANDLE(hApp) specified in the argument is not appropriate (which is invalid). [0]
+/// \~english @par Detail
+/// To return the Command ID/Request ID/Approval ID that are within \n
+/// the handle(hApp) specified in the argument as a return value.
+/// \~english @par
+/// The application shall execute this API using an application handle passed as an argument to the callback function.
+/// (Messages are received within the framework, stored in the application handles (hApp),
+/// and then executed by the application callback functions.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetMsgProtocol(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetMsgDataOfSize
+/// \~english @par Brief
+/// API to get the data of the received message
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [out] pData
+/// PVOID - Pointer to the buffer where the received message data will be copied
+/// \~english @param [in] uiSize
+/// UI_32 - Size of the buffer to which received message data is copied
+/// \~english @param [in] eRetrieveMethod
+/// ESMRetrieveTypes - Shared memory-acquisition-type (optional; eSMRRelease if not specified)
+/// \~english @par
+/// enum ESMRetrieveTypes variables
+/// - eSMRRelease = 0 : The shared memory data is deleted after acquisition.
+/// - eSMRRetain = 1 : Shared memory data is maintained.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the data size is larger than the buffer size (uiSize) specified by the parameter, [eFrameworkunifiedStatusInvldBufSize]
+/// - If the buffer (pData) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldBuf]
+/// - Incoming messages are incorrect [eFrameworkunifiedStatusInvldHndlType]
+/// - If the shared memory ID specified in the received message is invalid [FrameworkunifiedStatusErrOther]
+/// - If accessing shared memory (shm_open/fstat/mmap) fails [eFrameworkunifiedStatusErrOther]
+/// - If the size of the data in shared memory is larger than the buffer size (uiSize) specified by the arguments [FrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Receive message data is acquired from the receive buffer in the application handle (hApp) or the shared memory (message is stored in the shared memory when the size is 4096 bytes or more), and is stored in the area passed in the parameter pData.\n
+/// When data exists in the shared memory, the data is held or deleted in the shared memory by specifying the eRetrieveMethod of arguments of this API
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Execute this API using an application handle passed as an argument of a callback function.
+/// (Messages are received within the framework, stored in the application handles (hApp), and then executed by the application callback functions.)
+/// - Before executing this API, the size of the received message must be checked by the FrameworkunifiedGetMsgLength to determine whether data is to be retained in the shared memory.
+/// - If it is kept in shared memory, the application must execute the FrameworkunifiedClearMsgData and delete it.
+/// - If an invalid value other than the ESMRetrieveTypes defined value is specified for the shared memory allocation type (eRetrieveMethod), the shared memory allocation type behaves as if eSMRRetain were specified.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedClearMsgData
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [out] pData
+/// PVOID - Buffer to which the received message data will be copied.
+/// \param [out] uiSize
+/// UI_32 - Size of the buffer to which the received message data will be copied.
+/// \param [in] eRetrieveMethod
+/// ESMRetrieveTypes -
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \~english @par Type
+/// Sync
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetMsgDataOfSize(HANDLE hApp, PVOID pData, UI_32 uiSize, ESMRetrieveTypes eRetrieveMethod = eSMRRelease);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetDataPointer
+/// \~english @par Brief
+/// API to get start address of data from received message
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [out] datap
+/// void** - Pointer to the data of the received message
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the receive buffer address of the handle (hApp) specified in the parameter is NULL [eFrameworkunifiedStatusInvldBufSize]
+/// - When the pointer (datap) to the data of the received message specified by the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// This function gets the received message data from the receive buffer in the application handle (hApp)
+/// and returns the start address of the received message in the argument datap.\n
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - This API can be executed for messages that do not use shared memory (messages with a message size less than 4096 bytes).
+/// Check the size of received messages in the FrameworkunifiedGetMsgLength prior to executing this API.
+/// - Since the pointers acquired by this API are part of the Dispatcher, the pointers acquired by this API must not be released by the application.
+/// - Execute this API using an application handle passed as an argument of a callback function.
+/// (Messages are received within the framework, stored in the application handles (hApp), and then executed by the application callback functions.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [out] datap
+/// void ** - Pointer to which the receive message data.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @par Type
+/// Sync
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetDataPointer(HANDLE hApp, void **datap);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetMsgSrc
+/// \~english @par Brief
+/// API to get the application name of the sender of the received message
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval PCSTR Name of the application from which the message was sent
+/// \~english @retval NULL NULL pointer (Acquisition failure)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [NULL]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// \~english @par Detail
+/// This API returns the application name of the sender of the received message.\n
+/// The application name acquired by this API is used for establishing sessions, creating message queues for responses,
+/// and registering/releasing callbacks to the Dispatcher.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Execute this API using an application handle passed as an argument of a callback function.
+/// (Messages are received within the framework, stored in the application handles (hApp), and then executed by the application callback functions.)
+/// - Since the pointers acquired by this API are part of the Dispatcher, the pointers acquired by this API must not be released by the application.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedOpenService, FrameworkunifiedCreateSession, FrameworkunifiedMcOpenSender, \n
+/// FrameworkunifiedAttachCallbackToDispatcher, FrameworkunifiedAttachCallbacksToDispatcher, \n
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher, FrameworkunifiedDetachServiceFromDispatcher
+///
+/// Source of the message.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return pSourceName
+/// PCSTR - Source name of the message.
+/// \~english @par Type
+/// Sync
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetMsgSrc(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetLastNotification
+/// \~english @par Brief
+/// Get the most recent Notification names
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval PCSTR Pointers to Notification
+/// \~english @retval NULL NULL pointer (Acquisition failure)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [NULL]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// \~english @par Detail
+/// This API acquires and returns the most recent Notification name from the received data.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Execute this API using an application handle passed as an argument of a callback function.
+/// (Messages are received within the framework, stored in the application handles (hApp), and then executed by the application callback functions.)
+/// - Since the pointers acquired by this API are part of the Dispatcher, the pointers acquired by this API must not be released by the application.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedNPPublishNotification
+///
+/// Returns the last notification string that was received.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return pSourceName
+/// PCSTR - the last notification name that has been received.
+/// \~english @par Type
+/// Sync
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetLastNotification(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedClearMsgData
+/// \~english @par Brief
+/// API to delete shared memory used for sending and receiving messages
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval eFrameworkunifiedStatusOK Successful or Use Shared Memory Messages
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldID Invalid ID
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - Framework generating failure [eFrameworkunifiedStatusInvldParam]
+/// - If the shared memory ID specified in the message is invalid [eFrameworkunifiedStatusInvldParam]
+/// - If an attempt is made to remove a non-existent shared memory, [eFrameworkunifiedStatusInvldID]
+/// - If accessing shared memory (shm_unlink) fails, [eFrameworkunifiedStatusFail]
+/// - When the receive buffer address of the handle (hApp) specified in the parameter is NULL [eFrameworkunifiedStatusInvldBuf]
+/// \~english @par Detail
+/// This API deletes the shared memory used for sending and receiving messages.\n
+/// When an application gets received messages by specifying eSMRRetain as FrameworkunifiedGetMsgDataOfSize, it deletes the shared memories by using this API...\n
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - The shared memory information to be deleted by this API shall be executed by the application on the message receiving side because it is obtained from the received message.\n
+/// - Execute this API using an application handle passed as an argument of a callback function.
+/// (Messages are received within the framework, stored in the application handles (hApp), and then executed by the application callback functions.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedSendMsg, FrameworkunifiedGetMsgDataOfSize
+///
+/// Explicit call to clear the data from shared memory.
+/// To be used incase of forwarding messages ???
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @par Type
+/// Sync
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedClearMsgData(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedForwardMessage
+/// Forward a message to a service or a client.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the service
+/// \param [in] hChildQ
+/// HANDLE - Handle to the child thread
+/// \param [in] iCmd
+/// UI_32 - .
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedMcClose, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedGetSystemInfo
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedForwardMessage(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd);
+
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// Notification & Persistence Service
+////////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPRegisterNotification
+/// \~english @par Brief
+/// To the notification service to register the Notification, API to send a message.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pNotification
+/// PCSTR - A pointer to the Notification name
+/// \~english @param [in] max_length
+/// UI_32 - The maximum length of the Notification message (64byte below)
+/// \~english @param [in] persType
+/// \~english @par
+/// EFrameworkunifiedNotificationType - Type of Notification
+/// enum EFrameworkunifiedNotificationType Variable
+/// - eFrameworkunifiedNotificationVar : Non Persistent. Not stored locally by NPS.
+/// - eFrameworkunifiedStateVar : Non Persistent. stored locally by NPS.
+/// - eFrameworkunifiedPersistedStateVar : Not to be used. Persistent. Also stored locally by NPS.
+/// - eFrameworkunifiedPersistedStateUserVar : Not to be used. User specific Persistent. Also stored locally by NPS.
+/// - eFrameworkunifiedImmediatePersistedStateVar : Not to be used.
+/// - eFrameworkunifiedUnknown : Not to be used. This is not a type of notification.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNotification) is NULL to the Notification name specified. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - It is not appropriate length of the specified Notification name in argument(0, or more than a 64byte).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// To the notification service (NS_NPPService) to register the Notification, \n
+/// send a message for the Notification registration.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedNPRegisterNotifications, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback, FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
+ const EFrameworkunifiedNotificationType persType);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetPersistNotfnDefaultValue
+/// API to send message to Notification Service to set the default value for the notification.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+/// \param [in] data
+/// PVOID - Set the default value for the notification.
+/// \param [in] uiLength
+/// const UI_32 - length of the data
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetPersistNotfnDefaultValue(HANDLE hApp, PCSTR pNotification, PVOID data, const UI_32 uiLength);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPSetPersistentNotfnType
+/// \~english @par Brief
+/// API to send message to Notification Service to set persistent notification category.
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \~english @param [in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @param [in] ePersistCategory
+/// EFrameworkunifiedPersistCategory - Persistent Category
+/// \~english @return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @code
+/// typedef enum _EFrameworkunifiedNotificationType
+/// {
+/// eFrameworkunifiedNotificationVar = 0, /* Not persistent (not retained by NPS) */
+/// eFrameworkunifiedStateVar, /* Not persistent (held by NPS) */
+/// eFrameworkunifiedPersistedStateVar, /* persistent. Only kept in NPS */
+/// eFrameworkunifiedPersistedStateUserVar, /* Invalid handle type. Only kept in NPS */
+/// eFrameworkunifiedImmediatePersistedStateVar, /* Invalid handle. See \ref
+/// FrameworkunifiedNPRegisterImmediatePersistNotification */
+/// eFrameworkunifiedUnknown /* No Notification typing. Not recommended */
+/// } EFrameworkunifiedNotificationType;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue information handle specified in the argument (hApp) is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see none
+///
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetPersistentNotfnType(HANDLE hApp, PCSTR pNotification, EFrameworkunifiedPersistCategory ePersistCategory);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPRegisterImmediatePersNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to register a immediate notification
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \~english @param [in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @param [in] max_length
+/// const UI_32 - Max size of the notification message (should be <= 1Kb)
+/// \~english @param [in] delay
+/// const UI_32 - Min time interval between every persist (in sec)
+/// \~english @return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the pNotification to the Notification specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the length of the Notification specified by the arguments is 0, [eFrameworkunifiedStatusInvldParam]
+/// - If the length of the Notification specified in the arguments is 64 (MAX_STRING_SIZE_NOTIFICATION) or greater [eFrameworkunifiedStatusInvldParam]
+/// - Failed to get buffers to store Notification [eFrameworkunifiedStatusInvldParam]
+/// - When memory could not be allocated due to the allocation of message-sending buffers (malloc),... [eFrameworkunifiedStatusFail]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API registers a Notification to the notification service (NS_NPPService).\n
+/// By sending a Notification registration message to the notification service, the specified Notification is registered in the received notification service.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedNPRegisterNotifications, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback,FrameworkunifiedSubscribeNotificationsWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterImmediatePersistNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
+ const UI_32 delay);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPPersistentSync
+/// Processing which synchronizes by NPPService (syncfs)
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPPersistentSync(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPRegisterNotifications
+/// \~english @par Brief
+/// API to send a message to the notification service in order to register multiple Notification of list format.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pList
+/// FrameworkunifiedNotificationsList - Pointer to the Notification list to be registered
+/// \~english @param [in] uiListLength
+/// UI_32 - List length
+/// \~english @par
+/// FrameworkunifiedNotificationsList Structure
+/// \~english @code
+/// #define MAX_STRING_SIZE_NOTIFICATION 64
+/// typedef struct _FrameworkunifiedNotificationsList
+/// {
+/// CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION]; /* Notification Name */
+/// UI_32 uiLengthData; /* Notification Name length(64byte below) */
+/// EFrameworkunifiedNotificationType persType; /* Notification Type */
+/// }
+/// @endcode
+/// \~english @par
+/// enum EFrameworkunifiedNotificationType Variable
+/// - eFrameworkunifiedNotificationVar : Non Persistent. Not stored locally by NPS.
+/// - eFrameworkunifiedStateVar : Non Persistent. stored locally by NPS.
+/// - eFrameworkunifiedPersistedStateVar : Not to be used. Persistent. Also stored locally by NPS.
+/// - eFrameworkunifiedPersistedStateUserVar : Not to be used. User specific Persistent. Also stored locally by NPS.
+/// - eFrameworkunifiedImmediatePersistedStateVar : Not to be used.
+/// - eFrameworkunifiedUnknown : Not to be used. This is not a type of notification.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - A pointer to the Notification list to register specified in the argument (pList) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - And fail to acquire the buffer for storing a plurality Notification. [eFrameworkunifiedStatusInvldParam]
+/// - List specified in the argument length (uiListLength) has exceeded the maximum number of Notification.
+/// [eFrameworkunifiedStatusFail]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// This API is to register multiple Notification of list format to the notification service (NS_NPPService).\n
+/// By transmitting multiple Notification registration message to the notification service, Notification \n
+/// specified in the received notification service is registered. \n
+/// It sends a message for multiple Notification registered with the notification service (NS_NPPService) \n
+/// in order to register multiple Notification of list format.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPUnRegisterNotification, FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback, FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPUnRegisterNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to remove a notification.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pNotification
+/// PCSTR - A pointer to the Notification name
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNotification) is NULL to the Notification name specified. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - It fails to get the buffer that stores the Notification. [eFrameworkunifiedStatusInvldParam]
+/// - It is not appropriate length of the specified Notification name in argument(0, or more than a 64byte).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Can not be acquired memory in the acquisition of buffer for internal processing (malloc). [eFrameworkunifiedStatusFail]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// This API is, to remove the Notification from the notification service (NS_NPPService). \n
+/// By deleting, Notification specified from the notification service will no longer be delivered.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPRegisterNotifications, FrameworkunifiedNPUnRegisterNotifications,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback, FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotification(HANDLE hApp, PCSTR pNotification);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPUnRegisterNotifications
+/// \~english @par Brief
+/// API to send message to Notification Service to delete a notification.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pList
+/// FrameworkunifiedNotificationsList - Pointer to the Notification list that you want to delete
+/// \~english @param [in] uiListLength
+/// UI_32 - List length
+/// \~english @par
+/// FrameworkunifiedNotificationsList Structure
+/// \~english @code
+/// #define MAX_STRING_SIZE_NOTIFICATION 64
+/// typedef struct _FrameworkunifiedNotificationsList
+/// {
+/// CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION]; /* Notification Name */
+/// UI_32 uiLengthData; /* Notification Name length(64byte below) */
+/// EFrameworkunifiedNotificationType persType; /* Notification Type */
+/// }
+/// @endcode
+/// \~english @par
+/// enum EFrameworkunifiedNotificationType Variable
+/// - eFrameworkunifiedNotificationVar : Non Persistent. Not stored locally by NPS.
+/// - eFrameworkunifiedStateVar : Non Persistent. stored locally by NPS.
+/// - eFrameworkunifiedPersistedStateVar : Not to be used. Persistent. Also stored locally by NPS.
+/// - eFrameworkunifiedPersistedStateUserVar : Not to be used. User specific Persistent. Also stored locally by NPS.
+/// - eFrameworkunifiedImmediatePersistedStateVar : Not to be used.
+/// - eFrameworkunifiedUnknown : Not to be used. This is not a type of notification.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - It fails to get the buffer that stores multiple Notification. [eFrameworkunifiedStatusInvldParam]
+/// - List specified in the argument length (uiListLength) has exceeded the maximum number of Notification.
+/// [eFrameworkunifiedStatusFail]
+/// - Can not be acquired memory in the acquisition of buffer for internal processing (malloc). [eFrameworkunifiedStatusFail]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// This API is, delete multiple Notification of list format from the notification service (NS_NPPService). \n
+/// By deleting, Notification specified from the notification service will no longer be delivered.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPRegisterNotifications, FrameworkunifiedNPUnRegisterNotification,
+/// FrameworkunifiedNPPublishNotification, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedUnsubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback, FrameworkunifiedUnsubscribeNotificationsWithCallback
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList,
+ UI_32 uiListLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPPublishNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to notify subscribers
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application
+/// \~english @param [in] pNotification
+/// PCSTR - A pointer to the Notification name
+/// \~english @param [in] pData
+/// VOID * - Data buffer pointer
+/// \~english @param [in] iLength
+/// UI_32 - Size of data buffer
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some kind of error has occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - NS_NPPService of the process has been started.
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Conditions of processing failure
+/// - Pointer (pNotification) is NULL to the Notification name specified. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldParam]
+/// - Can not be acquired memory in the acquisition of the buffer of the message for transmission (malloc).
+/// [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Message queue name of HANDLE specified in the argument (hApp) is not appropriate(The name is NULL, more than
+/// 20byte) [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hApp) is not a transmission.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - It failed to shared memory access for transmission of the session message for the NPP Service.
+/// [eFrameworkunifiedStatusErrOther]
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Detail
+/// Send a message to the notification service(NS_NPPService), and notifies the Subscriber.\n
+/// - Publisher is required registration of Notification in advance FrameworkunifiedNPRegisterNotification.
+/// - Publisher is possible cancellation of the Notification in FrameworkunifiedNPUnRegisterNotification.
+/// - Subscriber need a reception procedure of Notification in advance FrameworkunifiedSubscribeNotification.
+/// - Subscriber is capable of receiving cancellation of the Notification in FrameworkunifiedUnsubscribeNotification.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedNPRegisterNotification, FrameworkunifiedNPUnRegisterNotification
+/// FrameworkunifiedNPRegisterNotifications, FrameworkunifiedNPUnRegisterNotifications
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPPublishNotification(HANDLE hApp, PCSTR pNotification,
+ PCVOID pData, UI_32 iLength);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPReadPersistedData
+/// \~english @par Brief
+/// API to requested the persistent data corresponding to the notification if available
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \~english @param [in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the pNotification to the Notification specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the length of the Notification specified by the arguments is 0, [eFrameworkunifiedStatusInvldParam]
+/// - Failed to get buffers to store Notification [eFrameworkunifiedStatusInvldParam]
+/// - When memory could not be allocated due to the allocation of message-sending buffers (malloc),... [eFrameworkunifiedStatusFail]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for the NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see none
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReadPersistedData(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPRegisterPersistentFile
+/// \~english @par Brief
+/// APIs that send messages to notification services and register Persistent file tags
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pTag
+/// PCSTR - Tag name
+/// \~english @param [in] bIsUserFile
+/// BOOL - User specified (TRUE: user-specific/FALSE: all users) (Default:FALSE)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue information handle specified in the argument (hApp) is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is an empty character, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sends messages to the notification service (NS_NPPService) and registers Persistent file tags.\n
+/// Tag name is 64 bytes or less. If the tag name exceeds 64 bytes, the tag name is truncated to 64 bytes or less. Therefore, specify a tag name of 64 bytes or less.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget
+/// \~english @see FrameworkunifiedNPLoadPersistentFile, FrameworkunifiedNPReleasePersistentFile
+///
+/// API to send message to Notification Service to add a file path as to be persisted
+///
+/// \param [in] pTag
+/// PCSTR - A unique identifier for the file path specified,
+/// this is used in retrieve/Load the file later
+///
+/// \param [in] bIsUserFile
+/// BOOL - set TRUE if want to register a file for user.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPLoadPersistentFile, FrameworkunifiedNPReleasePersistentFile
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFile(HANDLE hApp, PCSTR pTag, BOOL bIsUserFile = FALSE);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetFilePersistentType
+/// API to send message to Notification Service to set persistent file category.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pTag
+/// PCSTR - File tag
+/// \param [in] ePersistCategory
+/// EFrameworkunifiedPersistCategory - Persistent category
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetFilePersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPLoadPersistentFile
+/// \~english @par Brief
+/// APIs that send messages to notification services and request Load of Persistent file tags
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pDstFilePath
+/// PCSTR - Address of arbitrary data
+/// \~english @param [in] pTag
+/// PCSTR - Tag name
+/// \~english @param [in] hUser
+/// BOOL - Parameter error(Default:NULL)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue information handle specified in the argument (hApp) is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the Load destination file path (pDstFilePath) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the Load destination filepath (pDstFilePath) specified in the parameter is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is an empty character, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sends messages to the notification service (NS_NPPService) and requests the Load of Persistent file tags.\n
+/// The copy destination file path is 255 bytes or less, and any file that exceeds 255 bytes is truncated to 255 bytes. Therefore, specify a file path of 255 bytes or less.\n
+/// Tag name is 64 bytes or less. If the tag name exceeds 64 bytes, the tag name is truncated to 64 bytes or less. Therefore, specify a tag name of 64 bytes or less.\n
+///
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method(Async)
+/// \~english @see FrameworkunifiedNPRegisterPersistentFile, FrameworkunifiedNPReleasePersistentFile
+///
+/// API to send message to Notification Service to copy file from persistent memory to
+/// specified path. The caller recieves an acknowledgement once NPS completes file copy
+///
+/// \param [in] pDstFilePath
+/// PCSTR - Complete file path to which the file should be copied from persistent area
+/// \param [in] pTag
+/// PCSTR - Tag associated with the file that needs to be copied to pDstFilePath
+/// \param [in] hUser
+/// HANDLE - Handle for the user
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPRegisterPersistentFile, FrameworkunifiedNPReleasePersistentFile
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFile(HANDLE hApp, PCSTR pDstFilePath, PCSTR pTag, HANDLE hUser = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPReleasePersistentFile
+/// \~english @par Brief
+/// API to send message to Notification Service to notify that the file can be persisted.
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \~english @param [in] bIsPersist
+/// BOOL - If the specified file needs to be persisted or not on release
+/// \~english @param [in] pTag
+/// PCSTR - Tag associated with the file released
+/// \~english @param [in] pFullFilePath
+/// PCSTR - Full path name of the file to be persisted
+/// \~english @param [in] hUser
+/// HANDLE - Handle for the user
+/// \~english @return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue information handle specified in the argument (hApp) is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the Release destination file path (pFullFilePath) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the Release destination filepath (pFullFilePath) specified in the parameter is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is an empty character, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sends messages to the notification service (NS_NPPService) and requests the Load of Persistent file tags.\n
+/// The copy destination file path is 255 bytes or less, and any file that exceeds 255 bytes is truncated to 255 bytes. Therefore, specify a file path of 255 bytes or less.\n
+/// Tag name is 64 bytes or less. If the tag name exceeds 64 bytes, the tag name is truncated to 64 bytes or less. Therefore, specify a tag name of 64 bytes or less.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedNPRegisterPersistentFile, FrameworkunifiedNPLoadPersistentFile
+///
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, BOOL bIsPersist, PCSTR pTag, PCSTR pFullFilePath,
+ HANDLE hUser = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPReleasePersistentFile
+/// \~english @par Brief
+/// API to send message to Notification Service to notify that the file can be persisted.
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \~english @param [in] eReleaseType
+/// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease :not on release
+/// eFrameworkunifiedPersistOnShutdown:persist on shutdown
+/// eFrameworkunifiedPersistInstantly :persist instantly
+/// \~english @param [in] pTag
+/// PCSTR - Tag associated with the file released
+/// \~english @param [in] pFullFilePath
+/// PCSTR - Full path name of the file to be persisted
+/// \~english @param [in] hUser
+/// HANDLE - Handle for the user
+/// \~english @return status
+/// EFrameworkunifiedStatus - success or error
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue information handle specified in the argument (hApp) is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the Load destination file path (pDstFilePath) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the Load destination filepath (pDstFilePath) specified in the parameter is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the tag name (pTag) specified in the arguments is an empty character, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sends messages to the notification service (NS_NPPService) and requests the Load of Persistent file tags.\n
+/// The copy destination file path is 255 bytes or less, and any file that exceeds 255 bytes is truncated to 255 bytes. Therefore, specify a file path of 255 bytes or less.\n
+/// Tag name is 64 bytes or less. If the tag name exceeds 64 bytes, the tag name is truncated to 64 bytes or less. Therefore, specify a tag name of 64 bytes or less.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedNPRegisterPersistentFile, FrameworkunifiedNPLoadPersistentFile
+///
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag, PCSTR pFullFilePath,
+ HANDLE hUser = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPRegisterPersistentFolder
+/// API to send message to Notification Service to add a folder path to be persisted
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pTag
+/// PCSTR - A unique identifier for the folder path specified,
+/// this is used in retrieve/Load the folder later
+///
+/// \param [in] bIsUserFolder
+/// BOOL - set TRUE if want to register a folder for user.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPLoadPersistentFolder, FrameworkunifiedNPReleasePersistentFolder
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFolder(HANDLE hApp, PCSTR pTag, BOOL bIsUserFolder = FALSE);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetFolderPersistentType
+/// API to send message to Notification Service to set persistent folder category.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pTag
+/// PCSTR - A unique identifier for the folder path specified,
+/// this is used in retrieve/Load the folder later
+/// \param [in] ePersistCategory
+/// EFrameworkunifiedPersistCategory - Persistent category
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetFolderPersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPLoadPersistentFolder
+/// API to send message to Notification Service to copy folder from persistent memory to
+/// specified path. The caller recieves an acknowledgement once NPS completes folder copy
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pDstFolderPath
+/// PCSTR - Complete folder path to which the folder should be copied from persistent area
+/// \param [in] pTag
+/// PCSTR - Tag associated with the folder that needs to be copied to pDstFolderPath
+/// \param [in] hUser
+/// HANDLE - Handle for the user
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPRegisterPersistentFolder, FrameworkunifiedNPReleasePersistentFolder
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFolder(HANDLE hApp, PCSTR pDstFolderPath, PCSTR pTag, HANDLE hUser = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReleasePersistentFolder
+/// API to send message to Notification Service to notify that the folder can be persisted.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] bIsPersist
+/// BOOL - If the specified folder needs to be persisted or not on release
+/// \param [in] pTag
+/// PCSTR - Tag associated with the folder released
+/// \param [in] pFullFolderPath
+/// PCSTR - Full path name of the folder to be persisted
+/// \param [in] hUser
+/// HANDLE - Handle for the user
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPRegisterPersistentFolder, FrameworkunifiedNPLoadPersistentFolder
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, BOOL bIsPersist, PCSTR pTag, PCSTR pFullFolderPath,
+ HANDLE hUser = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPReleasePersistentFolder
+/// API to send message to Notification Service to notify that the folder can be persisted.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] eFrameworkunifiedReleaseType
+/// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease :not on release
+/// eFrameworkunifiedPersistOnShutdown:persist on shutdown
+/// eFrameworkunifiedPersistInstantly :persist instantly
+/// \param [in] pTag
+/// PCSTR - Tag associated with the folder released
+/// \param [in] pFullFolderPath
+/// PCSTR - Full path name of the folder to be persisted
+/// \param [in] hUser
+/// HANDLE - Handle for the user
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPRegisterPersistentFolder, FrameworkunifiedNPLoadPersistentFolder
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType, PCSTR pTag,
+ PCSTR pFullFolderPath, HANDLE hUser = NULL);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// Session APIs
+////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOpenSession
+/// \~english @par Brief
+/// API sends a message to the service requesting a session.
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService HANDLE acquired in)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (Service) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hService) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Message queue type of HANDLE specified in the argument (hService) is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the service session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) during the transmission of the session message to the service
+/// occurs. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the service. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for the session message to be sent to service failed. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// To send a message of the session request to the service.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedGetOpenSessionHandle, FrameworkunifiedOpenSessionWithData, FrameworkunifiedCloseSession, FrameworkunifiedGenerateNewSessionId,
+/// FrameworkunifiedGetSessionId
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSession(HANDLE hService);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOpenSessionWithData
+/// \~english @par Brief
+/// API to send to service the message of the session request together with the data.
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService HANDLE acquired in)
+/// \~english @param [in] pData
+/// PVOID - Pointer to the session data for transmission
+/// \~english @param [in] length
+/// UI_32 - Size of the session data for transmission
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - A pointer to the session data for transmission to the specified non-zero size at NULL in argument.
+/// [eFrameworkunifiedStatusInvldBuf]
+/// - The pointer is NULL to the session data for transmission specified in the argument. [eFrameworkunifiedStatusErrOther]
+/// - Size of the session data for transmission specified in the argument is 0. [eFrameworkunifiedStatusErrOther]
+/// - HANDLE specified in the argument (Service) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hService) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Message queue type of HANDLE specified in the argument (hService) is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the service session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) during the transmission of the session message to the service
+/// occurs. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the service. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for the session message to be sent to service failed. [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// To send to the service a message of session request together with the data.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSession, FrameworkunifiedGetOpenSessionHandle, FrameworkunifiedCloseSession, FrameworkunifiedGenerateNewSessionId,
+/// FrameworkunifiedGetSessionId
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSessionWithData(HANDLE hService, PVOID pData, UI_32 length);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOpenSessionSync
+/// \~english @par Brief
+/// Synchronous API of sending a message of the session request to the service.
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService/FrameworkunifiedGetOpenSessionHandle/FrameworkunifiedGetOpenSessionSyncHandle HANDLE
+/// acquired in)
+/// \~english @param [out] ack
+/// OpenSessionAck - Pointer to the response data of the session initiation
+/// \~english @par
+/// OpenSessionAck Structure
+/// \~english @code
+/// #define MAX_QUEUE_NAME_SIZE 20
+/// typedef struct _OpenSessionAck
+/// {
+/// EFrameworkunifiedStatus eStatus; /* Status */
+/// UI_32 sessionId; /* Session ID */
+/// CHAR cSessionName[MAX_QUEUE_NAME_SIZE]; /* Session Name(20byte) */
+/// UI_32 sessionType; /* Session Type */
+/// }OpenSessionAck;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusBadConnection It can not be a socket connection
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (Service) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hService) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - It failed to open the message queue for the response received [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - It fails to get the message storage buffer for the response received. [eFrameworkunifiedStatusFail]
+/// - Random number generation to fail for the sequence ID of the message for transmission. [eFrameworkunifiedStatusFail]
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Message queue type of HANDLE specified in the argument (hService) is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the service session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmit and receive file descriptor of the session message to the service.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) occurs during the transmission and reception of the session message
+/// to the service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the sending and receiving of a session message to the service. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for the session message to be sent to service failed. [eFrameworkunifiedStatusErrOther]
+/// - It failed to Socket connection of the response message for the reception from the service. [eFrameworkunifiedStatusFail]
+/// - The wait control of the response message received from the service failed. [eFrameworkunifiedStatusFail]
+/// - Interruption by the system call (signal) to wait in the response message received from the service has
+/// occurred. [eFrameworkunifiedStatusFail]
+/// - In response message at the time of failure to receive from the service, it failed to re-connection of the
+/// Socket. [eFrameworkunifiedStatusBadConnection]
+/// \~english @par Detail
+/// Send in the synchronous type the message of the session request to the service.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSessionWithDataSync, FrameworkunifiedGetOpenSessionSyncHandle, FrameworkunifiedCloseSessionSync,
+/// FrameworkunifiedGenerateNewSessionId,
+/// FrameworkunifiedGetSessionId
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSessionSync(HANDLE hService, OpenSessionAck *ack);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedOpenSessionWithDataSync
+/// \~english @par Brief
+/// Synchronous API that transmits to the service a message session request with the data.
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService/FrameworkunifiedGetOpenSessionHandle/FrameworkunifiedGetOpenSessionSyncHandle HANDLE
+/// acquired in)
+/// \~english @param [in] pData
+/// PVOID - Pointer to session data for transmission
+/// \~english @param [in] length
+/// UI_32 - Size of the session data for transmission
+/// \~english @param [out] ack
+/// OpenSessionAck - Pointer to the response data of the session initiation
+/// \~english @par
+/// OpenSessionAck Structure
+/// \~english @code
+/// #define MAX_QUEUE_NAME_SIZE 20
+/// typedef struct _OpenSessionAck
+/// {
+/// EFrameworkunifiedStatus eStatus; /* Status */
+/// UI_32 sessionId; /* Session ID */
+/// CHAR cSessionName[MAX_QUEUE_NAME_SIZE]; /* Session Name(20byte) */
+/// UI_32 sessionType; /* Session Type */
+/// }OpenSessionAck;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid Buffer
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusBadConnection It can not be a socket connection
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - A pointer to the session data for transmission to the specified non-zero size at NULL in argument.
+/// [eFrameworkunifiedStatusInvldBuf]
+/// - The pointer is NULL to the session data for transmission specified in the argument. [eFrameworkunifiedStatusErrOther]
+/// - Size of the session data for transmission specified in the argument is 0. [eFrameworkunifiedStatusErrOther]
+/// - HANDLE specified in the argument (Service) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - It failed to open the message queue for the response received [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hApp) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - It fails to get the message storage buffer for the response received. [eFrameworkunifiedStatusFail]
+/// - Random number generation to fail for the sequence ID of the message for transmission. [eFrameworkunifiedStatusFail]
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Message queue type of HANDLE specified in the argument (hService) is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the service session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmit and receive file descriptor of the session message to the service.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) occurs during the transmission and reception of the session message
+/// to the service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the sending and receiving of a session message to the service. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for transmission and reception of the service for the message for the session
+/// failed. [eFrameworkunifiedStatusErrOther]
+/// - It failed to Socket connection of the response message for the reception from the service. [eFrameworkunifiedStatusFail]
+/// - The wait control of the response message received from the service failed. [eFrameworkunifiedStatusFail]
+/// - Interruption by the system call (signal) to wait in the response message received from the service has
+/// occurred. [eFrameworkunifiedStatusFail]
+/// - In response message at the time of failure to receive from the service, it failed to re-connection of the
+/// Socket. [eFrameworkunifiedStatusBadConnection]
+/// \~english @par Detail
+/// Send in the synchronous type to service the message of the session request along with the data.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSessionSync, FrameworkunifiedGetOpenSessionSyncHandle, FrameworkunifiedCloseSessionSync, FrameworkunifiedGenerateNewSessionId,
+/// FrameworkunifiedGetSessionId
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOpenSessionWithDataSync(HANDLE hService, PVOID pData, UI_32 length, OpenSessionAck *ack);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetOpenSessionHandle
+/// \~english @par Brief
+/// Asynchronous API to get the session handler.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application (FrameworkunifiedCreateDispatcherWithoutLoop() HANDLE acquired in)
+/// \~english @retval HANDLE HANDLE for the session
+/// \~english @retval NULL Failure to HANDLE acquisition for the session
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// Under the following conditions, HANDLE is returned as NULL.
+/// - HANDLE specified in the argument (hApp) is NULL.
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid).
+/// - Data size received by the HANDLE specified in the argument (hApp) is not the data size of
+/// ProtocolOpenSessionAck message.
+/// - Can not get the data and the data length received by the HANDLE specified in the argument (hApp).
+/// - Size of the session name of the data received by the specified HANDLE (hApp) in the argument is more than
+/// 20byte.
+/// - Not be able to acquire the memory of the buffer for the internal processing.
+/// - Session name is NULL of data received by the HANDLE specified in the argument (hApp).
+/// - It failed to generate the message queue name.
+/// - It failed to open the message queue.
+/// \~english @par Detail
+/// This API will be used in an asynchronous type specification. \n
+/// Acquires received data ProtocolOpenSessionAck from HANDLE specified in the argument (hApp), \n
+/// obtains the session HANDLE from the session name.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSession, FrameworkunifiedOpenSessionWithData, FrameworkunifiedCloseSession, FrameworkunifiedGenerateNewSessionId,
+/// FrameworkunifiedGetSessionId
+////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetOpenSessionHandle(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetOpenSessionSyncHandle
+/// \~english @par Brief
+/// API to get the session ID without using the received data of ProtocolOpenSessionAck.
+/// \~english @param [in] hApp
+/// HANDLE - HANDLE for Application (FrameworkunifiedCreateDispatcherWithoutLoop() HANDLE acquired in)
+/// \~english @param [in] tAck
+/// OpenSessionAck - Pointer to the OpenSessionAck structure
+/// \~english @par
+/// OpenSessionAck Structure
+/// \~english @code
+/// #define MAX_QUEUE_NAME_SIZE 20
+/// typedef struct _OpenSessionAck
+/// {
+/// EFrameworkunifiedStatus eStatus; /* Status */
+/// UI_32 sessionId; /* Session ID */
+/// CHAR cSessionName[MAX_QUEUE_NAME_SIZE]; /* Session Name(20byte) */
+/// UI_32 sessionType; /* Session Type */
+/// }OpenSessionAck;
+/// @endcode
+/// \~english @retval HANDLE HANDLE for the session
+/// \~english @retval NULL Failure to HANDLE acquisition for the session
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// Under the following conditions, HANDLE is returned as NULL.
+/// - HANDLE specified in the argument (hApp) is NULL.
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid).
+/// - Data size received by the HANDLE specified in the argument (hApp) is not the data size of
+/// ProtocolOpenSessionAck message.
+/// - Size of the session name of the data received by the specified HANDLE (hApp) in the argument is more than
+/// 20byte.
+/// - Not be able to acquire the memory of the buffer for the internal processing.
+/// - Session name is NULL of data received by the HANDLE specified in the argument (hApp).
+/// - It failed to generate the message queue name.
+/// - It failed to open the message queue.
+/// \~english @par Detail
+/// This API is to be used at the time of the synchronous type specification. \n
+/// Use the session name of OpenSessionAck structure specified by the argument, to get the session HANDLE.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSessionSync, FrameworkunifiedOpenSessionWithDataSync, FrameworkunifiedCloseSessionSync, FrameworkunifiedGenerateNewSessionId,
+/// FrameworkunifiedGetSessionId
+////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetOpenSessionSyncHandle(HANDLE hApp, OpenSessionAck *tAck);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGenerateSessionHandle
+/// API will be called by server on receiving the Open session request to Create session
+///
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the framework application
+/// \param [in] pServiceName
+/// PCSTR - Service Name
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+///
+/// \see FrameworkunifiedOpenSession, FrameworkunifiedCloseSession, FrameworkunifiedGenerateNewSessionId
+/// FrameworkunifiedGetSessionId
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGenerateSessionHandle(HANDLE hApp, PCSTR pServiceName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCloseSession
+/// \~english @par Brief
+/// API to close the session.
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService HANDLE acquired in)
+/// \~english @param [in] hSession
+/// HANDLE - Handle to the session(FrameworkunifiedOpenSession HANDLE acquired in)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hService) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hSession) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hSession) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Message queue type of HANDLE specified in the argument (hService) is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the service session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) during the transmission of the session message to the service
+/// occurs. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the service. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for the session message to be sent to service failed. [eFrameworkunifiedStatusErrOther]
+/// - Message queue type of HANDLE specified in the argument (hSession) is mismatch.(eQTypeSender or
+/// eQTypeReveiver) [eFrameworkunifiedStatusInvldHndlType]
+/// - Failed to close message queue HANDLE specified in the argument (hSession). [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Send a message of the session close request to the service.\n
+/// And close message queue of the session.
+/// This is asynchronous API.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSession, FrameworkunifiedOpenSessionWithData, FrameworkunifiedGetOpenSessionHandle
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseSession(HANDLE hService, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCloseSessionSync
+/// \~english @par Brief
+/// API to close the session (synchronous).
+/// \~english @param [in] hService
+/// HANDLE - Handle to the service(FrameworkunifiedOpenService HANDLE acquired in)
+/// \~english @param [in] hSession
+/// HANDLE - Handle to the session(FrameworkunifiedOpenSessionSync HANDLE acquired in)
+/// \~english @param [out] ack
+/// CloseSessionAck - Pointer to the response data of the session close
+/// \~english @par
+/// CloseSessionAck Structure
+/// \~english @code
+/// typedef struct _CloseSessionAck
+/// {
+/// UI_32 sessionId; /* Session ID */
+/// EFrameworkunifiedStatus eStatus; /* Status */
+/// }CloseSessionAck;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusBadConnection It can not be a socket connection
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusOK [eStatus in CloseSessionAck]Success in serivice side.
+/// \~english @retval eFrameworkunifiedStatusFail [eStatus in CloseSessionAck]Some sort of error occurred in service side.
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure (API)
+/// - CloseSessionAck specified in the argument (ack) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (Service) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hService) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hSession) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - HANDLE specified in the argument (hSession) is not appropriate (which is invalid). [eFrameworkunifiedStatusNullPointer]
+/// - It failed to open the message queue for the response received [eFrameworkunifiedStatusFail]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - It fails to get the message storage buffer for the response received. [eFrameworkunifiedStatusFail]
+/// - Random number generation to fail for the sequence ID of the message for transmission. [eFrameworkunifiedStatusFail]
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Message queue HANDLE name in the HANDLE specified in the argument (hService) exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Message queue type of HANDLE specified in the argument (hService) is not a transmission type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - To the service session message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmit and receive file descriptor of the session message to the service.
+/// [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) occurs during the transmission and reception of the session message
+/// to the service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of the transmit buffer of the message for the session to the service is illegal.
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the sending and receiving of a session message to the service. [eFrameworkunifiedStatusFail]
+/// - In the shared memory access for the session message to be sent to service failed. [eFrameworkunifiedStatusErrOther]
+/// - It failed to Socket connection of the response message for the reception from the service. [eFrameworkunifiedStatusFail]
+/// - The wait control of the response message received from the service failed. [eFrameworkunifiedStatusFail]
+/// - Interruption by the system call (signal) to wait in the response message received from the service has
+/// occurred. [eFrameworkunifiedStatusFail]
+/// - In response message at the time of failure to receive from the service, it failed to re-connection of the
+/// Socket. [eFrameworkunifiedStatusBadConnection]
+/// - Failed to close message queue HANDLE specified in the argument (hSession). [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue type of HANDLE specified in the argument (hSession) is mismatch.(eQTypeSender or
+/// eQTypeReveiver) [eFrameworkunifiedStatusInvldHndlType]
+/// \~english @par Conditions of processing failure (eStatus in CloseSessionAck)
+/// - Any errors occur during in service side. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Send a message synchronously of the session close request to the service.\n
+/// And close message queue of the session.\n
+/// The eStatus value in CloseSessionAck is dependent on service. So we indecates major return value.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSessionSync, FrameworkunifiedOpenSessionWithDataSync
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCloseSessionSync(HANDLE hService, HANDLE hSession, CloseSessionAck *ack);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGenerateNewSessionId
+/// Used on the Server side to get the next session id
+///
+///
+/// \return sessionID
+/// UI_32 - session ID value
+///
+///
+/// \see FrameworkunifiedOpenSession, FrameworkunifiedGetOpenSessionHandle, FrameworkunifiedCloseSession,
+/// FrameworkunifiedGetSessionId
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGenerateNewSessionId();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetSessionId
+/// \~english @par Brief
+/// Returns the session id corresponding to the given session handle.
+/// \~english @param [in] hSession
+/// HANDLE - Handle to the session(FrameworkunifiedMcOpenSender HANDLE acquired in)
+/// \~english @retval UI_32 session ID value
+/// \~english @retval MAX_SESSION_ID_VAL Failed to get session ID value
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hSession) is NULL. [MAX_SESSION_ID_VAL]
+/// - HANDLE specified in the argument (hSession) is not appropriate (which is invalid). [MAX_SESSION_ID_VAL]
+/// \~english @par Detail
+/// Returns the session id corresponding to the given session handle.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedOpenSession, FrameworkunifiedOpenSessionSync, FrameworkunifiedOpenSessionWithData, FrameworkunifiedOpenSessionWithDataSync, \n
+/// FrameworkunifiedGetOpenSessionHandle, FrameworkunifiedGetOpenSessionSyncHandle, FrameworkunifiedGetCurrentSessionHandle, \n
+/// FrameworkunifiedMcOpenSender, FrameworkunifiedCreateSession
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetSessionId(HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetMsgSessionId
+/// \~english @par Brief
+/// Get session ID from received message.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval UI_32 session ID value
+/// \~english @retval MAX_SESSION_ID_VAL Failed to get session ID value
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been
+/// done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [MAX_SESSION_ID_VAL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [MAX_SESSION_ID_VAL]
+/// \~english @par Detail
+/// Get session ID from received message.\n
+/// Mostly, this API is used to get session ID from message received by callback function that is registered to
+/// Dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedGetSessionHandle
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetMsgSessionId(HANDLE hApp);
+
+
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// Defer Message APIs
+////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetDeferQueueCnt
+/// Get the number of messages in the defer queue
+///
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the App / Thread
+///
+/// \return count
+/// UI_32 - number of messages on Defered Queue
+///
+///
+/// \see FrameworkunifiedDeferMessage, FrameworkunifiedRetrieveDeferMessage
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetDeferQueueCnt(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedIsDeferQueueEmpty
+/// \~english @par Brief
+/// Empty determination of DeferQueue
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval BOOL DeferQueue status (TRUE: empty or FALSE: not empty)
+/// \~english @retval TRUE Judgment failure
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [TRUE]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [TRUE]
+/// \~english @par Detail
+/// Returns whether the DeferQueue in the application-handle given by the arguments is empty
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Not applicable
+/// \~english @see FrameworkunifiedDeferMessage, FrameworkunifiedRetrieveDeferMessage
+/// FrameworkunifiedIsDeferQueueEmpty
+/// Get the number of messages in the defer queue
+///
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the App / Thread
+///
+/// \return count
+/// BOOL - Indicates if the defer queue is empty, TRUE (empty), FALSE (not empty)
+///
+///
+/// \see FrameworkunifiedDeferMessage, FrameworkunifiedRetrieveDeferMessage, FrameworkunifiedGetDeferQueueCnt
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsDeferQueueEmpty(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDeferMessage
+/// \~english @par Brief
+/// Push messages to the DeferQueue
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Push received messages in the application handles specified by the arguments to the DeferQueue.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Set Get
+/// \~english @see FrameworkunifiedRetrieveDeferMessage
+/// FrameworkunifiedDeferMessage
+/// Defers the current message; Pushes the message on to a defer msg queue
+///
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the App / Thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+///
+/// \see FrameworkunifiedClearDeferMessages, FrameworkunifiedRetrieveDeferMessage
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDeferMessage(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedClearDeferMessages
+/// Clear all the defer messages
+///
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the App / Thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+///
+/// \see FrameworkunifiedDeferMessage, FrameworkunifiedRetrieveDeferMessage
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedClearDeferMessages(HANDLE hApp);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedRetrieveDeferMessage
+/// \~english @par Brief
+/// Write Messages Registered in DeferQueue to FD
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Write the messages registered in the DeferQueue in the application handler specified by arguments to the FD.\n
+/// This allows the main loop to receive the message.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Set Get
+/// \~english @see FrameworkunifiedDeferMessage
+/// FrameworkunifiedRetrieveDeferMessage
+/// Enables Checking for deferred message and retrieves messages when
+/// callback returns to the dispatcher.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the App / Thread
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+///
+/// \see FrameworkunifiedDeferMessage, FrameworkunifiedClearDeferMessages
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRetrieveDeferMessage(HANDLE hApp);
+
+// TODO(framework_unified) : clean up the old FrameworkunifiedRegisterPersistentStorage api's
+// 20110429_brp
+// defined for backward compatibility; will be removed once the persistence feature is finalized
+EFrameworkunifiedStatus FrameworkunifiedRegisterPersistentStorage(HANDLE hApp, PCSTR pFullFilePath);
+EFrameworkunifiedStatus FrameworkunifiedReleaseFileToPersistentStorage(HANDLE hApp, PCSTR pFullFilePath, BOOL persist);
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedRegisterEvent
+/// \~english @par Brief
+/// Registering Applications for Delivery of Service-Specific Events
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @param [in] uiEventId
+/// UI_32 - Event ID (Identification ID on the service's protocol)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sessions for services is full [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptor for sending messages for sessions intended for the service [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending session-specific messages for services [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of send buffers for sessions intended for services [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for the services [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Issues a request for registering the application that executes this API to the delivery target of the device-specific events of the service associated with the handle (hSession) specified in the arguments.\n
+/// The application specifies the type of events to receive in the uiEventId of arguments.\n
+/// (The event ID of this API refers to the identification ID on the protocol of the service, and the application identifies the content of the message. The specifiable service-specific events are events set by the service, such as the FrameworkunifiedDefinePublicStateEvents.)
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - This API is deprecated and should now use FrameworkunifiedSubscribeToSessionEventWithCallback.
+/// - When this API is used, the application shall use a FrameworkunifiedAttachCallbackToDispatcher or the like to register callback functions in its own Dispatcher for handling events.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents,
+/// FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedAttachCallbackToDispatcherWithFd,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedDefineStateEvents, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents
+///
+/// API to register for event of a service.
+/// This API is depricated, use FrameworkunifiedSubscribeToSessionEventWithCallback.
+///
+/// \param [in] hSession
+/// HANDLE - Handle to the application session
+/// \param [in] uiEventId
+/// UI_32 - Event registering for.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents, FrameworkunifiedBroadcastEvent, FrameworkunifiedDefineStateEvents,
+/// FrameworkunifiedPublishEvent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRegisterEvent(HANDLE hSession, UI_32 uiEventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedRegisterEvents
+/// \~english @par Brief
+/// Registering Applications for Delivery of Service-Specific Events
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @param [in] puiEventsArray
+/// PVOID - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] uiListSize
+/// UI_32 - Number of elements in the event ID array (0 to 4294967295)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the array (puiEventsArray) of event IDs specified by arguments is NULL, [eFrameworkunifiedStatusInvldBuf]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sessions for services is full [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptor for sending messages for sessions intended for the service [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending session-specific messages for services [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of send buffers for sessions intended for services [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for the services [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages for sessions for services [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Issues a request for registering the application that executes this API to the delivery target of the device-specific events of the service associated with the handle (hSession) specified in the arguments.\n
+/// The application specifies more than one type of events to receive in the puiEventsArray of arguments.\n
+/// (The event ID of this API refers to the identification ID on the protocol of the service, and the application identifies the content of the message. The specifiable service-specific events are events set by the service, such as the FrameworkunifiedDefinePublicStateEvents.)
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - This API is deprecated and should now use FrameworkunifiedSubscribeToSessionEventsWithCallbacks.
+/// - When this API is used, the application shall use a FrameworkunifiedAttachCallbackToDispatcher or the like to register callback functions in its own Dispatcher for handling events.
+/// - The maximum number of event IDs that can be registered depends on the size that can be allocated as the area for the event ID array.\n
+/// Therefore, the API caller should consider the size of the event ID array and define the number of event IDs (uiListSize).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedRegisterEvent, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents,
+/// FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedAttachCallbackToDispatcherWithFd,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedDefineStateEvents, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents
+///
+/// API to register for events of a service.
+/// This API is depricated, use FrameworkunifiedSubscribeToSessionEventsWithCallbacks.
+///
+/// \param [in] hSession
+/// HANDLE - Handle to the application session
+/// \param [in] puiEventsArray
+/// PVOID - Array of events registering for.
+/// \param [in] uiListSize
+/// UI_32 - count of elements in array.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedRegisterEvent, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents, FrameworkunifiedBroadcastEvent, FrameworkunifiedDefineStateEvents,
+/// FrameworkunifiedPublishEvent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRegisterEvents(HANDLE hSession, PVOID puiEventsArray, UI_32 uiListSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnRegisterEvent
+/// \~english @par Brief
+/// Unregistering Service-Specific Events from Delivery
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @param [in] uiEventId
+/// UI_32 - Event ID (Identification ID on the service's protocol)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sessions for services is full [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptor for sending messages for sessions intended for the service [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending session-specific messages for services [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of send buffers for sessions intended for services [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for the services [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Issues a request to unregister the application that executed this API from the delivery target of the service-specific event associated with the handle (hSession) specified in the arguments.\n
+/// The application specifies events that are no longer needed for delivery in the uiEventId of arguments.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - This API is deprecated and should now use FrameworkunifiedUnSubscribeSessionEventWithCallback.
+/// - When this API is used, the application shall unregister callbacks for events registered in its own Dispatcher by means of FrameworkunifiedDetachCallbackFromDispatcher, etc.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedRegisterEvent, FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvents,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcherWithFd, FrameworkunifiedDetachCallbacksFromDispatcherWithFd,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks,
+/// FrameworkunifiedDefineStateEvents, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents
+///
+/// API to unregister from event of a service.
+/// This API is depricated, use FrameworkunifiedUnSubscribeSessionEventsWithCallbacks.
+///
+/// \param [in] hSession
+/// HANDLE - Handle to the application session
+/// \param [in] uiEventId
+/// UI_32 - Event registering for.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedUnRegisterEvents, FrameworkunifiedRegisterEvent, FrameworkunifiedBroadcastEvent, FrameworkunifiedDefineStateEvents, FrameworkunifiedPublishEvent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnRegisterEvent(HANDLE hSession, UI_32 uiEventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnRegisterEvents
+/// \~english @par Brief
+/// Unregistering Service-Specific Events from Delivery
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @param [in] puiEventsArray
+/// PVOID - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] uiListSize
+/// UI_32 - Number of elements in the event ID array (0 to 4294967295)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the array (puiEventsArray) of event IDs specified by arguments is NULL, [eFrameworkunifiedStatusInvldBuf]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sessions for services is full [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptor for sending messages for sessions intended for the service [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending session-specific messages for services [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of send buffers for sessions intended for services [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for the services [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages for sessions for services [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Issues a request to unregister the application that executed this API from the delivery target of the service-specific event associated with the handle (hSession) specified in the arguments.\n
+/// The application specifies the unneeded events in the puiEventsArray of arguments.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - This API is deprecated and should now use FrameworkunifiedUnSubscribeSessionEventsWithCallbacks.
+/// - After executing this API, the callback of the event registered in the Dispatcher of the application itself must be unregistered by FrameworkunifiedDetachCallbackFromDispatcher, etc.
+/// - The maximum number of event IDs that can be registered depends on the size that can be allocated as the area for the event ID array.\n
+/// Therefore, the API caller should consider the size of the event ID array and define the number of event IDs (uiListSize).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedRegisterEvent, FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvent,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcherWithFd, FrameworkunifiedDetachCallbacksFromDispatcherWithFd,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks,
+/// FrameworkunifiedDefineStateEvents, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents
+///
+/// API to unregister from events of a service.
+/// This API is depricated, use FrameworkunifiedUnSubscribeSessionEventsWithCallbacks.
+///
+/// \param [in] hSession
+/// HANDLE - Handle to the application session
+/// \param [in] puiEventsArray
+/// PVOID - Array of events registering for.
+/// \param [in] uiListSize
+/// UI_32 - count of elements in array.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedUnRegisterEvent, FrameworkunifiedRegisterEvent, FrameworkunifiedBroadcastEvent, FrameworkunifiedDefineStateEvents, FrameworkunifiedPublishEvent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnRegisterEvents(HANDLE hSession, PVOID puiEventsArray, UI_32 uiListSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDefineStateEvents
+/// \~english @par Brief
+/// Subscribing to Application-Specific Events in the Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] puiEvents
+/// PVOID - Pointer to an array (UI_32 arrays) of event IDs (identification IDs on the service protocol)
+/// \~english @param [in] uiListSize
+/// UI_32 - Number of elements in the event ID array (0 to 4294967295)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the array (puiEvents) of event IDs specified by arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Register unique events in your Dispatcher that applications can deliver to other applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// For application-specific events registered by this API, the event is delivered by Dispatcher when the application executes the FrameworkunifiedPublishPublicEvent.\n
+/// Events are distributed to applications registered by FrameworkunifiedSubscribeToSessionEventsWithCallbacks, etc.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - This API is deprecated, use FrameworkunifiedDefinePublicStateEvents or FrameworkunifiedDefinePrivateStateEvents now.
+/// - The maximum number of event IDs that can be registered depends on the size that can be allocated as the area for the event ID array.\n
+/// Therefore, the API caller should consider the size of the event ID array and define the number of event IDs (uiListSize).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents,
+/// FrameworkunifiedPublishEvent, FrameworkunifiedBroadcastEvent, FrameworkunifiedPublishPublicEvent, FrameworkunifiedPublishPrivateEvent
+/// FrameworkunifiedRegisterEvent, FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks,
+///
+/// API to define the state events of the service.
+/// This API is depricated, use FrameworkunifiedDefinePublicStateEvents or FrameworkunifiedDefinePrivateStateEvents.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] puiEvents
+/// PVOID - Array of state events or single state event.
+/// \param [in] uiListSize
+/// UI_32 - size of events list.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedRegisterEvent, FrameworkunifiedBroadcastEvent, FrameworkunifiedPublishEvent, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDefineStateEvents(HANDLE hApp, PVOID puiEvents, UI_32 uiListSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedPublishEvent
+/// \~english @par Brief
+/// Deliver application-specific events
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] uiEventId
+/// UI_32 - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] pClientName
+/// PCSTR - Destination application name (distributed to all registered applications when NULL is specified),
+/// \~english @param [in] pData
+/// PCVOID - Pointer to trasmission data
+/// \~english @param [in] iLength
+/// UI_32 - Transmission data length
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - The events to be delivered must be specified in a FrameworkunifiedDefinePublicStateEvents, etc.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the application name of the delivery destination in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - Sessioninformation is not found with the application being delivered to within the handles (hApp) specified in the arguments. [eFrameworkunifiedStatusErrOther]
+/// - If the destination handles are inappropriate (disabled) [eFrameworkunifiedStatusErrOther]
+/// - If the message queue handle in the destination handle is NULL [eFrameworkunifiedStatusErrOther]
+/// - If the application name in the destination handles is not set, [eFrameworkunifiedStatusErrOther]
+/// - If the message queue handle in the destination handle is inappropriate (disabled) [eFrameworkunifiedStatusErrOther]
+/// - When the send data length (iLength) specified in the arguments is not 0 and the pointer to the send data pointer (pData) is NULL, [eFrameworkunifiedStatusErrOther]
+/// - When the name of the application in the destination handle exceeds 20 bytes [eFrameworkunifiedStatusErrOther]
+/// - When the name of the message queue in the destination handle is NULL, [eFrameworkunifiedStatusErrOther]
+/// - When the name of the message queue in the destination handle exceeds 20 bytes [eFrameworkunifiedStatusErrOther]
+/// - If the message queue type of the destination handler is not the send type [eFrameworkunifiedStatusErrOther]
+/// - When the message queue is full [eFrameworkunifiedStatusErrOther]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrOther]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrOther]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusErrOther]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusErrOther]
+/// - Failed to access shared memory for sending messages [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Delivers application-specific events to subscribed applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// The delivery destination of events is the application specified by the argument pClientName or (when the argument pClientName is NULL)
+/// all the applications registered by FrameworkunifiedSubscribeToSessionEventsWithCallbacks etc.\n
+/// The data (pData) to be distributed is the same for all distribution destinations.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation cannot be guaranteed if the size of the area indicated by the pointer (pData) address to the send data does not match the size specified by the send data length (iLength) address.
+/// \~english @par
+/// This API is deprecated, use FrameworkunifiedPublishPublicEvent or FrameworkunifiedPublishPrivateEvent now.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedDefineStateEvents, FrameworkunifiedDefinePublicStateEvents,
+/// FrameworkunifiedBroadcastEvent, FrameworkunifiedPublishPublicEvent,
+/// FrameworkunifiedRegisterEvent, FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents,
+/// FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedAttachCallbackToDispatcherWithFd,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcherWithFd, FrameworkunifiedDetachCallbacksFromDispatcherWithFd,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used to publish the event to one of the client subscribed to this event.
+/// This API can be used to publish the event to all the clients subscribed to this event by
+/// passing pClientName as NULL.
+/// This API is depricated, use FrameworkunifiedPublishPrivateEvent or FrameworkunifiedPublishPublicEvent.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] uiEventId
+/// UI_32 - Event id of Message
+/// \param [in] pClientName
+/// PCSTR - Name of the client
+/// \param [in] pData
+/// PCVOID - Data buffer
+/// \param [in] iLength
+/// UI_32 - Size of data buffer
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedRegisterEvent, FrameworkunifiedBroadcastEvent, FrameworkunifiedDefineStateEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishEvent(HANDLE hApp, UI_32 uiEventId, PCSTR pClientName, PCVOID pData, UI_32 iLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedBroadcastEvent
+/// \~english @par Brief
+/// Broadcast application-specific events
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] uiEventId
+/// UI_32 - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] pData
+/// PCVOID - Pointer to trasmission data
+/// \~english @param [in] iLength
+/// UI_32 - Transmission data length
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - The events to be delivered must be specified in a FrameworkunifiedDefinePublicStateEvents, etc.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusNullPointer]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusNullPointer]
+/// - When the application name of the delivery destination in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - Sessioninformation is not found with the application being delivered to within the handles (hApp) specified in the arguments. [eFrameworkunifiedStatusErrOther]
+/// - If the destination handles are inappropriate (disabled) [eFrameworkunifiedStatusErrOther]
+/// - If the message queue handle in the destination handle is NULL [eFrameworkunifiedStatusErrOther]
+/// - If the application name in the destination handles is not set, [eFrameworkunifiedStatusErrOther]
+/// - If the message queue handle in the destination handle is inappropriate (disabled) [eFrameworkunifiedStatusErrOther]
+/// - When the send data length (iLength) specified in the arguments is not 0 and the pointer to the send data pointer (pData) is NULL, [eFrameworkunifiedStatusErrOther]
+/// - When the name of the application in the destination handle exceeds 20 bytes [eFrameworkunifiedStatusErrOther]
+/// - When the name of the message queue in the destination handle is NULL, [eFrameworkunifiedStatusErrOther]
+/// - When the name of the message queue in the destination handle exceeds 20 bytes [eFrameworkunifiedStatusErrOther]
+/// - If the message queue type of the destination handler is not the send type [eFrameworkunifiedStatusErrOther]
+/// - When the message queue is full [eFrameworkunifiedStatusErrOther]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrOther]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrOther]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusErrOther]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Broadcast application-specific events to all registered applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// Events are delivered to all applications registered by FrameworkunifiedSubscribeToSessionEventsWithCallbacks, etc.
+/// The data (pData) to be distributed is the same for all distribution destinations.
+/// \~english @par
+/// This API is deprecated and should now use FrameworkunifiedPublishPublicEvent.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedDefineStateEvents, FrameworkunifiedDefinePublicStateEvents,
+/// FrameworkunifiedPublishEvent, FrameworkunifiedPublishPublicEvent,
+/// FrameworkunifiedRegisterEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents,
+/// FrameworkunifiedAttachCallbacksToDispatcher, FrameworkunifiedAttachCallbackToDispatcher,
+/// FrameworkunifiedAttachCallbacksToDispatcherWithFd, FrameworkunifiedAttachCallbackToDispatcherWithFd,
+/// FrameworkunifiedDetachCallbackFromDispatcher, FrameworkunifiedDetachCallbacksFromDispatcher,
+/// FrameworkunifiedDetachCallbackFromDispatcherWithFd, FrameworkunifiedDetachCallbacksFromDispatcherWithFd,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used to publish the event to all the clients subscribed to this event.
+/// This API is depricated, use FrameworkunifiedPublishPublicEvent.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] uiEventId
+/// UI_32 - Event id of Message
+/// \param [in] pData
+/// PCVOID - Data buffer
+/// \param [in] iLength
+/// UI_32 - Size of data buffer
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedRegisterEvent, FrameworkunifiedPublishEvent, FrameworkunifiedDefineStateEvents, FrameworkunifiedUnRegisterEvent, FrameworkunifiedUnRegisterEvents
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedBroadcastEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 iLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDefinePublicStateEvents
+/// \~english @par Brief
+/// Subscribing to Application-Specific Events in the Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] puiEvents
+/// PUI_32 - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] uiListSize
+/// UI_32 - Number of elements in the event ID array (0 to 4294967295)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the array (puiEvents) of event IDs specified by arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Register unique events in your Dispatcher that applications can deliver to other applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// For application-specific events registered by this API, the event is delivered by Dispatcher when the application executes the FrameworkunifiedPublishPublicEvent.\n
+/// Events are distributed to all applications registered by FrameworkunifiedSubscribeToSessionEventsWithCallbacks, etc.
+/// \~english @par
+/// The difference from FrameworkunifiedDefinePrivateStateEvents is that when the Dispatcher distributes events registered by this API, the same data is distributed to all registered applications.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - The maximum number of event IDs that can be registered depends on the size that can be allocated as the area for the event ID array.\n
+/// Therefore, the API caller should consider the size of the event ID array and define the number of event IDs (uiListSize).
+/// - FrameworkunifiedDefinePrivateStateEvents should be used to deliver individual data by registered application sessions.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedPublishPublicEvent, FrameworkunifiedDefinePrivateStateEvents, FrameworkunifiedPublishPrivateEvent,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used to define the public state events of the service.
+/// Public Event means the data associated with the event will be same for all the clients
+/// subscribed to it.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] puiEvents
+/// PUI_32 - Array of state events or single state event.
+/// \param [in] uiListSize
+/// UI_32 - size of events list.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedDefinePrivateStateEvents
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDefinePublicStateEvents(HANDLE hApp, PUI_32 puiEvents, UI_32 uiListSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDefinePrivateStateEvents
+/// \~english @par Brief
+/// Subscribing to Application-Specific Events in the Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] puiEvents
+/// PUI_32 - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] uiListSize
+/// UI_32 - Number of elements in the event ID array (0 to 4294967295)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the array (puiEvents) of event IDs specified by arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Register unique events in your Dispatcher that applications can deliver to other applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// For application-specific events registered by this API, the event is delivered by Dispatcher when the application executes the FrameworkunifiedPublishPrivateEvent.\n
+/// Events are distributed to applications registered by FrameworkunifiedSubscribeToSessionEventsWithCallbacks, etc.
+/// \~english @par
+/// The difference from FrameworkunifiedDefinePublicStateEvents is that when the Dispatcher distributes events registered by this API, it distributes individual data by sessions of the registered application.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - The maximum number of event IDs that can be registered depends on the size that can be allocated as the area for the event ID array.\n
+/// Therefore, the API caller should consider the size of the event ID array and define the number of event IDs (uiListSize).
+/// - Use FrameworkunifiedDefinePublicStateEvents to deliver broadcasts to all registered applications.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedPublishPrivateEvent, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedPublishPublicEvent,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used to define the private state events of the service.
+/// Private event means the data associated with the event will be specific for
+/// every session of all the clients on which it has subscribed.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] puiEvents
+/// PUI_32 - Array of state events or single state event.
+/// \param [in] uiListSize
+/// UI_32 - size of events list.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedDefinePublicStateEvents
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDefinePrivateStateEvents(HANDLE hApp, PUI_32 puiEvents, UI_32 uiListSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSubscribeToSessionEventWithCallback
+/// \~english @par Brief
+/// Register delivery of service-specific events and set callback for receiving events
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] uiEventId
+/// UI_32 - Event ID (Identification ID on the service protocol) (PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD)
+/// \~english @param [in] fpOnCmd
+/// CbFuncPtr - Pointer to callback function when event is received
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the callback function pointer (fpOnCmd) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sets the callback function for the event ID (iCmd) specified in the application Dispatcher.\n
+/// Then, it issues a request for registering the application that executed this API to the delivery target of the device-specific events of the service associated with the handle (hSession) specified in the argument.\n
+/// The application specifies the type of event to be received from the service by the event ID (uiEventId) of the arguments.\n
+/// (The event ID of this API refers to the identification ID on the protocol of the service, and the application identifies the content of the message. The specifiable service-specific events are events set by the service, such as the FrameworkunifiedDefinePublicStateEvents.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedSubscribeToSessionEventsWithCallbacks, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used for subscribing to single event of a service.
+/// This API also attaches the session event with callback.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - Event id
+/// \param [in] fpOnCmd
+/// CbFuncPtr - pointer to callback function
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedSubscribeToSessionEventsWithCallbacks
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithCallback(HANDLE hApp, UI_32 uiEventId, CbFuncPtr fpOnCmd, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSubscribeToSessionEventsWithCallbacks
+/// \~english @par Brief
+/// Registering multiple service-specific events for delivery and configuring callback settings when an event is received
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pEventHandler
+/// const FrameworkunifiedProtocolCallbackHandler* - Pointer to array of event handler structure
+/// \~english @param [in] uiHandlerCount
+/// UI_32 - Number of event handlers to register (0 to 214748362)
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @par
+/// FrameworkunifiedProtocolCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedProtocolCallbackHandler
+/// {
+/// UI_32 iCmd; /* Event ID (Identification ID on the service's protocol) */
+/// CbFuncPtr callBack; /* Reference to an XML stream */
+/// }FrameworkunifiedProtocolCallbackHandler;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the event handler structure array (pEventHandler) specified by arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Sets the callback functions for the IDs specified by the pEventHandler arguments in the Dispatcher of the application.\n
+/// Then, it issues a request for registering the application that executed this API to the delivery target of the device-specific events of the service associated with the handle (hSession) specified in the argument.\n
+/// The application specifies the type of event to be received from the service by the event ID.\n
+/// (The event ID of this API refers to the identification ID on the protocol of the service, and the application identifies the content of the message. The specifiable service-specific events are events set by the service, such as the FrameworkunifiedDefinePublicStateEvents.)
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the callback function pointer in the event handler structure (pEventHandler) specified in the arguments is NULL, the callback function up to NULL is registered.\n
+/// Later, FrameworkunifiedSendMsg() is executed inside this API, and the result becomes the return code of this API.\n
+/// Do not set NULL in the callback function pointer because operation cannot be guaranteed.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used for subscribing to multiple events of a service.
+/// This API also attaches the session event with callbacks.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pEventHandler
+/// FrameworkunifiedProtocolCallbackHandler - Array of event handler structures
+/// \param [in] uiHandlerCount
+/// UI_32 - number of event handlers
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedSubscribeToSessionEventWithCallback
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithCallbacks(HANDLE hApp, const FrameworkunifiedProtocolCallbackHandler *pEventHandler,
+ UI_32 uiHandlerCount, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnSubscribeSessionEventWithCallback
+/// \~english @par Brief
+/// Undeliver service-specific events and delete callbacks when events are received
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] uiEventId
+/// UI_32 - Event ID (Identification ID on the service protocol) (PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD)
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// - If the service specified by the parameter hSession is not registered in the Dispatcher, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Issues a request to unregister the application that executed this API from the delivery target of device-specific events
+/// of services associated with the handle (hSession) specified in the arguments.\n
+/// Then, the callback functions for the specified event ID (iCmd) are deleted from the application Dispatcher.\n
+/// The application specifies the type of event to be undelivered from the service by the event ID (uiEventId) of the arguments.\n
+/// (The event ID of this API refers to the identification ID on the protocol of the service, and the application identifies the content of the message.
+/// The specifiable service-specific events are events set by the service, such as the FrameworkunifiedDefinePublicStateEvents.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedUnSubscribeSessionEventsWithCallbacks, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks
+///
+/// API to unsubscribe from event of a service. Also detaches callback.
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [in] uiEventId
+/// UI_32 - Event id
+/// \param [in] hSession
+/// HANDLE - Session Handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithCallback(HANDLE hApp, UI_32 uiEventId, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+/// \~english @par Brief
+/// Undeliver multiple service-specific events and delete callbacks when an event is received
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pEventsArray
+/// PUI_32 - Pointer to an array of Event IDs (Identification IDs in the service's protocol)
+/// \~english @param [in] uiListSize
+/// UI_32 - Number of elements in the event ID (identification ID in the service protocol) array (1 to 1073741813)
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (obtained by FrameworkunifiedOpenSession)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Services and sessions are established (FrameworkunifiedOpenSession)
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle in the handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hSession) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle specified in the argument (hSession) is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the array (pEventsArray) of event IDs specified by arguments is NULL, [eFrameworkunifiedStatusInvldBuf]
+/// - When the name of the application in the handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the handle (hSession) specified in the argument exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hSession) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// - When the number of elements (uiListSize) of the event ID array specified by the arguments is 0, [eFrameworkunifiedStatusInvldParam]
+/// - If the service specified by the parameter hSession is not registered in the Dispatcher, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Issues a request to unregister the application that executed this API from the delivery target of the plurality of unique events of the service associated with the handle (hSession) specified by the argument.\n
+/// Then, the callback functions for the IDs specified in the pEventsArray arguments are deleted from the application Dispatcher.\n
+/// The application specifies the type of event to be undelivered from the service by the event ID (pEventsArray) of the arguments.\n
+/// (The event ID of this API refers to the identification ID on the protocol of the service, and the application identifies the content of the message. The specifiable service-specific events are events set by the service, such as the FrameworkunifiedDefinePublicStateEvents.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks
+///
+/// API to unsubscribe from multiple events of a service. Also detaches callbacks.
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [in] pEventsArray
+/// PUI_32 - Array of events id's.
+/// \param [in] uiListSize
+/// UI_32 - count of elements in array.
+/// \param [in] hSession
+/// HANDLE - Session Handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedUnSubscribeSessionEventWithCallback
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithCallbacks(HANDLE hApp, PUI_32 pEventsArray, UI_32 uiListSize,
+ HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedPublishPublicEvent
+/// \~english @par Brief
+/// Broadcast application-specific events
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] uiEventId
+/// UI_32 - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] pData
+/// PCVOID - Pointer to trasmission data
+/// \~english @param [in] uiLength
+/// UI_32 - Transmission data length
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - The events to be delivered must be specified in the FrameworkunifiedDefinePublicStateEvents.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the application name of the delivery destination in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - Sessioninformation is not found with the application being delivered to within the handles (hApp) specified in the arguments. [eFrameworkunifiedStatusErrOther]
+/// - If the destination handles are inappropriate (disabled) [eFrameworkunifiedStatusErrOther]
+/// - If the message queue handle in the destination handle is NULL [eFrameworkunifiedStatusErrOther]
+/// - If the application name in the destination handles is not set, [eFrameworkunifiedStatusErrOther]
+/// - If the message queue handle in the destination handle is inappropriate (disabled) [eFrameworkunifiedStatusErrOther]
+/// - When the send data length (uiLength) specified in the arguments is not 0 and the pointer to the send data pointer (pData) is NULL [eFrameworkunifiedStatusErrOther]
+/// - When the name of the application in the destination handle exceeds 20 bytes [eFrameworkunifiedStatusErrOther]
+/// - When the name of the message queue in the destination handle is NULL, [eFrameworkunifiedStatusErrOther]
+/// - When the name of the message queue in the destination handle exceeds 20 bytes [eFrameworkunifiedStatusErrOther]
+/// - If the message queue type of the destination handler is not the send type [eFrameworkunifiedStatusErrOther]
+/// - When the message queue is full [eFrameworkunifiedStatusErrOther]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrOther]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrOther]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusErrOther]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusErrOther]
+/// - Failed to access shared memory for sending messages [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Broadcast application-specific events to subscribed applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// Events are delivered to all applications registered by FrameworkunifiedSubscribeToSessionEventsWithCallbacks, etc.\n
+/// The data (pData) to be distributed is the same for all distribution destinations.
+/// \~english @par
+/// FrameworkunifiedPublishPrivateEvent should be used to deliver individual data by registered application sessions.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedDefinePrivateStateEvents, FrameworkunifiedPublishPrivateEvent,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used to publish the event to all the client over all the session it is subscribed to.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] uiEventId
+/// UI_32 - Event id of Message
+/// \param [in] pData
+/// PCVOID - Data buffer
+/// \param [in] uiLength
+/// UI_32 - Size of data buffer
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedPublishPrivateEvent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishPublicEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedPublishPrivateEvent
+/// \~english @par Brief
+/// Delivers application-specific events to a specified session
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] uiEventId
+/// UI_32 - The event ID to deliver (the identification ID on the service's protocol)
+/// \~english @param [in] pData
+/// PCVOID - Pointer to trasmission data
+/// \~english @param [in] uiLength
+/// UI_32 - Transmission data length
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusServNotFound Perform the event processing
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - The events to be delivered must be specified in the FrameworkunifiedDefinePrivateStateEvents.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the application handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application handle (hApp) specified in the arguments is not appropriate (disabled) [eFrameworkunifiedStatusInvldParam]
+/// - If the session handle (hSession) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the sessionhandle (hSession) specified in the arguments is not appropriate (is not valid) [eFrameworkunifiedStatusInvldParam]
+/// - The event ID (uiEventId) specified in the parameter is not registered as an event to be delivered to the Dispatcher. [eFrameworkunifiedStatusServNotFound]
+/// - When the session handle (hSession) specified in the arguments is not registered as the delivery destination in the Dispatcher [eFrameworkunifiedStatusServNotFound]
+/// - When the message queue handle in the session handle (hSession) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the application name in the session handle (hSession) specified by the arguments is not set [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue handle in the session handle (hSession) specified by the arguments is invalid. [eFrameworkunifiedStatusInvldHandle]
+/// - When the send data length (uiLength) specified in the arguments is not 0 and the pointer to the send data pointer (pData) is NULL [eFrameworkunifiedStatusInvldBuf]
+/// - When the name of the application in the session handle (hSession) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue in the session handle (hSession) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue in the session handle (hSession) specified in the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the session handle (hSession) specified in the parameter is not the send type [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages [eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Delivers application-specific events to specified sessions in registered applications.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// Events are delivered to the sessions specified in the hSession of arguments among the applications registered in the FrameworkunifiedSubscribeToSessionEventsWithCallbacks, etc.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - When broadcasting to all registered applications, use FrameworkunifiedPublishPublicEvent.
+/// - This API shall be executed from within a callback function, and a session-use handle acquired using FrameworkunifiedGetCurrentSessionHandle shall be passed to the parameter hSession.
+/// - Operation cannot be guaranteed if the size of the area indicated by the pointer (pData) address to the send data does not match
+/// the size specified by the send data length (iLength) address.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see FrameworkunifiedDefinePrivateStateEvents, FrameworkunifiedDefinePublicStateEvents, FrameworkunifiedPublishPublicEvent,
+/// FrameworkunifiedSubscribeToSessionEventWithCallback, FrameworkunifiedSubscribeToSessionEventsWithCallbacks,
+/// FrameworkunifiedUnSubscribeSessionEventWithCallback, FrameworkunifiedUnSubscribeSessionEventsWithCallbacks
+///
+/// This API is used to publish the event over session to the client subscribed to it using session handle.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application framework
+/// \param [in] uiEventId
+/// UI_32 - Event id of Message
+/// \param [in] pData
+/// PCVOID - Data buffer
+/// \param [in] uiLength
+/// UI_32 - Size of data buffer
+/// \param [in] hSession
+/// HANDLE - Session Handle
+///
+/// \return EFrameworkunifiedStatus
+/// eFrameworkunifiedStatusOK - If publish event success
+/// eFrameworkunifiedStatusInvldParam - Invalid parameter passed
+/// eFrameworkunifiedStatusServNotFound - If event uiEventId not subscribed on hSession by a client
+/// Any other values returned by FrameworkunifiedSendMsg
+///
+/// \see FrameworkunifiedPublishPublicEvent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishPrivateEvent(HANDLE hApp, UI_32 uiEventId, PCVOID pData, UI_32 uiLength, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetServiceAvailabilityTable
+/// returns the list that stores the available services
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application session
+
+/// \return ServiceAvailabilityList
+/// ServiceAvailabilityTable - ServiceAvailabilityList
+///
+/// \see FrameworkunifiedRegisterEvent
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+std::map<std::string, EFrameworkunifiedServiceAvailableStatus> FrameworkunifiedGetServiceAvailabilityTable(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedIsStateMachineApp
+/// \~english @par Brief
+/// Returns the presence or absence of a State Machine Application
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval BOOL State Machine Application existence (TRUE: existent/FALSE: nonexistent)
+/// \~english @retval FALSE Judgment failure
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [FALSE]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [FALSE]
+/// \~english @par Detail
+/// Determines whether there is a State Machine Application from the application handle specified by the arguments, and returns the handle.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Not applicable
+/// \~english @see FrameworkunifiedSetStateMachine, FrameworkunifiedHSMDispatcherWithArguments
+///
+/// FrameworkunifiedIsStateMachineApp
+/// Returns TRUE if it's a state machine application else FALSE.
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application session
+///
+/// \return TRUE - if a state machine application.
+/// FALSE - if not a state machine application
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsStateMachineApp(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetXMLConfigHandle
+/// Returns the handle to config file handle
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application session
+///
+/// \return handle
+/// HANDLE - Config file handle
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetXMLConfigHandle(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetNumberOfSession
+/// API to get the number of sessions created in the system.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] strServiceName
+/// PCSTR - Service name.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 FrameworkunifiedGetNumberOfSession(HANDLE hApp, PCSTR strServiceName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetSessionHandle
+/// \~english @par Brief
+/// Registering Session Handles with an Application Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] strServiceName
+/// PCSTR - Service name established for the session
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions (Acquired by FrameworkunifiedGetOpenSessionHandle, etc.)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusFail]
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusFail]
+/// - If the service-name (strServiceName) specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the length of the service-name (strServiceName) specified in the arguments is 0, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// After the application establishes a session with the service using a FrameworkunifiedOpenSession or the like,
+/// the session handle is registered in the application Dispatcher in association with the service name and session ID.
+/// Session handles shall be acquired by using a FrameworkunifiedGetOpenSessionHandle or the like when a response is received from the service.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedGetSessionHandle, FrameworkunifiedRemoveSessionHandle,
+/// FrameworkunifiedOpenSession, FrameworkunifiedOpenSessionWithData, FrameworkunifiedOpenSessionSync, FrameworkunifiedOpenSessionWithDataSync,
+/// FrameworkunifiedGetOpenSessionHandle, FrameworkunifiedGetOpenSessionSyncHandle,
+///
+/// Sets the session handle in the Application Framework. It stores the mapping between
+/// source, session id and session handle in the application framework.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] strServiceName
+/// PCSTR -Name of the associated service name
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedCreateSession, FrameworkunifiedGetSessionHandle, FrameworkunifiedRemoveSessionHandle.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetSessionHandle(HANDLE hApp, PCSTR strServiceName, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetSessionHandle
+/// \~english @par Brief
+/// Get the session handle for the given service name and session ID
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] strServiceName
+/// PCSTR - service name
+/// \~english @param [in] uiSessionId
+/// UI_32 - session ID
+/// \~english @retval HANDLE Handles for sessions
+/// \~english @retval NULL NULL pointer(Acquisition failure)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [NULL]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// - If the service-name (strServiceName) specified in the parameter is NULL, [NULL]
+/// - If the session with the service name (strServiceName) specified in the parameter is not registered in the Dispatcher, [NULL]
+/// - If the session with the session ID name (uiSessionId) specified in the parameter is not registered in the Dispatcher, [NULL]
+/// \~english @par Detail
+/// Gets and returns the session handle associated with the specified service and session id from the application Dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedSetSessionHandle, FrameworkunifiedRemoveSessionHandle
+///
+/// Returns the requested session handle associated with service name and session id.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] strServiceName
+/// PCSTR -Name of the associated service name
+/// \param [in] uiSessionId
+/// HANDLE - Session Id
+///
+/// \return handle
+/// HANDLE - Session handle
+///
+/// \see FrameworkunifiedSetSessionHandle
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetSessionHandle(HANDLE hApp, PCSTR strServiceName, UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetCurrentSessionHandle
+/// \~english @par Brief
+/// Get the session handle for the most recent incoming message
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval HANDLE Handles for sessions
+/// \~english @retval NULL NULL pointer (Acquisition failure)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [NULL]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// - When the source service name obtained from received messages is NULL [NULL]
+/// - If the Dispatcher does not have a session associated with the source service-name retrieved from the received message [NULL]
+/// - When the session ID acquired from the received message is not registered in the Dispatcher, [NULL]
+/// \~english @par Detail
+/// Gets and returns the session-handle associated with the most recently received message from the application's Dispatcher.
+/// \~english @par
+/// The application shall execute this API using an application handle passed as an argument to the callback function.\n
+/// (The callback functions are executed after the information required to execute the APIs is stored in the application handles (hApp) by receiving messages in the frameworks.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedGetSessionHandle, FrameworkunifiedSetSessionHandle
+///
+/// Returns the session handle for the current session. Useful, if used in the callback
+/// function of protocol. Current session means on which the protocol message received.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \return handle
+/// HANDLE - Session handle
+///
+/// \see FrameworkunifiedSetSessionHandle, FrameworkunifiedGetSessionHandle.
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetCurrentSessionHandle(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedRemoveSessionHandle
+/// \~english @par Brief
+/// Deletes the session handle for the given service name and session ID
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] strServiceName
+/// PCSTR - Service name
+/// \~english @param [in] uiSessionId
+/// UI_32 - session ID
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusFail]
+/// - If the service-name (strServiceName) specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the length of the service-name (strServiceName) specified in the arguments is 0, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This service call deletes the session handle associated with the specified service name and session ID among the session handles registered in the application's Dispatcher by FrameworkunifiedSetSessionHandle.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - When a session ID that has been deleted (or unregistered) is specified, this API returns an eFrameworkunifiedStatusOK.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedSetSessionHandle
+///
+/// Removes the session handle from the Application Framework associated with service name
+/// and session id. It actually removes the mapping between source, session id and session
+/// handle in the application framework which was set using FrameworkunifiedSetSessionHandle.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] strServiceName
+/// PCSTR -Name of the associated service name
+/// \param [in] uiSessionId
+/// HANDLE - Session Id
+///
+/// \return handle
+/// HANDLE - Session handle
+///
+/// \see FrameworkunifiedSetSessionHandle
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRemoveSessionHandle(HANDLE hApp, PCSTR strServiceName, UI_32 uiSessionId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetMandatoryServiceInfo
+/// \~english @par Brief
+/// Registers the specified Notification and event ID in the Notification list of the Dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pNotification
+/// PCSTR - Notification name
+/// \~english @param [in] uiEventId
+/// UI_32 - Event ID (Identification ID on the service's protocol)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the Notification name (pNotification) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the length of the Notification name (pNotification) specified in the arguments is 64 bytes or greater, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Registers the specified Notification and event ID in the Notification list of the Dispatcher.\n
+/// (The event ID of this API is the identification ID on the protocol of the service, which the application identifies the content of the message.)\n
+/// By registering a Notification with this API, a Notification registration/unregistration request
+/// to the notification service (NS_NPPService) is automatically issued by the Dispatcher when the Dispatcher starts/ends.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the Notification name is specified as an empty character, eFrameworkunifiedStatusOK is returned. Cannot guarantee operation.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Broadcast
+/// \~english @see
+///
+/// Sets the given service as Mandatory service in application handle
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pNotification
+/// PCSTR -Name of the Notification
+/// \param [in] uiEventId
+/// UI_32 - event id
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetMandatoryServiceInfo(HANDLE hApp, PCSTR pNotification, UI_32 uiEventId);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetSessionName
+/// \~english @par Brief
+/// Gets the name of the message queue from the session handle
+/// \~english @param [in] hSession
+/// HANDLE - Handles for sessions
+/// \~english @retval PCSTR Pointer to the message queue name
+/// \~english @retval NULL NULL pointer (Acquisition failure)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hSession specified in the parameter is NULL, [NULL]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [NULL]
+/// \~english @par Detail
+/// Gets the name of the message queue from the session handle (hSession) passed in the parameter.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see
+///
+/// Returns the session name corresponding to the given session handle.
+///
+///
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return session_name
+/// PCSTR - Session name
+///
+/// \see
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR FrameworkunifiedGetSessionName(HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedIsServiceAvailable
+/// \~english @par Brief
+/// Determine the availability of services
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application
+/// \~english @retval BOOL Use (TRUE: Available, FALSE: Not Available)
+/// \~english @retval FALSE Acquisition failure
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [FALSE]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [FALSE]
+/// - If the received message is not a service-availability notice... [FALSE]
+/// - Incoming messages are invalid [FALSE]
+/// \~english @par Detail
+/// Based on the received Notification, the service is judged to be usable or unusable, and true/false is returned.
+/// \~english @par
+/// The application shall execute this API using the handle of the application passed as the argument of the service availability notification callback function.\n
+/// (The callback functions are executed after the information required to execute the APIs is stored in the application handles (hApp) by receiving messages in the frameworks.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Broadcast
+/// \~english @see FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification,
+/// FrameworkunifiedSubscribeNotificationWithCallback, FrameworkunifiedSubscribeNotificationsWithCallback
+///
+/// This API should only be called in the callback/reaction associated with the Service
+/// availability notification. It returns TRUE if service is available and FALSE if service
+/// is not available.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return service_availability
+/// BOOL - returns TRUE if service is available otherwise returns FALSE
+///
+/// \see
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedIsServiceAvailable(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedPublishServiceAvailability
+/// \~english @par Brief
+/// Publish application availability status
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] bIsAvailable
+/// BOOL - Availability status of the application (TRUE: Available, FALSE: Not Available)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Notification must be registered by FrameworkunifiedRegisterServiceAvailabilityNotification.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - If the service-availability Notification is not set for the handle (hApp) specified in the parameter, [eFrameworkunifiedStatusFail]
+/// - When the message queue handle for NPP service in the handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the application name in the handler (hApp) specified by the arguments is not set, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle for NPP services in the handle (hApp) specified in the arguments is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hApp) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue for the NPP service in the handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue for NPP services in the handle (hApp) specified in the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - If the message queue type is not the send type [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusErrFail]
+/// \~english @par Detail
+/// Notifies (issues a Notification) the availability status of an application to another application.\n
+/// Applications must use this API to notify other applications when the availability of services provided by the application changes.\n
+/// (However, the state machine managed application generated by FrameworkunifiedHSMDispatcherWithArguments, etc. is excluded because the state machine automatically issues a Notification.)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Broadcast
+/// \~english @see FrameworkunifiedRegisterServiceAvailabilityNotification, FrameworkunifiedGetSelfAvailability
+///
+/// This API publishes service availability status of the service. This API needs to be
+/// used when service is up and ready to process clients requests.
+/// FrameworkunifiedRegisterServiceAvailabilityNotification must be called before calling this API.
+/// In Frameworkunified HSM Framework based application service availability is published by the Framework
+/// So this API can be used only in Non-FRAMEWORKUNIFIED HSM based application.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] bIsAvailable
+/// BOOL - TRUE if Service Available and FALSE if service is unavailable
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+/// FrameworkunifiedRegisterServiceAvailabilityNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedPublishServiceAvailability(HANDLE hApp, BOOL bIsAvailable);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetSelfAvailability
+/// \~english @par Brief
+/// Gets the availability status of the application itself
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval BOOL Use (TRUE: Available, FALSE: Not Available)
+/// \~english @retval FALSE Acquisition failure
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [FALSE]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [FALSE]
+/// \~english @par Detail
+/// Gets the availability status of the applications managed in the Dispatcher.\n
+/// Availability states are the values specified by the application when the FrameworkunifiedPublishServiceAvailability is executed.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Not applicable
+/// \~english @see FrameworkunifiedPublishServiceAvailability
+///
+/// This API get service availability status of the service. This API needs to be
+/// used when service is up and ready to process clients requests.
+/// FrameworkunifiedRegisterServiceAvailabilityNotification must be called before calling this API.
+/// In Frameworkunified HSM Framework based application service availability is published by the Framework
+/// So this API can be used only in Non-FRAMEWORKUNIFIED HSM based application.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+/// FrameworkunifiedRegisterServiceAvailabilityNotification, FrameworkunifiedPublishServiceAvailability
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL FrameworkunifiedGetSelfAvailability(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedRegisterServiceAvailabilityNotification
+/// \~english @par Brief
+/// Registering Application Availability Notification with NPP-Service
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pNotification
+/// PCSTR - Pointers to Notification names
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the Notification name (pNotification) specified in the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the length of the Notification name (pNotification) specified in the arguments is 64 bytes or greater, [eFrameworkunifiedStatusFail]
+/// - When the length of the Notification name (pNotification) specified in the arguments is 0, [eFrameworkunifiedStatusInvldParam]
+/// - Get buffer for sending messages (malloc) failed [eFrameworkunifiedStatusFail]
+/// - When the message queue handle for NPP service in the handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle for NPP services in the handle (hApp) specified in the arguments is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hApp) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue for the NPP service in the handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue for NPP services in the handle (hApp) specified in the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - If the message queue type is not the send type [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusErrFail]
+/// \~english @par Detail
+/// Requests that NPPservice register a Notification to notify the application availability status.\n
+/// A Notification registered by this API can publish the availability status to other applications by executing FrameworkunifiedPublishServiceAvailability from the application.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation is not guaranteed when the same application executes this API more than once with different Notification names.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Broadcast
+/// \~english @see FrameworkunifiedUnRegisterServiceAvailabilityNotification, FrameworkunifiedPublishServiceAvailability
+///
+/// This API registers the given service availability notification. Need to be used by
+/// service.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pNotification
+/// PCSTR -Name of the Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+/// FrameworkunifiedPublishServiceAvailability
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRegisterServiceAvailabilityNotification(HANDLE hApp, PCSTR pNotification);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedUnRegisterServiceAvailabilityNotification
+/// \~english @par Brief
+/// Revoke application availability Notification from NPPservice
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Notification must be registered by FrameworkunifiedRegisterServiceAvailabilityNotification.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - If the service-availability Notification is not set for the handle (hApp) specified in the parameter, [eFrameworkunifiedStatusInvldParam]
+/// - Get buffer for sending messages (malloc) failed [eFrameworkunifiedStatusFail]
+/// - When the message queue handle for NPP service in the handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue handle for NPP services in the handle (hApp) specified in the arguments is invalid (invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the application in the handle (hApp) specified by the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the name of the message queue for the NPP service in the handle (hApp) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the name of the message queue for NPP services in the handle (hApp) specified in the arguments exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - If the message queue type is not the send type [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Requests that NPPservice abandon the Notification to notify the availability status of the application that executed this API.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Broadcast
+/// \~english @see FrameworkunifiedRegisterServiceAvailabilityNotification
+///
+/// This API unregisters the service availability notification
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+/// FrameworkunifiedPublishServiceAvailability, FrameworkunifiedRegisterServiceAvailabilityNotification
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnRegisterServiceAvailabilityNotification(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateSession
+/// \~english @par Brief
+/// Create handles for sessions and register them with the application's Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pSessionName
+/// PCSTR - Session name (application name or thread name)
+/// \~english @retval HANDLE Handles for sessions
+/// \~english @retval NULL NULL pointer (Acquisition failure)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [NULL]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// - The session name (pSessionName) specified in the arguments is invalid.
+/// (For NULL, if the length is 0 or 20 bytes or more) [NULL]
+/// - When acquisition (malloc) of the message queue management information area fails, [NULL]
+/// - When the normalized message queue name from the session name (pSessionName) is inappropriate (exceeds 16 bytes) [NULL]
+/// - When acquisition (malloc) of the storage area for the message queue name fails, [NULL]
+/// - The open of the message queue (mq_open) failed [NULL]
+/// \~english @par Detail
+/// Creates handles (send message queues) for sessions with the specified application and registers them in the application's Dispatcher.\n
+/// The pSessionName is set to the application name or thread name of the client that establishes the session.\n
+/// This API is used to establish a session with a client application when an application on the service providing side receives a session start request from the client application.
+/// The application shall execute this API from the corresponding callback function.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedDestroySession
+///
+/// This API generates the session handle and sets it in the Application Framework. This API
+/// should be used by the server in the callback function attached to the open session request.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pSessionName
+/// PCSTR - SessionName can be application name or thread name
+///
+/// \return session_handle
+/// HANDLE - Session Handle
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateSession(HANDLE hApp, PCSTR pSessionName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDestroySession
+/// \~english @par Brief
+/// Destroys the session handle and removes the session handle from the application Dispatcher
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] hSession
+/// HANDLE - Handle for sessions (handle obtained with FrameworkunifiedCreateSession)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusFail]
+/// - If the hSession specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the hSession specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusFail]
+/// - When the length of the message queue name of the handle (hSession) specified in the arguments is 0, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Destroys the specified session handle and removes the specified session handle from the application Dispatcher.\n
+/// This API is used when the service-providing application receives a session termination request from the client application and discards the session with the client application.
+/// The application shall execute this API from the corresponding callback function.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see FrameworkunifiedCreateSession
+///
+/// This API destroys the session handle and removes it from the Application Framework.
+/// This API should be called by the server in the callback attached to the close session
+/// request
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDestroySession(HANDLE hApp, HANDLE hSession);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSendResponse
+/// \~english @par Brief
+/// Sending a Response to the Source of an Incoming Message
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] iCmd
+/// UI_32 - Identification ID on the service's protocol
+/// \~english @param [in] length
+/// UI_32 - Data size to be sent (0 to 4294967255)
+/// \~english @param [in] data
+/// PCVOID - Pointer to the data to send
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Bad buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther Other errors (Failed to open/allocate shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// - Sessions are registered in the Dispatcher by FrameworkunifiedCreateSession, etc.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusFail]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusFail]
+/// - When the source service name obtained from received messages is NULL [eFrameworkunifiedStatusFail]
+/// - If the Dispatcher does not have a session associated with the source service-name retrieved from the received message [eFrameworkunifiedStatusFail]
+/// - When the session ID acquired from the received message is not registered in the Dispatcher, [eFrameworkunifiedStatusFail]
+/// - If the sessionhandle for incoming messages is NULL [eFrameworkunifiedStatusNullPointer]
+/// - If the handles for sessions corresponding to incoming messages are inappropriate (disabled) [eFrameworkunifiedStatusNullPointer]
+/// - When the message queue handle corresponding to the received message in the session handle is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - When the application name length in the session handle corresponding to received messages is 0, [eFrameworkunifiedStatusInvldHandle]
+/// - Incorrect (invalid) message queue handle in session handle for incoming message [eFrameworkunifiedStatusInvldHandle]
+/// - When the data (data) of the send message specified by the parameter is NULL and the data length (length) is not 0, [eFrameworkunifiedStatusInvldBuf]
+/// - When the length of the application name in the session handle corresponding to the received message exceeds 20 bytes [eFrameworkunifiedStatusInvldQName]
+/// - When the message queue name of the session handle corresponding to the received message is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue name of the session handle corresponding to the received message exceeds 20 bytes [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the session handle corresponding to the received message is not the transmission type [eFrameworkunifiedStatusInvldHndlType]
+/// - When the message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending messages is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a systemcall (signal) occurs while sending messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - If the size of the message transmission buffer is invalid [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages [eFrameworkunifiedStatusFail]
+/// - Failed to access shared memory for sending messages [eFrameworkunifiedStatusErrOther]
+/// - When the size (length) of the data to be sent specified in the parameter is out of range, [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Gets the session ID and session name from received messages, and the corresponding session handles from Dispatcher.\n
+/// Send a response to the sender of the received message using the acquired session handle.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - The maximum data size (length) described above is a theoretical value. The maximum data size that can be actually used depends on the environment requirements.\n
+/// The maximum value is the upper limit of the type (UINT_MAX) minus the following size.\n
+/// Message header section\n
+/// - Operation cannot be guaranteed when the size of the allocated area indicated by the address of the pointer (data) to the data buffer does not match the size specified by the size of the data buffer (length).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method
+/// \~english @see FrameworkunifiedCreateSession, FrameworkunifiedSetSessionHandle
+///
+/// This API retrieves the session handle from the application framework and sends the response
+/// to the client on the same session. The session id and message source name available in the
+/// hApp at that instance is used to get the session handle. This API will work if server has
+/// created session using FrameworkunifiedCreateSession or has used FrameworkunifiedSetSessionHandle after creating the
+/// session.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] iCmd
+/// UI_32 - Protocol command
+/// \param [in] length
+/// UI_32 - size of message data
+/// \param [in] data
+/// PCVOID - message data
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedCreateSession, FrameworkunifiedSetSessionHandle, FrameworkunifiedSendRequest.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendResponse(HANDLE hApp, UI_32 iCmd, UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSendRequest
+/// This API retrieves the session handle from the application framework and sends the request
+/// to the server with specific service name and session id. This API will work, if application
+/// has previously stored associated session handle using FrameworkunifiedSetSessionHandle.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pServerName
+/// PCSTR - Name of the server
+/// \param [in] uiSessionId
+/// UI_32 - session id
+/// \param [in] iCmd
+/// UI_32 - Protocol command
+/// \param [in] length
+/// UI_32 - size of message data
+/// \param [in] data
+/// PCVOID - message data
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedSetSessionHandle, FrameworkunifiedSendResponse
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendRequest(HANDLE hApp, PCSTR pServerName, UI_32 uiSessionId, UI_32 iCmd,
+ UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPSetPersonality
+/// API to send message to Notification Service to set Personality
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [in] pUserName
+/// PCSTR - Name of the new Personality
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPRegisterPersistentFile, FrameworkunifiedNPLoadPersistentFile
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPSetPersonality(HANDLE hApp, PCSTR pUserName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPChangePersonality
+/// API to send message to Notification Service to set new Personality
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [in] pUserName
+/// PCSTR - Name of the new Personality
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedNPRegisterPersistentFile, FrameworkunifiedNPLoadPersistentFile
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPChangePersonality(HANDLE hApp, PCSTR pUserName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSendStopToNSNPP
+/// \~english @par Brief
+/// API that sends a message to the notification service and requests a shutdown
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] eShutdownType
+/// EFrameworkunifiedShutdownType - Shutdown type
+/// \~english @param [in] uiStopMsgData
+/// UI_32 - Flag subject to resetting (Default:0)
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sends a message to the notification service (NS_NPPService) and requests shutdown.\n
+/// The reset target flag (uiStopMsgData) is valid only when the shutdown type (eShutdownType) is eFrameworkunifiedDataResetShutdown.\n
+/// The reset target flag (uiStopMsgData) indicates the target of data reset at shutdown.\n
+/// The target can be OR-set by using EFrameworkunifiedPersistCategory defined values.\n
+/// The specified target is reset from the non-volatile memory.
+/// Eg: uiStopMsgData = (eFrameworkunifiedUserData | eFrameworkunifiedFactoryCustomerData) = 0x0101\n
+/// eFrameworkunifiedUserData bit : 1 : user data resets\n
+/// eFrameworkunifiedFactoryData bit : 0 : factory data not reset-target\n
+/// eFrameworkunifiedFactoryCustomerData bit : 1 : factory customer data resets\n
+/// eFrameworkunifiedDealerData bit : 0 : persist dealer data not reset-target\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync
+/// \~english @see
+///
+/// FrameworkunifiedSendStopToNSNPP
+/// To be used by System Manager Service only. This API would push NPP Service to persist
+/// the data/files. Ideally this should be sent during system shutdown by System Manager Service
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+///
+/// \param [in] eShutdownType
+/// EFrameworkunifiedShutdownType - shutdown type
+///
+/// \param [in] uiStopMsgData
+/// UI_32 - Flag representing which data to persist and which data to delete from
+/// persistent memory during shutdown.
+/// This needs to be specified only when shutdown type is eFrameworkunifiedDataResetShutdown.
+/// If not specified with DataReset type, then NPP will do normal shutdown.
+/// For other shutdown type this parameter has no effect.
+/// uiStopMsgData = 0 means Normal shutdown persisting all data
+/// else value from enum EFrameworkunifiedPersistCategory, multiple value from enum can be ORed.
+/// Bit value 1 represent resetting of data while value 0 bit represent data persisting
+/// Eg: uiStopMsgData = (eFrameworkunifiedUserData|eFrameworkunifiedFactoryCustomerData) = 0x0101 indicates
+/// eFrameworkunifiedUserData bit value 1 means delete user data
+/// eFrameworkunifiedFactoryData bit value 0 means persist factory data
+/// eFrameworkunifiedFactoryCustomerData bit value 1 means delete factory customer data
+/// eFrameworkunifiedDealerData bit value 0 means persist dealer data
+///
+/// \return status
+/// EFrameworkunifiedStatus - success if request sent to NPPService or error
+/// \~english @par Type
+/// Pub-Sub
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendStopToNSNPP(HANDLE hApp, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData = 0x0);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedNPGetReadyStatusOfNPP
+/// \~english @par Brief
+/// APIs that send messages to notification services and obtain Ready status
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR Generating an interrupt by a system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - The process of NS_NPPService is started.
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the application-name storage area address in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the application name in the handle (hApp) specified by the arguments is empty, [eFrameworkunifiedStatusInvldParam]
+/// - When the message queue handle in the handle (hApp) specified by the arguments is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - When the message queue type of the handle (hApp) specified in the parameter is not the send type, [eFrameworkunifiedStatusInvldHndlType]
+/// - If the message queue handle in the hApp specified by the arguments is inappropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - The message queue name of the handle (hApp) specified in the arguments is not appropriate (the name exceeds NULL, 20 bytes) [eFrameworkunifiedStatusInvldHandle]
+/// - Full Message Queue for Sessions for NPP Service [eFrameworkunifiedStatusMsgQFull]
+/// - Incorrect file descriptors for sending messages for NPP Service sessions [eFrameworkunifiedStatusErrNoEBADF]
+/// - When an interrupt by a system call (signal) occurs while sending NPP Service session-specific messages [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrectly sized send buffers for sessions destined for NPP Service [eFrameworkunifiedStatusInvldBufSize]
+/// - If there are any errors sending messages for sessions intended for NPP Service [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Sends messages to the notification service (NS_NPPService) and acquires the Ready status.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method
+/// \~english @see
+///
+/// FrameworkunifiedNPGetReadyStatusOfNPP
+/// To be used by System Manager Service only. SystemManager will use this API to get the
+/// ready status of NPPService.
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success if request sent to NPPService or error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPGetReadyStatusOfNPP(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification
+/// \~english @par Brief
+/// Get the available service names
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [out] pServiceName
+/// PSTR - Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some error occurred
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - When the service-name storage area (pServiceName) specified in the parameter is NULL, [eFrameworkunifiedStatusInvldParam]
+/// - If the received message is not a service-availability notice... [eFrameworkunifiedStatusFail]
+/// - Incoming messages are invalid [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// When an application receives a service availability notification, it gets the name of the available service.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - The application shall execute this API using an application handle passed as an argument to the callback function.\n
+/// (The callback functions are executed after the information required to execute the APIs is stored in the application handles (hApp) by receiving messages in the frameworks.)
+/// - The size of the buffer passed in the argument pServiceName must be at least MAX_NAME_SIZE_APP(20).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Not applicable
+/// \~english @see FrameworkunifiedIsServiceAvailable, FrameworkunifiedSubscribeNotificationWithCallback,
+/// FrameworkunifiedSubscribeNotificationsWithCallback
+///
+/// To be used when client receives service availability notification to get the available
+/// service name.
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [out] pServiceName
+/// PSTR - Name of the available service.
+/// Size of the buffer should be equal to or greater than MAX_NAME_SIZE_APP
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetServiceNameOnServiceAvailabilityNotification(HANDLE hApp, PSTR pServiceName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetCurrentUser
+/// Get the current user for the application
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+///
+/// \return userhandle
+/// HANDLE - Returns current user handle
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedGetCurrentUser(HANDLE hApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSetUser
+/// Set the current user for the application in application framework
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] hUser
+/// HANDLE - User handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetUser(HANDLE hApp, HANDLE hUser);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetAppData
+/// \~english @par Brief
+/// Hold the specified arbitrary data
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pKey
+/// PCSTR - Key strings
+/// \~english @param [in] pData
+/// PVOID - Service name that can be used
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Retention failure
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [eFrameworkunifiedStatusInvldHandle]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldHandle]
+/// - If the addresses of the key strings are NULL [eFrameworkunifiedStatusInvldParam]
+/// - Failed to retain arbitrary data. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This function stores an arbitrary data address in the heap using the specified key string as a key.
+/// Since the object to be held is an address, the caller must specify an accessible global address, etc.
+/// The caller should pay attention to the addresses of arbitrary data, since they retain the addresses of arbitrary data even if they are NULL.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Set Get
+/// \~english @see FrameworkunifiedGetAppData, FrameworkunifiedRemoveAppData
+///
+/// FrameworkunifiedSetAppData
+/// This API stores the data pointer against a key in application framework. This can be used
+/// as a global data and can be accessed in the FRAMEWORKUNIFIED functions. Please note that application
+/// developer should avoid using global data.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pKey
+/// PSTR - Data key
+/// \param [in] pData
+/// PVOID - data
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedGetAppData, FrameworkunifiedRemoveAppData
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetAppData(HANDLE hApp, PCSTR pKey, PVOID pData);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetAppData
+/// \~english @par Brief
+/// Returns the address of any data associated with the key string
+/// \~english @param [in] hApp
+/// HANDLE - Handle for the application
+/// \~english @param [in] pKey
+/// PCSTR - Key strings
+/// \~english @retval PVOID Address of arbitrary data
+/// \~english @retval NULL NULL pointers (unsuccessful retrieval, anomaly parameters)
+/// \~english @par Prerequisite
+/// - Creation/initialization (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) of the Dispatcher for the application must be performed.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the hApp specified in the parameter is NULL, [NULL]
+/// - If the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// - If the addresses of the Key strings are NULL [NULL]
+/// \~english @par Detail
+/// Returns the corresponding data address using the specified key string as the key.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Set Get
+/// \~english @see FrameworkunifiedSetAppData, FrameworkunifiedRemoveAppData
+///
+/// FrameworkunifiedGetAppData
+/// This API retrieves the data stored against a key in application framework.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pKey
+/// PSTR - Data key
+/// \return [in] pData
+/// PVOID - data
+///
+/// \see FrameworkunifiedSetAppData, FrameworkunifiedRemoveAppData
+////////////////////////////////////////////////////////////////////////////////////////////
+PVOID FrameworkunifiedGetAppData(HANDLE hApp, PCSTR pKey);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedRemoveAppData
+/// This API removes the data stored against a key in application framework.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pKey
+/// PSTR - Data key
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedSetAppData, FrameworkunifiedGetAppData
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedRemoveAppData(HANDLE hApp, PCSTR pKey);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetSystemInfo
+/// Gets some internal notification information
+///
+/// \param [in] hApp
+/// HANDLE - Handle to a Application Framework
+/// \param [in, out] pSystemInfo
+/// PVOID - Buffer pointer to which system info is copied.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedMcOpenSender, FrameworkunifiedSendMsg, FrameworkunifiedGetMsgLength, FrameworkunifiedGetMsgSrc, FrameworkunifiedGetMsgDataOfSize,
+/// FrameworkunifiedClearMsgData, FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage, FrameworkunifiedGetSystemInfo
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetSystemInfo(HANDLE hApp, PVOID pSystemInfo);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSetDeferredSyncResponse
+/// Set sync response deferred flag
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the dispatcher to receive message
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetDeferredSyncResponse(HANDLE hApp);
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_H__ */ // NOLINT (build/header_guard)
+/**@}*/ // end of framework
+/**@}*/ // end of framework_unified
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_sync.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_sync.h
new file mode 100644
index 00000000..3573e8cc
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_sync.h
@@ -0,0 +1,370 @@
+/*
+ *
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NativeService
+/// \brief This file contains the class declaration for synchronization
+/// API's.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_framework_sync.h
+ * @brief \~english This file contains the class declaration for synchronization
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_SYNC_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_SYNC_H__
+
+#include <pthread.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <time.h>
+#include <map>
+#include <string>
+
+struct SFrameworkunifiedSyncDataPacket;
+
+// Map containing the synchronization data as per the notification
+typedef std::map<std::string, SFrameworkunifiedSyncDataPacket *> TSyncDataPacketList;
+
+// Iterator to the map containing the synchronization data as per the notification
+typedef TSyncDataPacketList::iterator TSyncDataPacketItr;
+
+/**
+ * @class CFrameworkunifiedSyncData
+ * \~english @brief this file has the CFrameworkunifiedSyncData class definitions
+ * \~english @par Brief Introduction
+ * - This class provids some functions to handle the synchronization data as per the notification.
+ *
+ */
+class CFrameworkunifiedSyncData {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - This function is used to get the singleton instance of class.
+ /// \~english @param None
+ /// \~english @retval CFrameworkunifiedSyncData - singleton instance of class
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - If m_psSyncData is NULL,will create a new object,otherwise, will return m_psSyncData.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @see CFrameworkunifiedSyncData::CFrameworkunifiedSyncData
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ static CFrameworkunifiedSyncData *FrameworkunifiedGetSyncDataInstance();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - This function is used to release the instance of class.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval except eFrameworkunifiedStatusOK - failure
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - system function error.[Not eFrameworkunifiedStatusOK]
+ /// \~english @par Detail
+ /// - If m_psSyncData is NULL,return success,otherwise, will delete m_psSyncData.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see CFrameworkunifiedSyncData::CFrameworkunifiedSyncData
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus FrameworkunifiedReleaseSyncDataInstance();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - This method is used by the application to start the notification synchronization thread.
+ /// \~english @param [in] hApp
+ /// HANDLE - Application Handle.
+ /// \~english @retval eFrameworkunifiedStatusOK - On Success
+ /// \~english @retval eFrameworkunifiedStatusThreadAlreadyRunning - If thread already running
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - Null Handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid Handle
+ /// \~english @par Preconditons
+ /// - The function FrameworkunifiedReleaseSyncDataInstance is successed, object is created successfully.
+ /// \~english @par Change of internal status
+ /// -m_hSyncThreadMsgQHandle saves sync thread handle.
+ /// \~english @par Conditions of processing failure
+ /// - m_hSyncThreadMsgQHandle is not NULL, thread already running.[eFrameworkunifiedStatusThreadAlreadyRunning]
+ /// - Null Handle.[eFrameworkunifiedStatusNullPointer]
+ /// - Invalid Handle.[eFrameworkunifiedStatusInvldHandle]
+ /// \~english @par Detail
+ /// - This fucntion create a child thread of hApp, m_hSyncThreadMsgQHandle saves the child thread.
+ /// - The child thread will be used to receive and send notification data.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedStartNotificationSync(HANDLE hApp);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - This method is used to stop the synchronization notification thread.
+ /// \~english @param [in] hApp
+ /// HANDLE - Application Handle.
+ /// \~english @retval eFrameworkunifiedStatusOK - On Success
+ /// \~english @retval eFrameworkunifiedStatusThreadNotExist - If thread already running
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - Null Handle
+ /// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid Handle
+ /// \~english @par Preconditons
+ /// -The function FrameworkunifiedStartNotificationSync is successed.
+ /// \~english @par Change of internal status
+ /// - m_hSyncThreadMsgQHandle will be delete.
+ /// \~english @par Conditions of processing failure
+ /// - If thread doesn't exist.[eFrameworkunifiedStatusThreadNotExist]
+ /// - Null Handle.[eFrameworkunifiedStatusNullPointer]
+ /// - Invalid Handle.[eFrameworkunifiedStatusInvldHandle]
+ /// \~english @par Detail
+ /// - This method is used by the application to stop the notification synchronization thread.
+ /// m_hSyncThreadMsgQHandle is Invalid and can't be used to get notification data for hApp.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedStopNotificationSync(HANDLE hApp);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - API to subscribe to a synchronization notification data.
+ /// \~english @param [in] f_cNotification
+ /// std::string - Notification to be subscribed.
+ /// \~english @retval eFrameworkunifiedStatusOK - On Success
+ /// \~english @retval eFrameworkunifiedStatusFail - On failure
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If f_cNotification is empty or m_hSyncThreadAppHandle is NULL.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - API to subscribe to a synchronization notification data.\n
+ /// application will get the synchronization notification data at run-time.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - eFrameworkunifiedStatusFail:Failure
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithDataSync(const std::string &f_cNotification);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - API to unsubscribe to a synchronization notification data.
+ /// \~english @param [in] f_cNotification
+ /// std::string - Notification to be subscribed.
+ /// \~english @retval eFrameworkunifiedStatusOK - On Success
+ /// \~english @retval eFrameworkunifiedStatusFail - On failure
+ /// \~english @par Preconditons
+ /// - the FrameworkunifiedSubscribeNotificationWithDataSync result is success.
+ /// \~english @par Change of internal status
+ /// - The synchronization data's pointor of the special notification will be remove and delete.
+ /// - The synchronization data of the special notification will delete from m_mSyncDataMap.
+ /// \~english @par Conditions of processing failure
+ /// - If f_cNotification is empty or m_hSyncThreadAppHandle is NULL.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - API to unsubscribe to a synchronization notification data.\n
+ /// After unsubscribing,notification synchronization data of application will be freed.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - eFrameworkunifiedStatusFail:Failure
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedUnSubscribeNotificationWithDataSync(const std::string &f_cNotification);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - This function is used to get the synchronization notification data for a particular notification.
+ /// \~english @param [in] f_cNotification
+ /// std::string - Notification for which data is required
+ /// \~english @param [in] f_pBuffer
+ /// PVOID - Buffer for the synchronization data
+ /// \~english @param [in] f_nBufferSize
+ /// UI_16 - size of notification data buffer
+ /// \~english @retval eFrameworkunifiedStatusOK - Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - Null pointor
+ /// \~english @retval eFrameworkunifiedStatusFail - failure
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If f_cNotification is empty or m_hSyncThreadAppHandle is NULL or f_nBufferSize is 0.[eFrameworkunifiedStatusFail]
+ /// - If l_itSyncDataPacketItr is not in m_mSyncDataMap.[eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// - This function is used to get the synchronization notification data for a particular notification.
+ /// f_cNotification is the iterator to the map containing the synchronization data of notification,\n
+ /// using this iterator to get data from m_mSyncDataMap.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedGetSyncNotificationData(const std::string &f_cNotification, PVOID f_pBuffer, UI_16 f_nBufferSize);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedSyncData
+ /// \~english @par Brief
+ /// - API to get the size of synchronization notification data.
+ /// \~english @param [in] f_cNotification
+ /// const std::string - Notification to be subscribed.
+ /// \~english @retval UI_32 - size of notification data
+ /// \~english @par Preconditons
+ /// -Instance is created successfully.
+ /// \~english @par Change of internal status
+ /// -None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - This function is used to get the size of the synchronization data.
+ /// if f_cNotification is null or l_itSyncDataPacketItr is not in m_mSyncDataMap\n
+ /// the function will return 0.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 FrameworkunifiedGetSyncDataSize(const std::string &f_cNotification);
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedSyncData
+ /// Constructor of CFrameworkunifiedSyncData class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedSyncData();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedSyncData
+ /// Destructor of CFrameworkunifiedSyncData class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFrameworkunifiedSyncData();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedSyncDataThreadStart
+ /// Callback on the start of the sync thread.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Thread Application Handle.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedSyncDataThreadStart(HANDLE hThread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedSyncDataThreadStop
+ /// Callback on the stop of the sync thread.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Thread Application Handle.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedSyncDataThreadStop(HANDLE hThread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedSyncDataNotifCallback
+ /// Callback on the receiving the published notification.
+ ///
+ /// \param [in] hThread
+ /// HANDLE - Thread Application Handle.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedSyncDataNotifCallback(HANDLE hThread);
+
+ static CFrameworkunifiedSyncData *m_psSyncData; ///< singleton instance of class
+
+ BOOL m_bSyncThreadStarted; /// Check to verify if thread started
+
+ TSyncDataPacketList
+ *m_mSyncDataMap; /// Pointer to the map containing the synchronization data as per the notification
+
+ HANDLE m_hSyncThreadAppHandle; /// S ynchronization thread Application Handle
+
+ HANDLE m_hAppHandle; /// Application Handle
+
+ HANDLE m_hSyncThreadMsgQHandle; /// Synchronization thread message queue handle
+
+ static pthread_spinlock_t m_pSyncLock; /// Synchronization Spinlock
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_SYNC_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_system_if.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_system_if.h
new file mode 100644
index 00000000..af7a4f9b
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_system_if.h
@@ -0,0 +1,110 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief This file provides framework's API which are used by system services.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_framework_system_if.h
+ * @brief \~english This file provides framework's API which are used by system services.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_INC_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_SYSTEM_IF_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_INC_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_SYSTEM_IF_H__
+
+#include <native_service/frameworkunified_types.h>
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FrameworkunifiedNPClearPersistedData
+ /// \~english @par Summary
+ /// API to delete all the persistent files and notification data from persistent memory
+ /// related to NS_NPS.
+ /// Note: This API is only to be used HMI service.
+ /// This API should not be used by the other application.
+ /// \~english @param [in] hApp
+ /// hApp - Handle to the Framework
+ /// \~english @par
+ /// hApp HANDLE*
+ /// \~english @param [in] eFrameworkunifiedClearPersistenceScope
+ /// eFrameworkunifiedClearPersistenceScope - specifies what data to delete from persistent memory
+ /// \~english @par
+ /// eFrameworkunifiedClearPersistenceScope EFrameworkunifiedClearPersistence enum
+ /// \~english @code
+ /// typedef enum _EFrameworkunifiedClearPersistence {
+ /// eFrameworkunifiedClearAllData = 0, ///< clears all the data in persistence memory for all users
+ /// ///< (currently only this enum value is supported.)
+ /// eFrameworkunifiedClearAllApplicationData, ///< clears all the data(files, folders) related to all application for all
+ /// users
+ /// eFrameworkunifiedClearAllNotificationData, ///< clears all the notification data related to all application for all users
+ /// eFrameworkunifiedClearCurrentUserData, ///< clears all the data in persistence memory for current users
+ /// eFrameworkunifiedClearCurrentUserApplicationData, ///< clears all the data(files, folders) related to all application for
+ /// current users
+ /// eFrameworkunifiedClearCurrentUserNotificationData ///< clears all the notification data related to all application for
+ /// current users
+ /// } EFrameworkunifiedClearPersistence;
+ /// @endcode
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @par
+ /// eFrameworkunifiedStatusOK
+ /// eFrameworkunifiedStatusNullPointer
+ /// eFrameworkunifiedStatusInvldParam
+ /// \~english @par Preconditions
+ /// -
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// - If input parameter Framework handler is invalid. [eFrameworkunifiedStatusNullPointer]
+ /// - If communicate handler of NPPService is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Function NPClearPersistedData return invalid parameter. [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par Detail
+ /// API to delete all the persistent files and notification data from persistent memory
+ /// related to NS_NPS.
+ /// Note: This API is only to be used HMI service.
+ /// This API should not be used by the other application.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPClearPersistedData(HANDLE hApp, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope = eFrameworkunifiedClearAllData);
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_INC_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_SYSTEM_IF_H__ */ // NOLINT (build/header_guard)
+/**@}*/ // end of framework
+/**@}*/ // end of framework_unified
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_types.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_types.h
new file mode 100644
index 00000000..aa4119df
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_framework_types.h
@@ -0,0 +1,173 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup
+/// \brief Application framework's core structures and data types.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_framework_types.h
+ * @brief \~english Application framework's core structures and data types.
+ *
+ */
+/** @addtogroup BaseSystem
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_TYPES_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_TYPES_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <boost/function.hpp>
+
+#define MAX_LEN MAX_QUEUE_NAME_SIZE
+#define MAX_MSGQ_BUFFER MAX_QUEUE_MSG_SIZE
+#define MAX_SESSION_ID_VAL 0xFFFF
+#define MAX_FD_MULTIWAITING 8
+
+#define FRAMEWORKUNIFIED_ANY_SOURCE "NS_ANY_SRC"
+#define FRAMEWORKUNIFIED_ANY_COMMAND 0xFFFFFFFF
+#define FRAMEWORKUNIFIED_NS_NPSERVICE "NS_NPPService"
+#define FRAMEWORKUNIFIED_NS_VERSIONUTIL "nsverutil"
+#define FRAMEWORKUNIFIED_NS_MSGPROFILERUTIL "NSDisMsgProfile"
+#define FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE "NS_RemoteControlService"
+
+// call back function definition
+typedef boost::function< EFrameworkunifiedStatus(HANDLE) > TCbFunction;
+typedef TCbFunction CallbackFunctionPtr;
+typedef TCbFunction CbFuncPtr;
+typedef EFrameworkunifiedStatus(*CbArgumentParser)(SI_32 argument, PCHAR argumentValue);
+
+typedef enum _EFrameworkunifiedServiceAvailableStatus {
+ eFrameworkunifiedServiceAvailable = 0,
+ eFrameworkunifiedServiceNotAvailable,
+} EFrameworkunifiedServiceAvailableStatus;
+
+// Share Memory Retrieve Types
+typedef enum _ESMRetrieveTypes {
+ eSMRRelease = 0, ///< data will be released on a read
+ eSMRRetain = 1, ///< data will be retained in the shared memory
+} ESMRetrieveTypes;
+
+/**
+ * \~english Callbacks structure of Application Life cycle
+ */
+typedef struct _FrameworkunifiedDefaultCallbackHandler {
+ CbFuncPtr onInitilization; //!< \~english Callback of initialization
+ CbFuncPtr onDestroy; //!< \~english Callback of destroy
+ CbFuncPtr onStart; //!< \~english Callback of startup
+ CbFuncPtr onStop; //!< \~english Callback of stop
+ CbFuncPtr onPreStart; //!< \~english Callback of pre start
+ CbFuncPtr onPreStop; //!< \~english Callback of pre stop
+ CbFuncPtr onBackgroundStart; //!< \~english Callback of Background start
+ CbFuncPtr onBackgroundStop; //!< \~english Callback of Background stop
+ CbFuncPtr onDebugDump; //!< \~english Callback of debug dump
+ CbFuncPtr createStateMachine; //!< \~english Callback of created state machine
+ CbFuncPtr ssFrameworkInterface; //!< \~english Callback to Establish a session with the system_manager
+} FrameworkunifiedDefaultCallbackHandler;
+
+// LCOV_EXCL_BR_START 11:Occurred in the above test
+typedef struct _FrameworkunifiedProtocolCallbackHandler {
+ UI_32 iCmd;
+ CbFuncPtr callBack;
+} FrameworkunifiedProtocolCallbackHandler;
+// LCOV_EXCL_BR_STOP
+
+typedef struct _FrameworkunifiedFdProtocolCallbackHandler {
+ int fd;
+ CbFuncPtr callBack;
+} FrameworkunifiedFdProtocolCallbackHandler;
+
+// LCOV_EXCL_BR_START 11:Occurred in the above test
+typedef struct _FrameworkunifiedNotificationCallbackHandler {
+ CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION];
+ CbFuncPtr callBack;
+} FrameworkunifiedNotificationCallbackHandler;
+// LCOV_EXCL_BR_STOP
+
+typedef struct _FrameworkunifiedNotificationsList {
+ CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION];
+ UI_32 uiLengthData;
+ EFrameworkunifiedNotificationType persType;
+} FrameworkunifiedNotificationsList;
+
+typedef struct _FrameworkunifiedProtocolEvent {
+ UI_32 iCmd;
+ UI_32 iEventId;
+} FrameworkunifiedProtocolEvent;
+
+typedef struct _FrameworkunifiedNotificationEvent {
+ CHAR cNotification[MAX_STRING_SIZE_NOTIFICATION];
+ UI_32 iEventId;
+} FrameworkunifiedNotificationEvent;
+
+typedef struct _ServiceAvailability {
+ CHAR cServiceName[MAX_NAME_SIZE_APP];
+ EFrameworkunifiedServiceAvailableStatus eServiceAvailability;
+} ServiceAvailability;
+
+typedef enum _EFrameworkunifiedShutdowntatus {
+ eFrameworkunifiedShutdownOk = 0,
+ eFrameworkunifiedShutdownTimeout,
+ eFrameworkunifiedShutdownFail,
+} EFrameworkunifiedShutdownStatus;
+
+typedef struct _ShutdownComplete {
+ CHAR cServiceName[MAX_NAME_SIZE_APP];
+ EFrameworkunifiedShutdownStatus eShutdownCompleteStatus;
+} ShutdownComplete;
+
+typedef struct _CustomCommandLineOptions {
+ PCSTR cShortOptions;
+ PCHAR cLongOptions; // reserved for long options.
+ CbArgumentParser callback;
+} CustomCommandLineOptions;
+
+/// Scheduling Policy
+typedef enum _EFrameworkunifiedSchedPolicy {
+ eFrameworkunifiedSchedPolicyInherit = 0,
+ eFrameworkunifiedSchedPolicyTSS,
+ eFrameworkunifiedSchedPolicyFIFO,
+ eFrameworkunifiedSchedPolicyRR,
+ eFrameworkunifiedSchedPolicyMAX
+} EFrameworkunifiedSchedPolicy;
+
+/// Child Thread Attribute
+typedef struct _FrameworkunifiedChildThreadAttr {
+ EFrameworkunifiedSchedPolicy schedPolicy;
+ SI_32 schedPriority;
+} FrameworkunifiedChildThreadAttr;
+
+#endif /* __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_FRAMEWORK_TYPES_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_multithreading.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_multithreading.h
new file mode 100644
index 00000000..b9435969
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_multithreading.h
@@ -0,0 +1,745 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Application framework's core structures and data types.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_multithreading.h
+ * @brief \~english Application framework's core structures and data types.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__ // NOLINT (build/header_guard)
+#define __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__
+
+#include <native_service/frameworkunified_framework_types.h>
+
+#define INHERIT_PARENT_THREAD_PRIO -100
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateChildThread
+/// \~english @par Brief
+/// Create child thread and dispatcher for child thread, and initialize it
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] childName
+/// PCSTR - Child thread name
+/// \~english @param [in] CbInitialize
+/// CbFuncPtr - Pointer to the callback function for initializing child thread
+/// \~english @param [in] CbShutdown
+/// CbFuncPtr - Pointer to the callback function for stopping child thread
+/// \~english @retval HANDLE handle for communicate with child thread
+/// \~english @retval NULL Failure to get HANDLE
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
+/// - Callback function pointer specified in the argument (CbInitialize, CbShutdown) is NULL. [NULL]
+/// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
+/// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
+/// - Failed to create child thread (pthread_create). [NULL]
+/// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+/// \~english @par Detail
+/// This API creates child thread and returns handle for communicate with child thread.\n
+/// Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
+/// It starts to mainloop that receives request or notification,
+/// and runs registered callback to dispatcher for child thread.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// FrameworkunifiedDestroyChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateChildThreadWithPriority
+/// \~english @par Brief
+/// Create child thread with specified priority and dispatcher for child thread, and initialize it
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] childName
+/// PCSTR - Child thread name
+/// \~english @param [in] CbInitialize
+/// CbFuncPtr - Pointer to the callback function for initializing child thread
+/// \~english @param [in] CbShutdown
+/// CbFuncPtr - Pointer to the callback function for stopping child thread
+/// \~english @param [in] schedPrio
+/// SI_32 - priority of child thread
+/// (If INHERIT_PARENT_THREAD_PRIO specified, inherit from parent thread priority)
+/// \~english @retval HANDLE handle for communicate with child thread
+/// \~english @retval NULL Failure to get HANDLE
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
+/// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
+/// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
+/// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
+/// - Failed to create child thread (pthread_create). [NULL]
+/// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+/// \~english @par Detail
+/// This API creates child thread with specified priority(schedPrio) and
+/// returns handle for communicate with child thread.\n
+/// The thread scheduling policy of generated child thread is fixed to first in-first out scheduling
+/// (eFrameworkunifiedSchedPolicyFIFO).\n
+/// Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
+/// It starts to mainloop that receives request or notification,
+/// and runs registered callback to dispatcher for child thread.\n
+/// \n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// FrameworkunifiedDestroyChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
+ , CbFuncPtr CbShutdown, SI_32 schedPrio);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateDispatcherChild
+/// \~english @par Breif
+/// Creates and initializes a handle for the child thread's application
+/// \~english @param [out] hChildApp
+/// HANDLE & - A handle for the child thread's application
+/// \~english @param [in] childName
+/// PCSTR - Child thread name
+/// \~english @param [in] parentName
+/// PCSTR - Parent thread name
+/// \~english @retval eFrameworkunifiedStatusOK succss
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusNullPointer Framework generation failure
+/// \~english @par Prerequisite
+/// - A child thread has been created.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If the childName to the child thread name of the application specified in the arguments is NULL [eFrameworkunifiedStatusInvldParam]
+/// - If the parentName to the parent thread name of the application specified in the arguments is NULL [eFrameworkunifiedStatusInvldParam]
+/// - When the parent thread name (parentName) of the application specified in the arguments exceeds 16 bytes [eFrameworkunifiedStatusInvldParam]
+/// - When the normalized message queue name from the childName specified in the arguments exceeds 16 bytes [eFrameworkunifiedStatusNullPointer]
+/// - Failed to open a message queue (mq_open) [eFrameworkunifiedStatusNullPointer]
+/// - When acquisition (malloc) of the message queue management information area fails [eFrameworkunifiedStatusNullPointer]
+/// - If the creation (socket, bind, listen) of sockets for error monitoring fails [eFrameworkunifiedStatusFail]
+/// - When a message queue is created with the name of an already registered thread [eFrameworkunifiedStatusFail]
+/// - Failed to create epoll instances (epoll_create1) [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register Dispatcher message queue descriptor for epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - Failed to create file descriptor for receiving events to Dispatcher (eventfd) [eFrameworkunifiedStatusFail]
+/// - Failed to register file descriptor for receiving Dispatcher events to epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// - Failed to register socket for monitoring Dispatcher error in epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API creates a handle for the application of the child thread, initializes it, and returns the handle.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+///
+/// \~english @par Brief
+/// Create and initialize an threads dispatcher.
+///
+/// \~english \param [out] hChildApp
+/// HANDLE& - Reference of application handle
+/// \~english \param [in] childName
+/// PCSTR - create thread name
+/// \~english \param [in] parentName
+/// PCSTR - parent thread name
+///
+/// \~english \return status
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
+/// possible errors from call CreateDispatcher
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherChild(HANDLE &hChildApp, PCSTR childName, PCSTR parentName); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateChildThreadWithAttribute
+/// \~english @par Brief
+/// Create child thread with specified thread attributes and dispatcher for child thread, and initialize it
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] childName
+/// PCSTR - Child thread name
+/// \~english @param [in] CbInitialize
+/// CbFuncPtr - Pointer to the callback function for initializing child thread
+/// \~english @param [in] CbShutdown
+/// CbFuncPtr - Pointer to the callback function for stopping child thread
+/// \~english @param [out] attr
+/// FrameworkunifiedChildThreadAttr* - Pointer to thread attributes
+/// \~english @par
+/// FrameworkunifiedChildThreadAttr Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedChildThreadAttr
+/// {
+/// EFrameworkunifiedSchedPolicy schedPolicy; // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
+/// SI_32 schedPriority; // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
+/// } FrameworkunifiedChildThreadAttr;
+/// @endcode
+/// \~english @par
+/// enum EFrameworkunifiedSchedPolicy Variable
+/// \~english @code
+/// typedef enum _EFrameworkunifiedSchedPolicy {
+/// eFrameworkunifiedSchedPolicyInherit = 0, // Inherit from parent thread.
+/// eFrameworkunifiedSchedPolicyTSS, // Time Sharing System scheduling
+/// eFrameworkunifiedSchedPolicyFIFO, // First in-first out scheduling
+/// eFrameworkunifiedSchedPolicyRR, // Round-robin scheduling
+/// eFrameworkunifiedSchedPolicyMAX // EFrameworkunifiedSchedPolicy Max(Not to be used.)
+/// } EFrameworkunifiedSchedPolicy;
+/// @endcode
+/// \~english @retval HANDLE handle for communicate with child thread
+/// \~english @retval NULL Failure to get HANDLE
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
+/// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
+/// - Thread attribute specified in the argument (attr) is NULL. [NULL]
+/// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
+/// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
+/// - Failed to create child thread (pthread_create). [NULL]
+/// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+/// \~english @par Detail
+/// This API creates child thread with specified thread attributes(attr)
+/// and returns handle for communicate with child thread.\n
+/// Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
+/// It starts to mainloop that receives request or notification,
+/// and runs registered callback to dispatcher for child thread.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// FrameworkunifiedDestroyChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateChildThreadWithAttribute(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
+ , CbFuncPtr CbShutdown, const FrameworkunifiedChildThreadAttr *attr);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateChildThreadAttrInit
+/// \~english @par Brief
+/// Initialize thread attribute object.
+/// \~english @param [out] attr
+/// FrameworkunifiedChildThreadAttr* - Pointer to thread attribute
+/// \~english @par
+/// FrameworkunifiedChildThreadAttr Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedChildThreadAttr
+/// {
+/// EFrameworkunifiedSchedPolicy schedPolicy; // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
+/// SI_32 schedPriority; // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
+/// } FrameworkunifiedChildThreadAttr;
+/// @endcode
+/// \~english @par
+/// enum EFrameworkunifiedSchedPolicy Variable
+/// \~english @code
+/// typedef enum _EFrameworkunifiedSchedPolicy {
+/// eFrameworkunifiedSchedPolicyInherit = 0, // Inherit from parent thread.
+/// eFrameworkunifiedSchedPolicyTSS, // Time Sharing System scheduling
+/// eFrameworkunifiedSchedPolicyFIFO, // First in-first out scheduling
+/// eFrameworkunifiedSchedPolicyRR, // Round-robin scheduling
+/// eFrameworkunifiedSchedPolicyMAX // EFrameworkunifiedSchedPolicy Max(Not to be used.)
+/// } EFrameworkunifiedSchedPolicy;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - the argument attr is NULL. [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// This API initialize thread attribute (attr) by default value of NS framework.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedCreateChildThreadWithAttribute
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateChildThreadAttrSetSched
+/// \~english @par Brief
+/// Initialize thread attribute object with specified value.
+/// \~english @param [out] attr
+/// FrameworkunifiedChildThreadAttr* - Pointer to thread attribute
+/// \~english @param [in] policy
+/// EFrameworkunifiedSchedPolicy - Thread shcheduling policy at thread start
+/// \~english @param [in] priority
+/// SI_32 - Thread priority at thread start
+/// \~english @par
+/// FrameworkunifiedChildThreadAttr Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedChildThreadAttr
+/// {
+/// EFrameworkunifiedSchedPolicy schedPolicy; // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
+/// SI_32 schedPriority; // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
+/// } FrameworkunifiedChildThreadAttr;
+/// @endcode
+/// \~english @par
+/// enum EFrameworkunifiedSchedPolicy Variable
+/// \~english @code
+/// typedef enum _EFrameworkunifiedSchedPolicy {
+/// eFrameworkunifiedSchedPolicyInherit = 0, // Inherit from parent thread.
+/// eFrameworkunifiedSchedPolicyTSS, // Time Sharing System scheduling
+/// eFrameworkunifiedSchedPolicyFIFO, // First in-first out scheduling
+/// eFrameworkunifiedSchedPolicyRR, // Round-robin scheduling
+/// eFrameworkunifiedSchedPolicyMAX // EFrameworkunifiedSchedPolicy Max(Not to be used.)
+/// } EFrameworkunifiedSchedPolicy;
+/// @endcode
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @par Prerequisite
+/// None
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - the argument attr is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - the argument policy is out of range
+/// (less than eFrameworkunifiedSchedPolicyInherit, over eFrameworkunifiedSchedPolicyMAX). [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// This API initializes thread attribute object for child thread with specified value.\n
+/// \n
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// FrameworkunifiedCreateChildThreadWithAttribute
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedStartChildThread
+/// \~english @par Brief
+/// Send initialize request to the child thread.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] hChildQ
+/// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
+/// \~english @param [in] length
+/// UI_32 - Length of send message data
+/// \~english @param [in] data
+/// PCVOID - Pointer to message data
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state is depend on application implements.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Thread name specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
+/// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
+/// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API sends initialize request to the child thread from parent thread.\n
+/// Taking this request,
+/// child thread runs callback function for initialize that specified when the thread create.
+/// \~english @par
+/// \n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Open Close
+/// \~english @see
+/// FrameworkunifiedStopChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedStartChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedStopChildThread
+/// \~english @par Brief
+/// Send shutdown request to the child thread.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] hChildQ
+/// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
+/// \~english @param [in] length
+/// UI_32 - Length of send message data
+/// \~english @param [in] data
+/// PCVOID - Pointer to message data
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state is depend on application implements.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Thread name specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
+/// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
+/// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API sends shutdown request to the child thread.\n
+/// Taking this request,
+/// child thread runs callback function for shutdown that specified when the thread create.\n
+/// This API does not terminate child thread.
+/// Use FrameworkunifiedDestroyChildThread to terminate child thread from parent thread.
+/// \~english @par
+/// \n
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// FrameworkunifiedStartChildThread FrameworkunifiedDestroyChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedStopChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDestroyChildThread
+/// \~english @par Brief
+/// Terminate child thread.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] hChildQ
+/// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
+/// \~english @retval eFrameworkunifiedStatusThreadSelfJoin Self thread specified
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread
+/// (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state is depend on application implements.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Thread name specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
+/// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+/// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Message data size is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
+/// - Child thread is invalid (thread exit or invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Another thread is already waiting to join with this child thread. [eFrameworkunifiedStatusInvldParam]
+/// - Already child thread is in termination process [eFrameworkunifiedStatusInvldParam]
+/// - Thread specified in argument is self thread. [eFrameworkunifiedStatusThreadSelfJoin]
+/// - Failed to close message queue specified in the argument (hChildQ). [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// This API sends terminate request to child thread , and waits to terminate child thread.\n
+/// Taking this request, child thread terminates itself.\n
+/// After child thread terminates, parent thread destroys handle for communicate with child thread.
+/// \~english @par Classification
+/// Public
+/// \~english @see FrameworkunifiedCreateChildThread FrameworkunifiedCreateChildThreadWithAttribute FrameworkunifiedCreateChildThreadWithPriority
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDestroyChildThread(HANDLE hApp, HANDLE hChildQ);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSendChild
+/// \~english @par Brief
+/// Send a message to the child thread.
+/// \~english @param [in] hApp
+/// HANDLE - Handle for Application of parent thread
+/// \~english @param [in] hChildQ
+/// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
+/// \~english @param [in] iCmd
+/// UI_32 - Command of message
+/// \~english @param [in] length
+/// UI_32 - Length of send message data
+/// \~english @param [in] data
+/// PCVOID - Pointer to message data
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Thread name specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
+/// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
+/// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API sends a message to the child thread from parent thread.\n
+/// This API is available only from parent thread.
+/// \~english @par
+/// \n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedSendParent
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendChild(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd, UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSendParent
+/// \~english @par Brief
+/// Send a message to the parent thread.
+/// \~english @param [in] hChildApp
+/// HANDLE - Handle for Application of child thread(get as argument of callback function)
+/// \~english @param [in] iCmd
+/// UI_32 - Command of message
+/// \~english @param [in] length
+/// UI_32 - Length of send message data
+/// \~english @param [in] data
+/// PCVOID - Pointer to message data
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue for parent thread in HANDLE (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue for parent thread in HANDLE (hChildApp) is not appropriate
+/// (which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Thread name specified in the argument (hChildApp) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
+/// - The name of message queue for parent thread specified in the argument (hChildApp) is not appropriate
+/// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
+/// - Type of message queue to parent thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Any errors occur during the transmission of message to the parent thread. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// This API sends a message to the parent thread from child thread.\n
+/// This API is available only from child thread.
+/// \~english @par
+/// \n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedSendChild
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSendParent(HANDLE hChildApp, UI_32 iCmd, UI_32 length, PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedJoinChild
+/// \~english @par Brief
+/// Wait for child thread terminates.
+/// \~english @param [in] hChildApp
+/// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusThreadSelfJoin Self thread specified
+/// \~english @retval eFrameworkunifiedStatusFail thread exit or invalid
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Child thread is invalid (thread exit or invalid) [eFrameworkunifiedStatusFail]
+/// - Another thread is already waiting to join with this child thread. [eFrameworkunifiedStatusInvldParam]
+/// - Already child thread is in termination process [eFrameworkunifiedStatusInvldParam]
+/// - Thread specified in argument is self thread. [eFrameworkunifiedStatusThreadSelfJoin]
+/// \~english @par Detail
+/// It waits for terminate of child thread it was created by FrameworkunifiedCreateChildThread
+/// (or similar one) in the parent thread.\n
+/// This API blocks the calling thread until child thread terminates.\n
+/// This API does not terminate child thread.
+/// Use FrameworkunifiedDestroyChildThread to terminate child thread from parent thread.
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// FrameworkunifiedCreateChildThread, FrameworkunifiedCreateChildThreadWithPriority, FrameworkunifiedDestroyChildThread
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedJoinChild(HANDLE hChildApp);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetChildThreadPriority
+/// \~english @par Brief
+/// Get the child thread priority.
+/// \~english @param [in] hChildApp
+/// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
+/// \~english @param [out] threadPrio
+/// PSI_32 - Dispatcher file descriptor
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
+/// \~english @retval eFrameworkunifiedStatusFault Error occured during function
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hChildApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - child thread priority in the argument (threadPrio) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - Failed to get child thread priority (pthread_getschedparam). [eFrameworkunifiedStatusFault]
+/// - If child threads are inalid or already terminated. [eFrameworkunifiedStatusThreadNotExist]
+/// \~english @par Detail
+/// This API set the child thread priority generated by FrameworkunifiedCreateChildThread to argument threadPrio.
+/// Use to get child thread priority from parent thread.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// FrameworkunifiedCreateChildThread, FrameworkunifiedCreateChildThreadWithPriority
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio);
+#endif // __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_service_if.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_service_if.h
new file mode 100644
index 00000000..b142d110
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_service_if.h
@@ -0,0 +1,267 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_service_if.h
+ * @brief \~english This is base class for service interface classes
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __CSERVICESESSION_H__ // NOLINT (build/header_guard)
+#define __CSERVICESESSION_H__
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////
+/// class: CServiceSession
+/// Description: This is base class for service interface classes
+///
+////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedServiceInterface {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// Constructor for CFrameworkunifiedServiceInterface
+ /// \~english @retval none
+ /// \~english @par Preconditions
+ /// no preconditions
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// create CFrameworkunifiedServiceInterface class instance
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see ~CFrameworkunifiedServiceInterface
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedServiceInterface();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedServiceInterface
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// CFrameworkunifiedServiceInterface is decleared in constructor
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Release CFrameworkunifiedServiceInterface instance
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedServiceInterface
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFrameworkunifiedServiceInterface();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// API to open Service.
+ /// \~english @param [in] f_hApp
+ /// HANDLE* - Handle of framework
+ /// \~english @param [in] f_sServiceName
+ /// std::string - Service Name
+ /// \~english @retval HANDLE
+ /// \~english @par Preconditions
+ /// - no preconditions
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Open service by specified name and retrun handle of service. \n
+ /// If FrameworkunifiedOpenService failed, handle is NULL.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedOpenService
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ HANDLE OpenService(const HANDLE f_hApp, std::string f_sServiceName);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// API to close service.
+ /// \~english @param [in] f_hApp
+ /// HANDLE* - Handle of framework
+ /// \~english @param [in] f_hService
+ /// HANDLE - Handle of the service
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If parameter f_hApp is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - If parameter f_hService is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - If FrameworkunifiedCloseService failed. [eFrameworkunifiedStatusInvldHandle]
+ /// \~english @par Detail
+ /// close service by handle \n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedCloseService
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CloseService(const HANDLE f_hApp, const HANDLE f_hService);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// API to open session
+ /// \~english @param [in] f_hApp
+ /// HANDLE* -framework handle
+ /// \~english @param [in] f_uisessionType
+ /// UI_32 - sessiontype
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If parameter f_hApp is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - If FrameworkunifiedOpenSessionWithData failed. [eFrameworkunifiedStatusInvldHandle]
+ /// \~english @par Detail
+ /// open session by specified session type \n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedOpenSessionWithData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OpenSession(const HANDLE f_hApp, UI_32 f_uisessionType);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// API to open session Acknowledge
+ /// \~english @param [in] f_hApp
+ /// HANDLE* - Handle of framework
+ /// \~english @param [in] hSession
+ /// HANDLE - Session Handle
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Empty implement.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see one
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus OpenSessionAcknowledge(const HANDLE f_hApp, HANDLE &hSession); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// API to close session.
+ /// \~english @param [in] f_hService
+ /// HANDLE* - Handle of service
+ /// \~english @param [in] hSession
+ /// HANDLE - Session Handle
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If parameter f_hService is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - If parameter f_hSession is NULL. [eFrameworkunifiedStatusInvldParam]
+ /// - If FrameworkunifiedCloseSession failed. [eFrameworkunifiedStatusInvldHandle]
+ /// \~english @par Detail
+ /// close session of specified service. \n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedCloseSession
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CloseSession(const HANDLE f_hService, const HANDLE f_hSession);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedServiceInterface
+ /// \~english @par Brief
+ /// API to close session.
+ /// \~english @param [in] f_hService
+ /// HANDLE* - Handle of service
+ /// \~english @param [in] hSession
+ /// HANDLE - Session Handle
+ /// \~english @retval EFrameworkunifiedStatus
+ /// Success or Error
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If parameter hClient is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If FrameworkunifiedGetMsgDataOfSize failed. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Check close session acknowledge.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedGetMsgDataOfSize
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CloseSessionAcknowledge(const HANDLE hClient);
+};
+#endif // __CSERVICESESSION_H__ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_service_protocol.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_service_protocol.h
new file mode 100644
index 00000000..e66119e9
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_service_protocol.h
@@ -0,0 +1,116 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NativeServices
+/// \brief
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_service_protocol.h
+ * @brief \~english Include enums, structs and frameworkunified_types.h
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef FRAMEWORKUNIFIED_SERVICE_PROTOCOL_H_ // NOLINT (build/header_guard)
+#define FRAMEWORKUNIFIED_SERVICE_PROTOCOL_H_
+
+#include <native_service/frameworkunified_types.h>
+
+#define NS_INVALID_SESSION 0xFFFF
+
+typedef enum _EBaseProtocol {
+ PROTOCOL_OPEN_SESSION_REQ = 0x00, ///< Open session request (client > service)
+ PROTOCOL_OPEN_SESSION_ACK = 0x01, ///< Open session ack (service > client)
+ PROTOCOL_OPEN_SESSION_REQ_SYNC = 0x02, ///< Open session request sync (client > service)
+ PROTOCOL_CLOSE_SESSION_REQ = 0x03, ///< Close session request (client > service)
+ PROTOCOL_CLOSE_SESSION_ACK = 0x04, ///< Close session ack (service > client)
+ PROTOCOL_CLOSE_SESSION_REQ_SYNC = 0x05, ///< Close session request sync (client > service)
+
+ PROTOCOL_REGISTER_EVENTS = 0x06, ///< Register for events (client > service)
+ PROTOCOL_REGISTER_EVENTS_ACK = 0x07, ///< Register for events ack (service > client)
+ PROTOCOL_UNREGISTER_EVENTS = 0x08, ///< Un-Register for events (client > service)
+
+ PROTOCOL_THREAD_INITIALIZATION = 0x09, ///< Initialize thread after creation
+ PROTOCOL_THREAD_WAKEUP = 0x0A, ///< Wakeup Thread after sleep
+ PROTOCOL_THREAD_SHUTDOWN = 0x0B, ///< Stop the thread
+ PROTOCOL_THREAD_DESTROY = 0x0C, ///< Destroy the thread
+ PROTOCOL_RSV_0D = 0x0D, ///< Reserved
+ PROTOCOL_RSV_0E = 0x0E, ///< Reserved
+ PROTOCOL_DIS_MSGPROFILER = 0x0F, ///< Reserved
+
+ PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD = 0x10, ///< Protocols between range PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD
+ PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD = 0xFFFFFFF0, ///< are available for FRAMEWORKUNIFIED applications to use.
+
+ PROTOCOL_RSV_xF1 = 0xFFFFFFF1, ///< Reserved
+ PROTOCOL_RSV_xF2 = 0xFFFFFFF2, ///< Reserved
+ PROTOCOL_RSV_xF3 = 0xFFFFFFF3, ///< Reserved
+ PROTOCOL_RSV_xF4 = 0xFFFFFFF4, ///< Reserved
+ PROTOCOL_RSV_xF5 = 0xFFFFFFF5, ///< Reserved
+ PROTOCOL_RSV_xF6 = 0xFFFFFFF6, ///< Reserved
+ PROTOCOL_RSV_xF7 = 0xFFFFFFF7, ///< Reserved
+ PROTOCOL_RSV_xF8 = 0xFFFFFFF8, ///< Reserved
+ PROTOCOL_RSV_xF9 = 0xFFFFFFF9, ///< Reserved
+ PROTOCOL_RSV_xFA = 0xFFFFFFFA, ///< Reserved
+ PROTOCOL_RSV_xFB = 0xFFFFFFFB, ///< Reserved
+ PROTOCOL_RSV_xFC = 0xFFFFFFFC, ///< Reserved
+
+ PROTOCOL_TIMER_DUMMY_CMD = 0xFFFFFFFD, ///< NS internally use this command in timer
+
+ PROTOCOL_FRAMEWORKUNIFIED_NOTIFICATION = 0xFFFFFFFE,
+ PROTOCOL_FRAMEWORKUNIFIED_ANY_COMMAND = 0xFFFFFFFF
+} EBaseProtocol;
+
+typedef struct _OpenSessionAck {
+ EFrameworkunifiedStatus eStatus;
+ UI_32 sessionId;
+ CHAR cSessionName[MAX_QUEUE_NAME_SIZE];
+ UI_32 sessionType;
+} OpenSessionAck;
+
+
+typedef struct _CloseSessionReq {
+ UI_32 sessionId;
+ CHAR cSessionName[MAX_QUEUE_NAME_SIZE];
+} CloseSessionReq;
+
+typedef struct _CloseSessionAck {
+ UI_32 sessionId;
+ EFrameworkunifiedStatus eStatus;
+} CloseSessionAck;
+
+#endif /* FRAMEWORKUNIFIED_SERVICE_PROTOCOL_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_action.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_action.h
new file mode 100644
index 00000000..58dbf225
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_action.h
@@ -0,0 +1,150 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief This file has class declaration of the CFrameworkunifiedAction. This is an
+/// interface class that defines interfaces for implementing action
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_action.h
+ * @brief \~english This file has class declaration of the CFrameworkunifiedAction. This is an interface class that defines
+ * interfaces for implementing action
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMACTION_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMACTION_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <boost/smart_ptr.hpp>
+#include <string>
+
+class CFrameworkunifiedState;
+
+class CEventData;
+typedef boost::shared_ptr<CEventData> CEventDataPtr;
+
+class CFrameworkunifiedAction {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedAction
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedAction.
+ /// \~english @param [in] f_strName
+ /// std::string -Name of Action object
+ /// \~english @retval
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Constructor of CFrameworkunifiedAction class. Create an object of CFrameworkunifiedAction. \n
+ /// Initialize member value with name designated by f_strName. \n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see ~CFrameworkunifiedAction
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedAction(std::string f_strName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedAction
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedAction
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// none
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Pure virtual function , implemented by child class
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedAction
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedAction() {
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedAction
+ /// \~english @par Brief
+ /// Callback function of CFrameworkunifiedAction.(pure virtual function)
+ /// \~english @param [in] f_pSourceState
+ /// CFrameworkunifiedState - pointer of source state
+ /// \~english @param [in] f_pTargetState
+ /// CFrameworkunifiedState - pointer of target state
+ /// \~english @param [in] f_pData
+ /// CEventDataPtr - pointer of event data
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - none
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// Callback function of CFrameworkunifiedAction.(pure virtual function)
+ /// Implement action by subclass
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual VOID FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState,
+ CEventDataPtr f_pData) = 0;
+
+ // action name
+ std::string m_strName;
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMACTION_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_compositestate.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_compositestate.h
new file mode 100644
index 00000000..72ac6400
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_compositestate.h
@@ -0,0 +1,434 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedCompositeState class definitions. CFrameworkunifiedCompositeState is derived from C
+/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Composite
+/// state. It provides the standard interfaces for adding state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_compositestate.h
+ * @brief \~english This file has the CFrameworkunifiedCompositeState class definitions. CFrameworkunifiedCompositeState is derived from C
+ * FrameworkunifiedState class.This class implements the additional functionality supported by HSM Composite
+ * state. It provides the standard interfaces for adding state.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDCOMPOSITESTATE_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDCOMPOSITESTATE_H
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_state.h>
+#include <map>
+#include <string>
+
+typedef std::map<std::string, CFrameworkunifiedState *> ChildStateList;
+typedef std::map<std::string, CFrameworkunifiedState *>::iterator StateIterator;
+
+class CFrameworkunifiedHSM;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM Composite
+/// state. It provides the standard interfaces for adding state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedCompositeState : public CFrameworkunifiedState {
+ public :
+
+ typedef enum _FRAMEWORKUNIFIED_STATE_TYPE {
+ eFrameworkunifiedState = 0,
+ eFrameworkunifiedDefaultState
+ } FRAMEWORKUNIFIED_STATE_TYPE;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedCompositeState.
+ /// \~english @param [in] f_strName
+ /// std::string -Name of state
+ /// \~english @retval
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// This class inherit from CFrameworkunifiedState(basic class of state machine), \n
+ /// and create object of CFrameworkunifiedCompositeState class. \n
+ /// Create and initialize child state, and set the pointor to member variable. \n
+ /// Initialize other member variables with NULL. \n
+ /// Output the process error logs.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState, ~CFrameworkunifiedCompositeState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedCompositeState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedCompositeState
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Release the objects of CFrameworkunifiedState class and CFrameworkunifiedCompositeState class. \n
+ /// Release all the child states registered in child states list of member variable. \n
+ /// Output error log if failed.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState, CFrameworkunifiedCompositeState::CFrameworkunifiedCompositeState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedCompositeState();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// sets the given state as a substate of the current state. If the f_eStateType is
+ /// eFrameworkunifiedDefaultState then substate is default state for current state.
+ /// \~english @param [in] f_pState
+ /// CFrameworkunifiedState* - Pointer to the substate object to be added in the current state
+ /// \~english @param [in] f_eStateType
+ /// FRAMEWORKUNIFIED_STATE_TYPE - state type indicating if it is default state
+ /// \~english @retval EFrameworkunifiedStatus
+ /// success or fail
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If parameter f_pState is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If m_pChildStates is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// sets the given state as a substate of the current state. If the f_eStateType is
+ /// eFrameworkunifiedDefaultState then substate is default state for current state.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedAddState(CFrameworkunifiedState *f_pState,
+ FRAMEWORKUNIFIED_STATE_TYPE f_eStateType = eFrameworkunifiedState);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Returns the default state of the current composite state.
+ /// \~english @param none
+ /// \~english @retval CFrameworkunifiedState* - pointer default state
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Returns the default state of the current composite state.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedState *FrameworkunifiedGetDefaultState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Logs the state name and events associated with the state.
+ /// \~english @param none
+ /// \~english @retval eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer failed
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - Don't create instance of CFrameworkunifiedCompositeState [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This function overrides the fuction of CFrameworkunifiedState::FrameworkunifiedPrintStates.
+ /// This function outputs log of state name and events associated with the state as follows:
+ /// - state name of parent state machine and self state machine
+ /// - all the event names in event list
+ /// - all the event names in delay event list
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedPrintStates();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// This indicates if the state has sub states. It returns TRUE only in the CompositeState
+ /// where this function is overridden
+ /// \~english @param none
+ /// \~english @retval BOOL TRUE - has substate FALSE - has not substatue
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// This function overrides the fuction of CFrameworkunifiedState::FrameworkunifiedHasSubStates.
+ /// Return true only in CFrameworkunifiedCompositeState class.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedHasSubStates
+ virtual BOOL FrameworkunifiedHasSubStates();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// This interface returns the Active state of the current composite state. In case of
+ /// non-composite state current state is active state
+ /// \~english @param none
+ /// \~english @retval CFrameworkunifiedState* pointer of active state
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// This function overrides the pure virtual fuction of CFrameworkunifiedState::FrameworkunifiedGetActiveState.
+ /// Reture active state of current composite state. If it isn't a composite state,
+ /// return current state as an active state.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedGetActiveState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// This function stores the last active state
+ /// \~english @param none
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// This function overrides the pure virtual fuction of CFrameworkunifiedState::UpdateHistory.
+ /// Store the last active state.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState::UpdateHistory
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UpdateHistory();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Update the State information in the given stream in the form of XML tags
+ ///
+ /// \~english @param f_strXMLString
+ /// std::ostringstream & - reference to the XML stream
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK
+ /// eFrameworkunifiedStatusNullPointer
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedCompositeState created.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal status
+ /// - Self instance of CFrameworkunifiedCompositeState created failed. [eFrameworkunifiedStatusNullPointer].
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Detail
+ /// This function overrides the fuction of CFrameworkunifiedState::FrameworkunifiedPrintXML.
+ /// Set parameter f_strXMLString with the following state information by XML type.
+ /// - state name
+ /// - all the event information in event list(event ID, event name)
+ /// - all the event information in delay event list(event ID, event name)
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedPrintXML
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString);
+
+
+ protected :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Initialize state
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @par Preconditions
+ /// - Its own instance (CFrameworkunifiedCompositeState) has been created.
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This method overrides and uses CFrameworkunifiedState::FrameworkunifiedOnEntry, which is pure virtual functions, to initialize state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedOnEntry, FrameworkunifiedOnExit
+ ///
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Clean up state.
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @par Preconditions
+ /// - Its own instance (CFrameworkunifiedCompositeState) has been created.
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This method overrides and uses CFrameworkunifiedState::FrameworkunifiedOnExit, which is pure virtual functions, to clean up state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedOnExit, FrameworkunifiedOnEntry
+ ///
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData);
+
+ /// stores the pointers to sub state, key is state name
+ ChildStateList *m_pChildStates;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedCompositeState
+ /// \~english @par Brief
+ /// Associate the state machine with the current state.
+ /// \~english @param [in] f_pStatemachine
+ /// CFrameworkunifiedHSM* - Pointers to state machines (CFrameworkunifiedHSM classes)
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+ /// \~english @par Preconditions
+ /// - Its own instance (CFrameworkunifiedCompositeState) has been created.
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - When the pointers to the state machines (CFrameworkunifiedHSM classes) specified in the arguments (f_pStatemachine) are NULL [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This method is used by overriding CFrameworkunifiedState::FrameworkunifiedSetHSM.\n
+ /// Associates a state machine with the current state by setting a pointer (f_pStatemachine)
+ /// to the state machine (CFrameworkunifiedHSM) specified by the argument to the pointer to the state machine of the member variable. \n
+ /// Calling FrameworkunifiedSetHSM() for child states also associates the state machine of the child states with the state of the current state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedHSM, CFrameworkunifiedState::FrameworkunifiedSetHSM
+ ///
+ /// Sets the statemachine in the status
+ ///
+ /// \param [in] f_pStatemachine
+ /// CFrameworkunifiedHSM* - Statemachine pointer
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine);
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CheckHistory
+ /// This function searches for history state in this composite state and updates it.
+ ///
+ /// \param [in] l_cHistoryType
+ /// string - Type of history state (shallow or deep)
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CheckHistory(std::string l_cHistoryType);
+};
+
+#endif // _FRAMEWORKUNIFIEDCOMPOSITESTATE_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_conditionconnector.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_conditionconnector.h
new file mode 100644
index 00000000..110c1517
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_conditionconnector.h
@@ -0,0 +1,203 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+/// This file has class declaration of the CFrameworkunifiedConditionConnector. This class is responsible for
+/// implementing interfaces required to use condition connector in statemachine.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_conditionconnector.h
+ * @brief \~english This file has class declaration of the CFrameworkunifiedConditionConnector. This class is responsible for
+ * implementing interfaces required to use condition connector in statemachine.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMCONDITIONCONNECTOR_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMCONDITIONCONNECTOR_H__
+
+#include <native_service/frameworkunified_sm_externaltransition.h>
+#include <string>
+#include <vector>
+
+// This class is responsible for implementing interfaces required to use condition connector in statemachine.
+class CFrameworkunifiedConditionConnector : public CFrameworkunifiedExternalTransition {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedConditionConnector
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedConditionConnector.
+ /// \~english @param [in] f_strName
+ /// std::string - Name of the condition connector
+ /// \~english @retval
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Inherite from base class CFrameworkunifiedExternalTransition.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedExternalTransition, ~CFrameworkunifiedConditionConnector
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedConditionConnector(std::string f_strName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedConditionConnector
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedCompositeState
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedConditionConnector created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Class CFrameworkunifiedExternalTransition instance and CFrameworkunifiedConditionConnector instance release.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedConditionConnector::CFrameworkunifiedConditionConnector
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedConditionConnector();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedConditionConnector
+ /// \~english @par Brief
+ /// This API evaluates the guards added in the condition list. If the guard is evaluated as
+ /// true then statemachine transitions to target state associated with guard.
+ /// \~english @param [in] f_pSourceState
+ /// CFrameworkunifiedState* - Source state in which reaction is being executed
+ /// \~english @param [in] f_pData
+ /// CEventDataPtr - event data
+ /// \~english @retval CFrameworkunifiedState*
+ /// CFrameworkunifiedState* - Returns Active state
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedConditionConnector created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If parameter f_pSourceState is NULL. [NULL]
+ /// - If m_pConditionList is NULL. [NULL]
+ /// \~english @par Detail
+ /// This API evaluates the guards added in the condition list. If the guard is evaluated as
+ /// true then statemachine transitions to target state associated with guard.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedConditionConnector
+ /// \~english @par Brief
+ /// Adds connect condition into condition list of current connection
+ /// \~english @param [in] f_pGuard
+ /// CFrameworkunifiedState* - Pointer to the guard object to be added in the currrent connection
+ /// \~english @param [in] f_pTargetState
+ /// CFrameworkunifiedState* - Target state for given guard condition
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK
+ /// eFrameworkunifiedStatusNullPointer
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedConditionConnector created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If m_pConditionList is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If parameter f_pGuard is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If parameter f_pTargetState is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Adds connect condition into condition list of current connection.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedAddCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState);
+
+ private:
+ // This class defines the conditions required in condition connector
+ class CCondition {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CCondition
+ /// Parameterized constructor
+ /// \param [in] f_pGuard
+ /// CFrameworkunifiedGuard* - guard object
+ /// \param [in] f_pTargetState
+ /// CFrameworkunifiedState* - target state for a condition
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CCondition(CFrameworkunifiedGuard *f_pGuard, CFrameworkunifiedState *f_pTargetState);
+
+ // pointer to guard that will be evaluated for a condition
+ CFrameworkunifiedGuard *m_pGuard;
+
+ // pointer to target state for a condition
+ CFrameworkunifiedState *m_pTargetState;
+ };
+
+ // Condition list
+ typedef std::vector<CCondition *> TConditionList;
+
+ // Condition list iterator
+ typedef TConditionList::iterator TConditionIterator;
+
+ // condition connector name
+ std::string m_strName;
+
+ // List of conditions
+ TConditionList *m_pConditionList;
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMCONDITIONCONNECTOR_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_deephistorystate.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_deephistorystate.h
new file mode 100644
index 00000000..fbb74eeb
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_deephistorystate.h
@@ -0,0 +1,141 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the declaration of class CFrameworkunifiedDeepHistoryState . CFrameworkunifiedDeepHistoryState is
+/// derived from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported
+/// by HSM Deep History state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_deephistorystate.h
+ * @brief \~english This file has the declaration of class CFrameworkunifiedDeepHistoryState.CFrameworkunifiedDeepHistoryState is
+ * derived from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported
+ * by HSM Deep History state.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_SM_DEEPHISTORYSTATE_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_SM_DEEPHISTORYSTATE_H__
+
+#include <native_service/frameworkunified_sm_historystate.h>
+#include <string>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM Shallow History state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedDeepHistoryState : public CFrameworkunifiedHistoryState {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedDeepHistoryState
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedDeepHistoryState.
+ /// \~english @param [in] f_pName
+ /// std::string - Name of the state
+ /// \~english @retval
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Inherite from base class CFrameworkunifiedHistoryState.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedHistoryState, ~CFrameworkunifiedDeepHistoryState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedDeepHistoryState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedDeepHistoryState
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedDeepHistoryState
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedDeepHistoryState created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Class CFrameworkunifiedHistoryState instance and CFrameworkunifiedDeepHistoryState instance release.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedDeepHistoryState::CFrameworkunifiedDeepHistoryState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ~CFrameworkunifiedDeepHistoryState();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedDeepHistoryState
+ /// \~english @par Brief
+ /// This function stores the last active state
+ /// \~english @param
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK
+ /// eFrameworkunifiedStatusNullPointer
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedConditionConnector created.
+ /// \~english @par Change of internal status
+ /// - none
+ /// \~english @par Conditions of processing failure
+ /// - If m_pParentState is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This function stores the last active state.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UpdateHistory();
+
+ private:
+ static const UI_32 m_suievDeepHistory;
+};
+
+#endif /* __FRAMEWORKUNIFIED_SM_DEEPHISTORYSTATE_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_dispatcher.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_dispatcher.h
new file mode 100644
index 00000000..2f392bab
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_dispatcher.h
@@ -0,0 +1,338 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Application dispatch interface functions
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_dispatcher.h
+ * @brief \~english Application dispatch interface functions
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_SM_DISPATCHER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_SM_DISPATCHER_H__
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+
+class CFrameworkunifiedHSMFramework;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedHSMDispatcher
+/// \~english @par Brief
+/// Creates, initializes and runs the HSM dispatcher.
+/// \~english @param [in] cAppName
+/// PCSTR - pointer of Application/ thread name
+/// \~english @retval EFrameworkunifiedStatus
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// - none
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// none
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcher(PCSTR cAppName);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedHSMDispatcherWithArguments
+/// \~english @par Brief
+/// This API creates, initializes the dispatcher and runs loop with command-line options.
+/// \~english @param [in] cAppName
+/// PCSTR - Pointer to application thread name
+/// \~english @param [in] argc
+/// int - Number of command-line options
+/// \~english @param [in] argv
+/// char *[] - Array of pointer to command-line options
+/// \~english @param [in] CbHandler
+/// const FrameworkunifiedDefaultCallbackHandler* - Pointer to default callback functions.
+/// \~english @param [in] f_pFrameworkunifiedHSM
+/// CFrameworkunifiedHSMFramework* - state machine object pointer(default NULL)
+/// \~english @param [in] cmdLineOptions
+/// CustomCommandLineOptions* - Parser setting of command-line options(Optional. When don't use, set NULL.)
+/// \~english @par
+/// FrameworkunifiedDefaultCallbackHandler Structure
+/// \~english @code
+/// typedef struct _FrameworkunifiedDefaultCallbackHandler
+/// {
+/// CbFuncPtr onInitilization; /* Function is called when a Dispatcher is created. */
+/// CbFuncPtr onDestroy; /* Function is called when the Dispatcher is released. */
+/// CbFuncPtr onStart; /* Function is called when the Dispatcher is started. */
+/// CbFuncPtr onStop; /* Function is called when the Dispatcher is stopped. */
+/// CbFuncPtr onPreStart; /* Function is called when the Dispatcher is pre started. */
+/// CbFuncPtr onPreStop; /* Function is called when the Dispatcher is pre stoped. */
+/// CbFuncPtr onBackgroundStart; /* Function is called when the Dispatcher is Background started. */
+/// CbFuncPtr onBackgroundStop; /* Function is called when the Dispatcher is Background stopped. */
+/// CbFuncPtr onDebugDump; /* Function is called when the Dispatcher detects abnormal state. */
+/// CbFuncPtr createStateMachine; /* Set dummy function that does nothing. */
+/// CbFuncPtr ssFrameworkInterface; /* Function to connect to SystemManager */
+/// } FrameworkunifiedDefaultCallbackHandler;
+/// @endcode
+/// \~english @par
+/// CustomCommandLineOptions Structure
+/// \~english @code
+/// typedef struct _CustomCommandLineOptions
+/// {
+/// PCSTR cShortOptions; /* Short options list. */
+/// PCHAR cLongOptions; /* Reserved. Set to NULL. */
+/// CbArgumentParser callback; /* Pointer to callback function to parse command-line options. */
+/// } CustomCommandLineOptions;
+/// @endcode
+/// \~english @par
+/// About setting of default callback functions(FrameworkunifiedDefaultCallbackHandler)
+/// - Use FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK when initialize of FrameworkunifiedDefaultCallbackHandler structure as argument CbHandler.
+/// - Application that run this API need to define functions below.(allow to dummy function that does nothing.)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp)
+/// - EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+/// - If application is resident service, link library libSS_SystemIfUnified
+/// (This library provides the function FrameworkunifiedSSFrameworkInterface to connect to SystemManager.).
+/// - If application is nonresident service, define function that does nothing below.
+/// - EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE hApp)
+/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusDuplicate Duplication error of entry
+/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
+/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
+/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - Application thread name specified in the argument (cAppName) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - Pointer to default callback functions specified in the argument (CbHandler) is NULL. [eFrameworkunifiedStatusNullPointer]
+/// - One of members in default callback functions specified in the argument (CbHandler) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Application thread name specified in the argument (cAppName) is not appropriate(The name is more than
+/// 15byte). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to open message queue (mq_open). [eFrameworkunifiedStatusNullPointer]
+/// - Failed to get memory (malloc) of message queue info area. [eFrameworkunifiedStatusNullPointer]
+/// - Failed to initialize socket for monitoring abnormal state (socket, bind, listen). [eFrameworkunifiedStatusFail]
+/// - Session message queue is full to the NPP Service. [eFrameworkunifiedStatusMsgQFull]
+/// - It is invalid transmission file descriptor of the session message to the NPP Service. [eFrameworkunifiedStatusErrNoEBADF]
+/// - Interruption by the system call (signal) has occurred during the transmission of the session message for the
+/// NPP Service. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Incorrect size of the transmit buffer of the session message to the NPP Service. [eFrameworkunifiedStatusInvldBufSize]
+/// - Any errors occur during the transmission of a session message to the NPP Service. [eFrameworkunifiedStatusFail]
+/// - Failed to create of epoll instance (epoll_create1). [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to register of a descriptor of the message queue to the epoll instance (epoll_ctl).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to create file descriptor for receive event (eventfd). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a descriptor for receive event to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - Failed to register of a socket for detect abnormal state to the epoll instance (epoll_ctl). [eFrameworkunifiedStatusFail]
+/// - The result of FrameworkunifiedOnInitialization is not eFrameworkunifiedStatusOK. [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Detail
+/// This API creates and initializes the dispatcher with command-line options.\n
+/// It starts to mainloop that receives request or notification, and runs registered callback to dispatcher.
+/// When success starting mainloop, never return.
+/// Use this API to take over a command-line options to the dispatcher.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - Error handling is not performed when the state machine event registration process (CFrameworkunifiedHSMFramework::FrameworkunifiedCreate) fails.\n
+/// The behavior of state machine objects must be guaranteed by the application implementation.
+/// - When an exception occurs during Dispatcher generating, an error log is output and eFrameworkunifiedStatusOK is returned.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see none
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedHSMDispatcherWithArguments(PCSTR cAppName, int argc, char *argv[],
+ const FrameworkunifiedDefaultCallbackHandler *CbHandler,
+ CFrameworkunifiedHSMFramework *f_pFrameworkunifiedHSM = NULL,
+ CustomCommandLineOptions *cmdLineOptions = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetHSMType
+/// \~english @par Brief
+/// Set the Application Statemachine Type
+/// \~english @param [in] cAppName
+/// PCSTR - pointer of Application/ thread name
+/// \~english @code
+/// typedef enum _EUserChangeOptions {
+/// eUserchangeIgnore = 0,
+/// eUserchangeReInit,
+/// eUserchangeRetPrevState
+/// } EUserChangeOptions;
+/// @endcode
+/// \~english @retval EFrameworkunifiedStatus
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// - none
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// none
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void FrameworkunifiedSetHSMType(EUserChangeOptions f_eHSMType);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedEnableAutoPublishServiceAvailable
+/// \~english @par Brief
+/// Enables the AutoPublishServiceAvailability Feature
+/// \~english @param none
+/// \~english @retval EFrameworkunifiedStatus
+/// \~english @par Prerequisite
+/// - Prerequisites are nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// Enables the AutoPublishServiceAvailability Feature that publishes the service
+/// availability on entry of sFrameworkunifiedReady state and publishes the service unavailability
+/// on exit of sFrameworkunifiedReady state.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// none
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void FrameworkunifiedEnableAutoPublishServiceAvailable();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDisableAutoPublishServiceAvailable
+/// \~english @par Brief
+/// Disable to the AutoPublishServiceAvailability Feature.
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - Prerequisite is nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// None.
+/// \~english @par Detail
+/// This API disable feature that notify automatically service availability to clients
+/// at the timing of changing of internal state.\n
+/// If you disable this feature, the application needs to publish service availability state explicitly
+/// using FrameworkunifiedPublishServiceAvailability.
+/// \~english @par Classification
+/// Forbidden
+/// \~english @see FrameworkunifiedHSMDispatcherWithArguments FrameworkunifiedPublishServiceAvailability
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDisableAutoPublishServiceAvailable
+/// Disables the AutoPublishServiceAvailability Feature that publishes the service
+/// availability on entry of sFrameworkunifiedReady state and publishes the service unavailability
+/// on exit of sFrameworkunifiedReady state. Applications are responsible for publishing the service
+/// availability.
+void FrameworkunifiedDisableAutoPublishServiceAvailable();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedHSMEnableWaitInStoppingState
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedHSMEnableWaitInStoppingState
+/// If HSM application should wait in sStoppingState until user explicitly publishes evFrameworkunifiedStopComplete,
+/// then call this function before FrameworkunifiedHSMDispatcher APIs.
+/// Default behavior is application will not wait is sStoppingState.
+///
+/// \~english @par Brief
+/// Change state application when call FrameworkunifiedOnStop().
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - Prerequisite is nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// None.
+/// \~english @par Detail
+/// If HSM application should wait in sStoppingState until user explicitly publishes evFrameworkunifiedStopComplete,
+/// then call this function before FrameworkunifiedHSMDispatcher APIs.
+/// Default behavior is application will not wait in sStoppingState.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// none
+/// \~english @see FrameworkunifiedHSMDisableWaitInStoppingState
+VOID FrameworkunifiedHSMEnableWaitInStoppingState();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedHSMDisableWaitInStoppingState
+/// \~english @par Brief
+/// Chanage state to not wait in sStoppingState.
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - Prerequisite is nothing.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// None.
+/// \~english @par Detail
+/// If HSM application should not wait in sStoppingState, then call this function before FrameworkunifiedHSMDispatcher APIs.\n
+/// Default behavior is application will not wait is sStoppingState. So, it's not mandatory to use it.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// none
+/// \~english @see FrameworkunifiedHSMEnableWaitInStoppingState
+VOID FrameworkunifiedHSMDisableWaitInStoppingState();
+
+#endif // __NATIVESERVICES_FRAMEWORK_FRAMEWORKUNIFIED_SM_DISPATCHER_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventdata.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventdata.h
new file mode 100644
index 00000000..e54d095e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventdata.h
@@ -0,0 +1,83 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+/// This file has class declaration of the CFrameworkunifiedAction. This is an interface class that defines
+/// interfaces for implementing action
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_eventdata.h
+ * @brief \~english This file has class declaration of the CFrameworkunifiedAction. This is an interface class that defines
+ * interfaces for implementing action
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMEVENTDATA_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMEVENTDATA_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_logger_if.h>
+#include <boost/smart_ptr.hpp>
+
+
+class CEventData {
+ public:
+ CEventData(UI_32 f_uiEventId): m_uiEventId(f_uiEventId) { // NOLINT (readability/nolint)
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "CEventData parameterized constructor"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ virtual ~CEventData() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "CEventData destructor"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+ // event id
+ UI_32 m_uiEventId;
+
+ private:
+ CEventData() {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_SM_USR_INFO, __FUNCTION__, "CEventData constructor");
+ }
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSFRAMEWORKCORE_STATEMACHINE_INC_FRAMEWORKUNIFIEDSMEVENTDATA_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventfactory.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventfactory.h
new file mode 100644
index 00000000..02a2b3b7
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_eventfactory.h
@@ -0,0 +1,114 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file defines the events used by the statemachine framework
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_eventfactory.h
+ * @brief \~english This file defines the events used by the statemachine framework.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef CFRAMEWORKUNIFIEDEVENTFACTORY_H_ // NOLINT (build/header_guard)
+#define CFRAMEWORKUNIFIEDEVENTFACTORY_H_
+
+#include <native_service/frameworkunified_types.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class defines the events used by the statemachine framework
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedEventFactory {
+ public:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedEventFactory
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedEventFactory.
+ /// \~english @param none
+ /// \~english @retval
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see ~CFrameworkunifiedEventFactory
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedEventFactory();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedEventFactory
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedEventFactory
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedEventFactory created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Class CFrameworkunifiedHistoryState instance release.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedEventFactory::CFrameworkunifiedEventFactory
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedEventFactory();
+
+ /// Defines the events for starting an application
+ static const UI_32 evFrameworkunifiedStart = 0;
+
+ /// Defines the Higher limit for event id reserved only for framework
+ static const UI_32 evFrameworkunifiedEventLimit = 10;
+};
+
+#endif /* CFRAMEWORKUNIFIEDEVENTFACTORY_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_externaltransition.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_externaltransition.h
new file mode 100644
index 00000000..a4668064
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_externaltransition.h
@@ -0,0 +1,268 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
+/// from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
+/// from one state to another state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_externaltransition.h
+ * @brief \~english This file has the CFrameworkunifiedExternalTransition class definitions. CFrameworkunifiedExternalTransition is derived
+ * from CFrameworkunifiedTransition class.This class implements the FrameworkunifiedReaction interface to support transition
+ * from one state to another state.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_transition.h>
+#include <vector>
+class CFrameworkunifiedGuard;
+class CFrameworkunifiedAction;
+class CEventData;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the FrameworkunifiedReaction interface to support transition
+/// from one state to another state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedExternalTransition : public CFrameworkunifiedTransition {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedExternalTransition
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedExternalTransition.
+ /// \~english @param [in] f_pTargetState
+ /// CFrameworkunifiedState* - pointer of target CFrameworkunifiedState object
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// inherit the CFrameworkunifiedTransition class and create instance of CFrameworkunifiedExternalTransition class \n
+ /// create the list for CFrameworkunifiedAction class,set pointer as member parameter\n
+ /// this class is intanced with FrameworkunifiedReaction interfase in order to support changing one state to other state.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedExternalTransition, FrameworkunifiedReaction, FrameworkunifiedAddAction
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedExternalTransition
+ /// Parameterized constructor
+ /// \param [in] f_pTargetState
+ /// CFrameworkunifiedState* - Target state object
+ ///
+ /// \return none
+ CFrameworkunifiedExternalTransition(CFrameworkunifiedState *f_pTargetState); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedExternalTransition
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedExternalTransition
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedExternalTransition created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Class CFrameworkunifiedHistoryState instance release. \n
+ /// Member variable active action list of CFrameworkunifiedAction release.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedExternalTransition::CFrameworkunifiedExternalTransition
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedExternalTransition
+ /// Class destructor
+ ///
+ /// \return none
+ virtual ~CFrameworkunifiedExternalTransition();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedExternalTransition
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedReaction
+ /// The reaction for an event is implemented in this function. For external transition, Exit
+ /// of the source state is called and entry of the target state is called recursively.
+ ///
+ /// \~english @par Brief
+ /// CFrameworkunifiedExternalTransition instance event process.
+ /// \~english @param f_pSourceState
+ /// CFrameworkunifiedState* - source state object pointer
+ /// \~english @param f_pData
+ /// CEventDataPtr* - CEventData event pointer
+ /// \~english @retval CFrameworkunifiedState* active state pointer
+ /// \~english @retval NULL
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedExternalTransition created.
+ /// \~english @par Change of internal status
+ /// - If input parameter f_pSourceState is NULL. [NULL]
+ /// - If member variable m_pTargetState is NULL. [NULL]
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// if the self-instance has guard object,event operation will not conduct.
+ /// return soucestate(CFrameworkunifiedState class)object()f_pSourceState(set from parameter) as
+ /// activestate(CFrameworkunifiedState class)object\n
+ /// as activestate(CFrameworkunifiedState class)object
+ /// if there is no guard object:
+ /// - Exit process(FrameworkunifiedOnHSMStop call)for sorcestate(CFrameworkunifiedStateclass)object will conduct once more.
+ /// - Entryt process(FrameworkunifiedOnHSMStart call)for target state(CFrameworkunifiedState class)objectwill conduct once more.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedSetGuard, FrameworkunifiedAddAction
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedExternalTransition
+ /// \~english @par Brief
+ /// Sets the Guard object in External Transition
+ /// \~english @param f_pGuard
+ /// CFrameworkunifiedGuard* - CFrameworkunifiedGuard object pointer
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedExternalTransition created.
+ /// \~english @par Change of internal status
+ /// - If input parameter CFrameworkunifiedGuard is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Sets the Guard object in CFrameworkunifiedExternalTransition instance\n
+ /// in order to guard the transform process. and during setting process,\n
+ /// transform is not conduct
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedReaction, FrameworkunifiedAddAction
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedSetGuard
+ /// Sets the Guard object in External Transition
+ ///
+ /// \param [in] f_pGuard
+ /// CFrameworkunifiedGuard* - guard object
+ ///
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus -
+ ///
+ virtual EFrameworkunifiedStatus FrameworkunifiedSetGuard(CFrameworkunifiedGuard *f_pGuard);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedExternalTransition
+ /// \~english @par Brief
+ /// Adds CFrameworkunifiedAction object to the action list
+ /// \~english @param f_pAction
+ /// CFrameworkunifiedAction* - CFrameworkunifiedAction object pointer
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedExternalTransition created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - If input parameter CFrameworkunifiedAction is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If member variable m_pActionList is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// add CFrameworkunifiedAction class object to the end of the list for CFrameworkunifiedAction class in parameter
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedReaction, FrameworkunifiedSetGuard
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedAddAction(CFrameworkunifiedAction *f_pAction);
+
+
+ protected :
+ /// pointer to the guard condition object
+ CFrameworkunifiedGuard *m_pGuard;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ExecuteTransition
+ /// Execute the transition actions, calls OnExit of Source State and OnEntry of target state
+ ///
+ /// \param [in] f_pSourceState
+ /// CEventDataPtr - source state
+ ///
+ /// \param [in] f_pData
+ /// CFrameworkunifiedState* - Event data
+ ///
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus -
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedState *ExecuteTransition(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
+
+ // Action list
+ typedef std::vector<CFrameworkunifiedAction *> TActionList;
+
+ // Action list iterator
+ typedef TActionList::iterator TActionListIterator;
+
+ // List of conditions
+ TActionList *m_pActionList;
+};
+#endif // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_EXTERNALTRANSITION_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_dispatch.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_dispatch.h
new file mode 100644
index 00000000..70afea16
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_dispatch.h
@@ -0,0 +1,1054 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_framework_dispatch.h
+ * @brief \~english This file contains basic api to operate state machine
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_DISPATCH_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_DISPATCH_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_hsmframework.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedSetStateMachine
+/// \~english @par Brief
+/// Get pointer to the statemachine object.
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the framework application
+/// \~english @retval CFrameworkunifiedHSMParentFramework* pointer to the statemachine object
+/// \~english @retval NULL Failed to get pointer to the statemachine object
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedHSMDispatcherWithArguments has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) . [NULL]
+/// - Pointer to statemachine object is NULL. [NULL]
+/// \~english @par Detail
+/// Get pointer to the statemachine object associated with application framework handle.\n
+/// Do not release the statemachine object in application, because it is a part of the Dispathcer.
+/// \~english @par Classification
+/// public
+/// \~english @par type
+/// sync only
+/// \~english @see FrameworkunifiedHSMDispatcherWithArguments,FrameworkunifiedGetStateMachine
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSetStateMachine
+/// sets the statemachine object
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application session
+///
+/// \param [in] f_pFrameworkunifiedHSM
+/// CFrameworkunifiedHSM - Pointer to statemachine object
+///
+/// \return pointer to the StateMachine object
+/// CFrameworkunifiedHSMParentFramework* - pointer to the StateMachine object
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSetStateMachine(HANDLE hApp,
+ CFrameworkunifiedHSM *f_pFrameworkunifiedHSM);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventToDispatcher
+/// \~english @par Brief
+/// Register an event in dispatcher
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application framework handle
+/// \~english @param [in] pServiceName
+/// PCSTR pServiceName - Service Name
+/// \~english @param [in] iCmd
+/// UI_32 iCmd - service protocol command/request/acknowledgment ID
+/// \~english @param [in] iEvent
+/// UI_32 iEvent - event to be posted to active state on receiving iCmd from pServiceName.
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedHSMDispatcherWithArguments has been done.
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to service name specified in the argument (pServiceName) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Register an event information (iCmd,iEvent) for service specified in the argument in dispatcher.\n
+/// After that, when receiving an iCmd from service, post the event to active state.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - Operation is not guaranteed if a different handle is set for an application handle.
+/// - Operation is not guaranteed if an invalid handle is set for a session handle.
+/// - This API registers one event for one command and one callback for one event.\n
+/// When registration is performed for the same command, the previously registered event is activated.
+/// - The callback information is registered to the heap.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see FrameworkunifiedAttachHSMEventsToDispatcher
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachHSMEventToDispatcher
+/// Registers a single event with the dispatcher for a given service.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pServiceName
+/// PCSTR - Service Name
+/// \param [in] iCmd
+/// UI_32 - service protocol command/request/acknowledgment ID
+/// \param [in] iEvent
+/// UI_32 - event to be posted to active state on receiving iCmd from pServiceName.
+/// \param [in] hSession
+/// HANDLE - Session Handle.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventToDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, UI_32 iEvent,
+ HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// Register events in dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application framework handle
+/// \~english @param [in] pServiceName
+/// PCSTR pServiceName - Service Name
+/// \~english @param [in] pEventIds
+/// const FrameworkunifiedProtocolEvent *pEventIds - structure mapping event ids with the messages
+/// \~english @param [in] uiEventCount
+/// UI_32 uiEventCount - no of events
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedHSMDispatcherWithArguments has been done.
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to service name specified in the argument (pServiceName) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to FrameworkunifiedProtocolEvent structure specified in the argument is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Register events information (iCmd,iEvent) for service specified in the argument in dispatcher.\n
+/// After that, when receiving an iCmd from service, post the event to active state.\n
+/// If register failed, only the events that register before it are valid.\n
+/// When multiple registration, if an error occurs in the second and subsequent, becomes effective only \n
+/// information that has been registered so far. \n
+/// For number of upper limit of the registration possible event, depending on \n
+/// the securable size as the area of the FrameworkunifiedProtocolEvent structure. Therefore, note to ensure \n
+/// the size of the area of the FrameworkunifiedProtocolEvent structure at the call side of API, and define \n
+/// the number of event.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - Operation is not guaranteed if a different handle is set to Handle for the application.
+/// - Operation is not guaranteed if an invalid handle is set for a session handle.
+/// - If an error occurs when multiple events are registered, it is impossible to determine which event was valid.
+/// Therefore, either register multiple event information again or delete multiple event information at the same time when registration fails.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see FrameworkunifiedAttachHSMEventToDispatcher
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachHSMEventsToDispatcher
+/// Registers a multiple event with the dispatcher for a given service.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pServiceName
+/// PCSTR - Service Name
+/// \param [in] pEventIds
+/// const FrameworkunifiedProtocolEvent* - structure mapping event ids with the messages
+/// \param [in] uiEventCount
+/// UI_32 - no of events
+/// \param [in] hSession
+/// HANDLE - Session Handle.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachHSMEventsToDispatcher(HANDLE hApp, PCSTR pServiceName,
+ const FrameworkunifiedProtocolEvent *pEventIds,
+ UI_32 uiEventCount,
+ HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// register a notification in service
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pNotification
+/// PCSTR pNotification - Name of Notification
+/// \~english @param [in] max_length
+/// const UI_32 max_length - Max size of the notification message
+/// \~english @param [in] persType
+/// const EFrameworkunifiedNotificationType persType - Type of persistent
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pNotification) to service name is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// send message to Notification Service to register a notification
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMRegisterNotificatsionEvent
+/// API to send message to Notification Service to register a notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+/// \param [in] max_length
+/// const UI_32 - Max size of the notification message
+/// \param [in] persType
+/// const EFrameworkunifiedNotificationType - Type of persistent
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificatsionEvent(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
+ const EFrameworkunifiedNotificationType persType);
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// register many notifications in service
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pList
+/// const FrameworkunifiedNotificationsList *pList - List of the notifications that need to be registered
+/// \~english @param [in] uiListLength
+/// UI_32 uiListLength - Length of the list
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pList) to service name is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// send message to Notification Service to register many notifications
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMRegisterNotificationsEvents
+/// API to send message to Notification Service to register a notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pList
+/// FrameworkunifiedNotificationsList - List of the notifications that need to be registered
+/// \param [in] uiListLength
+/// const UI_32 - Length of the list
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationsList *pList,
+ UI_32 uiListLength);
+
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// remove a notification in service
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pNotification
+/// cPCSTR pNotification - Name of Notification
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pNotification) to service name is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// send message to Notification Service to remove a notification
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedNPHSMUnRegisterNotificationEvent
+/// API to send message to Notification Service to remove a notification
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the Framework
+/// \param [in] pNotification
+/// PCSTR - Name of Notification
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedNPHSMUnRegisterNotificationEvent(HANDLE hApp, PCSTR pNotification);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// attach an event to the dispatcher on receiving a specific notification.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pNotification
+/// cPCSTR pNotification - Name of Notification
+/// \~english @param [in] iEventId
+/// UI_32 iEventId - event ID
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pNotification) to service name is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// attach an event to the dispatcher on receiving a specific notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachNotificationEventToDispatcher
+/// API to attach a event to the dispatcher on receiving a specific notification.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pNotification
+/// PCSTR - Notification String.
+/// \param [in] iEventId
+/// UI_32 - event to be posted to active state on receiving iCmd from pServiceName.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification,
+ UI_32 iEventId);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// attach many events to eath dispatcher on receiving a specific notification.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pNtfyEvent
+/// const FrameworkunifiedNotificationEvent *pNtfyEvent - Notification event structure.
+/// \~english @param [in] uiEventCount
+/// UI_32 uiEventCount - Number of Notification event
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to FrameworkunifiedProtocolEvent structure specified in the argument is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// attach many events to eath dispatcher on receiving a specific notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachNotificationEventsToDispatcher
+/// API to attach a event to the dispatcher on receiving a specific notification.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pNtfyEvent
+/// const FrameworkunifiedNotificationEvent* - Notification event structure.
+/// \param [in] uiEventCount
+/// UI_32 - Number of Notification event
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyEvent,
+ UI_32 uiEventCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// detach events from the dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pNtfyHandler
+/// const FrameworkunifiedNotificationEvent *pNtfyHandler - Notification handler structure.
+/// \~english @param [in] uiHandlerCount
+/// UI_32 uiHandlerCount - Notification handler structure.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to FrameworkunifiedProtocolEvent structure specified in the argument is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// detach events from the dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedUnsubscribeNotificationsWithHSMEvent
+/// API to detach a notification event from the dispatcher.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pNtfyHandler
+/// const FrameworkunifiedNotificationEvent* - Notification handler structure.
+/// \param [in] uiHandlerCount
+/// UI_32 - Number of notification handlers
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationsWithHSMEvent(HANDLE hApp, const FrameworkunifiedNotificationEvent *pNtfyHandler,
+ UI_32 uiHandlerCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// detach a notification event from the dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Handle to the Framework
+/// \~english @param [in] pNotification
+/// PCSTR pNotification - Notification String.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pNotification) to service name is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// detach a notification event from the dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDetachNotificationEventsFromDispatcher
+/// API to detach a notification event from the dispatcher.
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pNotification
+/// PCSTR - Notification String.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnsubscribeNotificationWithHSMEvent(HANDLE hApp, PCSTR pNotification);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// Registers a multiple HSM event with the dispatcher for a given service.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Child Thread handle
+/// \~english @param [in] pEventIds
+/// const FrameworkunifiedProtocolEvent *pEventIds - structure mapping event ids with the messages
+/// \~english @param [in] uiEventCount
+/// UI_32 uiEventCount - no of events
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to FrameworkunifiedProtocolEvent structure specified in the argument is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Registers a multiple HSM event with the dispatcher for a given service.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedAttachParentHSMEventsToDispatcher
+/// Registers a multiple HSM event with the dispatcher for a given service.
+///
+///
+/// \param [in] hChildApp
+/// HANDLE - Application framework handle
+/// \param [in] pEventIds
+/// const FrameworkunifiedProtocolEvent* - structure mapping event ids with the messages
+/// \param [in] uiEventCount
+/// UI_32 - no of events
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedAttachParentHSMEventsToDispatcher(HANDLE hChildApp, const FrameworkunifiedProtocolEvent *pEventIds,
+ UI_32 uiEventCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachHSMEventsToDispatcher
+/// \~english @par Brief
+/// detach notification HSM events from the dispatcher.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Child Thread handle
+/// \~english @param [in] puiEventArray
+/// const PUI_32 puiEventArray - Array of events
+/// \~english @param [in] uiEventCount
+/// UI_32 uiEventCount - Number of events
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// detach notification HSM events from the dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+/////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDetachParentHSMEventsFromDispatcher
+/// API to detach a notification HSM event from the dispatcher.
+///
+///
+/// \param [in] hChildApp
+/// HANDLE - Child Thread handle
+/// \param [in] puiEventArray
+/// const PUI_32 puiEventArray - Array of events
+/// \param [in] uiEventCount
+/// UI_32 - Number of events
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachParentHSMEventsFromDispatcher(HANDLE hChildApp, const PUI_32 puiEventArray, UI_32 uiEventCount);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachHSMEventsFromDispatcher
+/// \~english @par Brief
+/// detach multiple events from the dispatcher
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application framework handle
+/// \~english @param [in] pServiceName
+/// PCSTR pServiceName - Service Name
+/// \~english @param [in] puiCmdArray
+/// const PUI_32 puiCmdArray - Array of commands
+/// \~english @param [in] uiCmdCount
+/// UI_32 uiCmdCount - Number of Commands
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @retval eFrameworkunifiedStatusFail process failed
+/// \~english @retval eFrameworkunifiedStatusInvldParam invalid parameter
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedHSMDispatcherWithArguments has been done.
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to service name specified in the argument (pServiceName) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pServiceName) to service name doesn't exist [eFrameworkunifiedStatusFail]
+/// - Pointer to event array specified in the argument which will be deleted is NULL [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// Detach multiple events(puiCmdArray) information for service specified in the argument from dispatcher.\n
+/// After that, when receiving command from service, post the event to unactive state.\n
+/// If the information has been deleted, return eFrameworkunifiedStatusOK.\n
+/// If the specific event has not been registered, return eFrameworkunifiedStatusOK.\n
+/// If number of puiCmdArray to be deleted is 0, return eFrameworkunifiedStatusOK.\n
+/// When deleting multiple events, if an error occurs, stop deleting. \n
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - Operation is not guaranteed if a different handle is set for an application handle.
+/// - Operation is not guaranteed if an invalid handle is set for a session handle.
+/// - Operatuib is not guaranteed if a puiCmdArray that differs from the events to be deleted is set.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see FrameworkunifiedDetachHSMEventFromDispatcher
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDetachHSMEventsFromDispatcher
+/// API to detach a notification HSM event from the dispatcher.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pServiceName
+/// PCSTR - Service Name
+/// \param [in] puiCmdArray
+/// const PUI_32 - Array of commands
+/// \param [in] uiCmdCount
+/// UI_32 - Number of Commands
+/// \param [in] hSession
+/// HANDLE - Session Handle.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventsFromDispatcher(HANDLE hApp, PCSTR pServiceName, const PUI_32 puiCmdArray,
+ UI_32 uiCmdCount, HANDLE hSession = NULL);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachHSMEventFromDispatcher
+/// \~english @par Brief
+/// detach an event from the dispatcher
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application framework handle
+/// \~english @param [in] pServiceName
+/// PCSTR pServiceName - Service Name
+/// \~english @param [in] iCmd
+/// UI_32 iCmd - service protocol command/request/acknowledgment ID
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @retval eFrameworkunifiedStatusFail process failed
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedHSMDispatcherWithArguments has been done.
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to service name specified in the argument (pServiceName) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer(pServiceName) to service name doesn't exist [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Detach an event information for service specified in the argument from dispatcher.\n
+/// After that, when receiving command from service, post the event to unactive state.\n
+/// If the information has been deleted or the specific iCmd has not been registered, return eFrameworkunifiedStatusOK.\n
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - Operation is not guaranteed if a different handle is set for an application handle.
+/// - Operation is not guaranteed if an invalid handle is set for a session handle.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see FrameworkunifiedDetachHSMEventsFromDispatcher
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedDetachHSMEventFromDispatcher
+/// API to detach a notification HSM event from the dispatcher.
+///
+///
+/// \param [in] hApp
+/// HANDLE - Application framework handle
+/// \param [in] pServiceName
+/// PCSTR - Service Name
+/// \param [in] iCmd
+/// UI_32 - service protocol command/request/acknowledgment ID
+/// \param [in] hSession
+/// HANDLE - Session Handle.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see
+///
+EFrameworkunifiedStatus FrameworkunifiedDetachHSMEventFromDispatcher(HANDLE hApp, PCSTR pServiceName, UI_32 iCmd, HANDLE hSession = NULL);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedGetStateMachine
+/// \~english @par Brief
+/// Get pointer to the statemachine object.
+/// \~english @param [in] hApp
+/// HANDLE - Handle to the framework application
+/// \~english @retval CFrameworkunifiedHSMParentFramework* pointer to the statemachine object
+/// \~english @retval NULL Failed to get pointer to the statemachine object
+/// \~english @par Prerequisite
+/// - Generation/Initialization of Dispatcher for the Application by FrameworkunifiedHSMDispatcherWithArguments has been done.
+/// \~english @par Change of internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) . [NULL]
+/// - HANDLE specified in the argument (hApp) is not generated by FrameworkunifiedHSMDispatcherWithArguments. [NULL]
+/// \~english @par Detail
+/// Get pointer to the statemachine object associated with application framework handle.\n
+/// Do not release the statemachine object in application, because it is a part of the Dispathcer.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see FrameworkunifiedHSMDispatcherWithArguments,FrameworkunifiedSetStateMachine
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedGetStateMachine
+/// returns the pointer to the statemachine object
+///
+/// \param [in] hApp
+/// HANDLE - Handle to the application session
+///
+/// \return pointer to the StateMachine object
+/// CFrameworkunifiedHSMParentFramework* - pointer to the StateMachine object
+///
+/// \see
+///
+CFrameworkunifiedHSMFramework *FrameworkunifiedGetStateMachine(HANDLE hApp);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachHSMEventFromDispatcher
+/// \~english @par Brief
+/// subscribing to single event of a service. attaches the session event with HSM events.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application handle
+/// \~english @param [in] uiEventId
+/// UI_32 uiEventId - Session Event id
+/// \~english @param [in] uiHSMEventId
+/// UI_32 uiHSMEventId- Statemachine Event id
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @retval eFrameworkunifiedStatusFail process failed
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// This API is used for subscribing to single event of a service.
+/// This API also attaches the session event with HSM events.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeToSessionEventWithHSMEvent
+/// This API is used for subscribing to single event of a service.
+/// This API also attaches the session event with HSM events.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] uiEventId
+/// UI_32 - Session Event id
+/// \param [in] uiHSMEventId
+/// UI_32 - Statemachine Event id
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedSubscribeToSessionEventsWithHSMEvents
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventWithHSMEvent(HANDLE hApp, UI_32 uiEventId, UI_32 uiHSMEventId, HANDLE hSession);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachHSMEventFromDispatcher
+/// \~english @par Brief
+/// subscribing to multiple events of a service. attaches the session events with HSM events.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application handle
+/// \~english @param [in] pEventIds
+/// const FrameworkunifiedProtocolEvent *pEventIds - structure mapping session event id's with the hsm event id's
+/// \~english @param [in] uiEventCount
+/// UI_32 uiEventCount - count of events
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @retval eFrameworkunifiedStatusFail process failed
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// - Pointer to FrameworkunifiedProtocolEvent structure specified in the argument is NULL [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// This API is used for subscribing to multiple events of a service.
+/// his API also attaches the session events with hsm events.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedSubscribeToSessionEventsWithHSMEvents
+/// This API is used for subscribing to multiple events of a service.
+/// This API also attaches the session events with hsm events.
+///
+/// \param [in] hApp
+/// HANDLE - Application handle
+/// \param [in] pEventIds
+/// FrameworkunifiedProtocolEvent - structure mapping session event id's with the hsm event id's
+/// \param [in] uiEventCount
+/// UI_32 - count of events
+/// \param [in] hSession
+/// HANDLE - Session handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedSubscribeToSessionEventWithHSMEvent
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedSubscribeToSessionEventsWithHSMEvents(HANDLE hApp, const FrameworkunifiedProtocolEvent *pEventIds, UI_32 uiEventCount,
+ HANDLE hSession);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachHSMEventFromDispatcher
+/// \~english @par Brief
+/// unsubscribe from event of a service. detaches HSM event from session event.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application handle
+/// \~english @param [in] uiEventId
+/// UI_32 uiEventId - Event id
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @retval eFrameworkunifiedStatusFail process failed
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// API to unsubscribe from event of a service. Also detaches HSM event from session event.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeSessionEventWithHSMEvent
+/// API to unsubscribe from event of a service. Also detaches HSM event from session event.
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [in] uiEventId
+/// UI_32 - Event id
+/// \param [in] hSession
+/// HANDLE - Session Handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventWithHSMEvent(HANDLE hApp, UI_32 uiEventId, HANDLE hSession);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachHSMEventFromDispatcher
+/// \~english @par Brief
+/// unsubscribe from multiple events of a service. detaches HSM events from session events.
+/// \~english @param [in] hApp
+/// HANDLE hApp - Application handle
+/// \~english @param [in] pEventsArray
+/// PUI_32 pEventsArray - Array of events id's.
+/// \~english @param [in] uiListSize
+/// UI_32 uiListSize - count of elements in array.
+/// \~english @param [in] hSession
+/// HANDLE hSession - Session Handle.
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle invalid state handle
+/// \~english @retval eFrameworkunifiedStatusFail process failed
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid) [eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// API to unsubscribe from multiple events of a service. Also detaches HSM events from session events.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @see
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents
+/// API to unsubscribe from multiple events of a service. Also detaches HSM events from session events.
+///
+/// \param [in] hApp
+/// HANDLE - Application Handle
+/// \param [in] pEventsArray
+/// PUI_32 - Array of events id's.
+/// \param [in] uiListSize
+/// UI_32 - count of elements in array.
+/// \param [in] hSession
+/// HANDLE - Session Handle
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+///
+/// \see FrameworkunifiedUnSubscribeSessionEventWithHSMEvent
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedUnSubscribeSessionEventsWithHSMEvents(HANDLE hApp, PUI_32 pEventsArray, UI_32 uiListSize,
+ HANDLE hSession);
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_DISPATCH_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_if.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_if.h
new file mode 100644
index 00000000..8c90e595
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_if.h
@@ -0,0 +1,486 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_framework_if.h
+ * @brief \~english This File has public Macro definition that simplifies the statemachine implementation
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_IF_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_IF_H__
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro creates an instance of a state object.
+/// \~english @param [in] class_name Class name
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro creates an instance of a state object with the specified class name.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Create a instance of state object
+#define CREATE_STATE(class_name) \
+ C## class_name *l_p## class_name = new C## class_name(#class_name);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro associates a framework event with a process and adds it to a state.
+/// \~english @param [in] state State
+/// \~english @param [in] eventid Event ID
+/// \~english @param [in] reaction Pointers to CFrameworkunifiedReaction objects
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macros retrieves the current state machine from the application handles used in the process
+/// and associates framework events with the process and adds them to the state using FrameworkunifiedFrameworkConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Connect framework event to reaction and add to state
+#define FRAMEWORKUNIFIED_CONNECT_EVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(CFrameworkunifiedHSMParentFramework::e## state, \
+ CFrameworkunifiedHSMParentFramework::_## eventid, l_pTrn## reaction, #eventid);
+
+#define FRAMEWORKUNIFIED_CONNECT_LOCAL_EVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(CFrameworkunifiedHSMParentFramework::e## state, \
+ CFrameworkunifiedHSMParentFramework::_## eventid, l_pLocalTrn## reaction, #eventid);
+
+/// Connect framework event to reaction and add to state as deferred event
+#define FRAMEWORKUNIFIED_CONNECT_DEFERREDEVENT(state, eventid) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(CFrameworkunifiedHSMParentFramework::e## state, \
+ CFrameworkunifiedHSMParentFramework::_## eventid, NULL, #eventid, TRUE);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro associates a child state as the default state with the ready state of the framework.
+/// \~english @param [in] child Child state
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro retrieves the current state machine from the application handles used in the process and uses FrameworkunifiedFrameworkConnect() to associate the specified child state with the ready state of the framework as the default state.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect state to framework ready state as default state
+#define FRAMEWORKUNIFIED_CONNECT_DEFAULTSTATE(child) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(l_p## child, TRUE);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro associates the child state with the ready state of the framework.
+/// \~english @param [in] child Child state
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro retrieves the current state machine from the application handles used in the process and associates the specified child state with the ready state of the framework using FrameworkunifiedFrameworkConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect state to framework ready state
+#define FRAMEWORKUNIFIED_CONNECT_STATE(child) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(l_p## child);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// A macro that associates a child state as the defaut state with a parent state.
+/// \~english @param [in] parent Parent state
+/// \~english @param [in] child Child state
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro takes the current state machine from the application handles used in the process and uses FrameworkunifiedConnect() to associate the specified child state with the specified parent state as the default state.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect child state to parent state as default state
+#define CONNECT_DEFAULTSTATE(parent, child) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## parent, l_p## child, TRUE);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// A macro that associates a child state with a parent state.
+/// \~english @param [in] parent Parent state
+/// \~english @param [in] child Child state
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro takes the current state machine from the application handles used in the process and associates the specified child state with the specified parent state using FrameworkunifiedConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect child state to parent state
+#define CONNECT_STATE(parent, child) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## parent, l_p## child);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro associates a state as the state of the root.
+/// \~english @param [in] orthogonalstate quadrature state(CFrameworkunifiedOrthogonalState*)
+/// \~english @param [in] orthogonalregion orthographic region(CFrameworkunifiedCompositeState*)
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro gets the current state machine from the application handles used in the process and associates the specified orthographic state as the state of the root using FrameworkunifiedConnectOrthogonal().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect child state to parent state
+#define CONNECT_ORTHOGONAL_REGION(orthogonalstate, orthogonalregion) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnectOrthogonal(l_p## orthogonalstate, l_p## orthogonalregion);
+
+/// connect the deferred event and reactions and associate them with the state
+#define CONNECT_DEFERREDEVENT(state, eventid) \
+ FrameworkunifiedGetStateMachine(hApp)->FrameworkunifiedConnect(l_p## state, _## eventid, NULL, #eventid, TRUE);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro associates a framework event with a process and adds it to a state.
+/// \~english @param [in] state State
+/// \~english @param [in] eventid Event ID
+/// \~english @param [in] reaction Pointers to CFrameworkunifiedReaction objects
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macros retrieves the current state machine from the application handles used in the process and associates framework events with the process and adds them to the state using FrameworkunifiedConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect event to reaction and add to state
+#define CONNECT_EVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid);
+
+/// connect event to reaction and add to state
+#define CONNECT_LOCAL_EVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## state, _## eventid, l_pLocalTrn## reaction, #eventid);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro logs state and events of the state machine.
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro gets the current state machine from the application handles used in the process and logs the state and events of the state machine using FrameworkunifiedPrintAllStates().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// print state machine states and events
+#define PRINTSTATEMACHINE() \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedPrintAllStates();
+
+/// Connect application defined event to application defined reaction and add to framework state
+#define CONNECT_FRAMEWORKUNIFIED_EVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## state, CFrameworkunifiedHSMParentFramework::_## eventid, \
+ l_pTrn## reaction, #eventid);
+
+/// Connect application defined deferred event to framework state
+#define CONNECT_FRAMEWORKUNIFIED_DEFERREDEVENT(state, eventid) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## state, CFrameworkunifiedHSMParentFramework::_## eventid, \
+ NULL, #eventid, TRUE);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro associates an application event with a process and adds it to a state.
+/// \~english @param [in] state State
+/// \~english @param [in] eventid Event ID
+/// \~english @param [in] reaction Pointers to CFrameworkunifiedReaction objects
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macros retrieves the current state machine from the application handles used in the process, and associates the events of the application with the process and adds them to the state using FrameworkunifiedFrameworkConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIED_CONNECT_APP_EVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(CFrameworkunifiedHSMParentFramework::e## state, _## eventid, \
+ l_pTrn## reaction, #eventid);
+
+#define FRAMEWORKUNIFIED_CONNECT_APP_DEFERREDEVENT(state, eventid) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedFrameworkConnect(CFrameworkunifiedHSMParentFramework::e## state, _## eventid, \
+ NULL, #eventid, TRUE);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that create and add Shallow history states to their parents.
+/// \~english @param [in] parent Parent state
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro retrieves the current state machine from the application handles used in the process after a new Shallow history state is created, and adds the Shallow history state created to the parent state using FrameworkunifiedConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+// create a new shallow history state and add it in parent state
+#define ADD_SHALLOWHISTORYSTATE(parent) \
+ CFrameworkunifiedShallowHistoryState *l_p##parent##SHALLOWHISTORYSTATE = new CFrameworkunifiedShallowHistoryState(SHALLOWHISTORYSTATE);\
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## parent, l_p##parent##SHALLOWHISTORYSTATE);\
+ CHKNULL(l_p##parent##SHALLOWHISTORYSTATE);\
+ l_p##parent##SHALLOWHISTORYSTATE->SetDefaultHistory();
+
+// create a new shallow history state and add it in parent state
+#define ADD_DEEPHISTORYSTATE(parent) \
+ CFrameworkunifiedDeepHistoryState *l_p##parent##DEEPHISTORYSTATE = new CFrameworkunifiedDeepHistoryState(DEEPHISTORYSTATE);\
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## parent, l_p##parent##DEEPHISTORYSTATE);\
+ CHKNULL(l_p##parent##DEEPHISTORYSTATE);\
+ l_p##parent##DEEPHISTORYSTATE->SetDefaultHistory();
+
+/// connect deep history event to reaction and add to state
+#define CONNECT_DEEPHISTORYEVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##DEEPHISTORYSTATE, #eventid);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that associate Shallow history events with processes and add them to states.
+/// \~english @param [in] state State
+/// \~english @param [in] eventid Event ID
+/// \~english @param [in] reaction Pointers to CFrameworkunifiedReaction objects
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macros retrieves the current state machine from the application handles used in the process and associates Shallow history events with the process and adds them to the state using FrameworkunifiedConnect().
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// connect shallow history event to reaction and add to state
+#define CONNECT_SHALLOWHISTORYEVENT(state, eventid, reaction) \
+ (FrameworkunifiedGetStateMachine(hApp))->FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn##reaction##SHALLOWHISTORYSTATE, #eventid);
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+///////////////////////////////////////////////////////////////////////////////////////////
+
+/// FrameworkunifiedCreateStateMachine
+/// The application state machine is created in this interface. User defined events can also
+/// be connected to the framework states in this interface.
+///
+/// \~english @par Brief
+/// - It's a callback function to create state machine used by application.
+/// \~english @param [in] hApp
+/// HANDLE - handle to application
+/// \~english @retval eFrameworkunifiedStatusOK -successed
+/// \~english @retval Except eFrameworkunifiedStatusOK - failure
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Inside state change
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// The application state machine is created in this interface. User defined events can also\n
+/// be connected to the framework states in this interface.
+/// - FrameworkunifiedDispatcherWithArguments
+/// - FrameworkunifiedDispatcher
+/// - FrameworkunifiedCreateDispatcherWithoutLoop
+/// \~english @par Classification
+/// - Public
+/// \~english @see FrameworkunifiedDispatcherWithArguments, FrameworkunifiedDispatcher, FrameworkunifiedCreateDispatcherWithoutLoop
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+/// All HSM applications must define this function. This function will be called on entry
+/// of sFrameworkunifiedLoadData state.
+// Expected in this function:
+/// All the persistent data of the applications should be loaded in this function.
+///
+/// \~english @par Brief
+/// - This function defines loading persistent data of HSM application.
+/// \~english @param [in] hApp
+/// HANDLE - handle to application
+/// \~english @retval eFrameworkunifiedStatusOK -successed
+/// \~english @retval Except eFrameworkunifiedStatusOK - failure
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Inside state change
+/// - None
+/// \~english @par Conditions of processing failure
+/// - The implementation specification of the callback depends on the implementation (design) of the application.
+/// For this reason, the application should consider the Public of errors in the failed condition.
+/// \~english @par Detail
+/// - All HSM applications must define this function. This function will be called on entry\n
+/// of sFrameworkunifiedLoadData state.Expected in this function:\n
+/// All the persistent data of the applications should be loaded in this function.
+/// \~english @par Classification
+/// - Private
+/// \~english @par Detail
+/// - None
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedHSMOnLoadData(HANDLE hApp);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+/// All HSM applications must define this function. This function will be called on exit
+/// of sFrameworkunifiedRun state.
+// Expected in this function:
+/// Send stop request to all the child threads.
+///
+/// \~english @par Brief
+/// - This function defines sending stop request to the child threads of HSM application.
+/// \~english @param [in] hApp
+/// HANDLE - handle to application
+/// \~english @retval eFrameworkunifiedStatusOK -successed
+/// \~english @retval Except eFrameworkunifiedStatusOK - failure
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Inside state change
+/// - None
+/// \~english @par Conditions of processing failure
+/// - The implementation specification of the callback depends on the implementation (design) of the application.
+/// For this reason, the application should consider the Public of errors in the failed condition.
+/// \~english @par Detail
+/// - All HSM applications must define this function.\n
+/// This function will be called on exit of sFrameworkunifiedRun state.\n
+/// Expected in this function:Send stop request to all the child threads.
+/// \~english @par Classification
+/// - Private
+/// \~english @par Type
+/// - None
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedHSMOnStopInsFrameworkunifiedRun(HANDLE hApp);
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_FRAMEWORK_IF_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_types.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_types.h
new file mode 100644
index 00000000..fb00ecd3
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_framework_types.h
@@ -0,0 +1,494 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This File has public Macro definition that simplifies the statemachine implementation
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_framework_types.h
+ * @brief \~english This File has public Macro definition that simplifies the statemachine implementation
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_FRAMEWORKUNIFIED_SM_FRAMEWORK_TYPES_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_FRAMEWORKUNIFIED_SM_FRAMEWORK_TYPES_H__
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_leafstate.h>
+#include <native_service/frameworkunified_sm_internaltransition.h>
+#include <native_service/frameworkunified_sm_compositestate.h>
+#include <native_service/frameworkunified_sm_eventfactory.h>
+#include <native_service/frameworkunified_sm_externaltransition.h>
+#include <native_service/frameworkunified_sm_localtransition.h>
+#include <native_service/frameworkunified_sm_orthogonalstate.h>
+#include <native_service/frameworkunified_sm_shallowhistorystate.h>
+#include <native_service/frameworkunified_sm_deephistorystate.h>
+#include <native_service/frameworkunified_sm_guard.h>
+#include <native_service/frameworkunified_sm_conditionconnector.h>
+#include <native_service/frameworkunified_sm_action.h>
+#include <native_service/frameworkunified_sm_eventdata.h>
+#include <exception>
+#include <string>
+
+class CFrameworkunifiedState;
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Defines the null pointer exception
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CNullPointerException: public std::exception {
+ virtual const char *what() const throw() {
+ return "Null pointer exception";
+ }
+};
+
+
+/// Macro to check pointer for null value and throw null pointer exception
+#define CHKNULL(x) if (NULL == x) throw CNullPointerException();
+
+#define SHALLOWHISTORYSTATE "ShallowHistory"
+#define DEEPHISTORYSTATE "DeepHistory"
+
+/// Defines the state machine class
+#define DEFINE_STATEMACHINE(class_name) \
+ class C## class_name : public CFrameworkunifiedHSM{ \
+ public: \
+ C## class_name(); \
+ virtual ~C## class_name(); \
+ EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL); \
+ };
+
+/// Defines the leafstate class that does not override entry and exit of base state
+#define DEFINE_LEAFSTATE(class_name) \
+ class C## class_name : public CFrameworkunifiedLeafState { \
+ public: \
+ C## class_name(std::string f_pName):CFrameworkunifiedLeafState(f_pName) {} };
+
+/// Defines the Composite state that does not override entry and exit of base state
+#define DEFINE_COMPOSITESTATE(class_name) \
+ class C## class_name : public CFrameworkunifiedCompositeState { \
+ public: \
+ C## class_name(std::string f_pName):CFrameworkunifiedCompositeState(f_pName) {} };
+
+/// Defines the Orthogonal state that does not override entry and exit of base state
+#define DEFINE_ORTHOGONALSTATE(class_name) \
+ class C## class_name : public CFrameworkunifiedOrthogonalState { \
+ public: \
+ C## class_name(std::string f_pName):CFrameworkunifiedOrthogonalState(f_pName) {} };
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that inherit CFrameworkunifiedLeafState classes.
+/// \~english @param [in] class_name Class name
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Macros that inherit from CFrameworkunifiedLeafState classes and override the following methods:
+/// The following overriding methods should be implemented by the user.
+/// - FrameworkunifiedOnEntry
+/// - FrameworkunifiedOnExit
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Defines the leafstate that overrides entry and exit of base state
+#define DEFINE_LEAFSTATE_OVERRIDE(class_name) \
+ class C## class_name : public CFrameworkunifiedLeafState{ \
+ public: \
+ C## class_name(std::string f_pName); \
+ virtual ~C## class_name(); \
+ EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData); \
+ EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData); \
+ };
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that inherit CFrameworkunifiedCompositeState classes.
+/// \~english @param [in] class_name Class name
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Macros that inherit from CFrameworkunifiedCompositeState classes and override the following methods:
+/// The following overriding methods should be implemented by the user.
+/// - FrameworkunifiedOnEntry
+/// - FrameworkunifiedOnExit
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Defines the Composite state class that overrides entry and exit of base state
+#define DEFINE_COMPOSITESTATE_OVERRIDE(class_name) \
+ class C## class_name : public CFrameworkunifiedCompositeState{ \
+ public: \
+ C## class_name(std::string f_pName); \
+ virtual ~C## class_name(); \
+ EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData); \
+ EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData); \
+ };
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that inherit CFrameworkunifiedOrthogonalState classes.
+/// \~english @param [in] class_name Class name
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Macros that inherit from CFrameworkunifiedOrthogonalState classes and override the following methods:
+/// The following overriding methods should be implemented by the user.
+/// - FrameworkunifiedOnEntry
+/// - FrameworkunifiedOnExit
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Defines the Orthogonal state that overrides entry and exit of base state
+#define DEFINE_ORTHOGONALSTATE_OVERRIDE(class_name) \
+ class C## class_name : public CFrameworkunifiedOrthogonalState{ \
+ public: \
+ C## class_name(std::string f_pName); \
+ virtual ~C## class_name(); \
+ EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData); \
+ EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData); \
+ };
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that inherit CFrameworkunifiedInternalTransition classes.
+/// \~english @param [in] class_name Class name
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Macros that inherit from CFrameworkunifiedInternalTransition classes and override the following methods:
+/// The following overriding methods should be implemented by the user.
+/// - FrameworkunifiedReaction
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Defines the InternalTransition class
+#define DEFINE_INTERNALTRANSITION(class_name) \
+ class C## class_name : public CFrameworkunifiedInternalTransition{ \
+ public: \
+ virtual CFrameworkunifiedState* FrameworkunifiedReaction(CFrameworkunifiedState* f_pSourceState, CEventDataPtr f_pData); \
+ };
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Macros that define application events.
+/// \~english @param [in] event_name Event name
+/// \~english @param [in] value Event value
+/// \~english @retval UI_32 Event value for the application
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Values of events defined in CFrameworkunifiedEventFactory classes (evFrameworkunifiedEventLimit:10) are specifiedMacros that define events for an application by adding event values (value).
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Defines the application event
+#define DEFINE_EVENT(event_name, value) \
+ static const UI_32 _## event_name = CFrameworkunifiedEventFactory::evFrameworkunifiedEventLimit + value;
+
+#define DEFINE_ACTION(class_name) \
+ class C## class_name: public CFrameworkunifiedAction{ \
+ public: \
+ C## class_name(std::string f_strName):CFrameworkunifiedAction(f_strName) {} \
+ VOID FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState, CEventDataPtr f_pEventData); \
+ };
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro creates an instance for an internal transition.
+/// \~english @param [in] class_name Class name
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// This macro creates an instance for an internal transition of a class with the specified name.\n
+/// Otherwise, the CNullPointerException objects are excepted.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// creates the instance of the internal transition
+#define CREATE_INTERNALTRANSITION(class_name) \
+ C## class_name *l_pTrn## class_name = new C## class_name(); \
+ CHKNULL(l_pTrn## class_name);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// This macro creates an instance for an external transition.
+/// \~english @param [in] target_state State name for external transition
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Macros that instantiate CFrameworkunifiedExternalTransition classes for external transitions.\n
+/// Otherwise, the CNullPointerException objects are excepted.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// creates the instance of the external transition
+#define CREATE_EXTERNALTRANSITION(target_state) \
+ CFrameworkunifiedExternalTransition *l_pTrn## target_state = new CFrameworkunifiedExternalTransition(l_p## target_state); \
+ CHKNULL(l_pTrn## target_state);
+
+/// creates the instance of the external transition
+#define CREATE_CONDITIONCONNECTOR(connector_name) \
+ CFrameworkunifiedConditionConnector *l_pTrn## connector_name = new CFrameworkunifiedConditionConnector( #connector_name); \
+ CHKNULL(l_pTrn## connector_name);
+
+
+/// creates the instance of the local transition
+#define CREATE_LOCALTRANSITION(target_state) \
+ CFrameworkunifiedLocalTransition *l_pLocalTrn## target_state = new CFrameworkunifiedLocalTransition(l_p## target_state); \
+ CHKNULL(l_pLocalTrn## target_state);
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// A macro that instantiates an orthographic region.
+/// \~english @param [in] target_state State name for external transition
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// Macros that create instances of compound states (CFrameworkunifiedCompositeState classes) as instances of orthographic regions.\n
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// create orthogonal region
+#define CREATE_ORTHOGONALREGION(name) \
+ CFrameworkunifiedCompositeState *l_p## name = new CFrameworkunifiedCompositeState(#name);
+
+/// create action for external transition
+#define CREATE_ACTION(class_name) \
+ C## class_name *l_pTrn## class_name = new C## class_name( #class_name); \
+ CHKNULL(l_pTrn## class_name);
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// A macro that defines events for the framework.
+/// \~english @param [in] eventid Event ID
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// These macros define the IDs of the current events in the CFrameworkunifiedHSMParentFramework classes.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// framework event
+#define FRAMEWORKUNIFIED_EVENT(eventid) \
+ CFrameworkunifiedHSMParentFramework::_## eventid
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// Is a macro that defines events for an application
+/// \~english @param [in] eventid Event ID
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// A macro that defines an event ID for an application.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Application event
+#define EVENT(eventid) \
+ _## eventid
+
+/// FrameworkunifiedReaction function signature for internal transition class
+#define IMPLEMENT_INTERNALTRANSITION(name) \
+ CFrameworkunifiedState* C## name::FrameworkunifiedReaction(CFrameworkunifiedState* f_pSourceState, CEventDataPtr f_pData)
+
+#define IMPLEMENT_ACTION(action_name) \
+ void C## action_name::FrameworkunifiedAction(CFrameworkunifiedState *f_pSourceState, CFrameworkunifiedState *f_pTargetState, CEventDataPtr f_pEventData)
+
+#define DEFINE_GUARD(guard_name)\
+ class C## guard_name : public CFrameworkunifiedGuard{ \
+ public: \
+ C## guard_name(std::string f_pName):CFrameworkunifiedGuard(f_pName) {} \
+ virtual BOOL FrameworkunifiedEvaluate();\
+ };
+
+#define CREATE_GUARD(guard_name)\
+ CFrameworkunifiedGuard *l_pGrd## guard_name = new C## guard_name(#guard_name);
+
+#define CONNECT_GUARD(transition, guard)\
+ l_pTrn## transition->FrameworkunifiedSetGuard(l_pGrd## guard);
+
+#define CONNECT_CONDITION(connector_name , guard , target_state) \
+ CHKNULL(l_pTrn## connector_name)\
+ l_pTrn## connector_name->FrameworkunifiedAddCondition(l_pGrd## guard , l_p## target_state); \
+
+#define IMPLEMENT_GUARD(guard_name) \
+ BOOL C## guard_name::FrameworkunifiedEvaluate()
+
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StateMachine_Macro
+/// \~english @par Brief
+/// These macros create instances for Shallow history transitions.
+/// \~english @param [in] parent State name for external transition
+/// \~english @retval None
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// These macros create instances of CFrameworkunifiedExternalTransition classes for external transitions of Shallow history transitions.\n
+/// Otherwise, the CNullPointerException objects are excepted.
+/// \~english @par Classification
+/// Public
+/// \~english @see None
+///////////////////////////////////////////////////////////////////////////////////////////
+/// creates the instance of the shallow history transition
+#define CREATE_SHALLOWHISTORYTRANSITION(parent) \
+ CFrameworkunifiedExternalTransition *l_pTrn##parent##SHALLOWHISTORYSTATE = \
+ new CFrameworkunifiedExternalTransition(l_p##parent##SHALLOWHISTORYSTATE); \
+ CHKNULL(l_pTrn##parent##SHALLOWHISTORYSTATE);
+
+/// creates the instance of the deep history transition
+#define CREATE_DEEPHISTORYTRANSITION(parent) \
+ CFrameworkunifiedExternalTransition *l_pTrn##parent##DEEPHISTORYSTATE = \
+ new CFrameworkunifiedExternalTransition(l_p##parent##DEEPHISTORYSTATE); \
+ CHKNULL(l_pTrn##parent##DEEPHISTORYSTATE);
+
+#define CONNECT_CONDITION_SHALLOWHISTORYTRANSITION(connector_name , guard , target_state) \
+ CHKNULL(l_pTrn## connector_name)\
+ l_pTrn## connector_name->FrameworkunifiedAddCondition(l_pGrd## guard , l_p## target_state##SHALLOWHISTORYSTATE); \
+
+
+#define CONNECT_CONDITION_DEEPHISTORYTRANSITION(connector_name , guard , target_state) \
+ CHKNULL(l_pTrn## connector_name)\
+ l_pTrn## connector_name->FrameworkunifiedAddCondition(l_pGrd## guard , l_p## target_state##DEEPHISTORYSTATE); \
+
+
+#define CONNECT_ACTION(transition, action_name) \
+ CHKNULL(l_pTrn## action_name); \
+ CHKNULL(l_pTrn## transition); \
+ l_pTrn## transition->FrameworkunifiedAddAction(l_pTrn## action_name); \
+
+#ifdef DEBUG
+#define FRAMEWORKUNIFIED_PRINT_HSM(x) (FrameworkunifiedGetStateMachine(x))->FrameworkunifiedPrintXML();
+#define PRINT_HSM() FrameworkunifiedPrintXML();
+#else
+#define FRAMEWORKUNIFIED_PRINT_HSM(x)
+#define PRINT_HSM()
+#endif
+
+/// defines options for integrating user change state
+typedef enum _EUserChangeOptions {
+ eUserchangeIgnore = 0,
+ eUserchangeReInit,
+ eUserchangeRetPrevState
+} EUserChangeOptions;
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_FRAMEWORKUNIFIED_SM_FRAMEWORK_TYPES_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_guard.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_guard.h
new file mode 100644
index 00000000..1792f72f
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_guard.h
@@ -0,0 +1,145 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedGuard class definitions. This is an interface that defines the Evaluate
+/// interface for guard condition validation.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_guard.h
+ * @brief \~english This file has the CFrameworkunifiedGuard class definitions.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDGUARD_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDGUARD_H
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+
+/**
+ * @class CNSSharedMem
+ * \~english @brief this file has the CFrameworkunifiedGuard class definitions
+ * \~english @par Brief Introduction
+ * This file has the CFrameworkunifiedGuard class definitions. This is an interface \n
+ * that defines the Evaluate interface for guard condition validation.
+ *
+ */
+class CFrameworkunifiedGuard {
+ public :
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedGuard
+ /// \~english @par Brief
+ /// CFrameworkunifiedGuard's constructor
+ /// \~english @param [in] f_strName
+ /// string - Name of the guard
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - CFrameworkunifiedGuard's constructor
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see ~CFrameworkunifiedGuard
+ ////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedGuard(std::string f_strName); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CFrameworkunifiedGuard
+ /// \~english @par Brief
+ /// - Destructor of CFrameworkunifiedGuard class
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - Destruct the object of this class.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see CFrameworkunifiedGuard
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedGuard();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedGuard
+ /// \~english @par Brief
+ /// This is a pure virtual function that defines the logic for evaluating the guard condition
+ /// \~english @param None
+ /// \~english @retval TRUE - if test passes
+ /// \~english @retval FALSE - otherwise returns false
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - This is a pure virtual function that defines the logic for evaluating the guard condition
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual BOOL FrameworkunifiedEvaluate() = 0;
+
+ private:
+ std::string m_strName;
+};
+
+#endif // _FRAMEWORKUNIFIEDGUARD_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_historystate.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_historystate.h
new file mode 100644
index 00000000..47d5914b
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_historystate.h
@@ -0,0 +1,253 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the declaration of CFrameworkunifiedHistoryState interface.
+/// CFrameworkunifiedHistoryState is derived from CFrameworkunifiedState class.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_historystate.h
+ * @brief \~english This file has the declaration of CFrameworkunifiedHistoryState interface.
+ * CFrameworkunifiedHistoryState is derived from CFrameworkunifiedState class.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDHISTORYSTATE_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDHISTORYSTATE_H
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_sm_state.h>
+#include <string>
+
+/**
+ * @class CFrameworkunifiedHistoryState
+ * \~english @brief this file has the CFrameworkunifiedHistoryState class definitions
+ * \~english @par Brief Introduction
+ * This class implements the additional functionality supported by HSM History state.
+ *
+ */
+class CFrameworkunifiedHistoryState : public CFrameworkunifiedState {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHistoryState
+ /// \~english @par Brief
+ /// -Constructor of CFrameworkunifiedHistoryState.
+ /// \~english @param [in] f_pName
+ /// std::string - Name of the state
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - This class inherits from CFrameworkunifiedState, which is the base class of state machine.
+ /// This class implements the additional functionality supported by HSM History state.
+ /// This function creates an object of CFrameworkunifiedHistoryState class.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @see ~CFrameworkunifiedHistoryState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedHistoryState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ CFrameworkunifiedHistoryState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHistoryState
+ /// \~english @par Brief
+ /// -Destructor of CFrameworkunifiedHistoryState.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// -Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// -Destruct the object of this class.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @see CFrameworkunifiedHistoryState::CFrameworkunifiedHistoryState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedHistoryState
+ /// Class destructor
+ ///
+ /// \return none
+ virtual ~CFrameworkunifiedHistoryState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHistoryState
+ /// \~english @par Brief
+ /// - Gets the pointor of this class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - Gets the pointor of this class.The pointor of this class's base class will get it.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHistoryState
+ /// \~english @par Brief
+ /// - This function stores the last active state.
+ /// \~english @param None
+ /// \~english @retval EFrameworkunifiedStatus - Returns status of operation
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - This function stores the last active state.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus UpdateHistory() = 0;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHistoryState
+ /// \~english @par Brief
+ /// - This function sets the default active state in history state.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK - Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - Null Pointer
+ /// \~english @par Preconditons
+ /// -Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// -m_pParentState is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// -This function sets the default state of parent state to the newest active state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// SetDefaultHistory
+ /// This function sets the default active state in history state
+ /// \param
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ EFrameworkunifiedStatus SetDefaultHistory();
+
+ protected :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEntry
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnExit
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnHSMStart
+ /// This function is called recursively till the leaf state is reached. This internally
+ /// calls the Entry function of the current state.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnHSMStop
+ /// This function is called recursively till the required parent state is reached. This
+ /// internally calls the Exit function of the current state.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData);
+
+ // last active state
+ CFrameworkunifiedState *m_pLastActiveState;
+
+ // event id of history state
+ UI_32 m_uiEventId;
+
+ // event name
+ std::string m_cEventName;
+};
+#endif // _FRAMEWORKUNIFIEDHISTORYSTATE_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsm.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsm.h
new file mode 100644
index 00000000..1a8e1d74
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsm.h
@@ -0,0 +1,798 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
+/// This class implements interfaces for connecting child states to parent states, connecting events
+/// to state.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_hsm.h
+ * @brief \~english This file has the CFrameworkunifiedHSM class definitions. CFrameworkunifiedHSM is base class for HSM Framework.
+ * This class implements interfaces for connecting child states to parent states, connecting events to state.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/frameworkunified_sm_eventdata.h>
+#include <vector>
+#include <exception>
+#include <map>
+#include <string>
+
+class CFrameworkunifiedEvent;
+
+class CFrameworkunifiedState;
+
+class CFrameworkunifiedCompositeState;
+
+class CFrameworkunifiedReaction;
+
+class CFrameworkunifiedOrthogonalState;
+
+class CEventData;
+
+typedef boost::shared_ptr<CEventData> CEventDataPtr;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements interfaces for connecting child states to parent states, connecting events
+/// to state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedHSM {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Destructor for CFrameworkunifiedHSM
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal status
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Release class CFrameworkunifiedHistoryState instance.\n
+ /// Release event in postevent list.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedHSM
+ /// Class destructor
+ ///
+ /// \return none
+ virtual ~CFrameworkunifiedHSM();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedHSM.
+ /// \~english @param
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSM class is the super class of HSM framework.
+ /// this class produce interface to connected super class state with sub class state and to connect event with
+ /// state
+ /// create the instance of CFrameworkunifiedHSM class\n
+ /// create event list as following and hold the member parameter,others will be initialized as NULL
+ /// - event list which is supported in state
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see ~CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSM();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Constructor for class CFrameworkunifiedHSM.
+ /// \~english @param f_pHApp
+ /// PVOID - handle of application
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// none
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSM class is the super class of HSM framework.
+ /// this class produce interface to connected super class state with sub class state and to connect event with
+ /// state
+ /// create the instance of CFrameworkunifiedHSM class\n
+ /// create event list as following and hold the member parameter,others will be initialized as NULL
+ /// - event list which is supported in state
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see ~CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedHSM(PVOID f_pHApp)
+ /// Class constructor
+ ///
+ /// \return none
+ CFrameworkunifiedHSM(PVOID f_pHApp); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Returns the active state of the statemachine
+ /// \~english @param none
+ /// \~english @retval CFrameworkunifiedState* - Returns ActiveState
+ /// \~english @retval NULL - failed
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created and active state exist.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - active state do not exist. [NULL]
+ /// \~english @par Detail
+ /// route state search will be continued until current state become active
+ /// route state search will be continued until Leaf State or orthogonal State is found\n
+ /// if there is no active state.reture NULL\n
+ /// if there is active state,this state will be hold in memeber parameter as return value
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedGetActiveState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// This creates the default event data and sends the event to the active HSM state.
+ /// \~english @param f_uiEventId
+ /// UI_32 - Event Id
+ /// \~english @retval eFrameworkunifiedStatusOK add succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Event data instance create faield. [eFrameworkunifiedStatusNullPointer]
+ /// - The pointer of post event list in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - The pointer of active state in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - The name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// create new event data object and send this event to active HSM state,\n
+ /// then add to event queue of the statemachine
+ /// add to event queque in order to process event using statemachine
+ /// event will be deleted from event queue when process complete
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedPostEvent(CEventDataPtr), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPostEvent
+ /// This creates the default event data and sends the event to the active HSM state.
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event Id
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedPostEvent(UI_32 f_uiEventId);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPostEvent
+ /// This sends the event to the active HSM state
+ ///
+ /// \~english @par Brief
+ /// Add event data into event queue of state machine.
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Event data
+ /// \~english @retval eFrameworkunifiedStatusOK add succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Input parameter f_pEventData is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - The pointer of post event list in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - The pointer of active state in State machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - The name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ ///
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedPostEvent(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// This is pure virtual function to be implemented by the derived classes. Statemachine
+ /// states and events created and connected in this interface.
+ /// \~english @param f_pEventData
+ /// PVOID - Event data
+ /// \~english @retval EFrameworkunifiedStatus Returns status of operation
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ // none
+ /// \~english @par Detail
+ /// none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL) = 0;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedStart
+ /// This starts the state machine
+ ///
+ /// \~english @par Brief
+ /// Start the state machine.
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Event data
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer set null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ // - Pointer of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ ///
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedStart(CEventDataPtr f_pEventData = boost::make_shared<CEventData>(0));
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Stop the state machine.
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Event data
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ // - Pointer of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Stop the state machine.\n
+ /// Release route state of state machine.\n
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedPostEvent(UI_32), CEventData, FrameworkunifiedQueueEvent, ProcessEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedClose(CEventDataPtr f_pEventData = boost::make_shared<CEventData>(0));
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPrintAllStates
+ /// This prints all states and events associated with every state on console.
+ ///
+ /// \~english @par Brief
+ /// Output log of all states and events name associated with every state.
+ /// \~english @param
+ /// \~english @retval EFrameworkunifiedStatus succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Root state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Self instance of CFrameworkunifiedHSM does not create. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// print out log for connected state name and event name\n
+ /// following log will be print put
+ /// - super statemachine state name and self-statemachine state name
+ /// - all the event name on event list
+ /// - all the event on delayed event list
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedPrintAllStates();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// This connects the reaction to event and add event to child states then add child state
+ /// to parent state.
+ /// \~english @param f_pParentState
+ /// CFrameworkunifiedState* - Parent state pointer
+ /// \~english @param f_pChildState
+ /// CFrameworkunifiedState* - Child state pointer
+ /// \~english @param f_uiEventId
+ /// UI_32 - eventi id
+ /// \~english @param f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction object for attaching to event
+ /// \~english @param f_eIsDefaultState
+ /// BOOL - Does has default state.(default: FALSE)
+ /// \~english @par
+ /// - TRUE : has default state
+ /// - FALSE: not has default state
+ /// \~english @param f_eIsDeferredEventType
+ /// BOOL - Does has the deferred event(default: FALSE)
+ /// \~english @par
+ /// - TRUE : has the deferred event
+ /// - FALSE: not has the deferred event
+ /// \~english @param f_strEventName
+ /// std::string - name of event(default:"")
+ /// \~english @retval eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Input parameter f_pParentState pointer is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pChildState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pReaction pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pParentState does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pChildState does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// connect process with event and add the event to sub state.
+ /// and do following considering the event delay and event declare(f_eIsDeferredEventType)
+ /// - if TRUE : add the event as delayed event(add to event name list and delayed event list)
+ /// - if FALSE:add normal event and event(add to event name list and event list)
+ /// \~english @par
+ /// After adding an event to a child state, associate the child state with the parent state and
+ /// set the HSM state machine for the child state only if the parent state is a compound state.
+ /// The following associations are made depending on whether or not a default state is defined (f_eIsDefaultState).
+ /// - TRUE: Associates a child state as the default state with the parent state.
+ /// - FALSE: Associates a child state with a parent state as a normal state.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,std::string,BOOL),
+ /// FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,BOOL)
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedConnect
+ /// This connects the reaction to event and add event to child states then add child state
+ /// to parent state.
+ ///
+ /// \param [in] f_pParentState
+ /// CFrameworkunifiedState* - Parent state
+ ///
+ /// \param [in] f_pChildState
+ /// CFrameworkunifiedState* - Child state
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id
+ ///
+ /// \param [in] f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction object for attaching to event
+ ///
+ /// \param [in] f_eIsDefaultState
+ /// BOOL - Defines if the state is default state
+ ///
+ /// \param [in] f_eIsDeferredEventType
+ /// BOOL - defines if the event is deferred event
+ ///
+ /// \param [in] f_strEventName
+ /// BOOL - Event name
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
+ UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
+ BOOL f_eIsDefaultState = FALSE,
+ BOOL f_eIsDeferredEventType = FALSE,
+ std::string f_strEventName = "");
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// This add child state to parent state.
+ /// \~english @param f_pParentState
+ /// CFrameworkunifiedState* - Parent state pointer
+ /// \~english @param f_pChildState
+ /// CFrameworkunifiedState* - Child state pointer
+ /// \~english @param f_eIsDefaultState
+ /// BOOL - Does has default state.(default: FALSE)
+ /// \~english @par
+ /// - TRUE : has default state
+ /// - FALSE: not has default state
+ /// \~english @retval eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Input parameter f_pParentState pointer is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pChildState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pParentState does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pChildState does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// connect super state with sub state and set HSM state machine to sub state only when super state is compond
+ /// state
+ /// according to the default state define(f_eIsDefaultState),doing the connection below
+ /// - if TRUE: connect sub state as default state with super state
+ /// - if FALSE: connect sub state as normal state with super state
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,std::string,BOOL),
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedConnect
+ /// This add child state to parent state.
+ ///
+ /// \param [in] f_pParentState
+ /// CFrameworkunifiedState* - Parent state
+ ///
+ /// \param [in] f_pChildState
+ /// CFrameworkunifiedState* - Child state
+ ///
+ /// \param [in] f_eIsDefaultState
+ /// BOOL - Defines if the state is default state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedConnect(CFrameworkunifiedState *f_pParentState, CFrameworkunifiedState *f_pChildState,
+ BOOL f_eIsDefaultState = FALSE);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedConnect
+ /// This connects the reaction to event and add event to states
+ ///
+ /// \~english @par Brief
+ /// This connects the reaction to event and add event to states.
+ /// \~english @param f_pState
+ /// CFrameworkunifiedState* - pointer of state class
+ /// \~english @param f_uiEventId
+ /// UI_32 - eventi id
+ /// \~english @param f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction object for attaching to event
+ /// \~english @param f_eIsDefaultState
+ /// BOOL - Does has default state.(default: FALSE)
+ /// \~english @par
+ /// - TRUE : has default state
+ /// - FALSE: not has default state
+ /// \~english @param f_eIsDeferredEventType
+ /// BOOL - Does has the deferred event(default: FALSE)
+ /// \~english @par
+ /// - TRUE : has the deferred event
+ /// - FALSE: not has the deferred event
+ /// \~english @param f_strEventName
+ /// std::string - name of event(default:"")
+ /// \~english @retval eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Input parameter f_pReaction pointer is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pState pointer does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// connect process with event and add event to sub state
+ /// following will be added according to whether delayed event or event define exsist
+ /// - if TRUE : add event as delayed event(add to event name list and delayed event list)
+ /// - if FALSE: add event as normal event(add to event name list and event list)
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,BOOL,BOOL,std::string)
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedConnect(CFrameworkunifiedState *f_pState, UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction,
+ std::string f_strEventName = "", BOOL f_eIsDeferredEventType = FALSE);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// This sets the givens state as root state in the state machine
+ /// \~english @param f_pRootState
+ /// CFrameworkunifiedState* - Root state
+ /// \~english @retval eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Input parameter f_pRootState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pRootState does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// set state(f_pRootState, which is designated as route state) to HSM state machine
+ /// set route state pointer(f_pRootState,which is set as parameter value)as pointer of
+ /// active state for member
+ /// parameter and routestate
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see FrameworkunifiedConnect(CFrameworkunifiedState*,CFrameworkunifiedState*,UI_32,CFrameworkunifiedReaction*,BOOL,BOOL,std::string)
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedConnect
+ /// This sets the givens state as root state in the state machine
+ ///
+ /// \param [in] f_pRootState
+ /// CFrameworkunifiedState* - Root state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedConnect(CFrameworkunifiedState *f_pRootState);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Set Composite state as HSM state OrthogonalState.
+ /// \~english @param f_pOrthogonalState
+ /// CFrameworkunifiedOrthogonalState* - Orthogonal state pointer
+ /// \~english @param f_pOrthogonalRegion
+ /// CFrameworkunifiedCompositeState* - Composite state pointer
+ /// \~english @retval eFrameworkunifiedStatusOK succ
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer(process failed)
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - Input parameter f_pOrthogonalState pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pOrthogonalRegion pointer is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Input parameter f_pOrthogonalState does not instance. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Set Composite state as HSM state OrthogonalState.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedConnect
+ /// This sets the givens state as root state in the state machine
+ ///
+ /// \param [in] f_pOrthogonalState
+ /// CFrameworkunifiedOrthogonalState* - Orthogonal state
+ ///
+ /// \param [in] f_pOrthogonalRegion
+ /// CFrameworkunifiedCompositeState* - Orthogonal region
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedConnectOrthogonal(CFrameworkunifiedOrthogonalState *f_pOrthogonalState,
+ CFrameworkunifiedCompositeState *f_pOrthogonalRegion);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// This interface returns the application handle
+ /// \~english @param none
+ /// \~english @retval HANDLE application handle
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ HANDLE FrameworkunifiedGetAppHandle();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Output statemachine information into XML file.
+ /// \~english @param none
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK succ
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedPrintXML();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Push the event in the post event list.
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - pointer of event data
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK succ
+ /// eFrameworkunifiedStatusNullPointer NULL pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - If input parameter f_pEventData is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If member variable m_pActiveState is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - If member variable m_pPostEventList is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedQueueEvent(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSM
+ /// \~english @par Brief
+ /// Remove the all events of eventId f_uiEventId from event queue of statemachine.
+ /// \~english @param f_pEventData
+ /// const UI_32 - event id
+ /// \~english @retval EFrameworkunifiedStatus eFrameworkunifiedStatusOK succ
+ /// eFrameworkunifiedStatusInvldID Not found event id
+ /// eFrameworkunifiedStatusNullPointer NULL pointer
+ /// \~english @par Prerequisite
+ /// - Self instance of CFrameworkunifiedHSM created.
+ /// \~english @par Change of internal state
+ /// none
+ /// \~english @par Conditions of processing failure
+ /// - If not find event id. [eFrameworkunifiedStatusInvldID]
+ /// - If member variable m_pPostEventList is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// none
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RemoveEventFromPostedEventQueue(const UI_32 f_uiEventId);
+
+ UI_32 m_uiCurrentEvent;
+
+ /// Application handle
+ HANDLE m_pHApp;
+
+ private:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ProcessEventQueue
+ /// Gets the event from StateMachine events list and post it.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ProcessEventQueue();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ProcessEvent
+ /// Processes the event posted to the statemachine
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ProcessEvent(CEventDataPtr f_pEventData);
+
+ /// pointer to the active state object
+ CFrameworkunifiedState *m_pActiveState;
+
+ /// pointer to the root state object
+ CFrameworkunifiedState *m_pRootState;
+
+ std::vector<CEventDataPtr> *m_pPostEventList;
+
+ BOOL m_bIsTransitioning;
+};
+
+#endif // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSM_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsmframework.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsmframework.h
new file mode 100644
index 00000000..fd61117f
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_hsmframework.h
@@ -0,0 +1,873 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedHSMParentFramework class definitions. CFrameworkunifiedHSMParentFramework is derived from
+/// CFrameworkunifiedHSM class. It defines the states required for NS statemachine framework, it creates the NS
+/// statemachine and implements the reaction associated with the events
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_hsmframework.h
+ * @brief \~english This file has the CFrameworkunifiedHSMParentFramework class definitions. CFrameworkunifiedHSMParentFramework is derived from
+ * CFrameworkunifiedHSM class. It defines the states required for NS statemachine framework, it creates the NS
+ * statemachine and implements the reaction associated with the events
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSMFRAMEWORK_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSMFRAMEWORK_H__
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/ns_timer_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <map>
+#include <string>
+
+class CFrameworkunifiedHSMFramework: public CFrameworkunifiedHSM {
+ public:
+ /**
+ * \~english state machine state
+ */
+ typedef enum _FRAMEWORKUNIFIED_HSM_STATES {
+ esFrameworkunifiedRoot = 0, //!< \~english Root state
+ esFrameworkunifiedInitialization, //!< \~english Initialization state
+ esFrameworkunifiedLoadData, //!< \~english LoadData state
+ esFrameworkunifiedPre, //!< \~english Pre state
+ esFrameworkunifiedBackground, //!< \~english Background state
+ esFrameworkunifiedRun, //!< \~english Run state
+ esFrameworkunifiedLoadSessions, //!< \~english LoadSessions state
+ esFrameworkunifiedReady, //!< \~english Ready state
+ esFrameworkunifiedStop, //!< \~english Stop state
+ esFrameworkunifiedApp, //!< \~english App state
+ esFrameworkunifiedUserChange, //!< \~english UserChange state
+ esFrameworkunifiedThreadRoot, //!< \~english ThreadRoot state
+ esFrameworkunifiedThreadIdle, //!< \~english ThreadIdle state
+ esFrameworkunifiedThreadStart, //!< \~english ThreadStart state
+ esFrameworkunifiedThreadReady, //!< \~english ThreadReady state
+ esFrameworkunifiedThreadStop, //!< \~english ThreadStop state
+ esFrameworkunifiedStopping, //!< \~english Stopping state
+ } FRAMEWORKUNIFIED_HSM_STATES;
+
+ /// Define evFrameworkunifiedStart event
+ DEFINE_EVENT(evFrameworkunifiedStart, 1)
+
+ /// Define evFrameworkunifiedStop event
+ DEFINE_EVENT(evFrameworkunifiedStop, 5)
+
+ /// Define evFrameworkunifiedDestroy event
+ DEFINE_EVENT(evFrameworkunifiedDestroy, 3)
+
+ /// Define evFrameworkunifiedReady event
+ DEFINE_EVENT(evFrameworkunifiedReady, 12)
+
+ /// Define evFrameworkunifiedError event
+ DEFINE_EVENT(evFrameworkunifiedError, 16)
+
+ /// Define evFrameworkunifiedPreStart event
+ DEFINE_EVENT(evFrameworkunifiedPreStart, 19)
+
+ /// Define evFrameworkunifiedPreStop event
+ DEFINE_EVENT(evFrameworkunifiedPreStop, 20)
+
+ /// Define evFrameworkunifiedBackgroundStart event
+ DEFINE_EVENT(evFrameworkunifiedBackgroundStart, 21)
+
+ /// Define evFrameworkunifiedBackgroundStop event
+ DEFINE_EVENT(evFrameworkunifiedBackgroundStop, 22)
+
+ // Define internal transition for event evFrameworkunifiedStart in sFrameworkunifiedStop state
+ DEFINE_INTERNALTRANSITION(OnEventStartInStopState)
+
+ // Define internal transition for event evFrameworkunifiedUserChange in sFrameworkunifiedInitialization state
+ DEFINE_INTERNALTRANSITION(OnEventUserChangeInInitializationState)
+
+ // Define internal transition for event evFrameworkunifiedUserChange in sFrameworkunifiedRun state
+ DEFINE_INTERNALTRANSITION(OnEventUserChangeInRunState)
+
+ DEFINE_INTERNALTRANSITION(OnEventStopInStoppingState)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMFramework default constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// CFrameworkunifiedHSM()
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMFramework default constructor, for create CFrameworkunifiedHSMFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSMFramework();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMFramework constructor with param
+ /// \~english @param [in] f_pHApp
+ /// PVOID f_pHApp - for parent class constructor
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// CFrameworkunifiedHSM(f_pHApp)
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMFramework constructor with param, for create CFrameworkunifiedHSMFramework object
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSMFramework(PVOID f_pHApp); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMFramework
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param [in] f_pEventData
+ /// PVOID f_pEventData - event data
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// pure virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedCreate
+ /// Statemachine states and events created and connected in this interface.
+ ///
+ /// \param [in] f_pEventData
+ /// PVOID - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMFramework
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param [in] f_pAppState
+ /// CFrameworkunifiedState *f_pAppState - state object to be added in the ready state.
+ /// \~english @param [in] f_bIsDefaultState
+ /// BOOL f_bIsDefaultState - if the state is default state
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// pure virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedFrameworkConnect
+ /// This adds the given state as a sub state of sReady state of the Framework
+ ///
+ /// \param [in] f_pAppState
+ /// CFrameworkunifiedState* - state object to be added in the ready state.
+ ///
+ /// \param [in] f_bIsDefaultState
+ /// BOOL - defines if the state is default state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState = FALSE) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMFramework
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param [in] f_eFrameworkunifiedState
+ /// FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState - enum maping to framework state
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - Event id
+ /// \~english @param [in] f_pReaction
+ /// CFrameworkunifiedReaction *f_pReaction - Reaction object for attaching to event
+ /// \~english @param [in] f_strEventName
+ /// std::string f_strEventName - Event name
+ /// \~english @param [in] f_bIsDeferredEvent
+ /// BOOL f_bIsDeferredEvent - defines if the event is deferred event
+ /// \~english @retval EFrameworkunifiedStatus depend on implement class
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// pure virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedFrameworkConnect
+ /// This connects the reaction to event and add event to states
+ ///
+ /// \param [in] f_eFrameworkunifiedState
+ /// FRAMEWORKUNIFIED_HSM_STATES - enum maping to framework state
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id
+ ///
+ /// \param [in] f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction object for attaching to event
+ ///
+ /// \param [in] f_strEventName
+ /// std::string - Event name
+ ///
+ /// \param [in] f_bIsDeferredEvent
+ /// BOOL - defines if the event is deferred event
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
+ CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName = "",
+ BOOL f_bIsDeferredEvent = FALSE) = 0;
+
+ protected:
+ /// Stores the state objects against FRAMEWORKUNIFIED_HSM_STATES enumerations
+ std::map<UI_32, CFrameworkunifiedState *> *m_pFrameworkunifiedStateList;
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// It defines the states required for NS statemachine framework, it creates the NS
+/// statemachine and implements the reaction associated with the events
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedHSMParentFramework: public CFrameworkunifiedHSMFramework {
+ public:
+ /// Define evFrameworkunifiedLoadPersistenceAck event
+ DEFINE_EVENT(evFrameworkunifiedLoadFileAck, 2)
+
+ /// Define evFrameworkunifiedLoadComplete event
+ DEFINE_EVENT(evFrameworkunifiedLoadComplete, 4)
+
+ /// Define evFrameworkunifiedUserChange event
+ DEFINE_EVENT(evFrameworkunifiedUserChange, 6)
+
+ /// Define evFrameworkunifiedReInit event
+ DEFINE_EVENT(evFrameworkunifiedReInit, 7)
+
+ /// Define evFrameworkunifiedLoadUserData event
+ DEFINE_EVENT(evFrameworkunifiedLoadUserData, 8)
+
+ /// Define evFrameworkunifiedCloseSessionAck event
+ DEFINE_EVENT(evFrameworkunifiedCloseSessionAck, 9)
+
+ /// Define evFrameworkunifiedCloseSessionAck event
+ DEFINE_EVENT(evFrameworkunifiedOpenSessionAck, 10)
+
+ /// Define evFrameworkunifiedStopComplete event
+ DEFINE_EVENT(evFrameworkunifiedStopComplete, 11)
+
+ /// Define evFrameworkunifiedOpenSessionReq event
+ DEFINE_EVENT(evFrameworkunifiedOpenSessionReq, 14)
+
+ /// Define evFrameworkunifiedCloseSessionReq event
+ DEFINE_EVENT(evFrameworkunifiedCloseSessionReq, 15)
+
+ /// Define evFrameworkunifiedInit event
+ DEFINE_EVENT(evFrameworkunifiedInit, 16)
+
+ /// Define evFrameworkunifiedUserChangeComplete event
+ DEFINE_EVENT(evFrameworkunifiedUserChangeComplete, 17)
+
+ /// Define evFrameworkunifiedLoadSessions event
+ DEFINE_EVENT(evFrameworkunifiedLoadSessions, 18)
+
+ /// Define sFrameworkunifiedRoot state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedRoot)
+
+ /// Define sFrameworkunifiedRoot state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedApp)
+
+ /// Define sFrameworkunifiedInitialization state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedInitialization)
+
+ /// Define sFrameworkunifiedPre state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedPre)
+
+ /// Define sFrameworkunifiedBackground state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedBackground)
+
+ /// Define sFrameworkunifiedRun state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedRun)
+
+ /// Define sFrameworkunifiedStop state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedStop)
+
+ /// Define sFrameworkunifiedReady state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedReady)
+
+ /// Define sFrameworkunifiedLoadData state
+ DEFINE_LEAFSTATE_OVERRIDE(sFrameworkunifiedLoadData)
+
+ /// Define sFrameworkunifiedLoadSessions state
+ DEFINE_LEAFSTATE_OVERRIDE(sFrameworkunifiedLoadSessions)
+
+ /// Define sFrameworkunifiedStopping state
+ DEFINE_LEAFSTATE_OVERRIDE(sFrameworkunifiedStopping)
+
+ /// Define sFrameworkunifiedUserChange state
+ DEFINE_LEAFSTATE_OVERRIDE(sFrameworkunifiedUserChange)
+
+ // DEFINE_ACTION(aFrameworkunifiedOnStart)
+ DEFINE_ACTION(aFrameworkunifiedOnStop)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMParentFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMFramework default constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
+ /// \~english @par Conditions of processing failure
+ /// apply space for m_pFrameworkunifiedStateList failed
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMFramework default constructor, for create CFrameworkunifiedHSMFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSMParentFramework();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMParentFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMFramework constructor with param
+ /// \~english @param [in] f_pHApp
+ /// PVOID f_pHApp - Name of the state
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
+ /// \~english @par Conditions of processing failure
+ /// apply space for m_pFrameworkunifiedStateList failed
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMFramework constructor with param, for create CFrameworkunifiedHSMFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedHSMParentFramework
+ /// default constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSMParentFramework(PVOID f_pHApp); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMParentFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMFramework destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMFramework destructor, for destory CFrameworkunifiedHSMFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedHSMParentFramework
+ /// Class destructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedHSMParentFramework();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMParentFramework
+ /// \~english @par Brief
+ /// create state and event
+ /// \~english @param [in] f_pEventData
+ /// PVOID f_pEventData - event data
+ /// \~english @retval eFrameworkunifiedStatusOK create state and event success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL point exception occur when create state and event
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// NULL pointer exception occur
+ /// \~english @par Detail
+ /// Statemachine states and events created and connected in this interface.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedCreate
+ /// Statemachine states and events created and connected in this interface.
+ ///
+ /// \param [in] f_pHApp
+ /// PVOID - application handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMParentFramework
+ /// \~english @par Brief
+ /// add sub state
+ /// \~english @param [in] f_pAppState
+ /// CFrameworkunifiedState *f_pAppState - state object to be added in the ready state.
+ /// \~english @param [in] f_bIsDefaultState
+ /// BOOL f_bIsDefaultState - defines if the state is default state.
+ /// \~english @retval eFrameworkunifiedStatusOK add sub state success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL point exception occur when add sub state
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// NULL point exception occur when add sub state
+ /// \~english @par Detail
+ /// This adds the given state as a sub state of sReady state of the Framework
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedFrameworkConnect
+ /// This adds the given state as a sub state of sReady state of the Framework
+ ///
+ /// \param [in] f_pAppState
+ /// CFrameworkunifiedState* - state object to be added in the ready state.
+ ///
+ /// \param [in] f_bIsDefaultState
+ /// BOOL - defines if the state is default state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState = FALSE);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMParentFramework
+ /// \~english @par Brief
+ /// connects the reaction to event and add event to states
+ /// \~english @param [in] f_eFrameworkunifiedState
+ /// FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState - framework state
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - Event id
+ /// \~english @param [in] f_pReaction
+ /// CFrameworkunifiedReaction *f_pReaction - Reaction object
+ /// \~english @param [in] f_strEventName
+ /// std::string f_strEventName - Event name
+ /// \~english @param [in] f_bIsDeferredEvent
+ /// BOOL f_bIsDeferredEvent - defines if the event is deferred event
+ /// \~english @retval eFrameworkunifiedStatusOK add sub state success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL point exception occur when add sub state
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// NULL point exception occur when add sub state
+ /// \~english @par Detail
+ /// This connects the reaction to event and add event to states
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedFrameworkConnect
+ /// This connects the reaction to event and add event to states
+ ///
+ /// \param [in] f_eFrameworkunifiedState
+ /// FRAMEWORKUNIFIED_HSM_STATES - enum maping to framework state
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id
+ ///
+ /// \param [in] f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction object for attaching to event
+ ///
+ /// \param [in] f_strEventName
+ /// std::string - Event name
+ ///
+ /// \param [in] f_bIsDeferredEvent
+ /// BOOL - defines if the event is deferred event
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState, UI_32 f_uiEventId,
+ CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName = "",
+ BOOL f_bIsDeferredEvent = FALSE);
+};
+
+class CFrameworkunifiedHSMChildFramework: public CFrameworkunifiedHSMFramework {
+ public:
+ /// Define sFrameworkunifiedThreadIdle state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedThreadRoot)
+
+ /// Define sFrameworkunifiedThreadIdle state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedThreadIdle)
+
+ /// Define sFrameworkunifiedThreadStart state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedThreadStart)
+
+ /// Define sFrameworkunifiedThreadReady state
+ DEFINE_COMPOSITESTATE_OVERRIDE(sFrameworkunifiedThreadReady)
+
+ /// Define sFrameworkunifiedThreadStop state
+ DEFINE_LEAFSTATE_OVERRIDE(sFrameworkunifiedThreadStop)
+
+ // Define internal transition for event evFrameworkunifiedDestroy
+ DEFINE_INTERNALTRANSITION(OnDestroyThread)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMChildFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMChildFramework constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMChildFramework constructor, for create CFrameworkunifiedHSMChildFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedHSMChildFramework
+ /// default constructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSMChildFramework();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMChildFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMChildFramework constructor with param
+ /// \~english @param [in] f_pHApp
+ /// PVOID f_pHApp - application handle
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// m_pFrameworkunifiedStateList = new std::map<UI_32, CFrameworkunifiedState *>();
+ /// \~english @par Conditions of processing failure
+ /// m_pFrameworkunifiedStateList apply space fail
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMChildFramework constructor with param, for create CFrameworkunifiedHSMChildFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedHSMChildFramework
+ /// default constructor
+ /// \param [in] f_pHApp
+ /// PVOID - application handle
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedHSMChildFramework(PVOID f_pHApp); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMChildFramework
+ /// \~english @par Brief
+ /// CFrameworkunifiedHSMChildFramework destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedHSMChildFramework destructor, for destory CFrameworkunifiedHSMChildFramework object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedHSMChildFramework
+ /// Class destructor
+ ///
+ /// \return none
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedHSMChildFramework();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMChildFramework
+ /// \~english @par Brief
+ /// create state and event
+ /// \~english @param [in] f_pEventData
+ /// PVOID f_pEventData - event data
+ /// \~english @retval eFrameworkunifiedStatusOK create state and event success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL point exception occur when create state and event
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// NULL pointer exception occur
+ /// \~english @par Detail
+ /// Statemachine states and events created and connected in this interface.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedCreate
+ /// Statemachine states and events created and connected in this interface.
+ ///
+ /// \param [in] f_pEventData
+ /// PVOID - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_pEventData = NULL);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMChildFramework
+ /// \~english @par Brief
+ /// add sub state
+ /// \~english @param [in] f_pAppState
+ /// CFrameworkunifiedState *f_pAppState - state object to be added in the ready state.
+ /// \~english @param [in] f_bIsDefaultState
+ /// BOOL f_bIsDefaultState - defines if the state is default state.
+ /// \~english @retval eFrameworkunifiedStatusOK add sub state success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL point exception occur when add sub state
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// NULL point exception occur when add sub state
+ /// \~english @par Detail
+ /// This adds the given state as a sub state of sReady state of the Framework
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedFrameworkConnect
+ /// This adds the given state as a sub state of sReady state of the Framework
+ ///
+ /// \param [in] f_pAppState
+ /// CFrameworkunifiedState* - state object to be added in the ready state.
+ ///
+ /// \param [in] f_bIsDefaultState
+ /// BOOL - defines if the state is default state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedFrameworkConnect(CFrameworkunifiedState *f_pAppState, BOOL f_bIsDefaultState = FALSE);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedHSMChildFramework
+ /// \~english @par Brief
+ /// connects the reaction to event and add event to states
+ /// \~english @param [in] f_eFrameworkunifiedState
+ /// FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState - framework state
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - Event id
+ /// \~english @param [in] f_pReaction
+ /// CFrameworkunifiedReaction *f_pReaction - Reaction object
+ /// \~english @param [in] f_strEventName
+ /// std::string f_strEventName - Event name
+ /// \~english @param [in] f_bIsDeferredEvent
+ /// BOOL f_bIsDeferredEvent - defines if the event is deferred event
+ /// \~english @retval eFrameworkunifiedStatusOK add sub state success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL point exception occur when add sub state
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// NULL point exception occur when add sub state
+ /// \~english @par Detail
+ /// This connects the reaction to event and add event to states
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedFrameworkConnect
+ /// This connects the reaction to event and add event to states
+ ///
+ /// \param [in] f_eFrameworkunifiedState
+ /// FRAMEWORKUNIFIED_HSM_STATES - enum maping to framework state
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id
+ ///
+ /// \param [in] f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction object for attaching to event
+ ///
+ /// \param [in] f_strEventName
+ /// std::string - Event name
+ ///
+ /// \param [in] f_bIsDeferredEvent
+ /// BOOL - defines if the event is deferred event
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedFrameworkConnect(FRAMEWORKUNIFIED_HSM_STATES f_eFrameworkunifiedState,
+ UI_32 f_uiEventId,
+ CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName = "",
+ BOOL f_bIsDeferredEvent = FALSE);
+
+ /// function pointer of the Thread start routine
+ CbFuncPtr m_fpStartThread;
+
+ /// function pointer of the Thread stop routine
+ CbFuncPtr m_fpStopThread;
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_HSMFRAMEWORK_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_internaltransition.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_internaltransition.h
new file mode 100644
index 00000000..71eebecf
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_internaltransition.h
@@ -0,0 +1,111 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedInternalTransition class definitions. CFrameworkunifiedInternalTransition is derived
+/// from CFrameworkunifiedReaction class.This class provides the interface for defining a reaction for an event
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_internaltransition.h
+ * @brief \~english This file has the CFrameworkunifiedInternalTransition class definitions. CFrameworkunifiedInternalTransition is derived
+ * from CFrameworkunifiedReaction class.This class provides the interface for defining a reaction for an event
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDINTERNALTRANSITION_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDINTERNALTRANSITION_H
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_reaction.h>
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class provides the interface for defining a reaction for an event
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedInternalTransition : public CFrameworkunifiedReaction {
+ public :
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedInternalTransition
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param [in] f_pSourceState
+ /// CFrameworkunifiedState* f_pSourceState - source state
+ /// \~english @param [in] f_pData
+ /// CEventDataPtr f_pData - event data
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Pure virtual function , implemented by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedReaction
+ /// The reaction for the event has to be implemented in this function
+ ///
+ /// \param [in] f_pSourceState
+ /// CFrameworkunifiedState* - Event id of the event to be added in the state
+ ///
+ /// \param [in] f_pData
+ /// CEventDataPtr - Reaction to be associated with the with event id in the state
+ ///
+ /// \return ActiveState
+ /// CFrameworkunifiedState* - Returns Active state
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) = 0;
+};
+
+#endif // _FRAMEWORKUNIFIEDINTERNALTRANSITION_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_leafstate.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_leafstate.h
new file mode 100644
index 00000000..e1aa6bda
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_leafstate.h
@@ -0,0 +1,252 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedLeafState class definitions. CFrameworkunifiedLeafState is derived from C
+/// FrameworkunifiedState class.This class implements the additional functionality supported by HSM Leafstate.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_leafstate.h
+ * @brief \~english This file has the CFrameworkunifiedLeafState class definitions. CFrameworkunifiedLeafState is derived from C
+ * FrameworkunifiedState class.This class implements the additional functionality supported by HSM Leafstate.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDLEAFSTATE_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDLEAFSTATE_H
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_state.h>
+#include <string>
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM Leafstate.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedLeafState : public CFrameworkunifiedState {
+ public :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLeafState
+ /// \~english @par Brief
+ /// It is a constructor for CFrameworkunifiedLeafState classes.
+ /// \~english @param [in] f_pName
+ /// std::string - state name
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// Inherits CFrameworkunifiedState, which is a superclass of state machines.\n
+ /// This class is implemented by HSM Leafstate as an additional class of functional support.\n
+ /// It inherits from the CFrameworkunifiedState classes and instantiates the CFrameworkunifiedLeafState.
+ /// \~english @par Immediate
+ /// Brief
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see ~CFrameworkunifiedLeafState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ CFrameworkunifiedLeafState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLeafState
+ /// \~english @par Brief
+ /// Destructors for CFrameworkunifiedLeafState classes.
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedLeafState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// Frees instances of CFrameworkunifiedLeafState classes.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedLeafState::CFrameworkunifiedLeafState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedState
+ /// Class destructor
+ ///
+ /// \return none
+ virtual ~CFrameworkunifiedLeafState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLeafState
+ /// \~english @par Brief
+ /// Get the active state.
+ /// \~english @retval CFrameworkunifiedState* Pointers to active-state (CFrameworkunifiedState classes) objects
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedLeafState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This method overrides and uses CFrameworkunifiedState::FrameworkunifiedGetActiveState, which is pure virtual functions.\n
+ /// Returns the current state (this) as the active state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedGetActiveState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedGetActiveState
+ /// This interface returns the Active state of the current composite state. In case of
+ /// non-composite state current state is active state
+ ///
+ /// \return Active state
+ /// CFrameworkunifiedState* - Active state
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLeafState
+ /// \~english @par Brief
+ /// Save the last active state.
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedLeafState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This method overrides CFrameworkunifiedState::UpdateHistory, which is pure virtual functions.Used and saves the last active state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedState::UpdateHistory
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateHistory
+ /// This function stores the last active state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ EFrameworkunifiedStatus UpdateHistory();
+
+ protected :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLeafState
+ /// \~english @par Brief
+ /// Initialize state
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedLeafState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This method overrides and uses CFrameworkunifiedState::FrameworkunifiedOnEntry, which is pure virtual functions, to initialize state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedOnEntry, FrameworkunifiedOnExit
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEntry
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLeafState
+ /// \~english @par Brief
+ /// Clean up state.
+ /// \~english @param f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedLeafState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This method overrides and uses CFrameworkunifiedState::FrameworkunifiedOnExit, which is pure virtual functions, to clean up state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedState::FrameworkunifiedOnExit, FrameworkunifiedOnEntry
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnExit
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData);
+};
+
+#endif // _FRAMEWORKUNIFIEDLEAFSTATE_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_localtransition.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_localtransition.h
new file mode 100644
index 00000000..99975eb1
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_localtransition.h
@@ -0,0 +1,163 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedLocalTransition class definitions. CFrameworkunifiedLocalTransition is derived
+/// from CFrameworkunifiedTransition class.This class provides the interface for local transition over event
+///////////////////////////////////////////// //////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_localtransition.h
+ * @brief \~english This file has the CFrameworkunifiedLocalTransition class definitions. CFrameworkunifiedLocalTransition is derived
+ * from CFrameworkunifiedTransition class.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDLOCALTRANSITIONS_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDLOCALTRANSITIONS_H
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_transition.h>
+
+class CFrameworkunifiedEventData;
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class provides the interface for local transition over event
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedLocalTransition : public CFrameworkunifiedTransition {
+ public :
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLocalTransition
+ /// \~english @par Brief
+ /// CFrameworkunifiedLocalTransition constructor
+ /// \~english @param [in] f_pTargetState
+ /// CFrameworkunifiedState *f_pTargetState - target state
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// Constructor of CFrameworkunifiedLocalTransition, to create CFrameworkunifiedLocalTransition object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedLocalTransition(CFrameworkunifiedState *f_pTargetState); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLocalTransition
+ /// \~english @par Brief
+ /// CFrameworkunifiedLocalTransition destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedLocalTransition destructor, for destory CFrameworkunifiedLocalTransition object
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedLocalTransition();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedLocalTransition
+ /// \~english @par Brief
+ /// reaction for location transition
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// For local transition from inner
+ /// state to outer state exit of the inner state is invoked, but entry of outer state is not
+ /// invoked and from outer state to inner state entry of the inner state is invoked but exit of
+ /// outer state is not invoked
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedReaction
+ /// The reaction for an event is implemented in this function. For local transition from inner
+ /// state to outer state exit of the inner state is invoked, but entry of outer state is not
+ /// invoked and from outer state to inner state entry of the inner state is invoked but exit of
+ /// outer state is not invoked
+ ///
+ /// \param [in] f_pSourceState
+ /// CFrameworkunifiedState* - Source state in which reaction is being executed
+ ///
+ /// \param [in] f_pData
+ /// CEventDataPtr - event data
+ ///
+ /// \return ActiveState
+ /// CFrameworkunifiedState* - Returns Active state
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData);
+};
+
+#endif // _FRAMEWORKUNIFIEDLOCALTRANSITIONS_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_multithreading.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_multithreading.h
new file mode 100644
index 00000000..827b180b
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_multithreading.h
@@ -0,0 +1,227 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \~english \brief Application framework's core structures and data types.
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_multithreading.h
+ * @brief \~english Application framework's core structures and data types.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_H__
+
+#include <native_service/frameworkunified_framework_types.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedCreateHSMChildThread
+/// \~english @par Brief
+/// Start a subordinate dispatcher in a separate thread
+///
+/// \~english \param [in] hApp
+/// HANDLE - parent framework HANDLE
+/// \~english \param [in] childName
+/// PCSTR - Name to give to the child object
+/// \~english \param [in] CbInitialize
+/// CbFuncPtr - Initialization callback - use this to initialize and configure
+/// the child's dispatcher.
+/// \~english \param [in] CbShutdown
+/// CbFuncPtr - Shutdown callback - use this to shutdown and close the child
+/// The correct way for child to exit dispatch loop is to return eFrameworkunifiedStatusExit
+/// directly from this callback, or from some other interaction triggered by this
+/// callback
+///
+/// \~english \param [in] CbCreateStateMachine
+/// CbFuncPtr - StateMachine callback - use this to add new states, events and reactions
+/// in the Thread statemachine.
+/// \~english @retval HANDLE create thread with Priority success
+/// \~english @retval NULL create thread with Priority failed
+/// \~english @par Preconditions
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+/// \~english @par Change of the internal state
+/// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
+/// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
+/// - Thread attribute specified in the argument (attr) is NULL. [NULL]
+/// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
+/// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
+/// - Failed to create child thread (pthread_create). [NULL]
+/// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par Detail
+/// Start a subordinate dispatcher in a separate thread
+/// This API creates a child thread and returns a handle for communication with the child thread.\n
+/// After creating/initializing the Dispatcher for the child thread, the child thread receives requests
+/// and notifications to the Dispatcher and starts a main loop that executes the registered callback.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateHSMChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr
+ CbShutdown, CbFuncPtr CbCreateStateMachine);
+
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FrameworkunifiedCreateHSMChildThread
+ /// \~english @par Summary
+ /// Start a subordinate dispatcher in a separate thread with given Priority
+ /// \~english @param [in] hApp
+ /// HANDLE - parent framework HANDLE
+ /// \~english @param [in] childName
+ /// PCSTR - Name to give to the child object
+ /// \~english @param [in] CbInitialize
+ /// CbFuncPtr - Initialization callback - use this to initialize and configure
+ /// the child's dispatcher.
+ /// \~english @param [in] CbShutdown
+ /// CbFuncPtr - Shutdown callback - use this to shutdown and close the child
+ /// The correct way for child to exit dispatch loop is to return eFrameworkunifiedStatusExit
+ /// directly from this callback, or from some other interaction triggered by this
+ /// callback
+ ///
+ /// \~english @param [in] CbCreateStateMachine
+ /// CbFuncPtr - StateMachine callback - use this to add new states, events and reactions
+ /// in the Thread statemachine.
+ /// \~english @param [in] schedPrio
+ /// SI_32 - given Priority for create thread
+ /// \~english @retval HANDLE create thread with Priority success
+ /// \~english @retval NULL create thread with Priority failed
+ /// \~english @par Preconditions
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
+/// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
+/// - Thread attribute specified in the argument (attr) is NULL. [NULL]
+/// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
+/// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
+/// - Failed to create child thread (pthread_create). [NULL]
+/// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Start a subordinate dispatcher in a separate thread with given Priority
+ /// This API creates a child thread and returns a handle for communication with the child thread.\n
+ /// After creating/initializing the Dispatcher for the child thread, the child thread receives requests
+ /// and notifications to the Dispatcher and starts a main loop that executes the registered callback.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateHSMChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize,
+ CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine, SI_32 schedPrio);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FrameworkunifiedCreateHSMChildThread
+ /// \~english @par Summary
+ /// Start a subordinate dispatcher in a separate thread with given attribute
+ /// \~english @param [in] hApp
+ /// HANDLE - parent framework HANDLE
+ /// \~english @param [in] childName
+ /// PCSTR - Name to give to the child object
+ /// \~english @param [in] CbInitialize
+ /// CbFuncPtr - Initialization callback - use this to initialize and configure
+ /// the child's dispatcher.
+ /// \~english @param [in] CbShutdown
+ /// CbFuncPtr - Shutdown callback - use this to shutdown and close the child
+ /// The correct way for child to exit dispatch loop is to return eFrameworkunifiedStatusExit
+ /// directly from this callback, or from some other interaction triggered by this
+ /// callback
+ ///
+ /// \~english @param [in] CbCreateStateMachine
+ /// CbFuncPtr - StateMachine callback - use this to add new states, events and reactions
+ /// in the Thread statemachine.
+ /// \~english @param [in] attr
+ /// const FrameworkunifiedChildThreadAttr * - given attribute to create thread
+ /// \~english @retval HANDLE create thread with Priority success
+ /// \~english @retval NULL create thread with Priority failed
+ /// \~english @par Preconditions
+/// - Generation/Initialization of Dispatcher for the Application
+/// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+/// \~english @par Conditions of processing failure
+/// - HANDLE specified in the argument (hApp) is NULL. [NULL]
+/// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
+/// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
+/// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
+/// - Thread attribute specified in the argument (attr) is NULL. [NULL]
+/// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
+/// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
+/// - Failed to create child thread (pthread_create). [NULL]
+/// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
+/// - Can not be acquired memory for message queue name(malloc). [NULL]
+/// - Failed to open message queue(mq_open). [NULL]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Start a subordinate dispatcher in a separate thread with given attribute
+ /// This API creates a child thread and returns a handle for communication with the child thread.\n
+ /// After creating/initializing the Dispatcher for the child thread, the child thread receives requests
+ /// and notifications to the Dispatcher and starts a main loop that executes the registered callback.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedCreateHSMChildThreadWithAttribute(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize,
+ CbFuncPtr CbShutdown, CbFuncPtr CbCreateStateMachine,
+ const FrameworkunifiedChildThreadAttr *attr);
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_MULTITHREADING_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_orthogonalstate.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_orthogonalstate.h
new file mode 100644
index 00000000..c9ea8c7f
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_orthogonalstate.h
@@ -0,0 +1,513 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedOrthogonalState class definitions. CFrameworkunifiedOrthogonalState is derived from
+/// CFrameworkunifiedCompositeState class.This class implements the additional functionality supported by HSM
+/// Orthogonal state. It provides the standard interfaces for adding orthogonal state machines.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_orthogonalstate.h
+ * @brief \~english This file has the CFrameworkunifiedOrthogonalState class definitions. CFrameworkunifiedOrthogonalState is derived from
+ * CFrameworkunifiedCompositeState class.This class implements the additional functionality supported by HSM
+ * Orthogonal state. It provides the standard interfaces for adding orthogonal state machines.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDORTHOGONALSTATE_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDORTHOGONALSTATE_H
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_state.h>
+#include <vector>
+
+typedef std::vector<CFrameworkunifiedState *> OrthogonalRegionList;
+
+class CFrameworkunifiedCompositeState;
+
+class CFrameworkunifiedHSM;
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM
+/// Orthogonal state. It provides the standard interfaces for adding orthogonal state machines.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedOrthogonalState : public CFrameworkunifiedState {
+ public :
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Constructors for CFrameworkunifiedOrthogonalState classes
+ /// \~english @param [in] f_pName
+ /// std::string - state name
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - When the quadrature region list cannot be created due to insufficient memory
+ /// \~english @par Detail
+ /// Generates an orthographic region list.\n
+ /// CFrameworkunifiedOrthogonalState classes are used to manage the status of independent features individually.\n
+ /// For example, when the function of the clock is set to the following two, the management of the internal state is performed according to the function.\n
+ /// - Clock function (Clock display by 12h/24h)\n
+ /// - Alarm function (on/off setting)
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see ~CFrameworkunifiedOrthogonalState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedCompositeState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ CFrameworkunifiedOrthogonalState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Destructors of CFrameworkunifiedOrthogonalState classes
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// Frees the memory in the orthographic area list and clears the memory contents.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedOrthogonalState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedOrthogonalState
+ /// Class destructor
+ ///
+ /// \return none
+ virtual ~CFrameworkunifiedOrthogonalState();
+
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Initialize state
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval Successful pointer to the current state after processing
+ /// \~english @retval NULL Exception supine in internal processing
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// - The State Machine for the current state of the application is set in the FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - Failed recursive function call (FrameworkunifiedOnEntry call)[NULL]
+ /// - If the pointers to the orthographic regions are NULL [NULL]
+ /// \~english @par Detail
+ /// Loops as many times as the number of elements in the quadrature area list, and initializes the active state (calls FrameworkunifiedOnEntry).\n
+ /// If the current state is Leaf State, it does not initialize because it does not have any active state.\n
+ /// If, after initialization, the current state is a child state of Orthogonal State, sets itself (the this pointer) to the current state.\n
+ /// Breaks looping if the current state is not a child state of Orthogonal State.\n
+ /// To maintain the hierarchy, the active state of the parent state is set to the current state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see FrameworkunifiedOnHSMStop, FrameworkunifiedOnEntry, CFrameworkunifiedState::FrameworkunifiedOnHSMStart, IsOrthogonalChildState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnHSMStart
+ /// This function is called recursively till the leaf state is reached. This internally
+ /// calls the Entry function of the current state.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ CFrameworkunifiedState *FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Clean up state.
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval Successful pointer to the current state after processing
+ /// \~english @retval NULL Exception supine in internal processing
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// - The State Machine for the current state of the application is set in the FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - If the pointers to the orthographic regions are NULL [NULL]
+ /// - If the pointers to the orthographic area lists of the member variables are NULL [NULL]
+ /// - Active state pointers from orthographic area lists of member variables are NULL [NULL]
+ /// - If the current state of the state being cleaned up is NULL [NULL]
+ /// \~english @par Detail
+ /// Loops as many times as the number of elements in the quadrature area list, and performs cleanup of the active state (calls FrameworkunifiedOnExit).\n
+ /// If the current state is Leaf State,Do not clean up because it does not have any active state.\n
+ /// If the current state is a child state of Orthogonal State (orthographic state) after the cleanup process finishes,Sets itself (the this pointer) to the current state.\n
+ /// Breaks looping if the current state is not a child state of Orthogonal State.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see FrameworkunifiedOnHSMStart, CFrameworkunifiedState::FrameworkunifiedOnHSMStop, CFrameworkunifiedState::FrameworkunifiedPostEvent, FrameworkunifiedOnExit,
+ /// IsOrthogonalChildState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnHSMStop
+ /// This function is called recursively till the required parent state is reached. This
+ /// internally calls the Exit function of the current state.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ CFrameworkunifiedState *FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedAddOrthogonalRegion
+ /// This Interface adds orthogonal region in the orthogonal state.
+ ///
+ /// \param [in] f_pOrthogonalRegion
+ /// CFrameworkunifiedCompositeState - Orthogonal region object to be associated with state.
+ ///
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedAddOrthogonalRegion(CFrameworkunifiedCompositeState *f_pOrthogonalRegion);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Checks whether OrthogonalRegion (orthographic area) is registered or not.
+ /// \~english @retval TRUE OrthogonalRegion (orthographic area) is registered
+ /// \~english @retval FALSE OrthogonalRegion (orthographic area) is not registered
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// - OrthogonalRegion (orthographic area) is registered in FrameworkunifiedAddOrthogonalRegion.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - If the pointers to the orthographic regions are NULL [FALSE]
+ /// - When the OrthogonalRegion (orthographic area) is not registered and the number of elements (size) of the orthographic area is 0, [FALSE]
+ /// \~english @par Detail
+ /// Checks whether OrthogonalRegion (orthographic area) is registered by referring to the number of elements (size) of the orthographic area list.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedHasOrthogoanlRegions
+ /// This checks if the current state has Orthogonal regions
+ ///
+ ///
+ /// \return TRUE/FASLE
+ /// BOOL - returns TRUE if orthogonal regions are available in the state
+ virtual BOOL FrameworkunifiedHasOrthogoanlRegions();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Event handling
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to the event data class
+ /// \~english @retval Successful pointer to the current state after processing
+ /// \~english @retval NULL Operation cannot be guaranteed.
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// - The State Machine for the current state of the application is set in the FrameworkunifiedSetHSM.
+ /// - OrthogonalRegion (orthographic area) is registered in FrameworkunifiedAddOrthogonalRegion.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - If the pointers to the orthographic regions are NULL [NULL]
+ /// - If the event data class is pointed to by NULL [NULL]
+ /// \~english @par Detail
+ /// If the event specified in the argument (f_pEventData) is available in the current state,Set itself (this) to current state and return it.\n
+ /// Invokes the parent-state FrameworkunifiedOnEvent if not available in the current state
+ /// (Repeated until the root state is reached.)\n
+ /// However, since the FrameworkunifiedState that is the parent state of the Orthogonal State (orthographic state) is the root state,You call the FrameworkunifiedOnEvent of FrameworkunifiedState.\n
+ /// If the current state is a child state of the Orthogonal State (quadrature state) after the above process, sets itself (the this pointer) to the current state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedCompositeState::FrameworkunifiedGetActiveState, CFrameworkunifiedState::FrameworkunifiedIsReactionAvailable, CFrameworkunifiedState::FrameworkunifiedOnEvent,
+ /// IsOrthogonalChildState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEvent
+ /// This function processes the event. If the reaction for event is available in the current
+ /// state within eventlist and deferred eventlist then it is consumed in the current state
+ /// otherwise forwarded to the parent state. Event forwarding is done recursively till either
+ /// event is consumed or the root state has encountered. This also process the events posted
+ /// in the reactions recursively till all posted events are cleared.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ ///
+ /// \return state
+ /// CFrameworkunifiedState* - Returns current state after the event is processed
+ ///
+ virtual CFrameworkunifiedState *FrameworkunifiedOnEvent(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Logs the state name and event name.
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Specifying NULL pointers
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// - OrthogonalRegion (orthographic area) is registered in FrameworkunifiedAddOrthogonalRegion.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - If the pointers to the orthographic regions are NULL [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Size of the log output data
+ /// - State name of the parent state machine and the state name of the self-state machine
+ /// - All event names on the event list
+ /// - All event names on the deferred event list
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedCompositeState::FrameworkunifiedPrintStates
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPrintStates
+ /// This logs the state name and events associated with the state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedPrintStates();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Get the active state.
+ /// \~english @retval Successful pointer to the active state
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// In this class, the current state (this state) is always returned as the active state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see None
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedGetActiveState
+ /// This interface returns the Active state of the current composite state. In case of
+ /// non-composite state current state is active state
+ ///
+ /// \return Active state
+ /// CFrameworkunifiedState* - Active state
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Associate the state machine with the current state.
+ /// \~english @param [in] f_pStatemachine
+ /// CFrameworkunifiedHSM* - Pointers to state machines (CFrameworkunifiedHSM classes)
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Specifiying NULL pointers
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - When the pointers to the state machines (CFrameworkunifiedHSM classes) specified in the arguments (f_pStatemachine) are NULL
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Associates a state machine with the current state by setting a pointer (f_pStatemachine) to the state machine (CFrameworkunifiedHSM) specified by the argument to the pointer to the state machine of the member variables.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedCompositeState::FrameworkunifiedSetHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedSetHSM
+ /// This Interface associates the gives statemachine with the current state
+ ///
+ /// \param [in] f_pStatemachine
+ /// CFrameworkunifiedHSM* - Statemachine associated with the state.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Outputs state information in the form of XML tags.
+ /// \~english @param [out] f_strXMLString
+ /// std::ostringstream& - Only kept in NPS
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Specifiying NULL pointers
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// - The State Machine for the current state of the application is set in the FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - If generating of own instance (CFrameworkunifiedOrthogonalState) failed, [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Outputs the following state information in XML tag format to the XML stream specified by the argument.
+ /// - Sate name
+ /// - All event information (event ID and event name) in the event list
+ /// - All event information (event ID and event name) in the deferred event list
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see CFrameworkunifiedCompositeState::FrameworkunifiedPrintXML
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPrintXML
+ /// Update the State information in the given stream in the form of XML tags
+ ///
+ /// \param [in] f_strXMLString
+ /// std::ostringstream & - reference to the XML stream
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_CFrameworkunifiedOrthogonalState
+ /// \~english @par Brief
+ /// Always returns eFrameworkunifiedStatusOK (Successful).
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @par Prerequisite
+ /// - Its own instance (CFrameworkunifiedOrthogonalState) has been created.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// In this class, eFrameworkunifiedStatusOK is always returned because the class does not require the History feature.\n
+ /// The History feature holds the active state prior to preprocessing and
+ /// returns the inside state to the active state prior to processing after the processing is executed.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Not applicable
+ /// \~english @see
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateHistory
+ /// This function stores the last active state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ EFrameworkunifiedStatus UpdateHistory();
+
+ protected :
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEntry
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnExit
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData);
+
+ private:
+ /// Pointer to the map that stores the pointer to Orthogonal region list
+ OrthogonalRegionList *m_pOrthogonalReigonList;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// IsOrthogonalChildState
+ /// Checks if the given state is a child of orthogonal region
+ ///
+ /// \param [in] f_pChildState
+ /// CFrameworkunifiedState* - Child state pointer
+ ///
+ /// \return TRUE/FASLE
+ /// BOOL - returns TRUE if the given state is child of orthogonal state
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsOrthogonalChildState(CFrameworkunifiedState *f_pChildState);
+};
+
+#endif // _FRAMEWORKUNIFIEDORTHOGONALSTATE_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_reaction.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_reaction.h
new file mode 100644
index 00000000..83beea0a
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_reaction.h
@@ -0,0 +1,184 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedReaction class definitions.This class provides the interface
+/// for defining a reaction for an event
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_reaction.h
+ * @brief \~english This file has the CFrameworkunifiedReaction class definitions.This class provides the interface
+ * for defining a reaction for an event
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef _FRAMEWORKUNIFIEDREACTION_H // NOLINT (build/header_guard)
+#define _FRAMEWORKUNIFIEDREACTION_H
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include <boost/smart_ptr.hpp>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_logger_if.h>
+#include <exception>
+
+class CFrameworkunifiedState;
+class CEventData;
+
+typedef boost::shared_ptr<CEventData> CEventDataPtr;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class provides the interface for defining a reaction for an event
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedReaction {
+ public :
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedReaction
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param [in] f_pSourceState
+ /// CFrameworkunifiedState* f_pSourceState - source state
+ /// \~english @param [in] f_pData
+ /// CEventDataPtr f_pData - event data
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// pure virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedReaction
+ /// The reaction for the event has to be implemented in this function
+ ///
+ /// \param [in] f_pSourceState
+ /// CFrameworkunifiedState* - Source state in which reaction is being executed
+ ///
+ /// \param [in] f_pData
+ /// CEventDataPtr - event data
+ ///
+ /// \return ActiveState
+ /// CFrameworkunifiedState* - Returns Active state
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedReaction
+ /// \~english @par Summary
+ /// CFrameworkunifiedReaction constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - m_ucRefCount = 0
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// CFrameworkunifiedReaction Constructor, for create CFrameworkunifiedReaction object
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedReaction
+ /// Constructor
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedReaction() {
+ m_ucRefCount = 0;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedReaction
+ /// \~english @par Summary
+ /// CFrameworkunifiedReaction destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// CFrameworkunifiedReaction destructor, for destory CFrameworkunifiedReaction object
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedReaction
+ /// Destructor
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedReaction() {}
+
+ // count to check the number of reference of this reaction in all the states of statemachine
+ UI_8 m_ucRefCount;
+};
+#endif // _FRAMEWORKUNIFIEDREACTION_H // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_shallowhistorystate.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_shallowhistorystate.h
new file mode 100644
index 00000000..945749db
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_shallowhistorystate.h
@@ -0,0 +1,163 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief
+///
+/// This file has the declaration of class CFrameworkunifiedShallowHistoryState . CFrameworkunifiedShallowHistoryState is
+/// derived from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported
+/// by HSM Shallow History state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_shallowhistorystate.h
+ * @brief \~english This file has the declaration of class CFrameworkunifiedShallowHistoryState . CFrameworkunifiedShallowHistoryState is
+ * derived from CFrameworkunifiedHistoryState class.This class implements the additional functionality supported
+ * by HSM Shallow History state.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_SM_SHALLOWHISTORYSTATE_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_SM_SHALLOWHISTORYSTATE_H__
+
+#include <native_service/frameworkunified_sm_historystate.h>
+#include <string>
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the additional functionality supported by HSM Shallow History state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedShallowHistoryState : public CFrameworkunifiedHistoryState {
+ public :
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedShallowHistoryState
+ /// \~english @par Brief
+ /// CFrameworkunifiedShallowHistoryState constructor
+ /// \~english @param [in] f_pName
+ /// std::string - Name of the state
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This class inherits from CFrameworkunifiedHistoryState class and creates CFrameworkunifiedShallowHistoryState object. \n
+ /// In this function, we set member variable m_uiEventId to ShallowHistoryID(71), \n
+ /// and set member variable m_cEventName to evShallowHistory"evShallowHistory".
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see ~CFrameworkunifiedShallowHistoryState
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedShallowHistoryState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ CFrameworkunifiedShallowHistoryState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedShallowHistoryState
+ /// \~english @par Brief
+ /// CFrameworkunifiedShallowHistoryState destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// Destory CFrameworkunifiedShallowHistoryState object.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CFrameworkunifiedShallowHistoryState::CFrameworkunifiedShallowHistoryState
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedShallowHistoryState
+ /// Class destructor
+ ///
+ /// \return none
+ ~CFrameworkunifiedShallowHistoryState();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedShallowHistoryState
+ /// \~english @par Brief
+ /// update history infomation
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK update history infomation success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer exception occur when update history infomation
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// m_pParentState is NULL
+ /// \~english @par Detail
+ /// update last active state, failed if m_pParentState is NULL
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateHistory
+ /// This function stores the last active state
+ /// \param
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UpdateHistory();
+
+ private:
+ static const UI_32 m_suievShallowHistory;
+};
+
+#endif /* __FRAMEWORKUNIFIED_SM_SHALLOWHISTORYSTATE_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_state.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_state.h
new file mode 100644
index 00000000..438e2e5a
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_state.h
@@ -0,0 +1,872 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedState class definitions. CFrameworkunifiedState is base class for all types of
+/// state classes.This class implements the basic functionality required for HSM state.
+/// It provides the standard interfaces for entering, exiting and reacting in a state.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_state.h
+ * @brief \~english This file has the CFrameworkunifiedState class definitions. CFrameworkunifiedState is base class for all types of
+ * state classes.This class implements the basic functionality required for HSM state.
+ * It provides the standard interfaces for entering, exiting and reacting in a state.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_STATE_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_STATE_H__
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_reaction.h>
+#include <string>
+#include <map>
+#include <exception>
+#include <vector>
+
+class CFrameworkunifiedReaction;
+class CFrameworkunifiedHSM;
+
+/// defines the map of event reactions
+typedef std::map<UI_32, CFrameworkunifiedReaction *> EventReactionList;
+
+typedef std::vector<UI_32> DeferredEventList;
+
+/// defines the map of event names
+typedef std::map<UI_32, std::string> EventNameList;
+
+/// defines the iterator for event reaction map
+typedef std::map<UI_32, CFrameworkunifiedReaction *>::iterator EventReactionIterator;;
+
+typedef std::vector<CEventDataPtr> EventInfoList;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class implements the basic functionality required for HSM state. It provides the standard
+/// interfaces for entering, exiting and reacting in a state.
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedState {
+ public :
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// CFrameworkunifiedState constructor
+ /// \~english @param [in] f_pName
+ /// std::string - Name of the state
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This clase is a base class of state machine. \n
+ /// It creates object of CFrameworkunifiedState class, and initializes the member variable with state name specified by
+ /// argument(f_pName). \n
+ /// It creates the following event lists, and saves them as member variables. About the other member variables,
+ /// it initialzes them with NULL. \n
+ /// If error occurs, output the error log. \n
+ /// - list of events associated with the state(used for managing state of eace event)
+ /// - list of deferred events associated with the state(used for managing state of deferred event)
+ /// - list of deferred events posted in the state(used for posting list of deferred events)
+ /// - list of event names(used for managing event names)
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see ~CFrameworkunifiedState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CFrameworkunifiedState
+ /// Parameterized constructor
+ /// \param [in] f_pName
+ /// string - Name of the state
+ ///
+ /// \return none
+ CFrameworkunifiedState(std::string f_pName); // NOLINT (readability/nolint)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// CFrameworkunifiedState destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This class destroys object of CFrameworkunifiedState class.\n
+ /// It destroys the following event list. If error occurs, output the error log.
+ /// - list of events associated with the state
+ /// - list of deferred events associated with the state
+ /// - list of deferred events posted in the state
+ /// - list of event names
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CFrameworkunifiedState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFrameworkunifiedState
+ /// Class destructor
+ ///
+ /// \return none
+ virtual ~CFrameworkunifiedState();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// add event information
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - event ID
+ /// \~english @param [in] f_pReaction
+ /// CFrameworkunifiedReaction *f_pReaction - event reaction
+ /// \~english @param [in] f_strEventName
+ /// std::string f_strEventName - event name
+ /// \~english @retval eFrameworkunifiedStatusOK add event success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer exception occur when add event
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// given param is NULL
+ /// \~english @par Detail
+ /// add event information to event list, failed if given param is NULL
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedAddEvent
+ /// Associates the event id with the reaction in the state. When the event is posted to the
+ /// state the associated reaction is executed. This also adds the event name to the map
+ /// which is used for debugging.
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id of the event to be added in the state
+ ///
+ /// \param [in] f_pReaction
+ /// CFrameworkunifiedReaction* - Reaction to be associated with the with event id in the state
+ ///
+ /// \param [in] f_strEventName
+ /// string - Name of the event (used for debugging purpose only)
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedAddEvent(UI_32 f_uiEventId, CFrameworkunifiedReaction *f_pReaction, std::string f_strEventName = "");
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This function processes the event.
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to event data class
+ /// \~english @retval CFrameworkunifiedState* Pointer to current CFrameworkunifiedState object after processing event
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Failed to call constructor to create object. [this(current CFrameworkunifiedState object]
+ /// - Pointer to event data class is NULL. [NULL]
+ /// \~english @par Detail
+ /// This function processes the event. If the reaction for event is available in the current
+ /// state within eventlist and deferred eventlist then it is consumed in the current state
+ /// otherwise forwarded to the parent state. Event forwarding is done recursively till either
+ /// event is consumed or the root state has encountered. This also process the events posted
+ /// in the reactions recursively till all posted events are cleared.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CEventData, FrameworkunifiedIsReactionAvailable
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEvent
+ /// This function processes the event. If the reaction for event is available in the current
+ /// state within eventlist and deferred eventlist then it is consumed in the current state
+ /// otherwise forwarded to the parent state. Event forwarding is done recursively till either
+ /// event is consumed or the root state has encountered. This also process the events posted
+ /// in the reactions recursively till all posted events are cleared.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ ///
+ /// \return state
+ /// CFrameworkunifiedState* - Returns current state after the event is processed
+ ///
+ virtual CFrameworkunifiedState *FrameworkunifiedOnEvent(CEventDataPtr f_pEventData);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// add deferred event information
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - event ID
+ /// \~english @param [in] f_strEventName
+ /// std::string f_strEventName - event name
+ /// \~english @retval eFrameworkunifiedStatusOK add deferred event success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer exception occur when add deferred event
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// given param is NULL
+ /// \~english @par Detail
+ /// add deferred event information to event list , failed if given param is NULL
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedAddDeferredEvent
+ /// Associates the deferred event id with the reaction in the state. When the event is posted
+ /// to the state the event is deferred and stored in the state. In case of implicit recall
+ /// of the deferred events, events are processed before exiting the state. The deferred
+ /// events can also be recalled explicitly in the state This also adds the event name
+ /// to the map which is used for debugging.
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id of the event to be added in the state
+ ///
+ /// \param [in] f_strEventName
+ /// string - Name of the event (used for debugging purpose only)
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedAddDeferredEvent(UI_32 f_uiEventId, std::string f_strEventName = "");
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This function creates new eventdata object and add it to event queue of the state machine.
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - event ID
+ /// \~english @retval eFrameworkunifiedStatusOK post event success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer exception occur when post event
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - State machine of application is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Failed to create object of eventdata. [eFrameworkunifiedStatusNullPointer]
+ /// - Pointer to event list in which to add eventdata in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Pointer to active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This function creates new eventdata object and add it to event queue of the state machine.\n
+ /// The events are posted in the reaction which are executed in the state.
+ /// The event queue is processed once the execution of the reaction is completed.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedPostEvent(CEventDataPtr), CEventData, CFrameworkunifiedHSM::FrameworkunifiedQueueEvent, CFrameworkunifiedHSM::ProcessEvent
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPostEvent
+ /// This function creates new eventdata object and add the to event queue of the state.
+ /// The events are posted in the reaction which are executed in the state.
+ /// The event queue is processed once the execution of the reaction is completed.
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event Id
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedPostEvent(UI_32 f_uiEventId);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This function adds event data to event queue of the state machine.
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to event data class
+ /// \~english @retval eFrameworkunifiedStatusOK post event success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer exception occur when post event
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - State machine of application is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Pointer to event data class specified by argument(f_pEventData) is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Pointer to event list in which to add eventdata in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Pointer to active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// - Name of active state in state machine is NULL. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This function adds event data to event queue of the state machine. The events are posted in the reaction
+ /// which are executed in the state. The event queue is processed once the execution of the
+ /// reaction is completed.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CEventData, FrameworkunifiedIsReactionAvailable, CFrameworkunifiedHSM::FrameworkunifiedQueueEvent, CFrameworkunifiedHSM::ProcessEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPostEvent
+ /// This function adds the event queue of the state. The events are posted in the reaction
+ /// which are executed in the state. The event queue is processed once the execution of the
+ /// reaction is completed.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ EFrameworkunifiedStatus FrameworkunifiedPostEvent(CEventDataPtr f_pEventData);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// delete event from deferred event list
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 f_uiEventId - event ID
+ /// \~english @retval eFrameworkunifiedStatusOK delete deferred event success
+ /// \~english @retval eFrameworkunifiedStatusInvldID invalid event ID
+ /// \~english @retval eFrameworkunifiedStatusNullPointer exception occur when delete deferred event
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// delete event from deferred event list by event ID
+ /// failed if event id is not exist. exception occur if given param is NULL
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedRemoveEventFromDeferredEventList
+ /// This function removes the event from the posted deferred queue list of the state.
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event id
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if event removed
+ /// eFrameworkunifiedStatusInvldID if event not found in list
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FrameworkunifiedRemoveEventFromDeferredEventList(UI_32 f_uiEventId);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This function indicates if the state has sub states.
+ /// \~english @param None
+ /// \~english @retval BOOL if the state has sub states
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function indicates if the state has sub states. It returns TRUE only in the CompositeState
+ /// where this function is overridden
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CFrameworkunifiedCompositeState::FrameworkunifiedHasSubStates
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedHasSubStates
+ /// This indicates if the state has sub states. It returns TRUE only in the CompositeState
+ /// where this function is overridden
+ ///
+ /// \return TRUE/FASLE
+ /// BOOL - returns TRUE if it has sub states otherwise returns false.
+ virtual BOOL FrameworkunifiedHasSubStates();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This function indicates if the state has sub states.
+ /// \~english @param None
+ /// \~english @retval BOOL if the state has sub states
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function indicates if the state has sub states. It returns TRUE only in the OrthogonalState
+ /// where this function is overridden
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CFrameworkunifiedOrthogonalState
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedHasOrthogoanlRegions
+ /// This indicates if the state has sub states. It returns TRUE only in the OrthogonalState
+ /// where this function is overridden
+ ///
+ /// \return TRUE/FASLE
+ /// BOOL - returns TRUE if it has sub states otherwise returns false.
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual BOOL FrameworkunifiedHasOrthogoanlRegions();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This logs the state name and event name associated with the state
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer null pointer exception
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Failed to call constructor to create object. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This logs the state name and event name associated with the state. \n
+ /// It outputs the following logs:
+ /// - state name of parent state machine and self state machine
+ /// - all event names in event list
+ /// - all event names in deferred event list
+ /// CFrameworkunifiedCompositeState and CFrameworkunifiedOrthogonalState class overrides this function
+ /// and use it.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPrintStates
+ /// This logs the state name and events associated with the state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedPrintStates();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// Initialize state.
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to event data class
+ /// \~english @retval CFrameworkunifiedState* Pointer to current CFrameworkunifiedState object after processing event
+ /// \~english @retval NULL error occurs in internal process
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Failed to call function(FrameworkunifiedOnEntry) recursively. [NULL]
+ /// \~english @par Detail
+ /// This function is called recursively till the leaf state is reached. This internally
+ /// calls the Entry function of the current state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CEventData, FrameworkunifiedOnEntry, FrameworkunifiedOnHSMStop
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnHSMStart
+ /// This function is called recursively till the leaf state is reached. This internally
+ /// calls the Entry function of the current state.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedOnHSMStart(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// Clearup state.
+ /// \~english @param [in] f_pEventData
+ /// CEventDataPtr - Pointer to event data class
+ /// \~english @retval CFrameworkunifiedState* Pointer to current CFrameworkunifiedState object after processing event
+ /// \~english @retval NULL error occurs in internal process
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Failed to call constructor to create object. [NULL]
+ /// - Pointer to list of deferred events posted in the state is NULL. [NULL]
+ /// - Pointer to event data getted from list of deferred events posted in the state is NULL. [NULL]
+ /// - Event name of event data getted from list of deferred events posted in the state is NULL. [NULL]
+ /// \~english @par Detail
+ /// This function is called recursively till the required parent state is reached. This
+ /// internally calls the Exit function of the current state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CEventData, FrameworkunifiedOnExit, FrameworkunifiedOnHSMStart
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnHSMStop
+ /// This function is called recursively till the required parent state is reached. This
+ /// internally calls the Exit function of the current state.
+ ///
+ /// \param [in] f_pEventData
+ /// CECEventDataPtr Event data
+ /// \return CurrentState
+ /// CFrameworkunifiedState* - Returns current state after operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedOnHSMStop(CEventDataPtr f_pEventData);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// Check the availability of event.
+ /// \~english @param [in] f_uiEventId
+ /// UI_32 - event ID
+ /// \~english @retval TRUE reaction is available for this event
+ /// \~english @retval FALSE reaction is not available for this event
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// If the event specified by argument(f_uiEventId) is in event list,
+ /// the reaction is available for this event, return TRUE.
+ /// If the event specified by argument(f_uiEventId) is in deferred event list
+ /// but not in event list, the reaction is available for this event, return TRUE.
+ /// Otherwise, the event specified by argument(f_uiEventId) isn't available, return FALSE.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see FrameworkunifiedPostEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedIsReactionAvailable
+ ///
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event identifier
+ ///
+ /// \return TRUE/FASLE
+ /// BOOL - returns TRUE if it reaction is available for this event
+ virtual BOOL FrameworkunifiedIsReactionAvailable(UI_32 f_uiEventId);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param None
+ /// \~english @retval CFrameworkunifiedState* depend on implement class
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// pure virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedGetActiveState
+ /// This interface returns the Active state of the current composite state. In case of
+ /// non-composite state current state is active state
+ ///
+ /// \return Active state
+ /// CFrameworkunifiedState* - Active state
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedGetActiveState() = 0;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// This Interface associates the gives statemachine with the current state
+ /// \~english @param [in] f_pStatemachine
+ /// CFrameworkunifiedHSM* - Statemachine associated with the state.
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer exception
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Pointer to state machine(CFrameworkunifiedHSM class) specified by argument(f_pStatemachine) is NULL.
+ /// [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// This Interface sets state machine of member variable to state machine specified by argument,
+ /// so it can associate the giving statemachine with current state.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CFrameworkunifiedHSM
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedSetHSM
+ /// This Interface associates the gives statemachine with the current state
+ ///
+ /// \param [in] f_pStatemachine
+ /// CFrameworkunifiedHSM* - Statemachine associated with the state.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ virtual EFrameworkunifiedStatus FrameworkunifiedSetHSM(CFrameworkunifiedHSM *f_pStatemachine);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// Get application handle.
+ /// \~english @param None
+ /// \~english @retval HANDLE application handle
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Failed to get application handle. [NULL]
+ /// \~english @par Detail
+ /// This interface gets and returns the application handle with following steps:
+ /// - If member variable used for state machine of application is not setted, return NULL.
+ /// - Get application handle from state machine of application.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CFrameworkunifiedHSM::FrameworkunifiedGetAppHandle
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedGetAppHandle
+ /// This interface returns the application handle
+ ///
+ /// \return HANDLE
+ /// HANDLE - Application Handle
+ ///
+ virtual HANDLE FrameworkunifiedGetAppHandle();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Brief
+ /// Update the State information in the given stream in the form of XML tags
+ /// \~english @param [out] f_strXMLString
+ /// std::ostringstream & - reference to the XML stream
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer exception
+ /// \~english @par Prerequisite
+ /// - Calls constructor to successfully create object.
+ /// - State machine of current state in the applicaton is setted in FrameworkunifiedSetHSM.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Failed to call constructor to create object. [eFrameworkunifiedStatusNullPointer]
+ /// \~english @par Detail
+ /// Update the following State information in the given stream in the form of XML tags
+ /// - state name
+ /// - all event information in event list(eventID, event name)
+ /// - all event information in deferred event list(eventID, event name)
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CEventData, FrameworkunifiedIsReactionAvailable, CFrameworkunifiedHSM::FrameworkunifiedQueueEvent, CFrameworkunifiedHSM::ProcessEvent
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedPrintXML
+ /// Update the State information in the given stream in the form of XML tags
+ ///
+ /// \param [in] f_strXMLString
+ /// std::ostringstream & - reference to the XML stream
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ virtual EFrameworkunifiedStatus FrameworkunifiedPrintXML(std::ostringstream &f_strXMLString);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedState
+ /// \~english @par Summary
+ /// pure virtual fuction
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// pure virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateHistory
+ /// This function stores the last active state
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus UpdateHistory() = 0;
+
+ protected :
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnEntry
+ /// This is pure virtual function implemented by the derived classes of the application.
+ /// state initialization can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_pEventData) = 0;
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedOnExit
+ /// This is pure virtual function implemented by the derived classes of the application.
+ /// state cleanup can be performed in this function.
+ ///
+ /// \param [in] f_pEventData
+ /// CEventDataPtr - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_pEventData) = 0;
+
+ private:
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// IsEventDeferred
+ /// This checks if the given event is marked as deferred in the state.
+ ///
+ /// \param [in] f_uiEventId
+ /// UI_32 - Event identifier
+ ///
+ /// \return BOOL
+ /// BOOL - event deferred or not
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsEventDeferred(UI_32 f_uiEventId);
+
+ public:
+ /// state name
+ std::string m_strStateName;
+
+ /// Pointer to the parent state
+ CFrameworkunifiedState *m_pParentState;
+
+ /// pointer to the default state
+ CFrameworkunifiedState *m_pDefaultState;
+
+ /// pointer to the active state
+ CFrameworkunifiedState *m_pActiveState;
+
+ /// pointer to the map that stores the event name against event id
+ EventNameList *m_pEventName;
+
+ protected :
+ /// pointer to the map that stores the reaction against event id
+ EventReactionList *m_pEventList;
+
+ /// pointer to the map that stores deferred event ids
+ DeferredEventList *m_pDeferredEventList;
+
+ /// pointer to the vector that stores the eventinfo of the posted deferred event
+ EventInfoList *m_pDeferredPostEventList;
+
+ /// pointer to the application statemachine
+ CFrameworkunifiedHSM *m_pStateMachine;
+};
+
+#endif // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_STATE_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_transition.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_transition.h
new file mode 100644
index 00000000..232c91e7
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_sm_transition.h
@@ -0,0 +1,150 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_StateMachine
+/// \brief
+///
+/// This file has the CFrameworkunifiedTransition class definitions.This class provides the
+/// interface for reacting local transition and external transition
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_sm_transition.h
+ * @brief \~english This file has the CFrameworkunifiedTransition class definitions.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+/** @addtogroup statemachine
+ * @ingroup framework
+ * @{
+ */
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_TRANSITION_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_TRANSITION_H__
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_sm_reaction.h>
+
+class CFrameworkunifiedState;
+class CFrameworkunifiedEventData;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class provides the interface for reacting local transition and external transition
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedTransition : public CFrameworkunifiedReaction {
+ public :
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedTransition
+ /// \~english @par Summary
+ /// CFrameworkunifiedTransition constructor
+ /// \~english @param [in] f_pTargetState
+ /// CFrameworkunifiedState *f_pTargetState - set m_pTargetState value
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - m_pTargetState = f_pTargetState
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// CFrameworkunifiedTransition constructor, for create CFrameworkunifiedTransition object
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedTransition(CFrameworkunifiedState *f_pTargetState); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedTransition
+ /// \~english @par Summary
+ /// CFrameworkunifiedTransition destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// CFrameworkunifiedTransition destructor, for destroy CFrameworkunifiedTransition object
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedTransition();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedTransition
+ /// \~english @par Summary
+ /// virtual fuction
+ /// \~english @param [in] f_pSourceState
+ /// CFrameworkunifiedState *f_pSourceState - source state
+ /// \~english @param [in] f_pData
+ /// CEventDataPtr f_pData - event data
+ /// \~english @retval CFrameworkunifiedState* depend on implement class
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// virtual function , implement by child class
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual CFrameworkunifiedState *FrameworkunifiedReaction(CFrameworkunifiedState *f_pSourceState, CEventDataPtr f_pData) = 0;
+
+ protected :
+
+ /// Pointer to the target state of transition
+ CFrameworkunifiedState *m_pTargetState;
+};
+
+#endif // __FRAMEWORKUNIFIED_NATIVESERVICES_NATIVESERVICES_INC_FRAMEWORK_STATEMACHINE_FRAMEWORKUNIFIED_SM_TRANSITION_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_thread_priority.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_thread_priority.h
new file mode 100644
index 00000000..2af26a31
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_thread_priority.h
@@ -0,0 +1,235 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief The file provide CFrameworkunifiedThreadPriorities class.
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_thread_priority.h
+ * @brief \~english The file contains declaration of CFrameworkunifiedThreadPriorities class
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef FRAMEWORKUNIFIED_THREAD_PRIORITY_H_ // NOLINT (build/header_guard)
+#define FRAMEWORKUNIFIED_THREAD_PRIORITY_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <map>
+
+#define FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND -1 ///< \~english if specified thread name not found
+
+namespace frameworkunified {
+namespace framework {
+class args {
+ public:
+ enum {
+ name,
+ priority
+ };
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// This class parses and stores thread priorities
+///////////////////////////////////////////////////////////////////////////////////////////////////
+class CFrameworkunifiedThreadPriorities {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedThreadPriorities
+ /// \~english @par Brief
+ /// CFrameworkunifiedThreadPriorities constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedThreadPriorities constructor, for create CFrameworkunifiedThreadPriorities
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedThreadPriorities();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedThreadPriorities
+ /// \~english @par Brief
+ /// CFrameworkunifiedThreadPriorities destructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// None
+ /// \~english @par Change of internal state
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// CFrameworkunifiedThreadPriorities destructor, for destory CFrameworkunifiedThreadPriorities
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ ///
+ /////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedThreadPriorities();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedThreadPriorities
+ /// \~english @par Brief
+ /// Get the priority of the thread. Priority of the thread was added by \ref AddPriority(),
+ /// when parsing command line arguments.
+ /// \~english @param [in] f_cThreadName
+ /// const std::string& - Name of thread
+ /// \~english @retval SI_32 Returns the priority of a thread.
+ /// \~english @retval FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND if specified thread name not found
+ /// \~english @par
+ /// FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND
+ /// \~english @code
+ /// #define FRAMEWORKUNIFIED_PRIORITY_NOT_FOUND -1 // if specified thread name not found
+ /// @endcode
+ /// \~english @par Prerequisite
+ /// - Call AddPriority() and set priority.
+ /// \~english @par Change of internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - Thread name is not registered in AddPriority()
+ /// \~english @par Detail
+ /// Get the priority of the thread. Priority of the thread was added by \ref AddPriority(),
+ /// when parsing command line arguments.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see
+ /// AddPriority
+ /////////////////////////////////////////////////////////////////////////////////////
+ static SI_32 GetPriority(const std::string &f_cThreadName);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedThreadPriorities
+ /// \~english @par Summary
+ /// set thread Priority
+ /// \~english @param [in] f_cThreadName
+ /// const std::string &f_cThreadName - thread name
+ /// \~english @param [in] f_si32Priority
+ /// SI_32 f_si32Priority - Priority
+ /// \~english @retval eFrameworkunifiedStatusOK set Priority success
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Change of the internal state
+ /// - ms_mapThreadPritories[f_cThreadName] = f_si32Priority
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// set thread Priority through thread name
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus AddPriority(const std::string &f_cThreadName, SI_32 f_si32Priority);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedThreadPriorities
+ /// \~english @par Summary
+ /// print thread Priority
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// read each thread and print it's Priority
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+ static VOID PrintPriorites();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CFrameworkunifiedThreadPriorities
+ /// \~english @par Summary
+ /// analyse thread param
+ /// \~english @param [in] f_cArgumentValue
+ /// PCHAR f_cArgumentValue - thread param string
+ /// \~english @retval eFrameworkunifiedStatusOK parse thread param success
+ /// \~english @retval eFrameworkunifiedStatusFail parse thread param failed
+ /// \~english @par Preconditions
+ /// - None
+ /// \~english @par Change of the internal state
+ /// - None
+ /// \~english @par Causes of failures
+ /// - f_cArgumentValue == NULL
+ /// - f_cArgumentValue is invalid
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// analyse thread param data, and set param to thread.
+ /// if given data is NULL or invalid , return false
+ /// \~english @see getsubopt, AddPriority
+ ////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus ParseThreadArguments(PCHAR f_cArgumentValue);
+
+ private:
+ typedef std::map<std::string, SI_32> TThreadPriorityList;
+ typedef TThreadPriorityList::iterator ThreadPrioMapIter;
+ static TThreadPriorityList ms_mapThreadPritories; // map of thread name and priority
+};
+
+} // namespace framework
+}; // namespace frameworkunified
+
+#endif /* FRAMEWORKUNIFIED_THREAD_PRIORITY_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_timer.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_timer.h
new file mode 100644
index 00000000..7a3c762e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_timer.h
@@ -0,0 +1,143 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+/// \brief Application framework's core structures and data types.
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file frameworkunified_timer.h
+ * @brief \~english Application framework's core structures and data types.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NSFRAMEWORK_NFRAMEWORKCORE_FRAMEWORKUNIFIEDTIMER__ // NOLINT (build/header_guard)
+#define __NSFRAMEWORK_NFRAMEWORKCORE_FRAMEWORKUNIFIEDTIMER__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedAttachTimerCallback
+/// \~english @par Brief
+/// Attach a callback to hApp dispatcher that will get called initially at initNS nanoseconds,
+/// and then repeatedly at repeatNS nanoseconds
+/// \~english @param[in] hApp
+/// HANDLE - hApp parent framework HANDLE
+/// \~english @param[in] initMS
+/// UI_32 - milliseconds to begin triggering callback(0 to 4294967295)
+/// \~english @param[in] repeatMS
+/// UI_32 - milliseconds between repeated triggerings of callback(0 to 4294967295)
+/// \~english @param[in] CbFn
+/// CbFuncPtr - Callback to be triggered
+/// \~english @retval Handle to the timer object or NULL on failure
+/// \~english @par Preconditons
+/// - hApp has already gotten the dispatcher(return NULL)
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - hApp is not application HNADLE(return NULL)
+/// - eFrameworkunifiedStatusFail if the hApp specified in the arguments is not appropriate (not valid) [NULL]
+/// - CbFn is NULL(return NULL))
+/// - If the send message queue handle specified in the argument (hApp) to itself is NULL [NULL]
+/// - Failed to create epoll instances (epoll_create1/eventfd) for timer event monitoring [NULL]
+/// - Failed to create a timer event monitor thread (pthread_create) [NULL]
+/// - When acquisition (malloc) of the timer-management-information area fails [NULL]
+/// - If the send message queue type to the handle (hApp) specified in the parameter is neither send nor receive, [NULL]
+/// - Failed to generate timers (timerfd_create) [NULL]
+/// - Failed to register file descriptors for timer notification to epoll instances (epoll_ctl) [NULL]
+/// - Failed to start/stop timer (timerfd_settime) [NULL]
+/// \~english @par Detail
+/// After registering the callback functions for timer events in the Dispatcher specified by the hApp arguments,
+/// it creates and starts a timer and returns its handles.\n
+/// Dispatcher executes callback functions when the timers generated by the APIs fire.\n
+/// The application shall use this API when there is a process to be executed once or repeatedly in response to a specified time elapsed.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - If the application specifies a initMS of 0, a timer is created and handles are returned, but the callback is not executed because the timer is stopped.
+/// - If the application specifies a repeatMS of zero, the callback is executed only once.
+/// - Since the timer handle is a FrameworkunifiedAttachTimerCallback return value, the callback cannot be set twice with the same timer handle.
+/// - If multiple calls are made with the same application handle, the second and subsequent callbacks are not set,
+/// and the first registered callback function is started at the last registered timer interval.
+/// - Create a thread for sending messages, but do not make dynamic calls because the thread is not destroyed even if FrameworkunifiedDetachTimerCallback is executed.
+/// \~english @par Classification
+/// \~english @par Type
+/// Open Close
+/// \~english @see FrameworkunifiedDetachTimerCallback
+/// \~english @todo needs to clarify this API require initMS except 0
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE FrameworkunifiedAttachTimerCallback(HANDLE hApp, UI_32 initMS, UI_32 repeatMS, CbFuncPtr CbFn);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup FrameworkunifiedDetachTimerCallback
+/// \~english @par Brief
+/// Detach callback and deallocate a timer previous created with FrameworkunifiedAttachTimerCallback
+/// \~english @param[in] hApp
+/// HANDLE - hApp parent framework HANDLE
+/// \~english @param[in] hTimer
+/// HANDLE - timer HANDLE
+/// \~english @retval HANDLE HANDLE used to communicate with child. NULL...failure, otherwize...success
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusFail(not happened)
+/// \~english @retval eFrameworkunifiedStatusInvldParam
+/// \~englsih @par Preconditions
+/// - Timer is dispatched for hApp Callback
+/// \~englsih @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - hApp is not application HNADLE(eFrameworkunifiedStatusInvldParam)
+/// - eFrameworkunifiedStatusFail if the hApp specified in the arguments is not appropriate (not valid) [eFrameworkunifiedStatusInvldParam]
+/// - hTimer is NULL(eFrameworkunifiedStatusInvldParam)
+/// - When the timer has been stopped by the timer administrative info of the timer handle specified by the arguments, [eFrameworkunifiedStatusFail]
+/// - When the timer administrative information of the timer handle specified by the arguments is NULL, [eFrameworkunifiedStatusFail]
+/// - Failed to stop the timer (timerfd_settime) [eFrameworkunifiedStatusFail]
+/// - If a callback for the timer event is not registered in the Dispatcher specified by the hApp, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Stops the timer (hTimer) specified by the argument and registrations the callback functions
+/// for timer events from the Dispacther specified by the argument hApp.
+/// \~english @par
+/// Please note the following points when using this API for application.\n
+/// - Operation is not guaranteed if a different handle is set for the timer handle.
+/// - If a normal timer handle and an invalid application handle are set, only the timer information is deleted, resulting in an inconsistent state.
+/// \~english @par Classification
+/// \~english @par Type
+/// Open Close
+/// \~english @see FrameworkunifiedAttachTimerCallback
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedDetachTimerCallback(HANDLE hApp, HANDLE hTimer);
+
+#endif // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/frameworkunified_types.h b/nsframework/framework_unified/client/include/native_service/frameworkunified_types.h
new file mode 100644
index 00000000..faaf3aa0
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/frameworkunified_types.h
@@ -0,0 +1,268 @@
+/*
+ *
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file frameworkunified_types.h
+ * @brief \~english This file contains basic define,enum and struct of framework_unified.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef FRAMEWORKUNIFIED_TYPES_H_ // NOLINT (build/header_guard)
+#define FRAMEWORKUNIFIED_TYPES_H_
+
+#include <stdint.h>
+
+#define DEFINE_HANDLE_TYPE(struct_type, handle_type) typedef struct struct_type* handle_type;
+
+#define MIN_VAL(a, b) ((a) < (b)? (a) : (b))
+
+#ifndef NULL
+#define NULL 0
+#endif
+#ifndef VOID
+typedef void VOID;
+#endif
+#ifndef CONST
+#define CONST const
+#endif
+
+/// Lengths and Max Sizes
+#define INVALID_HANDLE NULL
+#define MAX_QUEUE_MSG_SIZE 4096
+// #define MAX_QUEUE_NAME_SIZE 24
+#define MAX_QUEUE_NAME_SIZE 20
+#define LIMIT_QUEUE_NAME_SIZE 16
+#define MAX_SYS_INFO_SIZE 64
+
+#define MAX_NAME_SIZE_APP MAX_QUEUE_NAME_SIZE ///< Maximum name size of the APP (Client/Service)
+#define LIMIT_NAME_SIZE_APP LIMIT_QUEUE_NAME_SIZE ///< Limit name size of the APP (Client/Service)
+#define MAX_NAME_SIZE_NOTIFICATION 24 ///< Maximum name size of the Notification
+#define MAX_STRING_SIZE_NOTIFICATION 64
+
+#define MAX_STRING_SIZE_TAG 64
+#define MAX_PATH_LENGTH 255
+
+
+#define NS_SHM_ERROR -1
+
+// Types
+typedef int8_t SI_8;
+typedef uint8_t UI_8;
+typedef int16_t SI_16;
+typedef uint16_t UI_16;
+typedef int32_t SI_32;
+typedef uint32_t UI_32;
+typedef int64_t SI_64;
+typedef uint64_t UI_64;
+typedef float F_32;
+typedef double F_64;
+// use it defined kernelmoduleevklibdd.h typedef UI_32 BOOL;
+#define PFALSE ((BOOL)0)
+#define PTRUE ((BOOL)1)
+
+#ifndef FALSE
+#define FALSE PFALSE
+#endif
+#ifndef TRUE
+#define TRUE PTRUE
+#endif
+
+// Pointer Types
+typedef BOOL *PBOOL;
+typedef SI_8 *PSI_8;
+typedef UI_8 *PUI_8;
+typedef SI_16 *PSI_16;
+typedef UI_16 *PUI_16;
+typedef UI_32 *PUI_32;
+typedef SI_32 *PSI_32;
+typedef UI_64 *PUI_64;
+typedef SI_64 *PSI_64;
+typedef F_32 *PF_32;
+typedef void *PVOID;
+typedef CONST void *PCVOID;
+
+typedef char CHAR, *PCHAR;
+typedef CONST char *PCSTR;
+typedef char *PSTR;
+
+typedef UI_8 _TUCHAR;
+typedef SI_32 HFILE;
+typedef PVOID HANDLE;
+typedef HANDLE *PHANDLE;
+typedef CHAR TSysMsgSystemInfo[MAX_SYS_INFO_SIZE]; ///< Information passed via the framework
+
+
+/// CR carry over types...
+/// \brief Types that have been carried
+/// over from Color Radio header file WPFAPI_types.h.
+typedef UI_16 MID;
+typedef UI_16 FRAMEWORKUNIFIED_CID;
+typedef UI_8 RID;
+typedef UI_16 PNO;
+typedef UI_8 BYTE;
+
+#define LOWORD(l) ((WORD)(l))
+#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
+#define _countof(array) (sizeof(array)/sizeof(array[0]))
+
+/// \typedef EFrameworkunifiedStatus
+/// \brief Status and return types
+typedef enum eFrameworkunifiedStatus {
+ eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+ eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+ eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+ eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+ eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+ eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+ eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+ eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+ eFrameworkunifiedStatusFail = -2, ///< Failed
+ eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+ eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+ eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+ eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+ eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+ eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+ eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+ eFrameworkunifiedStatusInvldNotification = 6, ///< The Notification event not present
+ eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+ eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+ eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+ eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+ eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+ eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+ eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+ eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+ eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+ eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+ eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+ eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+ eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+ eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+ eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+ eFrameworkunifiedStatusNullPointer = 22,
+ eFrameworkunifiedStatusMsgNotProcessed = 23,
+ eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+ eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+ eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+ eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+ eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+ eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+ eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+ eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+ eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+ eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+ eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+ eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+} EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+
+/// \typedef EFrameworkunifiedNotificationType
+/// \brief Notification types
+typedef enum _EFrameworkunifiedNotificationType {
+ eFrameworkunifiedNotificationVar = 0, ///< Non Persistent. Not stored locally by NPS
+ eFrameworkunifiedStateVar, ///< Non Persistent. stored locally by NPS
+ eFrameworkunifiedPersistedStateVar, ///< Persistent. Also stored locally by NPS
+ eFrameworkunifiedPersistedStateUserVar, ///< User specific Persistent. Also stored locally by NPS
+ eFrameworkunifiedImmediatePersistedStateVar, ///< Not to be used. See \ref FrameworkunifiedNPRegisterImmediatePersistNotification
+ eFrameworkunifiedUnknown ///< This is not a type of notification and should not be used while
+ ///< defining any notification.
+} EFrameworkunifiedNotificationType;
+
+/// \typedef ENS_ApplicationState
+/// \brief Application States that all module must handle
+/// this should be handle by Publishing a "ModuleName/State"
+/// with the parameter being one of these state values.
+typedef enum _EApplicationStates {
+ eAppInital = 0, ///< Initial: state value
+ eAppIdle, ///< Idle: application shouldn't be processing anything
+ eAppReady, ///< Ready: application is ready to do work
+ eAppConnecting, ///< Connecting: Service is connecting
+ eAppDisconnecting ///< Disconnecting: Service is disconnecting
+} EApplicationStates;
+
+
+typedef enum _EFrameworkunifiedMessagePriorties {
+ eFrameworkunifiedMsgPrioVeryLow = 1,
+ eFrameworkunifiedMsgPrioLow = 8,
+ eFrameworkunifiedMsgPrioNormal = 16,
+ eFrameworkunifiedMsgPrioEmergency = 30,
+} EFrameworkunifiedMessagePriorties;
+
+// defines what data to delete from persistent memory
+typedef enum _EFrameworkunifiedClearPersistence {
+ eFrameworkunifiedClearAllData = 0, ///< clears all the data in persistence memory for all users
+ ///< (currently only this enum value is supported.)
+ eFrameworkunifiedClearAllApplicationData, ///< clears all the data(files, folders) related to all application for all users
+ eFrameworkunifiedClearAllNotificationData, ///< clears all the notification data related to all application for all users
+ eFrameworkunifiedClearCurrentUserData, ///< clears all the data in persistence memory for current users
+ eFrameworkunifiedClearCurrentUserApplicationData, ///< clears all the data(files, folders)
+ ///< related to all application for current users
+ eFrameworkunifiedClearCurrentUserNotificationData ///< clears all the notification data
+ ///< related to all application for current users
+} EFrameworkunifiedClearPersistence;
+
+/// Enum defining category of persistent data
+typedef enum _EFrameworkunifiedPersistCategory {
+ eFrameworkunifiedUserData = 0x0001,
+ eFrameworkunifiedFactoryData = 0x0010,
+ eFrameworkunifiedFactoryCustomerData = 0x0100,
+ eFrameworkunifiedDealerData = 0x1000
+} EFrameworkunifiedPersistCategory;
+
+// defines the type of system error
+typedef enum _EFrameworkunifiedSystemError {
+ // TODO(framework_unified): add generic system errors
+ eFrameworkunifiedSystemErrorNone = 0,
+ eFrameworkunifiedDSPHardwareReset = 1 // system error is DSP hardware reset.
+ // It was commented, because this is product
+ // specific error. Must handle by SystemServices only.
+ // Uncommented per system services request.
+} EFrameworkunifiedSystemError;
+
+/// defines the shutdown types
+typedef enum _EFrameworkunifiedShutdownType {
+ eFrameworkunifiedNormalShutdown = 0,
+ eFrameworkunifiedQuickShutdown,
+ eFrameworkunifiedDataResetShutdown
+} EFrameworkunifiedShutdownType;
+
+/// defines the Release types
+typedef enum _EFrameworkunifiedReleaseType {
+ eFrameworkunifiedNotOnRelease = 0, ///< 0:not on release
+ eFrameworkunifiedPersistOnShutdown, ///< 1:persist on shutdown
+ eFrameworkunifiedPersistInstantly, ///< 2:persist instantly
+} EFrameworkunifiedReleaseType;
+
+#endif // FRAMEWORKUNIFIED_TYPES_H_ // NOLINT (build/header_guard))
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns__CWORD77__common.h b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__common.h
new file mode 100644
index 00000000..e472b303
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__common.h
@@ -0,0 +1,129 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns__CWORD77__common.h
+ * @brief \~english This file has templet class declaration of CCallback and CResCallback
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _NS__CWORD77_COMMON_H_ // NOLINT (build/header_guard)
+#define _NS__CWORD77_COMMON_H_
+
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns__CWORD77__types.h>
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#define MAX_DATA_SIZE 512;
+// using namespace std;
+
+
+// typedef string ServiceName;
+
+
+#define DELETEPTR(p) {if (p != NULL) {delete p; p = NULL;}}
+
+typedef EFrameworkunifiedStatus(*_CWORD77_FuncPtr)(HANDLE hApp, BOOL bTImerExpiry);
+typedef EFrameworkunifiedStatus(*ResponseServiceTo_CWORD77_)(HANDLE hApp, E_CWORD77_ResponseType ResponseType, std::string ServiceName);
+typedef boost::function< EFrameworkunifiedStatus(HANDLE, std::string, std::string, UI_32, EFrameworkunifiedStatus) > SessionAckTo_CWORD77_;
+
+// typedef EFrameworkunifiedStatus (*_CWORD77_TimeoutFuncPtr)(HANDLE hApp,UI_32 uiCmdId, E_CWORD77_MessageType MessageType);
+
+template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE)>
+class CCallback {
+ public:
+ static CallbackFunctionPtr set(void *pInst) {
+ if (pInst == NULL) {
+ throw;
+ }
+ if (ms_pInst != NULL) {
+ // TODO(framework_unified): FRAMEWORKUNIFIEDLOG some warning, preferably outside the template (i.e. use a global),
+ // to limit executable size, as this code will be replicated many times over
+ }
+ ms_pInst = pInst;
+ return &CCallback::call;
+ }
+ static EFrameworkunifiedStatus call(HANDLE y) {
+ if (ms_pInst == NULL) {
+ return eFrameworkunifiedStatusFault; // can't throw here
+ }
+ C *c = static_cast<C *>(ms_pInst);
+ return (c->*M)(y);
+ }
+ private:
+ static void *ms_pInst;
+};
+
+
+
+template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE)>
+void *CCallback<C, M>::ms_pInst = NULL;
+
+
+
+template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE, E_CWORD77_ResponseType, std::string)>
+class CResCallback {
+ public:
+ static ResponseServiceTo_CWORD77_ set(void *pInst) {
+ if (pInst == NULL) {
+ throw;
+ }
+ if (ms_pInst != NULL) {
+ // TODO(framework_unified): FRAMEWORKUNIFIEDLOG some warning, preferably outside the template (i.e. use a global),
+ // to limit executable size, as this code will be replicated many times over
+ }
+ ms_pInst = pInst;
+ return &CResCallback::call;
+ }
+ static EFrameworkunifiedStatus call(HANDLE y, E_CWORD77_ResponseType ResponseType, std::string ServiceName) {
+ if (ms_pInst == NULL) {
+ return eFrameworkunifiedStatusFault; // can't throw here
+ }
+ C *c = static_cast<C *>(ms_pInst);
+ return (c->*M)(y, ResponseType, ServiceName);
+ }
+ private:
+ static void *ms_pInst;
+};
+
+template <typename C, EFrameworkunifiedStatus(C::*M)(HANDLE, E_CWORD77_ResponseType, std::string)>
+void *CResCallback<C, M>::ms_pInst = NULL;
+
+
+#endif // _NS__CWORD77_COMMON_H_ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_if.h b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_if.h
new file mode 100644
index 00000000..0fab83bf
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_if.h
@@ -0,0 +1,183 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns__CWORD77__data_pool_if.h
+ * @brief \~english This file provides api to operating _CWORD77_DataPool
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+#ifndef _C_CWORD77_DATAPOOLIF_H_ // NOLINT (build/header_guard)
+#define _C_CWORD77_DATAPOOLIF_H_
+
+#include <native_service/ns__CWORD77__types.h>
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_HMI_CWORD77_Controller
+ /// \~english @par Brief
+ /// API to set data associated with request into _CWORD77_ Data Pool
+ /// \~english @param [in] f_DataPoolKey
+ /// _CWORD77_DataPoolKey - Data pool key
+ /// \~english @param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \~english @param [in] f_pData
+ /// PVOID - void pointer to data
+ /// \~english @retval none
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - None.
+ /// \~english @par Detail
+ /// API to set data associated with request into _CWORD77_ Data Pool
+ /// \~english @par
+ /// It is maintained by executing C_CWORD77_Data::SetRespoData().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Set Get
+ /// \~english @see GetRespDataFrom_CWORD77_DataPool, C_CWORD77_Data::SetRespoData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+VOID SetReqDataIn_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 f_uiSize, PVOID f_pData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_HMI_CWORD77_Controller
+ /// \~english @par Brief
+ /// API to get data associated with response from _CWORD77_ Data Pool
+ /// \~english @param [in] f_DataPoolKey
+ /// _CWORD77_DataPoolKey - Data pool key
+ /// \~english @param [out] f_uiSize
+ /// UI_32 - size of the data
+ /// \~english @param [out] f_pData
+ /// PVOID - void pointer to data
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusFail Error
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - C_CWORD77_Data Class instance fail or create fail [eFrameworkunifiedStatusFail]
+ /// - f_DataPoolKey is not registered [eFrameworkunifiedStatusFail]
+ /// - f_pData is NULL [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// API to get data associated with response from _CWORD77_ Data Pool
+ /// \~english @par
+ /// Use SetRespNotfnDataFrom_CWORD77_DataPool() to keep the data.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Set Get
+ /// \~english @see SetRespNotfnDataFrom_CWORD77_DataPool, C_CWORD77_Data::GetRespoData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetRespDataFrom_CWORD77_DataPool(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_HMI_CWORD77_Controller
+ /// \~english @par Brief
+ /// API to set data associated with notification response into _CWORD77_ Data Pool
+ /// \~english @param[in] f_cNotificationName
+ /// const std::string& - Name of the notification
+ /// \~english @param[in] f_uiSize
+ /// UI_32 - size of the data
+ /// \~english @param[in] f_pData
+ /// const PVOID - void pointer to data
+ /// \~english @retval none
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - None.
+ /// \~english @par Detail
+ /// API to set data associated with notification response into _CWORD77_ Data Pool
+ /// \~english @par
+ /// Use GetRespNotfnDataFrom_CWORD77_DataPool() to get the held data.
+ /// \~english @par
+ /// It is maintained by executing C_CWORD77_Data::SetRespoData().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Set Get
+ /// \~english @see GetRespNotfnDataFrom_CWORD77_DataPool, C_CWORD77_Data::SetRespoData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+VOID SetRespNotfnDataIn_CWORD77_DataPool(const std::string &f_cNotificationName, UI_32 f_uiSize, const PVOID f_pData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup tag_HMI_CWORD77_Controller
+ /// \~english @par Brief
+ /// API to set data associated with notification response into _CWORD77_ Data Pool
+ /// \~english @param[in] f_cNotificationName
+ /// const std::string& - Name of the notification
+ /// \~english @param[out] f_uiSize
+ /// UI_32& - size of the data
+ /// \~english @param[out] f_pData
+ /// PVOID& - void pointer to data
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusFail Fail
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - C_CWORD77_Data Class instance fail or create fail [eFrameworkunifiedStatusFail]
+ /// - f_cNotificationName is not registered [eFrameworkunifiedStatusFail]
+ /// - f_pData is NULL [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// API to set data associated with notification response into _CWORD77_ Data Pool
+ /// \~english @par
+ /// Use SetRespNotfnDataFrom_CWORD77_DataPool() to keep the data.
+ /// \~english @par
+ /// Get by executing C_CWORD77_Data::GetRespoData().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Set Get
+ /// \~english @see SetRespNotfnDataFrom_CWORD77_DataPool, C_CWORD77_Data::GetRespoData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetRespNotfnDataFrom_CWORD77_DataPool(const std::string &f_cNotificationName, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData); // NOLINT (readability/nolint)
+
+#endif // _C_CWORD77_DATAPOOLIF_H_ NOLINT (build/header_guard)
+//@}
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_key.h b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_key.h
new file mode 100644
index 00000000..6e3fbc19
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_key.h
@@ -0,0 +1,53 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns__CWORD77__data_pool_key.h
+ * @brief \~english Provide function _CWORD77__DATA_POOL_KEY of make_pair
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+#ifndef NS__CWORD77__DATA_POOL_KEY_H_ // NOLINT (build/header_guard)
+#define NS__CWORD77__DATA_POOL_KEY_H_
+
+#define _CWORD77__DATA_POOL_KEY(ProtocolId) (std::make_pair(ProtocolId, g_c_CWORD77_ServiceName))
+
+#endif /* NS__CWORD77__DATA_POOL_KEY_H_ */ // NOLINT (build/header_guard)
+//@}
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_table.h b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_table.h
new file mode 100644
index 00000000..73f6a203
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__data_pool_table.h
@@ -0,0 +1,1217 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns__CWORD77__data_pool_table.h
+ * @brief \~english This file provides API for convert and C_CWORD77_DataPool class
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _CWORD77__DATA_POOL_TABLE_H_ // NOLINT (build/header_guard)
+#define _CWORD77__DATA_POOL_TABLE_H_
+
+#include <native_service/ns__CWORD77__common.h>
+#include <sstream>
+#include <map>
+#include <string>
+#include <vector>
+
+/// Enumeration for Type of Table
+typedef enum _ETableType {
+ REQUEST_TABLE = 1,
+ RESPONSE_TABLE
+} ETableType, *PETableType;
+
+/// Enumeration for Data Type
+typedef enum _EDataType {
+ UNKNOWNTYPE = -1,
+ SIGNEDINT,
+ UNSIGNEDINT,
+ FLOAT,
+ DOUBLE,
+ CHARACTER,
+ BOOLEAN,
+ STRING,
+} EDataType, *PEDataType;
+
+/// _CWORD77_ Data structure
+typedef struct __CWORD77_Data {
+ EDataType DataType;
+ std::string DataValue;
+} _CWORD77_Data, *P_CWORD77_Data;
+
+typedef std::map< _CWORD77_DataPoolKey, std::vector< CHAR > > T_CWORD77_DataPool;
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NoOfElementsinData
+/// Function to get number of elements for given string
+///
+/// \param [in] Input
+/// string - string
+///
+/// \return UI_32 - Number of elements
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 NoOfElementsinData(std::string Input);
+
+/// Template to Convert Number to String
+
+template <typename T>
+std::string NumberToString(T Number) {
+ std::ostringstream ss;
+ ss << Number;
+ return ss.str();
+}
+
+/// Template to convert String to Number
+
+template <typename T>
+T StringToNumber(const std::string &Text) {
+ std::istringstream ss(Text);
+ T result;
+ ss >> result;
+ return result;
+}
+
+/// Template to Convert an Array To String
+
+template<class T>
+std::string ConvertArrayToString(T *Array, int Arraysize) {
+ int length = 0;
+ std::string Result = "";
+ while (length < Arraysize) {
+ Result.append(NumberToString<T>(Array[length]));
+ Result.append(",");
+ length++;
+ }
+ Result.append("");
+ return Result;
+}
+
+/// Template to Convert String To Array
+template<class T>
+void ConvertStringToArray(std::string Input, std::vector<T> &Array, UI_32 &Arraysize) { // NOLINT (readability/nolint)
+ int i = 0;
+ std::string first = "";
+ std::istringstream ss(Input);
+ int Size = NoOfElementsinData(Input);
+ // T Arr[Size];
+ while (!ss.eof()) {
+ getline(ss, first, ',');
+ if (first != "") {
+ Array[i] = StringToNumber<T>(first);
+ i++;
+ }
+ }
+ Arraysize = i;
+ // memcpy(Array,(void *)Arr,Arraysize*sizeof(T));
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ConvertArrayStringsToString
+/// Function to convert array of strings to string
+///
+/// \param [in] strArr
+/// string * - pointer to array of strings
+/// \param [in] Size
+/// SI_32 - Number of strings
+///
+/// \return string
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string ConvertArrayStringsToString(std::string *strArr, SI_32 Size);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ConvertArrayStringsToString
+/// Function to convert string to array of strings
+///
+/// \param [in] Input
+/// string - string contains array of strings
+/// \param [out] strArr
+/// string * - Pointer to Array of strings
+/// \param [out] ArraySize
+/// UI_32 - No of elements in Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void ConvertStringToArrString(std::string Input, std::string *strArr, UI_32 &ArraySize); // NOLINT (readability/nolint)
+
+///////////////////////////////////////////////////////////////////////////
+/// class: C_CWORD77_DataPool
+/// Description: This is interface class to _CWORD77_ Data base.
+/// It provides APIs to set and get data from _CWORD77_ Data base
+///
+////////////////////////////////////////////////////////////////////////////
+class C_CWORD77_DataPool {
+ private:
+ std::map<UI_32, _CWORD77_Data> m__CWORD77_DataRequestTable; ///< Request Data Table
+ std::map<UI_32, _CWORD77_Data> m__CWORD77_DataResponseTable; ///< Response Data Table
+
+ static C_CWORD77_DataPool *m_p_CWORD77_DataPoolInstance; ///< Static instance to C_CWORD77_DataPool
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetData
+ /// Templatized Function to get data from _CWORD77_ Data base
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// string - Variable Name or key value
+ /// \param [out] Array
+ /// T * - Pointer to an array of given type
+ /// \param [out] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ template<class T>
+ void GetData(ETableType TableType, UI_32 VarName, T *Array, UI_32 &ArraySize) { // NOLINT (readability/nolint)
+ EDataType DataType = SIGNEDINT;
+ std::string DataValue;
+ GetValueFromMap(TableType, VarName, DataType, DataValue);
+ UI_32 Num = NoOfElementsinData(DataValue);
+ std::vector<T> Temp;
+ Temp.resize(Num);
+ ConvertStringToArray<T>(DataValue, Temp, ArraySize);
+ for (unsigned int i = 0; i < Num; i++) {
+ Array[i] = Temp[i];
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetData
+ /// Templatized Function to set data into _CWORD77_ Data base
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// string - Variable Name or key value
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] Array
+ /// T * - Pointer to an array of given type
+ /// \param [in] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void SetData(ETableType TableType, UI_32 VarName, EDataType DataType, T *Array, UI_32 ArraySize) {
+ std::string Result = ConvertArrayToString(Array, ArraySize);
+ SetValueinMap(TableType, VarName, DataType, Result);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetValueFromMap
+ /// Function to get data from _CWORD77_ map
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// string - Variable Name or key value
+ /// \param [out] DataType
+ /// EDataType - Data Type of key
+ /// \param [out] Strvalue
+ /// string - Output in the form of string
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void GetValueFromMap(ETableType TableType, UI_32 VarName, EDataType &DataType, std::string &Strvalue); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetValueinMap
+ /// Function to set data in _CWORD77_ map
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// string - Variable Name or key value
+ /// \param [in] VarType
+ /// EDataType - Data Type of key
+ /// \param [in] Result
+ /// string - input in the form of string
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetValueinMap(ETableType TableType, UI_32 VarName, EDataType VarType, std::string Result);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetArrayStringData
+ /// Function to set string data in _CWORD77_ map
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// string - Variable Name or key value
+ /// \param [in] VarType
+ /// EDataType - Data Type of key
+ /// \param [in] DataValue
+ /// string [] - Array of strings
+ /// \param [in] Size
+ /// UI_32 - No of elements in Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetArrayStringData(ETableType TableType,
+ UI_32 VarName,
+ EDataType VarType,
+ std::string DataValue[],
+ UI_32 size);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetArrayStringData
+ /// Function to get string data in _CWORD77_ map
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [out] DataValue
+ /// string [] - Array of strings
+ /// \param [out] Size
+ /// UI_32 - No of elements in Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void GetArrayStringData(ETableType TableType, UI_32 VarName, std::string DataValue[], UI_32 &size); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNoofElementsofData
+ /// Function to get Number of elements in data item
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// UI_32 - key
+
+ ///
+ /// \return UI_32 - Number of elements
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetNoofElementsofData(ETableType TableType, UI_32 Key);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetDataType
+ /// Function to get data type of given key Name
+ ///
+ /// \param [in] TableType
+ /// ETableType - Table Type (Request or Response)
+ /// \param [in] VarName
+ /// UI_32 - key
+
+ ///
+ /// \return EDataType - Data type of variable
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ EDataType GetDataType(ETableType TableType, UI_32 Key);
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// C_CWORD77_DataPool
+ /// Constructor for C_CWORD77_DataPool
+ /// \param None
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ C_CWORD77_DataPool();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~C_CWORD77_DataPool
+ /// Destructor for C_CWORD77_DataPool
+ /// \param None
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ ~C_CWORD77_DataPool();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetInstance
+ /// API to get single instance of C_CWORD77_DataPool
+ /// \param None
+ /// \return Pointer to single instance of C_CWORD77_Controller
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static C_CWORD77_DataPool *GetInstance();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// DeleteInstance
+ /// API to delete single instance of C_CWORD77_DataPool
+ /// \param None
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static void DeleteInstance();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestArrayData
+ /// Templatized Function to set array data into Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] Array
+ /// T * - Pointer to an array of given type
+ /// \param [in] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void SetReqArrayData(UI_32 VarName, EDataType DataType, T *Array, UI_32 ArraySize) {
+ SetData<T>(REQUEST_TABLE, VarName, DataType, Array, ArraySize);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestArrayData
+ /// Templatized Function to set array data into Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] Array
+ /// T * - Pointer to an array of given type
+ /// \param [in] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void SetRespArrayData(UI_32 VarName, EDataType DataType, T *Array, UI_32 ArraySize) {
+ SetData<T>(RESPONSE_TABLE, VarName, DataType, Array, ArraySize);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRequestArrayData
+ /// Templatized Function to get array data from Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [out] Array
+ /// T * - Pointer to an array of given type
+ /// \param [out] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void GetReqArrayData(UI_32 VarName, T *Array, UI_32 &ArraySize) { // NOLINT (readability/nolint)
+ GetData<T>(REQUEST_TABLE, VarName, Array, ArraySize);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRequestArrayData
+ /// Templatized Function to get array data from Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [out] Array
+ /// T * - Pointer to an array of given type
+ /// \param [out] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void GetRespArrayData(UI_32 VarName, T *Array, UI_32 &ArraySize) { // NOLINT (readability/nolint)
+ GetData<T>(RESPONSE_TABLE, VarName, Array, ArraySize);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestData
+ /// Templatized Function to set data into Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] Array
+ /// T - Data type of key
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void SetReqData(UI_32 VarName, EDataType DataType, T Array) {
+ SetData<T>(REQUEST_TABLE, VarName, DataType, &Array, 1);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestData
+ /// Templatized Function to set data into Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] Array
+ /// T - Data type of key
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ void SetRespData(UI_32 VarName, EDataType DataType, T Array) {
+ SetData<T>(RESPONSE_TABLE, VarName, DataType, &Array, 1);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRequestData
+ /// Templatized Function to get data from Resquest _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return T - value belong to type T
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ T GetReqData(UI_32 VarName) {
+ T Data;
+ UI_32 ArraySize = 0;
+ GetData<T>(REQUEST_TABLE, VarName, &Data, ArraySize);
+ return Data;
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetResponseData
+ /// Templatized Function to get data from Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return T - value belong to type T
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ template<class T>
+ T GetRespData(UI_32 VarName) {
+ T Data;
+ UI_32 ArraySize = 0;
+ GetData<T>(RESPONSE_TABLE, VarName, &Data, ArraySize);
+ return Data;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestArrayStringData
+ /// API to set array of string data into Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] DataValue
+ /// string [] - array of strings
+ /// \param [in] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ void SetReqArrayStringData(UI_32 VarName, EDataType VarType, std::string DataValue[], UI_32 size) {
+ SetArrayStringData(REQUEST_TABLE, VarName, VarType, DataValue, size);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestArrayStringData
+ /// API to set array of string data into Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] DataValue
+ /// string [] - array of strings
+ /// \param [in] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetRespArrayStringData(UI_32 VarName, EDataType VarType, std::string DataValue[], UI_32 size) {
+ SetArrayStringData(RESPONSE_TABLE, VarName, VarType, DataValue, size);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRequestArrayStringData
+ /// API to get array of string data from Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [out] DataValue
+ /// string [] - array of strings
+ /// \param [out] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ void GetReqArrayStringData(UI_32 VarName, std::string DataValue[], UI_32 &size) { // NOLINT (readability/nolint)
+ GetArrayStringData(REQUEST_TABLE, VarName, DataValue, size);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetResponseArrayStringData
+ /// API to get array of string data from Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [out] DataValue
+ /// string [] - array of strings
+ /// \param [out] ArraySize
+ /// UI_32 - No of elements of Array
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void GetRespArrayStringData(UI_32 VarName, std::string DataValue[], UI_32 &size) { // NOLINT (readability/nolint)
+ GetArrayStringData(RESPONSE_TABLE, VarName, DataValue, size);
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRequestStringData
+ /// API to set string data into Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] DataValue
+ /// string [] - array of strings
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetReqStringData(UI_32 VarName, EDataType VarType, std::string DataValue) {
+ UI_32 size = 1;
+ SetArrayStringData(REQUEST_TABLE, VarName, VarType, &DataValue, size);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetResponseStringData
+ /// API to set string data into Response _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ /// \param [in] DataType
+ /// EDataType - Data Type of key
+ /// \param [in] DataValue
+ /// string [] - array of strings
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ void SetRespStringData(UI_32 VarName, EDataType VarType, std::string DataValue) {
+ UI_32 size = 1;
+ SetArrayStringData(RESPONSE_TABLE, VarName, VarType, &DataValue, size);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRequestStringData
+ /// API to get string data from Request _CWORD77_ Data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return string - value of data
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetReqStringData(UI_32 VarName) {
+ UI_32 size = 0;
+ std::string DataValue = "";
+ GetArrayStringData(REQUEST_TABLE, VarName, &DataValue, size);
+ return DataValue;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNoofElementsFromRequestTable
+ /// API to get No of elements in a key from request data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return UI_32 - No of elements
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetReqDataSize(UI_32 Key) {
+ return GetNoofElementsofData(REQUEST_TABLE, Key);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNoofElementsFromResponseTable
+ /// API to get No of elements in a key from response data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return UI_32 - No of elements
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ UI_32 GetRespDataSize(UI_32 Key) {
+ return GetNoofElementsofData(RESPONSE_TABLE, Key);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetDataTypeFromRequestTable
+ /// API to get data type of key from request data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return EDataType - Data type of key
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+ EDataType GetReqDataType(UI_32 Key) {
+ return GetDataType(REQUEST_TABLE, Key);
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetDataTypeFromResponseTable
+ /// API to get data type of key from response data base
+ ///
+ /// \param [in] VarName
+ /// UI_32 - key
+ ///
+ /// \return EDataType - Data type of key
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EDataType GetRespDataType(UI_32 Key) {
+ return GetDataType(RESPONSE_TABLE, Key);
+ }
+};
+
+extern C_CWORD77_DataPool g__CWORD77_DataPool;
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestArrayData
+/// Templatized Function to set array data into Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] Array
+/// T * - Pointer to an array of given type
+/// \param [in] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+void SetRequestArrayData(UI_32 VarName, EDataType DataType, T *Array, UI_32 ArraySize) {
+ g__CWORD77_DataPool.SetReqArrayData(VarName, DataType, Array, ArraySize);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestArrayData
+/// Templatized Function to set array data into Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] Array
+/// T * - Pointer to an array of given type
+/// \param [in] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+void SetResponseArrayData(UI_32 VarName, EDataType DataType, T *Array, UI_32 ArraySize) {
+ g__CWORD77_DataPool.SetRespArrayData<T>(VarName, DataType, Array, ArraySize);
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequestArrayData
+/// Templatized Function to get array data from Request _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [out] Array
+/// T * - Pointer to an array of given type
+/// \param [out] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+void GetRequestArrayData(UI_32 VarName, T *Array, UI_32 &ArraySize) { // NOLINT (readability/nolint)
+ g__CWORD77_DataPool.GetReqArrayData<T>(VarName, Array, ArraySize);
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequestArrayData
+/// Templatized Function to get array data from Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [out] Array
+/// T * - Pointer to an array of given type
+/// \param [out] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+void GetResponseArrayData(UI_32 VarName, T *Array, UI_32 &ArraySize) { // NOLINT (readability/nolint)
+ g__CWORD77_DataPool.GetRespArrayData<T>(VarName, Array, ArraySize);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestData
+/// Templatized Function to set data into Request _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] Array
+/// T - Data type of key
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+void SetRequestData(UI_32 VarName, EDataType DataType, T Array) {
+ g__CWORD77_DataPool.SetReqData<T>(VarName, DataType, Array);
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestData
+/// Templatized Function to set data into Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] Array
+/// T - Data type of key
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+void SetResponseData(UI_32 VarName, EDataType DataType, T Array) {
+ g__CWORD77_DataPool.SetRespData<T>(VarName, DataType, Array);
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequestData
+/// Templatized Function to get data from Resquest _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return T - value belong to type T
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+T GetRequestData(UI_32 VarName) {
+ return g__CWORD77_DataPool.GetReqData<T>(VarName);
+}
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetResponseData
+/// Templatized Function to get data from Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return T - value belong to type T
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+template<class T>
+T GetResponseData(UI_32 VarName) {
+ return g__CWORD77_DataPool.GetRespData<T>(VarName);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestArrayStringData
+/// API to set array of string data into Request _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] DataValue
+/// string [] - array of strings
+/// \param [in] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+
+void SetRequestArrayStringData(UI_32 VarName, EDataType VarType, std::string DataValue[], UI_32 size);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestArrayStringData
+/// API to set array of string data into Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] DataValue
+/// string [] - array of strings
+/// \param [in] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void SetResponseArrayStringData(UI_32 VarName, EDataType VarType, std::string DataValue[], UI_32 size);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequestArrayStringData
+/// API to get array of string data from Request _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [out] DataValue
+/// string [] - array of strings
+/// \param [out] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+
+void GetRequestArrayStringData(UI_32 VarName, std::string DataValue[], UI_32 &size); // NOLINT (readability/nolint)
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetResponseArrayStringData
+/// API to get array of string data from Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [out] DataValue
+/// string [] - array of strings
+/// \param [out] ArraySize
+/// UI_32 - No of elements of Array
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void GetResponseArrayStringData(UI_32 VarName, std::string DataValue[], UI_32 &size); // NOLINT (readability/nolint)
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetRequestStringData
+/// API to set string data into Request _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] DataValue
+/// string [] - array of strings
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void SetRequestStringData(UI_32 VarName, EDataType VarType, std::string DataValue);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetResponseStringData
+/// API to set string data into Response _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+/// \param [in] DataType
+/// EDataType - Data Type of key
+/// \param [in] DataValue
+/// string [] - array of strings
+///
+/// \return None
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+void SetResponseStringData(UI_32 VarName, EDataType VarType, std::string DataValue);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequestStringData
+/// API to get string data from Request _CWORD77_ Data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return string - value of data
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string GetRequestStringData(UI_32 VarName);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequestDataLength
+/// API to get No of elements in a key from request data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return UI_32 - No of elements
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 GetRequestDataLength(UI_32 Key);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetResponseDataLength
+/// API to get No of elements in a key from response data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return UI_32 - No of elements
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+
+UI_32 GetResponseDataLength(UI_32 Key);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetDataTypeFromRequestTable
+/// API to get data type of key from request data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return EDataType - Data type of key
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+
+EDataType GetRequestDataType(UI_32 Key);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetDataTypeFromResponseTable
+/// API to get data type of key from response data base
+///
+/// \param [in] VarName
+/// UI_32 - key
+///
+/// \return EDataType - Data type of key
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+EDataType GetResponseDataType(UI_32 Key);
+
+
+
+class C_CWORD77_Data {
+ private:
+ T_CWORD77_DataPool m__CWORD77_RequestDataTable; ///< Request Data Table
+ T_CWORD77_DataPool m__CWORD77_ResponseDataTable; ///< Response Data Table
+
+ // Original data pool
+ // Depricated. Remove once all modules migrates to new API's for accessing data pool
+ std::map< UI_32, std::vector<CHAR> > m__CWORD77_RequestDataTableOrig; ///< Request Data Table
+ std::map< UI_32, std::vector<CHAR> > m__CWORD77_ResponseDataTableOrig; ///< Response Data Table
+
+ static C_CWORD77_Data *m_p_CWORD77_DataInstance; /// instance to C_CWORD77_Data
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// C_CWORD77_Data
+ /// Constructor for C_CWORD77_Data
+ /// \param None
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ C_CWORD77_Data();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// C_CWORD77_Data
+ /// Destructor for C_CWORD77_Data
+ /// \param None
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ ~C_CWORD77_Data();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetInstance
+ /// API to get single instance of C_CWORD77_Data
+ /// \param None
+ /// \return Pointer to single instance of C_CWORD77_Data
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static C_CWORD77_Data *GetInstance();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// DeleteInstance
+ /// API to delete single instance of C_CWORD77_DataPool
+ /// \param None
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static void DeleteInstance();
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetReqDataIn_CWORD77_DataPool
+ /// API to set data associated with request into _CWORD77_ Data Pool
+ ///
+ /// \param [in] f_DataPoolKey
+ /// _CWORD77_DataPoolKey - Data pool key
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return VOID - None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetRequData(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 f_uiSize, PVOID f_pData); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetReqDataIn_CWORD77_DataPool
+ /// API to set data associated with request into _CWORD77_ Data Pool
+ /// Depricated. Do not use.
+ ///
+ /// \param [in] f_uiMsgId
+ /// UI_32 - MsgId
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return VOID - None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetRequData(UI_32 f_uiMsgId, UI_32 f_uiSize, PVOID f_pData);
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRespDataIn_CWORD77_DataPool
+ /// API to set data associated with response into _CWORD77_ Data Pool
+ ///
+ /// \param [in] f_DataPoolKey
+ /// _CWORD77_DataPoolKey - Data pool key
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return VOID - None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetRespoData(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 f_uiSize, const PVOID f_pData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetRespDataIn_CWORD77_DataPool
+ /// API to set data associated with response into _CWORD77_ Data Pool
+ /// Depricated. Do not use.
+ ///
+ /// \param [in] f_uiMsgId
+ /// UI_32 - MsgId
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return VOID - None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetRespoData(UI_32 f_uiMsgId, UI_32 f_uiSize, const PVOID f_pData); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetReqDataIn_CWORD77_DataPool
+ /// API to get data associated with request from _CWORD77_ Data Pool
+ ///
+ /// \param [in] f_DataPoolKey
+ /// _CWORD77_DataPoolKey - Data pool key
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return EFrameworkunifiedStatus - Succes or Error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetRequData(const _CWORD77_DataPoolKey &f_DataPoolKey, UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetReqDataIn_CWORD77_DataPool
+ /// API to get data associated with request from _CWORD77_ Data Pool
+ /// Depricated. Do not use.
+ ///
+ /// \param [in] f_uiMsgId
+ /// UI_32 - MsgId
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return EFrameworkunifiedStatus - Succes or Error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetRequData(UI_32 f_uiMsgId, UI_32 &f_uiSize, PVOID &f_pData); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRespDataFrom_CWORD77_DataPool
+ /// API to get data associated with response from _CWORD77_ Data Pool
+ ///
+ /// \param [in] f_DataPoolKey
+ /// _CWORD77_DataPoolKey - Data pool key
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return EFrameworkunifiedStatus - Succes or Error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetRespoData(const _CWORD77_DataPoolKey &f_DataPoolKey, // NOLINT (readability/nolint)
+ UI_32 &f_uiSize, // NOLINT (readability/nolint)
+ PVOID &f_pData); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRespDataFrom_CWORD77_DataPool
+ /// API to get data associated with response from _CWORD77_ Data Pool
+ /// Depricated. Do not use.
+ ///
+ /// \param [in] f_uiMsgId
+ /// UI_32 - MsgId
+ /// \param [in] f_uiSize
+ /// UI_32 - size of the data
+ /// \param [in] f_pData
+ /// PVOID - void pointer to data
+ ///
+ /// \return EFrameworkunifiedStatus - Succes or Error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetRespoData(UI_32 f_uiMsgId, UI_32 &f_uiSize, PVOID &f_pData); // NOLINT (readability/nolint)
+};
+
+#endif /* _CWORD77__DATA_POOL_TABLE_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns__CWORD77__notifications.h b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__notifications.h
new file mode 100644
index 00000000..5d7e3999
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__notifications.h
@@ -0,0 +1,53 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns__CWORD77__notifications.h
+ * @brief \~english This file defines _CWORD77_ Service Availability Notification.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef NS__CWORD77__NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define NS__CWORD77__NOTIFICATIONS_H_
+
+#define NTFY_REG__CWORD77__Available "_CWORD77_/Available" ///< _CWORD77_ Service Availability Notification
+
+#endif /* NS__CWORD77__NOTIFICATIONS_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns__CWORD77__types.h b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__types.h
new file mode 100644
index 00000000..ae6ce838
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns__CWORD77__types.h
@@ -0,0 +1,68 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file
+ * @brief \~english This file contains enum of PE_CWORD77_ResponseType
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup _CWORD77_
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _NS__CWORD77__TYPES_H_ // NOLINT (build/header_guard)
+#define _NS__CWORD77__TYPES_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <sstream>
+#include <utility>
+#include <string>
+// using namespace std;
+
+typedef enum _E_CWORD77_ResponseType {
+ RESPONSE = 0,
+ NOTIFICATION,
+ EVENT
+} E_CWORD77_ResponseType, *PE_CWORD77_ResponseType;
+
+// Pair to uniquely identify protocol commands and notifications for different services
+// pair of protocol id and service name in case of protocol interfaces
+// pair of 0 and notification name in case of notifications, as notification name will always be unique
+typedef std::pair<UI_32, std::string> _CWORD77_DataPoolKey;
+
+#endif /* _NS__CWORD77__TYPES_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_buildversioncheck.hpp b/nsframework/framework_unified/client/include/native_service/ns_buildversioncheck.hpp
new file mode 100644
index 00000000..d7f702c8
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_buildversioncheck.hpp
@@ -0,0 +1,227 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_buildversioncheck.hpp
+ * @brief \~english Provide the APIs to check/get version
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_UTILITY_BUILDVERSIONCHECK_LIBRARY_INCLUDE_NATIVE_SERVICE_NS_BUILDVERSIONCHECK_HPP_ // NOLINT (build/header_guard)
+#define FRAMEWORK_UNIFIED_CLIENT_NS_UTILITY_BUILDVERSIONCHECK_LIBRARY_INCLUDE_NATIVE_SERVICE_NS_BUILDVERSIONCHECK_HPP_
+
+#include <native_service/frameworkunified_types.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+
+/**
+ * \~english the namespace frameworkunified
+ */
+namespace frameworkunified {
+/**
+ * \~english the namespace ns
+ */
+namespace ns {
+/**
+ * \~english the namespace utility
+ */
+namespace utility {
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_BuildVersionCheck
+/// \~english @par Brief
+/// Check whether the input param build_version is matched or not.
+/// \~english @param [in] build_version
+/// PCSTR - The version to be checked
+/// \~english @retval TRUE: match; FALSE: does not match
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// If the input param version string build_version is empty, the function returns FALSE. \n
+/// If the input param version string build_version is equal to the environment build version \n
+/// and library build version, the function returns TRUE.
+/// \~english @see getEnvironmentBuildVersion getLibraryBuildVersion
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL buildVersionsMatch(PCSTR build_version); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_BuildVersionCheck
+/// \~english @par Brief
+/// Get the build version from environment variable.
+/// \~english @retval the build version string
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The funcion returns the value of the system environment variable "BUILD_VERSION". If \n
+/// the environment variable does not exist, the function returns "".
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR getEnvironmentBuildVersion(); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_BuildVersionCheck
+/// \~english @par Brief
+/// Get the library build version string
+/// \~english @retval the library buidling version string
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function returns the string as macro _BUILD_VERSION.
+/// \~english @see _BUILD_VERSION
+////////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR getLibraryBuildVersion(); // NOLINT (readability/nolint)
+
+/**
+ * \~english the namespace utility_private
+ */
+namespace utility_private {
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_BuildVersionCheck
+/// \~english @par Brief
+/// Check whether the input param is empty or not.
+/// \~english @param [in] build_version
+/// PCSTR - the build version
+/// \~english @retval the input param build_version or "<Not defined>"
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// If the input param build_version is not empty, the function returns build_version, \n
+/// or the function returns "<Not defined>".
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR niceBuildVersion(PCSTR build_version); // NOLINT (readability/nolint)
+
+/**
+ * \~english the end of namespace utility_private
+ */
+}
+/**
+ * \~english the end of namespace utility
+ */
+}
+/**
+ * \~english the end of namespace ns
+ */
+}
+/**
+ * \~english the end of namespace frameworkunified
+ */
+}
+
+/**
+ * \~english define the macro _BUILD_VERSION
+ */
+#ifndef BUILD_VERSION
+#define _BUILD_VERSION ""
+#else
+#define QUOTE( ___str___ ) #___str___
+#define EXPAND_AND_QUOTE( ___str___ ) QUOTE( ___str___ )
+#define _BUILD_VERSION EXPAND_AND_QUOTE( BUILD_VERSION )
+#endif
+
+/**
+ * \~english define the macro WARNING_STRING to print the warning
+ */
+#define WARNING_STRING "\n\
+!!! WARNING - Build Versions do not match !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\
+project build: %s\n\
+library build: %s\n\
+environment build: %s\n\
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+
+/**
+ * \~english define the macro _BUILD_VERSION
+ */
+#if defined STDOUT_LOGGING
+#include <cstdio>
+#define BUILDVERSIONLOG( ___log_string___, ...) std::printf( ___log_string___ "\n", __VA_ARGS__)
+#define BUILDVERSION_NULL_STATEMENT (0)
+#elif defined NO_LOGGING
+#define BUILDVERSIONLOG(...) ((void)0)
+#define BUILDVERSION_NULL_STATEMENT ((void)0)
+#else
+#include <native_service/ns_logger_if.h>
+#define BUILDVERSIONLOG( ___log_string___, ...) TEXT( __PRETTY_FUNCTION__, ___log_string___, __VA_ARGS__)
+/**
+ * \~english define the macro BUILDVERSION_NULL_STATEMENT
+ */
+#define BUILDVERSION_NULL_STATEMENT ((void)0)
+#endif
+
+/**
+ * \~english define the macro CHECK_BUILD_VERSION to check the version
+ */
+#define CHECK_BUILD_VERSION() \
+ (!framework_unified::ns::utility::buildVersionsMatch( _BUILD_VERSION )) ? \
+ BUILDVERSIONLOG( WARNING_STRING, \
+ framework_unified::ns::utility::utility_private::niceBuildVersion( _BUILD_VERSION ), \
+ framework_unified::ns::utility::utility_private::niceBuildVersion( framework_unified::ns::utility::getLibraryBuildVersion() ), \
+ framework_unified::ns::utility::utility_private::niceBuildVersion( framework_unified::ns::utility::getEnvironmentBuildVersion() ) ) :\
+ BUILDVERSION_NULL_STATEMENT
+
+/** @}*/ // end of framework_unified
+
+/** @}*/ // end of native_service
+
+/** @}*/ // end of BaseSystem
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_UTILITY_BUILDVERSIONCHECK_LIBRARY_INCLUDE_NATIVE_SERVICE_NS_BUILDVERSIONCHECK_HPP_ // NOLINT (build/header_guard)
diff --git a/nsframework/framework_unified/client/include/native_service/ns_config_parser_if.h b/nsframework/framework_unified/client/include/native_service/ns_config_parser_if.h
new file mode 100644
index 00000000..b40c01eb
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_config_parser_if.h
@@ -0,0 +1,1038 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_config_parser_if.h
+ * @brief \~english This file contains declaration of class CNSConfigReader, CNSConfigWriter and CNSConfigParser. -- API
+ * define head file
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup Native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef NS_NATIVESERVICES_INC_NATIVE_NS_CONFIG_PARSER_IF_H_ // NOLINT (build/header_guard)
+#define NS_NATIVESERVICES_INC_NATIVE_NS_CONFIG_PARSER_IF_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+// forward declaration of classes
+class IConfigReader;
+class IConfigWriter;
+
+/**
+ * @class CNSConfigReader
+ * @brief \~english Configuration File Read Service Class
+ * @par \~english Brief Introduction
+ * \~english This class provides API's to application to read from configuration files.
+ *
+ */
+class CNSConfigReader {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSConfigReader
+ /// \~english @par Brief
+ /// Constructor of CNSConfigReader class
+ /// This constructor can only be called by derived class. Application cannot use this constructor
+ /// to create object of CNSConfigReader class.
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// It is called when generating the instance of CNSConfigParser class.
+ /// \~english @see CNSConfigReader::~CNSConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSConfigReader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSConfigReader
+ /// \~english @par Brief
+ /// Constructor of CNSConfigReader class
+ /// This is depricated. Use parameterless constructor instead to create object and
+ /// Parse(filepath) to parse the file using reader object.
+ /// \~english @param [in] f_c_filepath
+ /// const std::string& - Name of the configuration file
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// It doesn't need to call Parse() function to execute parse process of configuration file,
+ /// when using the constructor with file path. However, because we don't execute error process,
+ /// if it needs to reply error about parse process, we must to use the constructor without parameter
+ /// and call Parse() function.
+ /// \~english @see CNSConfigReader::~CNSConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CNSConfigReader(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Parse
+ /// \~english @par Brief
+ /// This function is used to parse configuration file
+ /// \~english @param [in] f_c_filepath
+ /// const std::string& - Name of the configuration file
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - if memory allocation failed or document is not proper
+ /// \~english @retval eFrameworkunifiedStatusFail - invalid file type
+ /// \~english @retval eFrameworkunifiedStatusInvldParam invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusErrOther - file data error
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File(f_c_filepath) designated by parameter is not proper [eFrameworkunifiedStatusNullPointer]
+ /// - Data of file(f_c_filepath) designated by parameter is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Expansion name of file(f_c_filepath) designated by parameter is not cfg [eFrameworkunifiedStatusFail]
+ /// - Failed to open file(f_c_filepath) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Path of file designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Data of file designated by parameter has error [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Parse designated configuration file. If the data format is correct, get memory to store the parsed result,
+ /// and store the parsed contents in it.
+ /// \~english @see CNSConfigWriter::Parse, CNSConfigParser::Parse
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Parse(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CNSConfigReader
+ /// \~english @par Brief
+ /// Destructor of CNSConfigReader class.
+ /// It is used when release the instance.
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Release the used memory and the parsed result of configuration file.
+ /// \~english @see CNSConfigReader::CNSConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSConfigReader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetBool
+ /// \~english @par Brief
+ /// This function is used to get the bool value associated with key.
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// This API has been depricated, use GetBool(key, ref_value)
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @retval TRUE - value associated with key
+ /// \~english @retval FALSE - Failed to get value associated with key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [FALSE]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [FALSE]
+ /// - Can not find search key(f_c_key) designated by parameter [FALSE]
+ /// - Value getted from configuration file is not true or false [FALSE]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(TRUE/FALSE) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// This API has been depricated, please use GetBool(const std::string& f_c_key, BOOL& f_bValue).
+ /// \~english @see CNSConfigWriter::SetBool
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL GetBool(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetDouble
+ /// \~english @par Brief
+ /// This function is used to get the double value associated with key.
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// This API has been depricated, use GetDouble(key, ref_value)
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @param [out] - none
+ /// \~english @retval F_64 - value associated with key
+ /// \~english @retval 0 - Failed to get value associated with key(64bit)
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [0]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [0]
+ /// - Can not find search key(f_c_key) designated by parameter [0]
+ /// - Failed to change data getted from configuration file from string type to double type [0]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - We can take the value in specification only if it is in the range of
+ /// [1.17549435082228750797e-38F, 3.40282346638528859812e+38F](min value of double, max value of double).
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(64bit) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// This API has been depricated, please use GetDouble(const std::string& f_c_key, F_64& f_f_value).
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ F_64 GetDouble(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetFloat
+ /// \~english @par Brief
+ /// This function is used to get the float value associated with key
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// This API has been depricated, use GetFloat(key, ref_value)
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @retval F_32 value associated with key
+ /// \~english @retval 0 - Failed to get value associated with key(32bit)
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [0]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [0]
+ /// - Can not find search key(f_c_key) designated by parameter [0]
+ /// - Can not change the data string, because that data string getted
+ /// from configuration file is over range [9.8765436e+12]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(32bit) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// This API has been depricated, please use GetFloat(const std::string& f_c_key, F_32& f_f_value).
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ F_32 GetFloat(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetInt
+ /// \~english @par Brief
+ /// This function is used to get the integer value associated with key
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// This API has been depricated, use GetInt(key, ref_value)
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @retval SI_32 - value associated with key
+ /// \~english @retval 0.0f - Failed to get value associated with key(32bit)
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [0]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [0]
+ /// - Can not find search key(f_c_key) designated by parameter [0]
+ /// - Failed to change data getted from Configuration file from string type to Int type [0]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(32bit) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// This API has been depricated, please use GetInt(const std::string& f_c_key, SI_32& f_si_value).
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - If data string getted from file is larger than INT_MAX(2147483648), return -1.
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 GetInt(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetString
+ /// \~english @par Brief
+ /// This function is used to get the string value associated with key
+ /// If there are multiple values associated with the same key, all the values separated by
+ /// delimiter "\n" are returned.
+ /// This API has been depricated, use GetString(key, ref_value)
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @retval std::string value(string) associated with key
+ /// \~english @retval nullbuffer - Failed to get value associated with key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [null buffer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [null buffer]
+ /// - Can not find search key(f_c_key) designated by parameter [null buffer]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(string) associated with key.
+ /// If there are multiple values associated with the same key,
+ /// return all the values separated by delimiter "\n".
+ /// This API has been depricated, please use GetString(
+ /// const std::string& f_c_key, std::string& f_cValue).
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetString(const std::string &f_c_key);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetBool
+ /// \~english @par Brief
+ /// This function is used to get the bool value associated with key
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key string
+ /// \~english @param [in] f_b_value
+ /// BOOL& - value associated with key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @retval eFrameworkunifiedStatusErrOther - value is not bool type
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Value getted from configuration file is not true or false [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(TRUE/FALSE) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// \~english @see CNSConfigWriter::SetBool
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetBool(const std::string &f_c_key, BOOL &f_b_value); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetDouble
+ /// \~english @par Brief
+ /// This function is used to get the double value associated with key.
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @param [in] f_f_value
+ /// F_64& - value associated with key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @retval eFrameworkunifiedStatusInvldBuf - change error
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Changed result of data string getted from configuration file is overflow or underflow [eFrameworkunifiedStatusInvldBuf]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - Return eFrameworkunifiedStatusOK if we didn't excute the changing operation
+ /// - We can take the value in specification only if it is in the range of
+ /// [1.17549435082228750797e-38F, 3.40282346638528859812e+38F](min value of double, max value of double).
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(64bit) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetDouble(const std::string &f_c_key, F_64 &f_f_value); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetFloat
+ /// \~english @par Brief
+ /// This function is used to get the float value associated with key
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @param [in] f_f_value
+ /// F_32& - value associated with key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @retval eFrameworkunifiedStatusInvldBuf - change error
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Can not change the data string, because that data string getted
+ /// from configuration file is over range [9.8765436e+12]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(32bit) associated with key.
+ /// If there are multiple values associated with the same key, return the first value.
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetFloat(const std::string &f_c_key, F_32 &f_f_value); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetInt
+ /// \~english @par Brief
+ /// This function is used to get the integer value associated with key
+ /// If there are multiple values associated with the same key, then the first value is returned.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @param [out] f_si_value
+ /// SI_32& - value associated with key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @retval eFrameworkunifiedStatusInvldBuf - change error
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Failed to change data getted from Configuration file from string type to Int type [eFrameworkunifiedStatusInvldBuf]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(32bit) associated with key.
+ /// If there are multiple values associated with the same key, return all the values separated by delimiter "\n".
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetInt(const std::string &f_c_key, SI_32 &f_si_value); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetString
+ /// \~english @par Brief
+ /// This function is used to get the string value associated with key
+ /// If there are multiple values associated with the same key, all the values separated by
+ /// delimiter "\n" are returned.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key to search
+ /// \~english @param [in] f_c_value
+ /// std::string& - value(string) associated with key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigReader
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(string) associated with key.
+ /// If there are multiple values associated with the same key,
+ /// return all the values separated by delimiter "\n".
+ /// \~english @see CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetString(const std::string &f_c_key, std::string &f_c_value); // NOLINT (readability/nolint)
+
+ protected:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetDataPtr
+ /// This function is used to get the data pointer. This pointer is then set in config writer.
+ /// This is needed to avoid recreation of same data structure object in both reader and writer
+ /// when we create object of NSConfigParser.
+ ///
+ /// \return PVOID - pointer of data structure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ PVOID GetDataPtr();
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FormatValue
+ /// This function is used to remove the line feed or carriage return from string
+ ///
+ /// \param [in] f_cValue
+ /// std::string - value
+ ///
+ /// \return std::string - formated data
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string FormatValue(const std::string &f_c_value);
+
+ // config reader pointer
+ IConfigReader *m_pReader;
+ static HANDLE m_hNSXMLLibHandle; // NOLINT (readability/nolint)
+};
+
+
+/**
+ * @class CNSConfigWriter
+ * @brief \~english File Write Service Class
+ * @par \~english Brief Introduction
+ * \~english This class provides API's to application to write to configuration files.
+ *
+ */
+class CNSConfigWriter {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSConfigWriter
+ /// \~english @par Brief
+ /// Constructor of CNSConfigWriter class
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// It is called when generating the instance of CNSConfigWriter class.
+ /// \~english @see CNSConfigWriter::~CNSConfigWriter
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSConfigWriter();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSConfigWriter
+ /// \~english @par Brief
+ /// Constructor of CNSConfigWriter class
+ /// This is depricated. Use parameterless constructor instead to create object and
+ /// Parse(filepath) to parse the file using writer object.
+ /// \~english @param [in] f_c_filepath
+ /// const std::string& - Full path of the configuration file
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// It doesn't need to call Parse() function to execute parse process of configuration File,
+ /// when using the constructor with file path. However, because we don't execute error process,
+ /// if it needs to reply error about parse process, we must to use the constructor without parameter
+ /// and call Parse() function.
+ /// \~english @see CNSConfigWriter::~CNSConfigWriter
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CNSConfigWriter(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CNSConfigWriter
+ /// \~english @par Brief
+ /// Destructor of CNSConfigWriter class
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Release the used memory and the parsed result of Configuration File.
+ /// \~english @see CNSConfigWriter::CNSConfigWriter
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSConfigWriter();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Parse
+ /// \~english @par Brief
+ /// This function is used to parse the configuration file
+ /// \~english @param [in] f_c_filepath
+ /// const std::string& - Name of the configuration file
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - if memory allocation failed or document not proper
+ /// \~english @retval eFrameworkunifiedStatusFail - invalid file type
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusErrOther - file data error
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File(f_c_filepath) designated by parameter is not proper [eFrameworkunifiedStatusNullPointer]
+ /// - Data of file(f_c_filepath) designated by parameter is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Expansion name of file(f_c_filepath) designated by parameter is not cfg [eFrameworkunifiedStatusFail]
+ /// - Failed to open file(f_c_filepath) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Path of file designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Data of file designated by parameter has error [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Parse designated configuration file. If the data format is correct, get memory to store the parsed result,
+ /// and store the parsed contents in it.
+ /// \~english @see CNSConfigParser::Parse, CNSConfigWriter::Parse
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Parse(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Save
+ /// \~english @par Brief
+ /// This function is used to save the configuration settings to config file
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusFail - file access fail
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - File doesn't exit [eFrameworkunifiedStatusFail]
+ /// - File access error [eFrameworkunifiedStatusFail]
+ /// - Can't open file [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Save the data stored in memory to configuration file.
+ /// \~english @see CNSConfigWriter::SetBool, CNSConfigWriter::Set
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Save();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetBool
+ /// \~english @par Brief
+ /// This function is used to set the bool value corresponding to key
+ /// This function is not overloaded with other Set() API's of this class because
+ /// BOOL is typedef of UI_32 so when we pass integer or BOOL to Set API it would have
+ /// called the same API.
+ /// If multiple identical keys are found it sets the value for all the keys.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key
+ /// \~english @param [in] f_b_value
+ /// BOOL - bool value to set for key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @retval eFrameworkunifiedStatusErrOther - if passsed value is invalid
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Data(f_bValue) of search key designated by parameter is not bool [eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - Valid condition of search key string: there is no separator and line feed in config tag
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set the value(bool type) associated with key to data stored in memory.
+ /// If there are multiple keys, set the values associated with all keys.
+ /// \~english @see CNSConfigReader::GetBool
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetBool(const std::string &f_c_key, BOOL f_b_value);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Set
+ /// \~english @par Brief
+ /// This function is used to set the double value corresponding to key.
+ /// If multiple identical keys are found it sets the value for all the keys.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key
+ /// \~english @param [in] f_f_value
+ /// F_64 - double value to set for key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - We can take the value in specification only if it is in the range of
+ /// [2.22507385850720138309e-308L, 1.7976931348623157e+308L](min value of double, max value of double).
+ /// - Valid condition of search key string: there is no separator and line feed in config tag
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set the bool type value(64bit) associated with key to data stored in memory.
+ /// If there are multiple keys, set the values associated with all keys.
+ /// \~english @see CNSConfigReader::GetDouble
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Set(const std::string &f_c_key, F_64 f_f_value);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Set
+ /// \~english @par Brief
+ /// This function is used to set the float value corresponding to key.
+ /// If multiple identical keys are found it sets the value for all the keys.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key
+ /// \~english @param [in] f_f_value
+ /// F_32 - float value to set for key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - We can take the value in specification only if it is in the range of
+ /// [1.17549435082228750797e-38F, 3.40282346638528859812e+38F](min value of double, max value of double).
+ /// - Valid condition of search key string: there is no separator and line feed in config tag
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set the float type value(32bit) associated with key to data stored in memory.
+ /// If there are multiple keys, set the values associated with all keys.
+ /// \~english @see CNSConfigReader::GetFloat
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Set(const std::string &f_c_key, F_32 f_f_value);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Set
+ /// \~english @par Brief
+ /// This function is used to set the integer value corresponding to key.
+ /// If multiple identical keys are found it sets the value for all the keys.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key
+ /// \~english @param [in] f_si_value
+ /// SI_32 - integer value to set for key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - Valid condition of search key string: there is no separator and line feed in config tag
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set the int type value(32bit) associated with key to data stored in memory.
+ /// If there are multiple keys, set the values associated with all keys.
+ /// \~english @see CNSConfigReader::GetInt
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Set(const std::string &f_c_key, SI_32 f_si_value);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Set
+ /// \~english @par Brief
+ /// This function is used to set the string value corresponding to key.
+ /// If multiple identical keys are found it sets the value for all the keys.
+ /// \~english @param [in] f_c_key
+ /// const std::string& - key
+ /// \~english @param [in] f_s_value
+ /// const std::string& - string value to set for key
+ /// \~english @retval eFrameworkunifiedStatusOK - success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - memory allocation failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - can not find key
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigWriter
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File data is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Data of search key(f_c_key) designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Can not find search key(f_c_key) designated by parameter [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par
+ /// Please pay attention to the following points when you use this API.\n
+ /// - Valid condition of search key string: there is no separator and line feed in config tag
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set the string type value associated with key to data stored in memory.
+ /// If there are multiple keys, set the values associated with all keys.
+ /// \~english @see CNSConfigReader::GetString
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Set(const std::string &f_c_key, const std::string &f_s_value);
+
+ protected:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNSConfigWriter
+ /// Constructor of CNSConfigWriter class
+ ///
+ /// \param [in] f_c_filepath
+ /// const std::string& - Full path of the configuration file
+ /// \param [in] f_b_noload
+ /// BOOL - load writer with no data
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSConfigWriter(const std::string &f_c_filepath, BOOL f_b_noload);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetDataPtr
+ /// This function is used to set the data pointer in writer class with data pointer
+ /// created in config reader class.
+ /// This is needed to avoid recreation of same data structure object in both reader and writer
+ /// when we create object of NSConfigParser
+ ///
+ /// \param [in] f_p_data
+ /// PVOID - Pointer to data structure
+ ///
+ /// \return VOID
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetDataPtr(PVOID f_p_data);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Create
+ /// This function is used to create config object
+ ///
+ /// \param [in] f_c_filepath
+ /// const std::string& - Name of the configuration file
+ ///
+ /// \return EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Create(const std::string &f_c_filepath);
+
+ private:
+ // config writer pointer
+ IConfigWriter *m_pWriter;
+ static HANDLE m_hNSXMLLibHandle; // NOLINT (readability/nolint)
+};
+
+
+/**
+ * @class CNSConfigParser
+ * @brief \~english File both Reade and Write Service Class
+ * @par \~english Brief Introduction
+ * \~english This class provides API's to application for both reading and writing into configuration files.
+ *
+ */
+class CNSConfigParser: public CNSConfigReader, public CNSConfigWriter {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSConfigParser
+ /// \~english @par Brief
+ /// Constructor of CNSConfigParser class
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// It is called when generating the instance of CNSConfigParser class.
+ /// \~english @see CNSConfigParser::~CNSConfigParser
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSConfigParser();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSConfigParser
+ /// \~english @par Brief
+ /// Constructor of CNSConfigParser class
+ /// This is depricated. Use parameterless constructor instead to create object and
+ /// Parse(filepath) to parse the file using parser object.
+ /// \~english @param [in] f_c_filepath
+ /// const std::string& - Full path of the configuration file
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// It doesn't need to call Parse() function to execute parse process of configuration File,
+ /// when using the constructor with file path. However, because we don't execute error process,
+ /// if it needs to reply error about parse process, we must to use the constructor without parameter
+ /// and call Parse() function.
+ /// \~english @see CNSConfigParser::~CNSConfigParser
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CNSConfigParser(const std::string &f_c_filepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CNSConfigParser
+ /// \~english @par Brief
+ /// Destructor of CNSConfigParser class
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigParser
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Release the used memory and the parsed result of Configuration File.
+ /// \~english @see CNSConfigParser::CNSConfigParser
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSConfigParser();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Parse
+ /// \~english @par Brief
+ /// This function is used to create config reader object and config writer object
+ /// which then parses the configuration file.
+ /// \~english @param [in] f_c_filepath
+ /// const std::string& - Name of the configuration file
+ /// \~english @retval eFrameworkunifiedStatusOK on success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer - if memory allocation failed or document not proper
+ /// \~english @retval eFrameworkunifiedStatusFail - invalid file type
+ /// \~english @retval eFrameworkunifiedStatusInvldParam invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusErrOther file data error
+ /// \~english @par Prerequisite
+ /// - Call the construct of CNSConfigParser
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Memory allocation failed [eFrameworkunifiedStatusNullPointer]
+ /// - File(f_c_filepath) designated by parameter is not proper [eFrameworkunifiedStatusNullPointer]
+ /// - Data of file(f_c_filepath) designated by parameter is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Expansion name of file(f_c_filepath) designated by parameter is not cfg [eFrameworkunifiedStatusFail]
+ /// - Failed to open file(f_c_filepath) designated by parameter [eFrameworkunifiedStatusFail]
+ /// - Path of file designated by parameter is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Data of file designated by parameter has error [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Parse designated configuration file. If the data format is correct, get memory to store the parsed result,
+ /// and store the parsed contents in it.
+ /// \~english @see CNSConfigReader::Parse, CNSConfigWriter::Parse
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Parse(const std::string &f_c_filepath);
+};
+
+#endif // NS_NATIVESERVICES_INC_NATIVE_NS_CONFIG_PARSER_IF_H_ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_endianess.h b/nsframework/framework_unified/client/include/native_service/ns_endianess.h
new file mode 100644
index 00000000..33fa8582
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_endianess.h
@@ -0,0 +1,192 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_endianess.h
+ * @brief \~english Provide api for convert value
+ */
+
+#ifndef NS_NATIVESERVICES_INC_UTILITY_NS_ENDIANESS_H_ // NOLINT (build/header_guard)
+#define NS_NATIVESERVICES_INC_UTILITY_NS_ENDIANESS_H_
+
+#include <native_service/frameworkunified_types.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup utility
+ * @ingroup framework_unified
+ * @{
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Convert the UI_16(unsigned 16bit) value to big-endian.
+/// \~english @param [in] f_value
+/// UI_16 - The value to be converted
+/// \~english @retval the big-endian value of the input param f_value
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function converts the UI_16(unsigned 16bit) value to big-endian.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+UI_16 ConvertEndian_UI16(UI_16 f_value); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Convert the SI_16(signed 16bit) value to big-endian.
+/// \~english @param [in] f_value
+/// SI_16 - The value to be converted
+/// \~english @retval the big-endian value of the input param f_value
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function converts the SI_16(signed 16bit) value to big-endian.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_16 ConvertEndian_SI16(SI_16 f_value); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Convert the UI_32(unsigned 32bit) value to big-endian.
+/// \~english @param [in] f_value
+/// UI_32 - The value to be converted
+/// \~english @retval the big-endian value of the input param f_value
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function convers the UI_32(unsigned 32bit) value to big-endian.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 ConvertEndian_UI32(UI_32 f_value); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Convert the SI_32(signed 32bit) value to big-endian.
+/// \~english @param [in] f_value
+/// SI_32 - The value to be converted
+/// \~english @retval the big-endian value of the input param f_value
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function convers the SI_32(signed 32bit) value to big-endian.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 ConvertEndian_SI32(SI_32 f_value); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Convert the UI_64(unsigned 64bit) value to big-endian.
+/// \~english @param [in] f_value
+/// UI_64 - The value to be converted
+/// \~english @retval the big-endian value of the input param f_value
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function convers the UI_64(unsigned 64bit) value to big-endian.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+UI_64 ConvertEndian_UI64(UI_64 f_value); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Convert the SI_64(signed 64bit) value to big-endian.
+/// \~english @param [in] f_value
+/// SI_64 - The value to be converted
+/// \~english @retval the big-endian value of the input param f_value
+///
+/// \~english @par Prerequisite
+/// - NULL
+/// \~english @par Change of internal state
+/// - NULL
+/// \~english @par Conditions of processing failure
+/// - NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function convers the SI_64(signed 64bit) value to big-endian.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_64 ConvertEndian_SI64(SI_64 f_value); // NOLINT (readability/nolint)
+
+#endif // NS_NATIVESERVICES_INC_UTILITY_NS_ENDIANESS_H_ // NOLINT (build/header_guard)
+
+/** @}*/ // end of utility
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_eventlogger.h b/nsframework/framework_unified/client/include/native_service/ns_eventlogger.h
new file mode 100644
index 00000000..ab96e115
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_eventlogger.h
@@ -0,0 +1,103 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief structures used by ns_logger.cpp for event and counter logging
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief \~english structures used by ns_logger.cpp for event and counter logging
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup Native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_EVENTLOGGER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_EVENTLOGGER_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// event log messageQ name
+#define EVENTLOG_MSGQ_NAME "/EvntLogQue"
+
+typedef enum _Datatype_ {
+ COMMON,
+ EVENT_SPECIFIC
+} Datatype;
+
+typedef enum _SystemPhase_ {
+ STARTUP = 0x21,
+ NORMAL = 0x22,
+ SHUTDOWN = 0x23,
+} SystemPhase;
+
+typedef enum _NStoSS_LOGGERSERVICEPROTOCOL {
+ SS_MSG_EVTLOG = 6463, // NS to Event Logger Thread
+ SS_MSG_LOGGERCNT, // NS to Event logger Thread
+ SS_MSG_LOGGER_CNT_EVTLOG // NS to event logger thread
+} NStoSS_loggerserviceprotocol;
+
+// Note: Don't remove #paragma pack(1) this is required for the
+// ARM processor, forces data structures to be on a byte boundary
+// all messages should be place in between #pragma pack(1) and #pragma pack()
+#pragma pack(1)
+typedef struct _stLogEvent_ {
+ UI_32 ts;
+ UI_8 grp_ID;
+ UI_8 event_id;
+ UI_8 data[4];
+ SystemPhase phase;
+ UI_16 cnt_ID;
+ Datatype typeofdata;
+} st_LogEvent;
+#pragma pack(0)
+
+#pragma pack(1)
+typedef struct _stLogCount_ {
+ SystemPhase phase;
+ UI_16 cnt_id;
+} st_LogCount;
+#pragma pack(0)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NATIVESERVICES_EVENTLOGGER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_logger_if.h b/nsframework/framework_unified/client/include/native_service/ns_logger_if.h
new file mode 100644
index 00000000..a1ca9ef7
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_logger_if.h
@@ -0,0 +1,1646 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \file
+/// Declares the external APIs to Logger.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief \~english Declares the external APIs to Logger.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup Native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_LOGGER_IF_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_LOGGER_IF_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FRAMEWORKUNIFIEDLOG_MSGQ_NAME "/NSLog"
+#define FRAMEWORKUNIFIEDLOG_SHAREDMEM_NAME "/frameworkunified_debug.log.1"
+#define FRAMEWORKUNIFIEDLOG_SHAREDMEM_SIZE 5242880 // 5MB
+
+#define MASTER_ZONE_COUNT 16U
+
+#include <native_service/loglibrarylog_if.h>
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief typedef of ZONE
+///////////////////////////////////////////////////////////////////////////////
+typedef UI_32 TFrameworkunifiedZone;
+// Note: if the BITS_IN_TZONE macro is getting modified do the corresponding changes
+// in GET_ZONE_INDEX and GET_ZONE_BIT_MASK
+#define BITS_IN_BYTE (8U)
+#define BITS_IN_TZONE ((UI_32 )(sizeof( TFrameworkunifiedZone ) * BITS_IN_BYTE))
+#define TZONE_COUNT ((UI_32)MASTER_ZONE_COUNT)
+#define BITS_IN_ZONE_MASK ((UI_32)(BITS_IN_TZONE * TZONE_COUNT))
+#define DEBUG_ZONE_COUNT BITS_IN_ZONE_MASK
+
+#define ZONE_MASK_ARRAY_ELTS ((UI_32)TZONE_COUNT)
+
+#define USER_ZONES_COUNT BITS_IN_ZONE_MASK -10
+
+#define ZONE_TEXT_SIZE 24
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief Array of mask options
+///////////////////////////////////////////////////////////////////////////////
+typedef TFrameworkunifiedZone TFrameworkunifiedZoneMask[ZONE_MASK_ARRAY_ELTS];
+
+typedef enum _TFrameworkunifiedLoggerSeverity {
+ FRAMEWORKUNIFIED_SEVERITY_LOW = 0x0, /// <all enable(default)
+ FRAMEWORKUNIFIED_SEVERITY_DEBUG2, /// <enable FRAMEWORKUNIFIEDLOG_DEBUG() and FRAMEWORKUNIFIEDLOG_DEBUG2() and all the follows
+ FRAMEWORKUNIFIED_SEVERITY_DEBUG1, /// <enable FRAMEWORKUNIFIEDLOG_DEBUG1() and all the follows
+ FRAMEWORKUNIFIED_SEVERITY_INFO, /// <enable FRAMEWORKUNIFIEDLOG_INFO() and all the follows
+ FRAMEWORKUNIFIED_SEVERITY_WARN, /// <enable FRAMEWORKUNIFIEDLOG_WARN() and all the follows
+ FRAMEWORKUNIFIED_SEVERITY_ERROR, /// <enable FRAMEWORKUNIFIEDLOG_ERROR() and all the follows
+ FRAMEWORKUNIFIED_SEVERITY_FATAL, /// <enable FRAMEWORKUNIFIEDLOG_FATAL() and FRAMEWORKUNIFIEDLOG_ALWAYS()
+ FRAMEWORKUNIFIED_SEVERITY_ALWAYS /// <enable FRAMEWORKUNIFIEDLOG_ALWAYS()
+} TFrameworkunifiedLoggerSeverity;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG parameter
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _FRAMEWORKUNIFIEDLOGPARAM {
+ UI_8 uiLogOptions; /// <output options (ref. NS_LoggingMethod_t )
+ CHAR cZones[USER_ZONES_COUNT][ZONE_TEXT_SIZE]; /// <mask text ZONE_TEXT_10 ... ZONE_TEXT_n
+ TFrameworkunifiedZoneMask uiZoneMask; /// <mask options ZONEMASK(10)...ZONEMASK(n) (ref. TFrameworkunifiedZone)
+ TFrameworkunifiedLoggerSeverity eSeverity; /// <severity level(ref. TFrameworkunifiedLoggerSeverity)
+} FRAMEWORKUNIFIEDLOGPARAM, *LPFRAMEWORKUNIFIEDLOGPARAM;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG output direction
+/// \note LMSGQ and LSLOGGER are disabled
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _NS_LOGGER_METHODS {
+ LPRINT = 0x01, /// <Print to the console(similar to printf)
+ LMSGQ = 0x02, /// <Disabled
+ LSLOGGER = 0x04, /// <Disabled
+ LSHAREDMEM = 0x08 /// <Output to shared memory. this is the default logging method.
+} NS_LoggingMethod_t;
+// Note: Don't remove #paragma pack(1) this is required for the
+// ARM processor, forces data structures to be on a byte boundary
+// all messages should be place in between #pragma pack(1) and #pragma pack()
+#pragma pack(1) // *** DO NOT REMOVE ***
+
+typedef struct tag_Change_Log_Parameters {
+ TFrameworkunifiedZoneMask uiZoneMask;
+ UI_8 uiLogOptions;
+ TFrameworkunifiedLoggerSeverity eSeverity;
+} CHANGELOGPARAMS;
+
+#pragma pack(0) // *** DO NOT REMOVE ***
+
+// RCS related
+#define NS_RCS_LOGGER_PLUGIN_Q "/NsRcsLoggerPlugin"
+
+typedef enum _NS_RCS_LOGGER_SETTINGS {
+ NS_RCS_LOGGER_PLUGIN_ADD_APPNAME = 0x500,
+} NS_RCS_LOGGER_SETTINGS;
+
+typedef struct _TNS_EnableRcsLogging {
+ CHAR m_cAppName[MAX_NAME_SIZE_APP];
+ BOOL m_bEnable;
+} TNS_EnableRcsLogging;
+
+// End RCS related
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLog
+/// \~english @par Brief
+/// Writes a log to the Native Services logging mechanism
+/// \~english @param [in] p_lLine_i
+/// const UI_16 - Line number(0 to 65535) that this log was was written on
+/// \~english @param [in] f_uiZoneIndex
+/// const UI_64 - Mask value(0 to 511) to check against
+/// \~english @param [in] p_pstrClassName_i
+/// PCSTR - Name of the class or method where the log was written
+/// \~english @param [in] lpszFormat
+/// PCSTR - string similar to that of a printf statement
+/// \~english @param [in] arg list
+/// ... - Data arguments(option)
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// FRAMEWORKUNIFIEDLOG parameter is set throuth NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// - Real-time log output switch can be turn on by NsLogSetRealtimeLog() generally.
+/// But in case of FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE real-time log and/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog /will not print out
+/// \~~english @par
+/// - in the following conditions,real-time log will not print out:
+/// - log output way is LPRINT but f_uiZoneIndex parameter is in [96 to 127]
+/// - log output way is LPRINT but real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB and mq_open system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB and mq_send system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and socket system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and setsockopt system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and bind system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and inet_addr system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and sendto system call failed(retry 5 times)
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE
+/// \~english @par
+/// in the following conditions /ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/ log can not be print out
+/// - log file for parameter f_uiZoneIndex and
+/// log file for parameter FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter can not be found
+/// - the ring_buffer of log file(log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter when
+/// log file is not exited) for parameter f_uiZoneIndex is not opened (CNSRingBuffer::IsOpen())
+/// - the write-in operation to ring_buffer of log file for parameter f_uiZoneIndex
+/// (log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter when file is not exited) is failed
+/// \~english @par Detail
+/// Writes a log to the Native Services logging mechanism
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLog(const UI_16 p_lLine_i, // Line number where message was generated
+ const UI_16 f_uiZoneIndex,
+ PCSTR p_pstrClassName_i,
+ PCSTR lpszFormat,
+ ...)
+#ifdef __GNUC__
+__attribute__((format(printf, 4, 5)))
+#endif
+; // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLog0
+/// \~english @par Brief
+/// Writes a log to the Native Services logging mechanism
+/// \~english @param [in] p_lLine_i
+/// const UI_16 - Line number(0 to 65535) that this log was was written on
+/// \~english @param [in] f_uiZoneIndex
+/// const UI_64 - Mask value(0 to 511) to check against
+/// \~english @param [in] p_pstrClassName_i
+/// PCSTR - Name of the class or method where the log was written
+/// \~english @param [in] lpszFormat
+/// PCSTR - string similar to that of a printf statement
+/// \~english @param [in] arg list
+/// ... - Data arguments(option)
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// FRAMEWORKUNIFIEDLOG parameter is set throuth NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// - Real-time log output switch can be turn on by NsLogSetRealtimeLog() generally.
+/// But in case of FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE real-time log and/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog /will not print out
+/// \~~english @par
+/// - in the following conditions,real-time log will not print out:
+/// - log output way is LPRINT but f_uiZoneIndex parameter is in [96 to 127]
+/// - log output way is LPRINT but real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB and mq_open system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB and mq_send system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and socket system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and setsockopt system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and bind system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and inet_addr system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and sendto system call failed(retry 5 times)
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE
+/// \~english @par
+/// in the following conditions /ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/ log can not be print out
+/// - log file for parameter f_uiZoneIndex and
+/// log file for parameter FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter can not be found
+/// - the ring_buffer of log file(log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter when
+/// log file is not exited) for parameter f_uiZoneIndex is not opened (CNSRingBuffer::IsOpen())
+/// - the write-in operation to ring_buffer of log file for parameter f_uiZoneIndex
+/// (log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter when file is not exited) is failed
+/// \~english @par Detail
+/// Writes a log to the Native Services logging mechanism
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLog0(const UI_16 p_lLine_i, // Line number where message was generated
+ const UI_16 f_uiZoneIndex,
+ PCSTR p_pstrClassName_i,
+ PCSTR lpszFormat);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogTime
+/// \~english @par Brief
+/// Print out real-time in log using Native Service mechanism
+/// \~english @param [in] f_uiZoneIndex
+/// const UI_64 - Mask value(0 to 511) to check against
+/// \~english @param [in] lpszFormat
+/// PCSTR - string similar to that of a printf statement
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// parameter FRAMEWORKUNIFIEDLOG has already set using NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// - Real-time log output switch can be turn on by NsLogSetRealtimeLog() generally.
+/// But in case of FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE real-time log and/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog /will not print out
+/// \~~english @par
+/// - in the following conditions,real-time log will not print out:
+/// - log output way is LPRINT but f_uiZoneIndex parameter is in [96 to 127]
+/// - log output way is LPRINT but real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB and mq_open system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB and mq_send system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and socket system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and setsockopt system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and bind system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and inet_addr system call failed
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER and sendto system call failed(retry 5 times)
+/// - log output way is LPRINT,real-time log output setting is
+/// FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE
+/// \~english @par
+/// in the following conditions /ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/ log can not be print out
+/// - log file for parameter f_uiZoneIndex and
+/// log file for parameter FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter can not be found
+/// - the ring_buffer of log file(log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter when
+/// log file is not exited) for parameter f_uiZoneIndex is not opened (CNSRingBuffer::IsOpen())
+/// - the write-in operation to ring_buffer of log file for parameter f_uiZoneIndex
+/// (log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter when file is not exited) is failed
+/// \~english @par Detail
+/// Print out real-time in log using Native Service mechanism
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogTime(const UI_16 f_uiZoneIndex,
+ PCSTR lpszFormat);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogData
+/// \~english @par Brief
+/// log print-out function
+/// \~english @param [in] f_uiZoneIndex
+/// const UI_64 - Mask value(0 to 511) to check against
+/// \~english @param [in] data
+/// PCSTR -log print-out data
+/// \~english @param [in] size (0 to ULONG_MAX)
+/// UI_32 - data size (0 to ULONG_MAX)
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// FRAMEWORKUNIFIEDLOG has already set by NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// None
+/// \~english @par Conditions of processing failure
+/// -Process will failed under following conditions:
+/// -Real-time log output switch can be turn on by NsLogSetRealtimeLog() generally.
+/// But the set value is FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE
+/// -the log file for f_uiZoneIndex and log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG parameter
+/// are both not found
+/// - the ring_buffer of log file for f_uiZoneIndex(using log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG
+/// if file is not exited)is not opened (CNSRingBuffer::IsOpen())
+/// - write operation on ring_buffer of log file for f_uiZoneIndex
+/// (using log file for FrameworkunifiedLogFlagId which is set by FRAMEWORKUNIFIEDLOG if file is not exited)is failed
+/// \~english @par Detail
+/// the difference bewteen NsLog and NsLogData:
+/// - NsLog()will print out real-time log
+/// NsLogData() will not print out real-time log but noly print out logs under /ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/
+/// - NsLog() will add ZoneIndex, process name, real-time info to log but
+/// NsLogData() only print out log
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogData(const UI_16 f_uiZoneIndex,
+ PCSTR data,
+ UI_32 size);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetFrameworkunifiedLogParams
+/// \~english @par Brief
+/// Sets the FRAMEWORKUNIFIEDLOG parameter of your application\process based on
+/// the value passed in.
+/// \~english @param [in] p_FrameworkunifiedLogParams
+/// FRAMEWORKUNIFIEDLOGPARAM * - FRAMEWORKUNIFIEDLOG parameter in process
+/// \~english @par
+/// FRAMEWORKUNIFIEDLOGPARAM Structure
+/// \~english @code
+/// typedef struct _FRAMEWORKUNIFIEDLOGPARAM {
+/// UI_8 uiLogOptions; // output options (ref. NS_LoggingMethod_t )
+/// CHAR cZones[USER_ZONES_COUNT][ZONE_TEXT_SIZE]; // mask text ZONE_TEXT_10 ... ZONE_TEXT_n
+/// // mask options ZONEMASK(10)...ZONEMASK(n) (ref. TFrameworkunifiedZone)
+/// TFrameworkunifiedZoneMask uiZoneMask;
+/// TFrameworkunifiedLoggerSeverity eSeverity; // severity level(ref. TFrameworkunifiedLoggerSeverity)
+/// } FRAMEWORKUNIFIEDLOGPARAM, *LPFRAMEWORKUNIFIEDLOGPARAM;
+/// @endcode
+/// \~english @par
+/// TFrameworkunifiedZoneMask Array
+/// \~english @code
+/// typedef TFrameworkunifiedZone TFrameworkunifiedZoneMask[ZONE_MASK_ARRAY_ELTS];
+/// @endcode
+/// \~english @par
+/// TFrameworkunifiedZone typedef
+/// \~english @code
+/// UI_32 TFrameworkunifiedZone; // 32bit
+/// @endcode
+/// \~english @par
+/// TFrameworkunifiedLoggerSeverity Enum
+/// \~english @code
+/// typedef enum _TFrameworkunifiedLoggerSeverity {
+/// FRAMEWORKUNIFIED_SEVERITY_LOW = 0x0, // all enable(default)
+/// FRAMEWORKUNIFIED_SEVERITY_DEBUG2, // enable FRAMEWORKUNIFIEDLOG_DEBUG() and FRAMEWORKUNIFIEDLOG_DEBUG2() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_DEBUG1, // enable FRAMEWORKUNIFIEDLOG_DEBUG1() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_INFO, // enable FRAMEWORKUNIFIEDLOG_INFO() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_WARN, // enable FRAMEWORKUNIFIEDLOG_WARN() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_ERROR, // enable FRAMEWORKUNIFIEDLOG_ERROR() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_FATAL, // enable FRAMEWORKUNIFIEDLOG_FATAL() and FRAMEWORKUNIFIEDLOG_ALWAYS()
+/// FRAMEWORKUNIFIED_SEVERITY_ALWAYS // enable FRAMEWORKUNIFIEDLOG_ALWAYS()
+/// } TFrameworkunifiedLoggerSeverity;
+/// @endcode
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - process will not conducted when p_FrameworkunifiedLogParams is NULL.
+/// \~english @par Detail
+/// set the FRAMEWORKUNIFIEDLOG of Application using the parameter set in parameter\n
+/// ZONE_NS_WAR(8), ZONE_NS_ERR(9) will be put-out forcely in the function\n
+/// log will be print out when ForceOutput is set.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetFrameworkunifiedLogParams(FRAMEWORKUNIFIEDLOGPARAM *p_FrameworkunifiedLogParams);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetProcessName
+/// \~english @par Brief
+/// Sets the name of your application\process based on
+/// the value passed in.
+/// \~english @param [in] p_strProcessName_i
+/// PCSTR - name of your application process.(string array ended by NULL below 20byte)
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// The specified Aplication names are not set in the following cases:
+/// - When the Application name specified in the arguments (p_strProcessName_i) is NULL
+/// - When the Application name specified in the arguments (p_strProcessName_i) is a NULL termination character string of 21 bytes or more
+/// \~english @par Detail
+/// -name in prarameter should be string array(less than 20byte) ended by NULL
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetProcessName(PCSTR p_strProcessName_i);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetControlMask
+/// \~english @par Brief
+/// Sets the control word that should be logged
+/// \~english @param [in] p_ulNSLogControl_i
+/// TFrameworkunifiedZoneMask - Set mask to the new value.
+/// \~english @par
+/// TFrameworkunifiedZoneMask Array
+/// \~english @code
+/// typedef TFrameworkunifiedZone TFrameworkunifiedZoneMask[ZONE_MASK_ARRAY_ELTS];
+/// @endcode
+/// \~english @par
+/// TFrameworkunifiedZone typedef
+/// \~english @code
+/// UI_32 TFrameworkunifiedZone; // 32bit
+/// @endcode
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// -process will not be conducted when p_ulNSLogControl_i is none
+/// \~english @par Detail
+/// -Sets the control word that should be logged
+/// zone mask(16) will be rewrited using parameter value
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// NsLogGetControlMask
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetControlMask(TFrameworkunifiedZoneMask p_ulNSLogControl_i);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogIsZoneSet
+/// \~english @par Brief
+/// check wheather the FRAMEWORKUNIFIEDLOG ZONE is set by your application process.
+/// \~english @param [in] set_zone
+/// UI_32 - checking zone_index
+/// \~english @retval TRUE zone is enable
+/// \~english @retval FALSE zone is disable
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// If the parameter of set_zone is outside(set_zone < 0 or 511 > set_zone), it will return FALSE.
+/// \~english @par Detail
+/// check wheather the FRAMEWORKUNIFIEDLOG ZONE is set by your application process.\n
+/// zone parameter first 4bit(0 to 15)is the index of zone mask array\n
+/// second 5bit(0 to 31) is showing bit position of mask(9bit,511 for the most)\n
+/// True will be returned when bit for zone mask is set as 1
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL NsLogIsZoneSet(UI_32 set_zone);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogGetControlMask
+/// \~english @par Brief
+/// Get the control word that you currently have set.
+/// \~english @param [out] p_Zonemask_i
+/// TFrameworkunifiedZoneMask - current mask value.
+/// \~english @par
+/// TFrameworkunifiedZoneMask Array
+/// \~english @code
+/// typedef TFrameworkunifiedZone TFrameworkunifiedZoneMask[ZONE_MASK_ARRAY_ELTS];
+/// @endcode
+/// \~english @par
+/// TFrameworkunifiedZone typedef
+/// \~english @code
+/// UI_32 TFrameworkunifiedZone; // 32bit
+/// @endcode
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - If p_Zonemask_i is NULL, no operation is performed.
+/// \~english @par Detail
+/// Get all 16 zone mask.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// NsLogSetControlMask
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogGetControlMask(TFrameworkunifiedZoneMask p_Zonemask_i);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetLogMethod
+/// \~english @par Brief
+/// Sets the logging place, LPRINT, LSHAREDMEM or any combination of these.
+/// If this is never called the default is LSHAREDMEM.
+/// \~english @param [in] p_eMethod_i
+/// UI_8 - Where you would like to log your data.
+/// \~english @par
+/// NS_LoggingMethod_t Enum
+/// \~english @code
+/// typedef enum _NS_LOGGER_METHODS {
+/// LPRINT = 0x01, // Print to the console(similar to printf)
+/// LMSGQ = 0x02, // Disabled
+/// LSLOGGER = 0x04, // Disabled
+/// LSHAREDMEM = 0x08 // Output to shared memory. this is the default logging method.
+/// } NS_LoggingMethod_t;
+/// @endcode
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// -switch the out-put place for NsLog API
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// Sets the logging place, LPRINT, LSHAREDMEM or any combination of these.
+/// If this is never called the default is LSHAREDMEM.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// NsLogGetLogMethod
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetLogMethod(UI_8 p_eMethod_i);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogGetLogMethod
+/// \~english @par Brief
+/// Get the logging method.
+/// \~english @param None
+/// \~english @retval - return the way you log your data.
+/// UI_8 - Log data type(NS_LoggingMethod_t Enum).
+/// \~english @par
+/// NS_LoggingMethod_t Enum
+/// \~english @code
+/// typedef enum _NS_LOGGER_METHODS {
+/// LPRINT = 0x01, // Print to the console(similar to printf)
+/// LMSGQ = 0x02, // Disabled
+/// LSLOGGER = 0x04, // Disabled
+/// LSHAREDMEM = 0x08 // Output to shared memory. this is the default logging method.
+/// } NS_LoggingMethod_t;
+/// @endcode
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// Invoke callback function to get the logging method.\n
+/// If callback function is null and expectedCalls is '0',
+/// using default SetSeparator function to get the logging method. \n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogSetLogMethod
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_8 NsLogGetLogMethod(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogInitialize
+/// \~english @par Brief
+/// Initialize the log level and real-time log out-put setting
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// if the getting process of FRAMEWORKUNIFIEDLOG CONFIG file data is failed
+/// \~english @par Detail
+/// Initialize the log level and real-time log out-put setting
+/// if the getting process of FRAMEWORKUNIFIEDLOG CONFIG file data is failed,log
+/// level and real-time log out-put setting will not be initialized
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogInitialize(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetFrameworkunifiedLogFlag
+/// \~english @par Brief
+/// set LogLevel of FRAMEWORKUNIFIEDLOG flag
+/// \~english @param [in] flag_id
+/// UI_8 - index for FRAMEWORKUNIFIEDLOG flag(0 to FLAG_LIST(declared in FRAMEWORKUNIFIEDLOG CONFIG file)
+/// \~english @param [in] mode
+/// UI_8 - LogLevel
+/// \~english @par
+/// avaliable LogLevel
+/// - FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE
+/// - FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// in the following conditions FRAMEWORKUNIFIEDLOG flag will not be set
+/// - mode is not FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE, FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG
+/// - the getting process of FRAMEWORKUNIFIEDLOG CONFIG file is failed(ns_logger_frameworkunifiedlog_xxx.cfg)
+/// - flag_id is not declared in FRAMEWORKUNIFIEDLOG CONFIG file
+/// \~english @par Detail
+/// set loglevel for specific FRAMEWORKUNIFIEDLOG flag
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogGetFrameworkunifiedLogFlag
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetFrameworkunifiedLogFlag(UI_8 flag_id, UI_8 mode);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogGetFrameworkunifiedLogFlag
+/// \~english @par Brief
+/// get LogLevel of FRAMEWORKUNIFIEDLOG flag
+/// \~english @param [in] flag_id
+/// UI_8 - index for FRAMEWORKUNIFIEDLOG flag(0 to FLAG_LIST(declared in FRAMEWORKUNIFIEDLOG CONFIG file)
+/// \~english @param [out]mode
+/// UI_8 - LogLevel value
+/// \return none
+/// void - there is no return.
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusFail any sort of error occurred
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// -parameter mode is NULL[eFrameworkunifiedStatusFail]
+/// -flag_id is not declared in FRAMEWORKUNIFIEDLOG CONFIG file [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// get FRAMEWORKUNIFIEDLOG flage for specific flag_id
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogSetFrameworkunifiedLogFlag
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NsLogGetFrameworkunifiedLogFlag(UI_8 flag_id, UI_8 *mode);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetRealtimeLog
+/// \~english @par Brief
+/// real-time log output setting
+/// \~english @param [in] mode
+/// UI_8 - set mode for Real time log
+/// \~english @par
+/// available setting for real-time log output
+/// default value is REALTIME_LOG in FRAMEWORKUNIFIEDLOG CFG file
+/// (FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF when FRAMEWORKUNIFIEDLOG CFG file get failed)
+/// \~english @code
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART 1 // : UARTOUT
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB 2 // : USB OUT
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE 0x82 // : USB OFF
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER 3 // : Ether OUT
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF 0 // : ALL OFF
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE 0xFF // : FREEZE
+/// @endcode
+/// \~english @retval none
+/// void - there is no return
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// -mode is not in FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_XXX above
+/// \~english @par Detail
+/// set the real-time log output using the setting value.\n
+/// need to reboot during ROM start in order to switch to Ethernet output\n
+/// /nv/BS/ns/framework_unified/rwdata/frameworkunifiedlog.ether file will be generated
+/// when mode FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER /nv/BS/ns/framework_unified/rwdata/frameworkunifiedlog.ether\n
+/// and /nv/BS/ns/framework_unified/rwdata/frameworkunifiedlog.ether file will be delated when mode is not FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogGetRealtimeLog
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetRealtimeLog(UI_8 mode);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogGetRealtimeLog
+/// \~english @par Brief
+/// get the setting of real-time log output
+/// \~english @param [out] mode
+/// UI_8 * -the setting of real-time log output
+/// \~english @par
+/// available settings of real-time log output
+/// default value is REALTIME_LOG in FRAMEWORKUNIFIEDLOG CFG file
+/// (FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF when FRAMEWORKUNIFIEDLOG CFG file get failed)
+/// \~english @code
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART 1 // : UARTOUT
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB 2 // : USB OUT
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE 0x82 // : USB OFF
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_ETHER 3 // : Ether OUT
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF 0 // : ALL OFF
+/// #define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE 0xFF // : FREEZE
+/// @endcode
+/// \~english @retval none
+/// void - there is no return
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - cannot get when mode is NULL
+/// -FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF will be returned when the approach
+/// of FRAMEWORKUNIFIEDLOG CONFIG file (ns_logger_frameworkunifiedlog_xxx.cfg)is failed
+/// \~english @par Detail
+/// get the setting of real-time log output
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogSetRealtimeLog
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogGetRealtimeLog(UI_8 *mode);
+
+// Deprecated API: Not use.
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetSeverity
+/// \~english @par Brief
+/// Set log severity level
+/// \~english @param [in] p_eLogSeverity_i
+/// TFrameworkunifiedLoggerSeverity - Log severity
+/// \~english @par
+/// TFrameworkunifiedLoggerSeverity Enum
+/// \~english @code
+/// typedef enum _TFrameworkunifiedLoggerSeverity {
+/// FRAMEWORKUNIFIED_SEVERITY_LOW = 0x0, /// <all enable(default)
+/// FRAMEWORKUNIFIED_SEVERITY_DEBUG2, /// <enable FRAMEWORKUNIFIEDLOG_DEBUG() and FRAMEWORKUNIFIEDLOG_DEBUG2() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_DEBUG1, /// <enable FRAMEWORKUNIFIEDLOG_DEBUG1() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_INFO, /// <enable FRAMEWORKUNIFIEDLOG_INFO() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_WARN, /// <enable FRAMEWORKUNIFIEDLOG_WARN() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_ERROR, /// <enable FRAMEWORKUNIFIEDLOG_ERROR() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_FATAL, /// <enable FRAMEWORKUNIFIEDLOG_FATAL() and FRAMEWORKUNIFIEDLOG_ALWAYS()
+/// FRAMEWORKUNIFIED_SEVERITY_ALWAYS /// <enable FRAMEWORKUNIFIEDLOG_ALWAYS()
+/// } TFrameworkunifiedLoggerSeverity;
+/// @endcode
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(p_eLogSeverity_i).
+/// \~english @par Detail
+/// Invoke callback function to set log severity.\n
+/// If callback function is null and expectedCalls is '0', using default function to set log severity.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogGetSeverity
+////////////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetSeverity(TFrameworkunifiedLoggerSeverity p_eLogSeverity_i);
+
+// Deprecated API: Not use.
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogGetSeverity
+/// \~english @par Brief
+/// Get the log severity.
+/// \~english @param none
+/// \~english @retval Log Severity
+/// TFrameworkunifiedLoggerSeverity - Log severity.
+/// \~english @par
+/// TFrameworkunifiedLoggerSeverity Enum
+/// \~english @code
+/// typedef enum _TFrameworkunifiedLoggerSeverity {
+/// FRAMEWORKUNIFIED_SEVERITY_LOW = 0x0, /// <all enable(default)
+/// FRAMEWORKUNIFIED_SEVERITY_DEBUG2, /// <enable FRAMEWORKUNIFIEDLOG_DEBUG() and FRAMEWORKUNIFIEDLOG_DEBUG2() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_DEBUG1, /// <enable FRAMEWORKUNIFIEDLOG_DEBUG1() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_INFO, /// <enable FRAMEWORKUNIFIEDLOG_INFO() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_WARN, /// <enable FRAMEWORKUNIFIEDLOG_WARN() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_ERROR, /// <enable FRAMEWORKUNIFIEDLOG_ERROR() and all the follows
+/// FRAMEWORKUNIFIED_SEVERITY_FATAL, /// <enable FRAMEWORKUNIFIEDLOG_FATAL() and FRAMEWORKUNIFIEDLOG_ALWAYS()
+/// FRAMEWORKUNIFIED_SEVERITY_ALWAYS /// <enable FRAMEWORKUNIFIEDLOG_ALWAYS()
+/// } TFrameworkunifiedLoggerSeverity;
+/// @endcode
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// none
+/// \~english @par Detail
+/// Invoke callback function to get log severity.\n
+/// If callback function is null and expectedCalls is '0', using default function to get log severity.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogSetSeverity
+////////////////////////////////////////////////////////////////////////////////////////////
+TFrameworkunifiedLoggerSeverity NsLogGetSeverity(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLog_EvtCnt
+/// \~english @par Brief
+/// Event and count logger.
+/// \~english @param [in] @param [in] Cnt_Id
+/// UI_16 - ID of counter from comm layer
+/// \~english @param [in] Evt_Id
+/// UI_16 - ID of Event from comm layer
+/// \~english @param [in] n
+/// UI_8 - number of variable arguments inputted
+/// \~english @param [in] arg list
+/// ... - Data arguments(option)
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(Cnt_Id).
+/// - It is an incorrect value(Evt_Id).
+/// - It is an incorrect value(n).
+/// \~english @par Detail
+/// Invoke callback function with argument 'Cnt_Id', 'Evt_Id', 'n' to log.\n
+/// If callback function is null and expectedCalls is '0', using default SetSeparator function to log. \n
+/// In other situation, match and log 'Cnt_Id', 'Evt_Id', 'n'.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+// Deprecated API: Not use.
+void NsLog_EvtCnt( // Line number where message was generated
+ UI_16 Cnt_Id,
+ UI_16 Evt_Id, UI_8 n,
+ ...);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLog_Evt
+/// \~english @par Brief
+/// Event logger mechanism.(Send data to SS event logger Queue)
+/// \~english @param [in] Evt_Id
+/// UI_16 - ID of Event from comm layer
+/// \~english @param [in] nu
+/// UI_8 - number of variable arguments inputted
+/// \~english @param [in] ...
+/// ... - Data arguments
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - process nothing when Evt_id is in [0 to 0xFF]
+/// - process nothing when nu is not 1 or 4
+/// \~english @par Detail
+/// -send the log event queue to SS(logger mechanism Event)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+// Deprecated API: Not use.
+void NsLog_Evt(UI_16 Evt_Id, UI_8 nu, ...);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLog_Cnt
+/// \~english @par Brief
+/// Counter logger mechanism.(Send data to SS event logger Queue)
+/// \~english @param [in] Cnt_Id
+/// UI_16 - ID of Counter from comm layer
+/// \~english @param [in] nu
+/// UI_8 - number of variable arguments inputted
+/// \~english @param [in] ...
+/// ... - Data arguments
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - process nothing when Cnt_Id is 0
+/// - process nothing when nu is not 0 or 1
+/// \~english @par Detail
+/// send the log event queue to SS(logger mechanism counter)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Fire and Forget
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+// Deprecated API: Not use.
+void NsLog_Cnt(UI_16 Cnt_Id, UI_8 nu, ...); // Not to use.
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogDetermineLogMethod
+/// \~english @par Brief
+/// Determines the control log method based on the string passed.
+/// If the string passed doesn't match any of the key words:
+/// slogger or msgr or console the method will return a value of
+/// zero. This string may be in the form of the following:
+/// "msgq|console" would cause the output to go to both the NSLog
+/// message queue and the console.
+/// \~english @param [in] output_type
+/// PCSTR - The key words:
+/// \~english @retval 1 ... 0xF Success
+/// \~english @retval 0 the string passed doesn't match any of the key words
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// the string passed doesn't match any of the key words
+/// \~english @par Detail
+/// mask value retruned from application can be used as parameter in NsLogSetLogMethod()
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_8 NsLogDetermineLogMethod(PCSTR output_type);
+
+// Unused API.
+// VOID NsLogEnableRcsLogging(BOOL f_bRCSEnableLogging);
+
+// Private API.
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogGetZoneTextList
+/// \~english @par Brief
+/// Get the zone data list.
+/// \~english @param [out] f_cZoneList
+/// CHAR [][ZONE_TEXT_SIZE] - zone text list(0 ... 511)
+/// \~english @par
+/// PUI_32 - Pointer to preallocated array of CHAR cZones[USER_ZONES_COUNT][ZONE_TEXT_SIZE];
+/// \~english @retval none
+/// VOID - There is no return
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(f_cZoneList) or f_cZoneList is empty.
+/// - Some error occur when get value from f_cZoneList
+/// \~english @par Detail
+/// Invoke callback function to get zone text list.\n
+/// If callback function is null and expectedCalls is '0', using default function to get zone text list.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NsLogSetZones
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID NsLogGetZoneTextList(CHAR f_cZoneList[][ZONE_TEXT_SIZE]);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogSetZones
+/// \~english @par Brief
+/// set FRAMEWORKUNIFIEDLOG ZONE
+/// \~english @param [in] f_uiZoneCount
+/// UI_32 - number of zone
+/// \~english @param [in] ...
+/// arg_list - zone list (0 ... 511)
+/// \~english @retval none
+/// void - there is no return.
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - zone value will not over 512
+/// \~english @par Detail
+/// set the specific bit to existed zone mask\n
+/// first 4bit(0 to 15) in zone is the index of zone mask array\n
+/// second 5bit(0 to 31)set the 9bit which shows the bit position of mask(blew 511)\n
+/// eg:in the case of setting three zones=31,30,29, function should be called like NsLogSetZones(3,31,30,29) \n
+/// operation may not be right when parameter shows in arg_list differs with array num in f_uiZoneCount
+///
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Set Get
+/// \~english @see
+/// none
+/////////////////////////////////////////////////////////////////////////////////////
+void NsLogSetZones(UI_32 f_uiZoneCount, ...);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogParseZones
+/// \~english @par Brief
+/// Parse the FRAMEWORKUNIFIEDLOG ZONE.
+/// \~english @param [out] p_FrameworkunifiedLogParams
+/// FRAMEWORKUNIFIEDLOGPARAM * - Input/output FRAMEWORKUNIFIEDLOG parameter
+/// \~english @param [in] f_uiZoneCount
+/// UI_32 - Zone setting
+/// \~english @param [in] ...
+/// arg_list - Zone lists (zone values are 0 to 511)
+/// \~english @par
+/// FRAMEWORKUNIFIEDLOGPARAM structures
+/// \~english @code
+/// typedef struct _FRAMEWORKUNIFIEDLOGPARAM {
+/// UI_8 uiLogOptions; // Log output location (ref NS_LoggingMethod_t)
+/// CHAR cZones[USER_ZONES_COUNT][ZONE_TEXT_SIZE]; // ZONE_TEXT_10 ... ZONE_TEXT_n
+/// TFrameworkunifiedZoneMask uiZoneMask; // ZONEMASK(10)...ZONEMASK(n) (ref TFrameworkunifiedZone)
+/// TFrameworkunifiedLoggerSeverity eSeverity; // Logging level (ref TFrameworkunifiedLoggerSeverity)
+/// } FRAMEWORKUNIFIEDLOGPARAM, *LPFRAMEWORKUNIFIEDLOGPARAM;
+/// @endcode
+/// \~english @retval none
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// In the FRAMEWORKUNIFIEDLOG parameter (p_FrameworkunifiedLogParams) specified in the arguments,\n
+/// add (or) all masked values of the zone lists specified by the arguments.
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// none
+/////////////////////////////////////////////////////////////////////////////////////
+void NsLogParseZones(FRAMEWORKUNIFIEDLOGPARAM *p_FrameworkunifiedLogParams, UI_32 f_uiZoneCount, ...);
+
+// Unused API.
+// VOID NsRcsSendTraceData(PCHAR f_pData, UI_32 f_len);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSLogGetFrameworkunifiedlogFileTotalNum
+/// \~english @par Brief
+/// get total number of log file
+/// \~english @retval num
+/// UI_32 - Total numger of frameworkunifiedlog files.
+/// \~english @par Prerequisite
+/// set log file using NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// get total number of log file
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 NSLogGetFrameworkunifiedlogFileTotalNum(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSLogGetFrameworkunifiedlogFileName
+/// \~english @par Brief
+/// get the name of log file
+/// \~english @param [in] index
+/// UI_32 - Index of a list of frameworkunifiedlog file names.(0 to NSLogGetFrameworkunifiedlogFileTotalNum()-1)
+/// \~english @retval file name -file with specific index is exsisted
+/// \~english @retval NULL -file with specific index is not exsisted
+/// \~english @par Prerequisite
+/// set log file using NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// file with specific index is not exsisted
+/// \~english @par Detail
+/// get the file name with specific index is not exsisted
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No macth
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR NSLogGetFrameworkunifiedlogFileName(UI_32 index);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSLogGetFrameworkunifiedlogFileName
+/// \~english @par Brief
+/// get index of log file
+/// \~english @param [in] filename
+/// PCSTR - Name of frameworkunifiedlog file.
+/// \~english @retval 0 log file specific logfile is not exsisted
+/// \~english @retval index of log file specific logfile is exsisted
+/// \~english @par Prerequisite
+/// set log file using NsLogSetFrameworkunifiedLogParams
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// process nothing when file name is NULL
+/// process nothing when file name is not exsisted
+/// \~english @par Detail
+/// get index of log file
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+int NSLogGetFrameworkunifiedlogIndex(PCSTR filename);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsForceClose
+/// \~english @par Brief
+/// clear log forcely.
+/// \~english @retval none
+/// return void
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// -clear log forcely.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID NsForceClose(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief extern FRAMEWORKUNIFIEDLOG parameter
+///////////////////////////////////////////////////////////////////////////////
+/// Global variable that's used by the Native Services Logger.
+/// An application will setup this variable in their main,
+/// values are user defined and provide user control of what
+/// should and shouldn't get logged.
+/// \code
+/// FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams =
+/// {
+/// FRAMEWORKUNIFIEDLOGOPTIONS,
+/// {
+/// ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+/// ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+/// ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+/// ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+/// ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+/// ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+/// ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+/// ZONE_TEXT_31, ZONE_TEXT_32, ZONE_TEXT_33,
+/// ZONE_TEXT_34, ZONE_TEXT_35, ZONE_TEXT_36,
+/// ZONE_TEXT_37, ZONE_TEXT_38, ZONE_TEXT_39,
+/// ZONE_TEXT_40, ZONE_TEXT_41, ZONE_TEXT_42,
+/// ZONE_TEXT_43, ZONE_TEXT_44, ZONE_TEXT_45,
+/// ZONE_TEXT_46, ZONE_TEXT_47, ZONE_TEXT_48,
+/// ZONE_TEXT_49, ZONE_TEXT_50, ZONE_TEXT_51,
+/// ZONE_TEXT_52, ZONE_TEXT_53, ZONE_TEXT_54,
+/// ZONE_TEXT_55
+/// },
+/// FRAMEWORKUNIFIEDLOGZONES
+/// };
+/// \endcode
+///
+
+/// if FRAMEWORKUNIFIEDLOGZONES not defined in makefile
+#ifndef FRAMEWORKUNIFIEDLOGZONES
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief g_FrameworkunifiedLogParams
+/// if FRAMEWORKUNIFIEDLOGZONES not defined in makefile
+///////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOGZONES {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup FRAMEWORKUNIFIED_SET_ZONES
+/// \~english @par Brief
+/// This macro API register FRAMEWORKUNIFIEDLOGAPPZONES.
+/// \~english @retval none
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// in main() function use macro FRAMEWORKUNIFIED_SET_ZONES() before FrameworkunifiedDispatcher()
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// NsLogSetFrameworkunifiedLogParams
+///////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIED_SET_ZONES() {UI_32 LogArr[] = {FRAMEWORKUNIFIEDLOGAPPZONES}; \
+ NsLogParseZones(&g_FrameworkunifiedLogParams, (UI_32)_countof(LogArr), FRAMEWORKUNIFIEDLOGAPPZONES); \
+ NsLogSetFrameworkunifiedLogParams(&g_FrameworkunifiedLogParams);}
+#else
+#warning "Zones defined by FRAMEWORKUNIFIEDLOGAPPZONES are overridden by FRAMEWORKUNIFIEDLOGZONES"
+#define FRAMEWORKUNIFIED_SET_ZONES() NsLogSetFrameworkunifiedLogParams(&g_FrameworkunifiedLogParams)
+#endif
+
+#define ZONE_END UINT_MAX
+// Unused API
+// #define CHECK_SEVERITY_LEVEL(sev_level) ((sev_level) >= NsLogGetSeverity())
+// If value of BITS_IN_TZONE changes in future then need to consider changes in the values 5 and 0x1F in below macros
+// here 5 represents (sizeof(TFrameworkunifiedZone)+1) and 0x1F represents (BITS_IN_TZONE-1)
+#define GET_ZONE_INDEX(zone) (((UI_32)zone) >> 5)
+#define GET_ZONE_BIT_MASK(zone) ((TFrameworkunifiedZone)(1U << (((UI_32)zone) & 0x1F)))
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup ZONEMASK
+/// \~english @par Brief
+/// the Macro for zone index mask
+/// \~english @param [in] n
+/// zone index
+/// \~english @retval num
+/// UI_32 - zone index
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - none
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// mask the zone index
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////////
+#define ZONEMASK( n ) ((TFrameworkunifiedZone)( n ))
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup IS_ZONE_SET
+/// \~english @par Brief
+/// check wheather the FRAMEWORKUNIFIEDLOG ZONE is set by your application process.
+/// \~english @param [in] set_zone
+/// UI_32 - checking zone_index
+/// \~english @retval TRUE zone is enable
+/// \~english @retval FALSE zone is disable
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// Checks if the FRAMEWORKUNIFIEDLOG ZONE can be configured by Application processes.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// NsLogIsZoneSet
+////////////////////////////////////////////////////////////////////////////////////////////////
+#define IS_ZONE_SET(set_zone) (NsLogIsZoneSet(set_zone) == TRUE)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup FRAMEWORKUNIFIEDLOG
+/// \~english @par Brief
+/// Developers should use the FRAMEWORKUNIFIEDLOG for logging.
+/// \~english @param [in] zone
+/// Defined zone in a process (e.g. ZONE_FUNC)
+/// \~english @param [in] funcname
+/// Name of the class or method where the log was written (e.g. "main")
+/// \~english @param [in] print_fmt
+/// string similar to that of a printf statement
+/// \~english @param [in] args
+/// Data arguments(option)
+/// \~english @retval none
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If print_fmt is NULL, no operation is performed.
+/// \~english @par Detail
+/// FRAMEWORKUNIFIEDLOG is simple macro to make it easy to log messages from any point in your code.
+/// This macro has smarts that does fast checks to determine if your log should or shouldn't be printed.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// ZONEMASK, IS_ZONE_SET, NsLog, NsLog0
+///////////////////////////////////////////////////////////////////////////////
+#ifndef _FRAMEWORKUNIFIEDLOG_ZONE_FUNC_ENABLE_
+#define FRAMEWORKUNIFIEDLOG(zone, funcname, print_fmt, args...)\
+ (zone != ZONEMASK(11))?((IS_ZONE_SET(zone))?TEXT_ZONE(zone, funcname, print_fmt, ## args):((void)0)):((void)(0))
+#else // _FRAMEWORKUNIFIEDLOG_ZONE_FUNC_ENABLE_
+#define FRAMEWORKUNIFIEDLOG(zone, funcname, print_fmt, args...)\
+ ((IS_ZONE_SET(zone)) ? TEXT_ZONE(zone, funcname, print_fmt, ## args) : ((void)0))
+#endif // _FRAMEWORKUNIFIEDLOG_ZONE_FUNC_ENABLE_
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \~english @par Brief
+/// This is the log output macro for clock display in milliseconds.
+/// \~english @param [in] zone
+/// Zone indexes to be checked
+/// \~english @param [in] str
+/// Log output string
+/// \~english @retval none
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// A simple macro for logging messages in milliseconds from any point in the source code.\n
+/// The log is output in the following format. "Hours:Minutes:Seconds.Milliseconds/=log-output-string"
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// IS_ZONE_SET
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOG_TIME(zone, str)\
+ ((IS_ZONE_SET(zone))?NsLogTime(zone, str):((void)(0)))
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \~english @par Brief
+/// This is a simplified version of the log output macro.
+/// \~english @param [in] zone
+/// Zone indexes to be checked
+/// \~english @param [in] data
+/// Log output data
+/// \~english @param [in] size
+/// Size of the log output data
+/// \~english @retval none
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// A simple macro for logging messages from any point in the source code.\n
+/// \ref The macro FRAMEWORKUNIFIEDLOG can specify variable argument lists for log output data,
+/// but the macro is a macro that specifies only data character strings.
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// IS_ZONE_SET, NsLogData
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOG_DATA(zone, data, size)\
+ ((IS_ZONE_SET(zone))?NsLogData(zone, data, size):((void)(0)))
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG_EVTCNT
+///////////////////////////////////////////////////////////////////////////////
+/// Deprecated API. Not use.
+#define FRAMEWORKUNIFIEDLOG_EVTCNT(zone, CntId, EvtId, n...) NsLog_EvtCnt(CntId, EvtId, ##n)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG_EVT
+///////////////////////////////////////////////////////////////////////////////
+/// Event logger mechanism.(Send data to SS event logger Queue)
+/// \note The ZONE is not used.
+///
+/// \param [in] zone
+/// Defined zone in a process (e.g. ZONE_FUNC)
+/// \param [in] EvtId
+/// UI_16 - ID of Event from comm layer
+/// \param [in] n
+/// UI_8 - number of variable arguments inputted
+///////////////////////////////////////////////////////////////////////////////
+/// Deprecated API. Not use.
+#define FRAMEWORKUNIFIEDLOG_EVT(zone, EvtId, n...) NsLog_Evt(EvtId, ##n)
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG_CNT
+///////////////////////////////////////////////////////////////////////////////
+/// Counter logger mechanism.(Send data to SS event logger Queue)
+/// \note The ZONE is not used.
+///
+/// \param [in] zone
+/// Defined zone in a process (e.g. ZONE_FUNC)
+/// \param [in] CntId
+/// UI_16 - ID of Event from comm layer
+/// \param [in] n
+/// UI_8 - number of variable arguments inputted
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Deprecated API. Not use.
+#define FRAMEWORKUNIFIEDLOG_CNT(zone, CntId, n...) NsLog_Cnt(CntId, ##n) // Not to use
+
+/// Deprecated API. Not use.
+#define TEXT(funcname, args...) TEXT_ZONE(BITS_IN_ZONE_MASK, funcname, ## args)
+
+// Unused API
+// #define TEXT0(funcname, print_fmt ) NsLog(__LINE__, BITS_IN_ZONE_MASK, funcname, print_fmt)
+
+#define GET_MACRO(_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, NAME, ...) NAME
+#define NsLogFunc(...)\
+ GET_MACRO(__VA_ARGS__, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, \
+ NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog, NsLog0)
+#define TEXT_ZONE(zone_index, funcname, ...)\
+ NsLogFunc(__VA_ARGS__)(__LINE__, zone_index, funcname, __VA_ARGS__)
+
+/// Deprecated API. Not use.
+#define TEXT_EVTCNT(CntId, EvtId, n...) NsLog_EvtCnt(CntId, EvtId, ##n)
+/// Deprecated API. Not use
+#define TEXT_EVT(EvtID, n...) NsLog_Evt(EvtID, ##n)
+/// Deprecated API. Not use.
+#define TEXT_CNT(CntId, n...) NsLog_Cnt(CntId, ##n)
+/// Used to log data that contains trailing arguments \n
+/// Example: FRAMEWORKUNIFIEDLOG0(ZONE_INFO, __FUNCTION__, "testers return value is [%d]!", rtnValue);
+
+
+/// Deprecated API. Use FRAMEWORKUNIFIEDLOG instead.
+#define FRAMEWORKUNIFIEDLOG0 FRAMEWORKUNIFIEDLOG
+
+
+/// Note: These bits are reserved for Framework logging and debugging
+#define ZONE_NS_FUNC ZONEMASK(0)
+#define ZONE_NS_DIS ZONEMASK(1)
+#define ZONE_NS__CWORD77_ ZONEMASK(2)
+#define ZONE_NS_IMP_INFO ZONEMASK(3)
+#define ZONE_NS_SM_DEV_INFO ZONEMASK(4)
+#define ZONE_NS_SM_USR_INFO ZONEMASK(5)
+#define ZONE_NS_INFO ZONEMASK(6)
+#define ZONE_NS_DEBUG_DUMP ZONEMASK(7)
+#define ZONE_NS_WAR ZONEMASK(8)
+#define ZONE_NS_ERR ZONEMASK(9)
+#define ZONE_DEBUG_DUMP ZONE_NS_DEBUG_DUMP
+
+#define ZONE_TEXT_0 "NS_Func"
+#define ZONE_TEXT_1 "NS_Dispatcher"
+#define ZONE_TEXT_2 "NS__CWORD77_"
+#define ZONE_TEXT_3 "NS_Reserved"
+#define ZONE_TEXT_4 "NS_StateMachine_Dev"
+#define ZONE_TEXT_5 "NS_StateMachine_Usr"
+#define ZONE_TEXT_6 "NS_Info"
+#define ZONE_TEXT_7 "NS_Debug_Dump"
+#define ZONE_TEXT_8 "NS_Warning"
+#define ZONE_TEXT_9 "NS_Error"
+
+////
+// Following is old definitions. Only for compile.
+// Specific ZONE to use the ns_logger_frameworkunifiedlog.cfg
+// If possible, following Specific ZONE difinitions shall be delete.
+////
+// Special ZONE(64)-(95)
+/// Note: These bits are reserved for special ZONE
+#define ZONE_PERFORMANCE ZONEMASK(64)
+#define ZONE_SCREEN_TRANS ZONEMASK(65)
+#define ZONE_SWDL ZONEMASK(66)
+#define ZONE_SYSTEMDATA ZONEMASK(67)
+#define ZONE_LOG_SH ZONEMASK(68)
+#define ZONE_LOG_SYS ZONEMASK(69)
+#define ZONE_LOG__CWORD52_ ZONEMASK(70)
+#define ZONE_SECURE ZONEMASK(71)
+#define ZONE_CAN_FILTER ZONEMASK(72)
+#define ZONE_COMM_PROCESS ZONEMASK(73)
+#define ZONE_CONNECT_DEVICE ZONEMASK(74)
+#define ZONE_SP_ZONE_75 ZONEMASK(75)
+#define ZONE_SP_ZONE_76 ZONEMASK(76)
+#define ZONE_SP_ZONE_77 ZONEMASK(77)
+#define ZONE_SP_ZONE_78 ZONEMASK(78)
+#define ZONE_SP_ZONE_79 ZONEMASK(79)
+#define ZONE_SP_ZONE_80 ZONEMASK(80)
+#define ZONE_SP_ZONE_81 ZONEMASK(81)
+#define ZONE_SP_ZONE_82 ZONEMASK(82)
+#define ZONE_SP_ZONE_83 ZONEMASK(83)
+#define ZONE_SP_ZONE_84 ZONEMASK(84)
+#define ZONE_SP_ZONE_85 ZONEMASK(85)
+#define ZONE_SP_ZONE_86 ZONEMASK(86)
+#define ZONE_SP_ZONE_87 ZONEMASK(87)
+#define ZONE_SP_ZONE_88 ZONEMASK(88)
+#define ZONE_SP_ZONE_89 ZONEMASK(89)
+#define ZONE_SP_ZONE_90 ZONEMASK(90)
+#define ZONE_SP_ZONE_91 ZONEMASK(91)
+#define ZONE_SP_ZONE_92 ZONEMASK(92)
+#define ZONE_SP_ZONE_93 ZONEMASK(93)
+#define ZONE_SP_ZONE_94 ZONEMASK(94)
+#define ZONE_SP_ZONE_95 ZONEMASK(95)
+
+// Special ZONE(96)-(127) (console off)
+/// Note: These bits are reserved for special ZONE
+#define ZONE_COMM_SYS ZONEMASK(96)
+#define ZONE_COMM_SH ZONEMASK(97)
+#define ZONE_COMM_USB ZONEMASK(98)
+#define ZONE_SP_ZONE_99 ZONEMASK(99)
+#define ZONE_SP_ZONE_100 ZONEMASK(100)
+#define ZONE_SP_ZONE_101 ZONEMASK(101)
+#define ZONE_SP_ZONE_102 ZONEMASK(102)
+#define ZONE_SP_ZONE_103 ZONEMASK(103)
+#define ZONE_SP_ZONE_104 ZONEMASK(104)
+#define ZONE_SP_ZONE_105 ZONEMASK(105)
+#define ZONE_SP_ZONE_106 ZONEMASK(106)
+#define ZONE_SP_ZONE_107 ZONEMASK(107)
+#define ZONE_SP_ZONE_108 ZONEMASK(108)
+#define ZONE_SP_ZONE_109 ZONEMASK(109)
+#define ZONE_SP_ZONE_110 ZONEMASK(110)
+#define ZONE_SP_ZONE_111 ZONEMASK(111)
+#define ZONE_SP_ZONE_112 ZONEMASK(112)
+#define ZONE_SP_ZONE_113 ZONEMASK(113)
+#define ZONE_SP_ZONE_114 ZONEMASK(114)
+#define ZONE_SP_ZONE_115 ZONEMASK(115)
+#define ZONE_SP_ZONE_116 ZONEMASK(116)
+#define ZONE_SP_ZONE_117 ZONEMASK(117)
+#define ZONE_SP_ZONE_118 ZONEMASK(118)
+#define ZONE_SP_ZONE_119 ZONEMASK(119)
+#define ZONE_SP_ZONE_120 ZONEMASK(120)
+#define ZONE_SP_ZONE_121 ZONEMASK(121)
+#define ZONE_SP_ZONE_122 ZONEMASK(122)
+#define ZONE_SP_ZONE_123 ZONEMASK(123)
+#define ZONE_SP_ZONE_124 ZONEMASK(124)
+#define ZONE_SP_ZONE_125 ZONEMASK(125)
+#define ZONE_SP_ZONE_126 ZONEMASK(126)
+#define ZONE_SP_ZONE_127 ZONEMASK(127)
+
+#endif /* __NATIVESERVICES_LOGGER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_mc_system_info.h b/nsframework/framework_unified/client/include/native_service/ns_mc_system_info.h
new file mode 100644
index 00000000..b61268aa
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_mc_system_info.h
@@ -0,0 +1,103 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageCenter
+/// \brief Native Services Special Interfaces
+///
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS_MC_SYSTEM_INFO_H_
+#define FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS_MC_SYSTEM_INFO_H_
+
+
+#include <native_service/ns_msgs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageCenter
+/// McSendWithSysInfo
+/// Sends data to a message queue, user defined system info.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \param [in] source
+/// LPCSTR - app (You) the sender
+/// \param [in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \param [in] sysInfo
+/// PCHAR - pointer to sysInfo data that will be placed in the header of the message.
+/// \param [in] length
+/// UI_32 - length of the data buffer provided
+/// \param [in] data
+/// void* - pointer to the data to be sent
+///
+/// \return EFrameworkunifiedStatus
+/// status -
+/// indicates if the message was sent successfully
+/// success >> (eFrameworkunifiedStatusOK)
+/// failure >> (anything else)
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McSendWithSysInfo(HANDLE hMessage, PCSTR source, UI_32 cmd, PCHAR sysInfo, UI_32 length, PCVOID data,
+ UI_32 sessionid);
+
+// EFrameworkunifiedStatus McSendWithSysInfoWithSession(HANDLE hMessage, PCSTR source,
+// UI_32 cmd, PCHAR sysInfo, UI_32 length, PCVOID data, UI_32 sessionid);
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageCenter
+/// McSendWithSysInfo
+/// Sends data to a message queue, user defined system info.
+///
+/// \param [in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \param [in] source
+/// LPCSTR - app (You) the sender
+/// \param [in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \param [in] sysInfo
+/// PCHAR - pointer to sysInfo data that will be placed in the header of the message.
+/// \param [in] length
+/// UI_32 - length of the data buffer provided
+/// \param [in] data
+/// void* - pointer to the data to be sent
+/// \param [in] priority
+/// EFrameworkunifiedMessagePriorties - various Message Priorities that a process can assign.
+///
+/// \return EFrameworkunifiedStatus
+/// status -
+/// indicates if the message was sent successfully
+/// success >> (eFrameworkunifiedStatusOK)
+/// failure >> (anything else)
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McSendPrioWithSysInfo(HANDLE hMessage, PCSTR source, UI_32 cmd, PCSTR sysInfo, UI_32 length, PCVOID data,
+ EFrameworkunifiedMessagePriorties priority, UI_32 sessionid);
+
+// EFrameworkunifiedStatus McSendPrioWithSysInfoWithSession(HANDLE hMessage, PCSTR source,
+// UI_32 cmd, PCSTR sysInfo, UI_32 length, PCVOID data, EFrameworkunifiedMessagePriorties priority, UI_32 sessionid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS_MC_SYSTEM_INFO_H_
diff --git a/nsframework/framework_unified/client/include/native_service/ns_message_center_if.h b/nsframework/framework_unified/client/include/native_service/ns_message_center_if.h
new file mode 100644
index 00000000..cfd350f6
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_message_center_if.h
@@ -0,0 +1,1536 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @brief \~english APIs to Open/Close and Send/Receive on message queues and shared memory.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_MESSAGE_CENTER_IF_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_MESSAGE_CENTER_IF_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_shared_mem_if.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McOpenReceiver
+/// \~english @par Brief
+/// Opens a handle to a Receiver message queue.
+/// \~english @param[in] name
+/// PCSTR - name of the message queue you want to receiver messages on
+/// \~english @retval Handle to a recevier's message queue (If INVALID_HANDLE is returned its an error)
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size of message queue name string specified by argument(name) is larger then 20byte. [NULL]
+/// - Message queue name specified by argument(name) is NULL. [NULL]
+/// - Size of name normalised from argument(name) for message queue is larger then 15byte[16byte when starts with
+/// "/"]. [NULL]
+/// - Failed to create(malloc) buffer to storage name normalised from argument(name) for message queue. [NULL]
+/// - Failed to get(mq_open) message queue. [NULL]
+/// - Failed to create(malloc) buffer to storage management information of message queue. [NULL]
+/// \~english @par Detail
+/// Create a message queue whose name is specified by argument, and return a handle for receiving message. \n
+/// The message queue created in this API is used to receive message, but not to send message. \n
+/// You can use message queue in McOpenSender to send message.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McReceive, McClose
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McOpenReceiver(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McOpenReceiverNotBlocked
+/// \~english @par Brief
+/// Opens a handle to a Receiver message queue. Operations on this queue are
+/// non-blocking if queue is empty or full.
+/// \~english @param[in] name
+/// PCSTR - name of the message queue you want to receiver messages on
+/// \~english @retval Handle to a recevier's message queue (If INVALID_HANDLE is returned its an error)
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size of message queue name string specified by argument(name) is larger then 20byte. [NULL]
+/// - Message queue name specified by argument(name) is NULL. [NULL]
+/// - Size of name normalised from argument(name) for message queue is larger then 15byte[16byte when starts with
+/// "/"]. [NULL]
+/// - Failed to create(malloc) buffer to storage name normalised from argument(name) for message queue. [NULL]
+/// - Failed to get(mq_open) message queue. [NULL]
+/// - Failed to create(malloc) buffer to storage management information of message queue. [NULL]
+/// \~english @par Detail
+/// Create a message queue whose name is specified by argument, and return a handle for receiving message. \n
+/// The message queue created in this API is used to receive message, but not to send message. \n
+/// You can use message queue in McOpenSender to send message.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McReceive, McClose, McOpenSenderNotBlocked
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McOpenReceiverNotBlocked(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McOpenSyncReceiver
+/// \~english @par Brief
+/// Opens a handle to a response Receiver message queue.
+/// \~english @param[in] name
+/// PCSTR - name of the message queue you want to receiver messages on
+/// \~english @retval Handle to a recevier's message queue (If INVALID_HANDLE is returned its an error)
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size of message queue name string specified by argument(name) is larger then 20byte. [NULL]
+/// - Message queue name specified by argument(name) is NULL. [NULL]
+/// - Size of name normalised from argument(name) for message queue(don't start with "/") is larger then 19byte.
+/// [NULL]
+/// - Size of name normalised from argument(name) for message queue(start with "/") is larger then 20byte. [NULL]
+/// - Failed to create(malloc) buffer to storage name normalised from argument(name) for message queue. [NULL]
+/// - Failed to get(mq_open) message queue. [NULL]
+/// - Failed to create(malloc) buffer to storage management information of message queue. [NULL]
+/// \~english @par Detail
+/// Create a message queue whose name is specified by argument, and return a handle for receiving message
+/// by synchronous communication.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// When the application used the message queue acquired by this API, note the following.
+/// - Use McCreateInvokerName to obtain the receive message queue handle to be passed to the parameter name.
+/// - It can not be used transmission because it is for reception.
+/// McOpenSender must be used for the message queue trasmission.
+/// - Cannot be used other than for waiting for response during synchronous communication.
+/// (because the maxmum number of messages in the queue is specified as 2)
+/// - When a message queue name (name) that has not been normalized is specified, transmission falis unless 18 byte are specified.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McCreateInvokerName, McInvokeSync, McClose
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McOpenSyncReceiver(PCSTR name);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McOpenSender
+/// \~english @par Brief
+/// The opens a handle for sending messages to another message queue.
+/// \~english @param[in] name
+/// PCSTR - name of the message queue you want to send messages too
+/// \~english @retval Handle for sending messages to a queue (If INVALID_HANDLE is returned its an error)
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size of message queue name string specified by argument(name) is larger then 20byte. [NULL]
+/// - Message queue name specified by argument(name) is NULL. [NULL]
+/// - Size of name normalised from argument(name) for message queue is larger then 15byte[16byte when starts with
+/// "/"]. [NULL]
+/// - Failed to create(malloc) buffer to storage name normalised from argument(name) for message queue. [NULL]
+/// - Failed to get(mq_open) message queue. [NULL]
+/// - Failed to create(malloc) buffer to storage management information of message queue. [NULL]
+/// \~english @par Detail
+/// Create a message queue whose name is specified by argument, and return a handle for sending message. \n
+/// The message queue created in this API is used to send message, but not to receive message. \n
+/// You can use message queue in McOpenReceiver to receive message.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenReceiver, McSend, McClose
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McOpenSender(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// The opens a handle for sending messages to another message queue.
+/// operations on this queue are non-blocking if queue is empty or full.
+///
+/// \param [in] name
+/// PCSTR - name of the message queue you want to send messages too
+///
+/// \return HANDLE
+/// handle - for sending messages to a queue (If INVALID_HANDLE is returned its an error)
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McOpenSenderNotBlocked(PCSTR name);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McOpenSyncSender
+/// \~english @par Brief
+/// The opens a handle for sending responce to another message queue.
+/// \~english @param[in] name
+/// PCSTR - name of the message queue you want to send messages too
+/// \~english @retval Handle for sending response to a queue (If INVALID_HANDLE is returned its an error)
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size of message queue name string specified by argument(name) is larger then 20byte. [NULL]
+/// - Message queue name specified by argument(name) is NULL. [NULL]
+/// - Size of name normalised from argument(name) for message queue(don't start with "/") is larger then 19byte.
+/// [NULL]
+/// - Size of name normalised from argument(name) for message queue(start with "/") is larger then 20byte. [NULL]
+/// - Failed to create(malloc) buffer to storage name normalised from argument(name) for message queue. [NULL]
+/// - Failed to get(mq_open) message queue. [NULL]
+/// - Failed to create(malloc) buffer to storage management information of message queue. [NULL]
+/// \~english @par Detail
+/// Create a message queue whose name is specified by argument, and return a handle for sending message. \n
+/// The message queue created in this API is used to send message, but not to receive message. \n
+/// You can use message queue in McOpenReceiver to receive message.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenReceiver, McSend, McClose
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McOpenSyncSender(PCSTR name);
+
+/////////////////////////////////////////
+#include <pthread.h>
+HANDLE McOpenSenderChild(PCSTR name, pthread_t childid);
+/////////////////////////////////////////
+
+/////////////////////////////////////////
+EFrameworkunifiedStatus McJoinChild(HANDLE hChildApp);
+/////////////////////////////////////////
+
+/////////////////////////////////////////
+EFrameworkunifiedStatus McGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio);
+/////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McReceive
+/// \~english @par Brief
+/// Retrieves data from a message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the recvMessage, McOpenRecevier
+/// \~english @param[out] source
+/// PSTR - app that sent this message
+/// \~english @param[out] cmd
+/// UI_32* - command message that has been received.
+/// \~english @param[in] length
+/// UI_32 - length of the data buffer provided
+/// \~english @param[out] data
+/// PVOID - pointer to the data to be received
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName - Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusInvldParam - Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF - Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR - An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail - Invalid handle of message queue for receiving message
+/// \~english @par Preconditons
+/// Message queue(McOpenReceiver etc.) for receiving message is created.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Data buffer specified by argument(data) for receiving message is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Size of data buffer specified by argument(length) for receiving message is 0. [eFrameworkunifiedStatusInvldBuf]
+/// - Buffer to storage application name specified by argument(source) for sending message is NULL.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Buffer to storage commond ID of protocol on the service specified by argument(cmd) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Size of application name of sender getted from received message is lager then 20byte. [eFrameworkunifiedStatusInvldBuf]
+/// - Handle specified by argument(hMessage) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified by argument(hMessage) is not appropriate(which is invalid). [eFrameworkunifiedStatusFail]
+/// - Message queue type of handle specified by argument(hMessage) is not receiving type. [eFrameworkunifiedStatusFail]
+/// - File descriptor for receiving message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - An interrupt is generated by the system call (signal) when receiving message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of buffer for receiving message is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// \~english @par Detail
+/// Receives data from message queue specified by argument.
+/// Sets application of sender(source), commond ID of protocol on the service(cmd), receiving data(data), and
+/// return.
+/// It will block until getting message from message queue.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// Since data is exchanged only in the message queue, the data size that can be received is up to 4096 bytes.
+/// \~english @par
+/// The caller must guarantee the allocation of the area for the receive data buffer
+/// and the consistency of the sizes set in the arguments.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenReceiver, McSend
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McReceive(HANDLE hMessage, PSTR source, UI_32 *cmd, UI_32 length, PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McReceiveWithSession
+/// \~english @par Brief
+/// Retrieves data from a message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the recvMessage, McOpenRecevier
+/// \~english @param[out] source
+/// PSTR - app that sent this message
+/// \~english @param[out] cmd
+/// UI_32* - command message that has been received.
+/// \~english @param[out] sessionid
+/// UI_32* - Session ID
+/// \~english @param[in] length
+/// UI_32 - length of the data buffer provided
+/// \~english @param[out] data
+/// PVOID - pointer to the data to be received
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldQName - Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusInvldParam - Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF - Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR - An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail - Invalid handle of message queue for receiving message
+/// \~english @par Preconditons
+/// Message queue(McOpenReceiver etc.) for receiving message is created.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Buffer to storage session ID specified by argument(sessionid) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - Buffer to storage handle of message queue specified by argument(hMessage) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Data buffer specified by argument(data) for receiving message is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Size of data buffer specified by argument(length) for receiving message is 0. [eFrameworkunifiedStatusInvldBuf]
+/// - Buffer to storage application name specified by argument(source) for sending message is NULL.
+/// [eFrameworkunifiedStatusInvldQName]
+/// - Buffer to storage commond ID of protocol on the service specified by argument(cmd) is NULL.
+/// [eFrameworkunifiedStatusInvldParam]
+/// - Size of application name of sender getted from received message is lager then 20byte. [eFrameworkunifiedStatusInvldBuf]
+/// - Handle specified by argument(hMessage) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified by argument(hMessage) is not appropriate(which is invalid). [eFrameworkunifiedStatusFail]
+/// - Message queue type of handle specified by argument(hMessage) is not receiving type. [eFrameworkunifiedStatusFail]
+/// - File descriptor for receiving message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - An interrupt is generated by the system call (signal) when receiving message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of buffer for receiving message is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// \~english @par Detail
+/// Receives data from message queue specified by argument.Sets application of sender(source),
+/// commond ID of protocol on the service(cmd), receiving data(data), session id(sessionid), and return.
+/// It will block until getting message from message queue.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// The caller must guarantee the allocation of the area for the receive data buffer
+/// and the consistency of the sizes set in the arguments.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenReceiver, McSendWithSession
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McReceiveWithSession(HANDLE hMessage, PSTR source, UI_32 *cmd, UI_32 *sessionid,
+ UI_32 length, PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetLength
+/// \~english @par Brief
+/// Get the length of data that needs to be retrieved.
+/// \~english @param[in] data
+/// PVOID - pointer to the data was received from the McReceive Call
+/// \~english @retval UI_32 indicates the number of bytes that in the message
+/// \~english @par
+/// if return is 0 or less then invalid data was passed.
+/// \~english @par Preconditons
+/// - Message is received by McReceive and so on.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Data of received message(data) is NULL. [0]
+/// \~english @par Detail
+/// Return message data length specified by the header of received message. \n
+/// Use this data length as the buffer size specified by McGetDataOfSize.
+/// \~english @par
+/// This API does not distinguish between error and no data.
+/// \~english @par
+/// The parameter data of this API must be the data obtained from the message queue by McReceive, etc.
+/// (Since the data obtained from the message queue incudes header information,
+/// this API acquires necessary iformation from the header)
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McReceive, McReceiveWithSession, McGetDataOfSize
+////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 McGetLength(PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetDataPointer
+/// \~english @par Brief
+/// Get header address of data from received message.
+/// \~english @param[in] data
+/// PVOID - received message data
+/// \~english @retval PVOID - data address of received message
+/// \~english @par Preconditons
+/// Message is received by McReceive and so on.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Data of received message(data) is NULL. [NULL]
+/// \~english @par Detail
+/// Get header address of data from received message excepting the header and system information.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - Since the pointer acquired by this API is part of the received message passed as an argument to this API,
+/// the pointer must not be released by specifying he address acquired by this API.
+/// - The parameter data of this API must be the data obtained from the message queue by McReceive, etc.
+/// (Since the data obtained from the message queue incudes header information,
+/// this API acquires necessary iformation from the header)
+/// - When the next message is received, the internally held data is discarded.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McReceive, McReceiveWithSession, McGetDataOfSize
+////////////////////////////////////////////////////////////////////////////////////////////
+PVOID McGetDataPointer(PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetDataOfSize
+/// \~english @par Brief
+/// Get the message data, this may be from a queue or shared memory where the maximum
+/// size of the data should not exceed the maximum size passed in.
+/// And deletes the data if it is stored in shared memory.
+/// \~english @param[in] data
+/// PVOID - pointer to the data was received from the McReceive Call
+/// \~english @param[in] to
+/// PVOID - pointer to the data to be received
+/// \~english @param[in] uiSize
+/// UI_32 - maximum size of the buffer to which the received data is copied
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK - success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType - invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusErrOther - invalid shared memory ID specified by received message
+/// \~english @par Preconditons
+/// - Message is received by McReceive and so on.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size specified by argument(uiSize) is smaller then size of received message data(data).
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Data of received message(data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Pointer to buffer(to) which is used to storage data getted from message is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Received message data specified by argument(data) is invalid. [eFrameworkunifiedStatusInvldHndlType]
+/// - Failed to access(shm_open/fstat/mmap) the shared memory of received message data(data).
+/// [eFrameworkunifiedStatusErrOther]
+/// - Shared memory ID specified by received message is invalid. [FrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Get data from received message excepting the header and system information.
+/// Delete data storaged in shared memory after getting the data successfully.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - In the case where he received message data becomes 0byte, there is no need to call this API,
+/// and be careful not to allocate the memory for the received message data by 0byte.
+/// - Error details related to shared memory access canno be detected.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McGetLength
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McGetDataOfSize(PVOID data, PVOID to, UI_32 uiSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetDataOfSizeWithSMRetain
+/// \~english @par Brief
+/// Get the message data, this may be from a queue or shared memory where the maximum
+/// size of the data should not exceed the maximum size passed in.
+/// Does not delete the data if it is stored in shared memory.
+/// \~english @param[in] data
+/// PVOID - pointer to the data was received from the McReceive Call
+/// \~english @param[in] to
+/// PVOID - pointer to the data to be received
+/// \~english @param[in] uiSize
+/// UI_32 - maximum size of the buffer to which the received data is copied
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK - success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType - invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusErrOther - invalid shared memory ID specified by received message
+/// \~english @par Preconditons
+/// - Message is received by McReceive and so on.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Size specified by argument(uiSize) is smaller then size of received message data(data).
+/// [eFrameworkunifiedStatusInvldBufSize]
+/// - Data of received message(data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Pointer to buffer(to) which is used to storage data getted from message is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Received message data specified by argument(data) is invalid. [eFrameworkunifiedStatusInvldHndlType]
+/// - Failed to access(shm_open/fstat/mmap) the shared memory of received message data(data).
+/// [eFrameworkunifiedStatusErrOther]
+/// - Shared memory ID specified by received message is invalid. [FrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// Get data from received message excepting the header and system information.
+/// Does not delete data storaged in shared memory after getting the data successfully.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - In the case where he received message data becomes 0byte, there is no need to call this API,
+/// and be careful not to allocate the memory for the received message data by 0byte.
+/// - Error details related to shared memory access canno be detected.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// McReceive
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McGetDataOfSizeWithSMRetain(PVOID data, PVOID to, UI_32 uiSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetSysInfoData
+/// \~english @par Brief
+/// Gets the data from system info buffer from message header.
+/// \~english @param[in] data
+/// PVOID - pointer to the data was received from the McReceive Call
+/// \~english @param[out] to
+/// PVOID - pointer to the data to be received
+/// \~english @retval EFrameworkunifiedStatus indicates if the close was successfully
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid handle
+/// \~english @par Preconditons
+/// Message is received by McReceive and so on.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Data of received message(data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Pointer to buffer(to) which is used to storage system info getted from message is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Received message data specified by argument(data) is invalid. [eFrameworkunifiedStatusInvldHndlType]
+/// \~english @par Detail
+/// Gets system info from received message, and set argument(to) with it. \n
+/// If there is no system info in received message,and set argument(to) with "\0".
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - The parameter data of this API must be the data obtained from the message queue by McReceive, etc.
+/// (Since the data obtained from the message queue incudes header information,
+/// this API acquires necessary iformation from the header)
+/// - Since the system information is 64 bytes (including the null character), the area of 64 byte must be allocated in the argument to fo this API.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McReceive, McReceiveWithSession
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McGetSysInfoData(PVOID data, PVOID to);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McClearData
+/// \~english @par Brief
+/// Clears the data that may be pending for the a message in shared memory.
+/// \~english @param[in] data
+/// PVOID - pointer to the data was received from the McReceive Call
+/// \~english @retval EFrameworkunifiedStatus indicates if the data was clear successfully
+/// \~english @retval eFrameworkunifiedStatusOK - success
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldParam - invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldID - invalid ID
+/// \~english @retval eFrameworkunifiedStatusFail - other errors
+/// \~english @par Preconditons
+/// - Message is received by McReceive and so on.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Data of received message(data) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Received message data specified by argument(data) is invalid. [eFrameworkunifiedStatusInvldParam]
+/// - Shared memory ID in received message is invalid. [eFrameworkunifiedStatusInvldParam]
+/// - Shared memory specified by ID in received message does not exist. [eFrameworkunifiedStatusInvldID]
+/// - Failed to delete shared memory specified by ID in received message. [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Delete data from received message.
+/// And delete the received message data if it is stored in shared memory.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McReceive, McReceiveWithSession
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McClearData(PVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McSend
+/// \~english @par Brief
+/// Sends data to a message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \~english @param[in] source
+/// PCSTR - app (You) the sender
+/// \~english @param[in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \~english @param[in] length
+/// UI_32 - length of the data buffer provided
+/// \~english @param[in] data
+/// PCVOID - pointer to the data to be sent
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK - Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer - NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType - Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName - Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull - Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF I- nvalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR - An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail - Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther - other errors(Failed to open/allocate shared memory)
+/// \~english @retval eFrameworkunifiedStatusInvldParam - Invalid parameter
+/// \~english @par Preconditons
+/// - Message queue(McOpenSender) for sending message is created.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Message queue name of HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue name of HANDLE specified in the argument (hService) exceeds 20byte. [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Application name of sender specified in the argument (source) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Application name of sender specified in the argument (source) exceeds 20byte. [eFrameworkunifiedStatusInvldQName]
+/// - Sender data does not match sender data size(size is larger then 0, and data is NULL). [eFrameworkunifiedStatusInvldBuf]
+/// - Message queue type of handle specified by argument(hMessage) is not sending type. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - An interrupt is generated by the system call (signal) when sending message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of buffer for sending message is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// - Some errors occur, when sending message. [eFrameworkunifiedStatusFail]
+/// - Failed to access(shm_open/ftruncate/mmap) the shared memory for sending message data. [eFrameworkunifiedStatusErrOther]
+/// - Sending data size specified in the argument (length) is out of range. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// It is an asynchronous API. It provides function to send message by message queue. \n
+/// Message queue name created by McOpenSender is the sender.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// Command ID must be within the range PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD(0x10) to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD(0xFFFFFFF0).
+/// Even if a command ID out of range is specified, a message is sent by the command ID (no erro occurs).
+/// Command ID out of range are resered ID used for session connection, etc.
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - The maximum transmission data size (ength) described above is a theoretical value,
+/// and the maximum actually usable data size depends on the environment requirements.\n
+/// The maximum value is the upper limit of the type (UNIT_MAX) minus the following size.\n
+/// Message header section \n
+/// - Operation cannot be guaranteed when the size of the allocated area indicated by the address
+/// of the pointer (data) to the data buffer does not match the size specified by the size of the data buffer (length).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McSendWithSession, McReceive
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McSend(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McSendWithSession
+/// \~english @par Brief
+/// Sends data to a message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \~english @param[in] source
+/// PCSTR - app (You) the sender
+/// \~english @param[in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \~english @param[in] length
+/// UI_32 - length of the data buffer provided
+/// \~english @param[in] data
+/// PCVOID - pointer to the data to be sent
+/// \~english @param[in] sessionid
+/// UI_32 - session id
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK - Success
+/// \~english @retval eFrameworkunifiedStatusNullPointer - NULL pointer specified
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType - Invalid type of handle
+/// \~english @retval eFrameworkunifiedStatusInvldQName - Illegal Message Queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull - Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF - Invalid File-Descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR - An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - Invalid buffer-size
+/// \~english @retval eFrameworkunifiedStatusFail - Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther - other errors(Failed to open/allocate shared memory)
+/// \~english @retval eFrameworkunifiedStatusInvldParam - Invalid parameter
+/// \~english @par Preconditons
+/// - Message queue(McOpenSender) for sending message is created.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Message queue HANDLE in HANDLE specified in the argument (hService) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - HANDLE specified in the argument message queue HANDLE in (hService) is not appropriate (which is invalid).
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Application name of sender specified in the argument (source) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Application name of sender specified in the argument (source) exceeds 20byte. [eFrameworkunifiedStatusInvldQName]
+/// - Sender data does not match sender data size(size is larger then 0, and data is NULL). [eFrameworkunifiedStatusInvldBuf]
+/// - Message queue type of handle specified by argument(hMessage) is not sending type. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor for sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - An interrupt is generated by the system call (signal) when sending message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of buffer for sending message is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// - Some errors occur, when sending message. [eFrameworkunifiedStatusFail]
+/// - Failed to access(shm_open/ftruncate/mmap) the shared memory for sending message data. [eFrameworkunifiedStatusErrOther]
+/// - Sending data size specified in the argument (length) is out of range. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// It is an asynchronous API. It provides function to send message by message queue. \n
+/// Message queue name created by McOpenSender is the sender.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// Command ID must be within the range PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD(0x10) to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD(0xFFFFFFF0).
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - McSend should be used if no sessionid is specified.
+/// - To communicate with an application that uses NS Framework Dispatcher, use FrameworkunifiedSendMsg, etc.
+/// - The maximum transmission data size (length) described above is a theoretical value,
+/// and the maximum actually usable data size depends on the environment requirements.\n
+/// - The maximum value is the upper limit of the type (UNIT_MAX) minus the following size.\n
+/// Message header section\n
+/// - Operation cannot be guaranteed when the size of the allocated area indicated by the address
+/// of the pointer (data) to the data buffer does not match the size specified by the size of the data buffer (length).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McSend, McReceiveWithSession, FrameworkunifiedSendMsg
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McSendWithSession(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data, UI_32 sessionid);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McSendWithPriority
+/// \~english @par Brief
+/// Sends data to a message queue, inserts based on priority given.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \~english @param[in] source
+/// PCSTR - app (You) the sender
+/// \~english @param[in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \~english @param[in] length
+/// UI_32 - length of the data buffer provided
+/// \~english @param[in] data
+/// PCVOID - pointer to the data to be sent
+/// \~english @param[in] sessionid
+/// UI_32 - session id
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK(success)
+/// \~english @retval eFrameworkunifiedStatusFail(anything else)
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hMessage) or hMessage is NULL.
+/// - It is an incorrect value(source) or hMessage is NULL.
+/// - It is an incorrect value(data) or hMessage is NULL.
+/// - It is an incorrect value(priority).
+/// - It is an incorrect value(sessionid).
+/// \~english @par Detail
+/// Invoke callback function with arguments to send data to message queue based on priority given.\n
+/// If callback function is null and expectedCalls is '0', using default function 'McSendWithPriority' to send
+/// data to message queue based on priority given.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// Command ID must be within the range PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD(0x10) to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD(0xFFFFFFF0).
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - McSend should be used if no sessionid is specified.
+/// - To communicate with an application that uses NS Framework Dispatcher, use FrameworkunifiedSendMsg, etc.
+/// - The maximum transmission data size (length) described above is a theoretical value,
+/// and the maximum actually usable data size depends on the environment requirements.\n
+/// The maximum value is the upper limit of the type (UNIT_MAX) minus the following size.\n
+/// Message header section\n
+/// - Operation cannot be guaranteed when the size of the allocated area indicated by the address
+/// of the pointer (data) to the data buffer does not match the size specified by the size of the data buffer (length).
+/// \~english @par
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+// McOpenSender, McSend, McSendWithSession, FrameworkunifiedSendMsg
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McSendWithPriority(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data,
+ EFrameworkunifiedMessagePriorties priority, UI_32 sessionid);
+
+// EFrameworkunifiedStatus McSendWithPriorityWithSession(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 length, PCVOID data,
+// EFrameworkunifiedMessagePriorties priority, UI_32 sessionid);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McInvokeSync
+/// \~english @par Brief
+/// Synchronous Invoke. Send data to message queue, and Receive data from message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \~english @param[in] source
+/// PCSTR - app (You) the sender
+/// \~english @param[in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \~english @param[in] msgLength
+/// UI_32 - length of the data buffer provided
+/// \~english @param[in] msgData
+/// PCVOID - pointer to the data to be sent
+/// \~english @param[in] sessionid
+/// UI_32 - session ID
+/// \~english @param[in] hRcvMessage
+/// HANDLE - handle to the receive message queue, McOpenSyncReceiver
+/// \~english @param[in] responseLength
+/// UI_32 - length of the responnce receive buffer provided
+/// \~english @param[out] responseData
+/// PVOID - pointer to the data to be receive
+/// \~english @param[out] receivedLength
+/// UI_32* - length of the data to be receive
+/// \~english @retval EFrameworkunifiedStatus indicates invoke response or message sent error or response receive error
+/// \~english @retval eFrameworkunifiedStatusOK - success
+/// \~english @retval eFrameworkunifiedStatusInvldParam - Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - Invalid handle
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType - Invalid handle type
+/// \~english @retval eFrameworkunifiedStatusInvldQName - Invalid message queue name
+/// \~english @retval eFrameworkunifiedStatusMsgQFull - Message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF - Invalid file descriptor
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR - An interrupt is generated by the system call (signal)
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - Invalid buffer size
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - Invalid buffer
+/// \~english @retval eFrameworkunifiedStatusBadConnection - Can't connect with Socket
+/// \~english @retval eFrameworkunifiedStatusFail - Some sort of error occurred
+/// \~english @retval eFrameworkunifiedStatusErrOther - other errors(Failed to open/allocate shared memory)
+/// \~english @par Preconditons
+/// - Message queue specified by argument hMessage and hRcvMessage is useful.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - Message queue handle specified in the argument (hMessage) for sending message is NULL.
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue handle specified in the argument (hMessage) for sending message is not appropriate (which is
+/// invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue handle specified in the argument (hRcvMessage) for receiving message is NULL.
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Message queue handle specified in the argument (hRcvMessage) for receiving message is not appropriate (which
+/// is invalid). [eFrameworkunifiedStatusInvldHandle]
+/// - Size of buffer(responseLength) which is used to storage received message is not 0,
+/// but the pointer to this buffer(responseData) is NULL. [eFrameworkunifiedStatusInvldHandle]
+/// - Failed to create buffer to storage the response message. [eFrameworkunifiedStatusFail]
+/// - Failed to generete random number of the sequence ID for sending message. [eFrameworkunifiedStatusFail]
+/// - Data size of sending message is not 0, but the message data(msgData) is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Application name of sender specified in the argument (source) is NULL. [eFrameworkunifiedStatusInvldQName]
+/// - Application name of sender specified in the argument (source) exceeds 20byte. [eFrameworkunifiedStatusInvldQName]
+/// - Name of message queue handle specified in the argument (hMessage) for sending message is NULL.
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Name of message queue handle specified in the argument (hMessage) for sending message exceeds 20byte.
+/// [eFrameworkunifiedStatusInvldHandle]
+/// - Size of sending message specified in the argument is not 0,
+/// but the pointer to sending message is NULL. [eFrameworkunifiedStatusInvldBuf]
+/// - Message queue type of handle specified by argument(hMessage) is not sending type. [eFrameworkunifiedStatusInvldHndlType]
+/// - Message queue for sending message is full. [eFrameworkunifiedStatusMsgQFull]
+/// - File descriptor of message queue for sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - An interrupt is generated by the system call (signal) when sending message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of buffer for sending message is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// - Some errors occur, when sending message. [eFrameworkunifiedStatusFail]
+/// - Failed to access the shared memory for sending message data. [eFrameworkunifiedStatusErrOther]
+/// - Failed to connect with the socket(socket/bind/connect) for checking the connection with application of
+/// sender. [eFrameworkunifiedStatusFail]
+/// - Failed to wait(epoll_create/epoll_ctl/epoll_wait) for receiving response message. [eFrameworkunifiedStatusFail]
+/// - Failed to reconnect with the socket(socket/bind/connect) for checking the connection with application of
+/// sender. [eFrameworkunifiedStatusBadConnection]
+/// - Application name of sender in response message exceeds 20byte.[eFrameworkunifiedStatusInvldBuf]
+/// - Message queue type of handle specified by argument(hMessage) is not receiving type.
+/// [eFrameworkunifiedStatusInvldHndlType]
+/// - File descriptor of message queue for receiving message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
+/// - An interrupt is generated by the system call (signal) when receiving message. [eFrameworkunifiedStatusErrNoEINTR]
+/// - Size of buffer for receiving message is invalid. [eFrameworkunifiedStatusInvldBufSize]
+/// - Received message is storaged in shared memory, but data size of shared memory is 0. [eFrameworkunifiedStatusErrOther]
+/// - Failed to create buffer(calloc) to storage date getted from shared memory. [eFrameworkunifiedStatusFail]
+/// - Failed to access(shm_open/fstat/mmap) the shared memory for receiving message data. [eFrameworkunifiedStatusErrOther]
+/// - Data size of received message specified by argument(receivedLength) is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - Sending data size specified in the argument (msgLength) is out of range. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// It provides synchronous communication for message queue between sender and receiver specified in the
+/// argument. \n
+/// As it is a synchronous function, after sending a message, the sender will wait until getting response form
+/// receiver.
+/// After receiving the response, set responseData with the received data and return.
+/// \~english @par
+/// This API provides the inter-process communication function by the message queue for the application
+/// which does not use the inter-process communication by NS Framework Dispatcher.
+/// \~english @par
+/// When data larger than the receive message storage buffer size (resposeLength) is received,
+/// the write size to the receive message storage buffer (responseData) does not exceed the specified size,
+/// but the receive size is set in the receive message data length (recievedLength) as is.
+/// \~english @par
+/// The caller must guarantee the allocation of the receive message storage buffer (resonseData) area
+/// and the consistency of the receive message stoage buffer sizes (resposeLength).
+/// \~english @par
+/// Please note the following points when using this API for application.
+/// - This API stores up to the storage buffer length (responseLength) and returs eFrameworkunifiedStatusOK even
+/// if the received reply message is larger than the storage buffer (responseData) size.\n
+/// Therefore, the application shoud compare the received message length (recievedLenght) and the storage buffer length (responseLength) even
+/// if this API returns eFrameworkunifiedStatusOK, and detect the above.
+/// - Specify 0 for the sessionid of argument.
+/// If a value other than 0 is specified, no error occurs and the value is used as is.
+/// - To communicate with an application that uses NS Framework Dispatcher, use FrameworkunifiedInvokeSync, etc.
+/// - The maximum data lenght (msgLength) of sent messages is a theoretical value,
+/// and the maximum value that can be actually used is environment-depedent.\n
+/// The maximum value is the upper limit of the type (UNIT_MAX) minus the following size.\n
+/// Message header section, System information department in messages\n
+/// - Operation cannot be guaranteed when the size of the allocated area indicated by the address
+/// of the pointer (msgData) to the data buffer does not match the size specified by the size of the data buffer (msgLength).
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McOpenSyncReceiver, FrameworkunifiedInvokeSync
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McInvokeSync(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 msgLength, PCVOID msgData, UI_32 sessionid,
+ HANDLE hRcvMessage, UI_32 responseLength, PVOID responseData, UI_32 *receivedLength);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McSendSyncResponse
+/// \~english @par Brief
+/// Sends response to a message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSyncSender
+/// \~english @param[in] source
+/// PCSTR - app (You) the sender
+/// \~english @param[in] cmd
+/// UI_32 - command id aka the message that's being sent
+/// \~english @param[in] seq_id
+/// UI_32 - response sequence ID
+/// \~english @param[in] ret_val
+/// EFrameworkunifiedStatus - response status
+/// \~english @param[in] length
+/// UI_32 - length of the data buffer provided
+/// \~english @param[in] data
+/// PCVOID - pointer to the data to be sent
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - If handle is NULL or invalid
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType -if handle type is invalid
+/// \~english @retval eFrameworkunifiedStatusInvldQName - if MQ name is invalid
+/// \~english @retval eFrameworkunifiedStatusMsgQFull - if MQ is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF - if fd is invalid
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR - if system call(signal) interupt occurs
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize -if buffer size is invalid
+/// \~english @retval eFrameworkunifiedStatusInvldBuf -if buffer is invalid
+/// \~english @retval eFrameworkunifiedStatusFail - any other error
+/// \~english @retval eFrameworkunifiedStatusErrOther -other error(memory open/allocate fail)
+/// \~english @par Preconditons
+/// - The message queue specified by argument hMessage of this API must be allocated
+/// in advance by McOpenSender and McOpenSyncSender.
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - sending MQ handle(designated by parameter)is NULL[eFrameworkunifiedStatusInvldHandle]
+/// - sending MQ handle(designated by parameter)is invalid[eFrameworkunifiedStatusInvldHandle]
+/// - the type of sending MQ handle(designated by parameter)is not sending type[eFrameworkunifiedStatusInvldHndlType]
+/// - application name(source,designated by parameter)is NULL[eFrameworkunifiedStatusInvldQName]
+/// - the length of application name(designated by parameter)is over 20byte[eFrameworkunifiedStatusInvldQName]
+/// - sending data not in accordance with the size of sending data(eg:size is not 0 but data is NULL)
+/// [eFrameworkunifiedStatusInvldBuf]
+/// - sending data MQ is full [eFrameworkunifiedStatusMsgQFull]
+/// - fd of sending data MQ is invalid [eFrameworkunifiedStatusErrNoEBADF]
+/// - system call(signal) interupt occurs during MQ receiveing process[eFrameworkunifiedStatusErrNoEINTR]
+/// - the size of receiveing MQ buffer is invalid[eFrameworkunifiedStatusInvldBufSize]
+/// - error occurs during MQ receiveing process [eFrameworkunifiedStatusFail]
+/// - failed to access shared memmory for sending message[eFrameworkunifiedStatusErrOther]
+/// - failed to allocate buffer for data retriving from shared memmory[eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// set the response data to buffer and call this API
+/// when need to response to synchronous message get from synchronous communication(McInvokeSync)
+/// \~english @par
+/// This API applies communication function(using message queue)between processes to the application which do not
+/// use
+/// Dispatcher of NS Framework
+/// \~english @par
+/// cautions when using this API
+/// - Use FrameworkunifiedSetSyncResponseData if communacate with application which use the Dispatcher of NS Framework\n
+/// - the limit of size for sending data is according to system
+/// but the total size of SSystemMsgHeader and ResponseHeader shared memmory header is 48byte
+/// size limit should be(UINT_MAX-48byte)
+/// - operation is not guaranteed if the size which shown in data buffer pointer(data) is not in
+/// accordance with the length set in data buffer
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McOpenSyncReceiver, McInvokeSync, FrameworkunifiedSetSyncResponseData
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McSendSyncResponse(HANDLE hMessage, PCSTR source, UI_32 cmd, UI_32 seq_id, EFrameworkunifiedStatus ret_val, UI_32 length,
+ PCVOID data);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McCreateInvokerName
+/// \~english @par Brief
+/// Create synchronous invoke response MQ name.
+/// \~english @param[in] source
+/// PCSTR - source service name
+/// \~english @param[in] sessionid
+/// UI_32 - session id
+/// \~english @param[in] invokerName
+/// PSTR - create invoker name buffer
+/// \~english @param[in] size
+/// UI_32 - InvokerName buffer size
+/// \~english @retval EFrameworkunifiedStatus indicates if the close was successfully
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusInvldParam -if parameter is invalid
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - sender application name(source,designated by parameter) is NULL[eFrameworkunifiedStatusInvldParam]
+/// - synchronous communication MQ name(invokerName,designated by parameter) is NULL[eFrameworkunifiedStatusInvldParam]
+/// - the size of synchronous communication MQ name buffer(designated by parameter)is NULL[eFrameworkunifiedStatusInvldParam]
+/// \~english @par Detail
+/// This API will add specific letters to the end of sender application name and return it as synchronous
+/// communication MQ name
+/// This name will be used when application create the MQ through McOpenSyncReceiver
+/// \~english @par
+/// cautions when using this API:
+/// - the synchronous communication MQ name(invokerName) buffer size should be larger than the length of source
+/// application
+/// name(at least 4byte larger)
+/// - source application name(designated by parameter) should be less than 15byte(according to NS framework
+/// spec,error occurs
+/// if message name length is over 20byte
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSyncReceiver
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McCreateInvokerName(PCSTR source, UI_32 sessionid, PSTR invokerName, UI_32 size);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McClose
+/// \~english @par Brief
+/// Close a connection to a Receiver message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle that will be closed
+/// \~english @retval EFrameworkunifiedStatus indicates if the close was successfully
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - If hMessage is NULL or invalid
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType - if hMessage is invalid
+/// \~english @par Preconditons
+/// message queue(McOpenSender, McOpenReceiver) is created in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(hMessage,designated by parameter) is NULL[eFrameworkunifiedStatusInvldHandle]
+/// - handle(hMessage,designated by parameter) is invalid[eFrameworkunifiedStatusInvldHandle]
+/// - the type of handle(designated by parameter) is neither sending or receiveing[eFrameworkunifiedStatusInvldHndlType]
+/// - fail to close the message queue(mq_close)[eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// close the message sending or receiveing message queue which is designated by parameter\n
+/// Application can call this API to close the message queue which is created by McOpenSender
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McOpenReceiver, McOpenSyncReceiver
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McClose(HANDLE hMessage);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetDataUSID
+/// \~english @par Brief
+/// Get the USID is the Unique Shared Memory ID.e. from the message that was received.
+/// \~english @param[in] pData
+/// void* - pointer to the data was received from the McReceive Call
+/// \~english @retval TMemID Type of memory buffer identifiers(unsigned int).
+/// \~english @retval NoneZero(Success)
+/// \~english @retval Zero(Failed)
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(pData) or pData is NULL.
+/// \~english @par Detail
+/// Invoke callback function with arguments to get the USID from the message that was received.\n
+/// If callback function is null and expectedCalls is '0', using default function 'McGetDataUSID' to get the USID
+/// from the message that was received.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+// FrameworkunifiedGetDataUSID, FrameworkunifiedForwardMessage
+//////////////////////////////////////////////////////////////////////////////////////////////
+TMemID McGetDataUSID(PVOID pData);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetMsgSrc
+/// \~english @par Brief
+/// Gets the constant pointer to source message queue.
+/// \~english @param[in] data
+/// PVOID - pointer to the data to be received
+/// \~english @retval PCSTR message queue's address
+/// CONST char* - constant pointer to source message queue
+/// \~english @retval NotNull(Success)
+/// \~english @retval Null(Failed)
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(data) or data is NULL.
+/// \~english @par Detail
+/// Invoke callback function with arguments to get the constant pointer to source message queue.\n
+/// If callback function is null and expectedCalls is '0', using default function 'McGetMsgSrc' to the constant
+/// pointer to source message queue.\n
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+// frameworkunifiedSendSyncResponse, frameworkunifiedProcessSyncResponse
+//////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR McGetMsgSrc(PVOID data);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McForward
+/// \~english @par Brief
+/// Forward a Message to indicate that there is a Shared Memory
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the send message queue, McOpenSender
+/// \~english @param[in] source
+/// PCSTR - the sender of this forwarding message.
+/// \~english @param[in] iCmd
+/// UI_32 - Command Id message to forward
+/// \~english @param[in] USID
+/// UI_32 - Unique Shared memory Id
+/// \~english @retval EFrameworkunifiedStatus indicates if the close was successfully
+/// CONST char* - constant pointer to source message queue
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Failed(anything else)
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hMessage) or hMessage is NULL.
+/// - It is an incorrect value(source) or source is NULL.
+/// - It is an incorrect value(iCmd).
+/// - It is an incorrect value(USID).
+/// \~english @par Detail
+/// Invoke callback function with arguments to forward a Message.\n
+/// If callback function is null and expectedCalls is '0', using default function 'McForward' to forward a
+/// Message.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+// FrameworkunifiedForwardMessage
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McForward(HANDLE hMessage, PCSTR source, UI_32 iCmd, TMemID USID);
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McFlushReceiver
+/// \~english @par Brief
+/// Flush's all data on HANDLE's Receiver message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the recvMessage queue that will be flushed
+/// \~english @retval void
+/// \~english @par Preconditons
+/// message queue(McOpenReceiver)is created in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(hMessage,designated by parameter) is NULL
+/// - handle(hMessage,designated by parameter) is invalid [-1]
+/// - the type of handle(designated by parameter) is neither sending or receiveing[-1]
+/// \~english @par Detail
+/// message will not be flushed if process failed
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenSender, McOpenReceiver, McOpenSyncReceiver
+////////////////////////////////////////////////////////////////////////////////////////////
+void McFlushReceiver(HANDLE hMessage);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetQueueName
+/// \~english @par Brief
+/// Gets the name of the message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle of the message queue,
+/// (handle created with McOpenReceiver or McOpenSender)
+/// \~english @retval PCSTR name - name of the message queue if handle is valid else NULL
+/// \~english @par Preconditons
+/// Dispatcher for application should be created and initilized(FrameworkunifiedCreateDispatcherWithoutLoop)in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(hMessage,designated by parameter) is NULL
+/// - handle(hMessage,designated by parameter) is invalid [-1]
+/// - the type of handle(designated by parameter) is neither sending or receiveing[-1]
+/// \~english @par Detail
+/// return the name of specific message queue
+/// this APL is used for application to supervize message queue
+/// \~english @par
+/// This API applies communication function(using message queue)between processes to the application which do not
+/// use
+/// Dispatcher of NS Framework
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenReceiver, McOpenSender
+////////////////////////////////////////////////////////////////////////////////////////////
+PCSTR McGetQueueName(HANDLE hMessage);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McGetQueueFD
+/// \~english @par Brief
+/// Gets the fd of the message queue.
+/// \~english @param[in] hMessage
+/// HANDLE - handle of the message queue.(handle created with McOpenReceiver or McOpenSender)
+/// \~english @retval int fd - fd of the message queue if handle is valid else -1
+/// \~english @par Preconditons
+/// - Dispatcher for application is created and initialized(FrameworkunifiedCreateDispatcherWithoutLoop) in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(hMessage,designated by parameter) is NULL
+/// - handle(hMessage,designated by parameter) is invalid [-1]
+/// - the type of handle(designated by parameter) is neither sending or receiveing[-1]
+/// \~english @par Detail
+/// return the fd of specific message queue
+/// this APL is used for application to supervize message queue
+/// \~english @par
+/// This API applies communication function(using message queue)between processes to the application which do not
+/// use
+/// Dispatcher of NS Framework
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McOpenReceiver, McOpenSender
+////////////////////////////////////////////////////////////////////////////////////////////
+int McGetQueueFD(HANDLE hMessage);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McTranslateError
+/// \~english @par Brief
+/// Translates global error variables into FW EFrameworkunifiedStatus
+/// \~english @param[in] error
+/// int - error variable
+/// \~english @retval EFrameworkunifiedStatus indicates frameworkunified error type
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(error).
+/// \~english @par Detail
+/// Invoke callback function with arguments to translates global error variables.\n
+/// If callback function is null and expectedCalls is '0', using default function 'McTranslateError' to translates
+/// global error variables.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+// none
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McTranslateError(int error);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McZcSetParam
+/// \~english @par Brief
+/// set variable parameter to messeg-sending header
+/// \~english @param[in] handle
+/// HANDLE - handle to the send message queue, McZcOpenSender
+/// \~english @param[in] cmd
+/// UI_32 -cmd for sending(ID to identify protocol of service)
+/// \~english @param[in] length
+/// UI_32 -size of buffer for message-sending
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was set successfully
+/// \~english @retval eFrameworkunifiedStatusOK sucess
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - If hMessage is NULL or invalid
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - invalid buffer
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize - invalid buffer size
+/// \~english @par Preconditons
+/// message queue is created by McZcOpenSender in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(designated by parameter) is NULL[NULL]
+/// - handle(designated by parameter) is invalid [NULL]
+/// - the buffer for sending in handle(designated by parameter) is NULL[NULL]
+/// - the size of data for sending(designated by parameter)(except header) is larger than the size of
+/// sending-buffer[eFrameworkunifiedStatusInvldBufSize]
+/// \~english @par Detail
+/// set the variable sending cmd and sending data length in sending buffer of message-sending handle
+/// This API will only do the initialization of message header.detail setting of data for sending will be done\n
+/// Application can use McZcGetBuf to do data setting
+/// \~english @par
+/// CMD ID should be in (PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD(0x10) to PROTOCOL_FRAMEWORKUNIFIED_MAX_CMD(0xFFFFFFF0))
+/// \~english @par
+/// cautions when using this API
+/// - detail data sending size should be in accordance with the data sending size which is set in this API
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McZcGetBuf, McZcSend
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McZcSetParam(HANDLE handle, UI_32 cmd, UI_32 length);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McZcGetBuf
+/// \~english @par Brief
+/// get the fist address of buffer for sending
+/// \~english @param[in] handle
+/// HANDLE - handle to the send message queue, McZcOpenSender
+/// \~english @retval PVOID the first address of buffer for data-sending
+/// \~english @retval NULL NULL pointer(fail to get)
+/// \~english @par Preconditons
+/// message queue is created by McZcOpenSender in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(designated by parameter) is NULL[NULL]
+/// - handle(designated by parameter) is invalid [NULL]
+/// - the buffer for sending in handle(designated by parameter) is NULL[NULL]
+/// \~english @par Detail
+/// get the first address of data(excpet the message-header)from sending-buffer in message-sending handle
+/// application will set the address got as sending message
+/// \~english @par
+/// cautions When using the application
+/// - result will not be guaranteed if the handle set is different from message-sending queue handle
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McZcGetBuf
+////////////////////////////////////////////////////////////////////////////////////////////
+PVOID McZcGetBuf(HANDLE handle);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McZcSend
+/// \~english @par Brief
+/// send message
+/// \~english @param[in] hMessage
+/// HANDLE - handle to the sendMessage, McZcOpenSender
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was sent successfully
+/// \~english @retval eFrameworkunifiedStatusOK success
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - If hMessage is NULL or invalid
+/// \~english @retval eFrameworkunifiedStatusInvldBuf - buffer is invalid
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType -handle type is invalid
+/// \~english @retval eFrameworkunifiedStatusMsgQFull - message queue is full
+/// \~english @retval eFrameworkunifiedStatusErrNoEBADF - file descriptor invalid
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR -system call(signal) interupt
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize -invalid buffer size
+/// \~english @par Preconditons
+/// message queuqe is created by McZcOpenSender
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - handle(hMessage,designated by parameter)is NULL[eFrameworkunifiedStatusInvldHandle]
+/// - handle(hMessage,designated by parameter)is invalid[eFrameworkunifiedStatusInvldHandle]
+/// - the sending-buffer in handle(hMessage,designated by parameter)is NULL[eFrameworkunifiedStatusInvldBuf]
+/// - the type of message queue in handle(hMessage,designated by parameter)is not sending
+/// type[eFrameworkunifiedStatusInvldHndlType]
+/// - message-sending queue is full[eFrameworkunifiedStatusMsgQFull]
+/// - file descriptor of message-sending queue is invalid[eFrameworkunifiedStatusErrNoEBADF]
+/// - system call(singal) interupts during the message sending process[eFrameworkunifiedStatusErrNoEINTR]
+/// - the size of buffer for message-sending is invalid[eFrameworkunifiedStatusInvldBufSize]
+/// \~english @par Detail
+/// send message using specific message-sending handle.\n
+/// data for sending should be set to message-sending handle(hMessage)beforhead using McZcSetParam, McZcGetBuf
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Method
+/// \~english @see McZcOpenSender, McZcSetParam, McZcGetBuf
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McZcSend(HANDLE hMessage);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McZcOpenSender
+/// \~english @par Brief
+/// create message-sending queuqe
+/// \~english @param[in] source
+/// PCSTR - app (You) the sender
+/// \~english @retval Handle for sending messages to a queue (If INVALID_HANDLE is returned its an error)
+/// \~english @retval NULL NULL pointer(fail to get)
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - message queue name(designated by parameter)is NULL[NULL]
+/// - the length of message queue name(designated by parameter)(source) is over 20byte[NULL]
+/// - fail to get memmory for restoring formated message queue name [NULL]
+/// - length of formated message queue name is over 15byte or 16byte(when initial letter is'/')[NULL]
+/// - fail to get message queue(mq_open)[NULL]
+/// - fail to get memmory for message queue info managment(malloc)[NULL]
+/// - fail to get memory for sending buffer[NULL]
+/// \~english @par Detail
+/// create message queuqe and return the handle
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McZcSetParam, McZcGetBuf, McZcSend, McZcClose
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE McZcOpenSender(PCSTR source);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup McZcClose
+/// \~english @par Brief
+/// close the handle to message queue
+/// \~english @param[in] handle
+/// HANDLE - handle to the send message queue, handle got through McZcOpenSender
+/// \~english @retval EFrameworkunifiedStatus indicates if the message was close successfully
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusInvldHandle - If hMessage is NULL or invalid
+/// \~english @retval eFrameworkunifiedStatusInvldHndlType If handle type is invalid
+/// \~english @par Preconditons
+/// - message queue is created by McZcOpenSender in advance
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - message handle(designated by parameters) is NULL[eFrameworkunifiedStatusInvldHandle]
+/// - message handle(designated by parameters) is invalid [eFrameworkunifiedStatusInvldHandle]
+/// - message handle type(designated by parameters) is not match(neither send or receive)[eFrameworkunifiedStatusInvldHndlType]
+/// - fail to close message queue(mq_close)[eFrameworkunifiedStatusInvldHandle]
+/// \~english @par Detail
+/// Close message-sending or message-receiving handle(designated by parameters)\n
+/// application call this function to close message queue which is created by McZcOpenSender.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see McZcOpenSender
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus McZcClose(HANDLE handle);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __NATIVESERVICES_MESSAGE_CENTER_IF_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_msgs.h b/nsframework/framework_unified/client/include/native_service/ns_msgs.h
new file mode 100644
index 00000000..48c83e71
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_msgs.h
@@ -0,0 +1,64 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSMessageCenter
+/// \brief
+///
+/// Header defines the messaging IF header that will be at the start of each message.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MSGS_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MSGS_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_shared_mem_if.h>
+
+#define MC_EMSGT_VALID_TOKEN (0xC8 << 24)
+#define MC_EMSGT_VALID_MASK (0xFF << 24)
+#define MC_EMSGT_VALID(t) ((t & MC_EMSGT_VALID_MASK) == MC_EMSGT_VALID_TOKEN) // NOLINT (readability/nolint)
+
+#define MC_EMSGT_SHM_MASK (0x1 << 0)
+#define MC_EMSGT_IS_SHM(t) (t & MC_EMSGT_SHM_MASK) // NOLINT (readability/nolint)
+
+#define MC_EMSGT_SYNC_MASK (0x1 << 1)
+#define MC_EMSGT_IS_SYNC(t) (t & MC_EMSGT_SYNC_MASK) // NOLINT (readability/nolint)
+
+#define MC_EMSGT_SYSINFO_MASK (0x1 << 2)
+#define MC_EMSGT_HAS_SYSINFO(t) (t & MC_EMSGT_SYSINFO_MASK) // NOLINT (readability/nolint)
+
+#pragma pack(1)
+/// \brief brief description of Messages Header that's pass via Message Center.
+/// Note: Don't remove #paragma pack(1) this is required for the
+/// ARM processor, forces data structures to be on a byte boundary
+/// all messages should be place in between #pragma pack(1) and #pragma pack()
+typedef struct tSysMsgHeader {
+ UI_32 eType; // The type of the message
+ TMemID memId; // Unique MemID of the data stored in shared memory,
+ // this is only valid if eType == IPC_MSG_SHM_TYPE
+ struct {
+ CHAR source[MAX_QUEUE_NAME_SIZE]; // Task that's sending the message.
+ UI_32 command; // The command id of the message
+ UI_32 length; // The length of the complete message in contiguous memory
+ // including the header and data block
+ UI_32 sessionid;
+ } info;
+} SSystemMsgHeader, *PSSystemMsgHeader;
+
+#pragma pack()
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_MESSAGECENTER_INCLUDE_NS_MSGS_H_
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_service.h b/nsframework/framework_unified/client/include/native_service/ns_np_service.h
new file mode 100644
index 00000000..e2a2deb7
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_service.h
@@ -0,0 +1,271 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief Header for message structures for notification_persistent_service.
+///
+/// Declares the external APIs to Notification and Persistence Service.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_np_service.h
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup notification_persistent_service
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef __NATIVESERVICES_NP_SERVICE_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NP_SERVICE_H__
+
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \~english A structure to register notification msg
+ */
+typedef struct _NC_register_notif_msg {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english notification event name string
+ UI_32 maxLength; //!< \~english Maximum possible length (bytes) of
+ // the message data
+ // UI_8 bIsPersistent; ///< Flag to indicate if data has to be persisted.
+ EFrameworkunifiedNotificationType persType; //!< \~english Specifies persitence for this notification
+ UI_8 dummy[4]; //!< \~english Packing to 32 bit boundary
+} NC_register_notif_msg;
+
+/**
+ * \~english A structure to register multiple notification msg
+ */
+typedef struct _NC_register_multiple_notif_msg {
+ UI_32 numNotifications; //!< \~english This has to be UI_32 to avoid holes.
+ NC_register_notif_msg notifierList[1]; //!< \~english variable number of structures
+} NC_register_multiple_notif_msg;
+
+/**
+ * \~english A structure to register immediate notification msg
+ */
+typedef struct _NC_register_immediate_notif_msg {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english Notification Event Name string
+ UI_32 maxLength; //!< \~english Maximum possible length (bytes) of
+ // the message data
+ EFrameworkunifiedNotificationType persType; //!< \~english Specifies persitence for this notification
+ UI_32 delay; //!< \~english Delay time for persistence
+ UI_8 dummy[4]; //!< \~english Packing to 32 bit boundary
+} NC_register_immediate_notif_msg;
+
+/**
+ * \~english A structure to register multiple immediate notification msg
+ */
+typedef struct _NC_register_multiple_immediate_notif_msg {
+ UI_32 numNotifications; //!< \~english This has to be UI_32 to avoid holes.
+ NC_register_immediate_notif_msg notifierList[1]; //!< \~english variable number of structures
+} NC_register_multiple_immediate_notif_msg;
+
+/**
+ * \~english A structure to unregister notification msg
+ */
+typedef struct _NC_unregister_notif_msg {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english Notification Event Name string
+} NC_unregister_notif_msg, NC_subscribe_msg, NC_unsubscribe_frm_notif_msg, NC_get_pers_data_msg;
+
+/**
+ * \~english A structure to unregister multiple notification msg
+ */
+typedef struct _NC_unregister_multiple_notif_msg {
+ UI_32 numNotifications; //!< \~english notification event name num
+ NC_unregister_notif_msg notificationList[1]; //!< \~english notification event name List
+} NC_unregister_multiple_notif_msg;
+
+/**
+ * \~english A structure to save pers data
+ */
+typedef struct _NC_savepersdata_ack {
+ EFrameworkunifiedStatus eStatus; //!< \~english eFrameworkunifiedStatusOK is (valid - data stored, anything else is
+} NC_savepersdata_ack;
+
+/**
+ * \~english A structure to subscribe multiple notification msg
+ */
+typedef struct _NC_subscribe_multiple_notif_msg {
+ UI_32 numNotifications; //!< \~english notification event name num
+ NC_subscribe_msg notificationList[1]; //!< \~english notification event name List
+} NC_subscribe_multiple_notif_msg;
+
+/**
+ * \~english A structure to subscribe multiple notification msg
+ */
+typedef struct _NC_unsubscribe_multiple_notif_msg {
+ UI_32 numNotifications; //!< \~english notification event name num
+ NC_unsubscribe_frm_notif_msg notificationList[1]; //!< \~english notification event name List
+} NC_unsubscribe_multiple_notif_msg;
+
+/**
+ * \~english A structure to get pers data failed
+ */
+typedef struct __NC_get_persdata_failed_ack {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english notification name
+} NC_get_persdata_failed_ack;
+
+/**
+ * \~english A structure to set personality
+ */
+typedef struct _NC_User {
+ CHAR cUsername[MAX_PATH_LENGTH]; //!< \~english name of personality
+} NC_User;
+
+/**
+ * \~english A structure to register persistent file with the notification_persistent_service
+ */
+typedef struct _NC_RegisterPersistentFileMsg {
+ CHAR cFileTag[MAX_STRING_SIZE_TAG]; //!< \~english Tag associated with the
+ // file that would be persisted
+ BOOL bIsUserFile; //!< \~english is user file
+} NC_RegisterPersistentFileMsg;
+
+/**
+ * \~english A structure to specify where to load the file associated with the Tag
+ */
+typedef struct _NC_LoadPersistedFileMsg {
+ CHAR cFileTag[MAX_STRING_SIZE_TAG]; //!< \~english Tag associated with the file
+ CHAR cFilePath[MAX_PATH_LENGTH]; //!< \~english path to which the file needs to retrieved
+ CHAR cUsername[MAX_PATH_LENGTH]; //!< \~english Name of the user for user specific file.
+} NC_LoadPersistedFileMsg;
+
+/**
+ * \~english A structure to release persistent file
+ */
+typedef struct _NC_ReleasePersistentFileMsg {
+ EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType; //!< \~english should the file be persisted
+ CHAR cFilePath[MAX_PATH_LENGTH]; //!< \~english path from which the
+ // file needs to be picked up to persist
+ CHAR cFileTag[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english Tag associated with the
+ // file to be persisted
+ CHAR cUsername[MAX_PATH_LENGTH]; //!< \~english Name of the user for user specific file.
+} NC_ReleasePersistentFileMsg;
+
+/**
+ * \~english A structure to register persistent folder with the notification_persistent_service
+ */
+typedef struct _NC_RegisterPersistentFolderMsg {
+ CHAR cFolderTag[MAX_STRING_SIZE_TAG]; //!< \~english Tag associated with the
+ // folder that would be persisted
+ BOOL bIsUserFolder; //!< \~english Check if the folder is of user type
+} NC_RegisterPersistentFolderMsg;
+
+/**
+ * \~english A structure to specify where to load the folder associated with the Tag
+ */
+typedef struct _NC_LoadPersistedFolderMsg {
+ CHAR cFolderTag[MAX_STRING_SIZE_TAG]; //!< \~english Tag associated with the folder
+ CHAR cFolderPath[MAX_PATH_LENGTH]; //!< \~english path to which the folder needs to retrieved
+ CHAR cUsername[MAX_PATH_LENGTH]; //!< \~english Name of the user for user specific folder.
+} NC_LoadPersistedFolderMsg;
+
+/**
+ * \~english A structure to Release Persistent Folder Msg
+ */
+typedef struct _NC_ReleasePersistentFolderMsg {
+ EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType; //!< \~english should the file be persisted
+ CHAR cFolderPath[MAX_PATH_LENGTH]; //!< \~english path from which the folder
+ // needs to be picked up to persist
+ CHAR cFolderTag[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english Tag associated with
+ // the folder to be persisted
+ CHAR cUsername[MAX_PATH_LENGTH]; //!< \~english Name of the user for user
+ // specific folder.
+} NC_ReleasePersistentFolderMsg;
+
+/**
+ * \~english A structure to Load Persisted Ack
+ */
+typedef struct _NC_LoadPersistedAck {
+ EFrameworkunifiedStatus eStatus; //!< \~english ack the success/failure in
+ // retrieving the file/folder from persistence
+ CHAR cTag[MAX_PATH_LENGTH]; //!< \~english tag of the file/folder for which acknowledge is made
+} NC_LoadPersistedAck, NC_ReleasePersistedAck;
+
+/**
+ * \~english A structure to Nor Persistent Data
+ */
+typedef struct _NC_NorPersistentData {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english Notification Event Name string
+ CHAR pPublisherName[MAX_NAME_SIZE_APP]; //!< \~english Publisher Event Name string
+ UI_32 dataSize; //!< \~english data size
+ UI_32 uiDelay; //!< \~english ui Delay
+ UI_32 uiMaxSize; //!< \~english ui Max Size
+} NC_NorPersistentData;
+
+/**
+ * \~english A structure to request for deleting data from persistent memory
+ */
+typedef struct _NC_ClearPersistedDataReq {
+ EFrameworkunifiedClearPersistence ePersistenceData; //!< \~english defines what
+ // data to be deleted from persistent memory
+} NC_ClearPersistedDataReq;
+
+/**
+ * \~english A structure for receiving ack of data deleted from persistent memory
+ */
+typedef struct _NC_ClearPersisteDatadAck {
+ EFrameworkunifiedStatus eStatus; //!< \~english ack status of ClearPersistedData request
+} NC_ClearPersisteDatadAck;
+
+/**
+ * \~english A structure to request stop message to notification_persistent_service.
+ */
+typedef struct _NC_StopMsgData {
+ EFrameworkunifiedShutdownType eShutdownType; //!< \~english shutdown type
+ UI_32 uiStopMsgData; //!< \~english Reason for sending stop message to NPPService
+} NC_StopMsgData;
+
+/**
+ * \~english A structure to set the persist type of file and folder
+ */
+typedef struct _NC_SetPersistType {
+ EFrameworkunifiedPersistCategory ePersistType; //!< \~english persist type
+ CHAR cTag[MAX_PATH_LENGTH]; //!< \~english tag name of the file or folder
+} NC_SetFilePersistType, NC_SetFolderPersistType;
+
+/**
+ * \~english A data received with ack sent by notification_persistent_service when immediate notification data is
+ * written in persistent memory
+ */
+typedef struct _NC_ImmediateWriteAck {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; //!< \~english notification Name
+ EFrameworkunifiedStatus eStatus; //!< \~english status of request
+} NC_ImmediateWriteAck;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NATIVESERVICES_NP_SERVICE_H__ */ // NOLINT (build/header_guard)
+/** @}*/ // end of notification_persistent_service
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
+// EOF
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_service_if.h b/nsframework/framework_unified/client/include/native_service/ns_np_service_if.h
new file mode 100644
index 00000000..b1889582
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_service_if.h
@@ -0,0 +1,2482 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_np_service_if.h
+ * @brief \~english Declares the external APIs to Notification and Persistence Service.
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup notification_persistent_service
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef __NATIVESERVICES_NP_SERVICE_IF_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NP_SERVICE_IF_H__
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \~english A structure to Notification Info
+ */
+typedef struct _NotificationInfo {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; ///< Notification Event Name string
+ UI_32 maxLength; ///< Maximum possible length (bytes) of the message data
+ EFrameworkunifiedNotificationType persType; ///< Specifies persitence for this notification
+ UI_8 dummy[4]; ///< Packing to 32 bit boundary
+} NotificationInfo;
+
+/**
+ * \~english A structure to Immediate Notification Info
+ */
+typedef struct _ImmediateNotificationInfo {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; ///< Notification Event Name string
+ UI_32 maxLength; ///< Maximum possible length (bytes) of the message data
+ EFrameworkunifiedNotificationType persType; ///< Specifies persitence for this notification
+ UI_32 delay;
+ UI_8 dummy[4]; ///< Packing to 32 bit boundary
+} ImmediateNotificationInfo;
+
+/**
+ * \~english A structure to Subscribe Info
+ */
+typedef struct _SubscribeInfo {
+ CHAR notificationName[MAX_STRING_SIZE_NOTIFICATION]; ///< Notification Event Name string
+} SubscribeInfo;
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPRegisterNotifications
+/// \~english @par Brief
+/// API to send message to Notification Service to register a set of notification
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \~english @param[in] numNotifications
+/// PCSTR - Name of Notification
+/// \~english @param[in] pNotificationArray
+/// NotificationInfo - Array of notifications
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(numNotifications).
+/// - It is an incorrect value(pNotificationArray) or pNotificationArray is NULL.
+/// \~english @par Detail
+/// Invoke callback function with arguments to register a set of notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPRegisterNotifications' to
+/// register a set of notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPRegisterNotification, NPRegisterNotification
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
+ NotificationInfo *pNotificationArray);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPRegisterImmediateNotifications
+/// \~english @par Brief
+/// API to send message to Notification Service to register a set of immediate notifications
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of Publisher message queue.
+/// \~english @param[in] numNotifications
+/// PCSTR - Name of Notification.
+/// \~english @param[in] pNotificationArray
+/// ImmediateNotificationInfo - Array of immediate notifications
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(numNotifications).
+/// - It is an incorrect value(pNotificationArray) or pNotificationArray is NULL.
+/// \~english @par Detail
+/// Invoke callback function with arguments to register a set of immediate notification.\n
+/// If callback function is null and expectedCalls is '0', using default function
+/// 'NPRegisterImmediateNotifications' to register a set\n
+/// of immediate notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPRegisterImmediatePersistNotification
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterImmediateNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
+ ImmediateNotificationInfo *pNotificationArray);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPRegisterNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to register a notification
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \~english @param[in] notif_name
+/// PCSTR - Name of Notification
+/// \~english @param[in] max_length
+/// const UI_32 - Max size of the notification message
+/// \~english @param[in] perstype
+/// const EFrameworkunifiedPersistentVarType - Flag to indicate if it has to be persistent
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(notif_name) or notif_name is NULL.
+/// - It is an incorrect value(max_length).
+/// \~english @par Detail
+/// Invoke callback function with arguments to register a notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPRegisterNotification' to
+/// register a notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// NPRegisterNotifications, FrameworkunifiedNPRegisterNotification
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPRegisterNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR notif_name,
+ const UI_32 max_length, const EFrameworkunifiedNotificationType perstype);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPUnRegisterNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to remove a notification
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \~english @param[in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pNotification) or pNotification is NULL.
+/// \~english @par Detail
+/// Invoke NPUnRegisterNotifications to remove one notification named 'pPublisherName'.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPUnRegisterNotification, NPUnRegisterNotifications
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPUnRegisterNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSetPersistentNotfnType
+/// \~english @par Brief
+/// API to send message to Notification Service to set the persist category of notification.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Service Name
+/// \~english @param[in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @param[in] ePersistCategory
+/// EFrameworkunifiedPersistCategory - Persistent category
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pNotification) or pNotification is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to set the persist category of
+/// notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSetPersistentNotfnType' to
+/// send\n
+/// message to Notification Service to set the persist category of notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSetPersistentNotfnType
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetPersistentNotfnType(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
+ EFrameworkunifiedPersistCategory ePersistCategory);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSetPersistNotfnDefaultValue
+/// \~english @par Brief
+/// API to send message to Notification Service to set default value of persistent category in notification.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Service Name
+/// \~english @param[in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @param[in] pData
+/// PVOID - Data buffer
+/// \~english @param[in] iLength
+/// const UI_32 - Size of data buffer
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pNotification) or pNotification is NULL.
+/// - It is an incorrect value(pData) or pData is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to set default value of persistent category
+/// in notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSetPersistNotfnDefaultValue'
+/// to send message\n
+/// to Notification Service to set default value of persistent category in notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSetPersistNotfnDefaultValue
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSetPersistNotfnDefaultValue(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
+ PCVOID pData, const UI_32 iLength);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPUnRegisterNotifications
+/// \~english @par Brief
+/// API to send message to Notification Service to remove a set of notification
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \~english @param[in] numNotifications
+/// UI_32 - Number of Notification
+/// \~english @param[in] pNotificationArray
+/// NotificationInfo - Array of notifications
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(numNotifications).
+/// - It is an incorrect value(pNotificationArray) or pNotificationArray is NULL.
+/// - Allocate memory for deal with original notification array failed.
+/// \~english @par Detail
+/// Copy original notification array to temp allocated memory and then remove the given notifications from the
+/// memory.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPUnRegisterNotifications
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPUnRegisterNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
+ NotificationInfo *pNotificationArray);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPPublishNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to notify subscribers
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of Publisher message queue
+/// \~english @param[in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @param[in] pData
+/// PVOID - Data buffer
+/// \~english @param[in] iLength
+/// const UI_32 - Size of data buffer
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusInvldParam
+/// \~english @retval eFrameworkunifiedStatusMsgQFull
+/// \~english @retval eFrameworkunifiedStatusErrNoEBAD
+/// \~english @retval eFrameworkunifiedStatusErrNoEINTR
+/// \~english @retval eFrameworkunifiedStatusInvldBufSize
+/// \~english @retval eFrameworkunifiedStatusFail
+/// \~english @retval eFrameworkunifiedStatusErrOther
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - none
+/// \~english @par Conditions of processing failure
+/// - queue handle(hNPMsgQ,designated by parameter)is NULL[eFrameworkunifiedStatusInvldParam]
+/// - pubulisher name(pPublisherName,designated by parameter)is NULL[eFrameworkunifiedStatusInvldParam]
+/// - Notification name(pNotification)is NULL[eFrameworkunifiedStatusInvldParam]
+/// - pubulisher name(pPublisherName,designated by parameter)is nullbuffer[eFrameworkunifiedStatusInvldParam]
+/// - Notification name(pNotification,designated by parameter)is nullbuffer[eFrameworkunifiedStatusInvldParam]
+/// - message queue is full [eFrameworkunifiedStatusMsgQFull]
+/// - wrong file discriptor for message sending [eFrameworkunifiedStatusErrNoEBAD]
+/// - system call disruput during message sending process[eFrameworkunifiedStatusErrNoEINTR]
+/// - wrong buffer size for sending message[eFrameworkunifiedStatusInvldBufSize]
+/// - message sending failed[eFrameworkunifiedStatusFail]
+/// - failed access to shared memmory for message sending[eFrameworkunifiedStatusErrOther]
+/// \~english @par Detail
+/// send system info as Notification name and command[NPS_PUBLISH_EV_REQ] through McSendWithSysInfo()
+/// NPP service wii process according to command[NPS_PUBLISH_EV_REQ]when get the message above
+/// \~english @par Classification
+/// - pubulic
+/// \~english @par Type
+/// Pub-Sub
+/// \~english @see McSendWithSysInfo
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPPublishNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
+ PCVOID pData, const UI_32 iLength);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSubscribeToNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to add to subscription list for.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pSubscriberName
+/// PCSTR - Name of subscriber message queue
+/// \~english @param[in] notif_name
+/// PCSTR - Name of Notification
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(notif_name) or notif_name is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to add to subscription list for given
+/// notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSubscribeToNotification' to
+/// Notification Service to add to subscription list for given notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSubscribeToNotification
+//////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSubscribeToNotification(HANDLE hNPMsgQ, PCSTR pSubscriberName, PCSTR notif_name);
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSubscribeToNotifications
+/// \~english @par Brief
+/// API to send message to Notification Service to add multiple subscriptions for a set of notification.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pSubscriberName
+/// PCSTR - Name of subscriber message queue
+/// \~english @param[in] numNotifications
+/// UI_32 - Number of Notifications
+/// \~english @param[in] pSubscribeInfoArray
+/// SubscribeInfo* - Array of SubscribeInfo
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(numNotifications).
+/// - It is an incorrect value(pSubscribeInfoArray) or pSubscribeInfoArray is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to add multiple subscriptions for a set of
+/// notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSubscribeToNotifications' to
+/// Notification Service to add multiple subscriptions for a set of notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSubscribeToNotifications
+EFrameworkunifiedStatus NPSubscribeToNotifications(HANDLE hNPMsgQ, PCSTR pSubscriberName, UI_32 numNotifications,
+ SubscribeInfo *pSubscribeInfoArray);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPUnsubscribeFromNotification
+/// \~english @par Brief
+/// API to send message to Notification Service to remove from subscription list for given notification.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pSubscriberName
+/// PCSTR - Name of subscriber message queue
+/// \~english @param[in] pNotification
+/// PCSTR - Name of Notification
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(pNotification) or pNotification is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to remove from subscription list for given
+/// notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPUnsubscribeFromNotification'
+/// to send message to Notification Service to remove from subscription list for given notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPUnsubscribeFromNotification
+EFrameworkunifiedStatus NPUnsubscribeFromNotification(HANDLE hNPMsgQ, PCSTR pSubscriberName, PCSTR pNotification);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPUnsubscribeFromNotifications
+/// \~english @par Brief
+/// API to send message to Notification Service to unsubscribe multiple subscriptions for a set of notification.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pSubscriberName
+/// PCSTR - Name of subscriber message queue
+/// \~english @param[in] numNotifications
+/// UI_32 - Number of Notifications
+/// \~english @param[in] pUnSubscribeInfoArray
+/// SubscribeInfo - Array of notifications
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(numNotifications).
+/// - It is an incorrect value(pUnSubscribeInfoArray) or pUnSubscribeInfoArray is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to unsubscribe multiple subscriptions for a
+/// set of notification.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPUnsubscribeFromNotifications'
+/// to send message to Notification Service to unsubscribe multiple subscriptions for a set of notification.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPUnsubscribeFromNotifications
+EFrameworkunifiedStatus NPUnsubscribeFromNotifications(HANDLE hNPMsgQ, PCSTR pUnSubscriberName, UI_32 numNotifications,
+ SubscribeInfo *pUnSubscribeInfoArray);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPReadPersistedData
+/// \~english @par Brief
+/// API to requested the persistent data corresponding to the notification if available.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue
+/// \~english @param[in] notification
+/// PCSTR - Name of Notification
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(notification) or notification is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to requested the persistent data corresponding to the notification if
+/// available.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPReadPersistedData' to
+/// requested the persistent data corresponding to the notification if available.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPReadPersistedData
+EFrameworkunifiedStatus NPReadPersistedData(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR notification);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSavePersistentData
+/// \~english @par Brief
+/// API to send message to Notification Service to save all persisted data that in Ram to the file system via a
+/// file write.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to save all persisted data.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSavePersistentData' to send
+/// message to Notification Service to save all persisted data.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSavePersistentData
+EFrameworkunifiedStatus NPSavePersistentData(HANDLE hNPMsgQ, PCSTR pPublisherName);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPRegisterPersistentFile
+/// \~english @par Brief
+/// API to send message to Notification Service to add a file path as to be persisted.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pTag
+/// PCSTR - A unique identifier for the file path specified, this is used in retrieve/Load the file later.
+/// \~english @param[in] bIsUserFile
+/// BOOL - Set TRUE, if registering user file.
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to add a file path as to be persisted.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPRegisterPersistentFile' to
+/// send message to Notification Service to add a file path as to be persisted.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPRegisterPersistentFile
+EFrameworkunifiedStatus NPRegisterPersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pTag, BOOL bIsUserFile);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSetFilePersistentType
+/// \~english @par Brief
+/// API to send message to Notification Service to add a file path as to be persisted.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pTag
+/// PCSTR - A unique identifier for the file path specified, this is used in retrieve/Load the file later.
+/// \~english @param[in] ePersistCategory
+/// EFrameworkunifiedPersistCategory - persist category
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pSubscriberName) or pSubscriberName is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to add a file path as to be persisted. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSetFilePersistentType' to
+/// send message to Notification Service to add a file path as to be persisted.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSetFilePersistentType
+EFrameworkunifiedStatus NPSetFilePersistentType(HANDLE hNPMsgQ, PCSTR pPublisherName,
+ PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPLoadPersistentFile
+/// \~english @par Brief
+/// API to send message to Notification Service to copy file from persistent memory to
+/// specified path. The caller recieves an acknowledgement once NPS completes file copy
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pDstFilePath
+/// PCSTR - Complete file path to which the file should be copied from persistent area.
+/// \~english @param[in] pTag
+/// PCSTR - Tag associated with the file that needs to be copied to pDstFilePath.
+/// \~english @param[in] hUser
+/// HANDLE - Load the file for the specified user.
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pDstFilePath) or pDstFilePath is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// - It is an incorrect value(hUser) or hUser is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to copy file from persistent memory to
+/// specified path. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPLoadPersistentFile' to send
+/// message to Notification Service to copy file from persistent memory to specified path.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPLoadPersistentFile
+EFrameworkunifiedStatus NPLoadPersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pDstFilePath,
+ PCSTR pTag, HANDLE hUser);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPReleasePersistentFile
+/// \~english @par Brief
+/// API to send message to Notification Service to notify that the file can be persisted.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] eReleaseType
+/// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease:not on release
+/// eFrameworkunifiedPersistOnShutdown:persist on shutdown
+/// eFrameworkunifiedPersistInstantly:persist instantly
+/// \~english @param[in] pTag
+/// PCSTR - Tag associated with the file released
+/// \~english @param[in] pFullFilePath
+/// PCSTR - Full path name of the file to be persisted
+/// \~english @param[in] hUser
+/// HANDLE - Release the file for the specified user.
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pDstFilePath) or pDstFilePath is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// - It is an incorrect value(pFullFilePath) or pFullFilePath is NULL.
+/// - It is an incorrect value(hUser) or hUser is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to notify that the file can be persisted. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPReleasePersistentFile' to
+/// send message to Notification Service to notify that the file can be persisted.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPReleasePersistentFile
+EFrameworkunifiedStatus NPReleasePersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
+ PCSTR pFullFilePath, HANDLE hUser);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPPersistentSync
+/// \~english @par Brief
+/// API to synchronizes by NPPService.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] eReleaseType
+/// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease:not on release
+/// eFrameworkunifiedPersistOnShutdown:persist on shutdown
+/// eFrameworkunifiedPersistInstantly:persist instantly
+/// \~english @param[in] SrcName
+/// PCSTR - source service name.
+/// \~english @param[in] sessionid
+/// UI_32 - session ID
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(SrcName) or SrcName is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(sessionid).
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// \~english @par Detail
+/// Invoke callback function to synchronizes by NPPService. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPPersistentSync' to
+/// synchronizes by NPPService.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPPersistentSync
+EFrameworkunifiedStatus NPPersistentSync(PCSTR SrcName, HANDLE hNPMsgQ, UI_32 sessionid, PCSTR pPublisherName);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSetPersonality
+/// \~english @par Brief
+/// API to send message to Notification Service to set the Personality.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pUserName
+/// PCSTR - Name of new Personality
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pUserName) or pUserName is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to set the Personality. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSetPersonality' to send
+/// message to Notification Service to set the Personality.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSetPersonality
+EFrameworkunifiedStatus NPSetPersonality(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pUserName);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPChangePersonality
+/// \~english @par Brief
+/// API to send message to Notification Service to change the current Personality.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pUserName
+/// PCSTR - Name of new Personality
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pUserName) or pUserName is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to change the current Personality. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPChangePersonality' to send
+/// message to Notification Service to change the current Personality.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPChangePersonality
+EFrameworkunifiedStatus NPChangePersonality(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pUserName);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPGetReadyStatusOfNPP
+/// \~english @par Brief
+/// To be used by System Manager Service only. SystemManager will use this API to get the ready status of
+/// NPPService.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pRequesterName
+/// PCSTR - Name of the requesters message queue.
+/// \~english @param[in] pUserName
+/// PCSTR - Name of new Personality
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pRequesterName) or pRequesterName is NULL.
+/// - It is an incorrect value(pUserName) or pUserName is NULL.
+/// \~english @par Detail
+/// Invoke callback function to get the ready status of NPPService. \n
+/// If callback function is null and expectedCalls is '0', using default function 'NPGetReadyStatusOfNPP' to get
+/// the ready status of NPPService.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPGetReadyStatusOfNPP
+EFrameworkunifiedStatus NPGetReadyStatusOfNPP(HANDLE hNPMsgQ, PCSTR pRequesterName);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPClearPersistedData
+/// \~english @par Brief
+/// API to delete the persisted data of NS_NPS.
+/// Note: Currently to be used by HMI service only
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pRequesterName
+/// PCSTR - Name of the requesters message queue.
+/// \~english @param[in] eFrameworkunifiedClearPersistenceScope
+/// EFrameworkunifiedClearPersistence - specifies what data to delete from persistent memory.
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pRequesterName) or pRequesterName is NULL.
+/// \~english @par Detail
+/// Invoke callback function to delete the persisted data of NS_NPS.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPClearPersistedData' to delete
+/// the persisted data of NS_NPS.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPClearPersistedData
+EFrameworkunifiedStatus NPClearPersistedData(HANDLE hNPMsgQ, PCSTR pRequesterName, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPRegisterPersistentFolder
+/// \~english @par Brief
+/// API to send message to Notification Service to add a folder path as to be persisted.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pTag
+/// PCSTR - A unique identifier for the folder path specified, this is used in retrieve/Load the folder later.
+/// \~english @param[in] bIsUserFolder
+/// BOOL - Set TRUE, if registering user folder.
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to add a folder path as to be persisted.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPRegisterPersistentFolder' to
+/// send message to Notification Service to add a folder path as to be persisted.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPRegisterPersistentFolder
+EFrameworkunifiedStatus NPRegisterPersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pTag, BOOL bIsUserFolder);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPSetFolderPersistentType
+/// \~english @par Brief
+/// API to send message to Notification Service to set the persist category of file.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pTag
+/// PCSTR - A unique identifier for the file path specified, this is used in retrieve/Load the file later
+/// \~english @param[in] ePersistCategory
+/// EFrameworkunifiedPersistCategory - persist category
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to set the persist category of file.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPSetFolderPersistentType' to
+/// send message to Notification Service to set the persist category of file.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPSetFolderPersistentType
+EFrameworkunifiedStatus NPSetFolderPersistentType(HANDLE hNPMsgQ, PCSTR pPublisherName,
+ PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPLoadPersistentFolder
+/// \~english @par Brief
+/// API to send message to Notification Service to copy folder from persistent memory to
+/// specified path. The caller recieves an acknowledgement once NPS completes folder copy.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to message queue of Notification service.
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] pDstFolderPath
+/// PCSTR - Complete folder path to which the folder should be copied from persistent area
+/// \~english @param[in] pTag
+/// PCSTR - Tag associated with the folder that needs to be copied to pDstFolderPath
+/// \~english @param[in] hUser
+/// HANDLE - Name of new Personality
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pDstFolderPath) or pDstFolderPath is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// - It is an incorrect value(hUser) or hUser is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to copy folder from persistent memory to
+/// specified path.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPLoadPersistentFolder' to send
+/// message to Notification Service to copy folder from persistent memory to specified path.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPLoadPersistentFolder
+EFrameworkunifiedStatus NPLoadPersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pDstFolderPath,
+ PCSTR pTag, HANDLE hUser);
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NPReleasePersistentFolder
+/// \~english @par Brief
+/// API to send message to Notification Service to notify that the folder can be persisted.
+/// \~english @param[in] hNPMsgQ
+/// HANDLE - Handle to the Framework
+/// \~english @param[in] pPublisherName
+/// PCSTR - Name of publisher message queue.
+/// \~english @param[in] eFrameworkunifiedReleaseType
+/// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease :not on release
+/// eFrameworkunifiedPersistOnShutdown:persist on shutdown
+/// eFrameworkunifiedPersistInstantly :persist instantly
+/// \~english @param[in] pTag
+/// PCSTR - Tag associated with the folder released
+/// \~english @param[in] pFullFolderPath
+/// PCSTR - Full path name of the folder to be persisted
+/// \~english @param[in] hUser
+/// HANDLE - Name of new Personality
+/// \~english @retval EFrameworkunifiedStatus indicates success or error
+/// \~english @retval Success(eFrameworkunifiedStatusOK)
+/// \~english @retval Error(anything else)
+/// \~english @par
+/// EFrameworkunifiedStatus Enum
+/// \~english @code
+/// typedef enum eFrameworkunifiedStatus {
+/// eFrameworkunifiedStatusEmptyMediaList = -10, ///< Empty media list
+/// eFrameworkunifiedStatusSessionLimitMaxedOut = -9, ///< Maximum session limit reached
+/// eFrameworkunifiedStatusDbRecNotFound = -8, ///< Database record not found
+/// eFrameworkunifiedStatusDbResultError = -7, ///< Database result error
+/// eFrameworkunifiedStatusDbExecuteFail = -6, ///< Database execute fail
+/// eFrameworkunifiedStatusSemCloseFail = -5, ///< Semaphore close failed
+/// eFrameworkunifiedStatusSemUnlockFail = -4, ///< Semaphore unlock failed
+/// eFrameworkunifiedStatusSemLockFail = -3, ///< Semaphore lock failed
+/// eFrameworkunifiedStatusFail = -2, ///< Failed
+/// eFrameworkunifiedStatusErrOther = -1, ///< Unknown error
+/// eFrameworkunifiedStatusOK = 0, ///< Success / Pass / OK
+/// eFrameworkunifiedStatusInvldBuf = 1, ///< Invalid buffer
+/// eFrameworkunifiedStatusInvldHandle = 2, ///< Invalid handle
+/// eFrameworkunifiedStatusInvldHndlType = 3, ///< Invalid handle type
+/// eFrameworkunifiedStatusInvldQName = 4, ///< Invalid messasge queue name
+/// eFrameworkunifiedStatusMsgQFull = 5, ///< Message queue full
+/// eFrameworkunifiedStatusInvldNotification = 6,///< The Notification event not present
+/// eFrameworkunifiedStatusInvldParam = 7, ///< Invalid parameter
+/// eFrameworkunifiedStatusInvldBufSize = 8, ///< Buf size too small
+/// eFrameworkunifiedStatusInvldID = 9, ///< Unrecognized ID
+/// eFrameworkunifiedStatusCannotRelease = 10, ///< Cannot release resource
+/// eFrameworkunifiedStatusBadConnection = 11, ///< Could not locate resource
+/// eFrameworkunifiedStatusExit = 12, ///< Normal application termination
+/// eFrameworkunifiedStatusNotImplemented = 13, ///< incomplete feature
+/// eFrameworkunifiedStatusThreadBusy = 14, ///< Joined thread is already being joined
+/// eFrameworkunifiedStatusThreadSelfJoin = 15, ///< Thread is joining itself
+/// eFrameworkunifiedStatusThreadInvalidVal = 16, ///< Invalid value passed
+/// eFrameworkunifiedStatusThreadNotExist = 17, ///< The thread does not exist
+/// eFrameworkunifiedStatusFault = 18, ///< A fault occurred while attempting to make call
+/// eFrameworkunifiedStatusServNotFound = 19, ///< Service not present in serv dir
+/// eFrameworkunifiedStatusServerInUse = 20, ///< Service already processing 1 client request
+/// eFrameworkunifiedStatusDbIndexing = 21, ///< Database Indexing in progress
+/// eFrameworkunifiedStatusNullPointer = 22,
+/// eFrameworkunifiedStatusMsgNotProcessed = 23,
+/// eFrameworkunifiedStatusFileLoadSuccess = 24, ///< File Load Success
+/// eFrameworkunifiedStatusFileLoadError = 25, ///< File Load Error
+/// eFrameworkunifiedStatusAccessError = 26, ///< Error when accessing resource
+/// eFrameworkunifiedStatusDuplicate = 27, ///< Duplicate entry
+/// eFrameworkunifiedStatusMsgQEmpty = 28, ///< Message queue empty
+/// eFrameworkunifiedStatusThreadAlreadyRunning = 29,
+/// eFrameworkunifiedStatusErrNoEBADF = 30, ///< Bad file descriptor
+/// eFrameworkunifiedStatusErrNoEAGAIN = 31, ///< Resource unavailable, try again
+/// eFrameworkunifiedStatusErrNoEINTR = 32, ///< Interrupted system call
+/// eFrameworkunifiedStatusSessionErr = 33, ///< Error in session handling
+/// eFrameworkunifiedStatusDBCorrupt = 34, ///< Database corrupt
+/// eFrameworkunifiedStatusDBFileNotFound = 35 ///< Database file not found
+/// } EFrameworkunifiedStatus, *PEFrameworkunifiedStatus;
+/// @endcode
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - Function pointer specified by the argument is NULL.
+/// - It is an incorrect value(hNPMsgQ) or hNPMsgQ is NULL.
+/// - It is an incorrect value(pPublisherName) or pPublisherName is NULL.
+/// - It is an incorrect value(pDstFolderPath) or pDstFolderPath is NULL.
+/// - It is an incorrect value(pTag) or pTag is NULL.
+/// - It is an incorrect value(hUser) or hUser is NULL.
+/// \~english @par Detail
+/// Invoke callback function to send message to Notification Service to notify that the folder can be persisted.\n
+/// If callback function is null and expectedCalls is '0', using default function 'NPReleasePersistentFolder' to
+/// send message to Notification Service to notify that the folder can be persisted.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync only
+/// \~english @see
+/// FrameworkunifiedNPReleasePersistentFolder
+EFrameworkunifiedStatus NPReleasePersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType, PCSTR pTag,
+ PCSTR pFullFolderPath, HANDLE hUser);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NATIVESERVICES_NP_SERVICE_IF_H__ */ // NOLINT (build/header_guard)
+/** @}*/ // end of notification_persistent_service
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
+// EOF
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence.h b/nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence.h
new file mode 100644
index 00000000..88daef7b
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence.h
@@ -0,0 +1,151 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief This file contains the declaration for methods to retrieve and store data for NOR storage
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_np_service_nor_persistence.h
+ * @brief This file contains the declaration for methods to retrieve and store data for NOR storage
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup notification_persistent_service
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef __NATIVESERVICES_NP_NOR_SERVICE_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NP_NOR_SERVICE_H__
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NPSynchronousReadPersistentData
+ /// \~english @par Brief
+ /// API to synchronously read persistent data corresponding to a notification before NPPService is available
+ /// \~english @param[in] pAppName
+ /// PCSTR - Application/ thread name
+ /// \~english @param[in] notif_name
+ // PCSTR - Name of Notification
+ /// \~english @param[in] pData
+ /// PVOID - Pointer to the buffer where read data will be written.
+ /// \~english @param[in] uiDataSize
+ /// UI_32 - Length of the data buffer.
+ /// \~english @param[in] ePersistCategory
+ /// const EFrameworkunifiedPersistCategory - Persist Category of Notification.
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusInvldParam
+ /// \~english @retval eFrameworkunifiedStatusFail
+ /// \~english @par Preconditons
+ /// none
+ /// \~english @par Change of internal status
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - NULL handle specified in the argument(pAppName).[eFrameworkunifiedStatusInvldParam]
+ /// - NULL handle specified in the argument(notif_name).[eFrameworkunifiedStatusInvldParam]
+ /// - NULL handle specified in the argument(pData).[eFrameworkunifiedStatusInvldParam]
+ /// - 0 specified in the argument(uiDataSize).[eFrameworkunifiedStatusFail]
+ /// - Handle of the application [eFrameworkunifiedStatusFail]
+ /// - If the file access process fails,.... [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// API to synchronously read persistent data corresponding to a notification before NPPService is available
+ /// \~english @par
+ /// File reading by this API is exclusive control by semaphore,
+ /// and writing to non-voatie area is to use NPSynchronousWritePersistentData().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Set Get
+ /// \~english @see NPSynchronousWritePersistentData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousReadPersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ UI_32 uiDataSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory = eFrameworkunifiedUserData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NPSynchronousWritePersistentData
+ /// \~english @par Brief
+ /// API to synchronously write persistent data corresponding to a notification before NPPService is available
+ /// \~english @param[in] pAppName
+ /// PCSTR - Application/ thread name
+ /// \~english @param[in] notif_name
+ // PCSTR - Name of Notification
+ /// \~english @param[in] pData
+ /// PVOID - Pointer to the buffer where read data will be written.
+ /// \~english @param[in] uiDataSize
+ /// UI_32 - Length of the data buffer.
+ /// \~english @param[in] ePersistCategory
+ /// const EFrameworkunifiedPersistCategory - Persist Category of Notification.
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusInvldParam
+ /// \~english @retval eFrameworkunifiedStatusFail
+ /// \~english @par Preconditons
+ /// none
+ /// \~english @par Change of internal status
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - NULL handle specified in the argument(pAppName).[eFrameworkunifiedStatusInvldParam]
+ /// - NULL handle specified in the argument(notif_name).[eFrameworkunifiedStatusInvldParam]
+ /// - NULL handle specified in the argument(pData).[eFrameworkunifiedStatusInvldParam]
+ /// - 0 specified in the argument(uiDataSize).[eFrameworkunifiedStatusFail]
+ /// - Handle of the application [eFrameworkunifiedStatusFail]
+ /// - If the file access process fails,.... [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// API to synchronously read persistent data corresponding to a notification before NPPService is available
+ /// \~english @par
+ /// File reading by this API is exclusive control by semaphore,
+ /// and writing to non-voatie area is to use NPSynchronousWritePersistentData().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Set Get
+ /// \~english @see NPSynchronousWritePersistentData
+ ////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousWritePersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ const UI_32 uiDataSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory = eFrameworkunifiedUserData);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NATIVESERVICES_NP_NOR_SERVICE_H__ */ // NOLINT (build/header_guard)
+/** @}*/ // end of notification_persistent_service
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
+// EOF
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence_internal.h b/nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence_internal.h
new file mode 100644
index 00000000..ea149c5a
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_service_nor_persistence_internal.h
@@ -0,0 +1,131 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPServiceIf
+/// \brief This file contains the declaration for internal functions to retrieve and store
+/// immediate notification data from and to persistent storage.
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_SERVICE_NOR_PERSISTENCE_INTERNAL_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_SERVICE_NOR_PERSISTENCE_INTERNAL_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// Include Files
+///////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_np_service.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSynchronousGetPersistentData
+/// API to retrieve immediate storage notification data structure.
+///
+///
+/// \param [in] pAppName
+/// PCSTR - Name of application service
+/// \param [in] notif_name
+/// PCSTR - Name of notification to be written to immediate storage
+/// \param [in] pData
+/// PVOID - Notification data
+/// \param [in] uiDataSize
+/// UI_32 - Size of notification data
+/// \param [out] ptNorPersistentData
+/// NC_NorPersistentData - Immediate notification structure
+/// \param [in] ePersistCategory
+/// const EFrameworkunifiedPersistCategory - Persist Category of Notification.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousGetPersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ UI_32 uiDataSize,
+ NC_NorPersistentData &ptNorPersistentData,
+ const EFrameworkunifiedPersistCategory ePersistCategory);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPSynchronousGetPersistentDataSize
+/// API to get immediate storage notification data size.
+///
+/// \param [in] notif_name
+/// PCSTR - Name of notification to be read from immediate storage
+/// \param [out] uiDataSize
+/// PUI_32 - notification data size
+/// \param [in] ePersistCategory
+/// const EFrameworkunifiedPersistCategory - Persist Category of Notification.
+///
+/// \return EFrameworkunifiedStatus
+/// EFrameworkunifiedStatus - success or failure
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPSynchronousGetPersistentDataSize(PCSTR notif_name,
+ PUI_32 uiDataSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SynchronousGetPersistentDataSize
+/// API to write immediate persistence notification data.
+///
+/// \param [in] notif_name
+/// PCSTR - Name of notification to be read from immediate storage
+/// \param [in] ePersistCategory
+/// const EFrameworkunifiedPersistCategory - Persist Category of Notification.
+///
+/// \return UI_32
+/// UI_32 - size of the data
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SynchronousWritePersistentData(PCSTR pAppName,
+ PCSTR notif_name,
+ PVOID pData,
+ const UI_32 uiDataSize,
+ const UI_32 uiDelay,
+ const UI_32 uiMaxSize,
+ const EFrameworkunifiedPersistCategory ePersistCategory);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SynchronousMovePersistentData
+/// API to move all the immediate notification data from f_cSrcDir directory to
+/// f_cDestDir directory
+///
+/// \param [in] f_cSrcDir
+/// PCSTR - Source directory full path
+/// \param [in] f_cDestDir
+/// PCSTR - Dest directory full path
+///
+/// \return EFrameworkunifiedStatus
+/// EFrameworkunifiedStatus - eFrameworkunifiedStatusAccessError if source path not exists
+/// eFrameworkunifiedStatusFileLoadError if unable to access src directory
+/// eFrameworkunifiedStatusInvldParam if invalid parameter is received
+/// eFrameworkunifiedStatusFail if error occurs while copying file
+/// eFrameworkunifiedStatus on success
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SynchronousMovePersistentData(PCSTR f_cSrcDir,
+ PCSTR f_cDestDir);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_SERVICE_NOR_PERSISTENCE_INTERNAL_H_
+
+// EOF
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_service_notification.h b/nsframework/framework_unified/client/include/native_service/ns_np_service_notification.h
new file mode 100644
index 00000000..5d389ec6
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_service_notification.h
@@ -0,0 +1,50 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief Notifications for notification service messages used by senders and receivers.
+///
+/// Declares the external Notification messages to the Notification Service.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @file ns_np_service_notification.h
+ */
+
+
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup notification_persistent_service
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef NS_NP_SERVICE_NOTIFICATIONS_H_ // NOLINT (build/header_guard)
+#define NS_NP_SERVICE_NOTIFICATIONS_H_
+
+#define NTFY_NPPService_UserChange "NPPService/UserChange" //!< \~english notification_persistent_service server's Availability folder
+
+#endif /* NS_NP_SERVICE_NOTIFICATIONS_H_ */ // NOLINT (build/header_guard)
+/** @}*/ // end of notification_persistent_service
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_service_protocol.h b/nsframework/framework_unified/client/include/native_service/ns_np_service_protocol.h
new file mode 100644
index 00000000..475950bb
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_service_protocol.h
@@ -0,0 +1,116 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief API Header for Notification Service messages used by senders and recievers.
+///
+/// Declares the external Protocol messages to the Notification Service.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @file ns_np_service_protocol.h
+ */
+
+
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup notification_persistent_service
+ * @ingroup native_service
+ * @{
+ */
+#ifndef __NATIVESERVICES_NP_SERVICE_PROTOCOL_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NP_SERVICE_PROTOCOL_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \~english notification_persistent_service protocol msg name define
+ */
+typedef enum _NS_NPServiceProtocol {
+ NPS_REGISTER_EV_REQ = PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD + 0, /// <16+0 Request to register a Notification
+ NPS_UNREGISTER_EV_REQ , /// <1 Request to unregister a Notification
+ NPS_PUBLISH_EV_REQ , /// <2 Sender request to NP service to publish (send) a notification to subscribers
+ NPS_NOTIFY_EV_REQ , /// <3 Message to subscribers that the notification was generated by publisher
+ NPS_SUBSCRIBE_TO_EV_REQ , /// <4 Request to subscribe to a notification
+ NPS_UNSUBSCRIBE_FROM_EV_REQ , /// <5 Request to unsubscribe from a notification
+ NPS_SET_PERSIST_FILE_PATH_REQ , /// <6 Request to add a path to the list of files to be persisted
+ NPS_GET_PERS_DATA_REQ , /// <7 Request to get persistent data for specified notification
+ NPS_GET_PERS_DATA_ACK , /// <8 MSG from NPS to requester of persistent data.
+ NPS_GET_PERS_FILE_REQ , /// <9 Request to get persistent File from specified path
+ NPS_GET_PERS_FILE_ACK , /// <10 MSG from NPS to inform that file was retrieved from persistent
+ /// mem and copied.
+ NPS_SAVE_PERS_DATA_REQ , /// <11 Request to save the persistent data to what ever file that has
+ /// been defined.
+ NPS_SAVE_PERS_DATA_ACK , /// <12 MSG from NPS to requester of Save Action.
+ NPS_RELEASE_PERS_FILE_REQ , /// <13 Request to NPS to persist file in persistent memory
+ NPS_NPP_STOP_REQ , /// <14 MSG from system manager to NS_NPS to stop processing.
+ /// NS_NPS goes to idle state.
+ NPS_TST_WAKEUP , /// <15
+ NPS_BATCH_SUBSCRIBE_TO_EV_REQ , /// <16 Request to subscribe to a batch of notification(s)
+ NPS_GET_PERS_DATA_FAILED_ACK , /// <17 Failed to get persistent data
+ NPS_SET_PERSONALITY_REQ , /// <18 Request to change current user
+ NPS_CHANGE_PERSONALITY_REQ , /// <19 Request to change current user
+ NPS_USER_CHANGE_REQ , /// <20 MSG from NPS to frameworkunified applications.
+ NPS_SET_PERSIST_FOLDER_PATH_REQ , /// <21 Request to add a path to the folder to be persisted
+ NPS_GET_PERS_FOLDER_REQ , /// <22 Request to get persistent Folder from specified path
+ NPS_RELEASE_PERS_FOLDER_REQ , /// <23 Request to NPS to persist folder in persistent memory
+ NPS_GET_PERS_FOLDER_ACK, /// <24 Ack from NPS to requester to inform that folder was retrieved from persistent mem
+ /// and copied.
+ NPS_NPP_STOP_ACK , /// <25 Ack from NS_NPS to system manager on NPS_NPP_STOP_REQ request
+ NPS_BATCH_UNSUBSCRIBE_FROM_EV_REQ , /// <26
+ NPS_GET_READYSTATUS_REQ , /// <27 Request from system manager to check the ready status of NPPService
+ NPS_GET_READYSTATUS_ACK , /// <28 Ack from NPPService to system manager, only if NPPService is in ready state
+ NPS_REGISTER_NOR_EV_REQ , /// <29 Request to register immediate notification
+ NPS_DELETE_PERSISTED_DATA_REQ , /// <30 Request to delete the persistent data.
+ NPS_DELETE_PERSISTED_DATA_ACK , /// <31 Ack of deleting the persistent data.
+ NPS_SET_DEFAULT_PERS_DATA , /// <32 Sets the default data for persistent notification.
+ NPS_SET_NOTFN_PERSISTENT_TYPE , /// <33 Sets the persistent type of notification.
+ NPS_SET_FILE_PERSISTENT_TYPE , /// <34 Sets the persistent type of file.
+ NPS_SET_FOLDER_PERSISTENT_TYPE , /// <35 Sets the persistent type of folder.
+ NPS_SYNCHRONOUS_WRITE_NOTIFY_REQ , /// <36 Updates the immediate notification data in NPPService,
+ /// when written using synchronous API.
+ NPS_IMMEDIATE_WRITE_ACK , /// <37 Sends the ack to publisher of immediate notification after
+ /// data is written to persistent memory.
+ NPS_NPP_SYNC_REQ /// <38 Processing which synchronizes by NPPService (syncfs)
+} NS_NPServiceProtocol;
+
+/**
+ * \~english notification_persistent_service service event
+ */
+typedef enum _NS_NPServiceEvent {
+ NPS_NPP_READY_EVENT = 0x100,
+} NS_NPServiceEvent;
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __NATIVESERVICES_NP_SERVICE_PROTOCOL_H__ */ // NOLINT (build/header_guard)
+/** @}*/ // end of notification_persistent_service
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
+// EOF
diff --git a/nsframework/framework_unified/client/include/native_service/ns_np_types.h b/nsframework/framework_unified/client/include/native_service/ns_np_types.h
new file mode 100644
index 00000000..01559d97
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_np_types.h
@@ -0,0 +1,47 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPServiceIf
+/// \brief
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_TYPES_H_
+#define FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_TYPES_H_
+
+// Path of immediate notification data in NS_NPS version 1
+#define IMMEDIATE_PERSISTENCE_STORAGE_V1 "/nv/BS/ns/npp/rwdata/NPSNOR/"
+
+// Path of immediate notification data in NS_NPS version 2
+#define IMMEDIATE_PERSISTENCE_STORAGE_V2 "/nv/BS/ns/npp/rwdata/"
+
+// name of persistence folder for persistent type categorization
+#define USERDATADIR "UserData/" // stores all the user data (all user common data as well as user specific data)
+#define FACTORYDATADIR "FactoryData/" // stores all the factory data
+#define FACTORYCUSTOMERDATADIR "FactoryCustomerData/" // store all the factory customer data
+#define DEALERDATADIR "DealerData/" // stores all the dealer data
+
+#define IMMEDIATEDATADIR "__ImmNotfn/" // all immediate notification are stored under this folder name
+
+// folder for storing userdata common for all user
+#define ALLUSERAPPDATADIR "AllUserAppData/"
+
+#define RELEASETEMP_DIR "/nps_tmp/"
+#define RELEASETEMP_FILENAME "/ReleaseWork.nps_tmp"
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_NS_NPSERVICEIF_INCLUDE_NS_NP_TYPES_H_
diff --git a/nsframework/framework_unified/client/include/native_service/ns_plogger_if.h b/nsframework/framework_unified/client/include/native_service/ns_plogger_if.h
new file mode 100644
index 00000000..f926f38e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_plogger_if.h
@@ -0,0 +1,288 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \file
+/// Declares functions and macros related to performance logging
+///
+/// \ingroup tag_NSLogger
+/// @{
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief \~english Declares functions and macros related to performance logging
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+
+#ifndef NS_PLOGGER_IF_H_ // NOLINT (build/header_guard)
+#define NS_PLOGGER_IF_H_
+
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NS_PLOGQ "/NSplog"
+#define NS_SYSEVENTLOGQ "/NSSysEventLog"
+
+/// Performance logging
+typedef enum _EPLOG_TIME_FORMAT {
+ EPLOG_TIME_FORMAT_USEC, ///< microseconds
+ EPLOG_TIME_FORMAT_MSEC, ///< miliseconds
+ EPLOG_TIME_FORMAT_SEC, ///< seconds
+} EPLOG_TIME_FORMAT;
+
+typedef enum _EPLOG_OUTPUT_OPTION {
+ EPLOG_SLOG = 0x01, ///< log to standard logging i.e. slogger
+ EPLOG_MSGQ = 0x02, ///< log to message queue NSPlog
+ EPLOG_TRACEEVENT = 0x04 ///< log to trace events
+} EPLOG_OUTPUT_OPTION;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief Performance LOG parameter
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _FRAMEWORKUNIFIEDLOGPPARAM {
+ BOOL bIsPLogEnabled; ///< PLog enabled or disabled
+ EPLOG_TIME_FORMAT eTimeFormat; ///< Time format when PLog is printed
+ UI_64 ui64GapInuS; ///< Gap in micro seconds
+ UI_8 uiLogOutputOptions; ///< Output log options
+} FRAMEWORKUNIFIEDLOGPPARAM, *LFRAMEWORKUNIFIEDLOGPPARAM;
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief System event LOG parameter
+///////////////////////////////////////////////////////////////////////////////
+typedef struct _FRAMEWORKUNIFIEDLOGSYSEVENTPARAM {
+ BOOL bIsSysEventLogEnabled; ///< SysEvent log enabled or disabled
+} FRAMEWORKUNIFIEDLOGSYSEVENTPARAM, *LFRAMEWORKUNIFIEDLOGSYSEVENTPARAM;
+
+extern FRAMEWORKUNIFIEDLOGPPARAM g_FrameworkunifiedLogPParams;
+extern FRAMEWORKUNIFIEDLOGSYSEVENTPARAM g_FrameworkunifiedLogSysEventParams;
+
+#define PLOG_TEXT(args...) NSLogPrintPerformanceLog(__LINE__, __FUNCTION__, ## args)
+#define SYSEVENTLOG_TEXT(args...) NSLogSysEvent(__LINE__, __FUNCTION__, ## args)
+#define IS_PLOG_ENABLED() NsLogIsPLogEnabled()
+#define IS_SYSEVENTLOG_ENABLED() NSLogIsSysEventLogEnabled()
+
+#ifdef __FRAMEWORKUNIFIEDLOG_NDEBUG_LEVEL2__
+#define FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG(print_fmt, args...) ((void)0)
+#else
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG
+///////////////////////////////////////////////////////////////////////////////
+/// Prints a performance log in PosixBasedOS001 system log. These logs can be viewed by using utility sloginfo.
+/// \note This macro API is disable in Linux system
+/// This macro API is disable if defined "__FRAMEWORKUNIFIEDLOG_NDEBUG_LEVEL2__"
+///
+/// \param [in] print_fmt
+/// PCSTR - Input string
+/// \param [in] args
+/// string similar to that of a printf statement and data argments
+///////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG(print_fmt, args...) ((IS_PLOG_ENABLED()) ? PLOG_TEXT(print_fmt, ## args): ((void)0))
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG_PERFORMANCE
+///////////////////////////////////////////////////////////////////////////////
+/// FRAMEWORKUNIFIEDLOG_PERFORMANCE is a logging API provided specifically for logging performance metrics.
+/// \note This macro API is disable in Linux system
+/// It should be used in few locations within an application. (Max 5 times per application).
+/// It should never be used in place of FRAMEWORKUNIFIEDLOG.
+///
+/// \param [in] print_fmt
+/// string similar to that of a printf statement
+/// \param [in] args
+/// Data arguments
+///////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOG_PERFORMANCE(print_fmt, args...) ((IS_PLOG_ENABLED()) ? PLOG_TEXT(print_fmt, ## args): ((void)0))
+
+///////////////////////////////////////////////////////////////////////////////
+/// FRAMEWORKUNIFIEDLOG_SYSTEMEVENT
+///
+/// \param [in] print_fmt
+/// string similar to that of a printf statement
+/// \param [in] args
+/// Data arguments
+///////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOG_SYSTEMEVENT(print_fmt, args...) ((IS_SYSEVENTLOG_ENABLED()) ?\
+ SYSEVENTLOG_TEXT(print_fmt, ## args): ((void)0))
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSLogPrintPerformanceLog
+/// \~english @par Brief
+/// This macro API is disable in Linux system
+/// \~english @param [in] f_ui16Line
+/// const UI_16 - line number
+/// \~english @param [in] f_cFuncName
+/// PCSTR - Function name. It takes __PRETTY_FUNCTION__
+/// \~english @param [in] print_fmt
+/// PCSTR - Input string
+/// \~english @retval none
+/// \~english @par Prerequisite
+/// - Work ony when AGL_STUB is disabled.
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// none
+/// \~english @par Detail
+/// Prints a performance log in PosixBasedOS001 system log. These logs can be viewed by using utility sloginfo.
+/// Log is in format: "Plog: Time[us]:x or o (if gap in cs):Line:Function Input string"\n
+/// - Outputs in time units (microseconds/milliseconds/second) that can be set by the NSLogSetPlogTimeFormat.
+/// - The time data to be output is added to the gap data described in the/dev/shmem/Plog.gap files.
+/// - This information is output to the log output destinations (system log, NSPlog message queue, and event trace)
+/// that can be set by the NSLogSetPlogOutputOptions.(Default: NSPLog message queue)
+/// - PLOG_TEXT, Use this API from the FRAMEWORKUNIFIEDLOG_PERFORMANCE and FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG macros.\n
+/// Continued:\n
+/// - PLOG_TEXT("Service Availability Status: %d", IsAvailable);
+/// - FRAMEWORKUNIFIEDLOG_PERFORMANCE("Service Availability Status: %d", IsAvailable);
+/// - FRAMEWORKUNIFIEDLOG_PERFORMANCE_DEBUG("Service Availability Status: %d", IsAvailable);
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// none
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSLogPrintPerformanceLog(const UI_16 f_ui16Line, PCSTR f_cFuncName, PCSTR __format, ...);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSLogEnablePLog
+/// Enables/Disables the performance logging
+///
+/// \param [in] f_bEnable
+/// BOOL - TRUE- Enable performance logging, FALSE - Disable
+///
+/// \return none
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSLogEnablePLog(BOOL f_bEnable);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NsLogIsPLogEnabled
+/// \~english @par Brief
+/// Is Enables/Disables the performance logging
+/// \~english @retval TRUE current state of plog enable.
+/// \~english @retval FALSE current state of plog disable.
+/// \~english @par Prerequisite
+/// -
+/// \~english @par Change of internal state
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// -
+/// \~english @par Detail
+/// Get the Performance Log enable/disable status.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// No match
+/// \~english @see
+/// NSLogEnablePLog
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL NsLogIsPLogEnabled(void);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSLogSetPlogTimeFormat
+/// Set the time format for performance logging.
+///
+/// \param [in] f_ePlogTimeFormat
+/// EPLOG_TIME_FORMAT - Time format for performance logging
+///
+/// \return none
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSLogSetPlogTimeFormat(EPLOG_TIME_FORMAT f_ePlogTimeFormat);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSLogSetPlogOutputOptions
+/// Set the output options for performance logging.
+///
+/// \param [in] f_uiPlogOutputOption
+/// UI_8 - Output option. Value is generated by or'ed value of enum EPLOG_OUTPUT_OPTION
+/// e.g. EPLOG_SLOG | EPLOG_MSGQ
+///
+/// \return none
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSLogSetPlogOutputOptions(UI_8 f_uiPlogOutputOption);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSLogSysEvent()
+/// Prints system event log in message queue NSSyseventlog.
+///
+/// \param [in] f_ui16Line
+/// const UI_16 - line number
+/// \param [in] f_cFuncName
+/// PCSTR - Function name. It takes __PRETTY_FUNCTION__
+/// \param [in] __format
+/// PCSTR - Input string
+///
+/// \return none
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSLogSysEvent(const UI_16 f_ui16Line, PCSTR f_cFuncName, PCSTR __format, ...);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSLogEnableSysEventLog
+/// Enables/Disables the system event logging
+///
+/// \param [in] f_bEnable
+/// BOOL - TRUE- Enable system event logging, FALSE - Disable
+///
+/// \return none
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID NSLogEnableSysEventLog(BOOL f_bEnable);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSLogIsSysEventLogEnabled
+/// Is Enables/Disables the system event logging
+///
+/// \return SysEventLogEnabled
+/// BOOL - current state of sys event log(enable/disable).
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL NSLogIsSysEventLogEnabled(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* NS_PLOGGER_IF_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+/// @}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_rcs_data_handler.hpp b/nsframework/framework_unified/client/include/native_service/ns_rcs_data_handler.hpp
new file mode 100644
index 00000000..6f303f1c
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_rcs_data_handler.hpp
@@ -0,0 +1,1159 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @brief \~english This file contains declaration of CPassThruInDataHandler class
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup nsrcs
+ * @ingroup framework_unified
+ * @{
+ */
+
+// todo: move this file to the rcs interface folder
+
+#ifndef _NS_RCS_DATA_HANDLER_H__ // NOLINT (build/header_guard)
+#define _NS_RCS_DATA_HANDLER_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_endianess.h>
+#include <vector>
+
+#ifdef AGL_STUB
+#include <cstring>
+#endif
+
+typedef UI_8 NSRCS_BOOL;
+
+#define SIZE_OF_PASSTHRU_DATATYPE_IDENTIFIER 1
+#define SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER 3
+#define PASSTHRU_DATA_HEADER_LEN 8
+
+
+// not valid for buffer or array
+// \return - 0 - invalid type id
+/*UI_16 GetLengthOfBasicType(UI_8 f_ui8TypeId)
+{
+
+ UI_16 l_ui16LengthOfBasicType = 0;
+ switch(f_ui8TypeId)
+ {
+ case 0x01: l_ui16LengthOfBasicType = 2; break; // eBool
+ case 0x02: l_ui16LengthOfBasicType = 1; break; // eUint8
+ case 0x03: l_ui16LengthOfBasicType = 2; break; // eUint16
+ case 0x04: l_ui16LengthOfBasicType = 4; break; // eUint32
+ case 0x05: l_ui16LengthOfBasicType = 8; break; // eUint64
+ case 0x06: l_ui16LengthOfBasicType = 1; break; // eSint8
+ case 0x07: l_ui16LengthOfBasicType = 2; break; // eSint16
+ case 0x08: l_ui16LengthOfBasicType = 4; break; // eSint32
+ case 0x09: l_ui16LengthOfBasicType = 8; break; // eSint64
+ case 0x0A: l_ui16LengthOfBasicType = 8; break; // eReal
+ default: break;
+ }
+ return l_ui16LengthOfBasicType;
+}*/
+
+/////////////////////////////////////////
+/// Class: CPassThruInDataHandler
+/////////////////////////////////////////
+/**
+ * @class CPassThruInDataHandler
+ * \~english @brief Data Handler
+ * \~english @par Brief Introduction
+ * Class to get/set function to do input data handler
+ *
+ */
+class CPassThruInDataHandler {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CPassThruInDataHandler
+ /// \~english @par Summary
+ /// Constructor of CPassThruInDataHandler class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a CPassThruInDataHandler class. \n
+ /// Member variables (m_ui8Data, m_ui16TotalLength, m_ui16ParamCount, m_pui8CurOffset, m_ui16RemainingLength) to
+ /// be initialized. \n
+ /// \~english @see ~CPassThruInDataHandler
+ ////////////////////////////////////////////////////////////////////////////////////
+ CPassThruInDataHandler(UI_8 *f_pui8Data, UI_16 f_ui16Length, UI_16 f_ui16ParamCount)
+ : m_ui8Data(f_pui8Data),
+ m_ui16TotalLength(f_ui16Length),
+ m_ui16ParamCount(f_ui16ParamCount),
+ m_pui8CurOffset(f_pui8Data),
+ m_ui16RemainingLength(f_ui16Length) {
+
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CPassThruInDataHandler
+ /// \~english @par Summary
+ /// Destructor of CPassThruInDataHandler class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To delete a CPassThruInDataHandler class. \n
+ /// \~english @see CPassThruInDataHandler
+ ////////////////////////////////////////////////////////////////////////////////////
+ ~CPassThruInDataHandler() {
+ m_ui8Data = NULL; // Do not delete. Because, not allocated in this class
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetBool
+ /// \~english @par Brief
+ /// This function is used to convert value to type NSRCS_BOOL
+ /// \~english @param [out] f_rcsboolOutValue
+ /// NSRCS_BOOL & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type NSRCS_BOOL(f_rcsboolOutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetBool(NSRCS_BOOL &f_rcsboolOutValue) {
+ return GetValue<NSRCS_BOOL>(f_rcsboolOutValue);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetUI8
+ /// \~english @par Brief
+ /// This function is used to convert value to type UI_8
+ /// \~english @param [out] f_rcsboolOutValue
+ /// UI_8 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type UI_8(f_ui8OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetUI8(UI_8 &f_ui8OutValue) {
+ return GetValue<UI_8>(f_ui8OutValue);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetUI16
+ /// \~english @par Brief
+ /// This function is used to convert value to type UI_16
+ /// \~english @param [out] f_rcsboolOutValue
+ /// UI_16 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type UI_16(f_ui16OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetUI16(UI_16 &f_ui16OutValue) {
+ EFrameworkunifiedStatus l_eStatus = GetValue<UI_16>(f_ui16OutValue);
+ f_ui16OutValue = ConvertEndian_UI16(f_ui16OutValue);
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetUI32
+ /// \~english @par Brief
+ /// This function is used to convert value to type UI_32
+ /// \~english @param [out] f_rcsboolOutValue
+ /// UI_32 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type UI_32(f_ui32OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetUI32(UI_32 &f_ui32OutValue) {
+ EFrameworkunifiedStatus l_eStatus = GetValue<UI_32>(f_ui32OutValue);
+ f_ui32OutValue = ConvertEndian_UI32(f_ui32OutValue);
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetUI64
+ /// \~english @par Brief
+ /// This function is used to convert value to type UI_64
+ /// \~english @param [out] f_rcsboolOutValue
+ /// UI_64 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type UI_64(f_ui64OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetUI64(UI_64 &f_ui64OutValue) {
+ EFrameworkunifiedStatus l_eStatus = GetValue<UI_64>(f_ui64OutValue);
+ f_ui64OutValue = ConvertEndian_UI64(f_ui64OutValue);
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetSI8
+ /// \~english @par Brief
+ /// This function is used to convert value to type SI_8
+ /// \~english @param [out] f_rcsboolOutValue
+ /// SI_8 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type SI_8(f_si8OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetSI8(SI_8 &f_si8OutValue) {
+ return GetValue<SI_8>(f_si8OutValue);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetSI16
+ /// \~english @par Brief
+ /// This function is used to convert value to type SI_16
+ /// \~english @param [out] f_rcsboolOutValue
+ /// SI_16 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type SI_16(f_si16OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetSI16(SI_16 &f_si16OutValue) {
+ EFrameworkunifiedStatus l_eStatus = GetValue<SI_16>(f_si16OutValue);
+ f_si16OutValue = ConvertEndian_SI16(f_si16OutValue);
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetSI32
+ /// \~english @par Brief
+ /// This function is used to convert value to type SI_32
+ /// \~english @param [out] f_rcsboolOutValue
+ /// SI_32 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type SI_32(f_si32OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetSI32(SI_32 &f_si32OutValue) {
+ EFrameworkunifiedStatus l_eStatus = GetValue<SI_32>(f_si32OutValue);
+ f_si32OutValue = ConvertEndian_SI32(f_si32OutValue);
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetSI64
+ /// \~english @par Brief
+ /// This function is used to convert value to type SI_64
+ /// \~english @param [out] f_rcsboolOutValue
+ /// SI_64 & - the given type of covert result
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Convert member data to the type SI_64(f_si64OutValue).
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetSI64(SI_64 &f_si64OutValue) {
+ EFrameworkunifiedStatus l_eStatus = GetValue<SI_64>(f_si64OutValue);
+ f_si64OutValue = ConvertEndian_SI64(f_si64OutValue);
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetBuffer
+ /// \~english @par Brief
+ /// This function is used to get the buffer and its size.
+ /// \~english @param [out] f_pui8Buffer
+ /// UI_8 *& - buffer address
+ /// \~english @param [out] f_ui16BufLength
+ /// UI_16 - buffer size
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_ui16RemainingLength) is invalid(outrange of the size
+ /// SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) [eFrameworkunifiedStatusInvldParam]
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get buffer address(f_pui8Buffer) and its size.
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetBuffer(UI_8 *&f_pui8Buffer, UI_16 &f_ui16BufLength) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (f_pui8Buffer == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "f_pui8Buffer is NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ if (m_pui8CurOffset == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "m_pui8CurOffsetis NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ if (m_ui16RemainingLength >= SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) {
+ if (0xB == *m_pui8CurOffset) { // check if the corresponding data is of type buffer
+ m_pui8CurOffset++;
+ f_ui16BufLength = *(static_cast<UI_16 *>(static_cast<PVOID>(m_pui8CurOffset)));
+ f_ui16BufLength = ConvertEndian_UI16(f_ui16BufLength);
+ m_pui8CurOffset += sizeof(UI_16);
+ m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
+
+ if (m_ui16RemainingLength >= f_ui16BufLength) {
+ f_pui8Buffer = m_pui8CurOffset;
+ m_pui8CurOffset += f_ui16BufLength;
+ m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - f_ui16BufLength);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetArrayCount
+ /// \~english @par Brief
+ /// This function is used to get the buffer and its size.
+ /// \~english @param [out] f_ui16NoOfArrayElements
+ /// UI_16 - buffer size
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - If no array id found at the current location
+ /// \~english @retval eFrameworkunifiedStatusFail - no sufficient buffer to read the data
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Data of value(m_ui16RemainingLength) is invalid(outrange of the size
+ /// SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) [eFrameworkunifiedStatusInvldParam]
+ /// - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
+ /// - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get buffer address(f_pui8Buffer) and its size.
+ /// Return the value(type EFrameworkunifiedStatus) indicate the operation result.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetArrayCount(UI_16 &f_ui16NoOfArrayElements) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (m_pui8CurOffset == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "m_pui8CurOffsetis NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ if (m_ui16RemainingLength >= SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) {
+ if (0xC == *m_pui8CurOffset) { // check if the corresponding data is of type array
+ m_pui8CurOffset++;
+ f_ui16NoOfArrayElements = *(static_cast<UI_16 *>(static_cast<PVOID>(m_pui8CurOffset)));
+ f_ui16NoOfArrayElements = ConvertEndian_UI16(f_ui16NoOfArrayElements);
+ m_pui8CurOffset += sizeof(UI_16);
+ m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ return l_eStatus;
+ }
+
+ UI_16 GetDataLength() {
+ return m_ui16TotalLength;
+ }
+
+ private:
+ // template <class DataType>
+ // EFrameworkunifiedStatus GetValue(DataType& f_dtOutValue);
+
+
+ /*
+ * \return -
+ * eFrameworkunifiedStatusFail - no sufficient data is available
+ * eFrameworkunifiedStatusOK - data retrieved
+ * eFrameworkunifiedStatusInvldID - invalid data type id passed
+ */
+ template <class DataType>
+ EFrameworkunifiedStatus GetValue(DataType &l_dtOutValue) {
+ if (m_pui8CurOffset == NULL) {
+ FRAMWEORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "m_pui8CurOffsetis NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (m_ui16RemainingLength >= (sizeof(DataType) + SIZE_OF_PASSTHRU_DATATYPE_IDENTIFIER)) {
+ if ((0x1 <= *m_pui8CurOffset) && (*m_pui8CurOffset <= 0x9)) // Get value is applicable only for basic types,
+ // not for buffer and array
+ {
+ m_pui8CurOffset++;
+ l_dtOutValue = *(static_cast<DataType *>(static_cast<PVOID>(m_pui8CurOffset)));
+ m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - sizeof(DataType));
+ m_pui8CurOffset += sizeof(DataType);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ return l_eStatus;
+ }
+
+ UI_8 *m_ui8Data;
+ UI_16 m_ui16TotalLength; // total data length
+ UI_16 m_ui16ParamCount;
+
+ UI_8 *m_pui8CurOffset;
+ UI_16 m_ui16RemainingLength; // remaining data length. Not yet parsed
+};
+
+/////////////////////////////////////////
+//// CPassThruOutDataHandler
+/////////////////////////////////////////
+/**
+ * @class CPassThruOutDataHandler
+ * \~english @brief Data Handler
+ * \~english @par Brief Introduction
+ * Class to get/set function to do output data handler
+ *
+ */
+class CPassThruOutDataHandler {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CPassThruOutDataHandler
+ /// \~english @par Summary
+ /// Constructor of CPassThruOutDataHandler class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To generate a CPassThruOutDataHandler class. \n
+ /// Member variables (m_ui16TotalLength, m_ui16ParamCount, m_ui16CurOffset, m_ui16CurrentArrCount,
+ /// m_bArrayTypeSet, m_ui8LastArrDataType) to be initialized. \n
+ /// \~english @see ~CPassThruOutDataHandler
+ ////////////////////////////////////////////////////////////////////////////////////
+ CPassThruOutDataHandler(UI_8 f_ui8ClientId, UI_8 f_ui8PluginId, UI_32 f_ui32CommandId)
+ : m_ui16TotalLength(PASSTHRU_DATA_HEADER_LEN),
+ m_ui16ParamCount(0),
+ m_ui16CurOffset(0),
+ m_ui16CurrentArrCount(0),
+ m_bArrayTypeSet(FALSE),
+ m_ui8LastArrDataType(0) { // default data type eNull
+ m_vui8Data.resize(PASSTHRU_DATA_HEADER_LEN);
+ // TODO: check error condition for resize operation
+ // TODO: try if &m_vui8Data[m_ui16CurOffset] directly works without casting
+ *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = f_ui8ClientId;
+ m_ui16CurOffset++;
+ *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = f_ui8PluginId;
+ m_ui16CurOffset++;
+ *static_cast<UI_32 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = ConvertEndian_UI32(f_ui32CommandId);
+ m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_32));
+ *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = 0; // initialize param count
+ m_ui16ParamCount = m_ui16CurOffset;
+ m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_16));
+ m_ui8ClientId = f_ui8ClientId;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CPassThruOutDataHandler
+ /// \~english @par Summary
+ /// Destructor of CPassThruOutDataHandler class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of internal state
+ /// - The internal state is not changed.
+ /// \~english @par Change of the internal state
+ /// - The internal state is not changed.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// None
+ /// \~english @par Detail
+ /// To delete a CPassThruOutDataHandler class. \n
+ /// \~english @see CPassThruOutDataHandler
+ ////////////////////////////////////////////////////////////////////////////////////
+ ~CPassThruOutDataHandler() {
+ m_vui8Data.clear();
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetClientID
+ /// \~english @par Brief
+ /// This function is used to get clinet id.
+ /// \~english @param none
+ /// \~english @retval
+ /// UI_8 - client id
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return the value(m_ui8ClientId).
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_8 GetClientID() {
+ return m_ui8ClientId;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetData
+ /// \~english @par Brief
+ /// This function is used to get m_vui8Data data address.
+ /// \~english @param none
+ /// \~english @retval
+ /// UI_8 * - m_vui8Data data address
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return m_vui8Data data address.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_8 *GetData() {
+ return static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[0]));
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetLength
+ /// \~english @par Brief
+ /// This function is used to get m_ui16CurOffset value.
+ /// \~english @param none
+ /// \~english @retval
+ /// UI_16 - m_ui16CurOffset value
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Return m_ui16CurOffset value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_16 GetLength() {
+ return m_ui16CurOffset;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetBool
+ /// \~english @par Brief
+ /// This function is used to set NSRCS_BOOL type value.
+ /// \~english @param[in] f_rcsboolValue
+ /// NSRCS_BOOL - new NSRCS_BOOL value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set NSRCS_BOOL type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetBool(NSRCS_BOOL &f_rcsboolValue) {
+ return SetValue<NSRCS_BOOL>(f_rcsboolValue, 0x1);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetUI8
+ /// \~english @par Brief
+ /// This function is used to set UI_8 type value.
+ /// \~english @param[in] f_ui8Value
+ /// UI_8 - new UI_8 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set UI_8 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetUI8(UI_8 f_ui8Value) {
+ return SetValue<UI_8>(f_ui8Value, 0x2);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetUI16
+ /// \~english @par Brief
+ /// This function is used to set UI_16 type value.
+ /// \~english @param[in] f_ui16Value
+ /// UI_16 - new UI_16 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set UI_16 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetUI16(UI_16 f_ui16Value) {
+ return SetValue<UI_16>(ConvertEndian_UI16(f_ui16Value), 0x3);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetUI32
+ /// \~english @par Brief
+ /// This function is used to set UI_32 type value.
+ /// \~english @param[in] f_ui32Value
+ /// UI_32 - new UI_32 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set UI_32 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetUI32(UI_32 f_ui32Value) {
+ return SetValue<UI_32>(ConvertEndian_UI32(f_ui32Value), 0x4);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetUI64
+ /// \~english @par Brief
+ /// This function is used to set UI_64 type value.
+ /// \~english @param[in] f_ui64Value
+ /// UI_64 - new UI_64 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set UI_64 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetUI64(UI_64 f_ui64Value) {
+ return SetValue<UI_64>(ConvertEndian_UI64(f_ui64Value), 0x5);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetSI8
+ /// \~english @par Brief
+ /// This function is used to set SI_8 type value.
+ /// \~english @param[in] f_si8Value
+ /// SI_8 - new SI_8 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set SI_8 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetSI8(SI_8 f_si8Value) {
+ return SetValue<SI_8>(f_si8Value, 0x6);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetSI16
+ /// \~english @par Brief
+ /// This function is used to set SI_16 type value.
+ /// \~english @param[in] f_si16Value
+ /// SI_16 - new SI_16 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set SI_16 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetSI16(SI_16 f_si16Value) {
+ return SetValue<SI_16>(ConvertEndian_SI16(f_si16Value), 0x7);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetSI32
+ /// \~english @par Brief
+ /// This function is used to set SI_32 type value.
+ /// \~english @param[in] f_si32Value
+ /// SI_32 - new SI_32 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set SI_32 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetSI32(SI_32 f_si32Value) {
+ return SetValue<SI_32>(ConvertEndian_SI32(f_si32Value), 0x8);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetSI64
+ /// \~english @par Brief
+ /// This function is used to set SI_64 type value.
+ /// \~english @param[in] f_si64Value
+ /// SI_64 - new SI_64 value
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set SI_64 type value.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetSI64(SI_64 f_si64Value) {
+ return SetValue<SI_64>(ConvertEndian_SI64(f_si64Value), 0x9);
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetBuffer
+ /// \~english @par Brief
+ /// This function is used to set buffer and size.
+ /// \~english @param[in] f_pui8Buffer
+ /// UI_8* - buffer address
+ /// \~english @param[in] f_ui16BufLength
+ /// UI_16 - buffer size
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
+ /// \~english @retval eFrameworkunifiedStatusInvldID - data member(m_ui8LastArrDataType) is invalid value
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set buffer and size.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetBuffer(UI_8 *f_pui8Buffer, UI_16 f_ui16BufLength) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // TODO: add error check for resize operation
+ if (f_pui8Buffer == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "f_pui8Buffer is NULL");
+ return eFrameworkunifiedStatusNullPointer;
+ }
+ m_ui16TotalLength = static_cast<UI_16>(m_ui16TotalLength + f_ui16BufLength + SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
+ m_vui8Data.resize(m_ui16TotalLength);
+ *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = 0xB;
+ m_ui16CurOffset++;
+ *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = ConvertEndian_UI16(f_ui16BufLength);
+ m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_16));
+ std::memcpy(&m_vui8Data[m_ui16CurOffset], f_pui8Buffer, f_ui16BufLength);
+ m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + f_ui16BufLength);
+
+ if (!m_bArrayTypeSet) {
+// *static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) =
+// (*static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount]))) + 1;
+ UpdateParamCount();
+ } else {
+ // setting array element
+ m_ui16CurrentArrCount--;
+
+ if ((m_ui8LastArrDataType != 0) && (m_ui8LastArrDataType != 0xB)) {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ } else {
+ m_ui8LastArrDataType = 0xB;
+ if (0 == m_ui16CurrentArrCount) {
+ m_ui8LastArrDataType = 0; // default data type eNull
+ m_bArrayTypeSet = FALSE;
+ }
+ }
+ }
+ return l_eStatus;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetArrayCount
+ /// \~english @par Brief
+ /// This function is used to set ArrayCount.
+ /// \~english @param f_ui16ArrayCount
+ /// UI_16 - ArrayCount
+ /// \~english @retval none
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - none
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set ArrayCount.
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetArrayCount(UI_16 f_ui16ArrayCount) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // TODO: add error check for resize operation
+ m_ui16TotalLength = static_cast<UI_16>(m_ui16TotalLength + SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
+ m_vui8Data.resize(m_ui16TotalLength);
+ *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = 0xC;
+ m_ui16CurOffset++;
+ *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = ConvertEndian_UI16(f_ui16ArrayCount);
+ m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_16));
+
+ m_ui16CurrentArrCount = f_ui16ArrayCount;
+ m_bArrayTypeSet = TRUE;
+// *static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) =
+// (*static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount]))) + 1;
+ UpdateParamCount();
+
+ // TODO: add error handling, if any other element is added before the array count reaches to f_ui16ArrayCount
+ return l_eStatus;
+ }
+
+ private:
+ CPassThruOutDataHandler() {
+
+ }
+
+ // SetValue
+ // \return - eFrameworkunifiedStatusInvldID - If setting array element of different type
+ template <class DataType>
+ EFrameworkunifiedStatus SetValue(DataType l_dtValue, UI_8 f_ui8DataType) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // TODO: add error check for resize operation
+
+ m_ui16TotalLength = static_cast<UI_16>(m_ui16TotalLength + SIZE_OF_PASSTHRU_DATATYPE_IDENTIFIER + sizeof(DataType));
+ m_vui8Data.resize(m_ui16TotalLength);
+ *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = f_ui8DataType;
+ m_ui16CurOffset++;
+ *static_cast<DataType *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = l_dtValue;
+ m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(DataType));
+
+ if (!m_bArrayTypeSet) {
+// *static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) =
+// (*static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount]))) + 1;
+ UpdateParamCount();
+ } else {
+ // setting array element
+ m_ui16CurrentArrCount--;
+
+ if ((m_ui8LastArrDataType != 0) && (m_ui8LastArrDataType != f_ui8DataType)) {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ } else {
+ m_ui8LastArrDataType = f_ui8DataType;
+ if (0 == m_ui16CurrentArrCount) {
+ m_ui8LastArrDataType = 0; // default data type eNull
+ m_bArrayTypeSet = FALSE;
+ }
+ }
+ }
+ return l_eStatus;
+ }
+
+ VOID UpdateParamCount() {
+ UI_16 l_ui16ParamCount = static_cast<UI_16>(ConvertEndian_UI16(*static_cast<UI_16 *>(static_cast<PVOID>
+ (&m_vui8Data[m_ui16ParamCount]))) + 1);
+ l_ui16ParamCount = ConvertEndian_UI16(l_ui16ParamCount);
+ *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) = l_ui16ParamCount;
+ }
+
+ // UI_8* m_ui8Data;
+ std::vector<UI_8> m_vui8Data;
+ UI_16 m_ui16TotalLength; // total data length
+ UI_16 m_ui16ParamCount;
+ UI_16 m_ui16CurOffset;
+ UI_8 m_ui8ClientId;
+
+ // required for array data type
+ UI_16 m_ui16CurrentArrCount;
+ BOOL m_bArrayTypeSet;
+ UI_8 m_ui8LastArrDataType;
+};
+
+#endif // _NS_RCS_DATA_HANDLER_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_rcs_logger_types.h b/nsframework/framework_unified/client/include/native_service/ns_rcs_logger_types.h
new file mode 100644
index 00000000..cc28f7c1
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_rcs_logger_types.h
@@ -0,0 +1,104 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * ns_rcs_logger_if.h
+ */
+/**
+ * @file
+ * @brief \~english This file provides logger type's structures
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup nsrcs
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _NS_RCS_LOGGER_IF_H_ // NOLINT (build/header_guard)
+#define _NS_RCS_LOGGER_IF_H_
+
+#include <native_service/ns_logger_if.h>
+
+// protocol: NSRCS_SET_LOG_SETTINGS_REQ,
+// NSRCS_SET_LOG_MASK_REQ,
+// NSRCS_SET_LOG_OUT_OPT_REQ,
+// NSRCS_SET_LOG_SEVERITY_REQ
+typedef struct _TNSRCS_SetLogSettingsReq {
+ UI_8 m_ui8ClientId;
+ TFrameworkunifiedZoneMask m_pui32ZoneMask;
+ UI_8 m_ui8OutputLogOption;
+ TFrameworkunifiedLoggerSeverity m_si32Severity;
+} TNSRCS_SetLogSettingsReq;
+
+// protocol: NSRCS_SET_LOG_SETTINGS_RESP
+typedef struct _TNSRCS_SetLogSettingsResp {
+ UI_8 m_ui8ClientId;
+ UI_8 m_ui8SetStatus;
+ TFrameworkunifiedZoneMask m_pui32ZoneMask;
+ UI_8 m_ui8OutputLogOption;
+ TFrameworkunifiedLoggerSeverity m_si32Severity;
+} TNSRCS_SetLogSettingsResp;
+
+// protocol: NSRCS_GET_LOG_SETTINGS_REQ
+typedef struct _TNSRCS_GetLogSettingsReq {
+ UI_8 m_ui8ClientId;
+} TNSRCS_GetLogSettingsReq;
+
+// protocol: NSRCS_GET_LOG_SETTINGS_RESP
+typedef struct _TNSRCS_GetLogSettingsResp {
+ UI_8 m_ui8ClientId;
+ CHAR m_cZoneList[BITS_IN_ZONE_MASK][ZONE_TEXT_SIZE];
+ TFrameworkunifiedZoneMask m_pui32ZoneMask;
+ UI_8 m_ui8OutputLogOption;
+ TFrameworkunifiedLoggerSeverity m_si32Severity;
+} TNSRCS_GetLogSettingsResp;
+
+// protocol: NSRCS_SET_LOG_MASK_RESP
+typedef struct _TNSRCS_SetLogMaskResp {
+ UI_8 m_ui8ClientId;
+ UI_8 m_ui8SetStatus;
+ TFrameworkunifiedZoneMask m_pui32ZoneMask;
+} TNSRCS_SetLogMaskResp;
+
+// protocol: NSRCS_SET_LOG_OUT_OPT_RESP
+typedef struct _TNSRCS_SetLogOutOptResp {
+ UI_8 m_ui8ClientId;
+ UI_8 m_ui8SetStatus;
+ UI_8 m_ui8OutputLogOption;
+} TNSRCS_SetLogOutOptResp;
+
+// protocol: NSRCS_SET_LOG_SEVERITY_RESP
+typedef struct _TNSRCS_SetLogSeverityResp {
+ UI_8 m_ui8ClientId;
+ UI_8 m_ui8SetStatus;
+ SI_32 m_si32Severity;
+} TNSRCS_SetLogSeverityResp;
+
+#endif /* _NS_RCS_LOGGER_IF_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_rcs_plugin.hpp b/nsframework/framework_unified/client/include/native_service/ns_rcs_plugin.hpp
new file mode 100644
index 00000000..617aa1d6
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_rcs_plugin.hpp
@@ -0,0 +1,328 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @brief \~english This file contains the declaration of CNSRcsPlugin class
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup nsrcs
+ * @ingroup framework_unified
+ * @{
+ */
+
+#ifndef _NS_RCS_PLUGIN_H__ // NOLINT (build/header_guard)
+#define _NS_RCS_PLUGIN_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+typedef EFrameworkunifiedStatus(*TFPNSRcsSendPassthruData)(UI_8 f_ui8clientId, PVOID f_data, UI_16 f_ui16PayloadLength);
+
+// forward declaration
+class CPassThruInDataHandler;
+
+/**
+ * @class CNSRcsPlugin
+ * \~english @brief CNSRcsPlugin
+ * \~english @par Brief Introduction
+ * Class to provide base class of CNSRcsPlugin
+ */
+
+class CNSRcsPlugin {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// Constructor of CNSRcsPlugin class.
+ /// \~english @param [in] f_cPluginName
+ /// std::string - the name of plugin
+ /// \~english @param [in] f_fpNSRcsSendPassthruData
+ /// TFPNSRcsSendPassthruData - the pointer of send data function
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Constructor of CNSRcsPlugin class. \n
+ /// variables (m_cPluginName,m_fpNSRcsSendPassthruData,m_uiPluginId) to be initialization.
+ /// \~english @see ~CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ CNSRcsPlugin(std::string f_cPluginName, TFPNSRcsSendPassthruData f_fpNSRcsSendPassthruData)
+ : m_fpNSRcsSendPassthruData(f_fpNSRcsSendPassthruData),
+ m_cPluginName(f_cPluginName) {
+ static UI_8 l_uiPluginId = 0;
+ m_uiPluginId = ++l_uiPluginId;
+ }
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// Destructor of CNSRcsPlugin class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// To delete a CNSRcsPlugin class. \n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CNSRcsPlugin() {
+
+ }
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// get plugin id.
+ /// \~english @param None
+ /// \~english @retval Plugin Id
+ /// UI_8 - the ID of plugin
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar get plugin id. \n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ UI_8 GetPluginId() {
+ return m_uiPluginId;
+ }
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// get plugin id.
+ /// \~english @param None
+ /// \~english @retval m_cPluginName
+ /// std::string - the name of plugin
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar get plugin name. \n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ std::string GetPluginName() {
+ return m_cPluginName;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// set parent name.
+ /// \~english @param f_cParentName
+ /// std::string - the name of parent
+ /// \~english @retval none
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar set parent name. \n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ static VOID SetParentName(const std::string &f_cParentName) {
+ CNSRcsPlugin::m_cParentName = f_cParentName;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// request from host side.
+ /// \~english @param f_uiProtocol
+ /// UI_32 - protocol ID
+ /// \~english @param f_ui8ClientId
+ /// UI_8 - client ID
+ /// \~english @param f_pData
+ /// CPassThruInDataHandler - the handler of transfer data
+ /// \~english @retval none
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar request from host side.\n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus ProcessRequestMessage(UI_32 f_uiProtocol, UI_8 f_ui8ClientId, CPassThruInDataHandler *f_pData) = 0;
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// response from service side on target
+ /// \~english @param f_cMsgSource
+ /// PCSTR -
+ /// \~english @param f_uiProtocol
+ /// UI_32 - protocol ID
+ /// \~english @param f_pui8Data
+ /// UI_8 - pointer of data
+ /// \~english @param f_uiDataLength
+ /// UI_32 - length of data
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar response from service side on target.\n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus ProcessResponseMessage(PCSTR f_cMsgSource, UI_32 f_uiProtocol, UI_8 *f_pui8Data,
+ UI_32 f_uiDataLength) = 0;
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// get response protocol array
+ /// \~english @param none
+ /// \~english @retval UI_32 const *
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar get response protocol array.\n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual UI_32 const *GetResponseProtocolArray() = 0;
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// get length of response protocol array
+ /// \~english @param none
+ /// \~english @retval UI_32 const
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar get length of response protocol array.\n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual UI_32 const GetResponseProtocolArrayLength() = 0;
+
+ static std::string m_cParentName; // TODO: move to private
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRcsPlugin
+ /// \~english @par Summary
+ /// the function of transport data
+ /// \~english @param f_ui8ClientId
+ /// UI_8 - client id
+ /// \~english @param f_data
+ /// PVOID - the pointer of transport data
+ /// \~english @param f_ui16PayloadLength
+ /// UI_16 - the size of transport data
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// provide API whar the function of transport data.\n
+ /// \~english @see CNSRcsPlugin
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SendPassthruOutData(UI_8 f_ui8clientId, PVOID f_data, UI_16 f_ui16PayloadLength) {
+ return m_fpNSRcsSendPassthruData(f_ui8clientId, f_data, f_ui16PayloadLength);
+ }
+ private:
+ CNSRcsPlugin() {
+ }
+
+ UI_8 m_uiPluginId;
+ TFPNSRcsSendPassthruData m_fpNSRcsSendPassthruData;
+ std::string m_cPluginName;
+};
+
+// std::string CNSRcsPlugin::m_cParentName = "";
+
+#endif // _NS_RCS_PLUGIN_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_reader.h b/nsframework/framework_unified/client/include/native_service/ns_reader.h
new file mode 100644
index 00000000..f306a52d
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_reader.h
@@ -0,0 +1,207 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains declaration of class IConfigReader.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_reader.h
+ * @brief \~english This file contains declaration of class IConfigReader.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_CONFIG_READER_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_CONFIG_READER_H__ // NOLINT(build/header_guard)
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h> // NOLINT(build/header_guard)
+#include <string>
+
+/*
+ * IConfigReader is an abstract class which is inherited by different type configuration file
+ * reader class.
+ */
+/**
+ * @class IConfigReader
+ * \~english @brief IConfigReader
+ * \~english @par Brief Introduction
+ * Class to provide class of parse config file.
+ */
+class IConfigReader {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigReader
+ /// \~english @par Summary
+ /// Constructor of IConfigReader class.
+ /// \~english @param none
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Constructor of IConfigReader class.
+ /// \~english @see ~IConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////
+ IConfigReader();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigReader
+ /// \~english @par Summary
+ /// Destructor of IConfigReader class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// To delete a IConfigReader class.
+ /// \~english @see IConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~IConfigReader();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigReader
+ /// \~english @par Summary
+ /// This function is used to parse the file.
+ /// \~english @param [IN] f_c_filepath
+ /// const std::string - path of file to parse.
+ /// \~english @retval EFrameworkunifiedStatus
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to parse the file.\n
+ /// This is abstract function.
+ /// \~english @see IConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus ParseFile(const std::string &f_c_filepath) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigReader
+ /// \~english @par Summary
+ /// This function is used to get the value associated with the key.
+ /// \~english @param [IN] f_c_key
+ /// const std::string - key to search.
+ /// \~english @retval l_cValue value for key
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to get the value associated with the key.\n
+ /// This is abstract function.
+ /// \~english @see IConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual std::string GetValue(const std::string &f_c_key) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigReader
+ /// \~english @par Summary
+ /// This function is used to get the value associated with the key.
+ /// \~english @param [IN] f_c_key
+ /// const std::string - key to search.
+ /// \~english @param [OUT] f_c_value
+ /// const std::string - value for key.
+ /// \~english @retval EFrameworkunifiedStatus error error if key not found else eFrameworkunifiedStatusOK
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to get the value associated with the key.\n
+ /// This is abstract function.
+ /// \~english @see IConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus GetValue(const std::string &f_c_key, std::string &f_c_value) = 0; // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigReader
+ /// \~english @par Summary
+ /// This function is used to get the data pointer.
+ /// \~english @param none.
+ /// \~english @retval PVOID - pointer of data structure
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to get the data pointer. This pointer is then set in config writer.\n
+ /// This is needed to avoid recreation of same data structure object in both reader and writer.\n
+ /// when we create object of NSConfigParser.
+ /// This is abstract function.
+ /// \~english @see IConfigReader
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual PVOID GetDataPtr() = 0;
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_CONFIG_READER_H__ */ // NOLINT (build/header_guard)
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_resource_controler.h b/nsframework/framework_unified/client/include/native_service/ns_resource_controler.h
new file mode 100644
index 00000000..0cce23af
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_resource_controler.h
@@ -0,0 +1,216 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ns_resource_controler.h
+ * @brief \~english This file provides api for operating Resource
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef _ns_resource_controler_h_ // NOLINT (build/header_guard)
+#define _ns_resource_controler_h_
+
+#define FRAMEWORKUNIFIED_RES_ABNMLMON "FRAMEWORKUNIFIED_RES_ABNMLMON"
+#define FRAMEWORKUNIFIED_RES_TIMER "FRAMEWORKUNIFIED_RES_TIMER"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup BaseSystem
+ /// \~english @par Summary
+ /// This function is used to get the resourceid associated with the mod and the key.
+ /// \~english @param [IN] mod
+ /// const char * - the mod of resource
+ /// \~english @param [IN] key
+ /// const char * - the key of resource
+ /// \~english @param [OUT] resource
+ /// long * - resource ID
+ /// \~english @retval -1 fail
+ /// \~english @retval 0 success
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to get the resourceid associated with the mod and the key.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+int frameworkunifiedGetResource(const char *mod, const char *key, long *resource); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup BaseSystem
+ /// \~english @par Summary
+ /// This function is used to acquire the resourceid associated with the mod and the key.
+ /// \~english @param [IN] mod
+ /// const char * - the mod of resource
+ /// \~english @param [IN] key
+ /// const char * - the key of resource
+ /// \~english @param [OUT] resource
+ /// long * - resource ID
+ /// \~english @retval ref_counter the counter of user
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to acquire the resourceid associated with the mod and the key.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+int frameworkunifiedAcquireResouce(const char *mod, const char *key, long *resource); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup BaseSystem
+ /// \~english @par Summary
+ /// This function is used to release the resourceid associated with the mod and the key.
+ /// \~english @param [IN] mod
+ /// const char * - the mod of resource
+ /// \~english @param [IN] key
+ /// const char * - the key of resource
+ /// \~english @retval ref_counter the counter of user
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to release the resourceid associated with the mod and the key.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+int frameworkunifiedReleaseResouce(const char *mod, const char *key);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup BaseSystem
+ /// \~english @par Summary
+ /// This function is used to get the key associated with the mod and the resourceid.
+ /// \~english @param [IN] mod
+ /// const char * - the mod of resource
+ /// \~english @param [IN] resource
+ /// long - resource ID
+ /// \~english @param [OUT] key
+ /// const char * - the key of resource
+ /// \~english @retval -1 fail
+ /// \~english @retval 0 success
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to get the key associated with the mod and the resourceid.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+int frameworkunifiedSearchResourseKey(const char *mod, long resource, const char **key); // NOLINT (readability/nolint)
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup BaseSystem
+ /// \~english @par Summary
+ /// This function is used to register the resource associated with the mod and the key.
+ /// \~english @param [IN] mod
+ /// const char * - the mod of resource
+ /// \~english @param [IN] key
+ /// const char * - the key of resource
+ /// \~english @param [IN] resource
+ /// const char * - resource ID
+ /// \~english @param [IN] init_counter
+ /// long - resource user counter
+ /// \~english @retval -1 fail
+ /// \~english @retval 0 success
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to register the resource associated with the mod and the key.init counter.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+
+int frameworkunifiedRegistResouce(const char *mod, const char *key, long resource, int init_counter); // NOLINT (readability/nolint)
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup BaseSystem
+ /// \~english @par Summary
+ /// This function is used to unregister the resource associated with the mod and the key.
+ /// \~english @param [IN] mod
+ /// const char * - the mod of resource
+ /// \~english @param [IN] key
+ /// const char * - the key of resource
+ /// \~english @retval 0 success
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Causes of failures
+ /// None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// This function is used to unregister the resource associated with the mod and the key.init counter.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////
+int frameworkunifiedUnregistResouce(const char *mod, const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ns_resource_controler_h_ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_ringbuffer.h b/nsframework/framework_unified/client/include/native_service/ns_ringbuffer.h
new file mode 100644
index 00000000..b67cd17e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_ringbuffer.h
@@ -0,0 +1,523 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSRingBuffer
+/// \brief This file contains implementation of class CNSRingBuffer.
+/// This class provides API to open, read, write and close ring buffer
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_ringbuffer.h
+ * @brief \~english This file contains implementation of class CNSRingBuffer.
+ * This class provides API to open, read, write and close ring buffer
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_RINGBUFFER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_RINGBUFFER_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <pthread.h>
+
+#include <native_service/frameworkunified_types.h>
+
+#include <string>
+
+// Structure of the header of the ring buffer
+typedef struct _NSRingBufferHdr {
+ UI_32 m_uiReadPtr; // Read pointer
+ UI_32 m_uiWritePtr; // Write pointer
+ UI_32 m_uiUnReadSize; // Data size not read yet
+ BOOL m_bIsFull; // Flag indicating if the buffer has full of data
+ UI_32 m_uiRingBufferSize; // Size of the ring buffer
+} NSRingBufferHdr;
+
+// Structure of the mutex of the ring buffer
+typedef struct _NSRingBufferMtx {
+ pthread_mutex_t m_tBufMutex; // Mutex object to mutual exclusion
+ int m_lid;
+} NSRingBufferMtx;
+
+
+/**
+ * @class CNSRingBuffer
+ * \~english @brief CNSRingBuffer
+ * \~english @par Brief Introduction
+ * Class to provide class of ring buffer.
+ */
+class CNSRingBuffer {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// Constructor for CNSRingBuffer
+ /// \~english @param[in] f_cMappedFilePath
+ /// const std::string& - path of the ring buffer mapped file
+ /// \~english @param[in] f_uiSize
+ /// const UI_32 - size of ring buffer
+ /// \~english @param[in] f_lid
+ /// int - Lock ID
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// none
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Create an instance of CNSRingBuffer class.\n
+ /// Initializes cass member (m_cMappedFilePath, m_uiRingBuffSize, m_pRbufMtx, m_pRbufHdr,
+ /// m_pRbuf, m_lid, m_pLockAddr, m_siProcessLastWrtPage, m_cRbufMtxName).\n
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par Detail
+ /// Constructor of CNSRingBuffer class.
+ /// variables (m_cMappedFilePath, m_uiRingBuffSize, m_pRbufMtx, m_pRbufHdr,
+ /// m_pRbuf, m_lid, m_pLockAddr, m_siProcessLastWrtPage, m_cRbufMtxName) to be initialization.
+ /// \~english @see ~CNSRingBuffer
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSRingBuffer(const std::string &f_cMappedFilePath, const UI_32 f_uiSize, int f_lid = -1);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// Destructor for CNSRingBuffer.
+ /// \~english @param none
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - The constructor creates an instance of the CNSRingBuffer class.
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// Closes the ring buffer, if it is open.
+ /// \~english @par
+ /// Closes the ring buffer if it is open.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CNSRingBuffer
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSRingBuffer();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function opens and maps the ring buffer object.
+ /// \~english @param none
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusInvldParam
+ /// \~english @retval eFrameworkunifiedStatusFail
+ /// \~english @retval eFrameworkunifiedStatusErrOther
+ /// \~english @par Preconditons
+ /// none
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - Different Lock ID in constructor parameter and mutex object [eFrameworkunifiedStatusInvldParam]
+ /// - If the path at the time of CNSRingBuffer class instantiation is empty [eFrameworkunifiedStatusFail]
+ /// - When the CNSRingBuffer class is instantiated with a path longer than 255 characters... [eFrameworkunifiedStatusFail]
+ /// - If accessing the information header file (shm_open/ mmap) fails [eFrameworkunifiedStatusFail]
+ /// - When accessing the ring buffer file (shm_open/ mmap) fails [eFrameworkunifiedStatusFail]
+ /// - Accessing a mutex file (shm_open/ mmap) fails [eFrameworkunifiedStatusFail]
+ /// - Alreadey opened [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Detail
+ /// It creates the ring buffer if it does not exists.
+ /// Opens the path information header, ring buffer, and mutex set at instance creation.
+ /// \~english @par
+ /// Update ring buffer size for instances created with different sizes on the same path.
+ /// \~english @par
+ /// Execute close() to close.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CNSRingBuffer, Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Open();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function is used to check whether the ring buffer is opened or not..
+ /// \~english @param none
+ /// \~english @retval TRUE - Open
+ /// \~english @retval FALSE - Not open
+ /// \~english @par Preconditions
+ /// - None.
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// none
+ /// \~english @par Detail
+ /// This function is used to check whether the ring buffer is opened or not.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see CNSRingBuffer, Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsOpen();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function unmaps the ring buffer object.
+ /// \~english @param none
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusFail
+ /// \~english @par Preconditons
+ /// - Open has been performed.
+ /// \~english @par Change of internal status
+ /// - The internal state is not changed.
+ /// \~english @par Conditions of processing failure
+ /// - not open [eFrameworkunifiedStatusFail]
+ /// - information header file munmap fail [eFrameworkunifiedStatusFail]
+ /// - ring buffer file munmap fail [eFrameworkunifiedStatusFail]
+ /// - minidesk file munmap fail [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function unmaps the ring buffer object.
+ /// \~english @par
+ /// Close processing is also performed when an instance is destructed to prevent leakage.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Close();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function reads data from the ring buffer.
+ /// \~english @param [OUT] buffer
+ /// PSTR - pointer to the buffer in which the read data is stored
+ /// \~english @param [IN] f_uilength
+ /// UI_32 - length of the data buffer provided
+ /// \~english @retval SI_32 Returns The number of bytes actually read
+ /// \~english @retval -1 error occurred
+ /// \~english @par Preconditions
+ /// - Open().
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - not open [-1]
+ /// \~english @par Detail
+ /// - This function reads data from the ring buffer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 Read(PSTR buffer, const UI_32 f_uilength);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function writes the data into the ring buffer.
+ /// \~english @param [OUT] buffer
+ /// PSTR - pointer to the buffer containing the data to be written
+ /// \~english @param [IN] f_uilength
+ /// UI_32 - length of the data buffer to be written
+ /// \~english @retval SI_32 Returns The number of bytes written
+ /// \~english @retval -1 error occurred
+ /// \~english @par Preconditions
+ /// - Open().
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - not open [-1]
+ /// \~english @par Detail
+ /// - This function writes the data into the ring buffer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 Write(PCSTR buffer, const UI_32 f_uilength);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function writes all the data in the buffer into provided file f_pPath.
+ /// \~english @param[in] f_pPath
+ /// PCSTR - file path.
+ /// \~english @param[in] f_uiDumpSize
+ /// PUI_32 - Returns The number of bytes written into file
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusNullPointer
+ /// \~english @retval eFrameworkunifiedStatusInvldParam
+ /// \~english @retval eFrameworkunifiedStatusFail
+ /// \~english @retval eFrameworkunifiedStatusFileLoadError
+ /// \~english @retval eFrameworkunifiedStatusErrOther
+ /// \~english @par Preconditions
+ /// - Open().
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - f_uiDumpSize is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - dump file path is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - not open [eFrameworkunifiedStatusFail]
+ /// - dump file open fail [eFrameworkunifiedStatusFileLoadError]
+ /// - ring buffer access fail [eFrameworkunifiedStatusFail]
+ /// - dump file write fail [eFrameworkunifiedStatusErrOther]
+ /// \~english @par Detail
+ /// This function does not changes the unread buffer.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Writing to a dump file is overwritten.
+ /// \~english @par
+ /// This function overwrites the file if it exists.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DumpToFile(PCSTR f_pPath, PUI_32 f_uiDumpSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function returns the number of unread bytes which can be read by Read().
+ /// \~english @retval SI_32 Returns The number of bytes which can be read by Read()
+ /// \~english @retval -1 error occurred
+ /// \~english @par Preconditions
+ /// - Open().
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - not open [-1]
+ /// \~english @par Detail
+ /// - This function returns the number of unread bytes which can be read by Read().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 GetSize();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function clears the ring buffer.
+ /// \~english @param none
+ /// \~english @retval eFrameworkunifiedStatusOK
+ /// \~english @retval eFrameworkunifiedStatusFail
+ /// \~english @par Preconditions
+ /// - Open().
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - not open [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// This function clears the ring buffer.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Only read/write information cleared, and the size of the ring buffer itself is not changed.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ClearBuf();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSRingBuffer
+ /// \~english @par Brief
+ /// This function sets the position of read ptr to write ptr in buffer.
+ /// \~english @param none
+ /// \~english @retval eFrameworkunifiedStatusOK success
+ /// \~english @retval eFrameworkunifiedStatusFail ring buffer is not open
+ /// \~english @par Preconditions
+ /// - Open().
+ /// \~english @par Change of the internal state
+ /// - Change of internal state according to the API does not occur.
+ /// \~english @par Conditions of processing failure
+ /// - not open [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// This function sets the position of read ptr to write ptr in buffer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetReadPtrToWritePtr();
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNSRingBuffer
+ /// Constructor of CNSRingBuffer class
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSRingBuffer();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateRBMutex
+ /// This function creates the ring buffer mutex object.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK ring buffer created successfully
+ /// eFrameworkunifiedStatusDuplicate ring buffer already exists
+ /// eFrameworkunifiedStatusInvldParam invalid ring buffer name
+ /// eFrameworkunifiedStatusFail on error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateRBMutex();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateRBHeader
+ /// This function creates the ring buffer object for header.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK ring buffer created successfully
+ /// eFrameworkunifiedStatusDuplicate ring buffer already exists
+ /// eFrameworkunifiedStatusInvldParam invalid ring buffer name
+ /// eFrameworkunifiedStatusFail on error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateRBHeader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateRBDataBuffer
+ /// This function creates the ring buffer object for data buffer.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK ring buffer created successfully
+ /// eFrameworkunifiedStatusDuplicate ring buffer already exists
+ /// eFrameworkunifiedStatusInvldParam invalid ring buffer name
+ /// eFrameworkunifiedStatusFail on error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateRBDataBuffer();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// MapRBHeader
+ /// This function open and maps the file in process space.
+ ///
+ /// \param [out] f_pRbuf
+ /// PVOID* - address of the mapped memory
+ /// \param [in] f_cMappedFile
+ /// std::string - Path of the ring buffer mapped file
+ /// \param [in] f_uiRbufSize
+ /// UI_32 - Size of the ring buffer
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK if ring buffer opened successfully
+ /// eFrameworkunifiedStatusFail unable to open ring buffer
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Map(PVOID *f_pRbuf, const std::string &f_cMappedFile, const UI_32 f_uiRbufSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// MapRBHeader
+ /// This function open and maps the shared memory in process space.
+ ///
+ /// \param [out] f_pShMem
+ /// PVOID* - address of the mapped memory
+ /// \param [in] f_cShmName
+ /// std::string - Name of the shared memory
+ /// \param [in] f_uiShmSize
+ /// UI_32 - Size of the shared memory
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK if shared memory opened successfully
+ /// eFrameworkunifiedStatusFail unable to open shared memory
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus MapSM(PVOID *f_pShMem, const std::string &f_cShmName, const UI_32 f_uiShmSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// UnMapRB
+ /// This function unmaps the object.
+ ///
+ /// \param [in] f_pRbuf
+ /// PCSTR - address of the memory to unmap
+ /// \param [in] f_uiRbufSize
+ /// UI_32 - Size of the memory to be unmapped
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK if ring buffer closed successfully
+ /// eFrameworkunifiedStatusFail if ring buffer is not open
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UnMap(PVOID f_pRbuf, const UI_32 f_uiRbufSize);
+
+ EFrameworkunifiedStatus CheckSize(int fd, off_t size);
+
+
+// void LockMtx();
+ int LockMtx();
+
+ void UnlockMtx();
+
+ std::string m_cRbufMtxName; // name of the ring buffer mutex name
+
+ std::string m_cMappedFileHdrPath; // path of the ring buffer mapped file header
+
+ std::string m_cMappedFilePath; // path of the ring buffer mapped file
+
+ UI_32 m_uiRingBuffSize; // ring buffer size
+
+ NSRingBufferMtx *m_pRbufMtx; // The pointer to the ring buffer mutex
+
+ NSRingBufferHdr *m_pRbufHdr; // The pointer to the ring buffer header
+
+ PCHAR m_pRbuf; // The pointer to the ring buffer data buffer
+
+ pthread_mutex_t m_tOpenMutex; // for multithread process
+
+ int m_lid; // Lock ID
+ void *m_pLockAddr; // Lock Address
+
+ SI_32 m_siProcessLastWrtPage; // to hold page that each process wrote in last
+};
+
+#endif /* __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_RINGBUFFER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_shared_mem.h b/nsframework/framework_unified/client/include/native_service/ns_shared_mem.h
new file mode 100644
index 00000000..981c1ad7
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_shared_mem.h
@@ -0,0 +1,100 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief Shared interface file for SharedMemory Service
+/// Detail description of interface and usage
+/// \ref http://ptcframeworkunifiedaccbuild2/TikiWiki/tiki-index.php?page=Shared+Memory
+/// http://ptcframeworkunifiedaspsql01/sites/ptcsweng/SW%20Engineering%20Document%20Library/
+/// Projects/Connected%20Color%20Radio%20(CCR)/Architecture/Framework/
+/// CCR%20Messaging.vsd
+///
+/// Declares the external APIs to Zone Player Service.
+///
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_shared_mem.h
+ * @brief \~english Shared interface file for SharedMemory Service
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+
+#ifndef __CCR_NATIVESERVICES_MESSAGECENTER_SHAREDMEMORY_H__ // NOLINT (build/header_guard)
+#define __CCR_NATIVESERVICES_MESSAGECENTER_SHAREDMEMORY_H__
+
+
+#include <native_service/frameworkunified_types.h> ///< Header file for Template
+#include <stdint.h>
+#ifdef AGL_STUB
+#else
+#include <devctl.h>
+#include <sys/neutrino.h>
+#endif
+
+typedef struct _pulse_t TPosixHdr; ///> Header for system-provided messages
+
+enum ESharedMemCommand {
+ eSharedMemCommandWrite = 1,
+ eSharedMemCommandRead = 2,
+ eSharedMemCommandSize = 3,
+ eSharedMemCommandDelete = 4,
+};
+
+#define NS_SHAREDMEM_NAME "NS_SharedMem"
+#define NS_SHAREDMEM_SOCK_QUEUE 10
+DEFINE_HANDLE_TYPE(SSHMemID, TShMemID);
+
+#ifdef AGL_STUB
+#else
+#include <_pack1.h>
+#endif
+struct SMsgHeader {
+ uint16_t cmd; // Command to the NS_SharedMem
+ uintptr_t id; // NS_SharedMem ID
+ UI_32 size; // The size of the data to write to NS_SharedMem
+};
+
+struct SReplyHeader {
+ EFrameworkunifiedStatus status; // write result
+ UI_32 size; // The size of the data to read from NS_SharedMem
+};
+#ifdef AGL_STUB
+#else
+#include <_packpop.h>
+#endif
+
+#endif // __CCR_NATIVESERVICES_MESSAGECENTER_SHAREDMEMORY_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_shared_mem_if.h b/nsframework/framework_unified/client/include/native_service/ns_shared_mem_if.h
new file mode 100644
index 00000000..25c5da19
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_shared_mem_if.h
@@ -0,0 +1,196 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_shared_mem_if.h
+ * @brief \~english API Header for Logger.
+ * Declares the external APIs to Logger.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __CCR_NATIVESERVICES_MESSAGECENTER_NSSHAREDMEMIF_H__ // NOLINT (build/header_guard)
+#define __CCR_NATIVESERVICES_MESSAGECENTER_NSSHAREDMEMIF_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <native_service/frameworkunified_types.h> ///< Standard Types
+
+typedef unsigned int TMemID; ///< Type of memory buffer identifiers
+#define BAD_MEM_ID (0)
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup SetDataToShared
+/// \~english @par Summary
+/// - Store a large chunk of memory using SharedMem service
+/// \~english @param [in] data
+/// - const void* - data to be stored in shared memory
+/// \~english @param [in] dataBytes
+/// - UI_32 - length of the data (in bytes) that is stored in shared memory
+/// \~english @param [in] from
+/// - const char * - start address
+/// \~english @param [in] to
+/// - const char * - end address
+/// \~english @retval TMemID - unique MemID of the data stored in the shared memory, 0 if error occurs
+/// \~english @par Preconditions
+/// - None
+/// \~english @par Change of the internal state
+/// - shared memory changed
+/// \~english @par Causes of failures
+/// - param is Invalid.[BAD_MEM_ID]
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - The function sets the data to the shared memory and associates it with a\n
+/// unique MemID that can be used to refer to data in subsequent calls \n
+/// (not necessarily from the same process).
+/// \~english @par
+/// - TMemID:Result
+/// - Except 0:Success
+/// - 0:Failure
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+TMemID SetDataToShared(const void *data, UI_32 dataBytes, const char *from, const char *to);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetDataFromShared
+/// \~english @par Summary
+/// - Retrieve a large chunk of memory using SharedMem service
+/// \~english @param [in] id
+/// - TMemID - MemID of the shared data
+/// \~english @param [in] data
+/// - void* - Buffer to store data in, must be at least as large as buffer associated with id
+/// \~english @param [in] dataMaxBytes
+/// - UI_32 - Size of data - system will never copy more than dataMaxBytes bytes into data
+/// \~english @retval eFrameworkunifiedStatusOK Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldID Invalid id
+/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
+/// \~english @par Preconditions
+/// -
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - param is Invalid. [eFrameworkunifiedStatusInvldParam]
+/// - id is Invalid. [eFrameworkunifiedStatusInvldID]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - Retrieve data, given a MemID. Each MemID is only safe to use until a call to \n
+/// DiscardDataFromShared If the call succeeds, the return value is eFrameworkunifiedStatusOK.\n
+/// Otherwise, the contents of data are undefined.
+/// \~english @par
+/// - eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Failure
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetDataFromShared(TMemID id, void *data, UI_32 dataMaxBytes);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup GetLengthOfDataFromShared
+/// \~english @par Summary
+/// - Query the minimum buffer size, in bytes, necessary to hold a chunk of memory in SharedMem
+/// \~english @param [in] id
+/// - TMemID - MemID of the shared data
+/// \~english @retval length - Minimum buffer size, in bytes, required to hold the data associated with id.
+/// \~english @par Preconditions
+/// -
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - param is Invalid.[BAD_MEM_ID]
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - Returns the minimum buffer size, in bytes, required to hold the data associated with id.\n
+/// Return value of 0 indicates failure.For an id, may be called one or more times \n
+/// until a successful call to either GetDataFromShared or DiscardDataFromShared with that id.
+/// \~english @par
+/// - TMemID:Result
+/// - Except 0:Success
+/// - 0:Failure
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+UI_32 GetLengthOfDataFromShared(TMemID id);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup DiscardDataFromShared
+/// \~english @par Summary
+/// - Discard a chunk of memory in SharedMem
+/// \~english @param [in] id
+/// - TMemID - MemID of the shared data
+/// \~english @retval eFrameworkunifiedStatusOK - Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam -Invalid parameter
+/// \~english @retval eFrameworkunifiedStatusInvldID -Invalid id
+/// \~english @retval eFrameworkunifiedStatusFail -Some sort of error occurred
+/// \~english @par Preconditions
+/// -
+/// \~english @par Change of the internal state
+/// - None
+/// \~english @par Causes of failures
+/// - param is Invalid. [eFrameworkunifiedStatusInvldParam]
+/// - id is Invalid. [eFrameworkunifiedStatusInvldID]
+/// - Any error has occurred at the time of transmission of the System Manager message for the session.
+/// [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// - Public
+/// \~english @par Type
+/// - sync only
+/// \~english @par Detail
+/// - Invalidates the data stored with the MemID. Each id is only safe to use in a\n
+/// single successful call to GetDataFromShared or DiscardDataFromShared
+/// If the call succeeds, the return value is eImageStatusOK.
+/// On failure, the state of shared memory shall not be altered
+/// \~english @par
+/// - eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Failure
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DiscardDataFromShared(TMemID id);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __CCR_NATIVESERVICES_MESSAGECENTER_NSSHAREDMEMIF_H__ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_sharedmem.h b/nsframework/framework_unified/client/include/native_service/ns_sharedmem.h
new file mode 100644
index 00000000..d8ac8b93
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_sharedmem.h
@@ -0,0 +1,486 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains implementation of class CNSSharedMem.
+/// This class provides API to open, read, write and close shared memory
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_sharedmem.h
+ * @brief \~english This file contains implementation of class CNSSharedMem.
+ * This class provides API to open, read, write and close shared memory
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_H__
+
+// Used only in nstest_sharedmem.
+// set environment, CNSSharedMem::Open() always fail. ===> eFrameworkunifiedStatusErrOther
+#define NSTEST_FAIL_SHAREDMEM_OPEN "NSTEST_FAIL_SHAREDMEM_OPEN"
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <pthread.h>
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+// Structure of the header of the shared memory buffer
+typedef struct _NSSharedBuffer {
+ pthread_mutex_t m_tBufMutex; // Mutex object to mutual exclusion
+ pthread_cond_t m_tCondVar; // Condition Variable
+ UI_32 m_uiReadPtr; // Read pointer
+ UI_32 m_uiWritePtr; // Write pointer
+ UI_32 m_uiUnReadSize; // Data size not read yet
+ BOOL m_bIsFull; // Flag indicating if the buffer has full of data
+ UI_32 m_uiShMemSize; // Size of the shared memory buffer
+} NSSharedBufferHdr;
+
+/**
+ * @class CNSSharedMem
+ * \~english @brief shared memory
+ * \~english @par Brief Introduction
+ * This class is used for handle shared memory.
+ *
+ */
+class CNSSharedMem {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// Constructor for CNSSharedMem
+ /// \~english @param[in] f_cSharedMemName
+ /// const std::string& - name of the shared memory
+ /// \~english @param[in] f_uiSize
+ /// const UI_32 - size of shared memory
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// Create object of CNSSharedMem class.
+ /// This class don't used to open shared memory object or allocate memory.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// \~english @see ~CNSSharedMem
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSSharedMem(const std::string &f_cSharedMemName, const UI_32 f_uiSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// Destructor for CNSSharedMem.
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// None
+ /// \~english @par Change of internal status
+ /// - Change the state of shared memory to closed state
+ /// \~english @par Conditions of processing failure
+ /// None
+ /// \~english @par Detail
+ /// Closes the shared memory, if it is open.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Since the destructor does not delete the shared memory area, \n
+ /// the application must execute shm_unlink to delete the shared memory area.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// \~english @see CNSSharedMem(const std::string&, const UI_32), CNSSharedMem(), Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSSharedMem();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// This function opens and maps the shared memory object.
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory opened successfully
+ /// \~english @retval eFrameworkunifiedStatusFail unable to open shared memory
+ /// \~english @retval eFrameworkunifiedStatusErrOther if shared memory already opened
+ /// \~english @par Preconditons
+ /// None
+ /// \~english @par Change of internal status
+ /// - Open shared memory object
+ /// \~english @par Conditions of processing failure
+ /// - if shared memory already opened [eFrameworkunifiedStatusErrOther]
+ /// - Unable to open shared memory(shm_open) [eFrameworkunifiedStatusFail]
+ /// - Unable to create shared memory(mmap) [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// It creates the shared memory if it does not exists.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Open();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// This function is used to check whether the shared memory buffer is opened or not.
+ /// \~english @retval TRUE - Open
+ /// \~english @retval FALSE - Not open
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - Check whether the shared memory buffer is opened or not, and return the result.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsOpen();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// This function unmaps the shared memory object.
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory closed successfully
+ /// \~english @retval eFrameworkunifiedStatusFail if shared memory is not opened
+ /// \~english @par Preconditons
+ /// - Open the shared memory object
+ /// \~english @par Change of internal status
+ /// - Close the shared memory object
+ /// \~english @par Conditions of processing failure
+ /// - The shared memory object is not opened. [eFrameworkunifiedStatusFail]
+ /// - Unable to unmap(munmap) the shared memory object [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function unmaps the shared memory object from memory space.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Since the destructor does not delete the shared memory area, \n
+ /// the application must execute shm_unlink to delete the shared memory area.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Close();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ // Read data from shared memory.
+ /// \~english @param [out] buffer
+ /// PSTR - pointer to the buffer in which the read data is stored
+ /// \~english @param [in] f_uilength
+ /// UI_32 - length of the data buffer provided
+ /// \~english @param [in] f_bBlock
+ /// BOOL - TRUE - blocking call
+ /// FALSE - non blocking call
+ /// \~english @retval SI_32 Returns The number of bytes actually read, or NS_SHM_ERROR if an error occurred
+ /// \~english @retval NS_SHM_ERROR
+ /// \~english @par Preconditons
+ /// - Open the shared memory object
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - The shared memory object is not opened. [NS_SHM_ERROR]
+ /// - Pointor to buffer(buffer) is NULL. [NS_SHM_ERROR]
+ /// - Byte of data(f_uilength)is 0. [NS_SHM_ERROR]
+ /// \~english @par Detail
+ /// This function reads data from the shared memory.
+ /// If this function is used as blocking call, then the calling thread will get blocked
+ /// until data is available for read. By default it is a blocking call.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Write
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 Read(PSTR buffer, const UI_32 f_uilength, const BOOL f_bBlock = TRUE);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// This function writes the data into the shared memory.
+ /// \~english @param[in] buffer
+ /// PCSTR - pointer to the buffer containing the data to be written
+ /// \~english @param[in] f_uilength
+ /// const UI_32 - length of the data buffer to be written
+ /// \~english @retval SI_32 Returns The number of bytes written, or NS_SHM_ERROR if an error occurred
+ /// \~english @par Preconditons
+ /// - Open the shared memory object
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - The shared memory object is not opened. [NS_SHM_ERROR]
+ /// - Pointor to buffer(buffer) is NULL. [NS_SHM_ERROR]
+ /// - Size of buffer(f_uilength) is larger than the size designated by constructor. [NS_SHM_ERROR]
+ /// \~english @par Detail
+ /// - This function writes the data into the shared memory.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Read
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 Write(PCSTR buffer, const UI_32 f_uilength);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// Dump data to file.
+ /// \~english @param [in] f_pPath
+ /// PCSTR - file path.
+ /// \~english @param[in] [in] f_uiDumpSize
+ /// PUI_32 - Returns The number of bytes written into file
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK on success,
+ /// eFrameworkunifiedStatusFileLoadError - file path is incorrect
+ /// eFrameworkunifiedStatusSemLockFail/
+ /// eFrameworkunifiedStatusSemLockFail - mutex locking/unlocking error
+ /// eFrameworkunifiedStatusFail - shared memory is not opened
+ /// eFrameworkunifiedStatusInvldParam - invalid param
+ /// \~english @par Preconditons
+ /// -
+ /// \~english @par Change of internal status
+ /// -None
+ /// \~english @par Conditions of processing failure
+ /// - file path is incorrect.[eFrameworkunifiedStatusFileLoadError]
+ /// - mutex locking/unlocking error.[eFrameworkunifiedStatusSemLockFail/eFrameworkunifiedStatusSemLockFail]
+ /// - shared memory is not opened.[eFrameworkunifiedStatusFail]
+ /// - invalid param.[eFrameworkunifiedStatusInvldParam]
+ /// \~english @par Detail
+ /// - This function writes all the data in the buffer into provided file f_pPath.
+ /// - This function does not changes the unread buffer.
+ /// - This function overwrites the file if it exists.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DumpToFile(PCSTR f_pPath, PUI_32 f_uiDumpSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// This function gets size of unread bytes.
+ /// \~english @param None
+ /// \~english @retval Except NS_SHM_ERROR - Returns The number of unread bytes
+ /// \~english @retval NS_SHM_ERROR -if an error occurred
+ /// \~english @par Preconditons
+ /// -
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// if m_pShmHdr is null.[NS_SHM_ERROR]
+ /// \~english @par Detail
+ /// This function returns the number of unread bytes which can be read by Read().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par
+ /// - l_uiReadSize:Result
+ /// - NS_SHM_ERROR:Failure
+ /// - Except NS_SHM_ERROR:Success
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 GetSize();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// Clear buffer.
+ /// \~english @param None
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK on success,
+ /// eFrameworkunifiedStatusSemLockFail/
+ /// eFrameworkunifiedStatusSemLockFail - mutex locking/unlocking error
+ /// eFrameworkunifiedStatusFail - shared memory is not opened
+ /// \~english @par Preconditons
+ /// -
+ /// \~english @par Change of internal status
+ /// - set m_pShmHdr->m_uiReadPtr with 0;
+ /// - set m_pShmHdr->m_uiWritePtr with 0;
+ /// - set m_pShmHdr->m_uiUnReadSize with 0;
+ /// - set m_pShmHdr->m_bIsFull with FALSE;
+ /// \~english @par Conditions of processing failure
+ /// - mutex locking/unlocking error.[eFrameworkunifiedStatusSemLockFail/eFrameworkunifiedStatusSemLockFail]
+ /// - shared memory is not opened.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function clears the shared memory buffer.if m_pShmHdr is null,return failure.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ClearBuf();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMem
+ /// \~english @par Brief
+ /// This function sets the position of read ptr to write ptr in buffer.
+ /// \~english @param None
+ /// \~english @retval EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK on success,
+ /// eFrameworkunifiedStatusSemLockFail/
+ /// eFrameworkunifiedStatusSemLockFail - mutex locking/unlocking error
+ /// eFrameworkunifiedStatusFail - shared memory is not opened
+ /// \~english @par Preconditons
+ /// -
+ /// \~english @par Change of internal status
+ /// - set m_pShmHdr->m_uiReadPtr with m_pShmHdr->m_uiWritePtr;
+ /// - set m_pShmHdr->m_uiUnReadSize with 0;
+ /// \~english @par Conditions of processing failure
+ /// - mutex locking/unlocking error.[eFrameworkunifiedStatusSemLockFail/eFrameworkunifiedStatusSemLockFail]
+ /// - shared memory is not opened.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function sets the position of read ptr to write ptr in buffer.\n
+ /// If m_pShmHdr of lock failure or unlock failure,result is error.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetReadPtrToWritePtr();
+
+ protected:
+ // no members in protected
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNSSharedMem
+ /// Constructor of CNSSharedMem class
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSSharedMem();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateSMHeader
+ /// This function creates the shared memory object for header.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK shared memory created successfully
+ /// eFrameworkunifiedStatusDuplicate shared memory already exists
+ /// eFrameworkunifiedStatusInvldParam invalid shared memory name
+ /// eFrameworkunifiedStatusFail on error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateSMHeader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateSMDataBuffer
+ /// This function creates the shared memory object for data buffer.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK shared memory created successfully
+ /// eFrameworkunifiedStatusDuplicate shared memory already exists
+ /// eFrameworkunifiedStatusInvldParam invalid shared memory name
+ /// eFrameworkunifiedStatusFail on error
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateSMDataBuffer();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// MapSMHeader
+ /// This function open and maps the shared memory in process space.
+ ///
+ /// \param [out] f_pShMem
+ /// PVOID* - address of the mapped memory
+ /// \param [in] f_cShmName
+ /// std::string - Name of the shared memory
+ /// \param [in] f_uiShmSize
+ /// UI_32 - Size of the shared memory
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK if shared memory opened successfully
+ /// eFrameworkunifiedStatusFail unable to open shared memory
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus MapSM(PVOID *f_pShMem, const std::string &f_cShmName, const UI_32 f_uiShmSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// UnMapSM
+ /// This function unmaps the shared memory object.
+ ///
+ /// \param [in] f_pShMem
+ /// PCSTR - address of the memory to unmap
+ /// \param [in] f_uiShmSize
+ /// UI_32 - Size of the memory to be unmapped
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// eFrameworkunifiedStatusOK if shared memory closed successfully
+ /// eFrameworkunifiedStatusFail if shared memory is not opened
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UnMapSM(PVOID f_pShMem, const UI_32 f_uiShmSize);
+
+ std::string m_cShmHdrName; // name of the shared memory header
+
+ std::string m_cShmName; // name of the shared memory data
+
+ UI_32 m_uiShmBuffSize; // shared memory size
+
+ NSSharedBufferHdr *m_pShmHdr; // The pointer to the shared memory header
+
+ PCHAR m_pShmBuff; // The pointer to the shared memory data buffer
+};
+
+#endif /* __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_sharedmem_reader.h b/nsframework/framework_unified/client/include/native_service/ns_sharedmem_reader.h
new file mode 100644
index 00000000..9a34909e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_sharedmem_reader.h
@@ -0,0 +1,340 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains implementation of class CNSSharedMemReader.
+/// This class provides API to open, close and perform read operation on shared memory.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_sharedmem_reader.h
+ * @brief \~english This file contains implementation of class CNSSharedMemReader.
+ * This class provides API to open, close and perform read operation on shared memory.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_READER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_READER_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+class CNSSharedMem;
+
+/**
+ * @class CNSSharedMemReader
+ * \~english @brief read shared memory
+ * \~english @par Brief Introduction
+ * This class is used for read shared memory.
+ *
+ */
+class CNSSharedMemReader {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// Constructor for CNSSharedMemReader
+ /// \~english @param[in] f_cSharedMemName
+ /// const std::string& - name of the shared memory
+ /// \~english @param[in] f_bBlock
+ /// BOOL - TRUE - blocking call for Read() API,Thread will get blocked \n
+ /// the thread until data is available for read.
+ /// FALSE - non blocking call for Read() API
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// Create object of CNSSharedMemReader class.
+ /// This class don't used to open shared memory object or allocate memory.
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - None
+ /// \~english @see ~CNSSharedMemReader
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSSharedMemReader(const std::string &f_cSharedMemName, const BOOL f_bBlock = TRUE); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// Destructor for CNSSharedMemReader.
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - Change the state of shared memory to closed state
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// Closes the shared memory, if it is open.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Since the destructor does not delete the shared memory area, \n
+ /// the application must execute shm_unlink to delete the shared memory area.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see CNSSharedMemReader(const std::string&, const BOOL), CNSSharedMemReader(), Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSSharedMemReader();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function opens and maps the shared memory object.
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory opened successfully
+ /// \~english @retval eFrameworkunifiedStatusFail unable to open shared memory
+ /// \~english @retval eFrameworkunifiedStatusErrOther if shared memory already opened
+ /// \~english @par Preconditons
+ /// None
+ /// \~english @par Change of internal status
+ /// - Open shared memory object
+ /// \~english @par Conditions of processing failure
+ /// - if shared memory already opened [eFrameworkunifiedStatusErrOther]
+ /// - Unable to open shared memory(shm_open) [eFrameworkunifiedStatusFail]
+ /// - Unable to create shared memory(mmap) [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// Opens a shared memory object and allocates it to a memory space.\n
+ /// It creates the shared memory if it does not exists.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Open();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function is used to check whether the shared memory buffer is opened or not.
+ /// \~english @retval TRUE - Open
+ /// \~english @retval FALSE - Not open
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - Check whether the shared memory buffer is opened or not, and return the result.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsOpen();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function unmaps the shared memory object.
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory closed successfully
+ /// \~english @retval eFrameworkunifiedStatusFail if shared memory is not opened
+ /// \~english @par Preconditons
+ /// - Open the shared memory object
+ /// \~english @par Change of internal status
+ /// - Close the shared memory object
+ /// \~english @par Conditions of processing failure
+ /// - The shared memory object is not opened. [eFrameworkunifiedStatusFail]
+ /// - Unable to unmap(munmap) the shared memory object [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function unmaps the shared memory object from memory space.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Since the closing does not delete the shared memory area, \n
+ /// the application must execute shm_unlink to delete the shared memory area.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Open
+ ////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Close();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function reads data from the shared memory.
+ /// \~english @param[in] buffer
+ /// PSTR - pointer to the buffer in which the read data is stored
+ /// \~english @param[in] f_uilength
+ /// const UI_32 - length of the data buffer provided
+ /// \~english @retval The number of bytes actually read, or NS_SHM_ERROR if an error occurred
+ /// \~english @par Preconditons
+ /// - Open the shared memory object
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - The shared memory object is not opened. [NS_SHM_ERROR]
+ /// - Pointor to buffer(buffer) is NULL. [NS_SHM_ERROR]
+ /// - Byte of data(f_uilength)is 0. [NS_SHM_ERROR]
+ /// \~english @par Detail
+ /// If this constructor is used as blocking call, then the calling thread will get blocked\n
+ /// until data is available for read.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Write
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 Read(PSTR buffer, const UI_32 f_uilength);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function writes all the data in the buffer into provided file f_pPath.
+ /// \~english @param[in] f_pPath
+ /// PCSTR - file path.
+ /// \~english @param[in] f_uiDumpSize
+ /// PUI_32 - Returns The number of bytes written into file
+ /// \~english @retval eFrameworkunifiedStatusOK - on success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - invalid param
+ /// \~english @retval eFrameworkunifiedStatusFail - shared memory is not open
+ /// \~english @retval eFrameworkunifiedStatusFileLoadError - file path is incorrect
+ /// \~english @retval eFrameworkunifiedStatusErrOther
+ /// \~english @retval eFrameworkunifiedStatusSemUnlockFail
+ /// \~english @par Preconditons
+ /// - File is opened.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - Pointor to dump size(f_uiDumpSize)is NULL [eFrameworkunifiedStatusNullPointer]
+ /// - Dump file path is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - File is not opened [eFrameworkunifiedStatusFail]
+ /// - Failed to open dump file [eFrameworkunifiedStatusFileLoadError]
+ /// - Failed to access shared memory [eFrameworkunifiedStatusFail]
+ /// - Failed to write data into dump file [eFrameworkunifiedStatusErrOther]
+ /// - Failed to lock mutex [eFrameworkunifiedStatusSemLockFail]
+ /// - Failed to unlock mutex [eFrameworkunifiedStatusSemUnlockFail]
+ /// \~english @par Detail
+ /// This function does not changes the unread buffer.
+ /// \~english @par
+ /// This function overwrites the file if it exists.
+ /// \~english @par Classification
+ /// public
+ /// \~english @par Type
+ /// none
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DumpToFile(PCSTR f_pPath, PUI_32 f_uiDumpSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function gets size of unread .bytes.
+ /// \~english @param None
+ /// \~english @retval Except NS_SHM_ERROR - Returns The number of bytes written,
+ /// \~english @retval NS_SHM_ERROR -if an error occurred
+ /// \~english @par Preconditons
+ /// -
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// if m_pShmHdr is null.[NS_SHM_ERROR]
+ /// \~english @par Detail
+ /// This function returns the number of unread bytes which can be read by Read().
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// sync only
+ /// \~english @par
+ /// - l_uiReadSize:Result
+ /// - NS_SHM_ERROR:Failure
+ /// - Except NS_SHM_ERROR:Success
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 GetSize();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemReader
+ /// \~english @par Brief
+ /// This function sets the position of read ptr to write ptr in buffer.
+ /// \~english @retval eFrameworkunifiedStatusOK - on success
+ /// \~english @retval eFrameworkunifiedStatusFail - shared memory is not open
+ /// \~english @retval eFrameworkunifiedStatusSemLockFail - mutex locking error
+ /// \~english @retval eFrameworkunifiedStatusSemUnlockFail - mutex unlocking error
+ /// \~english @par Preconditons
+ /// - File is opened.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - File is not opened [eFrameworkunifiedStatusFail]
+ /// - Failed to lock mutex [eFrameworkunifiedStatusSemLockFail]
+ /// - Failed to unlock mutex [eFrameworkunifiedStatusSemUnlockFail]
+ /// \~english @par Detail
+ /// - Set the position of read ptr to write ptr in buffer.\n
+ /// - Initialize state of unreading bytes to 0.
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// Open Close
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetReadPtrToWritePtr();
+
+ protected:
+ // no members in protected
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNSSharedMemReader
+ /// Constructor of CNSSharedMemReader class
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSSharedMemReader();
+
+ CNSSharedMem *m_pShmReader; // pointer to the CNSSharedMem object
+
+ BOOL m_bBlock; // blocking or non blocking read
+};
+
+#endif /*__NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_READER_H__*/ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_sharedmem_writer.h b/nsframework/framework_unified/client/include/native_service/ns_sharedmem_writer.h
new file mode 100644
index 00000000..de6e9f94
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_sharedmem_writer.h
@@ -0,0 +1,283 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains implementation of class CNSSharedMemWriter.
+/// This class provides API to open, close and perform write operation on shared memory.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_sharedmem_writer.h
+ * @brief \~english This file contains implementation of class CNSSharedMemWriter.
+ * This class provides API to open, close and perform write operation on shared memory.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_WRITER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_WRITER_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+class CNSSharedMem;
+
+/**
+ * @class CNSSharedMemWriter
+ * \~english @brief write shared memory
+ * \~english @par Brief Introduction
+ * This class is used for write shared memory.
+ *
+ */
+class CNSSharedMemWriter {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// Constructor for CNSSharedMemWriter
+ /// \~english @param[in] f_cSharedMemName
+ /// const std::string& - name of the shared memory
+ /// \~english @param[in] f_uiSize
+ /// UI_32 - size of shared memory
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// Create object of CNSSharedMemWriter class.
+ /// This class don't used to open shared memory object or allocate memory.
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @see ~CNSSharedMemWriter
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSSharedMemWriter(const std::string &f_cSharedMemName, const UI_32 f_uiSize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// Destructor of CNSSharedMemWriter class.
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - Change the state of shared memory to closed state
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// Closes the shared memory, if it is open.
+ /// \~english @par
+ /// Please note the following points when using this API for application.
+ /// - Since the destructor does not delete the shared memory area, \n
+ /// the application must execute shm_unlink to delete the shared memory area.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @see CNSSharedMemWriter(const std::string&, const BOOL), CNSSharedMemWriter(), Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSSharedMemWriter();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// This function opens and maps the shared memory object.
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory opened successfully
+ /// \~english @retval eFrameworkunifiedStatusNullPointer pointer of the CNSSharedMem object is NULL
+ /// \~english @retval eFrameworkunifiedStatusFail unable to open shared memory
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - Open shared memory object
+ /// \~english @par Conditions of processing failure
+ /// - pointer of the CNSSharedMem object is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// - unable to open shared memory.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// This function opens and maps the shared memory object.\n
+ /// It creates the shared memory if it does not exists.
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see Close
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Open();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// This function is used to check whether the shared memory buffer is opened or not.
+ /// \~english @retval TRUE - Open
+ /// \~english @retval FALSE - Not open
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - Check whether the shared memory buffer is opened or not, and return the result.
+ /// \~english @par Classification
+ /// - public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsOpen();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// This function unmaps the shared memory object.
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory closed successfully
+ /// \~english @retval eFrameworkunifiedStatusNullPointer pointer of the CNSSharedMem object is NULL
+ /// \~english @retval eFrameworkunifiedStatusFail if shared memory is not open
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - Close the shared memory object
+ /// \~english @par Conditions of processing failure
+ /// - Pointer of the CNSSharedMem object is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// - If shared memory is not open.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function unmaps the shared memory object.\n
+ /// If pointer of the CNSSharedMem object is NULL, will return eFrameworkunifiedStatusNullPointer.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see Open
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Close();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// This function writes the data into the shared memory.
+ /// \~english @param[in] buffer
+ /// PSTR - pointer to the buffer containing the data to be written
+ /// \~english @param[in] f_uilength
+ /// const UI_32 - length of the data buffer to be written
+ /// \~english @retval The number of bytes written
+ /// \~english @retval NS_SHM_ERROR if an error occurred
+ /// \~english @par Preconditons
+ /// - Open the shared memory object
+ /// \~english @par Change of internal status
+ /// - shared memory is changed.
+ /// \~english @par Conditions of processing failure
+ /// - m_pShmWriter is NULL.
+ /// - buffer is NULL.
+ /// - f_uilength is 0.
+ /// \~english @par Detail
+ /// - This function writes the buffer's data whose length is f_uilength to shared memory.\n
+ /// If successed,return write size,else return NS_SHM_ERROR.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// Sync only
+ /// \~english @par
+ /// - l_iWriteSize:Result
+ /// - NS_SHM_ERROR:Failure
+ /// - Except NS_SHM_ERROR:Success
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 Write(PCSTR buffer, const UI_32 f_uilength);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CNSSharedMemWriter
+ /// \~english @par Brief
+ /// This function clears the shared memory buffer.
+ /// \~english @retval eFrameworkunifiedStatusOK if shared memory cleared successfully
+ /// \~english @retval eFrameworkunifiedStatusNullPointer pointer of the CNSSharedMem object is NULL
+ /// \~english @retval eFrameworkunifiedStatusFail if shared memory is not open
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - shared memory is changed.
+ /// \~english @par Conditions of processing failure
+ /// - Pointer of the CNSSharedMem object is NULL.[eFrameworkunifiedStatusNullPointer]
+ /// - If shared memory is not open.[eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - This function clears the shared memory buffer.\n
+ /// If pointer of the CNSSharedMem object is NULL, will return eFrameworkunifiedStatusNullPointer.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @par
+ /// - eFrameworkunifiedStatus:Result
+ /// - eFrameworkunifiedStatusOK:Success
+ /// - Except eFrameworkunifiedStatusOK:Failure
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ClearBuf();
+
+ protected:
+ // no members in protected
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNSSharedMemWriter
+ /// Constructor of CNSSharedMemWriter class
+ ///
+ /// \param
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNSSharedMemWriter();
+
+ CNSSharedMem *m_pShmWriter; // pointer to the CNSSharedMem object
+};
+
+#endif /*__NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_WRITER_H__*/ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_system_mode.h b/nsframework/framework_unified/client/include/native_service/ns_system_mode.h
new file mode 100644
index 00000000..9815904c
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_system_mode.h
@@ -0,0 +1,67 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * NS_SYSTEM_MODE.h
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSFramework
+///////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_system_mode.h
+ * @brief \~english The file defines enum SystemModeProtocol
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_SYSTEM_MODE_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_SYSTEM_MODE_H__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_service_protocol.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_System
+/// \brief System Mode Protocol
+////////////////////////////////////////////////////////////////////////////////////////////////
+typedef enum _SystemModeProtocol {
+ SYSTEM_ON_INITIALIZATION = PROTOCOL_THREAD_INITIALIZATION, ///< Initialize thread after creation
+ SYSTEM_ON_WAKEUP = PROTOCOL_THREAD_WAKEUP, ///< Wakeup Thread after sleep
+ SYSTEM_ON_SHUTDOWN = PROTOCOL_THREAD_SHUTDOWN, ///< Stop the thread
+ SYSTEM_ON_DESTROY = PROTOCOL_THREAD_DESTROY ///< Destroy the thread
+} SystemModeProtocol;
+
+#endif /* __NATIVESERVICES_SYSTEM_MODE_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_timer_if.h b/nsframework/framework_unified/client/include/native_service/ns_timer_if.h
new file mode 100644
index 00000000..549fc4c3
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_timer_if.h
@@ -0,0 +1,317 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_timer_if.h
+ * @brief \~english APIs to create, delete and use Native Service timers .
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_TIMER_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_TIMER_H__
+
+#include <native_service/frameworkunified_types.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TIMER_QUE "TIMER"
+
+#define MAX_SERVICE_NAME 15
+
+/// \brief Timer Function Pointer definition
+/// Detailed description of the class
+typedef void (*TimerCb)(UI_16 cmd);
+
+/// \brief Timer info, defines the initial
+/// start of a timer, the repeat timer
+/// values and the cmd id for a timer
+typedef struct _NSTimerInfo {
+
+// UI_32 t_sec;
+ time_t t_sec;
+ UI_64 t_nsec;
+ UI_16 iCmd;
+
+// UI_32 rpt_sec;
+ time_t rpt_sec;
+ UI_64 rpt_nsec;
+} NSTimerInfo;
+
+/// \brief Enum Types for valid Callback Mechanisms for
+/// a NS_Timer
+typedef enum _NSTimerCallbackMechanism {
+ CALLBACK_MESSAGE
+} eNSTimerCallbackMechanism;
+
+/// \brief Helper methods that convert time provided in MS.
+/// mseconds
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup WholeSeconds
+/// \~english @par Brief
+/// Converts a time value in milliseconds (ms) to a time value in secods (s).
+/// \~english @param [in] ms
+/// UI_32 - Time value in milliseconds(0 to ULONG_MAX)
+/// \~english @retval Time value in seconds
+/// \~english @par Preconditons
+/// - none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Detail
+/// This function converts a time value in ms to a time value in s and returns it.\n
+/// For example, 12345ms obtains 12s as the conversion result.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Not applicable
+/// \~english @see
+/// none
+///
+/// \~english @par Brief
+/// Get the number of whole seconds in the milsecond number that was passed.
+/// \~english @param[in] ms
+/// UI_32 - time value in mil seconds
+/// \~english @retval Number of whole seconds in the number passed.
+/// \~english @par Preconditons
+/// \~english @par Change of internal status
+/// \~english @par Conditions of processing failure
+/// \~english @par Detail
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see
+/// none
+/////////////////////////////////////////////////////////////////////////////////////
+
+//UI_32 WholeSeconds(UI_32 ms);
+time_t WholeSeconds(UI_32 ms);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RemainderMs
+/// \~english @par Brief
+/// Get the number of remaining milseconds out of whole second for the number passed.
+/// \~english @param[in] ms
+/// UI_32 - time value in mil seconds
+/// \~english @retval Number of remaining mil seconds in the number passed.
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// none
+/// \~english @par Detail
+/// This function returns the time value in ms of the remainder from converting the time value in ms to the time value in s.\n
+/// For example, 12345ms obtains 345ms as the conversion result.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see
+/// none
+/////////////////////////////////////////////////////////////////////////////////////
+UI_32 RemainderMs(UI_32 ms);
+
+/////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup MSToNS
+/// \~english @par Brief
+/// Converts mil seconds to nano seconds.
+/// \~english @param[in] ms
+/// UI_32 - time value in mil seconds
+/// \~english @retval Number of nano seconds there are in mil seconds in the number passed.
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// none
+/// \~english @par Detail
+/// This function converts a time value in ms to a time value in ns and returns it.\n
+/// For example, 1234ms obtains 1234000000ns as the conversion result.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see
+/// none
+/////////////////////////////////////////////////////////////////////////////////////
+UI_64 MSToNS(UI_32 ms);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_TimerCreate
+/// \~english @par Brief
+/// to create an instance of a timer object, and start it
+/// \~english @param[in] timer_info
+/// NSTimerInfo - timer value represents an absolute expiration timeout
+/// \~english @param[in] cbMech
+/// eNSTimerCallbackMechanism - CALLBACKMECHANISM_ENUM - specifies the callback mechanism associated with the
+/// timer\n
+/// CALLBACK_MESSAGE will send a message to a message queue
+/// \~english @param[in] sndMqHndl
+/// HANDLE - implies a MESSAGE QUE HANDLE generated by McOpenSender() is specified
+/// \~english @retval Handle to the timer object or NULL on failure
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If HANDLE(sndMqHndl) is NULL, [NULL]
+/// - If the Callback mechanism (cbMech) specified in the arguments is not CALLBACK_MESSAGE [NULL]
+/// - If thread creation fails (reateTimerMonitoringThread(); returns eFrameworkunifiedStatusFail) [NULL]
+/// - Unable to allocate memory for timer handle structures [NULL]
+/// - Memory cannot be allocated for the timer-information struct. [NULL]
+/// - When the message queue name of the handle (sndMqHndl) specified in the arguments is NULL,[NULL]
+/// - If a system call (such as epoll_ctl()) is in error,[NULL]
+/// \~english @par Detail
+/// Creates an instance of a timer object, sends a CALLBACK_MESSAGE message to the message queue, and starts the timer.\n
+/// When McOpenSender() is executed to execute NS_TimerCreate, the handles should be closed if not needed.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see NS_TimerDelete,NS_TimerSetTime
+////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE NS_TimerCreate(NSTimerInfo timer_info, eNSTimerCallbackMechanism cbMech, HANDLE sndMqHndl);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_TimerDelete
+/// \~english @par Brief
+/// to delete an instance of a timer object
+/// \~english @param[in] hTimer
+/// HANDLE - a timer handle that was created via NS_TimerCreate
+/// \~english @retval EFrameworkunifiedStatus indicates if the timer handle was delete successfully
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusFail
+/// \~english @retval eFrameworkunifiedStatusInvldParam
+/// \~english @par Preconditons
+/// - NS_TimerCreate has generated a HANDLE of timers
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If HANDLE(hTimer) is NULL,[eFrameworkunifiedStatusInvldParam]
+/// - Initializes the state. [eFrameworkunifiedStatusFail]
+/// - Invalid timed objects for HANDLE(hTimer specified by arguments:[eFrameworkunifiedStatusInvldParam]
+/// - If semaphoring fails, [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// If the timer is set, the timer is stopped.\n
+/// Delete an instance of a timer object.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see NS_TimerCreate, NS_TimerSetTime
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NS_TimerDelete(HANDLE hTimer);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_TimerSetTime
+/// \~english @par Brief
+/// to start or stop a timer by setting the time interval associated
+/// with a timer, value of 0 in t_sec & t_nsec, will stop the timer.
+/// \~english @param[in] hTimer
+/// HANDLE - handle to timer that your specifying the timer to be set
+/// \~english @param[in] timer_info
+/// NSTimerInfo - timer value represents an absolute expiration timeout
+/// \~english @retval EFrameworkunifiedStatus indicates if the timer info was set successfully
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusInvldHandle
+/// \~english @retval eFrameworkunifiedStatusFail
+/// \~english @par Preconditons
+/// the timer must have already been created with NS_TimerCreate
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If HANDLE(hTimer) is NULL,[eFrameworkunifiedStatusInvldHandle]
+/// - Initializes the state. [eFrameworkunifiedStatusFail]
+/// - Retrieving timers fails [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// When the timer information (t_sec and t_nsec) is 0, the timer is stopped.\n
+/// If it is not 0, the timer is started based on the timer information.\n
+/// The hTimer must have been created with NS_TimerCreate.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see NS_TimerCreate, NS_TimerGetTime
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NS_TimerSetTime(HANDLE hTimer, NSTimerInfo timer_info);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_TimerGetTime
+/// \~english @par Brief
+/// to retrieve the time until a timer expires
+/// \~english @param[in] hTimer
+/// HANDLE - handle to timer that your trying to get information about
+/// \~english @param[out] timer_info
+/// NSTimerInfo* - a structure to store the delay time until the timer expires
+/// \~english @retval EFrameworkunifiedStatus indicates if the timer info was get successfully
+/// \~english @retval eFrameworkunifiedStatusOK
+/// \~english @retval eFrameworkunifiedStatusInvldHandle
+/// \~english @retval eFrameworkunifiedStatusFail
+/// \~english @par Preconditons
+/// - NS_TimerCreate has generated a HANDLE of timers
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// - If HANDLE(hTimer) is NULL,[eFrameworkunifiedStatusInvldHandle]
+/// - If the timer_info specified in the arguments is NULL,... [eFrameworkunifiedStatusInvldHandle]
+/// - Initializes the state. [eFrameworkunifiedStatusFail]
+/// - If the timerdelete fails.... [eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Gets the time until the timer expires.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see NS_TimerCreate, NS_TimerSetTime
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NS_TimerGetTime(HANDLE hTimer, NSTimerInfo *timer_info);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_TimerDebugOn
+/// \~english @par Brief
+/// to make a flag for the debugging process. for debug.
+/// \~english @param[in] FlagState
+/// BOOL - DebugFlag state
+/// \~english @retval none
+/// \~english @par Preconditons
+/// none
+/// \~english @par Change of internal status
+/// - The internal state is not changed.
+/// \~english @par Conditions of processing failure
+/// none
+/// \~english @par Detail
+/// Sets the debug flag specified by the argument.\n
+/// However, if the set flag is the same as the flag specified in the argument, no operation is performed.
+/// \~english @par Classification
+/// \~english @par Type
+/// \~english @see none
+////////////////////////////////////////////////////////////////////////////////////////////
+void NS_TimerDebugOn(BOOL FlagState);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __NATIVESERVICES_TIMER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_timer_if.hpp b/nsframework/framework_unified/client/include/native_service/ns_timer_if.hpp
new file mode 100644
index 00000000..ffcd8c8a
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_timer_if.hpp
@@ -0,0 +1,393 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSTimer
+/// \brief Header file for Timer class.
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_timer_if.hpp
+ * @brief \~english Header file for Timer class.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef NS_TIMER_IF_HPP_ // NOLINT (build/header_guard)
+#define NS_TIMER_IF_HPP_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_timer_if.h>
+
+/**
+ * @class NSTimer
+ * \~english @brief Handle Timer
+ * \~english @par Brief Introduction
+ * Timer class is using to handle the timer.creating, starting, stopping,and so on.
+ *
+ */
+class NSTimer {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Creates a timer object with default behavior as single timeout timer.
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// -To create the instance of this class.init the member var using m_hTimer, m_u64TimeInterval,
+ /// m_bRepeatTimer.\n
+ /// Default status,all time will be set 0.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -
+ /// \~english @see ~NSTimer
+ ////////////////////////////////////////////////////////////////////////////////////
+ NSTimer();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Deletes a timer object.
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// -Instance of this class is created successfully.
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// -Destruct the instance of this class.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see NSTimer
+ ////////////////////////////////////////////////////////////////////////////////////
+ ~NSTimer();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// This function overloads \ref SetNotifyMethod().
+ /// On timeout, sends the command id to the message queue of specified application.
+ /// Resets previous notify method if any.
+ /// \~english @param[in] notifyCmdId
+ /// UI_16 - command id.
+ /// \~english @param[in] notifyToAppName
+ /// PCSTR - Send command id to the message queue of this application
+ /// \~english @retval EFrameworkunifiedStatus - Returns eFrameworkunifiedStatusOK if the action is set otherwise eFrameworkunifiedStatusFail
+ /// \~english @retval eFrameworkunifiedStatusOK - Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam - Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusFail - process error
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// - Pointer of AppName specified by argument(notifyToAppName) is NULL [eFrameworkunifiedStatusInvldParam]
+ /// - Bytes of AppName specified by argument(notifyToAppName) are larger then MAX_SERVICE_NAME(15byte)
+ /// [eFrameworkunifiedStatusInvldParam]
+ /// - There isn't enough buffer(malloc) to storage message queue name, when getting(McOpenSender) message queue
+ /// handle [eFrameworkunifiedStatusFail]
+ /// - Bytes of message queue name are larger then LIMIT_QUEUE_NAME_SIZE(16byte), when getting(McOpenSender)
+ /// message queue handle [eFrameworkunifiedStatusFail]
+ /// - Failed to get message queue(mq_open), when getting(McOpenSender) message queue handle [eFrameworkunifiedStatusFail]
+ /// - There isn't enough buffer(malloc) to storage message queue information, when getting(McOpenSender) message
+ /// queue handle [eFrameworkunifiedStatusFail]
+ /// - Failed to create(epoll_create1) file descriptor for epoll, when creating timer handle(NS_TimerCreate)
+ /// [eFrameworkunifiedStatusFail]
+ /// - Failed to create(eventfd) file descriptor for event notification, when creating timer
+ /// handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - Failed to connect(epoll_ctl) file descriptors for epoll and event notification, when creating timer
+ /// handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - Failed to create(pthread_create) timer thread for event notification, when creating timer
+ /// handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - There isn't enough buffer(malloc) to storage timer handle structure, when creating timer
+ /// handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - There isn't enough buffer(malloc) to storage timer information structure,, when creating timer
+ /// handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - Message queue handle is INVALID_HANDLE(-1), when creating timer handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - Checking code of message queue handle is not MQ_CHECK_CODE, when creating timer handle(NS_TimerCreate)
+ /// [eFrameworkunifiedStatusFail]
+ /// - Type of message queue handle is not send/receive, when creating timer handle(NS_TimerCreate)
+ /// [eFrameworkunifiedStatusFail]
+ /// - Failed to create(timerfd_create) file descriptor for timer, when creating timer handle(NS_TimerCreate)
+ /// [eFrameworkunifiedStatusFail]
+ /// - Failed to connect(epoll_ctl) file descriptors for epoll and timer, when creating timer
+ /// handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// - Timer handle state of instance has been deleted(DELETED_STATE), when creating timer handle(NS_TimerCreate)
+ /// [eFrameworkunifiedStatusFail]
+ /// - Failed to start/stop(timerfd_settime) timer, when creating timer handle(NS_TimerCreate) [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// This function overloads \ref SetNotifyMethod().
+ /// On timeout, sends the command id to the message queue of specified application.
+ /// Create a timer handle(m_hTimer) of instance, if the time handle already exits, delete it then create a new
+ /// one.
+ /// If there is resource for timer notification before, reset it.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see McOpenSender, McClose, NS_TimerCreate
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetNotifyMethod(UI_16 notifyCmdId, PCSTR notifyToAppName);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Sets the timer as a repeat timer. Timer timeouts repeatedly as per the interval set.
+ /// Default timer fires only once.
+ /// Not effective, if the timer is running. Effective on next \ref Start() or \ref Start(seconds, msecs) call.
+ /// \~english @param[in] repeatTimer
+ /// BOOL - TRUE - set repeat timer
+ /// FALSE - set single timeout timer. (Default behavior)
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// -None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// Sets the timer as a repeat timer. Timer timeouts repeatedly as per the interval set.
+ /// Default timer fires only once.
+ /// Not effective, if the timer is running. Effective on next \ref Start() or \ref Start(seconds, msecs) call.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////
+ VOID SetRepeatTimer(BOOL repeatTimer);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Set the interval of timeout. Interval is addition of seconds and milliseconds passed as an arguments.
+ /// \~english @param[in] seconds
+ /// UI_32 - Time in seconds
+ /// \~english @param[in] msecs
+ /// UI_64 - Time in milliseconds
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// Set the interval of timeout. Interval is addition of seconds and milliseconds passed as an arguments.
+ /// The default value of interval time is 0.
+ /// If interval time is 0, stop timer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////
+ VOID SetTime(UI_32 seconds, UI_64 msecs);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// This function overloads SetTime(). Set the interval of timeout. Interval is addition of hrs,
+ /// mins, seconds and milliseconds passed as an arguments.
+ /// \~english @param[in] hrs
+ /// UI_32 - Time in hours
+ /// \~english @param[in] mins
+ /// UI_64 - Time in minutes
+ /// \~english @param[in] seconds
+ /// UI_32 - Time in seconds
+ /// \~english @param[in] msecs
+ /// UI_64 - Time in milliseconds
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// This function overloads SetTime(). Set the interval of timeout. Interval is addition of hrs,
+ /// mins, seconds and milliseconds passed as an arguments.
+ /// The default value of interval time is 0.
+ /// If interval time is 0, stop timer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see none
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetTime(UI_32 hrs, UI_32 mins, UI_32 seconds, UI_64 msecs);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Starts or restarts timer with specified time interval. Interval is addition of seconds and
+ /// milliseconds passed as an arguments.
+ /// \~english @param[in] seconds
+ /// UI_32 - Time in seconds
+ /// \~english @param[in] msecs
+ /// UI_64 - Time in milliseconds
+ /// \~english @retval EFrameworkunifiedStatus - Returns eFrameworkunifiedStatusOK on success otherwise eFrameworkunifiedStatusFail
+ /// \~english @par Preconditons
+ /// - Create a timer handle of instance by SetNotifyMethod()
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// - Timer handle of instance is NULL [eFrameworkunifiedStatusFail]
+ /// - Timer handle state of instance has been deleted(DELETED_STATE) [eFrameworkunifiedStatusFail]
+ /// - Failed to start/stop(timerfd_settime) timer [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// Starts or restarts timer with specified time interval. Interval is addition of seconds and
+ /// milliseconds passed as an arguments.
+ /// Interval time setted by this method will overwrite interval time setted by SetTime(UI_32, UI_64).
+ /// If interval time is 0, stop timer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// - None
+ /// \~english @see SetTime(UI_32, UI_64), Start, Stop, SetNotifyMethod
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Start(UI_32 seconds, UI_64 msecs);
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// This function overloads Start(). Starts or restarts timer with interval specified using SetTime()
+ /// or last interval (if the timer was started before using Start(seconds, msecs)).
+ /// \~english @retval EFrameworkunifiedStatus - Returns eFrameworkunifiedStatusOK on success otherwise eFrameworkunifiedStatusFail
+ /// \~english @par Preconditons
+ /// - Create a timer handle of instance by SetNotifyMethod()
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// - Timer handle of instance is NULL [eFrameworkunifiedStatusFail]
+ /// - Timer handle state of instance has been deleted(DELETED_STATE) [eFrameworkunifiedStatusFail]
+ /// - Failed to start/stop(timerfd_settime) timer [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - Starts or restarts timer with interval specified using SetTime(UI_32, UI_64) or Start(UI_32, UI_64).
+ /// If interval time is not setted, default value is 0. If interval time is 0, stop timer.
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// - None
+ /// \~english @see SetTime(UI_32, UI_64), Stop, SetNotifyMethod, WholeSeconds, MSToNS, NS_TimerSetTime
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Start();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Stops the timer
+ /// \~english @retval EFrameworkunifiedStatus - Returns eFrameworkunifiedStatusOK on success otherwise eFrameworkunifiedStatusFail
+ /// \~english @par Preconditons
+ /// - Create a timer handle of instance by SetNotifyMethod()
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// - Timer handle of instance is NULL [eFrameworkunifiedStatusFail]
+ /// - Timer handle state of instance has been deleted(DELETED_STATE) [eFrameworkunifiedStatusFail]
+ /// - Failed to stop(timerfd_settime) timer [eFrameworkunifiedStatusFail]
+ /// \~english @par Detail
+ /// - Stops the timer
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// - None
+ /// \~english @see Start, Start(UI_32, UI_64), SetNotifyMethod, NS_TimerSetTime
+ ////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Stop();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Returns timer running status
+ /// \~english @retval BOOL - TRUE if timer is running else FALSE
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// -Returns timer running status
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see Start, Start(UI_32, UI_64), SetNotifyMethod, NS_TimerSetTime
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsRunning();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NSTimer
+ /// \~english @par Brief
+ /// Returns timeout interval in milliseconds
+ /// \~english @retval UI_64 - Timeout interval in milliseconds
+ /// \~english @par Preconditons
+ /// -None
+ /// \~english @par Change of internal status
+ /// None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// - Returns timeout interval in milliseconds
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// -None
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_64 GetInterval();
+
+ private:
+
+ HANDLE m_hTimer; ///< Corresponding NS timer handle
+
+ UI_64 m_u64TimeInterval; ///< time interval in milliseconds
+
+ BOOL m_bRepeatTimer; ///< if it is a repeat timer. Default value is false.
+};
+
+
+#endif // NS_TIMER_IF_HPP_ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_transmit_log.h b/nsframework/framework_unified/client/include/native_service/ns_transmit_log.h
new file mode 100644
index 00000000..e61ec7ef
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_transmit_log.h
@@ -0,0 +1,256 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSSharedMemory
+/// \brief This file contains declaration of wrapper C type API's for class CNSSharedMem
+/// to read and write transmit log to shared memory.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_transmit_log.h
+ * @brief \~english This file contains declaration of wrapper C type API for reading and writing
+ * transmit log on shared memory.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_LOG_H__ // NOLINT (build/header_guard)
+#define __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_LOG_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define TRANSMIT_LOG_SHAREDMEM_NAME "/TransmitLogShBuf"
+#define TRANSMIT_LOG_SHAREDMEM_SIZE 5242880 // 5MB
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSSharedMemTransmitLogOpen
+/// \~english @par Brief
+/// Open the shared memory for transmit logging.
+/// \~english @param[in]
+/// \~english @retval eFrameworkunifiedStatusOK if shared memory is opened.
+/// \~english @retval eFrameworkunifiedStatusNullPointer if memory allocation error while creating shared memory pointer.
+/// \~english @retval eFrameworkunifiedStatusFail if shared memory not open
+/// \~english @par Preconditons
+/// - None
+/// \~english @par Change of internal status
+/// - Open shared memory object
+/// \~english @par Conditions of processing failure
+/// - Memory allocation error while creating shared memory pointer.[eFrameworkunifiedStatusNullPointer]
+/// - If shared memory not open.[eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Open the shared memory for transmit logging.\n
+/// If shared memory is not exist,then create a shared memory,and open.
+/// \~english @par Classification
+/// - public
+/// \~english @par Type
+/// - sync only
+/// \~english @par
+/// - eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Failure
+/// \~english @see NSSharedMemTransmitLogClose
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemTransmitLogOpen();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSSharedMemTransmitLogClose
+/// \~english @par Brief
+/// Close the transmit logging shared memory
+/// \~english @param[in]
+/// \~english @retval eFrameworkunifiedStatusOK if shared memory is closed
+/// \~english @retval eFrameworkunifiedStatusNullPointer if shared memory pointer is NULL.
+/// \~english @retval eFrameworkunifiedStatusFail if shared memory was not closed.
+/// \~english @par Preconditons
+/// - None
+/// \~english @par Change of internal status
+/// -Open shared memory object
+/// \~english @par Conditions of processing failure
+/// - shared memory pointer is NULL.[eFrameworkunifiedStatusNullPointer]
+/// - If shared memory not close.[eFrameworkunifiedStatusFail]
+/// \~english @par Detail
+/// Close the transmit logging shared memory.\n
+/// If shared memory closed failure or shared memory don't exist,then return failure.
+/// \~english @par Classification
+/// - public
+/// \~english @par Type
+/// - sync only
+/// \~english @par
+/// - eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Failure
+/// \~english @see NSSharedMemTransmitLogOpen
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemTransmitLogClose();
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSSharedMemReadTransmitLog
+/// \~english @par Brief
+/// Reads transmit log from the shared memory buffer.
+/// \~english @param [in] f_pBuffer
+/// PSTR - pointer to the buffer in which data to be read.
+/// \~english @param [in] f_uiLength
+/// UI_32 - length of the data to be read.
+/// \~english @param [in] f_bBlock
+/// BOOL - TRUE - blocking call
+/// FALSE - non blocking call
+/// \~english @retval Except NS_SHM_ERROR - Indicates the number of bytes read.
+/// \~english @retval NS_SHM_ERROR -if shared memory is not opened.
+/// \~english @par Preconditons
+/// -None
+/// \~english @par Change of internal status
+/// None
+/// \~english @par Conditions of processing failure
+/// if g_pTransmitLogSharedBuf or f_pBuffer is null.[NS_SHM_ERROR]
+/// \~english @par Detail
+/// If this function is used as blocking call,\n
+/// then the calling thread will get blocked until data is available for read.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par
+/// - l_iReadSize:Result
+/// - NS_SHM_ERROR:Failure
+/// - Except NS_SHM_ERROR:Success
+/// \~english @see NSSharedMemWriteTransmitLog
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 NSSharedMemReadTransmitLog(PSTR f_pBuffer, const UI_32 f_uiLength, const BOOL f_bBlock);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSSharedMemWriteTransmitLog
+/// \~english @par Brief
+/// Write transmit log into the shared memory buffer.
+/// \~english @param [in] f_pBuffer
+/// PSTR - pointer to the buffer containing the data to be written.
+/// \~english @param [in] f_uiLength
+/// UI_32 - length of the data buffer to be written.
+/// \~english @retval Except NS_SHM_ERROR - Indicates the number of bytes written,
+/// \~english @retval NS_SHM_ERROR -if shared memory is not opened.
+/// \~english @par Preconditons
+/// -None
+/// \~english @par Change of internal status
+/// None
+/// \~english @par Conditions of processing failure
+/// if g_pTransmitLogSharedBuf or f_pBuffer is null.[NS_SHM_ERROR]
+/// \~english @par Detail
+/// If this function is used as blocking call,\n
+/// then the calling thread will get blocked until data is available for write.
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// sync only
+/// \~english @par
+/// - l_iReadSize:Result
+/// - NS_SHM_ERROR:Failure
+/// - Except NS_SHM_ERROR:Success
+/// \~english @see NSSharedMemReadTransmitLog
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 NSSharedMemWriteTransmitLog(PCSTR f_pBuffer, const UI_32 f_uiLength);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSSharedMemDumpTransmitLogToFile
+/// \~english @par Brief
+/// Dump the transmit logging shared memory to file
+/// \~english @param [in] f_pPath
+/// PCSTR - full file path
+/// \~english @param [in] f_puiSize
+/// PCSTR - Size of data dumped to file
+/// \~english @retval eFrameworkunifiedStatusOK if shared memory is closed
+/// \~english @retval eFrameworkunifiedStatusFileLoadError file path is incorrect
+/// \~english @retval eFrameworkunifiedStatusSemLockFail/
+/// eFrameworkunifiedStatusSemUnLockFail - mutex locking/unlocking error
+/// \~english @retval eFrameworkunifiedStatusFail shared memory is not open
+/// \~english @par Preconditons
+/// - None
+/// \~english @par Change of internal status
+/// -Open shared memory object
+/// \~english @par Conditions of processing failure
+/// - shared memory pointer is NULL.[eFrameworkunifiedStatusNullPointer]
+/// - mutex locking/unlocking error.[eFrameworkunifiedStatusSemLockFail/eFrameworkunifiedStatusSemUnLockFail]
+/// - shared memory is not open.[eFrameworkunifiedStatusFail]
+/// - file path is incorrect.[eFrameworkunifiedStatusFileLoadError]
+/// \~english @par Detail
+/// Writes all the data in the buffer into provided file path.\n
+/// Overwrites the file if it exists.
+/// \~english @par Classification
+/// - public
+/// \~english @par Type
+/// - sync only
+/// \~english @par
+/// - eFrameworkunifiedStatus:Result
+/// - eFrameworkunifiedStatusOK:Success
+/// - Except eFrameworkunifiedStatusOK:Failure
+/// \~english @see None
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSSharedMemDumpTransmitLogToFile(PCSTR f_pPath, PUI_32 f_puiDumpSize);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NSSharedMemTransmitLogIsOpen
+/// \~english @par Brief
+/// This function is used to check whether the shared memory buffer is opened or not.
+/// \~english @retval TRUE - Open
+/// \~english @retval FALSE - Not open
+/// \~english @par Preconditons
+/// - None
+/// \~english @par Change of internal status
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Detail
+/// - This function is used to check whether the shared memory buffer is opened or not.\n
+/// Used only in nstest_sharedmem.
+/// \~english @par Classification
+/// - public
+/// \~english @par Type
+/// Sync only
+/// \~english @see none
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL NSSharedMemTransmitLogIsOpen();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NATIVESERVICES_NATIVESERVICES_INC_NATIVE_NS_SHAREDMEM_LOG_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_util_crc.h b/nsframework/framework_unified/client/include/native_service/ns_util_crc.h
new file mode 100644
index 00000000..55280071
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_util_crc.h
@@ -0,0 +1,111 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \brief This file contains declaration of APIs to calcuate 16-bit and 32-bit CRC checksum of file.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_util_crc.h
+ */
+
+#ifndef NS_NS_UTILITYCENTER_INC_NS_UTIL_CRC_H_ // NOLINT (build/header_guard)
+#define NS_NS_UTILITYCENTER_INC_NS_UTIL_CRC_H_
+
+#include <native_service/frameworkunified_types.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup utility
+ * @ingroup framework_unified
+ * @{
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Calculate the CRC value of the file
+/// \~english @param [in] f_c_file_name
+/// PCSTR - the file to be calculated
+/// \~english @param [out] f_ui_check_sum
+/// UI_16 - the CRC value of the file
+/// \~english @retval eFrameworkunifiedStatusOK : Success
+/// \~english @retval eFrameworkunifiedStatusFileLoadError : File Load Error
+/// \~english @retval eFrameworkunifiedStatusInvldParam : Invalid Param
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - Failed to open the file. [eFrameworkunifiedStatusFileLoadError]
+/// - The pointer f_c_file_name is NULL. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function calculates the CRC value(16 bit) of the file f_c_file_name.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CalculateCRC16(PCSTR f_c_file_name, UI_16 & f_ui_check_sum); // NOLINT (readability/nolint)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Calculate the CRC value of the file
+/// \~english @param [in] f_c_file_name
+/// PCSTR - the file to be calculated
+/// \~english @param [out] f_ui_check_sum
+/// UI_32 - the CRC value of the file
+/// \~english @retval eFrameworkunifiedStatusOK : Success
+/// \~english @retval eFrameworkunifiedStatusFileLoadError : File Load Error
+/// \~english @retval eFrameworkunifiedStatusInvldParam : Invalid Param
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - Failed to open the file. [eFrameworkunifiedStatusFileLoadError]
+/// - The pointer f_c_file_name is NULL. [eFrameworkunifiedStatusInvldParam]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function calculates the CRC value(32 bit) of the file f_c_file_name.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CalculateCRC32(PCSTR f_c_file_name, UI_32 & f_ui_check_sum); // NOLINT (readability/nolint)
+
+#endif // NS_NS_UTILITYCENTER_INC_NS_UTIL_CRC_H_ // NOLINT (build/header_guard)
+
+/** @}*/ // end of utility
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_util_directory.h b/nsframework/framework_unified/client/include/native_service/ns_util_directory.h
new file mode 100644
index 00000000..945275c0
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_util_directory.h
@@ -0,0 +1,160 @@
+/**
+ * @file ns_util_directory.h
+ * @brief \~english This file contains declaration of ns_util_directory.
+ *
+ */
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief This file contains utility functions to handle file and folder operations.
+///
+///
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef NS_NS_UTILITYCENTER_INC_NS_UTIL_DIRECTORY_H_ // NOLINT (build/header_guard)
+#define NS_NS_UTILITYCENTER_INC_NS_UTIL_DIRECTORY_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <vector>
+#include <string>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup utility
+ * @ingroup framework_unified
+ * @{
+ */
+
+/**
+ * \~english an abbreviation for std::vector<std::string>
+ */
+typedef std::vector< std::string > TFileList;
+
+/**
+ * \~english a abbreviation for std::vector<std::string>::iterator
+ */
+typedef TFileList::iterator TFileListIterator;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Get the name of files existing in a specific directory
+/// \~english @param [in] f_pc_path
+/// PCSTR - the directory path
+/// \~english @param [out] f_pv_tfile_list
+/// TFileList - store the name of the files in the specific directory
+/// \~english @retval eFrameworkunifiedStatusOK : Success
+/// \~english @retval eFrameworkunifiedStatusInvldParam : Invalid Param
+/// \~english @retval eFrameworkunifiedStatusNullPointer : NULL Pointer
+/// \~english @retval eFrameworkunifiedStatusFail : Abnormal Error
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - The pointer f_pv_tfile_list or f_pc_path is NULL. [eFrameworkunifiedStatusInvldParam]
+/// - Failed to open the directory f_pc_path. [eFrameworkunifiedStatusFail]
+/// - Failed to new a buffer for inner using. [eFrameworkunifiedStatusNullPointer]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function gets all the name of the file locating at the directory f_pc_path and stores \n
+/// them in f_pv_tfile_list.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus GetFileList(TFileList * f_pv_tfile_list, PCSTR f_pc_path);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Check whether the directory is existing or not.
+/// \~english @param [in] f_c_dir_path
+/// std::string - the directory to be checked
+/// \~english @retval TRUE: the directory is existing.
+/// FALSE: the directory is not existing.
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - None
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function checks whether the directory is existing or not.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL DoesDirecotryExist(std::string f_c_dir_path);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup NS_UtilityCenter
+/// \~english @par Brief
+/// Create the directory f_c_dir_path.
+/// \~english @param [in] f_c_dir_path
+/// std::string - the directory to be created
+/// \~english @retval eFrameworkunifiedStatusOK : Success
+/// \~english @retval eFrameworkunifiedStatusFail : Abnormal Error
+///
+/// \~english @par Prerequisite
+/// - None
+/// \~english @par Change of internal state
+/// - None
+/// \~english @par Conditions of processing failure
+/// - The input param f_c_dir_path is empty. [eFrameworkunifiedStatusFail]
+/// - Faild to create(mkdir) the direcory. [eFrameworkunifiedStatusFail]
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// The function creates the directory f_c_dir_path.
+/// \~english @see
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CreateDirectory(std::string f_c_dir_path);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NS_NS_UTILITYCENTER_INC_NS_UTIL_DIRECTORY_H_ NOLINT (build/header_guard)
+
+/** @}*/ // end of utility
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_utility.hpp b/nsframework/framework_unified/client/include/native_service/ns_utility.hpp
new file mode 100644
index 00000000..07fe4f55
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_utility.hpp
@@ -0,0 +1,572 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_UtilityCenter
+/// \brief This file contains declaration of common APIs for NS_UtilityCenter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//@{
+/**
+ * @file ns_utility.hpp
+ * @brief \~english This file contains declaration of common APIs for NS_UtilityCenter.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __NSFRAMEWORK_NSUTILITY_NSUTILITY__ // NOLINT (build/header_guard)
+#define __NSFRAMEWORK_NSUTILITY_NSUTILITY__
+
+#include <native_service/frameworkunified_types.h>
+#include <new>
+#include <exception>
+#include <algorithm>
+#include <iterator>
+
+#ifdef AGL_STUB
+#include <stdexcept>
+#endif
+
+// Macros ///////////////////////////////////////////////////////////////
+
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName& )
+
+#define DEFINE_EXCEPTION( name, base ) \
+class name : public base \
+{ \
+public: \
+ name ( const char* str = "" ) : base ( str ) \
+ {} \
+}
+
+// Helpful type definitions ////////////////////////////////////////////////
+template <int v>
+struct Int2Type {
+ enum { value = v }; // NOLINT (readability/nolint)
+};
+
+template <class T>
+struct Type2Type {
+ typedef T Type;
+};
+
+// Helpful Fucntions /////////////////////////////////////////////////////////
+template< class T, UI_32 N >
+const T *ArrBeg(const T(&arr)[ N ]) {
+ return &arr[ 0 ];
+}
+
+template< class T, UI_32 N >
+const T *ArrEnd(const T(&arr)[ N ]) {
+ return &arr[ 0 ] + N;
+}
+
+template< class O, class I >
+O SimpleCast(I i) {
+ return static_cast< O >(i);
+}
+
+template< class R, class B >
+R UnalignedRet(B *b) {
+ return *reinterpret_cast< R volatile * >(b);
+}
+
+template< class Cont, class Gen >
+Cont genRange(UI_32 N, Gen genFn) {
+ Cont c;
+ std::generate_n(std::back_inserter(c), N, genFn);
+ return c;
+}
+
+template< class OCont, class IIter, class MapFn >
+OCont mapRange(const IIter &begin, const IIter &end, MapFn fn) {
+ OCont c;
+ std::transform(begin, end, std::inserter(c, c.begin()), fn);
+ return c;
+}
+// Static Compile-time list creation /////////////////////////////////////////
+
+#ifdef AGL_STUB
+#else
+////////////////////////
+#include <_pack1.h> //
+//////////////////////////
+#endif
+
+template< class T, UI_32 N >
+struct TList {
+ T datum;
+ TList < T, N - 1 > data;
+
+ T *operator&() { // NOLINT (readability/nolint)
+ return reinterpret_cast< T * >(this);
+ }
+ const T *operator&() const { // NOLINT (readability/nolint)
+ return reinterpret_cast< const T * >(this);
+ }
+ static const UI_32 count = N; // NOLINT (readability/nolint)
+
+};
+
+template< class T >
+struct TList< T, 1 > {
+ T datum;
+
+ T *operator&() { // NOLINT (readability/nolint)
+ return reinterpret_cast< T * >(this);
+ }
+ const T *operator&() const { // NOLINT (readability/nolint)
+ return reinterpret_cast< const T * >(this);
+ }
+ static const UI_32 count = 1; // NOLINT (readability/nolint)
+
+};
+
+#ifdef AGL_STUB
+#else
+/////////////////////////
+#include <_packpop.h> //
+///////////////////////
+#endif
+
+// Function Decomposition ///////////////////////////////////////////////////
+
+template< class Sig >
+struct FSig {
+};
+
+template<class R>
+struct FSig< R(*)() > {
+ typedef R RType;
+ static const UI_32 argCount = 0; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1>
+struct FSig< R(*)(T1) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ static const UI_32 argCount = 1; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1, class T2>
+struct FSig< R(*)(T1, T2) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ typedef T2 TArg2;
+ static const UI_32 argCount = 2; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1, class T2, class T3>
+struct FSig< R(*)(T1, T2, T3) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ typedef T2 TArg2;
+ typedef T3 TArg3;
+ static const UI_32 argCount = 3; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1, class T2, class T3, class T4>
+struct FSig< R(*)(T1, T2, T3, T4) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ typedef T2 TArg2;
+ typedef T3 TArg3;
+ typedef T4 TArg4;
+ static const UI_32 argCount = 4; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1, class T2, class T3, class T4, class T5>
+struct FSig< R(*)(T1, T2, T3, T4, T5) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ typedef T2 TArg2;
+ typedef T3 TArg3;
+ typedef T4 TArg4;
+ typedef T5 TArg5;
+ static const UI_32 argCount = 5; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1, class T2, class T3, class T4, class T5, class T6>
+struct FSig< R(*)(T1, T2, T3, T4, T5, T6) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ typedef T2 TArg2;
+ typedef T3 TArg3;
+ typedef T4 TArg4;
+ typedef T5 TArg5;
+ typedef T6 TArg6;
+ static const UI_32 argCount = 6; // NOLINT (readability/nolint)
+};
+
+template<class R, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
+struct FSig< R(*)(T1, T2, T3, T4, T5, T6, T7) > {
+ typedef R RType;
+ typedef T1 TArg1;
+ typedef T2 TArg2;
+ typedef T3 TArg3;
+ typedef T4 TArg4;
+ typedef T5 TArg5;
+ typedef T6 TArg6;
+ typedef T7 TArg7;
+ static const UI_32 argCount = 7; // NOLINT (readability/nolint)
+};
+
+
+
+// Accumulator definition //////////////////////////////////////////////////
+
+/// \brief Accumultor type
+///
+/// An accumulator is an object that keeps an internal counter, and will increment its
+/// counter by n, which defaults to 1, each time operator() is called on it. Eample usage:
+///
+/// Accumulator< int > a( 42 ); // initialize a to 42
+/// int v1 = a(); // <-- v1 == 43
+/// int v2 = a(); // <-- v2 == 44
+/// int v4 = a(10); // <-- v4 == 54
+/// int v5 = a(); // <-- v5 == 55
+template<typename T>
+class Accumulator {
+ public:
+ Accumulator(T n) : n(n) {}
+
+ template<typename U>
+ Accumulator(const Accumulator<U> &u) : n(u.n) {}
+
+ T operator()(T i = 1) { // NOLINT (readability/nolint)
+ return operator()< T >(i);
+ }
+
+ template<typename U>
+ T operator()(U i) {
+ return n += i;
+ }
+
+ template< typename U >
+ friend class Accumulator;
+
+ private:
+ T n;
+};
+
+
+/// \brief Accumulator utility function
+///
+/// Given a value n of type T, returns an accumulator of type Accumulator<T> initialized to value n
+template<typename T>
+Accumulator<T> MakeAccumulator(T n) {
+ return Accumulator<T>(n);
+}
+
+// Rsrc Management helper class /////////////////////////////////////////////
+
+template< class T >
+class MemTraits {
+ public:
+ typedef T *Type;
+ typedef std::bad_alloc Exception;
+ static void Release(Type rsrc) {
+ delete rsrc;
+ }
+
+ static BOOL BadValue(Type rsrc) {
+ return NULL == rsrc;
+ }
+};
+
+template< class RsrcTraits >
+class RaiseExceptionPolicy {
+ public:
+ typedef typename RsrcTraits::Type Type;
+ static Type check(Type t) { // NOLINT (readability/nolint)
+ if (RsrcTraits::BadValue(t)) {
+ throw typename RsrcTraits::Exception();
+ }
+
+ return t;
+ }
+};
+
+template< class RsrcTraits >
+class CheckForErrorPolicy { // no exceptions
+ public:
+ typedef typename RsrcTraits::Type Type;
+
+ static Type check(Type t) { // NOLINT (readability/nolint)
+ return t;
+ }
+
+ static bool isValid(Type t) { // NOLINT (readability/nolint)
+ return ! RsrcTraits::BadValue(t);
+ }
+};
+
+template < class T,
+ class RsrcTraits = MemTraits< T >,
+ template <class> class ErrorPolicy = RaiseExceptionPolicy >
+class ResourceMgr : public RsrcTraits {
+ public:
+ typedef typename RsrcTraits::Type Type;
+ typedef ErrorPolicy< RsrcTraits > TFullErrorPolicy;
+
+ ResourceMgr(Type rsrc) : m_rsrc(TFullErrorPolicy::check(rsrc)) {}
+
+ ~ResourceMgr() {
+ RsrcTraits::Release(m_rsrc);
+ }
+
+ operator Type() { // NOLINT (readability/nolint)
+ return m_rsrc;
+ }
+
+ operator const Type() const { // NOLINT (readability/nolint)
+ return m_rsrc;
+ }
+
+ bool isValid() const { // NOLINT (readability/nolint)
+ return TFullErrorPolicy::isValid(m_rsrc);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ResourceMgr);
+
+ Type m_rsrc;
+};
+
+// Functor Helper classes /////////////////////////////////////
+template< class R >
+class IFunctor {
+ public:
+ IFunctor() {}
+ virtual ~IFunctor() {}
+
+ virtual R operator()() const = 0; // NOLINT (readability/nolint)
+ virtual UI_32 size() const = 0; // NOLINT (readability/nolint)
+};
+
+template< class TFn >
+class CFunctor0 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+ CFunctor0(TFn fn) : m_function(fn) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function();
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn);
+ }
+
+ private:
+ TFn m_function;
+};
+
+template< class TFn, class Arg1 >
+class CFunctor1 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+
+ CFunctor1(TFn fn, Arg1 arg1) : m_function(fn), m_arg1(arg1) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1);
+ }
+
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+};
+
+template< class TFn, class Arg1, class Arg2 >
+class CFunctor2 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+
+ CFunctor2(TFn fn, Arg1 arg1, Arg2 arg2) : m_function(fn), m_arg1(arg1), m_arg2(arg2) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1, m_arg2);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1) + sizeof(Arg2);
+ }
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+ Arg2 m_arg2;
+};
+
+template< class TFn, class Arg1, class Arg2, class Arg3 >
+class CFunctor3 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+
+ CFunctor3(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3) : m_function(fn), m_arg1(arg1), m_arg2(arg2), m_arg3(arg3) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1, m_arg2, m_arg3);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1) + sizeof(Arg2) + sizeof(Arg3);
+ }
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+ Arg2 m_arg2;
+ Arg3 m_arg3;
+};
+
+template< class TFn, class Arg1, class Arg2, class Arg3, class Arg4 >
+class CFunctor4 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+ CFunctor4(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) : m_function(fn), m_arg1(arg1), m_arg2(arg2),
+ m_arg3(arg3), m_arg4(arg4) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1, m_arg2, m_arg3, m_arg4);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1) + sizeof(Arg2) + sizeof(Arg3) + sizeof(Arg4);
+ }
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+ Arg2 m_arg2;
+ Arg3 m_arg3;
+ Arg4 m_arg4;
+};
+
+template< class TFn, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5 >
+class CFunctor5 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+ CFunctor5(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5) : m_function(fn), m_arg1(arg1), m_arg2(arg2),
+ m_arg3(arg3), m_arg4(arg4), m_arg5(arg5) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1, m_arg2, m_arg3, m_arg4, m_arg5);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1) + sizeof(Arg2) + sizeof(Arg3) + sizeof(Arg4) + sizeof(Arg5);
+ }
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+ Arg2 m_arg2;
+ Arg3 m_arg3;
+ Arg4 m_arg4;
+ Arg5 m_arg5;
+};
+
+template< class TFn, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6 >
+class CFunctor6 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+ CFunctor6(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6) : m_function(fn), m_arg1(arg1),
+ m_arg2(arg2), m_arg3(arg3), m_arg4(arg4), m_arg5(arg5), m_arg6(arg6) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1) + sizeof(Arg2) + sizeof(Arg3) + sizeof(Arg4) + sizeof(Arg5) + sizeof(Arg6);
+ }
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+ Arg2 m_arg2;
+ Arg3 m_arg3;
+ Arg4 m_arg4;
+ Arg5 m_arg5;
+ Arg6 m_arg6;
+};
+
+template< class TFn, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7 >
+class CFunctor7 : public IFunctor< typename FSig< TFn >::RType > {
+ public:
+ CFunctor7(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7)
+ : m_function(fn), m_arg1(arg1), m_arg2(arg2), m_arg3(arg3), m_arg4(arg4), m_arg5(arg5), m_arg6(arg6), m_arg7(arg7) {}
+ typename FSig< TFn >::RType operator()() const { // NOLINT (readability/nolint)
+ return m_function(m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7);
+ }
+ UI_32 size() const { // NOLINT (readability/nolint)
+ return sizeof(TFn) + sizeof(Arg1) + sizeof(Arg2) + sizeof(Arg3) + sizeof(Arg4) + sizeof(Arg5) + sizeof(Arg6) + sizeof(Arg7);
+ }
+ private:
+ TFn m_function;
+ Arg1 m_arg1;
+ Arg2 m_arg2;
+ Arg3 m_arg3;
+ Arg4 m_arg4;
+ Arg5 m_arg5;
+ Arg6 m_arg6;
+ Arg7 m_arg7;
+};
+
+
+template<class TFn>
+CFunctor0<TFn> functor(TFn fn) {
+ return CFunctor0<TFn>(fn);
+}
+
+template<class TFn, class Arg1>
+CFunctor1<TFn, Arg1> functor(TFn fn, Arg1 arg1) {
+ return CFunctor1<TFn, Arg1>(fn, arg1);
+}
+
+template<class TFn, class Arg1, class Arg2>
+CFunctor2<TFn, Arg1, Arg2> functor(TFn fn, Arg1 arg1, Arg2 arg2) {
+ return CFunctor2<TFn, Arg1, Arg2>(fn, arg1, arg2);
+}
+
+template<class TFn, class Arg1, class Arg2, class Arg3>
+CFunctor3<TFn, Arg1, Arg2, Arg3> functor(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
+ return CFunctor3<TFn, Arg1, Arg2, Arg3>(fn, arg1, arg2, arg3);
+}
+
+template<class TFn, class Arg1, class Arg2, class Arg3, class Arg4>
+CFunctor4<TFn, Arg1, Arg2, Arg3, Arg4> functor(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) {
+ return CFunctor4<TFn, Arg1, Arg2, Arg3, Arg4>(fn, arg1, arg2, arg3, arg4);
+}
+
+template<class TFn, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
+CFunctor5<TFn, Arg1, Arg2, Arg3, Arg4, Arg5> functor(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5) {
+ return CFunctor5<TFn, Arg1, Arg2, Arg3, Arg4, Arg5>(fn, arg1, arg2, arg3, arg4, arg5);
+}
+
+template<class TFn, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
+CFunctor6<TFn, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6> functor(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4,
+ Arg5 arg5, Arg6 arg6) {
+ return CFunctor6<TFn, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(fn, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+
+template<class TFn, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
+CFunctor7<TFn, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7> functor(TFn fn, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4,
+ Arg5 arg5, Arg6 arg6, Arg7 arg7) {
+ return CFunctor7<TFn, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+}
+
+#endif // __NSFRAMEWORK_NSUTILITY_NSUTILITY__ NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
+//@}
diff --git a/nsframework/framework_unified/client/include/native_service/ns_utility_if.h b/nsframework/framework_unified/client/include/native_service/ns_utility_if.h
new file mode 100644
index 00000000..ee103376
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_utility_if.h
@@ -0,0 +1,76 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief This file contains declaration of common APIs for NS_UtilityCenter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @file ns_utility_if.h
+ */
+
+#ifndef NS_NATIVESERVICES_INC_NATIVE_NS_UTILITY_IF_H_ // NOLINT (build/header_guard)
+#define NS_NATIVESERVICES_INC_NATIVE_NS_UTILITY_IF_H_
+
+#include <native_service/frameworkunified_types.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+
+/**
+ * \~english Macro for invalid/undefined return
+ */
+#define NS_INVALID_RETURN -1
+
+/**
+ * \~english Macro for setting the i bit of x to one
+ */
+#define NS_SETBIT(x, i) ((x) |= (1 << (i)))
+
+/**
+ * \~english Macro for setting the i bit of x to zero
+ */
+#define NS_CLEARBIT(x, i) ((x) &= ~(1 << (i)))
+
+/**
+ * \~english Macro for making the exclusive-OR operator on the i bit of x with one
+ */
+#define NS_TOGGLEBIT(x, i) ((x) ^= (1 << (i)))
+
+/**
+ * \~english Macro for checking whether the i bit of x is one or not
+ */
+#define NS_ISBITSET(x, i) (((x) & (1 << (i))) != 0)
+
+#endif // NS_NATIVESERVICES_INC_NATIVE_NS_UTILITY_IF_H_ // NOLINT (build/header_guard)
+
+/** @}*/ // end of native
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_utility_sys.hpp b/nsframework/framework_unified/client/include/native_service/ns_utility_sys.hpp
new file mode 100644
index 00000000..5780144d
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_utility_sys.hpp
@@ -0,0 +1,321 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief This file contains declaration of common APIs for NS_UtilityCenter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_utility_sys.hpp
+ */
+
+#ifndef __NSFRAMEWORK_NSUTILITY_NSUTILITYSYS__ // NOLINT (build/header_guard)
+#define __NSFRAMEWORK_NSUTILITY_NSUTILITYSYS__
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_utility.hpp>
+#include <pthread.h>
+#include <errno.h>
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+
+// Lock Wrapper ////////////////////////////////////////////////////////////////
+
+/**
+ * \~english define the lock_error class inherit from std::runtime_error
+ */
+DEFINE_EXCEPTION(lock_error, std::runtime_error);
+
+/**
+ * \~english define the lock_creation_error class inherit from lock_error
+ */
+DEFINE_EXCEPTION(lock_creation_error, lock_error);
+
+/**
+ * \~english define the lock_acquireread_error class inherit from lock_error
+ */
+DEFINE_EXCEPTION(lock_acquireread_error, lock_error);
+
+/**
+ * \~english define the lock_acquirewrite_error class inherit from lock_error
+ */
+DEFINE_EXCEPTION(lock_acquirewrite_error, lock_error);
+
+/**
+ * \~english define the lock_release_error class inherit from lock_error
+ */
+DEFINE_EXCEPTION(lock_release_error, lock_error);
+
+
+/**
+ * @class CMutex
+ * @brief \~english Mutex Lock Class
+ * @par \~english Brief Introduction
+ * \~english This class defines locking policy for Mutexes.
+ *
+ */
+class CMutex {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Construct a CMutex object.
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function constructs a CMutex object.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CMutex();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Destruct the CMutex object.
+ /// \~english @par Prerequisite
+ /// - Construct a CMutex object
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function destructs the CMutex object.
+ /// \~english @see CMutex()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CMutex();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Lock the CMutex object when reading.
+ /// \~english @retval void
+ ///
+ /// \~english @par Prerequisite
+ /// - Construct a CMutex object
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function locks the CMutex object when reading.
+ /// \~english @see CMutex(), WriteLock(), UnLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ void ReadLock();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Lock the CMutex object when writing.
+ /// \~english @retval void
+ ///
+ /// \~english @par Prerequisite
+ /// - Construct a CMutex object
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function locks the CMutex object when writing.
+ /// \~english @see CMutex(), ReadLock(), UnLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ void WriteLock();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Open the lock of the CMutex object.
+ /// \~english @retval void
+ ///
+ /// \~english @par Prerequisite
+ /// - Construct a CMutex object
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function opens the lock of the CMutex object.
+ /// \~english @see CMutex(), ReadLock(), WriteLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ void Unlock();
+
+ private:
+
+ pthread_mutex_t m_mtx;
+};
+
+/**
+ * @class CRWLock
+ * @brief \~english Read/Write Lock Class
+ * @par \~english Brief Introduction
+ * \~english This class defines locking policy for reader/writer.
+ *
+ */
+class CRWLock {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// - Construct a CRWLock object.
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function constructs a CRWLock object.
+ /// \~english @see ~CRWLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CRWLock();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Destruct the CRWLock object.
+ /// \~english @par Prerequisite
+ /// - Construct a CRWLock object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function destructs the CRWLock object.
+ /// \~english @see CRWLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CRWLock();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Lock the CRWLock object when reading.
+ /// \~english @retval void
+ ///
+ /// \~english @par Prerequisite
+ /// - Construct a CRWLock object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function locks the CRWLock object when reading.
+ /// \~english @see CRWLock(), WriteLock(), UnLoack()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ void ReadLock();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Lock the CRWLock object when writing.
+ /// \~english @retval void
+ ///
+ /// \~english @par Prerequisite
+ /// - Construct a CRWLock object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function locks the CRWLock object when writing.
+ /// \~english @see CRWLock(), ReadLock(), UnLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ void WriteLock();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Open the lock of CRWLock object
+ /// \~english @retval void
+ ///
+ /// \~english @par Prerequisite
+ /// - Construct a CRWLock object.
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function opens the lock of the CRWLock object.
+ /// \~english @see CRWLock(), ReadLock(), WriteLock()
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ void Unlock();
+
+ private:
+ pthread_rwlock_t m_rwl;
+};
+
+#endif // __NSFRAMEWORK_NSUTILITY_NSUTILITYSYS__ // NOLINT (build/header_guard)
+/** @}*/ // end of native
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_version.h b/nsframework/framework_unified/client/include/native_service/ns_version.h
new file mode 100644
index 00000000..fad7efff
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_version.h
@@ -0,0 +1,48 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_version.h
+ * @brief \~english This file provides version define
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef VERSION_H_ // NOLINT (build/header_guard)
+#define VERSION_H_
+
+#define MAJORNO 0x02
+#define MINORNO 0x02
+#define REVISION 0x05
+
+#endif /* VERSION_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_version_if.h b/nsframework/framework_unified/client/include/native_service/ns_version_if.h
new file mode 100644
index 00000000..d0f5172e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_version_if.h
@@ -0,0 +1,510 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Header for CFrameworkunifiedVersion class
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_version_if.h
+* @brief \~english Header for CFrameworkunifiedVersion class
+ */
+
+#ifndef NS_NATIVESERVICES_INC_NATIVE_NS_VERSION_IF_H_ // NOLINT (build/header_guard)
+#define NS_NATIVESERVICES_INC_NATIVE_NS_VERSION_IF_H_
+#include <native_service/frameworkunified_types.h>
+#include <string.h>
+
+#ifdef AGL_STUB
+#include <other_service/strlcpy.h>
+#include <other_service/strlcat.h>
+#endif
+
+
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup native
+ * @ingroup framework_unified
+ * @{
+ */
+
+/**
+ * @class CFrameworkunifiedVersion
+ * @brief \~english Version Info Class
+ * @par \~english Brief Introduction
+ * \~english This class provides functions to get various information of the version.
+ *
+ */
+class CFrameworkunifiedVersion {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Construct a CFrameworkunifiedVersion object.
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function constructs a CFrameworkunifiedVersion object.
+ /// \~english @see ~CFrameworkunifiedVersion
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedVersion();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Constructs a CFrameworkunifiedVersion object with parameters.
+ /// \~english @param[in] major
+ /// UI_16 - Major number of the application
+ /// \~english @param[in] minor
+ /// UI_16 - Minor number of the application
+ /// \~english @param[in] revision
+ /// UI_16 - Revision number of the application
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function constructs a CFrameworkunifiedVersion object with parameters.
+ /// \~english @see ~CFrameworkunifiedVersion
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFrameworkunifiedVersion(UI_16 major, UI_16 minor, UI_16 revision);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Destruct the CFrameworkunifiedVersion object.
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function destructs the CFrameworkunifiedVersion object.
+ /// \~english @see CFrameworkunifiedVersion
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CFrameworkunifiedVersion();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the data number
+ /// \~english @param [in] a
+ /// CFrameworkunifiedVersion - the CFrameworkunifiedVersion object that will be compared against b.
+ /// \~english @param [in] b
+ /// CFrameworkunifiedVersion - the CFrameworkunifiedVersion object that will be compared against a.
+ /// \~english @retval TRUE: Match, FALSE: Does not Match
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function is a friend function of the class. \n
+ /// The function checks whether the object matchs the other or not. Match: returns TRUE, \n
+ /// Does not match: returns FALSE.
+ /// \~english @see operator ==
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ friend BOOL operator == (CFrameworkunifiedVersion &a, CFrameworkunifiedVersion &b); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the data number
+ /// \~english @param [in] f_test_i
+ /// CFrameworkunifiedVersion - the CFrameworkunifiedVersion object that will be compared against this obj.
+ /// \~english @retval TRUE: Match, FALSE: Does not Match
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function checks whether the object matchs the other or not. Match: returns TRUE, \n
+ /// Does not match: returns FALSE.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL operator == (const CFrameworkunifiedVersion &f_test_i); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the version as string
+ /// \~english @retval the vision string
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the version string.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ PCSTR VersionStr();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the date as string
+ /// \~english @retval the date string
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the date when building.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ PCSTR DateStr();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the signature number
+ /// \~english @retval the signature
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the signature number.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 Signature() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the structure version number
+ /// \~english @retval the structure version number
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the structure version number.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 StrucVersion() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the product version
+ /// \~english @retval the product version
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the product version.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 ProductVersion() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the date as number
+ /// \~english @retval the date number
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the date as number.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 Date() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the major verion number
+ /// \~english @retval the major version number
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the major version number.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_16 Major() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the minor version number
+ /// \~english @retval the minor version number
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the minor version number.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_16 Minor() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the unique product identifier
+ /// \~english @retval the revision number
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the unique product identifier generated by the build server.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ PCSTR Product() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the building version string
+ /// \~english @retval the building version string
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the unique build identifier generated by the build server.
+ /// \~english @see
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ PCSTR Build() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NS_UtilityCenter
+ /// \~english @par Brief
+ /// Get the revision number
+ /// \~english @retval the revision number
+ ///
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Change of internal state
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// The function returns the revision as number.
+ /// \~english @see CFrameworkunifiedVersion
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_16 Revision() const;
+
+ private:
+ CFrameworkunifiedVersion(const CFrameworkunifiedVersion &);
+ CFrameworkunifiedVersion &operator= (const CFrameworkunifiedVersion &); // NOLINT (readability/nolint)
+ struct VersionInfo {
+ PSTR p_str_product;
+ UI_32 u32_signature;
+ UI_32 u32_struc_version;
+ UI_32 u32_product_version;
+ UI_32 u32_date;
+ UI_16 u16_major;
+ UI_16 u16_minor;
+ PSTR p_str_build;
+ UI_16 u16_revision;
+ VersionInfo(PSTR p, UI_32 a, UI_32 b, UI_32 c, UI_32 d, UI_16 e, UI_16 f , PSTR g, UI_16 h) :
+ u32_signature(a),
+ u32_struc_version(b),
+ u32_product_version(c),
+ u32_date(d),
+ u16_major(e),
+ u16_minor(f),
+ u16_revision(h) {
+ size_t length = strlen(p) + 1;
+ p_str_product = new CHAR[length]; // LCOV_EXCL_BR_LINE 11:except branch
+ if (NULL != p_str_product) { // LCOV_EXCL_BR_LINE 5:new's error case
+ memset(p_str_product, 0, length);
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(p_str_product, p, length);
+#endif
+ }
+
+ length = strlen(g) + 1;
+ p_str_build = new CHAR[length]; // LCOV_EXCL_BR_LINE 11:except branch
+ if (NULL != p_str_build) { // LCOV_EXCL_BR_LINE 5:new's error case
+ memset(p_str_build, 0, length);
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(p_str_build, g , length);
+#endif
+ }
+ }
+ ~VersionInfo() {
+ delete[] p_str_product; // LCOV_EXCL_BR_LINE 11:except branch
+ p_str_product = NULL;
+ delete[] p_str_build; // LCOV_EXCL_BR_LINE 11:except branch
+ p_str_build = NULL;
+ }
+ } m_tVersionInfo;
+ UI_32 m_u32Month;
+ UI_32 m_u32Year;
+ UI_32 m_u32Day;
+};
+
+/**
+ * \~english define macro for version string
+ */
+#define FRAMEWORKUNIFIED_GET_VERSION() "undefined_undefined_00.00.00"
+
+/**
+ * \~english define macro for the major number of the version
+ */
+#define FRAMEWORKUNIFIED_APP_VERSION_MAJOR() (0)
+
+/**
+ * \~english define macro for the minor number of the version
+ */
+#define FRAMEWORKUNIFIED_APP_VERSION_MINOR() (0)
+
+/**
+ * \~english define macro for the revision number
+ */
+#define FRAMEWORKUNIFIED_APP_VERSION_REVISION() (0)
+
+/**
+ * \~english define macro for the building version
+ */
+#define FRAMEWORKUNIFIED_APP_VERSION_BUILDVER() "undefined"
+
+/**
+ * \~english define macro for product version
+ */
+#define FRAMEWORKUNIFIED_APP_VERSION_PRODUCTID() "undefined"
+
+#endif // NS_NATIVESERVICES_INC_NATIVE_NS_VERSION_IF_H_ // NOLINT (build/header_guard)
+/** @}*/ // end of native
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_writer.h b/nsframework/framework_unified/client/include/native_service/ns_writer.h
new file mode 100644
index 00000000..788b6a4f
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_writer.h
@@ -0,0 +1,229 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains declaration of class IConfigWriter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file ns_writer.h
+ * @brief \~english This file contains declaration of class IConfigWriter.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_CONFIG_WRITER_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_CONFIG_WRITER_H__ // NOLINT(build/header_guard)
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h> // NOLINT(build/header_guard)
+#include <string>
+
+
+/**
+ * @class IConfigWriter
+ * \~english @brief Config writer abstract class.
+ * \~english @par Brief Introduction
+ * IConfigWriter is an abstract class which is inherited by\n
+ * different type configuration file writer class.
+ *
+ */
+class IConfigWriter {
+ public:
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigWriter
+ /// \~english @par Brief
+ /// Constructor of IConfigWriter class
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - To get a instance of this class.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see ~IConfigWriter
+ ////////////////////////////////////////////////////////////////////////////////////
+ IConfigWriter();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~IConfigWriter
+ /// \~english @par Brief
+ /// Destructor of IConfigWriter class
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// - Destruct the object of this class.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see IConfigWriter
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual ~IConfigWriter();
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigWriter
+ /// \~english @par Brief
+ /// This function is used to parse the file.
+ /// \~english @param [in] f_c_filepath
+ /// std::string - path of file to parse
+ /// \~english @retval EFrameworkunifiedStatus - success or failure
+ /// \~english @par Preconditons
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function is used to parse the file.
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus ParseFile(const std::string &f_c_filepath) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigWriter
+ /// \~english @par Brief
+ /// This function is used to set the value for the key
+ /// \~english @param [in] f_c_key
+ /// std::string - key to search
+ /// \~english @param [in] f_c_value
+ /// std::string - value to set
+ /// \~english @retval EFrameworkunifiedStatus - error if key not found else eFrameworkunifiedStatusOK
+ /// \~english @par Preconditons
+ /// - Calls constructor to successfully create object.
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function is used to set the value for the key
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus SetValue(const std::string &f_c_key, std::string f_c_value) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigWriter
+ /// \~english @par Brief
+ /// This function is used to save the changed value permanently to the config source
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function is used to save the changed value permanently to the config source
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus SaveData() = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigWriter
+ /// \~english @par Brief
+ /// This function is used to set the config file path
+ /// \~english @param [in] f_cpath
+ /// std::string - Path of file
+ /// \~english @retval EFrameworkunifiedStatus - success or failure
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function is used to set the config file path
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus SetPath(const std::string &f_cpath) = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IConfigWriter
+ /// \~english @par Brief
+ /// This function is used to set the data pointer in config writer class with data pointer\n
+ /// created in config reader class.\n
+ /// This is needed to avoid recreation of same data structure object in both reader and writer\n
+ /// when we create object of NSConfigParser.\n
+ /// \~english @param [in] f_pdata
+ /// PVOID - Pointer to data structure
+ /// \~english @retval None
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - None
+ /// \~english @par Conditions of processing failure
+ /// - None
+ /// \~english @par Detail
+ /// This function is used to set the data pointer in config writer class with data pointer\n
+ /// created in config reader class.\n
+ /// This is needed to avoid recreation of same data structure object in both reader and writer\n
+ /// when we create object of NSConfigParser.\n
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - Sync only
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////////
+ virtual VOID SetDataPtr(PVOID f_pdata) = 0;
+};
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_CONFIG_WRITER_H__ */ // NOLINT (build/header_guard)
+/** @}*/ // end of framework_unified
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/ns_xml_reader.h b/nsframework/framework_unified/client/include/native_service/ns_xml_reader.h
new file mode 100644
index 00000000..91e88c03
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_xml_reader.h
@@ -0,0 +1,291 @@
+/**
+ * @file ns_xml_reader.h
+ * @brief \~english This file contains declaration of class CXMLReader.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains declaration of class CXMLReader.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_READER_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_READER_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <libxml/tree.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_reader.h>
+#include <string>
+
+
+/**
+ * @class CXMLReader
+ * \~english @par Brief Introduction
+ * This class provides functionalities to read from XML config file.
+ *
+ */
+class CXMLReader: public IConfigReader {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXMLReader
+ /// \~english @par Brief
+ /// This API constructor of CXMLReader class.
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API should be called by ServiceA and create a new object of CXMLReader.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+ CXMLReader();
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXMLReader
+ /// \~english @par Brief
+ /// This API constructor of CXMLReader class.
+ /// \~english @param [IN] f_cFilePath
+ /// std::string - Full path of the configuration file
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API should be called by ServiceA and create a new object of CXMLReader with filepath.
+ /// \~english @see GetCXMLReaderObject
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXMLReader(const std::string &f_cFilePath); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CXMLReader
+ /// \~english @par CXMLReader
+ /// Destructor of CXMLReader class.
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// - Close shared memory object.
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// Destruct the object of CXMLReader
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @see CXMLReader
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CXMLReader();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ParseFile
+ /// \~english @par Brief
+ /// This API parser file
+ /// \~english @param [IN] f_cFilePath
+ /// std::string - path of file to parse
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// - Create XmlReader object.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API is used to parse the file from the path.
+ /// \~english @see CXMLReader or GetCXMLReaderObject
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus ParseFile(const std::string &f_cFilePath);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ParseFile
+ /// \~english @par Brief
+ /// Get Value with key
+ /// \~english @param [IN] f_cKey
+ /// std::string - key to search
+ /// \~english @retval std::string - value for key
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// - Create XmlReader object.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to get the value associated with the key
+ /// \~english @see CXMLReader or GetCXMLReaderObject
+ ////////////////////////////////////////////////////////////////////////////////
+ std::string GetValue(const std::string &f_cKey);
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ParseFile
+ /// \~english @par Brief
+ /// Get Value with key
+ /// \~english @param [IN] f_cKey
+ /// std::string - key to search
+ /// \~english @param [REF] f_cValue
+ /// std::string - Value of key
+ /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
+ /// \~english @retval eFrameworkunifiedStatusFail Failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// - Create XmlReader object.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to get the value associated with the key
+ /// \~english @see CXMLReader or GetCXMLReaderObject
+ ////////////////////////////////////////////////////////////////////////////////
+
+
+ EFrameworkunifiedStatus GetValue(const std::string &f_cKey, std::string &f_cValue); // NOLINT (readability/nolint)
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ParseFile
+ /// \~english @par Brief
+ /// Get Value with key
+ /// \~english @param None
+ /// \~english @retval PVOID - pointer of data structure
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// - Create XmlReader object.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to get the data pointer. This pointer is then set in config writer.
+ /// \~english @see CXMLReader or GetCXMLReaderObject
+ ////////////////////////////////////////////////////////////////////////////////
+ PVOID GetDataPtr();
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// XMLGetValue
+ /// This function is used to parse and get the value from xml file
+ ///
+ /// \param [IN] f_pCurrNode
+ /// xmlNodePtr - pointer to current node in xml
+ /// \param [IN] f_cUserKey
+ /// std::string - Key to be searched for
+ ///
+ /// \return std::string - content of key node
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string XMLGetValue(xmlNodePtr f_pCurrNode, const std::string &f_cUserKey);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// XMLGetValue
+ /// This function is used to parse and get the value from xml file
+ ///
+ /// \param [IN] f_pCurrNode
+ /// xmlNodePtr - pointer to current node in xml
+ /// \param [IN] f_cUserKey
+ /// std::string - Key to be searched for
+ /// \param [IN] f_cValue
+ /// std::string - Value of Key
+ /// \param [IN] f_bKeyFound
+ /// BOOL - flag to check whether key exists in xml file or not
+ ///
+ /// \return EFrameworkunifiedStatus - error if key not found or else eFrameworkunifiedStatusOK
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus XMLGetValue(xmlNodePtr f_pCurrNode,
+ const std::string &f_cUserKey, std::string &f_cValue, BOOL &f_bKeyFound); // NOLINT (readability/nolint)
+ // pointer of xml document structure(DOM)
+ xmlDocPtr m_pXmlDoc;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetCXMLReaderObject
+ /// \~english @par Brief
+ /// Get CXMLReader object.
+ /// \~english @param [IN] f_cFilePath
+ /// std::string - path of file to parse
+ /// \~english @retval CXMLReader *
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API is used to create CXMLReader object with file path and return the CXMLReader pointer.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+CXMLReader *GetCXMLReaderObject(CHAR *f_cFilePath);
+#ifdef __cplusplus
+}
+#endif
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_READER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_xml_writer.h b/nsframework/framework_unified/client/include/native_service/ns_xml_writer.h
new file mode 100644
index 00000000..7686553e
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_xml_writer.h
@@ -0,0 +1,336 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ns_xml_writer.h
+ * @brief \~english This file contains declaration of class CXMLWriter.
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_ConfigParser
+/// \brief This file contains declaration of class CXMLWriter.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_WRITER_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_WRITER_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <libxml/tree.h>
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_writer.h>
+
+#include <string>
+
+/**
+ * @class CXMLWriter
+ * \~english @brief this file has the CXMLWriter class definitions
+ * \~english @par Brief Introduction
+ * This class provides functionalities to write to XML config file
+ *
+ */
+class CXMLWriter: public IConfigWriter {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXMLWriter
+ /// \~english @par Brief
+ /// Parameterless Constructor of CXMLWriter class
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API should be called by ServiceA and create a new object without file path of CXMLWriter
+ /// \~english @see GetCXMLWriterObjectNoParam
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXMLWriter();
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXMLWriter
+ /// \~english @par Brief
+ /// Constructor of CXMLWriter class
+ /// \~english @param [IN] f_cFilePath
+ /// std::string - Full path of the configuration file
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API should be called by ServiceA and create a new object with file path of CXMLWriter
+ /// \~english @see GetCXMLWriterObject
+ ////////////////////////////////////////////////////////////////////////////////
+ CXMLWriter(const std::string &f_cFilePath); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ~CXMLWriter
+ /// \~english @par CXMLWriter
+ /// Destructor of CXMLWriter class.
+ /// \~english @param None
+ /// \~english @retval none
+ /// \~english @par Preconditons
+ /// - None
+ /// \~english @par Change of internal status
+ /// -None
+ /// \~english @par Conditions of processing failure
+ /// -None
+ /// \~english @par Detail
+ /// Destruct the object of CXMLWriter
+ /// \~english @par Classification
+ /// - Public
+ /// \~english @par Type
+ /// - sync only
+ /// \~english @see CXMLWriter
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CXMLWriter();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ParseFile
+ /// \~english @par Brief
+ /// Parse file
+ /// \~english @param [IN] f_cFilePath
+ /// std::string - path of file to parse
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Create CXMLWriter object
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to parse the file
+ /// \~english @see CXMLWriter
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus ParseFile(const std::string &f_cFilePath);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetValue
+ /// \~english @par Brief
+ /// Set vaule for key
+ /// \~english @param [IN] f_cKey
+ /// std::string - key to search
+ /// \~english @param [IN] f_cValue
+ /// std::string - value to set
+ /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
+ /// \~english @retval eFrameworkunifiedStatusFail Failed
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Create CXMLWriter object
+ /// - ParseFile set the path
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to set the value for the key
+ /// \~english @see CXMLWriter,ParseFile
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus SetValue(const std::string &f_cKey, std::string f_cValue);
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SaveData
+ /// \~english @par Brief
+ /// Save changed data
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
+ /// \~english @retval eFrameworkunifiedStatusFail Failed
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Create CXMLWriter object
+ /// - ParseFile set the path
+ /// - Change the data
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to save the changed value to the xml config file
+ /// \~english @see GetCXMLWriterObjectNoParam
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus SaveData();
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetPath
+ /// \~english @par Brief
+ /// Updata file path
+ /// \~english @param [IN] f_cPath
+ /// std::string - Path of file
+ /// \~english @retval eFrameworkunifiedStatusOK Success / Pass / OK
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Create CXMLWriter object
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to set the config file path
+ /// \~english @see GetCXMLWriterObjectNoParam
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus SetPath(const std::string &f_cPath);
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetDataPtr
+ /// \~english @par Brief
+ /// Parse file
+ /// \~english @param [IN] f_pData
+ /// PVOID - Pointer to data structure
+ /// \~english @retval VOID
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Create CXMLWriter object
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This function is used to set the data pointer in config writer class
+ /// \~english @see CXMLWriter
+ ////////////////////////////////////////////////////////////////////////////////
+
+ VOID SetDataPtr(PVOID f_pData);
+
+ private:
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// XMLSetValue
+/// This function is used to parse the value from xml file
+///
+/// \param [IN] f_pCurrNode
+/// xmlNodePtr - pointer to current node in xml
+/// \param [IN] f_cUserKey
+/// std::string - Key to be searched for
+/// \param [IN] f_cValue
+/// std::string - Required Value for key
+/// \param [IN] f_bKeyFound
+/// std::string - Flag to check whether key is present in xml file
+///
+/// \return EFrameworkunifiedStatus- success or failure
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus XMLSetValue(xmlNodePtr f_pCurrNode,
+ const std::string &f_cUserKey, // NOLINT (readability/nolint)
+ std::string &f_cValue, // NOLINT (readability/nolint)
+ BOOL &f_bKeyFound); // NOLINT (readability/nolint)
+
+// pointer of xml document structure(DOM)
+ xmlDocPtr m_pXmlDoc;
+
+// path of config file
+ std::string m_cFilePath;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetCXMLWriterObject
+ /// \~english @par Brief
+ /// Get CXMLWriter object.
+ /// \~english @param [IN] f_cFilePath
+ /// std::string - path of file to parse
+ /// \~english @retval CXMLWriter *
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API is used to create CXMLWriter object with file path and return the CXMLWriter pointer.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+CXMLWriter *GetCXMLWriterObject(CHAR *f_cFilePath);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetCXMLWriterObjectNoParam
+ /// \~english @par Brief
+ /// Get CXMLWriter object.
+ /// \~english @param None
+ /// \~english @retval CXMLWriter *
+ /// \~english @par Prerequisite
+ /// - Load the shared library first.
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync
+ /// \~english @par Detail
+ /// This API is used to create CXMLWriter object without file path and return the CXMLWriter pointer.
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+
+CXMLWriter *GetCXMLWriterObjectNoParam();
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NSCONFIGPARSER_INC_NS_XML_WRITER_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/ns_xmlparser_if.h b/nsframework/framework_unified/client/include/native_service/ns_xmlparser_if.h
new file mode 100644
index 00000000..f944dddb
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/ns_xmlparser_if.h
@@ -0,0 +1,1150 @@
+/**
+ * @file ns_xmlparser_if.h
+ * @brief \~english This file contains declaration of class CXmlParser, CXmlNode and CXmlAttr.
+ * This file provides the interface for Parsing XML file, API for operation on node
+ * of an xml structure.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FRAMEWORKUNIFIED_NATIVESERVICES_NS_XMLPARSER_INC_NS_XMLPARSER_IF_H__ // NOLINT (build/header_guard)
+#define __FRAMEWORKUNIFIED_NATIVESERVICES_NS_XMLPARSER_INC_NS_XMLPARSER_IF_H__
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#include <string>
+#include <list>
+
+// defines the type of xml nodes
+/**
+ * \~english type of xml nodes
+ */
+typedef enum _EFrameworkunifiedXmlNodeTypes {
+ FRAMEWORKUNIFIED_XML_NODE_NONE = 0, //!< \~english not exist node
+ FRAMEWORKUNIFIED_XML_ELEMENT_NODE = 1, //!< \~english element node
+ FRAMEWORKUNIFIED_XML_ATTRIBUTE_NODE = 2, //!< \~english attribute node
+ FRAMEWORKUNIFIED_XML_TEXT_NODE = 3, //!< \~english text node
+ FRAMEWORKUNIFIED_XML_CDATA_SECTION_NODE = 4, //!< \~english section node
+ FRAMEWORKUNIFIED_XML_ENTITY_REF_NODE = 5, //!< \~english entity ref node
+ FRAMEWORKUNIFIED_XML_ENTITY_NODE = 6, //!< \~english entity node
+ FRAMEWORKUNIFIED_XML_PI_NODE = 7, //!< \~english PI node
+ FRAMEWORKUNIFIED_XML_COMMENT_NODE = 8, //!< \~english comment node
+ FRAMEWORKUNIFIED_XML_DOCUMENT_NODE = 9, //!< \~english document node
+ FRAMEWORKUNIFIED_XML_DOCUMENT_TYPE_NODE = 10, //!< \~english document type node
+ FRAMEWORKUNIFIED_XML_DOCUMENT_FRAG_NODE = 11, //!< \~english document frag node
+ FRAMEWORKUNIFIED_XML_NOTATION_NODE = 12, //!< \~english notation node
+ FRAMEWORKUNIFIED_XML_HTML_DOCUMENT_NODE = 13, //!< \~english document node
+ FRAMEWORKUNIFIED_XML_DTD_NODE = 14, //!< \~english dtd node
+ FRAMEWORKUNIFIED_XML_ELEMENT_DECL = 15, //!< \~english element decl
+ FRAMEWORKUNIFIED_XML_ATTRIBUTE_DECL = 16, //!< \~english attribute decl
+ FRAMEWORKUNIFIED_XML_ENTITY_DECL = 17, //!< \~english entity decl
+ FRAMEWORKUNIFIED_XML_NAMESPACE_DECL = 18, //!< \~english namespace decl
+ FRAMEWORKUNIFIED_XML_XINCLUDE_START = 19, //!< \~english include start
+ FRAMEWORKUNIFIED_XML_XINCLUDE_END = 20, //!< \~english include end
+ FRAMEWORKUNIFIED_XML_DOCB_DOCUMENT_NODE = 21 //!< \~english document node
+} EFrameworkunifiedXmlNodeTypes;
+
+// forward declaration
+class CXmlNode;
+class CXmlAttr;
+
+// list of CXmlNode
+typedef std::list<CXmlNode> TNodeList;
+typedef TNodeList::iterator TNodeListIterator;
+
+// list of CXmlAttr
+typedef std::list<CXmlAttr> TAttrList;
+typedef std::list<CXmlAttr>::iterator TAttrListIterator;
+
+
+/**
+ * @class CXmlNode
+ * \~english @brief This class represents node of an XML.
+ * \~english @par Brief Introduction
+ * Provides API for performing operations on node.
+ *
+ */
+class CXmlNode {
+ friend class CXmlParser;
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXmlNode
+ /// \~english @par Brief
+ /// Destructor of CXmlNode class
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Inside state change
+ /// - None
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Destructor of CXmlNode class
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+ ~CXmlNode();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup IsNull
+ /// \~english @par Brief
+ /// Check xmlNodePtr
+ /// \~english @param None
+ /// \~english @retval BOOL true if valid else false
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Checks whether the corresponding xmlNodePtr is valid or not
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ BOOL IsNull();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Type
+ /// \~english @par Brief
+ /// Get type
+ /// \~english @param None
+ /// \~english @retval FRAMEWORKUNIFIED_XML_NODE_NONE not exist node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_ELEMENT_NODE element node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_TEXT_NODE text node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_CDATA_SECTION_NODE section node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_ENTITY_REF_NODE entity ref node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_ENTITY_NODE entity node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_PI_NODE PI node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_COMMENT_NODE comment node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_DOCUMENT_NODE document node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_DOCUMENT_TYPE_NODE document type node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_DOCUMENT_FRAG_NODE document frag node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_NOTATION_NODE notation node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_HTML_DOCUMENT_NODE document node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_DTD_NODE dtd node
+ /// \~english @retval FRAMEWORKUNIFIED_XML_ELEMENT_DECL element decl
+ /// \~english @retval FRAMEWORKUNIFIED_XML_ATTRIBUTE_DECL attribute decl
+ /// \~english @retval FRAMEWORKUNIFIED_XML_ENTITY_DECL entity decl
+ /// \~english @retval FRAMEWORKUNIFIED_XML_NAMESPACE_DECL namespace decl
+ /// \~english @retval FRAMEWORKUNIFIED_XML_XINCLUDE_START include start
+ /// \~english @retval FRAMEWORKUNIFIED_XML_XINCLUDE_END include end
+ /// \~english @retval FRAMEWORKUNIFIED_XML_DOCB_DOCUMENT_NODE document node
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Gets the type of XML node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedXmlNodeTypes Type();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Name
+ /// \~english @par Brief
+ /// Get name
+ /// \~english @param None
+ /// \~english @retval std::string node name
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the name/tag of an XML node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ std::string Name();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetContent
+ /// \~english @par Brief
+ /// Get content
+ /// \~english @param None
+ /// \~english @retval std::string content of current node
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Gets the content of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ std::string GetContent();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetContent
+ /// \~english @par Brief
+ /// Set content
+ /// \~english @param [IN] f_cUpdatedText
+ /// std::string - updated value
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set or update the content of current node. If the node has children then it removes all the child
+ /// nodes and sets the content for the current node.
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus SetContent(std::string f_cUpdatedText);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetAttributeValue
+ /// \~english @par Brief
+ /// Get attribute
+ /// \~english @param [IN] f_cKey
+ /// std::string - attribute name
+ /// \~english @param [OUT] f_cAttributeValue
+ /// std::string& - attribute value
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the attribute's value for the key
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus GetAttributeValue(std::string f_cKey, std::string &f_cAttributeValue); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SetAttributeValue
+ /// \~english @par Brief
+ /// Set attribute
+ /// \~english @param [IN] f_cKey
+ /// std::string - attribute name
+ /// \~english @param [IN] f_cValue
+ /// std::string - attribute value
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Set the attribute's value for the key
+ /// If attribute is not found then new attribute key-value pair is created and added to node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus SetAttributeValue(std::string f_cKey, std::string f_cValue);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup AddNewAttribute
+ /// \~english @par Brief
+ /// Add new attribute
+ /// \~english @param [IN] f_cKey
+ /// std::string - attribute name
+ /// \~english @param [IN] f_cValue
+ /// std::string - attribute value
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Add new attribute to the node. If the attribute key is existing then it updates the existing
+ /// value with the new value or else adds the new attribute
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus AddNewAttribute(std::string f_cKey, std::string f_cAttributeValue);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RemoveAttribute
+ /// \~english @par Brief
+ /// Removes attribute
+ /// \~english @param [IN] f_cKey
+ /// std::string - attribute name
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Remove the attribute from the node with the specified key
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus RemoveAttribute(std::string f_cKey);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetAttributeItems
+ /// \~english @par Brief
+ /// Get attributes list
+ /// \~english @param None
+ /// \~english @retval TAttrList - list of all attributes of node or empty list in case of no attributes
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the list of all the attribute's key and value of the node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ TAttrList GetAttributeItems();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Parent
+ /// \~english @par Brief
+ /// Get parent
+ /// \~english @param None
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the parent node of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+
+ CXmlNode Parent();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FirstChild
+ /// \~english @par Brief
+ /// Get first child
+ /// \~english @param None
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the first child node of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode FirstChild();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup LastChild
+ /// \~english @par Brief
+ /// Get last child
+ /// \~english @param None
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the last child node of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode LastChild();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup Children
+ /// \~english @par Brief
+ /// Get child list
+ /// \~english @param None
+ /// \~english @retval TNodeList - list of all child node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the list of all the child nodes of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ TNodeList Children();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup NextSibling
+ /// \~english @par Brief
+ /// Get next node
+ /// \~english @param None
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the next sibling node of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode NextSibling();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup PrevSibling
+ /// \~english @par Brief
+ /// Get previous node
+ /// \~english @param None
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the previous sibling node of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode PrevSibling();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FindChildNode
+ /// \~english @par Brief
+ /// Find child node
+ /// \~english @param [IN] f_cNodeName std::string - tag name of the node
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the first immediate sub node with matching node name
+ /// This function does not provide support to find node based on attribute value
+ /// Use FindNode() API of CXmlParser to find node based on XPath expression
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+
+ CXmlNode FindChildNode(std::string f_cNodeName);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FindAllChildNodes
+ /// \~english @par Brief
+ /// Get list of all the immediate sub node
+ /// \~english @param [IN] f_cNodeName std::string - tag name of the node
+ /// \~english @retval TNodeList - list of matching nodes
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the list of all the immediate sub node matching tag as f_cNodeName.
+ /// This function does not provide support to find node based on attribute value.
+ /// Use FindNode() API of CXmlParser to find node based on XPath expression.
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ TNodeList FindAllChildNodes(std::string f_cNodeName);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetContentOfChildNode
+ /// \~english @par Brief
+ /// Find first level node
+ /// \~english @param [IN] f_cNodeName
+ /// std::string - name of the node
+ /// \~english @param [OUT] f_cContent
+ /// std::string& - content of the node
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusFail Failed
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Find the first level sub node matching tag as f_cNodeName
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus GetContentOfChildNode(std::string f_cNodeName, std::string &f_cContent); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup AddChildNode
+ /// \~english @par Brief
+ /// Add sub node
+ /// \~english @param [IN] f_cNodeName
+ /// std::string - tag of the new node
+ /// \~english @param [IN] f_cText
+ /// std::string - content of the new node
+ /// \~english @retval CXmlNode - object of child node
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Add sub node to the current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode AddChildNode(std::string f_cNodeName, std::string f_cText = "");
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup AddSiblingNode
+ /// \~english @par Brief
+ /// Add new node to siblings
+ /// \~english @param [IN] f_cNodeName
+ /// std::string - tag of the new node
+ /// \~english @param [IN] f_cText
+ /// std::string - content of the new node
+ /// \~english @retval CXmlNode - object of sibling node
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Add a new node to the list of siblings of current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode AddSiblingNode(std::string f_cNodeName, std::string f_cText = "");
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RemoveChildNode
+ /// \~english @par Brief
+ /// Remove child node
+ /// \~english @param [IN] f_cNodeName
+ /// std::string - name of child node
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Remove the child node from current node
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus RemoveChildNode(std::string f_cNodeName);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ClearNode
+ /// \~english @par Brief
+ /// Removes elements and attributes
+ /// \~english @param None
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// This function removes all sub elements, clears all attributes,
+ /// and sets the text and tail attributes to None
+ /// \~english @see CXmlNode
+ ////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ClearNode();
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CXmlNode
+ /// Constructor of CXmlNode class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CXmlNode();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CXmlNode
+ /// Parameterized constructor of CXmlNode class
+ ///
+ /// \param f_pXmlNodePtr
+ /// xmlNodePtr - pointer of an xml node
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CXmlNode(xmlNodePtr f_pXmlNodePtr); // NOLINT (readability/nolint)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetXmlNodePtr
+ /// Sets the xmlNodePtr
+ ///
+ /// \param f_pXmlNodePtr
+ /// xmlNodePtr - pointer of an xml node
+ ///
+ /// \return VOID
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetXmlNodePtr(xmlNodePtr f_pXmlNodePtr);
+
+ // pointer to xml node
+ xmlNodePtr m_pXmlNodePtr;
+};
+
+
+/**
+ * @class CXmlAttr
+ * \~english @brief This class represents the attribute of an xml node.
+ * \~english @par Brief Introduction
+ * This class represents the attribute of an xml node.
+ *
+ */
+class CXmlAttr {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXmlAttr
+ /// \~english @par Brief
+ /// CXmlAttr constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Parameterized constructor of CXmlAttr class
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+ CXmlAttr();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXmlAttr
+ /// \~english @par Brief
+ /// CXmlAttr constructor
+ /// \~english @param [IN] f_cKey
+ /// std::string - attributes key
+ /// \~english @param [IN] f_cValue
+ /// std::string - attributes value
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Parameterized constructor of CXmlAttr class
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+ CXmlAttr(std::string f_cKey, std::string f_cValue);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXmlAttr
+ /// \~english @par Brief
+ /// Destructor of CXmlAttr class
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Inside state change
+ /// - None
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Destructor of CXmlAttr class
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+ ~CXmlAttr();
+
+ // atrribute key
+ std::string m_cKey;
+
+ // atrribute value
+ std::string m_cValue;
+};
+
+/**
+ * @class CXmlParser
+ * \~english @brief This class represents the XML parser.
+ * \~english @par Brief Introduction
+ * Provides API for parsing xml file. Also provides API to search node/nodes based on Xml Path
+ *
+ */
+class CXmlParser {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXmlParser
+ /// \~english @par Brief
+ /// CXmlParser constructor
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Constructor of CXmlParser class
+ /// \~english @see None
+ ////////////////////////////////////////////////////////////////////////////////
+ CXmlParser();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CXmlParser
+ /// \~english @par Brief
+ /// Destructor of CXmlParser class
+ /// \~english @param None
+ /// \~english @retval None
+ /// \~english @par Prerequisite
+ /// - None
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Destructor of CXmlParser class
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+ ~CXmlParser();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ParseXml
+ /// \~english @par Brief
+ /// Parses xml file
+ /// \~english @param [IN] f_cFileName
+ /// std::string - full path of xml file to be parsed
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Parses the xml file and creates a document structure
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus ParseXml(std::string f_cFileName);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup CreateNewXmlDoc
+ /// \~english @par Brief
+ /// Creates new xml
+ /// \~english @param [IN] f_cRootNodeName
+ /// std::string - root node name in new doc
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Create a new xml document
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus CreateNewXmlDoc(std::string f_cRootNodeName);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup SaveXml
+ /// \~english @par Brief
+ /// Save XML file
+ /// \~english @param [IN] f_cFileName
+ /// std::string - full path of output xml file
+ /// In case of parsing an xml file,
+ /// if f_cFileName is empty, output will be saved in source xml file
+ /// else output will be saved in user provided file path
+ /// In case of creating new xml document,
+ /// if f_cFileName is empty, returns error
+ /// else output will be saved in user provided file path
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Save the updated structure to the XML file
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus SaveXml(std::string f_cFileName = "");
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup GetRootNode
+ /// \~english @par Brief
+ /// Get root node
+ /// \~english @param None
+ /// \~english @retval CXmlNode - root node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Get the root node object
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode GetRootNode();
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup AddNewNode
+ /// \~english @par Brief
+ /// Create and add node
+ /// \~english @param [IN] f_pParentNode
+ /// CXmlNode - parent node
+ /// \~english @param [IN] f_cNewNodeName
+ /// std::string - tag name of the new node
+ /// \~english @param [IN] f_cContent
+ /// std::string - text to set for the new node
+ /// \~english @retval CXmlNode - new node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Create new node and add it to the parent node
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ CXmlNode AddNewNode(CXmlNode m_pParentNode, std::string f_cNewNodeName, std::string f_cContent = "");
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup RemoveNode
+ /// \~english @par Brief
+ /// Remove node
+ /// \~english @param [IN] f_pNode
+ /// CXmlNode - node object
+ /// \~english @retval eFrameworkunifiedStatusOK Success
+ /// \~english @retval eFrameworkunifiedStatusNullPointer Null pointer
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Remove the node from the xml
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ EFrameworkunifiedStatus RemoveNode(CXmlNode m_pNode);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FindNode
+ /// \~english @par Brief
+ /// Find first matching node
+ /// \~english @param [IN] f_cNodePath
+ /// std::string - name or path of node(XPath) path is relative to current node or absolute path
+ /// \~english @param [IN] f_pCurrentNode
+ /// CXmlNode - current node
+ /// \~english @retval CXmlNode - node object
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Find the first matching node, by tag name or path relative to current node path or
+ /// absolute path. Here the path is XPath expression
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+
+ CXmlNode FindNode(std::string f_cNodePath, CXmlNode f_pCurrentNode);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup FindAllNodes
+ /// \~english @par Brief
+ /// Find all matching node
+ /// \~english @param [IN] f_cNodePath
+ /// std::string - name or path of node(XPath) path is relative to current node or absolute path
+ /// \~english @param [IN] f_pCurrentNode
+ /// CXmlNode - current node
+ /// \~english @retval TNodeList - list of matching nodes
+ /// \~english @par Prerequisite
+ /// - Load the shared library first
+ /// - Get CXmlNode from CXmlParser
+ /// \~english @par Inside state change
+ /// - The API no inside state change
+ /// \~english @par None
+ /// \~english @par Classification
+ /// Public
+ /// \~english @par Type
+ /// Sync Only
+ /// \~english @par Detail
+ /// Find all the matching node, by tag name or path relative to current node path or
+ /// absolute path.
+ /// \~english @see CXmlParser
+ ////////////////////////////////////////////////////////////////////////////////
+
+ TNodeList FindAllNodes(std::string f_cNodePath, CXmlNode f_pCurrentNode);
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNodeSet
+ /// Gets the node set resulting from search of nodepath using XPath
+ ///
+ /// \param f_cNodePath
+ /// std::string - name or path of node
+ /// path is relative to current node or absolute path
+ /// \param f_pCurrentNode
+ /// CXmlNode - current node
+ ///
+ /// \return xmlXPathObjectPtr
+ /// xmlXPathObjectPtr - returns the xpath object pointer containing nodes pointer
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ xmlXPathObjectPtr GetNodeSet(std::string f_cNodePath, CXmlNode f_pCurrentNode);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsReadable
+ /// Checks whether the file exists or not
+ ///
+ /// \param
+ ///
+ /// \return VOID
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsReadable(const std::string &filename);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ClearDocument
+ /// Clears the document structure and resets the root node
+ ///
+ /// \param
+ ///
+ /// \return VOID
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID ClearDocument();
+
+ // pointer to structure created from xml after parsing
+ xmlDocPtr m_pXmlDoc;
+
+ // stores the name/path of source xml file
+ std::string m_cFileName;
+
+ // pointer to the root node of xml structure
+ CXmlNode m_pRootNode;
+};
+
+
+#endif /* __FRAMEWORKUNIFIED_NATIVESERVICES_NS_XMLPARSER_INC_NS_XMLPARSER_IF_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/nsfw_message.h b/nsframework/framework_unified/client/include/native_service/nsfw_message.h
new file mode 100644
index 00000000..b5872c57
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/nsfw_message.h
@@ -0,0 +1,65 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file nsfw_message.h
+ * @brief \~english The file definition of NSFW message for NSFW independent module reference
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup utility
+ * @ingroup framework_unified
+ * @{
+ */
+/*
+ * The definition of NSFW message for NSFW independent module reference.
+ *
+ */
+//@{
+#ifndef _nsfw_message_h_ // NOLINT (build/header_guard)
+#define _nsfw_message_h_
+
+/*
+ * The following definitions are defined only for NSFW to check consistency.
+ * NOT TO BE USED IN ANY WAY.
+ */
+#define _NSFW_MSG_LEN_ (40)
+#define _NSFW_SYSINFO_FLAG_ (4)
+#define _NSFW_SYSINFO_SIZE_ (64)
+
+/*
+ * The following definitions are published definitions.
+ */
+#define NSFW_GET_MESSAGE(msg) \
+ ((*((unsigned int *)msg) & _NSFW_SYSINFO_FLAG_) ? \
+ ((unsigned char *)msg) + _NSFW_MSG_LEN_ + _NSFW_SYSINFO_SIZE_ : \
+ ((unsigned char *)msg) + _NSFW_MSG_LEN_)
+
+#endif // _nsfw_message_h_ // NOLINT (build/header_guard)
+//@}
+/**@}*/ // end of utility
+/**@}*/ // end of framework_unified
+/**@}*/ // end of native_service
+/**@}*/ // end of BaseSystem
diff --git a/nsframework/framework_unified/client/include/native_service/nslogutil_cmd_if.h b/nsframework/framework_unified/client/include/native_service/nslogutil_cmd_if.h
new file mode 100644
index 00000000..90f03b79
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/nslogutil_cmd_if.h
@@ -0,0 +1,86 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \file
+/// Declares COMMANDS related to Log Utility
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @file
+ * @brief \~english Declares COMMANDS related to Log Utility
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup utility
+ * @ingroup framework_unified
+ * @{
+ */
+
+#ifndef COMMANDS_H_ // NOLINT (build/header_guard)
+#define COMMANDS_H_
+
+// Notifications
+#define NTFY_LOGGER_SETCONTROLMASK "LoggerService/SetControlMask"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief Logger Utility Commands
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _COMMANDS {
+ SET_LOG_MASK = 0xAEA, // < Sets the NS log mask for a process. uses CHANGELOGPARAMS
+ GET_LOG_MASK, // < Gets the NS log mask for a process. uses CHANGELOGPARAMS
+ SET_LOG_OUT_OPT, // < Sets the NS log output option mask for a process. uses CHANGELOGPARAMS
+ GET_LOG_OUT_OPT, // < Gets the NS log output option mask for a process. uses CHANGELOGPARAMS
+ GET_LOG_MASK_RESPONSE, // < Get the response about NS log masks
+ GET_LOG_OUT_OPT_RESPONSE, // < Get the response about NS log output options
+ SET_MSGTX_RX_ON_AND_TX_OFF, // < Sets TransmissionLogger to receive ON, transmit OFF
+ SET_MSGTX_RX_OFF_AND_TX_ON, // < Sets TransmissionLogger to receive OFF, transmit ON
+ SET_MSGTX_RX_AND_TX_ON, // < Sets TransmissionLogger to receive ON, transmit ON
+ SET_MSGTX_RX_AND_TX_OFF, // < Sets TransmissionLogger to receive OFF, transmit OFF
+ kDebugDumpRequest, // < Sets a debug dump log to the debug dump queue
+ SET_LOG_SEVERITY, // < Sets the NS severity log level
+ GET_LOG_SEVERITY, // < Gets the NS severity log level
+ GET_LOG_SEVERITY_RESPONSE, // < Get the response about NS serverity log level
+
+ // list of protocols provided for rcs logger plugin
+ NSRCS_SET_LOG_SETTINGS_REQ, // < Set the NS RCS log setting request
+ NSRCS_SET_LOG_SETTINGS_RESP, // < Set the NS RCS log setting response
+ NSRCS_GET_LOG_SETTINGS_REQ, // < Get the NS RCS log setting request
+ NSRCS_GET_LOG_SETTINGS_RESP, // < Get the NS RCS log setting response
+ NSRCS_SET_LOG_MASK_REQ, // < Set the NS RCS log mask request
+ NSRCS_SET_LOG_MASK_RESP, // < Get the NS RCS log mask response
+ NSRCS_SET_LOG_OUT_OPT_REQ, // < Set the NS RCS log output option request
+ NSRCS_SET_LOG_OUT_OPT_RESP, // < Set the NS RCS log output option response
+ NSRCS_SET_LOG_SEVERITY_REQ, // < Set the NS RCS severity log level request
+ NSRCS_SET_LOG_SEVERITY_RESP, // < Set the NS RCS severity log level response
+} COMMANDS;
+
+#endif /* COMMANDS_H_ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/native_service/wpf_legacy.h b/nsframework/framework_unified/client/include/native_service/wpf_legacy.h
new file mode 100644
index 00000000..7553f911
--- /dev/null
+++ b/nsframework/framework_unified/client/include/native_service/wpf_legacy.h
@@ -0,0 +1,152 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @brief \~english This file define primary types to use
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup framework_unified
+ * @ingroup native_service
+ * @{
+ */
+/** @addtogroup framework
+ * @ingroup framework_unified
+ * @{
+ */
+#ifndef __WPF_LEGACY_H__ // NOLINT (build/header_guard)
+#define __WPF_LEGACY_H__
+
+// these are legacy definitions.
+// these were defined at Windows_Def.h ... in the past.
+// if you make new code , you should not use these.
+// you should use definitions in frameworkunified_types.h.
+
+#include <native_service/frameworkunified_types.h>
+
+
+// Windows_Def.h
+#define CALLBACK
+#define INVALID_HANDLE_VALUE ((void*)(-1))
+#define INFINITE 0xFFFFFFFF
+
+typedef int INT;
+typedef unsigned int UINT;
+typedef unsigned int *PUINT;
+#define VOID void
+typedef char CHAR;
+typedef short SHORT; // NOLINT (readability/nolint)
+typedef long LONG; // NOLINT (readability/nolint)
+typedef SHORT *PSHORT;
+typedef LONG *PLONG;
+typedef unsigned long ULONG; // NOLINT (readability/nolint)
+typedef ULONG *PULONG;
+typedef unsigned short USHORT; // NOLINT (readability/nolint)
+typedef USHORT *PUSHORT;
+typedef unsigned char UCHAR;
+typedef UCHAR *PUCHAR;
+typedef unsigned long DWORD; // NOLINT (readability/nolint)
+// defined in kernelmoduleevklibdd.h typedef int BOOL;
+typedef unsigned char BYTE;
+typedef unsigned short WORD; // NOLINT (readability/nolint)
+typedef float FLOAT;
+typedef FLOAT *PFLOAT;
+typedef BOOL *PBOOL;
+typedef BOOL *LPBOOL;
+typedef BYTE *PBYTE;
+typedef BYTE *LPBYTE;
+typedef int *PINT;
+typedef int *LPINT;
+typedef WORD *PWORD;
+typedef WORD *LPWORD;
+typedef long *LPLONG; // NOLINT (readability/nolint)
+typedef DWORD *PDWORD;
+typedef DWORD *LPDWORD;
+typedef void *PVOID;
+typedef void *LPVOID;
+typedef const void *LPCVOID;
+typedef wchar_t WCHAR;
+typedef size_t SIZE_T;
+typedef DWORD COLORREF;
+typedef DWORD *LPCOLORREF;
+typedef CHAR *PCHAR, *LPCH, *PCH;
+typedef CONST CHAR *LPCCH, *PCCH;
+typedef CHAR *NPSTR, *LPSTR, *PSTR;
+typedef PSTR *PZPSTR;
+typedef CONST PSTR *PCZPSTR;
+typedef CONST CHAR *LPCSTR, *PCSTR;
+typedef PCSTR *PZPCSTR;
+typedef void *HGDIOBJ;
+typedef int INT_PTR, *PINT_PTR;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+typedef long LONG_PTR, *PLONG_PTR; // NOLINT (readability/nolint)
+typedef unsigned long ULONG_PTR, *PULONG_PTR; // NOLINT (readability/nolint)
+typedef unsigned long ULONGLONG; // NOLINT (readability/nolint)
+typedef char CCHAR;
+typedef DWORD LCID;
+typedef PDWORD PLCID;
+typedef WORD LANGID;
+typedef long LONGLONG; // NOLINT (readability/nolint)
+typedef WORD ATOM;
+
+typedef pthread_mutex_t CRITICAL_SECTION;
+typedef CRITICAL_SECTION *LPCRITICAL_SECTION;
+
+#define __readableTo(extent)
+#define __nullterminated __readableTo(sentinel(0))
+
+typedef __nullterminated WCHAR *NWPSTR, *LPWSTR, *PWSTR;
+typedef __nullterminated PWSTR *PZPWSTR;
+typedef __nullterminated CONST PWSTR *PCZPWSTR;
+typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR;
+typedef __nullterminated PCWSTR *PZPCWSTR;
+
+#ifdef UNICODE
+#define wsprintf swprintf
+typedef WCHAR *PWCHAR, *LPWCH, *PWCH;
+typedef LPWSTR PTSTR, LPTSTR;
+typedef LPCWSTR PCTSTR, LPCTSTR;
+#else /* UNICODE */
+#define wsprintf sprintf
+typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
+typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
+typedef WCHAR *LPWCH;
+typedef WCHAR *PWCHAR; // 110509 chg
+#endif /* UNICODE */
+
+#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
+
+typedef struct _SYSTEMTIME {
+ WORD wYear;
+ WORD wMonth;
+ WORD wDayOfWeek;
+ WORD wDay;
+ WORD wHour;
+ WORD wMinute;
+ WORD wSecond;
+ WORD wMilliseconds;
+} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
+
+#endif /* __WPF_LEGACY_H__ */ // NOLINT (build/header_guard)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/framework_unified/client/include/ns__CWORD77__template.h b/nsframework/framework_unified/client/include/ns__CWORD77__template.h
new file mode 100644
index 00000000..e4069dd9
--- /dev/null
+++ b/nsframework/framework_unified/client/include/ns__CWORD77__template.h
@@ -0,0 +1,60 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_HMI_CWORD77_Controller
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////
+//@{
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS__CWORD77__TEMPLATE_H_
+#define FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS__CWORD77__TEMPLATE_H_
+
+#include <iterator>
+#include <algorithm>
+
+/// Template for Map range transformation
+template< class OCont, class IIter, class MapFn >
+OCont mapRange(const IIter &begin, const IIter &end, MapFn fn) {
+ OCont c;
+ std::transform(begin, end, std::inserter(c, c.begin()), fn);
+ return c;
+}
+
+
+/// Template to get Array begining
+template< class T, UI_32 N >
+const T *ArrBeg(const T(&arr)[ N ]) {
+ return &arr[ 0 ];
+}
+
+/// Template to get Array ending
+template< class T, UI_32 N >
+const T *ArrEnd(const T(&arr)[ N ]) {
+ return &arr[ 0 ] + N;
+}
+
+/// Template to convert structure to Map
+template< class Cont, class T, class C, class TFn >
+const Cont GetMap(const T *mapTable, C N, TFn transform) {
+ return mapRange< Cont >(&mapTable[0], &mapTable[0] + N, transform);
+}
+
+ServiceResponseTableItem TransformServiceResponseTableIteminMap(const ServiceResponse &uch);
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS__CWORD77__TEMPLATE_H_
+//@}
diff --git a/nsframework/framework_unified/client/include/ns_logger_additional_if.h b/nsframework/framework_unified/client/include/ns_logger_additional_if.h
new file mode 100644
index 00000000..4d67e189
--- /dev/null
+++ b/nsframework/framework_unified/client/include/ns_logger_additional_if.h
@@ -0,0 +1,40 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \file
+/// Declares the external APIs to Logger.Include this header when you want to use FRAMEWORKUNIFIEDLOG_TEXT.
+/// \ingroup tag_NSLogger
+/// @{
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS_LOGGER_ADDITIONAL_IF_H_
+#define FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS_LOGGER_ADDITIONAL_IF_H_
+
+#include <native_service/ns_logger_if.h>
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NSLogger
+/// \brief FRAMEWORKUNIFIEDLOG_TEXT
+///////////////////////////////////////////////////////////////////////////////
+/// FRAMEWORKUNIFIEDLOG_TEXT macro will output the log without relationship to the ZONE.
+/// \note Developers should use the FRAMEWORKUNIFIEDLOG for logging.
+///////////////////////////////////////////////////////////////////////////////
+#define FRAMEWORKUNIFIEDLOG_TEXT(funcname, args...) TEXT_ZONE(BITS_IN_ZONE_MASK, funcname, ## args)
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NS_LOGGER_ADDITIONAL_IF_H_
+/// @}
diff --git a/nsframework/framework_unified/client/include/nsverutil_cmd_if.h b/nsframework/framework_unified/client/include/nsverutil_cmd_if.h
new file mode 100644
index 00000000..70705e84
--- /dev/null
+++ b/nsframework/framework_unified/client/include/nsverutil_cmd_if.h
@@ -0,0 +1,25 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NSVERUTIL_CMD_IF_H_
+#define FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NSVERUTIL_CMD_IF_H_
+
+typedef enum _VERCOMMANDS {
+ GET_VERSION_RESPONSE = 0xBEB, /**< Version response from framework */
+ GET_VERSION /**< Version request to framework */
+} VERCOMMANDS;
+
+#endif // FRAMEWORK_UNIFIED_CLIENT_INCLUDE_NSVERUTIL_CMD_IF_H_
diff --git a/nsframework/framework_unified/client/libNS_FrameworkUnified.ver b/nsframework/framework_unified/client/libNS_FrameworkUnified.ver
new file mode 100644
index 00000000..764c5bbd
--- /dev/null
+++ b/nsframework/framework_unified/client/libNS_FrameworkUnified.ver
@@ -0,0 +1,144 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#
+# libNS_FrameworkUnified version script
+#
+{
+ global:
+ ### .text section ###
+ extern "C++" {
+ Frameworkunified*;
+ SetReqDataIn_CWORD77_DataPool*;
+ GetResp*;
+ SetResp*;
+ CalculateCRC32*;
+ ConvertEndian_*;
+ CFrameworkunifiedAction::*;
+ CFrameworkunifiedVersion::*;
+ operator*CFrameworkunifiedVersion*;
+ CNSSharedMem::*;
+ CNSSharedMemReader::*;
+ CNSRingBuffer::*;
+ CFrameworkunifiedLeafState::*;
+ CFrameworkunified_CWORD77_Service::*;
+ CFrameworkunified_CWORD77_Session::*;
+ CNSConfig*::*;
+ CFrameworkunifiedCompositeState::*;
+ CFrameworkunifiedOrthogonalState::*;
+ CFrameworkunifiedConditionConnector::*;
+ CFrameworkunifiedExternalTransition::*;
+ frameworkunified::framework::CFrameworkunifiedThreadPriorities::*;
+ CMutex::*;
+ CFrameworkunifiedHSM::*;
+ CRWLock::*;
+ NSTimer::*;
+ NsForceClose;
+ CFrameworkunifiedGuard::*;
+ CFrameworkunifiedState::*;
+ CFrameworkunifiedLocalTransition::*;
+ CFrameworkunifiedShallowHistoryState::*;
+ CFrameworkunifiedHistoryState::*;
+ CFrameworkunifiedDeepHistoryState::*;
+ CFrameworkunifiedHSMParentFramework::*;
+ CFrameworkunifiedSyncData::*;
+ IConfigWriter::*;
+ IConfigReader::*;
+ };
+ GetFileList;
+ MSToNS;
+ DoesDirecotryExist;
+ CreateDirectory;
+ Mc*;
+ NP*;
+ NSLog*;
+ NsLogIsPLogEnabled;
+ NsLogData;
+ NsLogTime;
+ NsLog0;
+ NsLog;
+ NsLogSetFrameworkunifiedLogParams;
+ NsLogSetProcessName;
+ NsLogSetControlMask;
+ NsLogIsZoneSet;
+ NsLogGetControlMask;
+ NsLogSetLogMethod;
+ NsLog_EvtCnt;
+ NsLog_Evt;
+ NsLog_Cnt;
+ NsLogDetermineLogMethod;
+ NsLogSetZones;
+ NsLogParseZones;
+ NsRcsSendTraceData;
+ NSLogGetFrameworkunifiedlogFileTotalNum;
+ NSLogGetFrameworkunifiedlogFileName;
+ NsLogGetLogMethod;
+ NsLogSetFrameworkunifiedLogFlag;
+ NsLogGetFrameworkunifiedLogFlag;
+ NsLogSetRealtimeLog;
+ NsLogGetRealtimeLog;
+ NsLogInitialize;
+ NS_Timer*;
+ OpenReceiver;
+ OpenReceiverNotBlocked;
+ CloseSender;
+ CloseReceiver;
+ OpenSender;
+ ReceiveMessage;
+ RemainderMs;
+ SendMessage;
+ SynchronousWritePersistentData;
+ SynchronousMovePersistentData;
+ WholeSeconds;
+ _init;
+ _fini;
+ GetLengthOfDataFromShared;
+
+ ### .data section ###
+ extern "C++" {
+ typeinfo?for?CFrameworkunifiedAction;
+ typeinfo?for?CFrameworkunifiedVersion;
+ typeinfo?for?CNSSharedMem;
+ typeinfo?for?CNSSharedMemReader;
+ typeinfo?for?CNSRingBuffer;
+ typeinfo?for?CFrameworkunifiedLeafState;
+ typeinfo?for?CFrameworkunified_CWORD77_Service;
+ typeinfo?for?CFrameworkunified_CWORD77_Session;
+ typeinfo?for?CNSConfig*;
+ typeinfo?for?CFrameworkunifiedCompositeState;
+ typeinfo?for?CFrameworkunifiedOrthogonalState;
+ typeinfo?for?CFrameworkunifiedConditionConnector;
+ typeinfo?for?CFrameworkunifiedExternalTransition;
+ typeinfo?for?frameworkunified::framework::CFrameworkunifiedThreadPriorities;
+ typeinfo?for?CMutex;
+ typeinfo?for?CFrameworkunifiedHSM;
+ typeinfo?for?CRWLock;
+ typeinfo?for?NSTimer;
+ typeinfo?for?CFrameworkunifiedGuard;
+ typeinfo?for?CFrameworkunifiedState;
+ typeinfo?for?CFrameworkunifiedLocalTransition;
+ typeinfo?for?CFrameworkunifiedShallowHistoryState;
+ typeinfo?for?CFrameworkunifiedHistoryState;
+ typeinfo?for?CFrameworkunifiedDeepHistoryState;
+ typeinfo?for?CFrameworkunifiedHSMParentFramework;
+ typeinfo?for?CFrameworkunifiedSyncData;
+ typeinfo?for?IConfigWriter;
+ typeinfo?for?IConfigReader;
+ };
+ local:
+ *;
+};
+
diff --git a/nsframework/log_library/LICENSE b/nsframework/log_library/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/nsframework/log_library/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/nsframework/log_library/Makefile.client b/nsframework/log_library/Makefile.client
new file mode 100644
index 00000000..fb995b35
--- /dev/null
+++ b/nsframework/log_library/Makefile.client
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS = client
+
+include ../native_service.mk
diff --git a/nsframework/log_library/client/Makefile b/nsframework/log_library/client/Makefile
new file mode 100644
index 00000000..24279270
--- /dev/null
+++ b/nsframework/log_library/client/Makefile
@@ -0,0 +1,32 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### libraries to be installed(*.a) #############
+INST_SHLIBS = liblog
+######### headers to be installed(*.h) #############
+INST_HEADERS := loglibrarylog_library.h loglibrarylog_if.h
+
+######### sources to be compiled #############
+liblog_SRCS := loglibrarylog.c
+
+######### search paths #############
+VPATH = ./src ./include/$(COMPONENT_NAME)
+
+######### include paths #############
+CFLAGS += -I./include
+LDFLAGS += -Wl,--no-as-needed
+
+include ../../native_service.mk
diff --git a/nsframework/log_library/client/include/loglibrarylog_internal.h b/nsframework/log_library/client/include/loglibrarylog_internal.h
new file mode 100644
index 00000000..af6e7cf1
--- /dev/null
+++ b/nsframework/log_library/client/include/loglibrarylog_internal.h
@@ -0,0 +1,26 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//@{
+
+#ifndef LOG_LIBRARY_CLIENT_INCLUDE_LOGLIBRARYLOG_INTERNAL_H_
+#define LOG_LIBRARY_CLIENT_INCLUDE_LOGLIBRARYLOG_INTERNAL_H_
+
+// Prototype
+int LOGLIBRARYLOG_Freeze(void);
+
+#endif // LOG_LIBRARY_CLIENT_INCLUDE_LOGLIBRARYLOG_INTERNAL_H_
+//@}
diff --git a/nsframework/log_library/client/include/native_service/loglibrarylog_if.h b/nsframework/log_library/client/include/native_service/loglibrarylog_if.h
new file mode 100644
index 00000000..5bf90c3a
--- /dev/null
+++ b/nsframework/log_library/client/include/native_service/loglibrarylog_if.h
@@ -0,0 +1,79 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @brief \~english This file contains defines and LOGLIBRARYLOG_Freeze API for free frameworkunifiedlog.
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup log_library
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef __LOGLIBRARYLOG_IF_H__ // NOLINT (readability/nolint)
+#define __LOGLIBRARYLOG_IF_H__
+
+#define FRAMEWORKUNIFIEDLOG_SHARED_MEM_NAME "loglibrarylogconfig.cfg"
+#define FRAMEWORKUNIFIEDLOG_RAMDISC_NAME "/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog/frameworkunified_debug.log"
+#define FRAMEWORKUNIFIEDLOG_RAMDISC_PATH "/ramd/BS/ss/logger_service/rwdata/frameworkunifiedlog"
+
+// Out put mode
+#define FRAMEWORKUNIFIEDLOG_FLAG_MODE_DEBUG 1 // Debug
+#define FRAMEWORKUNIFIEDLOG_FLAG_MODE_RELEASE 0 // :Release
+
+// RealtimeLog mode
+#define LOGLIBRARYLOG_REALTIMELOG_DISABLE_MASK 0x80
+#define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE 0xFF // : FREEZE
+
+#define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_OFF 0 // :ALL OFF
+#define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_UART 1 // :UARTOUT
+#define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB 2 // :USB OUT
+#define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB_DISABLE \
+ (FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_USB | LOGLIBRARYLOG_REALTIMELOG_DISABLE_MASK)
+#define FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_MAX 3 // :MAX NUM
+
+//////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup LOGLIBRARYLOG_Freeze
+/// \~english @par Brief
+/// Freeze Loglibrarylog API.
+/// \~english @retval 0: success
+/// \~english @retval -1: error
+/// \~english @par Prerequisite
+/// - none
+/// \~english @par Conditions of processing failure
+/// - none
+/// \~english @par Classification
+/// Public
+/// \~english @par Type
+/// Sync Only
+/// \~english @par Detail
+/// This API is provide to freeze Loglibrarylog.
+/// \~english @see none
+////////////////////////////////////////////////////////////////////////////////
+int LOGLIBRARYLOG_Freeze(void);
+
+#endif // __LOGLIBRARYLOG_IF_H__ // NOLINT (readability/nolint)
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/log_library/client/include/native_service/loglibrarylog_library.h b/nsframework/log_library/client/include/native_service/loglibrarylog_library.h
new file mode 100644
index 00000000..60edd01f
--- /dev/null
+++ b/nsframework/log_library/client/include/native_service/loglibrarylog_library.h
@@ -0,0 +1,42 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @brief \~english include all log_library head files
+ *
+ */
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup log_library
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef NATIVESERVICE_LOGLIBRARY_H_ // NOLINT(build/header_guard)
+#define NATIVESERVICE_LOGLIBRARY_H_
+
+#include <native_service/loglibrarylog_if.h>
+
+#endif // NATIVESERVICE_LOGLIBRARY_H_
+/** @}*/
+/** @}*/
+/** @}*/
+/** @}*/
diff --git a/nsframework/log_library/client/src/loglibrarylog.c b/nsframework/log_library/client/src/loglibrarylog.c
new file mode 100644
index 00000000..7aa7c2b6
--- /dev/null
+++ b/nsframework/log_library/client/src/loglibrarylog.c
@@ -0,0 +1,60 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <native_service/loglibrarylog_if.h>
+#include "loglibrarylog_internal.h"
+
+int
+LOGLIBRARYLOG_Freeze(void) {
+ int fd;
+ int *pmap;
+ int ret;
+
+ fd = shm_open(FRAMEWORKUNIFIEDLOG_SHARED_MEM_NAME, O_RDWR | O_CREAT, S_IRWXU | S_IRWXO);
+ if (fd == -1) {
+ fprintf(stderr, "[%s:L%d]shm_open(%s) error(%d)\n", __FUNCTION__, __LINE__,
+ FRAMEWORKUNIFIEDLOG_SHARED_MEM_NAME, errno);
+ return -1;
+ }
+
+ ret = ftruncate(fd, sizeof(int));
+ if (ret == 0) {
+ fprintf(stderr, "[%s:L%d]ftruncate() error(%d)\n", __FUNCTION__, __LINE__, ret);
+ close(fd);
+ return -1;
+ }
+
+ pmap = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ close(fd);
+ if (pmap == MAP_FAILED) {
+ fprintf(stderr, "[%s:L%d]mmap() error(%d)\n", __FUNCTION__, __LINE__, errno);
+ return -1;
+ }
+ *pmap = FRAMEWORKUNIFIEDLOG_REALTIMELOG_MODE_FREEZE;
+
+ if (munmap(pmap, sizeof(int)) != 0) {
+ fprintf(stderr, "[%s:L%d]munmap() error(%d)\n", __FUNCTION__, __LINE__, errno);
+ }
+
+ return 0;
+}
diff --git a/nsframework/native_service.mk b/nsframework/native_service.mk
new file mode 100644
index 00000000..729362ca
--- /dev/null
+++ b/nsframework/native_service.mk
@@ -0,0 +1,44 @@
+#############################################################
+#
+# Common Makefile for native_service
+# Copyright (C) 2017-2020 TOYOTA MOTOR CORPORATION
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#############################################################
+
+CURRENT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+#############################################################
+# COMPONENT_NAME must not be blank and be named snake_case
+
+COMPONENT_NAME := native_service
+
+#############################################################
+
+
+
+#############################################################
+# You can add several flags and libraries.
+# When you add -I or -L path, DO NOT USE relative path.
+# Instead, use $(CURRENT_DIR) variable
+# that indicates the path this .mk file is stored.
+
+COMPONENT_CFLAGS :=
+COMPONENT_CXXFLAGS :=
+COMPONENT_LDLIBS :=
+COMPONENT_LDFLAGS :=
+
+##############################################################
+
+include $(SDKTARGETSYSROOT)/usr/agl/share/agl.mk
diff --git a/nsframework/notification_persistent_service/LICENSE b/nsframework/notification_persistent_service/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/nsframework/notification_persistent_service/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/nsframework/notification_persistent_service/Makefile.server b/nsframework/notification_persistent_service/Makefile.server
new file mode 100644
index 00000000..13475190
--- /dev/null
+++ b/nsframework/notification_persistent_service/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := server
+
+include ../native_service.mk
diff --git a/nsframework/notification_persistent_service/server/Makefile b/nsframework/notification_persistent_service/server/Makefile
new file mode 100644
index 00000000..b5b80cb9
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/Makefile
@@ -0,0 +1,87 @@
+#
+# @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+INST_PROGS = NS_NPPService
+
+######### add source path #############
+VPATH += ./src
+VPATH += ./include/$(COMPONENT_NAME)
+
+######### installed library(*.a) #############
+#INST_LIBS =
+
+######### installed shared library(*.so) #############
+#INST_SHLIBS =
+
+######### install headers(*.h) #############
+INST_HEADERS = notification_persistent_service.h
+
+######### compiled sources #############
+NS_NPPService_SRCS = app_states.cpp \
+ ns_npp.cpp \
+ ns_npp_archive.cpp \
+ ns_npp_binary_accesser.cpp \
+ ns_npp_copy_worker.cpp \
+ ns_npp_fs_directory.cpp \
+ ns_npp_handlelist.cpp \
+ ns_npp_nor_persistence_worker_thread.cpp \
+ ns_npp_notification.cpp \
+ ns_npp_notification_manager.cpp \
+ ns_npp_notification_receiver.cpp \
+ ns_npp_persist_file.cpp \
+ ns_npp_persist_folder.cpp \
+ ns_npp_persistence.cpp \
+ ns_npp_persistence_manager.cpp \
+ ns_npp_persistent_data.cpp \
+ ns_npp_personalization_manager.cpp \
+ ns_npp_registry_entry.cpp \
+ ns_npp_regular_notification.cpp \
+ ns_npp_state_nor_persistence_notification.cpp \
+ ns_npp_state_notification.cpp \
+ ns_npp_state_persistence_notification.cpp \
+ ns_npp_state_persistence_user_notification.cpp \
+ notificationpersistentservice_application.cpp \
+ notificationpersistentservice_main.cpp
+
+######### add include path #############
+CPPFLAGS += -I./include
+CPPFLAGS += -Wl,--no-undefined
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+######### add compile option #############
+ENABLE_PARA_INST += install-prog # PARALLEL MAKE
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+
+######### linked library #############
+
+######### linked library (dynamic) #############
+LDFLAGS += -Wl,--no-as-needed
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -ltar
+LDLIBS += -Wl,-Bdynamic -lz
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy #-lPosixBasedOS001ClockCycleApi -lPosixBasedOS001MsgApi -lPosixBasedOS001GetPrioApi -lPosixBasedOS001TimeApi -lPosixBasedOS001SlogApi
+
+LINK_CXX=Y
+
+######### add library path #############
+
+include ../../native_service.mk
diff --git a/nsframework/notification_persistent_service/server/include/app_states.h b/nsframework/notification_persistent_service/server/include/app_states.h
new file mode 100644
index 00000000..a7f4b4a0
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/app_states.h
@@ -0,0 +1,187 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file all the states, events, internal transitions of state machine.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_APP_STATES_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_APP_STATES_H_
+
+#include <native_service/frameworkunified_sm_framework_if.h>
+#include <native_service/ns_np_service.h>
+#include <string>
+
+const UI_32 kCuiEventIdStartLimit = 20;
+
+DEFINE_COMPOSITESTATE(sNotificationpersistentserviceNPPRoot) // NOLINT (readability/naming)
+DEFINE_ORTHOGONALSTATE_OVERRIDE(sNotificationpersistentserviceNPPStart)
+DEFINE_LEAFSTATE(sNotificationpersistentserviceNPPError)
+
+// =====Define Persistence state
+DEFINE_LEAFSTATE_OVERRIDE(sNotificationpersistentservicePersistenceReady)
+DEFINE_LEAFSTATE(sNotificationpersistentservicePersistenceError)
+
+// DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentData)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPReadPersistedData)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPReleaseFileAck)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnSaveDataAck)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPNorDataSaveAck)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFile)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFile)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFile)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFolder)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFolder)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFolder)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFilePersistentType)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFolderPersistentType)
+
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnUserChange)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceCheckAllReleaseRequestsProcessed)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPPersistentSync)
+
+// =====Define Shutdown state
+DEFINE_LEAFSTATE(sNotificationpersistentserviceShutdownIdle)
+// DEFINE_LEAFSTATE_OVERRIDE(sNotificationpersistentserviceShutdownDataSave)
+class CsNotificationpersistentserviceShutdownDataSave : public CFrameworkunifiedLeafState {
+ public:
+ explicit CsNotificationpersistentserviceShutdownDataSave(std::string f_pName);
+ virtual ~CsNotificationpersistentserviceShutdownDataSave();
+ EFrameworkunifiedStatus FrameworkunifiedOnEntry(CEventDataPtr f_peventdata);
+ EFrameworkunifiedStatus FrameworkunifiedOnExit(CEventDataPtr f_peventdata);
+ private:
+ std::string m_cShutdownRequestor;
+};
+
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPShutdown) // NOLINT (readability/naming)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnShutdownTimeout)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceReInitShutdownTimer)
+
+// =====Define Notification state
+DEFINE_LEAFSTATE(sNotificationpersistentserviceNotificationReady)
+DEFINE_LEAFSTATE(sNotificationpersistentserviceNotificationError)
+
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishNotification)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterNotifications)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotification)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotifications)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnRegisterNotifications)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotification)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotifications)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterImmediateNotifications)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPGetReadyStatus)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPClearPersistedData)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetDefaultPersistentData)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetNotfnPersistentType)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishImmediateNotification)
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfileNotifications)
+DEFINE_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfilePersistence)
+
+#endif
+
+// ==========Define event
+DEFINE_EVENT(evIdle, kCuiEventIdStartLimit + 1)
+DEFINE_EVENT(evReady, kCuiEventIdStartLimit + 2)
+DEFINE_EVENT(evShutdown, kCuiEventIdStartLimit + 3)
+DEFINE_EVENT(evError, kCuiEventIdStartLimit + 4)
+
+DEFINE_EVENT(evNPSetNotfnPersistentType, kCuiEventIdStartLimit + 5)
+DEFINE_EVENT(evNPSetDefaultPersistentData, kCuiEventIdStartLimit + 6)
+DEFINE_EVENT(evNPReadPersistedData, kCuiEventIdStartLimit + 7)
+DEFINE_EVENT(evNPReleaseLoadAck, kCuiEventIdStartLimit + 8)
+DEFINE_EVENT(evNPNorShutdownAck, kCuiEventIdStartLimit + 9)
+DEFINE_EVENT(evNPRegisterPersistentFile, kCuiEventIdStartLimit + 10)
+DEFINE_EVENT(evNPReleasePersistentFile, kCuiEventIdStartLimit + 11)
+DEFINE_EVENT(evNPLoadPersistentFile, kCuiEventIdStartLimit + 12)
+DEFINE_EVENT(evNPSetFilePersistentType, kCuiEventIdStartLimit + 13)
+DEFINE_EVENT(evNPSetFolderPersistentType, kCuiEventIdStartLimit + 14)
+DEFINE_EVENT(evUserChange, kCuiEventIdStartLimit + 15)
+DEFINE_EVENT(evShutdownTimeout, kCuiEventIdStartLimit + 16)
+
+DEFINE_EVENT(evNPPublishNotification, kCuiEventIdStartLimit + 17)
+DEFINE_EVENT(evNPRegisterNotifications, kCuiEventIdStartLimit + 18)
+DEFINE_EVENT(evNPSubscribeToNotification, kCuiEventIdStartLimit + 19)
+DEFINE_EVENT(evNPSubscribeToNotifications, kCuiEventIdStartLimit + 20)
+DEFINE_EVENT(evNPUnRegisterNotifications, kCuiEventIdStartLimit + 21)
+DEFINE_EVENT(evNPUnSubscribeFromNotification, kCuiEventIdStartLimit + 22)
+DEFINE_EVENT(evNPRegisterPersistentFolder, kCuiEventIdStartLimit + 23)
+DEFINE_EVENT(evNPLoadPersistentFolder, kCuiEventIdStartLimit + 24)
+DEFINE_EVENT(evNPReleasePersistentFolder, kCuiEventIdStartLimit + 25)
+DEFINE_EVENT(evNPUnSubscribeFromNotifications, kCuiEventIdStartLimit + 26)
+DEFINE_EVENT(evCheckAllFilesPersisted, kCuiEventIdStartLimit + 27)
+DEFINE_EVENT(evNPGetReadyStatus, kCuiEventIdStartLimit + 28)
+DEFINE_EVENT(evNPRegisterImmediateNotifications, kCuiEventIdStartLimit + 29)
+DEFINE_EVENT(evNPClearPersistedData, kCuiEventIdStartLimit + 30)
+
+DEFINE_EVENT(evNPShutdownDataSave, kCuiEventIdStartLimit + 31)
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+DEFINE_EVENT(evNPProfileNotification, kCuiEventIdStartLimit + 32)
+DEFINE_EVENT(evNPProfilePersistence, kCuiEventIdStartLimit + 33)
+
+#endif
+
+DEFINE_EVENT(evNPPublishImmediateNotification, kCuiEventIdStartLimit + 34)
+DEFINE_EVENT(evNPPersistentSync, kCuiEventIdStartLimit + 35)
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersonality
+/// Set the personality in the framework on userchange.
+///
+/// \param [IN] f_happ
+/// HANDLE - Application Handle
+///
+/// \param [IN] f_tMsg
+/// NC_User - Structure containing user specific details
+///
+/// \return EFrameworkunifiedStatus
+// EFrameworkunifiedStatus - success or failure status
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SetPersonality(HANDLE f_happ, NC_User &f_tMsg); // NOLINT (runtime/references)
+
+
+/*
+ * CShutDownMsgData
+ * This class is used to pass the data between states sShutdownIdle and sShutdownDataSave
+ */
+class CShutDownMsgData : public CEventData {
+ public:
+ // constructor
+ CShutDownMsgData(UI_32 f_uieventid, EFrameworkunifiedShutdownType f_etype, UI_32 f_uidata): CEventData(f_uieventid),
+ m_eShutdownType(f_etype), m_uiMsgData(f_uidata) {} // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ // destructor
+ virtual ~CShutDownMsgData() {}
+
+ EFrameworkunifiedShutdownType m_eShutdownType;
+
+ UI_32 m_uiMsgData;
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_APP_STATES_H_
diff --git a/nsframework/notification_persistent_service/server/include/native_service/notification_persistent_service.h b/nsframework/notification_persistent_service/server/include/native_service/notification_persistent_service.h
new file mode 100644
index 00000000..a7c9f8ec
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/native_service/notification_persistent_service.h
@@ -0,0 +1,40 @@
+/*
+ * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file notification_persistent_service.h
+ * @brief \~english include all notification_persistent_service head files
+ */
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup native_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup notification_persistent_service
+ * @ingroup native_service
+ * @{
+ */
+
+#ifndef NATIVESERVICE_NOTIFICATIONPERSISTENTSERVICE_H_ // NOLINT(build/header_guard)
+#define NATIVESERVICE_NOTIFICATIONPERSISTENTSERVICE_H_
+
+#endif // NATIVESERVICE_NOTIFICATIONPERSISTENTSERVICE_H_
+
+/** @}*/ // end of notification_persistent_service
+/** @}*/ // end of native_service
+/** @}*/ // end of BaseSystem
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp.h b/nsframework/notification_persistent_service/server/include/ns_npp.h
new file mode 100644
index 00000000..f96dd755
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp.h
@@ -0,0 +1,296 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
+
+#include <native_service/frameworkunified_sm_framework_types.h>
+#include <native_service/frameworkunified_sm_hsm.h>
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+
+class CPersistenceManager;
+class CNotificationManager;
+class CnotificationpersistentservicePersonalizationManager;
+
+/**
+ * This class act as a controller class which holds the instance of notification, personalization
+ * and persistence manager respectively.
+ */
+class CNSNPP: public CFrameworkunifiedHSM {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNSNPP
+ /// Constructor of CNSNPP class
+ ///
+ /// \param f_happ
+ /// PVOID - application handle
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CNSNPP(PVOID f_happ);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNSNPP
+ /// Destructor of CNSNPP class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNSNPP();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// Init
+ /// This function is used to allocate dynamic memory for member variables of this class after
+ /// creation of object.
+ ///
+ /// \param f_happ
+ /// HANDLE - Application handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Init(HANDLE f_happ);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// DeInit
+ /// This function is used to deinitialize the NPP object.
+ ///
+ /// \param f_happ
+ /// HANDLE - Application handle
+ ///
+ /// \return VOID
+ /// VOID - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID DeInit(HANDLE f_happ);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FrameworkunifiedCreate
+ /// This function is pure virtual function of parent class.
+ /// In this function, states and events of StateMachine are created and connected.
+ ///
+ /// \param [in] f_peventdata
+ /// PVOID - Event data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_peventdata = NULL);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentservicePersistAll
+ /// Persist all persistent state, user persistent state notification data;
+ /// and all global and user related files to permenant storage
+ ///
+ /// \param [in] f_eshutdowntype
+ /// EFrameworkunifiedShutdownType - shutdown type i.e. normal shutdown, quick, data reset
+ ///
+ /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
+ /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
+ /// 0 - persist orignal data and
+ /// 1 - persist default data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentservicePersistAll(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSaveNotificationPersistentData
+ /// In this function, all the data related to persistent notification is retrieved from
+ /// notification manager and stored in persistent file by persistent manager.
+ ///
+ /// \param [in] f_epersistenttype
+ /// EFrameworkunifiedPersistentVarType - Type of persistent notification
+ /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
+ /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
+ /// 0 - persist orignal data and
+ /// 1 - persist default data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSaveNotificationPersistentData(EFrameworkunifiedNotificationType f_epersistenttype,
+ UI_32 f_uinotificationpersistentservicepersistcategoryflag = 0x0);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceLoadPersistentNotificationData
+ /// In this transition, persistent file is loaded by persistent manager and
+ /// persistent notifications and its data is loaded to notification manager.
+ ///
+ /// \param [in] f_epersistenttype
+ /// EFrameworkunifiedPersistentVarType - Type of persistent notification
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceLoadPersistentNotificationData(EFrameworkunifiedNotificationType f_epersistenttype);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// DeletePersistedDataFolder
+ /// This function does not deletes the data instead just rename the folder which needs to
+ /// be deleted. And this data will gets deleted during next startup.
+ ///
+ /// \param f_uipersistcategoryflag
+ /// UI_32 - Rename the persisted data folder depending on enum EFrameworkunifiedPersistCategory value
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DeletePersistedDataFolder(UI_32 f_uipersistcategoryflag);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// Syncfs
+ /// Syncfs is carried out.
+ ///
+ /// \param
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Syncfs();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Singleton instance of NotificationManager
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotificationManager *m_pNotificationManager; ///< Instance of Notification Manager
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Singleton instance of PersonalizationManager
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CnotificationpersistentservicePersonalizationManager *m_pPersonalizationManager; ///< Instance of Personalization Manager
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Singleton instance of PersistenceManager
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CPersistenceManager *m_pPersistenceManager;
+ // scheduling priority of read thread
+ static SI_32 m_siReadThreadPrio; // NOLINT (readability/naming)
+ // scheduling priority of write thread
+ static SI_32 m_siWriteThreadPrio; // NOLINT (readability/naming)
+ // scheduling priority of immediate persistence thread
+ static SI_32 m_siImmediatePersistenceThreadPrio; // NOLINT (readability/naming)
+ // number of times CRC check is required. (CRC check will be done more than once only on failure)
+ static UI_16
+ m_siCRCCheckCount; // NOLINT (readability/naming)
+
+ private:
+ ///< name of reader thread
+ const std::string m_cReadThreadName; // NOLINT (readability/naming)
+ ///< name of writer thread
+ const std::string m_cWriteThreadName; // NOLINT (readability/naming)
+ ///< name of immediate persistence thread
+ const std::string m_cImmediatePersistenceThreadName; // NOLINT (readability/naming)
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateAndStartChildThreads
+ /// This function creates and start all child threads.
+ ///
+ /// \param f_happ
+ /// HANDLE - Application handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateAndStartChildThreads(HANDLE f_happ);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// SwitchToFileStructureVersion1
+ /// Copy all the data from old persistent path to new persistent path
+ ///
+ /// \param [IN] f_uinppversion
+ /// UI_32 - New version of NPPService
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SwitchToFileStructureVersion1(const UI_32 f_uinppversion);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// SwitchToFileStructureVersion2
+ /// Move immediate notification data files from IMMEDIATE_PERSISTENCE_STORAGE_V1 to
+ /// IMMEDIATE_PERSISTENCE_STORAGE_V2/AllUserAppData/UserData
+ ///
+ /// \param [IN] f_uinppversion
+ /// UI_32 - New version of NPPService
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SwitchToFileStructureVersion2(const UI_32 f_uinppversion);
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNSNPPVersion
+ /// Get the version of NSNPP from version.txt
+ ///
+ /// \param
+ ///
+ /// \return UI_8
+ /// UI_8 - version number
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetNSNPPVersion();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// SetNSNPPVersion
+ /// Set the version of NSNPP in version.txt
+ ///
+ /// \param [IN] f_uiversion
+ /// UI_32 - version number
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - Returns status of operation
+ ///
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetNSNPPVersion(UI_8 f_uiversion);
+
+ HANDLE m_hNSReadThread; ///< Reader thread handle
+
+ HANDLE m_hNSWriteThread; ///< Writer thread handle
+
+ HANDLE m_hNSImmediatePersistenceThread; ///< immediate persistence thread handle
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_binary_accesser.h b/nsframework/notification_persistent_service/server/include/ns_npp_binary_accesser.h
new file mode 100644
index 00000000..aed4d2a8
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_binary_accesser.h
@@ -0,0 +1,230 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CBinaryAccesser class.
+/// This class stores data in a file in binary format.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_BINARY_ACCESSER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_BINARY_ACCESSER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <vector>
+#include "ns_npp_persistent_accesser.h"
+
+class CPersistentAccesser;
+class CPersistentData;
+class CNotificationsToPersist;
+class CPersistDataHeader;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// vector of all available persistent notification and its data.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef std::vector<CNotificationsToPersist *> Persistent_Notification_List_Type;
+
+typedef Persistent_Notification_List_Type::iterator Persistent_Notification_List_Iterator;
+
+/**
+ * This class stores data in a file in binary format.
+ *
+ */
+class CBinaryAccesser: public CPersistentAccesser {
+ public:
+ typedef enum FileOpentype {
+ EREAD = 0,
+ EWRITE
+ } FILE_OPEN_TYPE;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CBinaryAccesser
+ /// Constructor of CBinaryAccesser class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CBinaryAccesser();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CBinaryAccesser
+ /// Destructor of CBinaryAccesser class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CBinaryAccesser();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// PersistData
+ /// Persist data in persistent memory in a file in binary format.
+ ///
+ /// \param [IN] f_cmemfilepath
+ /// std::string - Memory file path for saving notification.
+ ///
+ /// \param [IN] f_vdata
+ /// Persistent_Notification_List_Type* - Data which has to be persisted.
+ ///
+ /// \param [IN] f_epersistenttype
+ /// EFrameworkunifiedNotificationType - Type of Notification.
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PersistData(std::string f_cmemfilepath,
+ Persistent_Notification_List_Type *f_vdata,
+ EFrameworkunifiedNotificationType f_epersistenttype,
+ EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// RetrieveData
+ /// Retrieve data from from a file from persistent memory and store in a vector.
+ ///
+ /// \param [IN] f_cmemfilepath
+ /// std::string - Memory file path from where to retrieve notification data.
+ ///
+ /// \param [OUT] f_vdata
+ /// Persistent_Notification_List_Type*& - Retrieved notification data is filled in this vector.
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RetrieveData(std::string f_cmemfilepath,
+ Persistent_Notification_List_Type *&f_vdata, // NOLINT (runtime/references)
+ EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData);
+
+ private:
+ UI_32 m_uiCurStrOffset;
+ UI_32 m_uiCurStrSize;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OpenFileForReading
+ /// Open file in read mode.
+ ///
+ /// \param [OUT] f_Fd
+ /// int * - File descriptor to read from a file
+ ///
+ /// \param [IN] f_cfilepath
+ /// std::string - File Path from the file is to be read
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OpenFileForReading(int *f_infd,
+ std::string f_cfilepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OpenFileForWriting
+ /// Open file in write mode.
+ ///
+ /// \param [OUT] f_Fd
+ /// int * - File descriptor to write to a file
+ ///
+ /// \param [IN] f_cfilepath
+ /// std::string - File Path for the file that is to be written
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OpenFileForWriting(int *f_outfd,
+ std::string f_cfilepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// WriteHeaderAndData
+ /// Write header and data in a file.
+ ///
+ /// \param [IN] f_pnotificationstopersist
+ /// CNotificationsToPersist - Object of class CNotificationsToPersist
+ ///
+ /// \param [IN] f_pdata
+ /// PVOID - notification data
+ ///
+ /// \param [IN] f_Fd
+ /// int - File descriptor to write the file.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus WriteHeaderAndData(CNotificationsToPersist *f_pnotificationstopersist,
+ PVOID f_pdata,
+ int f_outfd);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ReadHeaderAndData
+ /// Read header from the file.
+ ///
+ /// \param [IN] f_objcpersistdataheader
+ /// CPersistDataHeader& - Object of class CPersistDataHeader
+ ///
+ /// \param [OUT] f_pdata
+ /// CHAR*& -
+ ///
+ /// \param [IN] f_Fd
+ /// int - File descriptor to read the file.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ReadHeaderAndData(CPersistDataHeader &f_objcpersistdataheader, // NOLINT (runtime/references)
+ CHAR *&f_pdata, int f_infd); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FillNotificationList
+ /// This function retrieves the notification data from file and fill it in map.
+ ///
+ /// \param [IN] f_Fd
+ /// int - File descriptor to retrieve notification data.
+ ///
+ /// \param [OUT] f_vdata
+ /// Persistent_Notification_List_Type*& - Retrieved notification data is filled in this vector.
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FillNotificationList(int f_infd,
+ Persistent_Notification_List_Type *&f_vdata, // NOLINT (runtime/references)
+ EFrameworkunifiedPersistCategory f_epersistcategory);
+
+ EFrameworkunifiedStatus WriteFileHeaderAndDuplicate(int f_outfd, std::string f_cfilepath);
+ EFrameworkunifiedStatus CheckFileHeader(int f_infd);
+ EFrameworkunifiedStatus OpenBakFileForReading(int *f_infd, std::string f_cfilepath);
+ UI_32 CalcCRC(PVOID f_pdata, UI_32 f_size);
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_BINARY_ACCESSER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_copy_worker.h b/nsframework/notification_persistent_service/server/include/ns_npp_copy_worker.h
new file mode 100644
index 00000000..984296f6
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_copy_worker.h
@@ -0,0 +1,558 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contain declaration of class CCopyWorker and CArchive.
+/// Class CCopyWorker holds the implementation for worker thread.
+/// Class CArchive holds the implementation for archive.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_COPY_WORKER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_COPY_WORKER_H_
+
+#define LIBTARFAIL -1
+#define LIBTARSUCCESS 0
+#define TARMODE 0644
+#define FILEERROR -1
+
+#include <pthread.h>
+#include <libtar.h>
+#include <stdio.h>
+#include <zlib.h>
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_utility_sys.hpp>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/ns_np_service.h>
+
+#include <map>
+#include <string>
+
+#include "ns_npp_types.h"
+
+typedef std::map<std::string, UI_32> TMTagCRC; // map of tag and corresponding CRC
+typedef std::map<std::string, TMTagCRC> TMServiceTagCRC; // map of service and tag list
+typedef std::map<int, gzFile> GZFiles;
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPCopyWorkerOnStart
+/// Callback method on start of worker thread.
+///
+/// \param [IN] f_hthread
+/// HANDLE - Thread Handle
+///
+/// \return EFrameworkunifiedStatus
+// EFrameworkunifiedStatus - success or failure status
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPCopyWorkerOnStart(HANDLE f_hthread);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPCopyWorkerOnStop
+/// Callback method on stopping of worker thread.
+///
+/// \param [IN] f_hthread
+/// HANDLE - Thread Handle
+///
+/// \return EFrameworkunifiedStatus
+// EFrameworkunifiedStatus - success or failure status
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPCopyWorkerOnStop(HANDLE f_hthread);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// gzopen_frontend
+/// Method to set archiving options.
+///
+/// \param [IN] f_pcpathname
+/// PCHAR - Thread Handle
+///
+/// \param [IN] f_sioflags
+/// SI_32 - Open file flags
+///
+/// \param [IN] f_simode
+/// SI_32 - File Mode
+///
+/// \return EFrameworkunifiedStatus
+// EFrameworkunifiedStatus - success or failure status
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 OpenArchive(PCHAR f_pcpathname, SI_32 f_sioflags, SI_32 f_simode);
+
+int CloseArchive(int fd);
+ssize_t ReadArchive(int fd, void *buf, size_t count);
+ssize_t WriteArchive(int fd, const void *buf, size_t count);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPServiceOnDeleteOldDataCmd
+/// This callback is used to delete the data which was requested to be deleted during
+/// previous shutdown.
+///
+/// \param [in] f_happ
+/// HANDLE - Handle to notificationpersistentservice_application Framework.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPServiceOnDeleteOldDataCmd(HANDLE f_happ);
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPDataResetThreadCallback
+/// Callback of data reset thread.
+/// This callback delete all the data which was requested for reset during previous shutdown.
+///
+/// \param [in] f_parg
+/// PVOID - Thread argument
+///
+/// \return PVOID
+/// PVOID - NULL
+////////////////////////////////////////////////////////////////////////////////////////////
+PVOID NSPDataResetThreadCallback(PVOID f_parg);
+
+class CCopyWorker {
+ public:
+ static TMServiceTagCRC g_mservicetagcrc;
+ static CMutex g_objmtxservicetag;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CCopyWorker
+ /// Constructor of class CCopyWorker
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CCopyWorker();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CCopyWorker
+ /// Destructor of class CCopyWorker
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CCopyWorker();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnWrkCmdCopy
+ /// Callback method for start copy command.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnWrkCmdCopy(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnWrkCmdResume
+ /// Callback method for resuming worker thread.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnWrkCmdResume(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnWrkCmdStart
+ /// Callback method for starting worker thread.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnWrkCmdStart(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnWrkCmdArchive
+ /// Callback method to start archiving/unarchiving for file or folder
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnWrkCmdArchive(HANDLE f_hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnWrkCmdStop
+ /// Callback method for stopping worker thread.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnWrkCmdStop(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnCmdShutdownRequest
+ /// Callback method on shutdown request.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnCmdShutdownRequest(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Abort
+ /// Method to abort worker thread tasks.
+ ///
+ ///
+ /// \return VOID
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ static VOID Abort();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetCopyStatusToFailure
+ /// Method to set the copy status to failure.
+ ///
+ /// \param [IN] f_tcopystatusresponse
+ /// NSP_CopyStatusResponse - Response status struct
+ ///
+ /// \param [IN] f_eworkerfailcmd
+ /// ENPS_CopyWorkerFailures - Worker failure Commands
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetCopyStatusToFailure(NSP_CopyStatusResponse &f_tcopystatusresponse, // NOLINT (runtime/references)
+ const ENPS_CopyWorkerFailures f_eworkerfailcmd);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// InAbortState
+ /// Method to check if the thread is in abort state
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return BOOL
+ // BOOL - true if in abort state or false.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL InAbortState() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SendAck
+ /// Method to send ack to the parent thread
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \param [IN] f_eworkercmd
+ /// ENSP_CopyWorkerProtocol - Worker protocol command
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SendAck(HANDLE hthread, const ENSP_CopyWorkerProtocol &f_eworkercmd);
+
+ private:
+ static pthread_mutex_t m_sAbortMutex; // NOLINT (readability/naming) , Mutex for abort
+ static BOOL m_sbAbortCopy; // NOLINT (readability/naming) , Check for abort state
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CopyFile
+ /// Copy the content of source file f_csrcpath to destination file f_cdestpath.
+ /// Creates the destination file path if does not exists.
+ ///
+ /// \param [IN] f_csrcpath
+ /// PCSTR - source file path
+ ///
+ /// \param [IN] f_cdestpath
+ /// PCSTR - dest file path
+ ///
+ /// \param [OUT] f_uiwritesize
+ /// UI_32 - number of bytes written to the destination file
+ ///
+ /// \param [IN] f_btmpfile
+ /// BOOL - TRUE:RELEASE-temp file use /FALSE:LOAD-temp file not use
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK on success else eFrameworkunifiedStatusFail
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CopyFile(PCSTR f_csrcpath, PCSTR f_cdestpath, UI_32 &f_uiwritesize, BOOL btmpfile = FALSE); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetCopyBufSize
+ /// Get the buffer size appropriate for file copy
+ ///
+ /// \param [IN] f_si32openfd
+ /// SI_32 - File descriptor of a file opened with open() api
+ ///
+ /// \param [OUT] f_ui32filesize
+ /// UI_32 - Get the size of file
+ ///
+ /// \return SI_32
+ /// SI_32 - Returns the buffer size appropriate for file copy
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ SI_32 GetCopyBufSize(SI_32 f_si32openfd, UI_32 &f_ui32filesize); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// VerifyWithStoredCRC
+ /// Verify CRC stored internally for the tag matches with the CRC of a file (file passed as a argument)
+ ///
+ /// \param [IN] f_crequesterappname
+ /// PCSTR - Name of the requester. This is to find the corresponding stored CRC
+ ///
+ /// \param [IN] f_cpersistenttag
+ /// PCSTR - Tag. This is to find the corresponding stored CRC
+ ///
+ /// \param [IN] f_cFile
+ /// PCSTR - Complete file path on temporary storage.
+ /// Comparison of CRC needs to be done with this temporary file.
+ ///
+ /// \return BOOL
+ /// BOOL - Returns TRUE if f_cFile's CRC matches with CRC stored internally for the corresponding tag
+ /// else FALSE
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL VerifyWithStoredCRC(PCSTR f_crequesterappname, PCSTR f_cpersistenttag, PCSTR f_cFile, UI_32 &f_ui32crc); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// UpdateTagCRC
+ /// Update the passed CRC in the internal map for the corresponding requester and tag.
+ ///
+ /// \param [IN] f_crequesterappname
+ /// PCSTR - Name of the requester.
+ ///
+ /// \param [IN] f_cpersistenttag
+ /// PCSTR - File Tag.
+ ///
+ /// \param [IN] f_ui32crc
+ /// UI_32 - New CRC.
+ ///
+ /// \return None
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID UpdateTagCRC(PCSTR f_crequesterappname, PCSTR f_cpersistenttag, UI_32 f_ui32crc);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// TryFileCopyWithCRCCheck
+ /// Try to copy file from source to destination until src and dest CRC matches or max f_ui32checkcount
+ /// number of times
+ ///
+ /// \param [IN] f_csource
+ /// PCSTR - Source file
+ ///
+ /// \param [IN] f_cdest
+ /// PCSTR - Destination file
+ ///
+ /// \param [IN] f_ui32checkcount
+ /// UI_32 - Maximum number of times to perform file copy
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK - If file copy done successfully and CRC matches.
+ /// eFrameworkunifiedStatusFail - otherwise
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus TryFileCopyWithCRCCheck(PCSTR f_csource, PCSTR f_cdest, UI_32 f_ui32checkcount);
+
+ class CArchive {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CArchive
+ /// Constructor of CArchive class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CArchive();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CArchive
+ /// Destructor of CArchive class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CArchive();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Archive
+ /// Method for performing folder archive or extraction operation.
+ ///
+ /// \param [IN] f_tarchiveinfocmd
+ /// NSP_CopyInfoCmd - Archive Command Info Structure
+ ///
+ /// \param [IN] f_tarchivestatusresponse
+ /// NSP_CopyStatusResponse - Archive Command Response Structure
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Archive(NSP_CopyInfoCmd &f_tarchiveinfocmd, NSP_CopyStatusResponse &f_tarchivestatusresponse); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// FileOperationUsingLibz
+ /// Method to determine whether to compress or decompres file using libz.
+ ///
+ /// \param [IN] f_toperainfocmd
+ /// NSP_CopyInfoCmd - File Operation Command Info Structure
+ ///
+ /// \param [IN] f_toperarespstatus
+ /// NSP_CopyStatusResponse - File Operation Command Response Structure
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus FileOperationUsingLibz(NSP_CopyInfoCmd &f_toperainfocmd, NSP_CopyStatusResponse &f_toperarespstatus); // NOLINT (runtime/references)
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateTar
+ /// Method to Create tar archive.
+ ///
+ /// \param [IN] f_csourepath
+ /// std::string - Source path of the folder to be archived
+ ///
+ /// \param [IN] f_cdestpath
+ /// std::string - Destination path for the archived folder.
+ ///
+ /// \param [IN] f_tarchivestatusresponse
+ /// NSP_CopyStatusResponse - Archive Command Response Structure
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreateTar(const std::string &f_csourepath, const std::string &f_cdestpath,
+ NSP_CopyStatusResponse &f_tarchivestatusresponse); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ExtractTar
+ /// Method to extract tar archive.
+ ///
+ /// \param [IN] f_csourepath
+ /// std::string - Source path of the folder to be extracted
+ ///
+ /// \param [IN] f_csourcedest
+ /// std::string - Destination path for the extracted folder.
+ ///
+ /// \param [IN] f_tarchivestatusresponse
+ /// NSP_CopyStatusResponse - Archive Command Response Structure
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ExtractTar(const std::string &f_csourepath, const std::string &f_csourcedest,
+ NSP_CopyStatusResponse &f_tarchivestatusresponse); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Create
+ /// Method to Create archive
+ ///
+ /// \param [IN] f_pctarfiledestpath
+ /// CHAR - Destination path for the archived folder.
+ ///
+ /// \param [IN] f_pcrootdirpath
+ /// CHAR - Source path of the folder to be archived
+ ///
+ /// \param [IN] f_plibtarlist
+ /// BOOL - TRUE if user file else FALSE
+ ///
+ /// \return SI_32
+ //
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Create(std::string &f_pctarfiledestpath, std::string &f_pcrootdirpath, libtar_list_t *f_plibtarlist); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Extract
+ /// Nethod to extract archive.
+ ///
+ /// \param [IN] f_pcrootdirpath
+ /// CHAR - Source path of the folder to be extracted
+ ///
+ /// \param [IN] f_pctarfiledestpath
+ /// CHAR - Destination path for extraction.
+ ///
+ /// \return SI_32
+ //
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Extract(std::string &f_pcrootdirpath, std::string &f_pctarfiledestpath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CompressUsingZlib
+ /// Method to compress file using libz
+ ///
+ /// \param [IN] f_csourepath
+ /// std::string - Source path of the file to be compressed
+ ///
+ /// \param [IN] f_cdestpath
+ /// std::string - Destination path for the compressed file.
+ ///
+ /// \param [IN] f_iziplevel
+ /// Level of compression i.e.
+ /// More compression results in more time taken for compression operation and vice versa.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CompressUsingZlib(const std::string &f_csourepath, const std::string &f_cdestpath, SI_32 f_iziplevel);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// DeCompressUsingZlib
+ /// Method to decompress file using libz.
+ ///
+ /// \param [IN] f_csourepath
+ /// std::string - Source path of the file to be decompressed.
+ ///
+ /// \param [IN] f_csourcedest
+ /// std::string - Destination path for the decompressed file.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DeCompressUsingZlib(const std::string &f_csourepath, const std::string &f_csourcedest);
+ };
+};
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_COPY_WORKER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_fs_directory.h b/nsframework/notification_persistent_service/server/include/ns_npp_fs_directory.h
new file mode 100644
index 00000000..4f7876db
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_fs_directory.h
@@ -0,0 +1,111 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CFSDirectory.
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_FS_DIRECTORY_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_FS_DIRECTORY_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+
+
+// Class to provide file system directory operations like create,delete etc.
+class CFSDirectory {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFSDirectory
+ /// Constructor of CFSDirectory class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFSDirectory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFSDirectory
+ /// Destructor of CFSDirectory class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFSDirectory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to check if the directory exists.
+ ///
+ /// \param [in] f_cdirpath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL DoesDirecotryExist(const std::string &f_cdirpath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to create a directory.
+ ///
+ /// \param [in] f_cdirpath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus CreateDirectory(const std::string &f_cdirpath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to verify directory.
+ ///
+ /// \param [in] f_cpath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL IsDirectory(const std::string &f_cpath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to delete directory with delay of f_uidelay(msec)
+ /// between consecutive deletes.
+ ///
+ /// \param [in] f_cpath
+ /// std::string - Path of the directory to delete.
+ /// \param [in] f_uidelay
+ /// UI_32 - delay in millisec before recursive call.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL RemoveDirectory(std::string f_cpath, const UI_32 f_uidelay = 0);
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_FS_DIRECTORY_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_handlelist.h b/nsframework/notification_persistent_service/server/include/ns_npp_handlelist.h
new file mode 100644
index 00000000..30c8a26f
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_handlelist.h
@@ -0,0 +1,145 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup tag_NS_NPPService
+/// \ingroup tag_NS_NPPService
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This class holds the message queue handles for notification subscribers
+///
+/// This is a singleton class which holds the message queue handles for notification subscribers.
+/// This will ensure that NS_NPPService will hold only one handle per subscriber.
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_HANDLELIST_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_HANDLELIST_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <map>
+#include <utility>
+
+typedef std::map<std::string, HANDLE> HandleList_Type;
+typedef std::pair<HandleList_Type::iterator, bool> HandleListRetStatus_Type;
+
+
+
+/**
+ * This class holds the message queue handles for notification subscribers
+ */
+class CHandleList {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetHandleList
+ /// This function is used to get the singleton instance of class.
+ /// NOTE: Not thread safe. Others threads would not use this function.
+ ///
+ /// \return CHandleList
+ /// CHandleList - singleton instance of class
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ static CHandleList *GetHandleList();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ReleaseHandleList
+ /// This function is used to release the instance of class.
+ /// NOTE: Not thread safe. Others threads would not use this function.
+ ///
+ /// \param
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus ReleaseHandleList();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddHandleInList
+ /// Add pair of subscriber name and corresponding handle in map.
+ /// NOTE: Not thread safe. Others threads would not use this function.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ /// \param [IN] f_hmqhandle
+ /// HANDLE - Message queue handle of the subscriber
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus -
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AddHandleInList(std::string f_csubscribername, HANDLE f_hmqhandle);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// RemoveHandleFromList
+ /// Remove handle for subscriber from the list.
+ /// Handle will actually get removed when all the notifications are unsubscribed by the subscriber
+ /// NOTE: Not thread safe. Others threads would not use this function.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus -
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RemoveHandleFromList(std::string f_csubscribername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetSubscriberMqHandle
+ /// Get the message queue handle of a subscriber.
+ /// NOTE: Not thread safe. Others threads would not use this function.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ ///
+ /// \return HANDLE
+ // HANDLE - Message queue handle of the subscriber
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ HANDLE GetSubscriberMqHandle(std::string f_csubscribername);
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CHandleList
+ /// Constructor of CHandleList class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CHandleList();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CHandleList
+ /// Destructor of CHandleList class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CHandleList();
+
+ HandleList_Type m_mHandleList; ///< map which stores all the message queue handle
+
+ static CHandleList *m_psHandleList; // NOLINT (readability/naming)
+};
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_HANDLELIST_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_nor_persistence_worker_thread.h b/nsframework/notification_persistent_service/server/include/ns_npp_nor_persistence_worker_thread.h
new file mode 100644
index 00000000..a3994ca0
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_nor_persistence_worker_thread.h
@@ -0,0 +1,218 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contain declaration of class CImmediatePersistenceWorker and holds the
+/// implementation for worker thread.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_timer_if.hpp>
+
+#include "ns_npp_types.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSP_NorPersistenceWorkerOnStart
+/// Callback method on start of worker thread.
+///
+/// \param [IN] hthread
+/// HANDLE - Thread Handle
+///
+/// \return EFrameworkunifiedStatus
+// EFrameworkunifiedStatus - success or failure status
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStart(HANDLE hthread);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPNorPersistenceWorkerOnStop
+/// Callback method on stopping of worker thread.
+///
+/// \param [IN] hthread
+/// HANDLE - Thread Handle
+///
+/// \return EFrameworkunifiedStatus
+// EFrameworkunifiedStatus - success or failure status
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStop(HANDLE hthread);
+
+// Forward Declaration for class
+class CNotificationsToPersist;
+
+
+/**
+ * This class handles the immediate persistence notification related requests.
+ *
+ */
+class CNorPersistenceWorker {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNorPersistenceWorker
+ /// Constructor of class CNorPersistenceWorker
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNorPersistenceWorker();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNorPersistenceWorker
+ /// Destructor of class CNorPersistenceWorker
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNorPersistenceWorker();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnNorPersistenceTimerStart
+ /// When immediate persistence notification publish request is received by NPPService. It sends a
+ /// NOR_PERSISTENCE_TIMER_START command to the worker thread and this function gets called.
+ /// This function starts the respective timer of the notification. Timeout of timer writes
+ /// corresponding notification data to persistent memory.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnNorPersistenceTimerStart(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// RegisterImmediatePersistNotification
+ /// When immediate persistence notification register request is received by NPPService. It sends a
+ /// NOR_PERSISTENCE_REGISTER command to the worker thread and this function gets called.
+ /// Registration with worker thread is required because only child thread will be responsible for
+ /// data saving related stuff. It creates a timer corresponding to the notification.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RegisterImmediatePersistNotification(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// UnregisterImmediatePersistNotification
+ /// When immediate persistence notification unregister request is received by NPPService. It sends a
+ /// NOR_PERSISTENCE_UNREGISTER command to the worker thread and this function gets called.
+ /// It deletes a timer corresponding to the notification.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus UnregisterImmediatePersistNotification(HANDLE hthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnShutdown
+ /// This API stops all the immediate notification timer.
+ /// This API immediately writes the data to persistent memory if the timer is runnning,
+ /// irrespective of delay unless the data .
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnShutdown(HANDLE hthread);
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnCategoryChange
+ /// This API updates the category of immediate persistence notification.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnCategoryChange(HANDLE hthread);
+};
+
+/**
+ * CTimerHelper class maps the timer id and corresponding data.
+ *
+ */
+class CTimerHelper: public NSTimer {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CTimerHelper
+ /// Constructor of class CTimerHelper
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CTimerHelper();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CTimerHelper
+ /// Destructor of class CTimerHelper
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CTimerHelper();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetCmdId
+ /// Returns the timer id of the timer.
+ ///
+ /// \param [IN] none
+ ///
+ /// \return UI_32
+ // UI_32 - Timer id of the timer
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetCmdId();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// OnTimeOut
+ /// This function gets called when timer expires. This function writes the notification data in
+ /// persistent memory.
+ ///
+ /// \param [IN] f_hthread
+ /// HANDLE - Thread Handle
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus OnTimeOut(HANDLE hthread);
+
+ // member variables
+ PUI_8 m_pui8HeaderAndData; // header and corresponding data of the notfn stored as part of timer
+
+ private:
+ UI_32 m_uiCmdId; // command id associated with timer
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOR_PERSISTENCE_WORKER_THREAD_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_notification.h b/nsframework/notification_persistent_service/server/include/ns_npp_notification.h
new file mode 100644
index 00000000..673e54cd
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_notification.h
@@ -0,0 +1,323 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <map>
+#include <string>
+#include <iostream>
+#include "ns_npp_notification_receiver.h"
+
+typedef std::map<std::string, CNotificationReceiver *> NotifReceiver_Type;
+
+/// Iterator of map of CNotificationReceiver
+typedef NotifReceiver_Type::iterator NotifReceiver_Iterator_Type;
+
+/**
+ * This class is base class for all the notification types classes.
+ */
+class CNotification {
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNotification
+ /// Parameterless Constructor of CNotification class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotification();
+
+ protected:
+ std::string m_cNotificationName; ///< Name of Notification
+
+ UI_32 m_uiMaxMsgSize; ///< Maximum size of notification data
+
+ EFrameworkunifiedNotificationType m_ePersistentType; ///< type of notification
+
+ std::string m_cServiceName; ///< List of services registering notification
+
+ NotifReceiver_Type *m_pmSubscribersList; ///< list of subscribers of notification
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddReceiverInMap
+ /// This function adds the name of the service to receiver list of notification.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AddReceiverInMap(const std::string &f_csubscribername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// PublishData
+ /// This function publishes the notification to subscribed clients.
+ ///
+ /// \param [IN] f_hmsgqhandle
+ /// HANDLE - MessageQ Handle of ReceiverQ
+ ///
+ /// \param [IN] f_pmessage
+ /// std::string - data of notification
+ ///
+ /// \param [IN] f_uimsgsize
+ /// std::string - length of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PublishData(HANDLE f_hmsgqhandle,
+ const PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNotification
+ /// Constructor of CNotification class
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification name
+ ///
+ /// \param [IN] f_uimaxmsgsize
+ /// UI_32 - Maximum size of notification data
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNotification
+ /// Destructor of CNotification class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CNotification();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddEventReciever
+ /// This function adds the name of the application to receiver list of particular notification.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus AddEventReciever(const std::string &f_csubscribername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Publish
+ /// This function publishes the notification to subscribed clients.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service publishing the notification
+ ///
+ /// \param [IN] f_pmessage
+ /// std::string - data of notification
+ ///
+ /// \param [IN] f_uimsgsize
+ /// std::string - length of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// DeleteEventReciever
+ /// This function deletes the name of application from receivers list.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus DeleteEventReciever(const std::string &f_csubscribername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetNewSubscribersList
+ /// This function sets the subscribers list of notification
+ ///
+ /// \param [IN] f_pnotification
+ /// CNotification - notification object containing subscribers list
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetNewSubscribersList(CNotification *f_pnotification);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetEventPublisher
+ /// This function set the publisher name to current received service name
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of application
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetEventPublisher(const std::string &f_cservicename);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ResetEventPublisher
+ /// This function resets the publisher name to NULL
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of application
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ResetEventPublisher(const std::string &f_cservicename);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsServiceRegistered
+ /// This function checks whether the notification is registered with any service or not.
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - true,if subscriber list is empty
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsServiceRegistered();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsSubscribersListEmpty
+ /// This function is used to check whether any service is subscribed to notification
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - true,if subscriber list is empty
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsSubscribersListEmpty();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNotificationName
+ /// This function is used to get the notification name.
+ ///
+ /// \param
+ ///
+ /// \return std::string
+ // std::string - notification name
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetNotificationName();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPublisherName
+ /// This function is used to get the publisher name of notification.
+ ///
+ /// \param
+ ///
+ /// \return std::string
+ // std::string - service name
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetPublisherName();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistenceType
+ /// This function is used to get the type of notification.
+ ///
+ /// \param
+ ///
+ /// \return EFrameworkunifiedPersistentVarType
+ // EFrameworkunifiedPersistentVarType - persistent type
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedNotificationType GetNotificationType();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetMaxMessageSize
+ /// This function is used to get the max size of data of notification message.
+ ///
+ /// \param
+ ///
+ /// \return UI_32
+ // UI_32 - Max Message Size
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetMaxMessageSize();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ResetMaxMessageSize
+ /// This function reset the max size of data that can be published with notification
+ ///
+ /// \param [IN] f_uilength
+ /// std::string - Max size for notification data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus ResetMaxMessageSize(const UI_32 f_uilength);
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetSubscriberList
+ /// Returns the list of subscribers subscribed to notification
+ ///
+ /// \param
+ ///
+ /// \return NotifReceiver_Type
+ // NotifReceiver_Type - subscriber's list of notification
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ NotifReceiver_Type *GetSubscriberList();
+
+#endif
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_notification_manager.h b/nsframework/notification_persistent_service/server/include/ns_npp_notification_manager.h
new file mode 100644
index 00000000..e730d02a
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_notification_manager.h
@@ -0,0 +1,496 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of singleton class CNotificationManager which is used
+/// to manage notification information.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_np_service.h>
+
+#include <map>
+#include <vector>
+#include <string>
+#include <iostream>
+
+/// forward declaration of class
+class CNotification;
+class CPersistentData;
+class CNotificationsToPersist;
+class CStateNotification;
+
+/// map of all the available notification.
+typedef std::map<std::string, CNotification *> Notification_Type;
+
+/// iterator for map of notifications.
+typedef Notification_Type::iterator Notification_Iterator_Type;
+
+/// map of all available persistent notification and its data.
+typedef std::map<std::string, CPersistentData *> Persistent_Type;
+
+/// Iterator for map of persistent notifications.
+typedef Persistent_Type::iterator Persistent_Iterator_Type;
+
+/**
+ * This class is used to manage the operations related to notification
+ * on registration, subscription, publication, etc.
+ */
+class CNotificationManager {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNotificationManager
+ /// Constructor of CNotificationManager class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotificationManager();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNotificationManager
+ /// Destructor of CNotificationManager class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNotificationManager();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceServiceOnRegisterEvents
+ /// This function creates notification object depending on its type and if already created it
+ /// adds the service name to the list in the notification object.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service registering for notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \param [IN] f_uimsglength
+ /// UI_32 - Maximum length of Message
+ ///
+ /// \param [IN] f_enotificationtype
+ /// EFrameworkunifiedPersistentVarType - type of notification
+ ///
+ /// \param [IN] f_uidelay
+ /// UI_32 - Delay time for persistence
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceServiceOnRegisterEvents(const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ const UI_32 f_uimsglength,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ const UI_32 f_uidelay = 0);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceServiceOnUnRegisterEvents
+ /// This function removes the name of the service from the notification object.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service unregistering from notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceServiceOnUnRegisterEvents(const std::string &f_cservicename,
+ const std::string &f_cnotificationname);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceServiceOnPublishEvent
+ /// This function stores the published data in the notification object in case of state and
+ /// persistent notification.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service registering for notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \param [IN] f_pmessage
+ /// PVOID - pointer to message
+ ///
+ /// \param f_uimsgsize
+ /// UI_32 - size of Message
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceServiceOnPublishEvent(const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceServiceOnSubscribeToEvent
+ /// This function adds the name of the application to subscribers list in notification object.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing to notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceServiceOnSubscribeToEvent(const std::string &f_csubscribername,
+ const std::string &f_cnotificationname);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceServiceOnUnSubscribeFromEvent
+ /// This function adds the name of the application to subscribers list in notification object.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing to notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceServiceOnUnSubscribeFromEvent(const std::string &f_csubscribername,
+ const std::string &f_cnotificationname);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NPGetPersistentNotificationData
+ /// Get data for notification name
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - name of notification
+ /// \param [OUT] f_pnotificationdata
+ /// PVOID - data corresponding to notification name
+ /// \param [IN] f_uidatasize
+ /// UI_32 - size of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NPGetPersistentNotificationData(const std::string &f_cnotificationname,
+ PVOID f_pnotificationdata, const UI_32 f_uidatasize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceServiceOnGetPersistentData
+ /// This function is used to get the persistent data stored related to notification.
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification Name
+ ///
+ /// \param [IN] f_creceivername
+ /// std::string - Source Name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceServiceOnGetPersistentData(const std::string &f_cnotificationname,
+ const std::string &f_creceivername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceGetPersistentNotificationData
+ /// This function is used to get the list of persistent notifications and the data associated
+ /// with it.
+ ///
+ /// \param [OUT] f_pvpersistnotification
+ /// CNotificationsToPersist - vector containing list of persistent notifications and
+ /// data associated with it.
+ ///
+ /// \param [IN] f_enotificationtype
+ /// EFrameworkunifiedNotificationType - Type of notification
+ ///
+ /// \param [IN] f_uinotificationpersistentservicepersistcategoryflag
+ /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
+ /// 0 - persist orignal data and
+ /// 1 - persist default data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceGetPersistentNotificationData(std::vector<CNotificationsToPersist *> *f_pvpersistnotification,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ UI_32 f_uinotificationpersistentservicepersistcategoryflag);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSetPersistentNotificationData
+ /// This function is used to create the persistent notifications object and fill the data
+ /// related with it on system load.
+ ///
+ /// \param [IN] f_pvpersistnotification
+ /// vector<CNotificationsToPersist> - vector containing list of notifications and data associated with it
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentNotificationData(std::vector<CNotificationsToPersist *> *f_pvpersistnotification);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNotificationInfo
+ /// This function is used to get the notification information.
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification Name
+ ///
+ /// \param [IN] l_pnotificationstopersist
+ /// CNotificationsToPersist - Notification info structure
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetNotificationInfo(const std::string &f_cnotificationname,
+ CNotificationsToPersist *&l_pnotificationstopersist); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSetDefaultPersistentNotificationData
+ /// This function is used to set the default data of persistent notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ /// \param [IN] f_pmessage
+ /// PVOID - message data
+ /// \param [IN] f_uimsgsize
+ /// UI_32 - message size
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSetDefaultPersistentNotificationData(const std::string &f_cnotificationname,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSetPersistentCategory
+ /// This function is used to set the persistent type of persistent notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ /// \param [IN] f_epersistenttype
+ /// EFrameworkunifiedPersistCategory - persistent category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentCategory(const std::string &f_cnotificationname,
+ const EFrameworkunifiedPersistCategory f_epersistcategory);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentservicePublishImmediateNotification
+ /// This function publish the immediate notification f_cnotificationname to all its subscribers.
+ /// This API is called when service updates the immediate notification data in persistent memory
+ /// using synchronous API.
+ ///
+ /// \param [IN] f_cservicename
+ /// const std::string& - name of service registering for notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// const std::string& - notification name
+ ///
+ /// \param [IN] f_pmessage
+ /// PVOID - pointer to message
+ ///
+ /// \param f_uimsgsize
+ /// UI_32 - size of Message
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - eFrameworkunifiedStatusOK on success
+ /// eFrameworkunifiedStatusInvldParam - invalid parameter
+ /// eFrameworkunifiedStatusNullPointer - if notification not found
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentservicePublishImmediateNotification(const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetNotificationProfilingData
+ /// This function is used to get the notification profiling information.
+ ///
+ /// \param [OUT] f_tNotificationProfileInfo
+ /// std::string - all the notification info of all applications concated in a string
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetNotificationProfilingData(std::string &f_cnotificationprofileInfo); // NOLINT (runtime/references)
+
+#endif
+
+ private:
+ Notification_Type *m_pmNotificationList; /// < map containing list of all notifications.
+
+ std::vector<std::string> *m_pvPersistentList; /// < vector containing list of all persistent notifications.
+
+ std::vector<std::string> *m_pvUserPersistentList; /// < vector containing list of all user persistent notifications.
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateNotificationObject
+ /// This function is used to get notification object from map if it exists else create new
+ /// object as per type of notification.
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \param [IN] f_uimsglength
+ /// UI_32 - Maximum size of notification message
+ ///
+ /// \param [IN] f_enotificationtype
+ /// EFrameworkunifiedPersistentVarType - Delay time for persistence
+ ///
+ /// \param [IN] f_uidelay
+ /// UI_32 - Persistence Delay
+ ///
+ /// \return CNotification
+ // CNotification - pointer of notification object
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotification *CreateNotificationObject(const std::string &f_cnotificationname,
+ const UI_32 f_uimsglength,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ const UI_32 f_uidelay = 0);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SearchNotification
+ /// This function is used to search whether notification object is present in map or not.
+ /// If present it sends the reference. CNotification - reference to pointer of notification object
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \return CNotification
+ // CNotification - pointer of notification object
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotification *SearchNotification(const std::string &f_cnotificationname);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SearchPersistenceNotification
+ /// This function is used to search whether the given persistent notification object
+ /// is present in map or not.
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \return CStateNotification
+ // CStateNotification - pointer of notification object
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CStateNotification *SearchPersistenceNotification(const std::string &f_cnotificationname);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreateNotificationObjectToPersist
+ /// Creates the CNotificationsToPersist object from notification object and the persistent data.
+ ///
+ /// \param [IN] f_pnotification
+ /// CStateNotification - notification object ptr
+ /// \param [IN] f_pdata
+ /// CPersistentData - persistent data
+ ///
+ /// \return CNotification
+ // CNotification - pointer of notification object
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotificationsToPersist *CreateNotificationObjectToPersist(CStateNotification *f_pnotification,
+ const CPersistentData *f_pdata);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// RemoveUserSpecificNotificationEntry
+ /// This function is used to get the singleton instance of class.
+ ///
+ /// \param
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus RemoveUserSpecificNotificationEntry();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ChangeNotificationType
+ /// This function creates new notification object depending on the type and replaces the old one.
+ /// The subscribers list is copied from the old notification object is copied to the new one.
+ ///
+ /// \param [IN] f_pnotification
+ /// CNotification* - old notification object
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service registering for notification
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - notification name
+ ///
+ /// \param [IN] f_uimsglength
+ /// UI_32 - Maximum length of Message
+ ///
+ /// \param [IN] f_enotificationtype
+ /// EFrameworkunifiedPersistentVarType - new type of notification
+ ///
+ /// \param [IN] f_uidelay
+ /// UI_32 - Delay time for persistence
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ChangeNotificationType(CNotification *f_pnotification,
+ const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ const UI_32 f_uimsglength,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ const UI_32 f_uidelay);
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_notification_receiver.h b/nsframework/notification_persistent_service/server/include/ns_npp_notification_receiver.h
new file mode 100644
index 00000000..09f6b151
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_notification_receiver.h
@@ -0,0 +1,68 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contain declaration of class CNotificationReceiver.
+/// It holds the handle of message queue for sending notification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_RECEIVER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_RECEIVER_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_types.h>
+
+class CNotificationReceiver {
+ private:
+ // no members in private
+
+ public:
+ HANDLE m_MsgQHandle; ///< handle to message queue
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNotificationReceiver
+ /// Constructor of CNotificationReceiver class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotificationReceiver();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNotificationReceiver
+ /// Destructor of CNotificationReceiver class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNotificationReceiver();
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_RECEIVER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_notificationpersistentservicelog.h b/nsframework/notification_persistent_service/server/include/ns_npp_notificationpersistentservicelog.h
new file mode 100644
index 00000000..e668af6a
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_notificationpersistentservicelog.h
@@ -0,0 +1,94 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATIONPERSISTENTSERVICELOG_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATIONPERSISTENTSERVICELOG_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_NPP_INFO ZONEMASK(25)
+#define ZONE_PRD_INFO3 ZONEMASK(26)
+#define ZONE_PRD_INFO2 ZONEMASK(27)
+#define ZONE_PRD_INFO1 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 "NPP Info"
+#define ZONE_TEXT_26 "Product Info3"
+#define ZONE_TEXT_27 "Product Info2"
+#define ZONE_TEXT_28 "Product Info1"
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LPRINT) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_WARN, ZONE_ERR, ZONE_NS_WAR, ZONE_NS_ERR, ZONE_PRD_INFO2
+#endif
+
+extern const CHAR AppName[]; // NOLINT (readability/naming)
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATIONPERSISTENTSERVICELOG_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_persist_file.h b/nsframework/notification_persistent_service/server/include/ns_npp_persist_file.h
new file mode 100644
index 00000000..04468bee
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_persist_file.h
@@ -0,0 +1,121 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CFilePersistence class.
+/// This class is responsible for persisting and retrieving of files.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSIST_FILE_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSIST_FILE_H_
+
+#include <native_service/ns_np_service.h>
+#include <string>
+#include <map>
+#include "ns_npp_persistence.h"
+
+// Forward declaration of classes.
+class CPersistence;
+class CRegistryEntry;
+
+/**
+ * This class is responsible for persisting and retrieving of files..
+ */
+class CFilePersistence : public CPersistence {
+ private:
+ TSourceRegistryList m_mPersistFileRegistry;
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFilePersistence
+ /// Constructor of CFilePersistence class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFilePersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFilePersistence
+ /// Destructor of CFilePersistence class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFilePersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Release
+ /// Request for release file to persistent storage. File persist will be done at shutdown.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File will be persist against this tag.
+ ///
+ /// \param [IN] f_cmempath
+ /// string - File which needs to persist.
+ ///
+ /// \param [IN] enotificationpersistentservicereleasetype
+ /// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease = 0 :not on release
+ /// eFrameworkunifiedPersistOnShutdown :persist on shutdown
+ /// eFrameworkunifiedPersistInstantly :persist instantly
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Release(std::string f_cappname, std::string f_ctag, std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype, std::string f_cusername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Load
+ /// Load file from persistent memory to the specified location.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File corresponding to this tag will be retrieved.
+ ///
+ /// \param [IN] f_cretrievepath
+ /// string - Filepath for retrieved file.
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Load(std::string f_cappname, std::string f_ctag, std::string f_cretrievepath,
+ std::string f_cusername);
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSIST_FILE_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_persist_folder.h b/nsframework/notification_persistent_service/server/include/ns_npp_persist_folder.h
new file mode 100644
index 00000000..39cf9753
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_persist_folder.h
@@ -0,0 +1,122 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSIST_FOLDER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSIST_FOLDER_H_
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <string>
+
+#include "ns_npp_persistence.h"
+
+
+// class CPersistence;
+
+class CFolderPersistence : public CPersistence {
+ private:
+ TSourceRegistryList m_mPersistFolderRegistry; // map to hold the folder registry entries
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFolderPersistence
+ /// Constructor of CFolderPersistence class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFolderPersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFolderPersistence
+ /// Destructor of CFolderPersistence class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFolderPersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Release
+ /// Entry for the folder is stored in map for persistence.
+ /// If f_bPersist is TRUE folder will be persisted immediately else will be persisted on shutdown
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - Folder will be persist against this tag.
+ ///
+ /// \param [IN] f_cmempath
+ /// string - Folder which needs to persist.
+ ///
+ /// \param [IN] enotificationpersistentservicereleasetype
+ /// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease = 0 :not on release
+ /// eFrameworkunifiedPersistOnShutdown :persist on shutdown
+ /// eFrameworkunifiedPersistInstantly :persist instantly
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Release(std::string f_crequesterappname,
+ std::string f_ctag,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ std::string f_cusername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Load
+ /// Load folder from persistent memory to the specified location.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - Folder corresponding to this tag will be retrieved.
+ ///
+ /// \param [IN] f_cretrievepath
+ /// string - Filepath for retrieved file.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Load(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cretrievepath,
+ std::string f_cusername);
+};
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSIST_FOLDER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_persistence.h b/nsframework/notification_persistent_service/server/include/ns_npp_persistence.h
new file mode 100644
index 00000000..d84f9fbe
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_persistence.h
@@ -0,0 +1,365 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CPersistence class.
+/// This is a abstract class for file and folder persistency.
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENCE_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENCE_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_np_service.h>
+#include <string>
+#include <map>
+#include <list>
+
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_copy_worker.h"
+
+class CRegistryEntry;
+
+typedef std::string TSourceName;
+typedef std::string TTag;
+typedef std::map< TTag, CRegistryEntry > TTagRegistryList;
+typedef TTagRegistryList::iterator TTagRegistryListItr;
+
+typedef std::map<TSourceName, TTagRegistryList> TSourceRegistryList;
+typedef TSourceRegistryList::iterator TSourceRegistryListItr;
+
+typedef std::list<NSP_CopyInfoCmd> TPendingJobs;
+typedef TPendingJobs::iterator TPendingJobsItr;
+
+/**
+ * This is a abstract class for file and folder persistence.
+ */
+class CPersistence {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CPersistence
+ /// Constructor of CPersistence class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CPersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CPersistence
+ /// Destructor of CPersistence class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CPersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Register
+ /// Register file/folder tag for persistence.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder corresponding to this tag will be retrieved.
+ ///
+ /// \param [IN] bisuserpersistence
+ /// BOOL - TRUE if user persistence else FALSE
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus Register(std::string f_crequestorappname, std::string f_ctag, BOOL bisuserpersistence);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Release
+ /// Entry for the file/Folder is stored in map for persistence.
+ /// If f_bPersist is TRUE file/folder will be persisted immediately else will be persist on shutdown
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder will be persist against this tag.
+ ///
+ /// \param [IN] f_cmempath
+ /// string - File/Folder path that is to be persisted.
+ ///
+ /// \param [IN] enotificationpersistentservicereleasetype
+ /// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease = 0 :not on release
+ /// eFrameworkunifiedPersistOnShutdown :persist on shutdown
+ /// eFrameworkunifiedPersistInstantly :persist instantly
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus Release(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ std::string f_cusername) = 0;
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Load
+ /// Load file/folder from persistent memory to the specified location.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder corresponding to this tag will be retrieved.
+ ///
+ /// \param [IN] f_cretrievepath
+ /// string - Path to retrieve.
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus Load(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cretrievepath,
+ std::string f_cusername) = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Persist
+ /// Persist file/folder immediately
+ ///
+ /// \param [IN] f_objregistryentry
+ /// CRegistryEntry& - Registry entry job object to persist.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Persist(CRegistryEntry &f_objregistryentry); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// AckReceivedFromWorker
+ ///
+ ///
+ /// \param [in] pSource
+ /// PCSTR - Name of the source.
+ /// \param [in] f_ctag
+ /// PCSTR - file/folder tag.
+ /// \param [in] f_bcopystatus
+ /// BOOL - Status of file/folder copy by copy worker.
+ /// \param [in] f_eloadtype
+ /// ENPS_Loadtype - Type of load release or load.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus AckReceivedFromWorker(PCSTR f_csource, PCSTR f_ctag, BOOL f_bcopystatus,
+ ENPS_Loadtype f_eloadtype);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PersistAllReleaseRequests
+ /// Persist all files/folders which are not persisted yet.
+ ///
+ /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
+ /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
+ /// 0 - persist orignal data and
+ /// 1 - persist default data
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus PersistAllReleaseRequests(UI_32 f_uinotificationpersistentservicepersistcategoryflag);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// HaveAllReleaseRequestsPersisted
+ /// Checks if all release requests are processed or not
+ ///
+ /// \param [out] f_ctagnotreleased
+ /// std::string - list of tags not released by application
+ ///
+ /// \return BOOL
+ /// TRUE if all release requests are processed else false
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL HaveAllReleaseRequestsPersisted(std::string &f_ctagnotreleased); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// ResetPersistFlag
+ /// Resets persist flag.
+ ///
+ /// \param none
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID ResetPersistFlag();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// PersistAllUserRequests
+ /// Persist all files/folders which are not persisted yet.
+ ///
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus PersistAllUserRequests();
+
+ // virtual VOID ListAllInMap() = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetReadThreadHandle
+ /// Set read thread handle.
+ ///
+ /// \param [in] f_hreadthread
+ /// HANDLE - Handle of the read thread.
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetReadThreadHandle(HANDLE f_hreadthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetWriteThreadHandle
+ /// Set write thread handle.
+ ///
+ /// \param [in] f_hwritethread
+ /// HANDLE - Handle of the write thread.
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetWriteThreadHandle(HANDLE f_hwritethread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetStoragePath
+ /// Get the permanent storage path. Get it from NS_NPPService's config file.
+ ///
+ /// \return std::string
+ /// std::string - Permanant storage path
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static std::string GetStoragePath();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetPersistentCategory
+ /// Sets the persist type of file/folder
+ ///
+ /// \param [IN] f_crequestorname
+ /// string - Application Name
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder will be persist against this tag.
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persistent category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetPersistentCategory(const std::string &f_crequestorname,
+ const std::string &f_ctag,
+ EFrameworkunifiedPersistCategory f_epersistcategory);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsUserPersistence
+ /// Check if the file/folder being persisted is user specific
+ ///
+ /// \param [in] - f_ctag
+ /// std::string - File/Folder Tag
+ ///
+ /// \return status
+ /// BOOL - TRUE for user specific persistence
+ /// FALSE for global persistence
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ virtual BOOL IsUserPersistence(std::string f_ctag);
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistenceProfilingData
+ /// This function is used to get the persistence info
+ ///
+ /// \param [out] f_cpersistenceprofileinfo
+ /// std::string - Persistence info concated in a string
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetPersistenceProfilingData(std::string &f_cpersistenceprofileinfo); // NOLINT (runtime/references)
+
+#endif
+
+ protected:
+ EFrameworkunifiedStatus ProcessReleaseRequest(std::string f_crequesterappname,
+ std::string f_ctag,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ std::string f_cusername);
+
+ EFrameworkunifiedStatus ProcessLoadRequest(std::string f_crequesterappname,
+ std::string f_ctag,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cretrievepath,
+ std::string f_cusername);
+
+ VOID AddRequestData(NSP_CopyInfoCmd &f_tcpinfo, // NOLINT (runtime/references)
+ std::string f_sourcepath,
+ std::string f_destpath,
+ std::string f_crequesterappname,
+ std::string f_ctag,
+ ENPS_Loadtype f_eloadtype,
+ ENotificationpersistentservicePersistType f_epersisttype);
+
+ EFrameworkunifiedStatus SendRequestMessage(NSP_CopyInfoCmd &f_tcpinfo); // NOLINT (runtime/references)
+
+ std::string m_cStoragePath; ///< Persistent memory storage path
+
+ NOTIFICATIONPERSISTENTSERVICE_COMPRESSION_TYPE m_eCompressionType; ///< Compression type for file/folder persistency
+
+ HANDLE m_hNSWriteToPersistentMem; ///< Child thread handle, copies file to persistent memory.
+
+ HANDLE m_hNSReadFromPersistentMem; ///< Child thread handle, copies file from persistent memory.
+
+ // TODO(my_username): Remove this member var. Once the API to get application handle is available, use that.
+ HANDLE m_hAppHandle;
+
+ TSourceRegistryList m_mPersistRegistry;
+
+ TPendingJobs m_lPendingJobs; ///< stores the list of pending jobs sequentially
+
+ BOOL m_bPersist; ///< persist or not. It will be set to TRUE either on shutdown or userchange
+
+ UI_32 m_uiNotificationpersistentservicePersistCategoryFlag; ///< Stores the persist category flag value on shutdown request.
+ ///< It is needed to decide which data to persist, if
+ ///< release request is received by NSNPP after shutdown request
+};
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENCE_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_persistence_manager.h b/nsframework/notification_persistent_service/server/include/ns_npp_persistence_manager.h
new file mode 100644
index 00000000..99f98d7e
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_persistence_manager.h
@@ -0,0 +1,536 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CPersistenceManager class.
+/// This class acts as a manager for notification persistent data storage
+/// and file and folder persistence.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENCE_MANAGER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENCE_MANAGER_H_
+
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_np_service.h>
+#include <map>
+#include <string>
+#include <vector>
+#include "ns_npp_types.h"
+#include "ns_npp_persistent_accesser.h"
+
+class CPersistence;
+class CPersistentData;
+class CNotificationsToPersist;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// vector of all available persistent notification and its data.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef std::vector<CNotificationsToPersist *> Persistent_Notification_List_Type;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Map of all persist file type. i.e. FilePersistence and FolderPersistence
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef std::map<ENotificationpersistentservicePersistType, CPersistence *> Persist_Type;
+
+typedef Persist_Type::iterator Persist_Type_Iter;
+
+/**
+ * This class acts as a manager for storing notification data,file and folder in
+ * persistent memory.
+ */
+class CPersistenceManager {
+ public:
+ /// Disable Persistence
+ static BOOL m_bPersistenceDisabled; // NOLINT (readability/naming)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CPersistenceManager
+ /// Constructor of CPersistenceManager class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CPersistenceManager();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CPersistenceManager
+ /// Destructor of CPersistenceManager class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CPersistenceManager();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceRegister
+ /// Registers a tag for the file or folder. This tag will be used for releasing or loading a
+ /// file or folder.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder will be persist against this tag.
+ ///
+ /// \param [IN] f_epersisttype
+ /// ENotificationpersistentservicePersistType - ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE - Tag to register is for a file
+ /// ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER - Tag to register is for a folder
+ ///
+ /// \param [IN] bisuserpersistence
+
+ /// BOOL - TRUE if user persistence else FALSE
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceRegister(std::string f_cappname,
+ std::string f_ctag,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ BOOL bisuserpersistence);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceRelease
+ /// Entry for the file or folder is stored in map for persistence.
+ /// If f_bPersist is TRUE file or folder will be persist immediately else will be persist
+ /// on shutdown
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder will be persist against this tag.
+ ///
+ /// \param [IN] f_cmempath
+ /// string - File/Folder which needs to persist.
+ ///
+ /// \param [IN] enotificationpersistentservicereleasetype
+ /// EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease = 0 :not on release
+ /// eFrameworkunifiedPersistOnShutdown :persist on shutdown
+ /// eFrameworkunifiedPersistInstantly :persist instantly
+ ///
+ /// \param [IN] f_epersisttype
+ /// ENotificationpersistentservicePersistType - ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE - Persist a file to a persistent memory
+ /// ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER - Persist a folder to a persistent memory
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceRelease(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cusername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceLoad
+ /// Load file/folder from persistent memory to the specified location.
+ ///
+ /// \param [IN] f_cappname
+ /// string - Name of the application requesting for persistence
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder corresponding to this tag will be retrieved.
+ ///
+ /// \param [IN] f_cretrievepath
+ /// string - Filepath for retrieved file/folder.
+ ///
+ /// \param [IN] f_epersisttype
+ /// ENotificationpersistentservicePersistType - ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE - Load a file from persistent memory
+ /// ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER - Load a folder from persistent memory
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - If tag is registered as user, then f_cusername holds the name of user,
+ /// else an empty string
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceLoad(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cretrievepath,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cusername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AckReceivedFromWorker
+ /// Send release ack to file/folder persistence object.
+ ///
+ /// \param [IN] f_csource
+ /// PCSTR - Source of released file/folder
+ ///
+ /// \param [IN] f_ctag
+ /// PCSTR - Tag of released file/folder
+ ///
+ /// \param [IN] f_epersisttype
+ /// ENotificationpersistentservicePersistType - ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE - Ack for file persistence object
+ /// ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER - Ack for folder persistence object
+ ///
+ /// \param [in] f_bcopystatus
+ /// BOOL - Status of file/folder copy by worker.
+ ///
+ /// \param [in] f_eloadtype
+ /// ENPS_Loadtype - Type of load release or load.
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AckReceivedFromWorker(PCSTR f_csource, PCSTR f_ctag, ENotificationpersistentservicePersistType f_epersisttype,
+ BOOL f_bcopystatus, ENPS_Loadtype f_eloadtype);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSaveNotificationData
+ /// Save notification data in a persistent file.
+ ///
+ /// \param [IN] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - List of all notifications and corresponding data.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSaveNotificationData(Persistent_Notification_List_Type *f_vpersistentnotificationlist);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSaveUserNotificationData
+ /// Save notification data of user in a persistent file.
+ ///
+ /// \param [IN] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - List of all notifications and corresponding data.
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSaveUserNotificationData(Persistent_Notification_List_Type *f_vpersistentnotificationlist);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceReadNotificationData
+ /// Get the list of all persistent notifications from a persistent memory and store it in a map.
+ ///
+ /// \param [OUT] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - Retrieved list of all notifications and corresponding data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceReadNotificationData(Persistent_Notification_List_Type *&f_vnotificationlist); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceReadUserNotificationData
+ /// Get the list of all user persistent notifications from a persistent memory and store it in a map.
+ ///
+ /// \param [OUT] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - Retrieved list of all notifications and corresponding data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceReadUserNotificationData(Persistent_Notification_List_Type *&f_vnotificationlist); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceReadNorNotificationData
+ /// Get the list of all Nor persistent notifications from a persistent memory and store it in a map.
+ ///
+ /// \param [OUT] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - Retrieved list of all notifications and corresponding data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceReadNorNotificationData(Persistent_Notification_List_Type *&f_vnotificationlist); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// PersistAllReleaseRequests
+ /// Persist all files and folder contained in the map in persistent memory.
+ ///
+ /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
+ /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
+ /// 0 - persist orignal data and
+ /// 1 - persist default data
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PersistAllReleaseRequests(UI_32 f_uinotificationpersistentservicepersistcategoryflag);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentservicePersistAllUserRequests
+ /// Persist all user files and folder contained in the map in persistent memory.
+ ///
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentservicePersistAllUserRequests();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetReadThreadHandle
+ /// Pass the handle of the read thread to the object of file/folder persistence
+ ///
+ /// \param [IN] f_hreadthread
+ /// HANDLE - Handle of read thread.
+ ///
+ /// \return
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetReadThreadHandle(HANDLE f_hreadthread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetWriteThreadHandle
+ /// Pass the handle of the write thread to the object of file/folder persistence
+ ///
+ /// \param [IN] f_hwritethread
+ /// HANDLE - Handle of write thread.
+ ///
+ /// \return
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetWriteThreadHandle(HANDLE f_hwritethread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetNorPersistenceThreadHandle
+ /// Pass the handle of the Nor persistence write thread to the object of file/folder persistence
+ ///
+ /// \param [IN] f_hwritethread
+ /// HANDLE - Handle of write thread.
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetNorPersistenceThreadHandle(HANDLE f_hwritethread);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetUserPersistentPath
+ /// Set user persistent path.
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - Name of user
+ ///
+ /// \return
+ ///
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetUserPersistentPath(std::string f_cusername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsUserPersistence
+ /// Check if the persistence is user specific
+ ///
+ /// \param [in] - f_ctag
+ /// std::string - File/folder Tag
+ ///
+ /// \param [in] - f_epersisttype
+ /// ENotificationpersistentservicePersistType - persistent type
+ ///
+ /// \return status
+ /// BOOL - TRUE for user specific persistence
+ /// FALSE for global persistence
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsUserPersistence(std::string f_ctag, ENotificationpersistentservicePersistType f_epersisttype);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// HaveAllReleaseRequestsPersisted
+ /// Checks if all files and immediate persistent data are persisted.
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ /// TRUE if all release requests are processed else false
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL HaveAllReleaseRequestsPersisted();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// ResetPersistFlag
+ /// Resets persist flag.
+ ///
+ /// \param none
+ ///
+ /// \return none
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ VOID ResetPersistFlag();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ClearPersistenceData
+ /// Deletes the data from the persistent memory
+ ///
+ /// \param [in] f_enotificationpersistentserviceclearpersistencescope
+ /// EFrameworkunifiedClearPersistence - data to be deleted from memory
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ClearPersistenceData(const EFrameworkunifiedClearPersistence &f_enotificationpersistentserviceclearpersistencescope);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSetPersistentCategory
+ /// Sets the persist type of file or folder
+ ///
+ /// \param [IN] f_crequestorname
+ /// string - Application name
+ ///
+ /// \param [IN] f_ctag
+ /// string - File/Folder will be persist against this tag.
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persistent category
+ ///
+ /// \param [IN] f_bPersist
+ /// ENotificationpersistentservicePersistType - file or folder
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentCategory(std::string f_crequestorname,
+ std::string f_ctag,
+ EFrameworkunifiedPersistCategory f_epersistcategory,
+ ENotificationpersistentservicePersistType f_epersisttype);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// PersistNORData
+ /// Sends the message to Immediate Persistence Thread to Persists the data immediately or reset
+ /// the NOR data depending on persist category flag during shutdown irrespective of delay.
+ ///
+ /// \param f_eshutdowntype
+ /// EFrameworkunifiedShutdownType - shutdown type - normal, quick, data reset
+ ///
+ /// \param f_uinotificationpersistentservicepersistcategoryflag
+ /// UI_32 - flag representing whether to persist or reset data.
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PersistNORData(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetImmediateDataPersistedStatus
+ /// Set/Reset the persistence status of immediate persistence data
+ ///
+ /// \param [in] - f_bstatus
+ /// BOOL
+ /// TRUE - immediate persistent data are persisted
+ /// FALSE - immediate persistent data not persisted
+ ///
+ /// \return
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetImmediateDataPersistedStatus(BOOL f_bstatus);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetFilePersistedStatus
+ /// Set/Reset the persistence status of files and folders
+ ///
+ /// \param [in] - f_bstatus
+ /// BOOL
+ /// TRUE - all files are persisted
+ /// FALSE - all files and folders are not persisted
+ ///
+ /// \return
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetFilePersistedStatus(BOOL f_bstatus);
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistenceProfilingData
+ /// This function is used to get the persistence info
+ ///
+ /// \param [out] f_cpersistenceprofileinfo
+ /// std::string - Persistence info concated in a string
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus GetPersistenceProfilingData(std::string &f_cpersistenceprofileinfo); // NOLINT (runtime/references)
+
+#endif
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ReadImmediateNotificationData
+ /// Get the list of all immediate persistent notifications of f_epersistcategory
+ /// from a persistent memory in a vector.
+ ///
+ /// \param [OUT] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - Retrieved list of all notifications and corresponding data
+ ///
+ /// \param [IN] f_epersistcategory
+ /// const EFrameworkunifiedPersistCategory - persistent category
+ ///
+ /// \return EFrameworkunifiedStatus
+ /// EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ReadImmediateNotificationData(Persistent_Notification_List_Type *&f_vpersistentnotificationlist, // NOLINT (runtime/references)
+ const EFrameworkunifiedPersistCategory f_epersistcategory);
+
+ std::string m_cUserNotificationTag; ///< Tag associated with a file which is used
+ ///< for storing user related notification persistent data.
+
+ std::string m_cNotificationPersistFilepath; ///< Persistent file path for storing persistent data
+
+ std::string m_cNotificationUserMemFilepath; ///< Memory location of a file for storing persistent data of a user
+
+ Persist_Type m_mPersist_Type; ///< Map holds the objects of file and folder persistency.
+
+ CPersistentAccesser *m_poDataAccesser; ///< Object for persistent data accesser
+
+ HANDLE m_hNSImmediatePersistenceThread; ///< Nor persistence thread handle
+
+ BOOL m_bAllFilePersisted; // all files have been persisted
+
+ BOOL m_bImmediatedDataPersisted; // all immediate peristence data have been persisted
+
+ EFrameworkunifiedStatus Init();
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPServiceOnCpWorkerAckCmd
+/// Handles when the CopyWorker sends an ack back for a message received .
+///
+/// \param [in] f_happ
+/// HANDLE - Handle to notificationpersistentservice_application Framework.
+///
+/// \return status
+/// EFrameworkunifiedStatus - success or error
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPServiceOnCpWorkerAckCmd(HANDLE f_happ);
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENCE_MANAGER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_persistent_accesser.h b/nsframework/notification_persistent_service/server/include/ns_npp_persistent_accesser.h
new file mode 100644
index 00000000..bfb15386
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_persistent_accesser.h
@@ -0,0 +1,119 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CPersistentAccesser class.
+/// This is a abstract class. Derived classes of this class will store the data in different
+/// file formats.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENT_ACCESSER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENT_ACCESSER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include <vector>
+
+class CPersistentData;
+class CNotificationsToPersist;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// vector of all available persistent notification and its data.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef std::vector<CNotificationsToPersist *> Persistent_Notification_List_Type;
+
+/**
+ * This is a abstract class. Derived classes of this class will store the data in different
+ * file formats.
+ */
+class CPersistentAccesser {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CPersistentAccesser
+ /// Constructor of CPersistentAccesser class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CPersistentAccesser() {}
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CPersistentAccesser
+ /// Destructor of CPersistentAccesser class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CPersistentAccesser() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// PersistData
+ /// Persist data in persistent memory depending on file format.
+ ///
+ /// \param [IN] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type - Data which has to be persisted.
+ ///
+ /// \param [IN] f_cmemfilepath
+ /// std::string - Read data from this file.
+ ///
+ /// \param [IN] f_epersistenttype
+ /// EFrameworkunifiedNotificationType - Type of persistent notification
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus PersistData(std::string f_cmemfilepath,
+ Persistent_Notification_List_Type *f_vpersistentnotificationlist,
+ EFrameworkunifiedNotificationType f_epersistenttype,
+ EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData) = 0;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// RetrieveData
+ /// Retrieve data in persistent memory depending on file format.
+ ///
+ /// \param [IN] f_cmemfilepath
+ /// std::string - Write data from this file.
+ ///
+ /// \param [IN] f_vpersistentnotificationlist
+ /// Persistent_Notification_List_Type* - Retrieved data.
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus RetrieveData(std::string f_cmemfilepath,
+ Persistent_Notification_List_Type *&f_vpersistentnotificationlist, // NOLINT (runtime/references)
+ EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData) = 0;
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENT_ACCESSER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_persistent_data.h b/nsframework/notification_persistent_service/server/include/ns_npp_persistent_data.h
new file mode 100644
index 00000000..84e2b433
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_persistent_data.h
@@ -0,0 +1,165 @@
+ /*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file conains declaration of CPersistentData, CNotificationsToPersist and CPersistDataHeader class.
+/// This class is used to hold the persistent data related to state and persistent
+/// notification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENT_DATA_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENT_DATA_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+#ifdef AGL_STUB
+#include <cstring>
+#endif
+/**
+ * This class holds the message and message length of notification data.
+ */
+class CPersistentData {
+ private:
+ // no members in private
+
+ public:
+ PVOID m_pMessage; ///< pointer to message structure
+
+ UI_32 m_uiMsgSize; ///< length of message
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CPersistentData
+ /// Constructor of CPersistentData class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CPersistentData();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CPersistentData
+ /// Destructor of CPersistentData class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CPersistentData();
+};
+
+class CNotificationsToPersist {
+ private:
+ // no members in private
+
+ public:
+ std::string m_cNotificationName; ///< Name of Notification
+
+ UI_32 m_uiMaxMsgLength; ///< Maximum data length of notification
+
+ EFrameworkunifiedNotificationType m_ePersistentType; ///< type of notification
+
+ EFrameworkunifiedPersistCategory m_ePersistCategory; ///< Persistent category
+
+ std::string m_cPublisherName; ///< Service Name
+
+ CPersistentData *m_pPersistentData; ///< Persistent data related to notification
+
+ UI_32 m_uiDelay; ///< Maximum delay for persistence
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNotificationsToPersist
+ /// Constructor of CNotificationsToPersist class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotificationsToPersist(): m_cNotificationName(""),
+ m_uiMaxMsgLength(0),
+ m_ePersistentType(eFrameworkunifiedUnknown),
+ m_ePersistCategory(eFrameworkunifiedUserData),
+ m_cPublisherName(""),
+ m_pPersistentData(NULL),
+ m_uiDelay(0) {
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNotificationsToPersist
+ /// Destructor of CNotificationsToPersist class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNotificationsToPersist() {
+ if (NULL != m_pPersistentData) { // LCOV_EXCL_BR_LINE 6: m_pPersistentData can't be NULL
+ delete m_pPersistentData;
+ m_pPersistentData = NULL;
+ }
+ }
+};
+
+class CPersistDataHeader {
+ private:
+ // no members in private
+
+ public:
+ UI_32 m_uiSize; ///< size of the associated data blob
+ UI_32 m_uiOffset; ///< Offset at which the data blob starts
+ EFrameworkunifiedNotificationType m_ePersistentType;
+ CHAR m_cPublisherName[MAX_QUEUE_NAME_SIZE];
+ CHAR m_cNotificationName[MAX_STRING_SIZE_NOTIFICATION];
+ UI_32 m_uiMaxMsgLength; ///< max size of the associated data
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CPersistDataHeader
+ /// Constructor of CPersistDataHeader class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CPersistDataHeader(): m_uiSize(0),
+ m_uiOffset(0),
+ m_ePersistentType(eFrameworkunifiedPersistedStateVar),
+ m_uiMaxMsgLength(0) {
+ std::memset(m_cPublisherName, 0, MAX_QUEUE_NAME_SIZE);
+ std::memset(m_cNotificationName, 0, MAX_STRING_SIZE_NOTIFICATION);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CPersistDataHeader
+ /// Destructor of CPersistDataHeader class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CPersistDataHeader() {
+ }
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSISTENT_DATA_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_personality.h b/nsframework/notification_persistent_service/server/include/ns_npp_personality.h
new file mode 100644
index 00000000..9ac052f2
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_personality.h
@@ -0,0 +1,75 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contain declaration of CNotificationpersistentservicePersonality class.
+/// The class object define personality.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSONALITY_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSONALITY_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+
+/**
+ * This class holds all the informations related to a personality.
+ */
+class CNotificationpersistentservicePersonality {
+ private:
+ // no members in private
+
+ public:
+ std::string m_cUserName; ///< user name
+
+ UI_32 m_uiUserId; ///< unique identifier of each user
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CNotificationpersistentservicePersonality
+ /// Constructor of CNotificationpersistentservicePersonality class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CNotificationpersistentservicePersonality(): m_cUserName(""), m_uiUserId(0) {} // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CNotificationpersistentservicePersonality
+ /// Destructor of CNotificationpersistentservicePersonality class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CNotificationpersistentservicePersonality() {}
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSONALITY_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_personalization_manager.h b/nsframework/notification_persistent_service/server/include/ns_npp_personalization_manager.h
new file mode 100644
index 00000000..b1042fbe
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_personalization_manager.h
@@ -0,0 +1,132 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of singleton class CnotificationpersistentservicePersonalizationManager which is
+/// used to manage information of personality.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSONALIZATION_MANAGER_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSONALIZATION_MANAGER_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <string>
+#include <map>
+#include "ns_npp_personality.h"
+
+typedef std::map<std::string, CNotificationpersistentservicePersonality *> Personality_Type;
+
+/**
+ * This class maintains information on creation of new personality or
+ * change of personality.
+ */
+class CnotificationpersistentservicePersonalizationManager {
+ private:
+ Personality_Type *m_pmPersonality; ///< list of personality
+
+ UI_32 m_uiUserId; ///< unique user id
+
+ std::string m_cCurrentPersonality; ///< current personality name
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CreatePersonality
+ /// This function is used to create new Personality.
+ ///
+ /// \param [IN] f_cpersonalityname
+ /// std::string - Personality name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus CreatePersonality(const std::string &f_cpersonalityname);
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CnotificationpersistentservicePersonalizationManager
+ /// Constructor of CnotificationpersistentservicePersonalizationManager class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CnotificationpersistentservicePersonalizationManager();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CnotificationpersistentservicePersonalizationManager
+ /// Destructor of CnotificationpersistentservicePersonalizationManager class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CnotificationpersistentservicePersonalizationManager();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceGetPersonality
+ /// This function is used to get the current personality.
+ ///
+ /// \param [OUT] f_cpersonalityname
+ /// std::string - Personality name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceGetPersonality(std::string &f_cpersonalityname); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceSetPersonality
+ /// This function is used to set the new personality.
+ ///
+ /// \param [IN] f_cpersonalityname
+ /// std::string - Personality name
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus NotificationpersistentserviceSetPersonality(const std::string f_cpersonalityname);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// NotificationpersistentserviceIsValidPersonality
+ /// Check if user is valid or not.
+ ///
+ /// \param [IN] f_cpersonalityname
+ /// std::string - Personality name
+ ///
+ /// \return BOOL
+ /// TRUE - Valid user
+ /// FALSE - Not a valid user
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL NotificationpersistentserviceIsValidPersonality(const std::string f_cpersonalityname);
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PERSONALIZATION_MANAGER_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_profiling_protocols_internal.h b/nsframework/notification_persistent_service/server/include/ns_npp_profiling_protocols_internal.h
new file mode 100644
index 00000000..13b96a23
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_profiling_protocols_internal.h
@@ -0,0 +1,34 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NativeServices
+/// \brief This file contains declaration of all the protocols and structures related to profiling.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PROFILING_PROTOCOLS_INTERNAL_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PROFILING_PROTOCOLS_INTERNAL_H_
+
+
+#define NPS_PROFILE_NOTIFICATION_REQ 0x1AA
+#define NPS_PROFILE_NOTIFICATION_RESP 0x1BB
+
+#define NPS_PROFILE_PERSISTENCE_REQ 0x2AA
+#define NPS_PROFILE_PERSISTENCE_RESP 0x2BB
+
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_PROFILING_PROTOCOLS_INTERNAL_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_registry_entry.h b/nsframework/notification_persistent_service/server/include/ns_npp_registry_entry.h
new file mode 100644
index 00000000..3cb475ee
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_registry_entry.h
@@ -0,0 +1,330 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CRegistryEntry class.
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGISTRY_ENTRY_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGISTRY_ENTRY_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "ns_npp_types.h"
+
+/**
+ * This class contains the registry information of the files/folders to be peresisted.
+ */
+class CRegistryEntry {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CRegistryEntry
+ /// Constructor of CRegistryEntry class
+ ///
+ /// \param [OUT] f_ctag
+ /// std::string& - File or Folder tag
+ ///
+ /// \param [OUT] f_crequester
+ /// std::string& - Requester Name
+ ///
+ /// \param [OUT] f_cstoragepath
+ /// std::string& - File or Folder persistence storage path
+ ///
+ /// \param [IN] f_bisuserpersistence
+ /// BOOL - File or Folder is user specific
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ explicit CRegistryEntry(const std::string &f_ctag, const std::string &f_crequester,
+ const std::string &f_cstoragepath, BOOL f_bisuserpersistence);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CRegistryEntry
+ /// Copy Constructor of CRegistryEntry class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CRegistryEntry(const CRegistryEntry &f_objin);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// operator=
+ /// Operator overload =
+ ///
+ /// \param [IN] f_objin
+ /// CRegistryEntry& - In object.
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CRegistryEntry &operator=(const CRegistryEntry &f_objin); // NOLINT (readability/naming)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetReleasePath
+ /// Set release path.
+ ///
+ /// \param [IN] f_creleasepath
+ /// std::string& - Path of the file/folder to be released.
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetReleasePath(const std::string &f_creleasepath);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetBeingPersisted
+ /// Set the file/folder persist member variable to true to notify that the file/folder is being
+ /// persisted.
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetBeingPersisted();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AckReceived
+ /// Ack from copy worker received. Process the ack.
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID AckReceived();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsReleased
+ /// Check if File/folder released or not.
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - True if file/folder is released else false
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsReleased() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// HasntBeenPersisted
+ /// File persisted or not
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - True if file is not persisted else false
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL HasntBeenPersisted() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsPersisted
+ /// File/Folder persisted or not
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - True if file/folder is persisted else false
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsPersisted() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsAckPending
+ /// Ack is pending or not.
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - True if ack is pending else false
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsAckPending() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistPath
+ /// Get the persist path.
+ ///
+ /// \param
+ ///
+ /// \return std::string
+ // std::string - Returns the persist path.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetPersistPath() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetReleasePath
+ /// Get the release path.
+ ///
+ /// \param
+ ///
+ /// \return std::string
+ // std::string - Returns the release path.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetReleasePath() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetLoadPath
+ /// Get the load path.
+ ///
+ /// \param [IN] f_epersisttype
+ /// ENotificationpersistentservicePersistType - type of persisted data
+ ///
+ /// \param [IN] f_cusername
+ /// std::string - Current user name
+ ///
+ ///
+ /// \return std::string
+ // std::string - Returns the load path.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetLoadPath(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername) const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetRequester
+ /// Get the name of requester.
+ ///
+ /// \param
+ ///
+ /// \return std::string
+ // std::string - Returns the name of requester.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetRequester() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetTag
+ /// Get the tag.
+ ///
+ /// \param
+ ///
+ /// \return std::string
+ // std::string - Returns the tag.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ std::string GetTag() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsUserPersistence
+ /// Returns TRUE if it is a user persistence.
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - Returns TRUE if it is a user persistence.
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsUserPersistence();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetCurrentAction
+ /// Set current copying action of a the corresponding tag.
+ ///
+ /// \param [IN] f_ecurrentaction
+ /// ENPS_Loadtype - Current action
+ ///
+ /// \return
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetCurrentAction(ENPS_Loadtype f_ecurrentaction);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ResetPersistedFlag
+ /// Reset Persist flags
+ ///
+ /// \param
+ ///
+ /// \return
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID ResetPersistedFlag();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetPersistProperties
+ /// creates persistence path and stores the persist type
+ ///
+ /// \param [IN] f_epersisttype
+ /// ENotificationpersistentservicePersistType - Set persist type
+ /// \param [IN] f_cusername
+ /// std::string - Username related to persist tag if any.
+ ///
+ ///
+ /// \return
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ VOID SetPersistProperties(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername = "");
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistType
+ /// Returns persist type of a job
+ ///
+ /// \param
+ ///
+ /// \return ENotificationpersistentservicePersistType
+ // ENotificationpersistentservicePersistType - Returns persist type
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ENotificationpersistentservicePersistType GetPersistType() const;
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetPersistentCategory
+ /// Sets the persistent type related to tag
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetPersistentCategory(EFrameworkunifiedPersistCategory f_epersistcategory);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistentCategory
+ /// Returns persistent type of tag
+ ///
+ /// \param
+ ///
+ /// \return EFrameworkunifiedPersistCategory
+ // EFrameworkunifiedPersistCategory - Returns persistent type
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedPersistCategory GetPersistentCategory();
+
+ ENPSPersistenceJobState m_eJobState; // Current state of a job
+
+ private:
+ std::string m_cTag; // File/Folder tag
+ std::string m_cRequestor; // Requester application name
+ BOOL m_bIsReleased; // if file or folder released
+ BOOL m_bIsPersisted; // if file or folder is persisted
+ std::string m_cPersistPath; // Persist path
+ std::string m_cReleasePath; // Release path
+ std::string m_cBasePath; // Persist base path
+ BOOL m_bIsUserPersistence; // If user persistence
+ ENPS_Loadtype m_eCurrentAction; // Current action to load file to/from
+ /// temporary/persistence memory
+ ENotificationpersistentservicePersistType m_ePersistType;
+ EFrameworkunifiedPersistCategory m_ePersistCategory; // Persistent category
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGISTRY_ENTRY_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_regular_notification.h b/nsframework/notification_persistent_service/server/include/ns_npp_regular_notification.h
new file mode 100644
index 00000000..da5427de
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_regular_notification.h
@@ -0,0 +1,109 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CRegularNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGULAR_NOTIFICATION_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGULAR_NOTIFICATION_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include "ns_npp_notification.h"
+
+/**
+ * This class inherits CNotification class and implements regular notification related operations.
+ */
+class CRegularNotification : public CNotification {
+ private:
+ // no members in private
+
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CRegularNotification
+ /// Constructor of CRegularNotification class
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification name
+ ///
+ /// \param [IN] f_uimaxmsgsize
+ /// UI_32 - Maximum size of notification data
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CRegularNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CRegularNotification
+ /// Destructor of CRegularNotification class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CRegularNotification();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddEventReciever
+ /// This function adds the name of the application to receiver list of particular notification.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AddEventReciever(const std::string &f_csubscribername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Publish
+ /// This function publishes the notification to subscribed clients.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service publishing the notification
+ ///
+ /// \param [IN] f_pmessage
+ /// std::string - data of notification
+ ///
+ /// \param [IN] f_uimsgsize
+ /// std::string - length of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+};
+
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_REGULAR_NOTIFICATION_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_state_nor_persistence_notification.h b/nsframework/notification_persistent_service/server/include/ns_npp_state_nor_persistence_notification.h
new file mode 100644
index 00000000..26edf734
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_state_nor_persistence_notification.h
@@ -0,0 +1,177 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CStateNorPersistenceNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOR_PERSISTENCE_NOTIFICATION_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOR_PERSISTENCE_NOTIFICATION_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include "ns_npp_state_notification.h"
+
+/**
+ * This class inherits CStateNotification class and implements specific operations related to
+ * nor persistent notifications.
+ */
+class CStateNorPersistenceNotification : public CStateNotification {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CStateNorPersistenceNotification
+ /// Constructor of CStateNorPersistenceNotification class
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification name
+ ///
+ /// \param [IN] f_uimaxmsgsize
+ /// UI_32 - Maximum size of notification data
+ ///
+ /// \param [IN] f_uidelay
+ /// UI_32 - delay
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CStateNorPersistenceNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize,
+ const UI_32 f_uidelay,
+ const EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CStateNorPersistenceNotification
+ /// Destructor of CStateNorPersistenceNotification class
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CStateNorPersistenceNotification();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistenceDelay
+ /// Method to get the persistence delay for a specific notification.
+ ///
+ /// \param
+ ///
+ /// \return UI_32
+ // UI_32 - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ UI_32 GetPersistenceDelay();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Publish
+ /// This function publishes the notification to subscribed clients and saves the data
+ /// immediately to persistent memory.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service publishing the notification
+ ///
+ /// \param [IN] f_pmessage
+ /// std::string - data of notification
+ ///
+ /// \param [IN] f_uimsgsize
+ /// std::string - length of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// PublishNotification
+ /// This function publishes the notification to subscribed clients.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service publishing the notification
+ ///
+ /// \param [IN] f_pmessage
+ /// std::string - data of notification
+ ///
+ /// \param [IN] f_uimsgsize
+ /// std::string - length of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus PublishNotification(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistentCategory
+ /// Gets the persist type of notification
+ ///
+ ///
+ /// \return EFrameworkunifiedPersistCategory
+ // EFrameworkunifiedPersistCategory - persist type
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedPersistCategory GetPersistentCategory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetPersistentCategory
+ /// Sets the persist type of notification
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetPersistentCategory(const EFrameworkunifiedPersistCategory f_epersistcategory);
+ // Handle of the immediate persistence worker thread.
+ static HANDLE m_hNSImmediatePersistenceThread; // NOLINT (readability/naming)
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SaveDataToNor
+ /// Saves the persistent data to nor
+ ///
+ /// \param [IN] f_pmessage
+ /// PVOID - Message data
+ ///
+ /// \param [IN] f_msgsize
+ /// UI_32 - Size of Message data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SaveDataToNor(PVOID f_pmessage,
+ const UI_32 f_msgsize);
+
+ UI_32 m_uiDelay; // Time Delay between persistence on NOR
+
+ EFrameworkunifiedPersistCategory m_ePersistCategory; // Persistent category
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOR_PERSISTENCE_NOTIFICATION_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_state_notification.h b/nsframework/notification_persistent_service/server/include/ns_npp_state_notification.h
new file mode 100644
index 00000000..aaa69927
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_state_notification.h
@@ -0,0 +1,221 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CStateNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOTIFICATION_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOTIFICATION_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include "ns_npp_notification.h"
+
+class CPersistentData;
+
+/**
+ * This class inherits CNotification class and implements state and persistent notification
+ * related operations.
+ */
+class CStateNotification : public CNotification {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CStateNotification
+ /// Constructor of CStateNotification class
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification name
+ ///
+ /// \param [IN] f_uimaxmsgsize
+ /// UI_32 - Maximum size of notification data
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CStateNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CStateNotification
+ /// Destructor of CStateNotification class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual ~CStateNotification();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// AddEventReciever
+ /// This function adds the name of the application to receiver list of particular notification.
+ ///
+ /// \param [IN] f_csubscribername
+ /// std::string - name of application subscribing for notification
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus AddEventReciever(const std::string &f_csubscribername);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// Publish
+ /// This function publishes the notification to subscribed clients.
+ ///
+ /// \param [IN] f_cservicename
+ /// std::string - name of service publishing the notification
+ ///
+ /// \param [IN] f_pmessage
+ /// std::string - data of notification
+ ///
+ /// \param [IN] f_uimsgsize
+ /// std::string - length of data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistentData
+ /// This function get the data related to notification
+ ///
+ /// \param
+ ///
+ /// \return CPersistentData
+ // CPersistentData - notification data
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ const CPersistentData *GetPersistentData();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetPersistentData
+ /// This function is used to set the data related to notification
+ ///
+ /// \param [IN] f_pmessage
+ /// PVOID - Message data
+ ///
+ /// \param [IN] f_msgsize
+ /// UI_32 - Size of Message data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus SetPersistentData(PVOID f_pmessage,
+ const UI_32 f_msgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetDefaultPersistentData
+ /// This function get the default data(if any) related to notification
+ ///
+ /// \param
+ ///
+ /// \return CPersistentData
+ // CPersistentData - notification data
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ const CPersistentData *GetDefaultPersistentData();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetDefaultPersistentData
+ /// This function is used to set the default data related to notification
+ ///
+ /// \param [IN] f_pmessage
+ /// PVOID - Message data
+ ///
+ /// \param [IN] f_msgsize
+ /// UI_32 - Size of Message data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ virtual EFrameworkunifiedStatus SetDefaultPersistentData(PVOID f_pmessage,
+ const UI_32 f_msgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// IsPublished
+ /// This functions returns the published status of notification.
+ ///
+ /// \param
+ ///
+ /// \return BOOL
+ // BOOL - returns true if published before
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ BOOL IsPublished();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ResetMaxMessageSize
+ /// This function reset the max size of data that can be published with notification.
+ /// Also deletes the old persistent data and default data.
+ ///
+ /// \param [IN] f_uilength
+ /// std::string - Max size for notification data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus ResetMaxMessageSize(const UI_32 f_uilength);
+
+ protected:
+ CPersistentData *m_pData; ///< persistent data of notification
+
+ CPersistentData *m_pDefaultData; ///< persistent data of notification
+
+ BOOL m_bWasPublished; ///< Flag to check whether publisher had published notification
+
+ private:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetData
+ /// This function is used to set the persistent data
+ ///
+ /// \param [IN] f_pdata
+ /// CPersistentData - persistent data ptr
+ ///
+ /// \param [IN] f_pmessage
+ /// PVOID - Message data
+ ///
+ /// \param [IN] f_msgsize
+ /// UI_32 - Size of Message data
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetData(CPersistentData *f_pdata,
+ PVOID f_pmessage,
+ const UI_32 f_msgsize);
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_NOTIFICATION_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_notification.h b/nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_notification.h
new file mode 100644
index 00000000..1123941c
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_notification.h
@@ -0,0 +1,104 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CStatePersistenceNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_PERSISTENCE_NOTIFICATION_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_PERSISTENCE_NOTIFICATION_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <string>
+#include "ns_npp_state_notification.h"
+
+/**
+ * This class inherits CStateNotification class and implements specific operations related to
+ * persistent notifications.
+ */
+class CStatePersistenceNotification : public CStateNotification {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CStatePersistenceNotification
+ /// Constructor of CStatePersistenceNotification class
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification name
+ ///
+ /// \param [IN] f_uimaxmsgsize
+ /// UI_32 - Maximum size of notification data
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CStatePersistenceNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize,
+ const EFrameworkunifiedPersistCategory f_epersistcategory = eFrameworkunifiedUserData);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CStatePersistenceNotification
+ /// Destructor of CStatePersistenceNotification class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CStatePersistenceNotification();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// GetPersistentCategory
+ /// Gets the persist type of notification
+ ///
+ ///
+ /// \return EFrameworkunifiedPersistCategory
+ // EFrameworkunifiedPersistCategory - persist type
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedPersistCategory GetPersistentCategory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// SetPersistentCategory
+ /// Sets the persist type of notification
+ ///
+ /// \param [IN] f_epersistcategory
+ /// EFrameworkunifiedPersistCategory - persist category
+ ///
+ /// \return EFrameworkunifiedStatus
+ // EFrameworkunifiedStatus - success or failure status
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ EFrameworkunifiedStatus SetPersistentCategory(const EFrameworkunifiedPersistCategory f_epersistcategory);
+
+ private:
+ EFrameworkunifiedPersistCategory m_ePersistCategory; // Persistent category
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_PERSISTENCE_NOTIFICATION_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_user_notification.h b/nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_user_notification.h
new file mode 100644
index 00000000..8423e3e9
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_state_persistence_user_notification.h
@@ -0,0 +1,73 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains declaration of class CStatePersistenceUserNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_PERSISTENCE_USER_NOTIFICATION_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_PERSISTENCE_USER_NOTIFICATION_H_
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include "ns_npp_state_notification.h"
+
+
+/**
+ * This class inherits CStateNotification class and implements specific operations related to
+ * persistent notifications specific to user.
+ */
+class CStatePersistenceUserNotification : public CStateNotification {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CStatePersistenceUserNotification
+ /// Constructor of CStatePersistenceUserNotification class
+ ///
+ /// \param [IN] f_cnotificationname
+ /// std::string - Notification name
+ ///
+ /// \param [IN] f_uimaxmsgsize
+ /// UI_32 - Maximum size of notification data
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CStatePersistenceUserNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize);
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CStatePersistenceUserNotification
+ /// Destructor of CStatePersistenceUserNotification class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CStatePersistenceUserNotification();
+};
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_STATE_PERSISTENCE_USER_NOTIFICATION_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_threads.h b/nsframework/notification_persistent_service/server/include/ns_npp_threads.h
new file mode 100644
index 00000000..042e8579
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_threads.h
@@ -0,0 +1,46 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_THREADS_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_THREADS_H_
+
+// name of threads
+#define NS_NPP_READ_THREAD_NAME "NS_NPPReadWkr"
+#define NS_NPP_WRITE_THREAD_NAME "NS_NPPWriteWkr"
+#define NS_NPP_IMMEDIATE_PERSIST_THREAD_NAME "NS_NPPIPWkr"
+#define NS_NPP_DATA_RESET_THREAD_NAME "NS_NPPDataRst"
+
+// priority of threads
+#define NS_NPP_READ_THREAD_PRIO 15
+#define NS_NPP_WRITE_THREAD_PRIO 15
+#define NS_NPP_IMMEDIATE_PERSIST_THREAD_PRIO 25
+#define NS_NPP_DATA_RESET_THREAD_PRIO 10
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_THREADS_H_
diff --git a/nsframework/notification_persistent_service/server/include/ns_npp_types.h b/nsframework/notification_persistent_service/server/include/ns_npp_types.h
new file mode 100644
index 00000000..79a44d74
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/include/ns_npp_types.h
@@ -0,0 +1,212 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_TYPES_H_
+#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_TYPES_H_
+
+#include <native_service/frameworkunified_sm_eventdata.h>
+#include <aglpath.h>
+#include <native_service/ns_np_types.h>
+
+// name of notification file to be saved in persistent memory depending on the persistent type category
+
+#define NOTIFICATIONFILE "PERSISTENT_NOTIFICATION" // stores user notification common to all user
+#define USERNOTIFICATIONFILE "USER_PERSISTENT_NOTIFICATION" // stores user notification specific to particular user
+#define FACTORYNOTIFICATIONFILE "FACTORY_NOTIFICATION" // stores factory notification
+#define FACTORYCUSTOMERNOTIFICATIONFILE "FACTORYCUSTOMER_NOTIFICATION" // stores factorycustomer notification
+#define DEALERNOTIFICATIONFILE "DEALER_NOTIFICATION" // stores dealer notification
+
+// name of persistence folder for persistent type categorization
+#define USERDATA "UserData" // name of folder contatining userdata
+#define FACTORYDATA "FactoryData" // name of folder contatining factory data
+#define FACTORYCUSTOMERDATA "FactoryCustomerData" // name of folder contatining factory customer data
+#define DEALERDATA "DealerData" // name of folder contatining dealer data
+
+// default user name for personalization
+#define DEFAULTUSERNAME "DefaultUser"
+
+// name of NSNPS version file
+#define VERSION_TXT "version.txt"
+
+#define STORAGE_PATH "/nv/BS/ns/npp/rwdata/"
+
+
+typedef enum ENPSLoadType {
+ LOADTYPE_NONE = -1,
+ LOADTYPE_RELEASE = 0, // load file to persistent memory
+ LOADTYPE_LOAD = 1, // load file to temporary memory
+ LOADTYPE_RELOAD = 2, // reload the file.
+} ENPS_Loadtype;
+
+/// \typedef ENotificationpersistentservicePersistType
+/// \brief Persist file types
+typedef enum ENotificationpersistentservicePersistType {
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST = 0, ///< Add values after this value only.
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE, ///< Persist a file to a persistent memory
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER, ///< Persist a folder to a persistent memory
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTNONE, ///< no type
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST, ///< Add values before this value only.
+} ENotificationpersistentservicePersistType;
+
+typedef enum ENPSPersistenceJobState {
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE = 0, ///< Job is idle. // NOLINT (readability/naming)
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEINPROCESS = 1, ///< Job is in process. Either release or load. // NOLINT (readability/naming)
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATERELEASEABORTED = 2, ///< Job release was aborted due to abort shutdown. // NOLINT (readability/naming)
+} ENPSPersistenceJobState;
+
+typedef CHAR CopyInfoStr[MAX_PATH_LENGTH]; ///< Information passed via the framework
+
+
+typedef enum ENPSCopyWorkerProtocol {
+ // > Command(s)
+ CP_WRK_CMD_START = 1500,
+ CP_WRK_CMD_STOP = 1501,
+ CP_WRK_CMD_COPY = 1502,
+ CP_WRK_CMD_RESUME = 1503, // This will release the thread from the abort command.
+
+ // < Command Ack(s)
+ CP_WRK_ACK_CMD_COMPLETE = 1504,
+
+ // < Notification(s)
+ CP_WRK_NTFY = 1505,
+
+ // < Shutdown request command
+ CMD_WRK_SHUTDOWN_REQ = 1506,
+ CMD_WRK_SHUTDOWN_ACK = 1507,
+
+ CMD_DELETE_OLD_DATA = 1508,
+
+ AR_CMD_START = 1400,
+ AR_CMD_STOP = 1401,
+ AR_CMD_ARCHIVE = 1402,
+ AR_CMD_RESUME = 1403, // This will release the thread from the abort command.
+
+ // < Command Ack(s)
+ AR_ACK_CMD_COMPLETE = 1404,
+
+ // < Notification(s)
+ AR_CMD_NTFY = 1405,
+
+ NOR_PERSISTENCE_TIMER_START = 1406,
+ NOR_PERSISTENCE_REGISTER = 1407,
+ NOR_PERSISTENCE_UNREGISTER = 1408,
+ // this cmd is used to tell the NOR thread to stop the timer
+ // for all the the notifications in case of userdata reset during shutdown
+ NOR_PERSISTENCE_ONSHUTDOWN = 1409,
+ // while to persist the data immediately irrespective of delay in case of shutdown without userdata reset.
+ // ack sent to NPPService main thread by Nor worker thread after persisting immediate data
+ NOR_PERSISTENCE_ONSHUTDOWN_ACK = 1410,
+ // message sent by main thread to immediate persistence thread
+ // to change the persistent category of immediate notification
+ NOR_PERSISTENCE_CHANGE_CATEGORY = 1411
+} ENSP_CopyWorkerProtocol, *PENSP_CopyWorkerProtocol, ENPS_ArchiveProtocol;
+
+
+typedef enum ENPSCopyWorkerFailures {
+ // > Failure codes(s)
+ CP_WRK_FAILURE_SRC_NOT_FND = 3500,
+ CP_WRK_FAILURE_DST_CREATE = 3501,
+ CP_WRK_FAILURE_ABORT_DURING_CP = 3502,
+ CP_WRK_FAILURE_ABORT_BEFORE_CP = 3503,
+ CP_WRK_FAILURE_WRITE_ERROR_CP = 3504,
+
+ AR_THREAD_FAILURE_SRC_NOT_FND = 3400,
+ AR_THREAD_FAILURE_DST_CREATE = 3401,
+ AR_THREAD_FAILURE_ABORT_DURING_ARCHIVE = 3402,
+ AR_THREAD_FAILURE_ABORT_BEFORE_ARCHIVE = 3403,
+} ENPS_CopyWorkerFailures, *PENPS_CopyWorkerFailures, ENPS_ArchiveFailures;
+
+typedef struct NPSCopyAckMsg {
+ ENSP_CopyWorkerProtocol m_eworkerprotocol; // Worker Load or Release Protocol Id
+} NSP_CopyAckMsg;
+
+typedef enum NotificationpersistentserviceCompressionType {
+ ENOTIFICATIONPERSISTENTSERVICENONE = 0, /// No Compression before file persistence
+ ENOTIFICATIONPERSISTENTSERVICEDEFAULTCOMPRESSION, /// Compress file before persistence using default compression method
+ ENOTIFICATIONPERSISTENTSERVICECOMPRESSUSINGLIBZ /// Compress file before persistence using libz
+} NOTIFICATIONPERSISTENTSERVICE_COMPRESSION_TYPE;
+
+typedef struct NPSCopyInfoMsg {
+ CopyInfoStr m_csourcepath; // Source path
+ CopyInfoStr m_cdestinationpath; // Destination path
+ CopyInfoStr m_cpersistenttag; // Tag for Persistence
+ CopyInfoStr m_crequesterappname; // Requester Name
+ ENPS_Loadtype m_eloadtype; // Load to Persistent or Temporary Memory
+ ENotificationpersistentservicePersistType m_epersisttype; // Folder or File Persistence
+ NOTIFICATIONPERSISTENTSERVICE_COMPRESSION_TYPE m_ecompressiontype; // Check for Compression of the file
+} NSP_CopyInfoCmd;
+
+typedef struct NPSCopyStatus {
+ BOOL m_bpersistencechk; // Persistence Success or Failure
+ ENPS_CopyWorkerFailures m_ecopyfailures; // Failure Protocol ID
+ CopyInfoStr m_cpersistenttag; // Tag for Persistence
+ CopyInfoStr m_crequesterappname; // Requester Name
+ ENPS_Loadtype m_eloadtype; // Load to Persistent or Temporary Memory
+ ENotificationpersistentservicePersistType m_epersisttype; // Folder or File Persistence
+ NOTIFICATIONPERSISTENTSERVICE_COMPRESSION_TYPE m_ecompressiontype; // Check for Compression of the file
+} NSP_CopyStatusResponse, NSP_CopyCancel;
+
+
+// Structure for Nor Persistent Notification
+typedef struct TNorPersistenceNotifInfoHeader {
+ CHAR m_cnotificationname[MAX_STRING_SIZE_NOTIFICATION]; ///< Name of Notification
+ UI_32 m_uimaxmsglength; ///< Maximum data length of notification
+ EFrameworkunifiedNotificationType m_epersistenttype; ///< type of notification
+ CHAR m_cpublishername[MAX_NAME_SIZE_APP]; ///< Service Name
+ UI_32 m_uimsgsize; ///< length of message
+ UI_32 m_uidelay; ///< Time delay between persistence
+ EFrameworkunifiedPersistCategory m_epersistcategory; ///< Persistent Category
+} TNorPersistenceNotifInfoHeader;
+
+typedef struct _TImmediatePersistenceRegisterNotifInfo { // NOLINT (readability/naming)
+ CHAR m_cnotificationname[MAX_STRING_SIZE_NOTIFICATION]; ///< Name of Notification
+ UI_32 m_uidelay; ///< Time delay between persistence
+ EFrameworkunifiedPersistCategory m_epersistcategory; ///< Persistent Category
+} TImmediatePersistenceRegisterNotifInfo;
+
+typedef struct _TImmediatePersistenceUnregisterNotifInfo { // NOLINT (readability/naming)
+ CHAR m_cnotificationname[MAX_STRING_SIZE_NOTIFICATION]; ///< Name of Notification
+} TImmediatePersistenceUnregisterNotifInfo;
+
+typedef struct _NPS_CopyShutdown { // NOLINT (readability/naming)
+ CopyInfoStr m_crequesterappname;
+} NSP_CopyShutdown, NSP_CopyShutdownAck;
+
+typedef struct _TImmediatePersistenceChangeCategory { // NOLINT (readability/naming)
+ TNorPersistenceNotifInfoHeader m_tnornotifInfoheader; ///< Notification info with new persist category type
+ EFrameworkunifiedPersistCategory m_eoldpersistcategory; ///< Old Persistent Category of notification
+} TImmediatePersistenceChangeCategory;
+
+typedef struct _TImmediateShutdown { // NOLINT (readability/naming)
+ EFrameworkunifiedShutdownType f_eshutdowntype;
+ UI_32 f_uinotificationpersistentservicepersistcategoryflag;
+} TImmediateShutdown;
+
+#endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_TYPES_H_
diff --git a/nsframework/notification_persistent_service/server/src/app_states.cpp b/nsframework/notification_persistent_service/server/src/app_states.cpp
new file mode 100644
index 00000000..c54508b1
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/app_states.cpp
@@ -0,0 +1,2684 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of internal transitions of state machine
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <unistd.h>
+#include <native_service/ns_np_service.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_np_service_notification.h>
+#include <string>
+#include <vector>
+#include "app_states.h"
+#include "ns_npp.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_notification_manager.h"
+#include "ns_npp_persistence_manager.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_personalization_manager.h"
+
+
+#ifdef NPP_PROFILEINFO_ENABLE
+#include <ns_npp_profiling_protocols_internal.h>
+#endif
+
+#ifdef AGL_STUB
+#include <other_service/strlcpy.h>
+#endif
+
+static size_t NppUIToA(unsigned int value, char *buf) {
+ static const char c[] = "0123456789";
+ char b[12];
+ char *p = b + sizeof(b);
+ int i = 0;
+
+ *--p = '\0';
+ do {
+ *--p = c[value % 10];
+ value /= 10;
+ ++i;
+ } while (value);
+ strcpy(buf, p); // NOLINT (runtime/printf)
+
+ return i;
+}
+
+static size_t NppStrlcpy(char *dst, const char *src, size_t siz) {
+ size_t ret = strlen(src);
+
+ if (siz) { // LCOV_EXCL_BR_LINE 6: siz can't be 0
+ size_t len = (ret >= siz) ? siz - 1 : ret;
+ memcpy(dst, src, len);
+ dst[len] = '\0';
+ }
+ return ret;
+}
+
+#define NPP_SET_FIXSTR(buf, str) \
+ do { \
+ strcpy(buf, str); /* NOLINT (runtime/printf) */ \
+ buf += sizeof(str) - 1; \
+ } while (0)
+
+#define NPP_SET_VARSTR(buf, str, siz) \
+ buf += NppStrlcpy(buf, str, siz)
+
+extern CHAR g_csendreadyackto[];
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPRegisterNotifications
+/// The state machine executes this transition when event for registering notification is triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterNotifications) { // NOLINT (readability/naming)
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_register_multiple_notif_msg *l_pMsg = NULL;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get app name of message source
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ if (l_uiMsgLength <= 0) { // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register notifications. Invalid message length received."); // LCOV_EXCL_LINE 6: l_uiMsgLength must be greater than 0 // NOLINT[whitespace/line_length]
+ } else {
+ std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(
+ l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) {
+ l_pMsg = reinterpret_cast<NC_register_multiple_notif_msg *>(&l_vData[0]);
+
+ if (NULL != l_pMsg) { // LCOV_EXCL_BR_LINE 6: l_pMsg can't be NULL
+ NC_register_notif_msg *l_pEventInfo = NULL;
+
+ // register all the notifications
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_pMsg->numNotifications;
+ ++l_uiCount) {
+ l_pEventInfo = &l_pMsg->notifierList[l_uiCount];
+
+ if (NULL != l_pEventInfo) { // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Register Notfn request, src=%s, name=%s, len=%d, type=%d",
+ l_cMsgSource, l_pEventInfo->notificationName, l_pEventInfo->maxLength, l_pEventInfo->persType);
+
+ // register the notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnRegisterEvents(l_cMsgSource,
+ l_pEventInfo->notificationName,
+ l_pEventInfo->maxLength,
+ l_pEventInfo->persType)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnRegisterEvents :: %s", l_pEventInfo->notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register notification from source %s. l_pEventInfo is NULL", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid src mq"); // LCOV_EXCL_LINE 6: l_pMsg can't be NULL
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register notifications from source %s, Unable to get message data. Error Status: 0x%x",
+ l_cMsgSource, l_estatus);
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationManager is NULL"); // LCOV_EXCL_LINE 6: l_pNotificationManager can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPSubscribeToNotification
+/// The state machine executes this transition when event for subscribing single notification is
+/// triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotification) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_subscribe_msg l_objSubscribeMsg;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ if (FrameworkunifiedGetMsgLength(l_pHApp) == sizeof(NC_subscribe_msg)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // get the data received
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_objSubscribeMsg), sizeof(NC_subscribe_msg), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+#ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
+ char buf[128];
+ char *p = buf;
+ NPP_SET_FIXSTR(p, "Subscribing Notfn request, src=");
+ NPP_SET_VARSTR(p, l_cMsgSource, sizeof(buf) - (p - buf));
+ NPP_SET_FIXSTR(p, ", name=");
+ strcpy(p, l_objSubscribeMsg.notificationName); // NOLINT (runtime/printf)
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, buf);
+ /* FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ * "Subscribing Notfn request, src=%s, name=%s",
+ * l_cMsgSource, l_objSubscribeMsg.notificationName);*/
+#endif // ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
+
+ // subscribe for notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnSubscribeToEvent(
+ l_cMsgSource,
+ l_objSubscribeMsg.notificationName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnSubscribeToEvent :: %s", l_objSubscribeMsg.notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't subscribe to notification from source %s. Unable to get msg data, status: 0x%x",
+ l_cMsgSource, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't subscribe to notification from source %s. Invalid message length received.",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't subscribe to notification from source %s. l_pNotificationManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPSubscribeToNotifications
+/// The state machine executes this transition when event for subscribing multiple notification is
+/// triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotifications) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_subscribe_multiple_notif_msg *l_pMsg = NULL;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ if (l_uiMsgLength <= 0) { // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
+ // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid msg len");
+ // LCOV_EXCL_STOP
+ } else {
+ std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the data received
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ l_pMsg = reinterpret_cast<NC_subscribe_multiple_notif_msg *>(&l_vData[0]);
+
+ if (NULL != l_pMsg) { // LCOV_EXCL_BR_LINE 6: l_pMsg can't be NULL
+ NC_subscribe_msg *l_pEventInfo = NULL;
+
+ // subscribe to multiple notifications
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_pMsg->numNotifications;
+ ++l_uiCount) {
+ l_pEventInfo = &l_pMsg->notificationList[l_uiCount];
+
+ if (NULL != l_pEventInfo) { // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
+#ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
+ char buf[128];
+ char *p = buf;
+ NPP_SET_FIXSTR(p, "Subscribe Notfn request, src=");
+ NPP_SET_VARSTR(p, l_cMsgSource, sizeof(buf) - (p - buf));
+ NPP_SET_FIXSTR(p, ", name=");
+ strcpy(p, l_pEventInfo->notificationName); // NOLINT (runtime/printf)
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, buf);
+ /* FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "Subscribe Notfn request, src=%s, name=%s",
+ l_cMsgSource,
+ l_pEventInfo->notificationName);*/
+#endif // ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
+
+ // subscribe to notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnSubscribeToEvent(
+ l_cMsgSource,
+ l_pEventInfo->notificationName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnSubscribeToEvent :: %s", l_pEventInfo->notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to subscribe to notifications from source %s, l_pEventInfo is NULL", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pMsg can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to subscribe to notifications from source %s, Invalid src mq", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+
+ l_vData.clear();
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to subscribe to notifications from source %s, error retrieving message data, status: 0x%x",
+ l_cMsgSource,
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to subscribe to notifications from source %s, l_pNotificationManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPPublishNotification
+/// The state machine executes this transition when event for publishing notification is triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishNotification) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+
+ CHAR l_cData[MAX_SYS_INFO_SIZE];
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get the app name of message source
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ // retrieve notification name
+ FrameworkunifiedGetSystemInfo(l_pHApp, l_cData);
+
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ char buf[144];
+ char *p = buf;
+ NPP_SET_FIXSTR(p, "Publish Notfn request, src=");
+ NPP_SET_VARSTR(p, l_cMsgSource, sizeof(buf) - (p - buf));
+ NPP_SET_FIXSTR(p, ", name=");
+ NPP_SET_VARSTR(p, l_cData, sizeof(buf) - (p - buf));
+ NPP_SET_FIXSTR(p, ", len=");
+ NppUIToA(l_uiMsgLength, p);
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, buf);
+ /* FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "Publish Notfn request, src=%s, name=%s, len=%d",
+ l_cMsgSource, l_cData, l_uiMsgLength);*/
+
+ if (0 != l_uiMsgLength) {
+ std::vector<CHAR> pMsgData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &pMsgData[0], static_cast<UI_32>(pMsgData.size()), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // publish the notification
+ (VOID)l_pNotificationManager->NotificationpersistentserviceServiceOnPublishEvent(l_cMsgSource, l_cData,
+ (PVOID)&pMsgData[0], l_uiMsgLength);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't publish notification from source %s, Unable to get messsage data, Error Status: 0x%x",
+ l_cMsgSource, l_estatus);
+ // LCOV_EXCL_STOP 4: NSFW error case
+ }
+ } else {
+ // publish the notification
+ (VOID)l_pNotificationManager->NotificationpersistentserviceServiceOnPublishEvent(l_cMsgSource, l_cData, NULL, l_uiMsgLength);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't publish notification from source %s. l_pNotificationManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPUnSubscribeFromNotification
+/// The state machine executes this transition when event for unsubscribing notification is triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotification) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_unsubscribe_frm_notif_msg unsubscribeMsg;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get the msg source name
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 200: l_pNotificationManager can't be NULL
+ if (FrameworkunifiedGetMsgLength(l_pHApp) == sizeof(NC_unsubscribe_frm_notif_msg)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&unsubscribeMsg), sizeof(NC_unsubscribe_frm_notif_msg), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Source: %s is unsubscribing from notification: %s", l_cMsgSource,
+ unsubscribeMsg.notificationName);
+
+ // unsubscribe from notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnUnSubscribeFromEvent(
+ l_cMsgSource,
+ unsubscribeMsg.notificationName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnUnSubscribeFromEvent :: %s",
+ unsubscribeMsg.notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "%s is unable to subscribe from notification, error getting message data, status: 0x%x",
+ l_cMsgSource, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe to notification from source %s, Invalid Message size received.",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe to notification from source %s, l_pNotificationManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPUnSubscribeFromNotification
+/// The state machine executes this transition when event for unsubscribing notification is triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotifications) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_unsubscribe_multiple_notif_msg *l_pMsg = NULL;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ if (l_uiMsgLength <= 0) { // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
+ // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe from notifications from source %s. Invalid message length received",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ } else {
+ std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the data received
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ l_pMsg = reinterpret_cast<NC_unsubscribe_multiple_notif_msg *>(&l_vData[0]);
+
+ if (NULL != l_pMsg) { // LCOV_EXCL_BR_LINE 6: l_pMsg can't be NULL
+ NC_unsubscribe_frm_notif_msg *l_pEventInfo = NULL;
+
+ // subscribe to multiple notifications
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_pMsg->numNotifications;
+ ++l_uiCount) {
+ l_pEventInfo = &l_pMsg->notificationList[l_uiCount];
+
+ if (NULL != l_pEventInfo) { // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Source: %s is unsubscribing from notification: %s", l_cMsgSource,
+ l_pEventInfo->notificationName);
+
+ // unsubscribe from notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnUnSubscribeFromEvent(
+ l_cMsgSource,
+ l_pEventInfo->notificationName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnUnSubscribeFromEvent :: %s", l_pEventInfo->notificationName);
+ }
+
+ } else {
+ // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe from notifications from source %s. l_pEventInfo is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pMsg can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe from notifications from source %s. Invalid src mq", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+
+ l_vData.clear();
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe from notifications from source %s, error getting message data, status: 0x%x",
+ l_cMsgSource,
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unsubscribe from notifications from source %s. l_pNotificationManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPUnRegisterNotifications
+/// The state machine executes this transition when event for unregistering notifications is triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnRegisterNotifications) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_unregister_multiple_notif_msg *l_pMsg = NULL;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get the source name
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ if (l_uiMsgLength <= 0) { // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
+ // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unregister to notifications from source %s. Invalid message length received.",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ } else {
+ std::vector<CHAR>l_vData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ l_pMsg = reinterpret_cast<NC_unregister_multiple_notif_msg *>(&l_vData[0]);
+
+ // unregister multiple notifications
+ if (NULL != l_cMsgSource && NULL != l_pMsg) { // LCOV_EXCL_BR_LINE 6: l_cMsgSource and l_pMsg can't be NULL
+ NC_unregister_notif_msg *l_pEventInfo = NULL;
+
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_pMsg->numNotifications;
+ ++l_uiCount) {
+ l_pEventInfo = &l_pMsg->notificationList[l_uiCount];
+
+ if (NULL != l_pEventInfo) { // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Source %s is unregistering to notification %s", l_cMsgSource,
+ l_pEventInfo->notificationName);
+
+ // unregister notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnUnRegisterEvents(
+ l_cMsgSource,
+ l_pEventInfo->notificationName)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnUnRegisterEvents :: %s", l_pEventInfo->notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unregister to notifications from source %s, l_pEventInfo is NULL", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_cMsgSource and l_pMsg can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unregister to notificationsfrom source %s, Invalid src mq ", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+
+ l_vData.clear();
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unregister to notifications from source %s, Unable to get message data, status: 0x%x",
+ l_cMsgSource, l_estatus);
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't unregister to notifications from source %s, l_pNotificationManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPReadPersistedData
+/// The state machine executes this transition when event for getting notification's persistent data
+/// is triggered.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPReadPersistedData) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_get_pers_data_msg l_tMsg;
+
+ l_tMsg.notificationName[0] = '\0';
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ if (FrameworkunifiedGetMsgLength(l_pHApp) == sizeof(NC_get_pers_data_msg)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // get the message data received
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(NC_get_pers_data_msg), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Source %s is requesting to read data for persistent notification %s",
+ l_cMsgSource, l_tMsg.notificationName);
+ // get persistent data related to notification
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationManager->NotificationpersistentserviceServiceOnGetPersistentData(
+ l_tMsg.notificationName,
+ l_cMsgSource))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in NotificationpersistentserviceServiceOnGetPersistentData :: %s", l_tMsg.notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't read persistent data for source %s, Error getting message data, status: 0x%x",
+ l_cMsgSource, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't read persistent data for source %s. Invalid Message size received.",
+ l_cMsgSource);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't read persistent data for source %s. l_pNotificationManager is NULL",
+ l_cMsgSource);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ // if any error occurs while reading persistent data, send failed ack to the requestor
+ if (eFrameworkunifiedStatusOK != l_estatus) {
+ HANDLE l_hReceiverMq = McOpenSender(l_cMsgSource);
+ if (NULL != l_hReceiverMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ NC_get_persdata_failed_ack gpdFailed = {};
+ std::strncpy(&gpdFailed.notificationName[0], l_tMsg.notificationName, MAX_STRING_SIZE_NOTIFICATION);
+
+ // send the failure ack to requester
+ l_estatus = McSend(l_hReceiverMq, AppName, NPS_GET_PERS_DATA_FAILED_ACK, sizeof(gpdFailed), &gpdFailed); // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "Sent NPS_GET_PERS_DATA_FAILED_ACK to %s. Status: %d.",
+ l_cMsgSource, l_estatus);
+
+ McClose(l_hReceiverMq);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in opening sender queue of %s. Can't send NPS_GET_PERS_DATA_FAILED_ACK",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPPublishImmediateNotification
+/// This transition is executed when service updates the immediate notification data
+/// using synchronous API
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishImmediateNotification) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ // get the app name of message source
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+ CHKNULL(l_pNotificationManager);
+
+ CHAR l_cNotfName[MAX_SYS_INFO_SIZE] = {};
+
+ // retrieve notification name
+ (VOID)FrameworkunifiedGetSystemInfo(l_pHApp, l_cNotfName);
+
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Warning::Notification %s published using sync API by %s, Data length: %d",
+ l_cNotfName,
+ l_cMsgSource, l_uiMsgLength);
+
+ if (0 != l_uiMsgLength) {
+ std::vector<CHAR> pMsgData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &pMsgData[0], l_uiMsgLength, eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // publish the notification
+ (VOID)l_pNotificationManager->NotificationpersistentservicePublishImmediateNotification(l_cMsgSource, l_cNotfName, (PVOID)&pMsgData[0],
+ l_uiMsgLength);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't publish notification %s from source %s, Unable to get messsage data, Error Status: 0x%x",
+ l_cNotfName,
+ l_cMsgSource, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // publish the notification
+ (VOID)l_pNotificationManager->NotificationpersistentservicePublishImmediateNotification(l_cMsgSource, l_cNotfName, NULL, l_uiMsgLength);
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ f_pSourceState = NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPPersistentSync
+/// Processing which synchronizes by NPPService (syncfs)
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPPersistentSync) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ if (TRUE == l_pnsnpp->Syncfs()) { // LCOV_EXCL_BR_LINE 6: always return true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "syncfs are processed."); // LCOV_EXCL_LINE 6: always return true
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPReleaseFileAck) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ NSP_CopyStatusResponse l_tCpStatus = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, (PVOID)&l_tCpStatus, sizeof(l_tCpStatus), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s for tag: %s sender: %s, persist type:%d",
+ (l_tCpStatus.m_bpersistencechk ? "Successful copy" : "Non-Successful copy"),
+ l_tCpStatus.m_cpersistenttag, l_tCpStatus.m_crequesterappname, l_tCpStatus.m_eloadtype);
+
+ if (LOADTYPE_LOAD == l_tCpStatus.m_eloadtype) { // ack for load file/folder
+ HANDLE hMq = NULL;
+ NC_LoadPersistedAck l_tMsgAck = {};
+
+ // HANDLE hMq = McOpenSender(l_tCpStatus.sender);
+ hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_tCpStatus.m_crequesterappname);
+
+ // send NC_LoadPersistedAck to the requester
+ l_tMsgAck.eStatus = (TRUE == l_tCpStatus.m_bpersistencechk) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_tMsgAck.cTag, l_tCpStatus.m_cpersistenttag, sizeof(l_tMsgAck.cTag));
+#endif
+
+ if (NULL == hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // catastrophic failure!
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender failed for %s ", l_tCpStatus.m_crequesterappname); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ } else {
+ if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == l_tCpStatus.m_epersisttype) {
+ // send ack to requester for file successfully persisted
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hMq, NPS_GET_PERS_FILE_ACK, sizeof(l_tMsgAck), &l_tMsgAck)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "ERROR :: Sending NPS_GET_PERS_FILE_ACK message to %s", l_tCpStatus.m_crequesterappname);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "NPS_GET_PERS_FILE_ACK is sent to %s for file tag %s and load status: %d.",
+ l_tCpStatus.m_crequesterappname, l_tMsgAck.cTag, l_tMsgAck.eStatus);
+ }
+ } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == l_tCpStatus.m_epersisttype) { // LCOV_EXCL_BR_LINE 6: m_epersisttype must be ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE or ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER // NOLINT[whitespace/line_length]
+ // send ack to requester for folder successfully persisted
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hMq, NPS_GET_PERS_FOLDER_ACK, sizeof(l_tMsgAck), &l_tMsgAck)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "ERROR :: Sending NPS_GET_PERS_FOLDER_ACK message to %s", l_tCpStatus.m_crequesterappname);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "NPS_GET_PERS_FOLDER_ACK is sent to %s for folder tag %s and load status: %d.",
+ l_tCpStatus.m_crequesterappname, l_tMsgAck.cTag, l_tMsgAck.eStatus);
+ }
+ } else {
+ // do nothing
+ }
+ // close mq
+ FrameworkunifiedMcClose(hMq);
+ hMq = NULL;
+ }
+ }
+
+ // Update registry
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ if (l_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: unexpected branch can't be NULL
+ l_pPersistenceManager->AckReceivedFromWorker(l_tCpStatus.m_crequesterappname,
+ l_tCpStatus.m_cpersistenttag,
+ l_tCpStatus.m_epersisttype,
+ l_tCpStatus.m_bpersistencechk,
+ l_tCpStatus.m_eloadtype);
+ }
+
+ if (LOADTYPE_RELEASE == l_tCpStatus.m_eloadtype) {
+ f_pSourceState->FrameworkunifiedPostEvent(EVENT(evCheckAllFilesPersisted));
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "ERROR ::invalid length FrameworkunifiedGetMsgDataOfSize expected(%ld)", static_cast<long int>(sizeof(l_tCpStatus))); // NOLINT (runtime/int)
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnSaveDataAck) { // LCOV_EXCL_START 6: unused code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnUserChange
+/// The state machine executes this transition when event to set or change personality is received
+/// from the system.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnUserChange) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ try {
+ CHKNULL(f_pSourceState);
+ NC_User l_tMsg;
+ std::string l_cCurrentUsername;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ // TODO(my_username): Only accept user change from authorized app. Compare l_cMsgSource with authorized source.
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(NC_User), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ if (NULL != l_pnsnpp) { // LCOV_EXCL_BR_LINE 6: l_pnsnpp can't be NULL
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ CnotificationpersistentservicePersonalizationManager *l_pPersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
+
+ if (NULL != l_pPersonalizationManager) { // LCOV_EXCL_BR_LINE 6: l_pPersonalizationManager can't be NULL
+ l_pPersonalizationManager->NotificationpersistentserviceGetPersonality(l_cCurrentUsername);
+ }
+
+ // writes the temporary user files and folders to permanent memory
+ if (NULL != l_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
+ if (!l_cCurrentUsername.empty()) { // LCOV_EXCL_BR_LINE 6: double check, l_cCurrentUsername can't be empty
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentservicePersistAllUserRequests()) { // LCOV_EXCL_BR_LINE 6: NotificationpersistentservicePersistAllUserRequests will always return ok // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while persisting user files and folders."); // LCOV_EXCL_LINE 6: NotificationpersistentservicePersistAllUserRequests will always return ok // NOLINT[whitespace/line_length]
+ }
+ }
+ }
+
+ // save the user persistent notification data
+ if (eFrameworkunifiedStatusOK != l_pnsnpp->NotificationpersistentserviceSaveNotificationPersistentData(eFrameworkunifiedPersistedStateUserVar)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while NotificationpersistentserviceSaveNotificationPersistentData");
+ }
+ }
+
+ // set new personality
+ SetPersonality(l_pHApp, l_tMsg);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "Cannot set new personality, error getting message data, status: 0x%x", l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+// ===========Shutdown
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnShutdownTimeout) { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+// LCOV_EXCL_STOP
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceCheckAllReleaseRequestsProcessed) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ CHKNULL(l_pPersistenceManager);
+ if (TRUE == l_pPersistenceManager->HaveAllReleaseRequestsPersisted()) { // LCOV_EXCL_BR_LINE 6: always return ok
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All release requests are processed.");
+ f_pSourceState->FrameworkunifiedPostEvent(EVENT(evIdle));
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceReInitShutdownTimer) { // LCOV_EXCL_START 8: not be used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+// LCOV_EXCL_STOP
+
+CsNotificationpersistentserviceNPPStart::CsNotificationpersistentserviceNPPStart(std::string f_strName): CFrameworkunifiedOrthogonalState(f_strName) {
+}
+
+CsNotificationpersistentserviceNPPStart::~CsNotificationpersistentserviceNPPStart() { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CsNotificationpersistentserviceNPPStart::FrameworkunifiedOnEntry(CEventDataPtr f_peventdata) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ try {
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // Get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ NC_User l_tMsg = {};
+
+ // register the user change notification
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnRegisterEvents(AppName, // LCOV_EXCL_BR_LINE 6: always return ok // NOLINT[whitespace/line_length]
+ NTFY_NPPService_UserChange,
+ sizeof(NC_User),
+ eFrameworkunifiedPersistedStateVar)) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in user change notification registration."); // LCOV_EXCL_LINE 6: always return ok // NOLINT[whitespace/line_length]
+ }
+
+ // Set initial user. By default, NS_NPPService will set the current user as last user. If no
+ // last user found set the default user.
+ UI_32 l_uiUserNotificationDataSize = 0;
+ EFrameworkunifiedStatus l_eGetNotificationDataStatus = eFrameworkunifiedStatusFail;
+ l_eGetNotificationDataStatus = l_pNotificationManager->NPGetPersistentNotificationData(
+ NTFY_NPPService_UserChange,
+ (PVOID)&l_tMsg,
+ sizeof(l_tMsg));
+
+ if ((eFrameworkunifiedStatusOK != l_eGetNotificationDataStatus) || (l_uiUserNotificationDataSize <= 0)) {
+ // set default user
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_tMsg.cUsername, DEFAULTUSERNAME, sizeof(l_tMsg.cUsername));
+#endif
+ }
+
+ l_estatus = SetPersonality(l_pHApp, l_tMsg);
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return l_estatus;
+}
+
+EFrameworkunifiedStatus SetPersonality(HANDLE l_pHApp, NC_User &f_tMsg) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ if (NULL != l_pnsnpp) { // LCOV_EXCL_BR_LINE 6: l_pnsnpp can't be NULL
+ // Get the instance of personalization manager
+ CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
+
+ if (NULL != l_pNotificationpersistentservicePersonalizationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationpersistentservicePersonalizationManager can't be NULL
+ // send msg to all notificationpersistentservice apps that user has change.
+ // register user change notification
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Personality :: %s", f_tMsg.cUsername);
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceSetPersonality(f_tMsg.cUsername))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Personality not set in Personality Manager :: user : %s", f_tMsg.cUsername);
+ } else {
+ // Get the instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ if (NULL != l_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
+ l_pPersistenceManager->SetUserPersistentPath(f_tMsg.cUsername);
+
+ // save the user persistent notification data
+ if (eFrameworkunifiedStatusOK != l_pnsnpp->NotificationpersistentserviceLoadPersistentNotificationData(eFrameworkunifiedPersistedStateUserVar)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while loading user specific notification data.");
+ }
+
+ // Get instance of notification manager
+ CNotificationManager *l_pNotificationManager = NULL;
+ l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ // publish the user change notification
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationManager->NotificationpersistentserviceServiceOnPublishEvent(AppName, NTFY_NPPService_UserChange, (PVOID)&f_tMsg, sizeof(f_tMsg)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in publish user change event."); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ }
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationpersistentservicePersonalizationManager is NULL"); // LCOV_EXCL_LINE 6: l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return l_estatus;
+}
+
+EFrameworkunifiedStatus CsNotificationpersistentserviceNPPStart:: FrameworkunifiedOnExit(CEventDataPtr f_peventdata) { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+}
+
+CsNotificationpersistentserviceShutdownDataSave::CsNotificationpersistentserviceShutdownDataSave(std::string f_strName): CFrameworkunifiedLeafState(f_strName) {
+}
+
+CsNotificationpersistentserviceShutdownDataSave::~CsNotificationpersistentserviceShutdownDataSave() { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CsNotificationpersistentserviceShutdownDataSave::FrameworkunifiedOnEntry(CEventDataPtr f_peventdata) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ m_cShutdownRequestor = l_cMsgSource;
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "NS_NPP received STOP message from %s.", l_cMsgSource);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ if (NULL != l_pnsnpp) { // LCOV_EXCL_BR_LINE 6: can't be NULL
+ CShutDownMsgData *l_pMsgData = dynamic_cast<CShutDownMsgData *>(f_peventdata.get());
+ CHKNULL(l_pMsgData);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Shutdown Type=%d, Data received with shutdown message:: %x",
+ l_pMsgData->m_eShutdownType, l_pMsgData->m_uiMsgData);
+
+ // save the persistent data on shutdown
+ if (eFrameworkunifiedStatusOK != l_pnsnpp->NotificationpersistentservicePersistAll(l_pMsgData->m_eShutdownType, l_pMsgData->m_uiMsgData)) { // LCOV_EXCL_BR_LINE 6: always return ok // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in NotificationpersistentserviceOnSavePersistentData"); // LCOV_EXCL_LINE 6: always return ok
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus CsNotificationpersistentserviceShutdownDataSave:: FrameworkunifiedOnExit(CEventDataPtr f_peventdata) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ try {
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ CHKNULL(l_pPersistenceManager);
+
+ l_pPersistenceManager->ResetPersistFlag();
+
+ // before sending shutdown ack, synchronize all the modified block buffers by NPPService for writing
+ l_pnsnpp->Syncfs();
+
+ // Send shutdown ack response to requester
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Sending shutdown complete message to requestor %s.",
+ m_cShutdownRequestor.c_str());
+ HANDLE hMq = FrameworkunifiedMcOpenSender(l_pHApp, m_cShutdownRequestor.c_str());
+ if (NULL != hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hMq, NPS_NPP_STOP_ACK, 0, NULL)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error sending shutdown complete message to requestor %s.",
+ m_cShutdownRequestor.c_str());
+ // LCOV_EXCL_STOP
+ }
+ FrameworkunifiedMcClose(hMq);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in OpenSender for requestor %s.", m_cShutdownRequestor.c_str()); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnRegisterPersistentFile
+/// The state machine executes this transition when event for registering persistent file tag is
+/// received.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFile) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+ NC_RegisterPersistentFileMsg l_tMsg = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+
+ if (NULL != l_pPersistenceManager && NULL != l_cMsgSource) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ std::string l_cName;
+ l_cName = l_tMsg.cFileTag;
+
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRegister(l_cMsgSource, // LCOV_EXCL_BR_LINE 6: always return ok
+ l_tMsg.cFileTag,
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE,
+ // l_tMsg.eRegisterType,
+ l_tMsg.bIsUserFile)) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Registering Persitence File :: %s", l_tMsg.cFileTag); // LCOV_EXCL_LINE 6: always return ok // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Registered File %s as TO BE PERSISTED for %s",
+ l_tMsg.cFileTag, l_cMsgSource);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent file. Invalid message size received."); // LCOV_EXCL_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent file. l_pPersistenceManager is NULL"); // LCOV_EXCL_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnReleasePersistentFile
+/// The state machine executes this transition when event for releasing persistent file tag is
+/// received.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFile) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ // Check if persistence has been disabled than return immediately
+ if (TRUE == CPersistenceManager::m_bPersistenceDisabled) { // LCOV_EXCL_BR_LINE 6: custom command line options
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return f_pSourceState; // LCOV_EXCL_LINE 6: custom command line options
+ }
+
+ CHKNULL(f_pSourceState);
+ NC_ReleasePersistentFileMsg l_tMsg = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get the instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ // get the instance of persistence manager
+ CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
+
+ if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // Check if the filetag is registered as user specific persistence
+ if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFileTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE)) {
+ if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRelease(l_cMsgSource,
+ l_tMsg.cFileTag,
+ l_tMsg.cFilePath,
+ l_tMsg.eFrameworkunifiedReleaseType, // NOLINT (readability/naming)
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE,
+ l_tMsg.cUsername)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in releasing persitence file :: %s", l_tMsg.cFileTag);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Release file %s to tag %s for source %s",
+ l_tMsg.cFilePath, l_tMsg.cFileTag, l_cMsgSource);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent file. Invalid message size received"); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent file. l_pPersistenceManager is NULL"); // LCOV_EXCL_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnLoadPersistentFile
+/// The state machine executes this transition when event for loading persistent file is received.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFile) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+ NC_LoadPersistedFileMsg l_tMsg = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
+ // get the instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Load file %s that was PERSISTED by %s with tag %s",
+ l_tMsg.cFilePath, l_cMsgSource, l_tMsg.cFileTag);
+
+ // Check if the filetag is registered as user specific persistence
+ if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFileTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE)) {
+ if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+ }
+ }
+
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ NC_LoadPersistedAck l_tMsgAck = {};
+
+ HANDLE l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
+
+ if (NULL != l_hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ //// Check if persistence has been disabled than send positive acknowledgement to the application
+ if (TRUE == CPersistenceManager::m_bPersistenceDisabled) { // LCOV_EXCL_BR_LINE 6: custom command line options // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: custom command line options
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_tMsgAck.eStatus = eFrameworkunifiedStatusOK;
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_tMsgAck.cTag, l_tMsg.cFileTag, sizeof(l_tMsgAck.cTag));
+#endif
+
+ // send ack to requester
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_GET_PERS_FILE_ACK, sizeof(l_tMsgAck), &l_tMsgAck))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pPersistenceManager->NotificationpersistentserviceLoad(l_cMsgSource,
+ l_tMsg.cFileTag,
+ l_tMsg.cFilePath,
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE,
+ l_tMsg.cUsername))) {
+ if (eFrameworkunifiedStatusFileLoadSuccess == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus can't be eFrameworkunifiedStatusFileLoadSuccess // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_tMsgAck.eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_LINE 6: l_estatus can't be eFrameworkunifiedStatusFileLoadSuccess
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Loading Persitence File :: %s", l_tMsg.cFileTag);
+
+ // return error to requester
+ l_tMsgAck.eStatus = l_estatus;
+ }
+
+ std::strncpy(l_tMsgAck.cTag, l_tMsg.cFileTag, (MAX_PATH_LENGTH - 1));
+
+ // send ack to requester
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_GET_PERS_FILE_ACK, sizeof(l_tMsgAck), &l_tMsgAck))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "NPS_GET_PERS_FILE_ACK is sent to %s. File load status: %d, "
+ "message sent status: %d ", l_cMsgSource, l_tMsgAck.eStatus, l_estatus);
+ }
+ }
+
+ FrameworkunifiedMcClose(l_hMq);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // catastrophic failure!
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender failed for %s", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent file. Invalid message size received."); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent file. l_pNotificationManager is NULL"); // LCOV_EXCL_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnRegisterPersistentFolder
+/// The state machine executes this transition when event for registering persistent folder tag is
+/// received.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFolder) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+ NC_RegisterPersistentFolderMsg l_tMsg = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ if (NULL != l_pPersistenceManager && NULL != l_cMsgSource) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, // LCOV_EXCL_BR_LINE 4: NSFW error case
+ static_cast<PVOID>(&l_tMsg),
+ sizeof(l_tMsg),
+ eSMRRelease)) {
+ std::string l_cName;
+ l_cName = l_tMsg.cFolderTag;
+
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRegister(l_cMsgSource, // LCOV_EXCL_BR_LINE 6: always return ok
+ l_tMsg.cFolderTag,
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER,
+ // l_tMsg.eRegisterType,
+ l_tMsg.bIsUserFolder)) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Registering Persitence Folder :: %s", l_tMsg.cFolderTag); // LCOV_EXCL_LINE 6: always return ok // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Registered Folder %s as TO BE PERSISTED for %s",
+ l_tMsg.cFolderTag, l_cMsgSource);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent folder. Invalid message size received.");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent folder.. l_pPersistenceManager is NULL"); // LCOV_EXCL_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnLoadPersistentFolder
+/// The state machine executes this transition when event for loading persistent folder is received.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFolder) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+ NC_LoadPersistedFolderMsg l_tMsg = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
+
+ // get the instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Load folder %s that was PERSISTED by %s with tag %s",
+ l_tMsg.cFolderPath, l_cMsgSource, l_tMsg.cFolderTag);
+
+ // Check if the foldertag is registered as user specific persistence
+ if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFolderTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER)) {
+ if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+ }
+ }
+
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ NC_LoadPersistedAck l_tMsgAck = {};
+ HANDLE l_hMq = NULL;
+ l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
+
+ if (NULL != l_hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ //// Check if persistence has been disabled than send positive acknowledgement to the application
+ if (TRUE == CPersistenceManager::m_bPersistenceDisabled) { // LCOV_EXCL_BR_LINE 6: custom command line options // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: custom command line options
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_tMsgAck.eStatus = eFrameworkunifiedStatusOK;
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_tMsgAck.cTag, l_tMsg.cFolderTag, sizeof(l_tMsgAck.cTag));
+#endif
+
+ // send ack to requester
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq,
+ NPS_GET_PERS_FOLDER_ACK,
+ sizeof(l_tMsgAck), &l_tMsgAck))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pPersistenceManager->NotificationpersistentserviceLoad(l_cMsgSource,
+ l_tMsg.cFolderTag,
+ l_tMsg.cFolderPath,
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER,
+ l_tMsg.cUsername))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Loading Persitence Folder :: %s", l_tMsg.cFolderTag);
+
+ // return error to requester
+ l_tMsgAck.eStatus = l_estatus;
+ std::strncpy(l_tMsgAck.cTag, l_tMsg.cFolderTag, (MAX_PATH_LENGTH - 1));
+
+ // send ack to requester
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq, // LCOV_EXCL_BR_LINE 4: NSFW error case
+ NPS_GET_PERS_FOLDER_ACK,
+ sizeof(l_tMsgAck), &l_tMsgAck))) {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ FrameworkunifiedMcClose(l_hMq);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't send ack NPS_GET_PERS_FOLDER_ACK. McOpenSender failed for %s ", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent folder. Invalid message size received.");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent folder. l_pNotificationManager is NULL"); // LCOV_EXCL_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnReleasePersistentFolder
+/// The state machine executes this transition when event for releasing persistent folder tag is
+/// received.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFolder) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+
+ // Check if persistence has been disabled than return immediately
+ if (TRUE == CPersistenceManager::m_bPersistenceDisabled) { // LCOV_EXCL_BR_LINE 6: custom command line options
+ // LCOV_EXCL_START 6: custom command line options
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+ // LCOV_EXCL_STOP
+ }
+
+ NC_ReleasePersistentFolderMsg l_tMsg = {};
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get the instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
+
+ if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // Check if the foldertag is registered as user specific persistence
+ if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFolderTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER)) {
+ if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+ }
+ }
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRelease(l_cMsgSource,
+ l_tMsg.cFolderTag,
+ l_tMsg.cFolderPath,
+ l_tMsg.eFrameworkunifiedReleaseType, // NOLINT (readability/naming)
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER,
+ l_tMsg.cUsername)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in releasing persitence folder :: %s", l_tMsg.cFolderTag);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Release Folder %s to tag %s for source %s",
+ l_tMsg.cFolderPath, l_tMsg.cFolderTag, l_cMsgSource);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent folder. Invalid message size received.");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent folder. l_pPersistenceManager is NULL"); // LCOV_EXCL_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPGetReadyStatus
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPGetReadyStatus) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ HANDLE l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
+ if (NULL != l_hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // send ack to requester
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_GET_READYSTATUS_ACK, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __PRETTY_FUNCTION__, "NPP ready status sent to %s.", l_cMsgSource);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error sending NPS_GET_READYSTATUS_ACK to %s, status: %d", l_cMsgSource,
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FrameworkunifiedMcClose(l_hMq);
+ l_hMq = NULL;
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // catastrophic failure!
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender failed for %s ", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterImmediateNotifications) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+ NC_register_multiple_immediate_notif_msg *l_pMsg = NULL;
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+
+ // get app name of message source
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ if (l_uiMsgLength <= 0) { // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
+ // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register immediate persistence notification from source %s. Invalid message length.",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ } else {
+ std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ l_pMsg = reinterpret_cast<NC_register_multiple_immediate_notif_msg *>(&l_vData[0]);
+
+ if (NULL != l_pMsg) { // LCOV_EXCL_BR_LINE 5: reinterpret_cast's error case.
+ NC_register_immediate_notif_msg *l_pEventInfo = NULL;
+ UI_32 l_uiCount;
+ // register all the notifications
+ for (l_uiCount = 0 ; l_uiCount < l_pMsg->numNotifications; ++l_uiCount) {
+ l_pEventInfo = &l_pMsg->notifierList[l_uiCount];
+
+ if (NULL != l_pEventInfo) { // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Register immediate persistence notification: "
+ "NotificationName[%d] = %s, data length = %d ",
+ l_uiCount, l_pEventInfo->notificationName, l_pEventInfo->maxLength);
+
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnRegisterEvents(l_cMsgSource,
+ l_pEventInfo->notificationName,
+ l_pEventInfo->maxLength,
+ l_pEventInfo->persType,
+ l_pEventInfo->delay)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceServiceOnRegisterEvents :: %s", l_pEventInfo->notificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register immediate persistence notification from source %s. l_pEventInfo is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 5: reinterpret_cast's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register immediate persistence notification from source %s. Invalid src mq",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register immediate persistence notification from source %s, "
+ "Error getting message data, status: 0x%x",
+ l_cMsgSource, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't register immediate persistence notification from source %s. "
+ "l_pNotificationManager is NULL", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPClearPersistedData
+/// Deletes NPS Persistent Data and sends the ack back to requester
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPClearPersistedData) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+
+ // requeter MsgQ handle for sending Ack
+ HANDLE hRequesterAck = NULL;
+
+ // Application Handle
+ HANDLE l_pHApp = NULL;
+
+ // Received request data
+ NC_ClearPersistedDataReq l_tMsg = {};
+
+ // Ack structure
+ NC_ClearPersisteDatadAck l_tMsgAck = {};
+
+ // requester name
+ PCSTR pRequester = NULL;
+
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ pRequester = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(pRequester);
+
+ if (sizeof(NC_ClearPersistedDataReq) == FrameworkunifiedGetMsgLength(l_pHApp)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, (PVOID)(&l_tMsg), sizeof(NC_ClearPersistedDataReq), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Request for deleting the persistent data of type %d received from %s",
+ l_tMsg.ePersistenceData, pRequester);
+
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ CHKNULL(l_pPersistenceManager);
+
+ l_estatus = l_pPersistenceManager->ClearPersistenceData(l_tMsg.ePersistenceData);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Error");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't delete persistent data. Invalid message size received.");
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ f_pSourceState = NULL;
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ // sending acknowledgement to the requester
+
+ // create the requestor handle to send the ack
+ hRequesterAck = FrameworkunifiedMcOpenSender(l_pHApp,
+ pRequester);
+
+ if (NULL != hRequesterAck) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // set the status
+ l_tMsgAck.eStatus = l_estatus;
+
+ // send NC_ClearPersisteDatadAck to the requester
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hRequesterAck, // LCOV_EXCL_BR_LINE 4: NSFW error case
+ NPS_DELETE_PERSISTED_DATA_ACK,
+ sizeof(l_tMsgAck),
+ &l_tMsgAck)) {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending NPS_GET_PERS_FILE_ACK message to %s", pRequester);
+ // LCOV_EXCL_STOP
+ }
+
+ // close handle
+ FrameworkunifiedMcClose(hRequesterAck);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedMcOpenSender failed for %s ", pRequester);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPSetDefaultPersistentData
+/// Sets the default value of the persistent notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetDefaultPersistentData) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
+ UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
+
+ CHAR l_cNotificationName[MAX_SYS_INFO_SIZE] = {};
+
+ // retrieve notification name
+ FrameworkunifiedGetSystemInfo(l_pHApp, l_cNotificationName);
+
+ if (0 != std::strlen(l_cNotificationName)) { // LCOV_EXCL_BR_LINE 6: double check, l_cNotificationName can't be empty // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "Set default value request for Notification:: %s from :: %s", l_cNotificationName,
+ l_cMsgSource);
+
+ if (0 != l_uiMsgLength) {
+ std::vector<CHAR> pMsgData = std::vector<CHAR>(l_uiMsgLength);
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &pMsgData[0], static_cast<UI_32>(pMsgData.size()), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // set the default notification data
+ if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceSetDefaultPersistentNotificationData(l_cNotificationName,
+ (PVOID)&pMsgData[0],
+ l_uiMsgLength)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in NotificationpersistentserviceSetDefaultPersistentNotificationData :: %s", l_cNotificationName);
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to set default persistent notification data for %s, "
+ "Error retrieving data from message, status: 0x%x",
+ l_cNotificationName, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Not setting default persistent notification data for %s, Data length received is %d",
+ l_cNotificationName, l_uiMsgLength);
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_cNotificationName can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to Set DefaultPersistentNotificationData from source %s, Notification name is blank",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't set default value for notification from source %s, l_pNotificationManager is NULL", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPSetNotfnPersistentType
+/// Sets the persist type of notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetNotfnPersistentType) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ CHAR l_cNotificationName[MAX_SYS_INFO_SIZE] = {};
+
+ // retrieve notification name
+ FrameworkunifiedGetSystemInfo(l_pHApp,
+ l_cNotificationName);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+
+ if (NULL != l_pNotificationManager && 0 != std::strlen(l_cNotificationName)) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL, l_cNotificationName can't be empty // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Set persist type request for Notification:: %s", l_cNotificationName);
+
+ EFrameworkunifiedPersistCategory ePersistCategory = eFrameworkunifiedUserData;
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &ePersistCategory, sizeof(EFrameworkunifiedPersistCategory), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // set the notification persist type
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationManager->NotificationpersistentserviceSetPersistentCategory(l_cNotificationName, // LCOV_EXCL_BR_LINE 6: always return ok // NOLINT[whitespace/line_length]
+ ePersistCategory))) {
+ // LCOV_EXCL_START 6: always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Setting PersistentType for notification :: %s, Status: 0x%x",
+ l_cNotificationName, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in getting the PersistentType message data for notification :: %s, Status: 0x%x",
+ l_cNotificationName, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL, l_cNotificationName can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't set persist type for notification :: %s", l_cNotificationName);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPSetFilePersistentType
+/// Sets the persist type of file
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFilePersistentType) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ if (NULL != l_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
+ NC_SetFilePersistType l_tMsg = {};
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ if (0 != std::strlen(l_tMsg.cTag)) { // LCOV_EXCL_BR_LINE 6: double check, l_tMsg.cTag can't be empty
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "Set persist type request for file tag:: %s from %s", l_tMsg.cTag, l_cMsgSource);
+
+ // set the file persist type
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceSetPersistentCategory(l_cMsgSource,
+ l_tMsg.cTag,
+ l_tMsg.ePersistType,
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in Setting FilePersistentType for tag:: %s for request from:: %s", l_tMsg.cTag,
+ l_cMsgSource);
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_tMsg.cTag can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "set file persistent type request for NULL file tag from source:: %s", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pPersistenceManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't process request for setting persist type for file from source: %s, l_pPersistenceManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPSetFolderPersistentType
+/// Sets the persist type of folder
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFolderPersistentType) {
+ try {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ if (NULL != l_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
+ NC_SetFolderPersistType l_tMsg = {};
+
+ // get the received data
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ if (0 != std::strlen(l_tMsg.cTag)) { // LCOV_EXCL_BR_LINE 6: double check, l_tMsg.cTag can't be empty
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Set persist type request for folder tag:: %s", l_tMsg.cTag);
+
+ // set the file persist type
+ if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceSetPersistentCategory(l_cMsgSource,
+ l_tMsg.cTag,
+ l_tMsg.ePersistType,
+ ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error in Setting FolderPersistentType for tag:: %s for request from:: %s", l_tMsg.cTag,
+ l_cMsgSource);
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_tMsg.cTag can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "set file persistent type request for NULL folder tag from source:: %s", l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pPersistenceManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't process request for setting persist type for folder from source: %s, l_pPersistenceManager is NULL",
+ l_cMsgSource);
+ // LCOV_EXCL_STOP
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPShutdown
+/// Internal transition when NPP receives shutdown message
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPShutdown) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ try {
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ NC_StopMsgData l_tStopMsgData = {};
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tStopMsgData), sizeof(l_tStopMsgData), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // make a transition to sNotificationpersistentserviceShutdownDataSave state and pass the message data through event
+ CShutDownMsgData *l_pMsgData = new(std::nothrow) CShutDownMsgData(EVENT(evNPShutdownDataSave),
+ l_tStopMsgData.eShutdownType,
+ l_tStopMsgData.uiStopMsgData);
+ CHKNULL(l_pMsgData);
+
+ CEventDataPtr l_pData(l_pMsgData);
+ f_pSourceState->FrameworkunifiedPostEvent(l_pData);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Shutdown Message received from %s with data: %d", l_cMsgSource,
+ l_tStopMsgData.uiStopMsgData);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't process shutdown request from:: %s, Invalid message data", l_cMsgSource); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ f_pSourceState = NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnNPNorDataSaveAck
+/// Internal transition when NPP receives shutdown ack message nor worker thread
+////////////////////////////////////////////////////////////////////////////////////////////////////
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPNorDataSaveAck) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ try {
+ // data received with ack
+ UI_32 l_uiPersistCategoryFlag = 0;
+
+ CHKNULL(f_pSourceState);
+
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CHKNULL(l_pNotificationpersistentserviceHSM);
+
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+ CHKNULL(l_pPersistenceManager);
+
+ l_pPersistenceManager->SetImmediateDataPersistedStatus(TRUE);
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_uiPersistCategoryFlag), sizeof(l_uiPersistCategoryFlag), eSMRRelease)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "ShutdownAck received from %s with data: %d", l_cMsgSource,
+ l_uiPersistCategoryFlag);
+ }
+
+ // depending on the flag delete the persisted data from persistent memory
+ // which are not to be persisted during shutdown
+ l_pnsnpp->DeletePersistedDataFolder(l_uiPersistCategoryFlag);
+
+ if (TRUE == l_pPersistenceManager->HaveAllReleaseRequestsPersisted()) { // LCOV_EXCL_BR_LINE 6: always return ok
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All release requests are processed.");
+ f_pSourceState->FrameworkunifiedPostEvent(EVENT(evIdle));
+ }
+ } catch (std::exception &e) { // LCOV_EXCL_START 5: exception error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ f_pSourceState = NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+CsNotificationpersistentservicePersistenceReady::CsNotificationpersistentservicePersistenceReady(std::string f_strName): CFrameworkunifiedLeafState(f_strName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+}
+
+CsNotificationpersistentservicePersistenceReady::~CsNotificationpersistentservicePersistenceReady() { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CsNotificationpersistentservicePersistenceReady::FrameworkunifiedOnEntry(CEventDataPtr f_peventdata) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
+
+ if (NULL != l_pHApp) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ HANDLE l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, g_csendreadyackto);
+
+ if (NULL != l_hMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // send ack to requester
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_NPP_READY_EVENT, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __PRETTY_FUNCTION__, "NPP ready status sent to %s.", g_csendreadyackto);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error sending NPS_NPP_READY_EVENT to %s, status: %d", g_csendreadyackto,
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ FrameworkunifiedMcClose(l_hMq);
+ l_hMq = NULL;
+ } else {
+ // catastrophic failure!
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "McOpenSender failed for %s ", g_csendreadyackto); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus CsNotificationpersistentservicePersistenceReady::FrameworkunifiedOnExit(CEventDataPtr f_peventdata) { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+}
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfileNotifications) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ try {
+ CHKNULL(f_pSourceState);
+
+ // get the application handle
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ // get the statemachine pointer of application
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ // get the message source name
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get the message queue handle for sending the response
+ HANDLE hSrcMqHandle = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
+ CHKNULL(hSrcMqHandle);
+
+ // get instance of notification manager
+ CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
+ CHKNULL(l_pNotificationManager);
+
+ std::string l_cNotificationProfileInfo = "";
+
+ // get the data from notification manager
+ if (eFrameworkunifiedStatusOK == l_pNotificationManager->GetNotificationProfilingData(l_cNotificationProfileInfo)) {
+ UI_32 l_uiLength = l_cNotificationProfileInfo.size();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendMsg NPS_PROFILE_NOTIFICATION_RESP Msg Length: %d", l_uiLength);
+
+ PCHAR l_pData = new CHAR[l_uiLength];
+ std::memset(l_pData, '0', l_uiLength);
+
+ std::strncpy(l_pData, l_cNotificationProfileInfo.c_str(), l_cNotificationProfileInfo.size());
+
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hSrcMqHandle,
+ NPS_PROFILE_NOTIFICATION_RESP,
+ l_uiLength,
+ l_pData)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
+ "FrameworkunifiedSendMsg NPS_PROFILE_NOTIFICATION_RESP for Notification Profiling failed.");
+ }
+
+ delete[] l_pData;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Failed to get Notification profiling data from NSNPP.");
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ f_pSourceState = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfilePersistence) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ try {
+ CHKNULL(f_pSourceState);
+
+ // get the application handle
+ HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
+ CHKNULL(l_pHApp);
+
+ // get the statemachine pointer of application
+ CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
+ CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
+ CHKNULL(l_pnsnpp);
+
+ // get the message source name
+ PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
+ CHKNULL(l_cMsgSource);
+
+ // get the message queue handle for sending the response
+ HANDLE hSrcMqHandle = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
+ CHKNULL(hSrcMqHandle);
+
+ // get instance of persistence manager
+ CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
+
+ CHKNULL(l_pPersistenceManager);
+
+ std::string l_cPersistenceProfileInfo = "";
+
+ if (eFrameworkunifiedStatusOK == l_pPersistenceManager->GetPersistenceProfilingData(l_cPersistenceProfileInfo)) {
+ UI_32 l_uiLength = l_cPersistenceProfileInfo.size();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendMsg NPS_PROFILE_PERSISTENCE_RESP Msg Length: %d", l_uiLength);
+
+ PCHAR l_pData = new CHAR[l_uiLength];
+ std::memset(l_pData, '0', l_uiLength);
+
+ std::strncpy(l_pData, l_cPersistenceProfileInfo.c_str(), l_cPersistenceProfileInfo.size());
+
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hSrcMqHandle,
+ NPS_PROFILE_PERSISTENCE_RESP,
+ l_uiLength,
+ l_pData)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSendMsg NPS_PROFILE_PERSISTENCE_RESP for Persistence Profiling failed.");
+ }
+
+ delete[] l_pData;
+ }
+ } catch (std::exception &e) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
+ f_pSourceState = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return f_pSourceState;
+}
+
+#endif
diff --git a/nsframework/notification_persistent_service/server/src/notificationpersistentservice_application.cpp b/nsframework/notification_persistent_service/server/src/notificationpersistentservice_application.cpp
new file mode 100644
index 00000000..c1b97f96
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/notificationpersistentservice_application.cpp
@@ -0,0 +1,258 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_np_service_notification.h>
+
+#include "app_states.h"
+#include "ns_npp.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_persistence_manager.h"
+
+using std::malloc;
+
+#ifdef NPP_PROFILEINFO_ENABLE
+#include "ns_npp_profiling_protocols_internal.h"
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnInitialization
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE happ) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != happ) { // LCOV_EXCL_BR_LINE 4: happ can't be null
+ FrameworkunifiedProtocolEvent ns_npp_protocol_handlers[] = {
+ {NPS_REGISTER_EV_REQ, EVENT(evNPRegisterNotifications)},
+ {NPS_PUBLISH_EV_REQ, EVENT(evNPPublishNotification)},
+ {NPS_SUBSCRIBE_TO_EV_REQ, EVENT(evNPSubscribeToNotification)},
+ {NPS_BATCH_SUBSCRIBE_TO_EV_REQ, EVENT(evNPSubscribeToNotifications)},
+ {NPS_UNSUBSCRIBE_FROM_EV_REQ, EVENT(evNPUnSubscribeFromNotification)},
+ {NPS_UNREGISTER_EV_REQ, EVENT(evNPUnRegisterNotifications)},
+ {NPS_GET_PERS_DATA_REQ, EVENT(evNPReadPersistedData)},
+ {NPS_SET_PERSIST_FILE_PATH_REQ, EVENT(evNPRegisterPersistentFile)},
+ {NPS_RELEASE_PERS_FILE_REQ, EVENT(evNPReleasePersistentFile)},
+ {NPS_GET_PERS_FILE_REQ, EVENT(evNPLoadPersistentFile)},
+ {NPS_SET_PERSIST_FOLDER_PATH_REQ, EVENT(evNPRegisterPersistentFolder)},
+ {NPS_GET_PERS_FOLDER_REQ, EVENT(evNPLoadPersistentFolder)},
+ {NPS_RELEASE_PERS_FOLDER_REQ, EVENT(evNPReleasePersistentFolder)},
+ {NPS_CHANGE_PERSONALITY_REQ, EVENT(evUserChange)},
+ {NPS_NPP_STOP_REQ, EVENT(evShutdown)},
+ {NPS_BATCH_UNSUBSCRIBE_FROM_EV_REQ, EVENT(evNPUnSubscribeFromNotifications)},
+ {NPS_GET_READYSTATUS_REQ, EVENT(evNPGetReadyStatus)},
+ {NPS_REGISTER_NOR_EV_REQ, EVENT(evNPRegisterImmediateNotifications)},
+ {NPS_DELETE_PERSISTED_DATA_REQ, EVENT(evNPClearPersistedData)},
+ {NPS_SET_DEFAULT_PERS_DATA, EVENT(evNPSetDefaultPersistentData)},
+ {NPS_SET_NOTFN_PERSISTENT_TYPE, EVENT(evNPSetNotfnPersistentType)},
+ {NPS_SET_FILE_PERSISTENT_TYPE, EVENT(evNPSetFilePersistentType)},
+ {NPS_SET_FOLDER_PERSISTENT_TYPE, EVENT(evNPSetFolderPersistentType)},
+ {NPS_SYNCHRONOUS_WRITE_NOTIFY_REQ, EVENT(evNPPublishImmediateNotification)},
+ {NPS_NPP_SYNC_REQ, EVENT(evNPPersistentSync)}
+ };
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+ FrameworkunifiedProtocolEvent ns_npp_profile_protocol_handlers[] = {
+ {NPS_PROFILE_NOTIFICATION_REQ, EVENT(evNPProfileNotification)},
+ {NPS_PROFILE_PERSISTENCE_REQ, EVENT(evNPProfilePersistence)},
+ };
+
+ if (eFrameworkunifiedStatusOK == FrameworkunifiedAttachHSMEventsToDispatcher(happ,
+ "NSProfileUtil",
+ ns_npp_profile_protocol_handlers,
+ _countof(ns_npp_profile_protocol_handlers))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Profile info messages are attached to events");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to attach profile info messages to events");
+ }
+
+#endif
+
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedAttachHSMEventsToDispatcher(happ, FRAMEWORKUNIFIED_ANY_SOURCE, ns_npp_protocol_handlers, static_cast<UI_32>(_countof(ns_npp_protocol_handlers))))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ CNSNPP *l_pnsnpp = new(std::nothrow) CNSNPP(happ);
+ if (NULL != l_pnsnpp) { // LCOV_EXCL_BR_LINE 5: new's error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "l_pnsnpp object created");
+
+ if (eFrameworkunifiedStatusOK == (l_estatus = l_pnsnpp->Init(happ))) { // LCOV_EXCL_BR_LINE 200: can't test
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "l_pnsnpp object initialized");
+
+ if (eFrameworkunifiedStatusOK == (l_estatus = l_pnsnpp->FrameworkunifiedCreate())) { // LCOV_EXCL_BR_LINE 200: the result of l_pnsnpp->FrameworkunifiedCreate() is always eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ FrameworkunifiedSetStateMachine(happ, l_pnsnpp);
+
+ l_pnsnpp->FrameworkunifiedStart();
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NSNPP statemachine not created, status: 0x%x", l_estatus); // LCOV_EXCL_LINE 200: the result of l_pnsnpp->FrameworkunifiedCreate() is always eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 200: can't test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pnsnpp object initialization error, status: %d", l_estatus);
+
+ // de-initialize the partially initialize object
+ l_pnsnpp->DeInit(happ);
+
+ delete l_pnsnpp;
+ l_pnsnpp = NULL;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pnsnpp object not created");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedAttachHSMEventsToDispatcher Failed Status:0x%x ", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 4: happ can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Application handle happ is NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE happ) { // LCOV_EXCL_START 14: Resident process, not called by NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnDebugDump
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE happ) { // LCOV_EXCL_START 7: debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+ /// << Dump internal tables!
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE happ) {
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus FrameworkunifiedSSFrameworkInterface(HANDLE happ) {
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnStart
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE happ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnStop
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE happ) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnPreStart
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnPreStop
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnBackgroundStart
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : FrameworkunifiedOnBackgroundStop
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "+", __FUNCTION__);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, "-", __FUNCTION__);
+ return eFrameworkunifiedStatusOK;
+}
+
+extern const FrameworkunifiedDefaultCallbackHandler kDefaultCbHandler = { // NOLINT (readability/naming)
+ FrameworkunifiedOnInitialization,
+ FrameworkunifiedOnDestroy,
+ FrameworkunifiedOnStart,
+ FrameworkunifiedOnStop,
+ FrameworkunifiedOnPreStart,
+ FrameworkunifiedOnPreStop,
+ FrameworkunifiedOnBackgroundStart,
+ FrameworkunifiedOnBackgroundStop,
+ FrameworkunifiedOnDebugDump,
+ FrameworkunifiedCreateStateMachine,
+ FrameworkunifiedSSFrameworkInterface
+}; // LCOV_EXCL_BR_LINE 10: The final line
diff --git a/nsframework/notification_persistent_service/server/src/notificationpersistentservice_main.cpp b/nsframework/notification_persistent_service/server/src/notificationpersistentservice_main.cpp
new file mode 100644
index 00000000..fd963c5f
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/notificationpersistentservice_main.cpp
@@ -0,0 +1,131 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_version.h>
+#include <native_service/ns_version_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+#include <stdlib.h>
+#include <cstdlib>
+#include <iostream>
+
+#include "ns_npp.h" // for static members. Set thread prio.
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_persistence_manager.h" // for static members. Set enable/disable persistence feature.
+
+const CHAR AppName[] = FRAMEWORKUNIFIED_NS_NPSERVICE; // NOLINT (readability/naming)
+CHAR g_csendreadyackto[MAX_QUEUE_NAME_SIZE];
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION); // NOLINT (readability/naming)
+
+// Argument Parser for NSNPP
+EFrameworkunifiedStatus NPPArgumentParser(SI_32 f_iargument, PCHAR f_pargumentvalue);
+
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT (readability/naming)
+ FRAMEWORKUNIFIEDLOGOPTIONS,
+ {
+ ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ ZONE_TEXT_31,
+ },
+ FRAMEWORKUNIFIEDLOGZONES
+};
+
+extern const FrameworkunifiedDefaultCallbackHandler kDefaultCbHandler;
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function : main
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int main(int argc, char *argv[]) {
+ FRAMEWORKUNIFIED_SET_ZONES();
+ CustomCommandLineOptions l_tcmdlineoptions = { "i:e:w:fa:v:", NULL, NPPArgumentParser};
+ EFrameworkunifiedStatus l_estatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv, &kDefaultCbHandler, &l_tcmdlineoptions);
+
+ return static_cast<SI_32>(l_estatus);
+}
+
+EFrameworkunifiedStatus NPPArgumentParser(SI_32 f_iargument, PCHAR f_pargumentvalue) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ SI_32 l_iTmpArgValue = 0;
+ switch (f_iargument) { // LCOV_EXCL_BR_LINE 8: cannot test
+ // Disable Persistence
+ case 'f': {
+ CPersistenceManager::m_bPersistenceDisabled = TRUE;
+ break;
+ }
+ case 'i': {
+ l_iTmpArgValue = atoi(f_pargumentvalue);
+ if (l_iTmpArgValue > 0) { // LCOV_EXCL_BR_LINE 8: cannot test
+ CNSNPP::m_siImmediatePersistenceThreadPrio = l_iTmpArgValue;
+ }
+ break;
+ }
+ case 'e': {
+ l_iTmpArgValue = atoi(f_pargumentvalue);
+ if (l_iTmpArgValue > 0) { // LCOV_EXCL_BR_LINE 8: cannot test
+ CNSNPP::m_siReadThreadPrio = l_iTmpArgValue;
+ }
+ break;
+ }
+ case 'w': {
+ l_iTmpArgValue = atoi(f_pargumentvalue);
+ if (l_iTmpArgValue > 0) { // LCOV_EXCL_BR_LINE 8: cannot test
+ CNSNPP::m_siWriteThreadPrio = l_iTmpArgValue;
+ }
+ break;
+ }
+ case 'a': {
+ std::memset(g_csendreadyackto, 0, MAX_QUEUE_NAME_SIZE);
+ std::strncpy(g_csendreadyackto, f_pargumentvalue, (MAX_QUEUE_NAME_SIZE - 1));
+ break;
+ }
+ case 'v': {
+ l_iTmpArgValue = atoi(f_pargumentvalue);
+ CNSNPP::m_siCRCCheckCount = static_cast<UI_16>(l_iTmpArgValue);
+ break;
+ }
+
+ default:
+ l_estatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp.cpp b/nsframework/notification_persistent_service/server/src/ns_npp.cpp
new file mode 100644
index 00000000..25b64432
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp.cpp
@@ -0,0 +1,1149 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <time.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/timeb.h>
+#include <sys/types.h>
+
+#include <native_service/frameworkunified_sm_leafstate.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/ns_np_service_protocol.h>
+
+#include <string>
+#include <vector>
+
+#include <native_service/ns_np_service_nor_persistence_internal.h>
+#include "app_states.h"
+#include "ns_npp.h"
+#include "ns_npp_types.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_threads.h"
+#include "ns_npp_copy_worker.h"
+#include "ns_npp_fs_directory.h"
+#include "ns_npp_persist_folder.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_persistence_manager.h"
+#include "ns_npp_notification_manager.h"
+#include "ns_npp_personalization_manager.h"
+#include "ns_npp_nor_persistence_worker_thread.h"
+
+#define NPP_VERSION_INVALID 255
+#define NPP_VERSION_0 0
+#define NPP_VERSION_1 1
+
+#define NPP_CONNECT_DEFAULTSTATE(parent, child) \
+ FrameworkunifiedConnect(l_p## parent, l_p## child, TRUE);
+
+#define NPP_CONNECT_STATE(parent, child) \
+ FrameworkunifiedConnect(l_p## parent, l_p## child);
+
+#define NPP_CONNECT_DEFERREDEVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid, TRUE); \
+
+#define NPP_CONNECT_EVENT(state, eventid, reaction) \
+ FrameworkunifiedConnect(l_p## state, _## eventid, l_pTrn## reaction, #eventid);
+
+#define NPP_CONNECTROOT(state) \
+ FrameworkunifiedConnect(l_p## state);
+
+#define NPP_CONNECT_ORTHOGONAL_REGION(orthogonalstate, orthogonalregion) \
+ FrameworkunifiedConnectOrthogonal(l_p## orthogonalstate, l_p## orthogonalregion);
+
+#define NPP_CREATE_STATE(class_name) \
+ C## class_name *l_p## class_name = new (std::nothrow) C## class_name(#class_name);
+
+#define NPP_PRINTSTATEMACHINE() \
+ FrameworkunifiedPrintAllStates();
+
+// typedef of vector of CNotificationsToPersist
+typedef std::vector<CNotificationsToPersist *> Persistent_Notification_List_Type;
+
+// iterator for CNotificationsToPersist vector
+typedef Persistent_Notification_List_Type::iterator Persistent_Notification_List_Iterator;
+
+// initialize static variables
+SI_32 CNSNPP::m_siWriteThreadPrio = NS_NPP_WRITE_THREAD_PRIO;
+SI_32 CNSNPP::m_siReadThreadPrio = NS_NPP_READ_THREAD_PRIO;
+SI_32 CNSNPP::m_siImmediatePersistenceThreadPrio = NS_NPP_IMMEDIATE_PERSIST_THREAD_PRIO;
+UI_16 CNSNPP::m_siCRCCheckCount = 0;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSNPP
+/// Class Constructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNSNPP::CNSNPP(PVOID f_happ) : CFrameworkunifiedHSM(f_happ),
+ m_cReadThreadName(NS_NPP_READ_THREAD_NAME),
+ m_cWriteThreadName(NS_NPP_WRITE_THREAD_NAME),
+ m_cImmediatePersistenceThreadName(NS_NPP_IMMEDIATE_PERSIST_THREAD_NAME) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_hNSReadThread = NULL;
+ m_hNSWriteThread = NULL;
+ m_hNSImmediatePersistenceThread = NULL;
+
+ m_pNotificationManager = NULL;
+ m_pPersonalizationManager = NULL;
+ m_pPersistenceManager = NULL;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNSNPP
+/// Class Destructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNSNPP::~CNSNPP() { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pNotificationManager) {
+ delete m_pNotificationManager;
+ m_pNotificationManager = NULL;
+ }
+
+ if (NULL != m_pPersonalizationManager) {
+ delete m_pPersonalizationManager;
+ m_pPersonalizationManager = NULL;
+ }
+ if (NULL != m_pPersistenceManager) {
+ delete m_pPersistenceManager;
+ m_pPersistenceManager = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Init
+/// This function is used to allocate dynamic memory for member variables of this class after
+/// creation of object.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::Init(HANDLE f_happ) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FrameworkunifiedProtocolEvent ns_npp_internal_protocol_handlers[] = {
+ {CP_WRK_NTFY, EVENT(evNPReleaseLoadAck)}
+ };
+
+ FrameworkunifiedProtocolEvent immediate_thread_protocol_handlers[] = {
+ {NOR_PERSISTENCE_ONSHUTDOWN_ACK, EVENT(evNPNorShutdownAck)},
+ };
+
+ UI_32 l_uiNPPVersion = NPP_VERSION_INVALID;
+
+ // initialize Notification Manager
+ m_pNotificationManager = new(std::nothrow) CNotificationManager();
+ // initialize Personalization Manager
+ m_pPersonalizationManager = new(std::nothrow) CnotificationpersistentservicePersonalizationManager();
+ // initialize Persistence Manager
+ m_pPersistenceManager = new(std::nothrow) CPersistenceManager();
+
+ if ((NULL == f_happ) || (NULL == m_pNotificationManager) || (NULL == m_pPersonalizationManager) || (NULL == m_pPersistenceManager)) { // LCOV_EXCL_BR_LINE 5: f_happ, m_pNotificationManager, m_pPersonalizationManager, m_pPersistenceManager can't be NULL // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: f_happ, m_pNotificationManager, m_pPersonalizationManager, m_pPersistenceManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "f_happ or m_pNotificationManager or m_pPersonalizationManager or m_pPersistenceManager is NULL");
+
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ if ((eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbackToDispatcher( // LCOV_EXCL_BR_LINE 4: NSFW error case
+ f_happ, m_cReadThreadName.c_str(),
+ CP_WRK_ACK_CMD_COMPLETE,
+ NPServiceOnCpWorkerAckCmd))
+ || (eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbackToDispatcher(
+ f_happ, m_cWriteThreadName.c_str(),
+ CP_WRK_ACK_CMD_COMPLETE,
+ NPServiceOnCpWorkerAckCmd))
+ || (eFrameworkunifiedStatusOK != FrameworkunifiedAttachHSMEventsToDispatcher(
+ f_happ, m_cWriteThreadName.c_str(),
+ ns_npp_internal_protocol_handlers,
+ static_cast<UI_32>(_countof(ns_npp_internal_protocol_handlers))))
+ || (eFrameworkunifiedStatusOK != FrameworkunifiedAttachHSMEventsToDispatcher(
+ f_happ, m_cReadThreadName.c_str(),
+ ns_npp_internal_protocol_handlers,
+ static_cast<UI_32>(_countof(ns_npp_internal_protocol_handlers))))
+ || (eFrameworkunifiedStatusOK != FrameworkunifiedAttachHSMEventsToDispatcher(
+ f_happ, m_cImmediatePersistenceThreadName.c_str(),
+ immediate_thread_protocol_handlers,
+ static_cast<UI_32>(_countof(immediate_thread_protocol_handlers))))) {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Attaching callbacks and events failed for protocols CP_WRK_ACK_CMD_COMPLETE, CP_WRK_NTFY");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ l_estatus = CreateAndStartChildThreads(f_happ);
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ if (NPP_VERSION_INVALID != (l_uiNPPVersion = GetNSNPPVersion())) { // LCOV_EXCL_BR_LINE 6: l_uiNPPVersion can't be NPP_VERSION_INVALID // NOLINT[whitespace/line_length]
+ if (NPP_VERSION_0 == l_uiNPPVersion) {
+ l_estatus = SwitchToFileStructureVersion1(l_uiNPPVersion + 1);
+
+ l_estatus = SwitchToFileStructureVersion2(l_uiNPPVersion + 2);
+ } else if (NPP_VERSION_1 == l_uiNPPVersion) { // LCOV_EXCL_BR_LINE 200: cannot test code in init sequence
+ // LCOV_EXCL_START 200: cannot test code in init sequence
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = SwitchToFileStructureVersion2(l_uiNPPVersion + 1);
+
+ // send the message to write worker thread to delete the persistent
+ /// which was requested for deletion during previous shutdown
+ l_estatus = FrameworkunifiedSendChild(f_happ, m_hNSWriteThread, CMD_DELETE_OLD_DATA, 0, NULL);
+ // LCOV_EXCL_STOP
+ } else {
+ // send the message to write worker thread to delete the persistent
+ /// which was requested for deletion during previous shutdown
+ l_estatus = FrameworkunifiedSendChild(f_happ, m_hNSWriteThread, CMD_DELETE_OLD_DATA, 0, NULL);
+ }
+
+ // Try to load persisted notification data
+ NotificationpersistentserviceLoadPersistentNotificationData(eFrameworkunifiedPersistedStateVar);
+
+ // load immediate persistence data as the respective thread is now started.
+ NotificationpersistentserviceLoadPersistentNotificationData(eFrameworkunifiedImmediatePersistedStateVar);
+ } else {
+ // LCOV_EXCL_START 6: l_uiNPPVersion can't be NPP_VERSION_INVALID
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid version of NPPService");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in creating child threads of NPPService"); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DeInit
+/// This function is used to deinitialize the NPP object
+////////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CNSNPP::DeInit(HANDLE f_happ) { // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pNotificationManager) {
+ delete m_pNotificationManager;
+ m_pNotificationManager = NULL;
+ }
+
+ if (NULL != m_pPersonalizationManager) {
+ delete m_pPersonalizationManager;
+ m_pPersonalizationManager = NULL;
+ }
+
+ if (NULL != m_pPersistenceManager) {
+ delete m_pPersistenceManager;
+ m_pPersistenceManager = NULL;
+ }
+
+ if (NULL != f_happ) {
+ EFrameworkunifiedStatus eStatus;
+
+ if (NULL != m_hNSReadThread) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedStopChildThread(f_happ, m_hNSReadThread, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedStopChildThread Read Thread Failed. status=%d", eStatus);
+ }
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDestroyChildThread(f_happ, m_hNSReadThread))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedDestroyChildThread Read Thread Failed. status=%d", eStatus);
+ }
+ m_hNSReadThread = NULL;
+ }
+
+ if (NULL != m_hNSWriteThread) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedStopChildThread(f_happ, m_hNSWriteThread, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedStopChildThread Write Thread Failed. status=%d", eStatus);
+ }
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDestroyChildThread(f_happ, m_hNSWriteThread))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedDestroyChildThread Write Thread Failed. status=%d", eStatus);
+ }
+ m_hNSWriteThread = NULL;
+ }
+
+ if (NULL != m_hNSImmediatePersistenceThread) {
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedStopChildThread(f_happ, m_hNSImmediatePersistenceThread, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedStopChildThread ImmidatePersistence Thread Failed. status=%d", eStatus);
+ }
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDestroyChildThread(f_happ, m_hNSImmediatePersistenceThread))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedDestroyChildThread ImmidatePersistence Thread Failed. status=%d", eStatus);
+ }
+ m_hNSImmediatePersistenceThread = NULL;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SwitchToFileStructureVersion1
+/// Copy all the user data from old persistent path to new persistent path i.e. UserData folder
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::SwitchToFileStructureVersion1(const UI_32 f_uinppversion) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string l_cSrcPath = "";
+ std::string l_cDestPath = "";
+
+ std::string l_cNSNPSPath = CPersistence::GetStoragePath();
+ std::string l_cUserDataPath = "";
+
+ if (CFSDirectory::DoesDirecotryExist(l_cNSNPSPath)) { // LCOV_EXCL_BR_LINE 6: l_cNSNPSPath must exist
+ DIR *l_pdir = NULL;
+
+ struct dirent *l_pdirent = NULL;
+
+ l_pdir = opendir(l_cNSNPSPath.c_str());
+
+ if (NULL != l_pdir) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ if (l_cNSNPSPath[l_cNSNPSPath.length() - 1] != '/') { // LCOV_EXCL_BR_LINE 6: l_cNSNPSPath must has '/'
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_cNSNPSPath.append("/"); // LCOV_EXCL_LINE 6: l_cNSNPSPath must has '/'
+ }
+
+ // set the userdata folder path
+ l_cUserDataPath.assign(l_cNSNPSPath);
+ l_cUserDataPath.append(USERDATADIR);
+ l_cUserDataPath.append(ALLUSERAPPDATADIR);
+
+ // create the userdata directory
+ if (!CFSDirectory::DoesDirecotryExist(l_cUserDataPath)) {
+ l_estatus = CFSDirectory::CreateDirectory(l_cUserDataPath);
+ }
+
+ // if directory successfully created or is already present on target
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus must be eFrameworkunifiedStatusOK
+ while (NULL != (l_pdirent = readdir(l_pdir))) {
+ if (0 != std::strcmp(l_pdirent->d_name, ".") &&
+ 0 != std::strcmp(l_pdirent->d_name, "..") &&
+ 0 != std::strcmp(l_pdirent->d_name, AppName) &&
+ 0 != std::strcmp(l_pdirent->d_name, USERDATA)) {
+ l_cSrcPath.assign(l_cNSNPSPath.c_str());
+ l_cSrcPath.append(l_pdirent->d_name);
+
+ if (CFSDirectory::IsDirectory(l_cSrcPath)) { // LCOV_EXCL_BR_LINE 6: cannot test in init sequence
+ l_cDestPath.assign(l_cUserDataPath);
+ l_cDestPath.append(l_pdirent->d_name);
+
+ // move the old app user data to the UserData fodler
+ if (0 != rename(l_cSrcPath.c_str(), l_cDestPath.c_str())) { // LCOV_EXCL_BR_LINE 6: rename must return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: rename must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error renaming folder %s to %s",
+ l_cSrcPath.c_str(), l_cDestPath.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to create directory:: %s", l_cDestPath.c_str()); // LCOV_EXCL_LINE 6: l_estatus must be eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ }
+
+ closedir(l_pdir); // close the directory
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pdir is NULL");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ l_estatus = SetNSNPPVersion(static_cast<UI_8>(f_uinppversion));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SwitchToFileStructureVersion2
+/// Move immediate notification data files from IMMEDIATE_PERSISTENCE_STORAGE_V1 to
+/// IMMEDIATE_PERSISTENCE_STORAGE_V2/AllUserAppData/UserData
+//// ////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::SwitchToFileStructureVersion2(const UI_32 f_uinppversion) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // immediate notification persistent path for NPPService version 1
+ std::string l_cSrcDir = IMMEDIATE_PERSISTENCE_STORAGE_V1;
+
+ // immediate notification persistent path for NPPService version 2
+ std::string l_cDestDir = IMMEDIATE_PERSISTENCE_STORAGE_V2;
+ l_cDestDir.append(USERDATADIR);
+ l_cDestDir.append(ALLUSERAPPDATADIR);
+ l_cDestDir.append(IMMEDIATEDATADIR);
+
+ if (eFrameworkunifiedStatusOK == (l_estatus = SynchronousMovePersistentData(l_cSrcDir.c_str(), l_cDestDir.c_str()))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ if (!CFSDirectory::RemoveDirectory(l_cSrcDir)) { // LCOV_EXCL_BR_LINE 6: cannot test in init sequence
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error deleting old immediate pers. dir %s", l_cSrcDir.c_str());
+ }
+
+ l_estatus = SetNSNPPVersion(static_cast<UI_8>(f_uinppversion));
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SynchronousMovePersistentData faiure, status=%d", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+/// GetNSNPPVersion
+/// Get the version of NSNPP from version.txt
+///////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CNSNPP::GetNSNPPVersion() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ UI_32 l_uiVersion = NPP_VERSION_INVALID;
+ CHAR l_cVerStr[3] = {};
+ FILE *l_pFile = NULL;
+
+ std::string l_cVersion = CPersistence::GetStoragePath();
+ if (l_cVersion[l_cVersion.length() - 1] != '/') { // LCOV_EXCL_BR_LINE 6: must has '/'
+ l_cVersion += "/";
+ }
+ l_cVersion.append(VERSION_TXT);
+
+ if (NULL != (l_pFile = fopen(l_cVersion.c_str(), "r"))) {
+ // read the version from file
+ if (NULL == fgets(l_cVerStr, 2, l_pFile)) { // LCOV_EXCL_BR_LINE 6: can't return NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "File empty: %s", l_cVersion.c_str()); // LCOV_EXCL_LINE 6: can't return NULL
+ } else {
+ errno = EOK;
+ l_uiVersion = static_cast<UI_32>(strtol(l_cVerStr, NULL, 10));
+
+ if (EOK != errno) { // LCOV_EXCL_BR_LINE 6: errno always is EOK
+ // LCOV_EXCL_START 6: errno always is EOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error converting string %s to hex, errno=%d", l_cVerStr, errno);
+ l_uiVersion = NPP_VERSION_0;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ fclose(l_pFile);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to open file: %s, errno=%d", l_cVersion.c_str(), errno);
+ l_uiVersion = NPP_VERSION_0;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_uiVersion;
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// Syncfs
+/// Syncfs is carried out.
+///
+/// \param
+///
+/// \return EFrameworkunifiedStatus
+/// EFrameworkunifiedStatus - Returns status of operation
+///
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::Syncfs() {
+ int dfd;
+
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string l_cPath = CPersistence::GetStoragePath();
+
+ // create the file
+ dfd = open(l_cPath.c_str(), O_RDONLY | O_DIRECTORY);
+ if (-1 != dfd) {
+ // syncfs()
+ if (syncfs(dfd) < 0) { // LCOV_EXCL_BR_LINE 5: syncfs's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to syncfs: %s errno=%d", l_cPath.c_str(), errno); // LCOV_EXCL_LINE 5: syncfs's error case. // NOLINT[whitespace/line_length]
+ }
+ close(dfd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to open file: %s serrno=%d", l_cPath.c_str(), errno);
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+///////////////////////////////////////////////////////////////////////////////////////////
+/// SetNSNPPVersion
+/// Set the version of NSNPP in version.txt
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::SetNSNPPVersion(UI_8 f_uiversion) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FILE *l_pFile = NULL;
+
+ std::string l_cVersion = CPersistence::GetStoragePath();
+ if (l_cVersion[l_cVersion.length() - 1] != '/') { // LCOV_EXCL_BR_LINE 6: must has '/'
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_cVersion += "/"; // LCOV_EXCL_LINE 6: must has '/'
+ }
+ if (!CFSDirectory::DoesDirecotryExist(l_cVersion)) {
+ CFSDirectory::CreateDirectory(l_cVersion);
+ }
+
+ l_cVersion.append(VERSION_TXT);
+
+ // create the file and write
+ l_pFile = fopen(l_cVersion.c_str(), "w");
+ if (NULL != l_pFile) { // LCOV_EXCL_BR_LINE 6: l_pFile can't be NULL
+ // write the version to file
+ fprintf(l_pFile, "%d", f_uiversion);
+ fclose(l_pFile);
+ } else {
+ // LCOV_EXCL_START 6: l_pFile can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to open file: %s", l_cVersion.c_str());
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// FrameworkunifiedCreate
+/// In this function, states and events of StateMachine are created and connected.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::FrameworkunifiedCreate(PVOID f_peventdata) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // ========Create states
+ NPP_CREATE_STATE(sNotificationpersistentserviceNPPRoot)
+ NPP_CREATE_STATE(sNotificationpersistentserviceNPPStart)
+ NPP_CREATE_STATE(sNotificationpersistentserviceNPPError)
+
+ CREATE_ORTHOGONALREGION(sNotificationpersistentservicePersistence)
+ CREATE_ORTHOGONALREGION(sNotificationpersistentserviceShutdown)
+ CREATE_ORTHOGONALREGION(sNotificationpersistentserviceNotification)
+
+ NPP_CREATE_STATE(sNotificationpersistentservicePersistenceReady)
+ NPP_CREATE_STATE(sNotificationpersistentservicePersistenceError)
+
+ NPP_CREATE_STATE(sNotificationpersistentserviceNotificationReady)
+ NPP_CREATE_STATE(sNotificationpersistentserviceNotificationError)
+
+ NPP_CREATE_STATE(sNotificationpersistentserviceShutdownIdle)
+ NPP_CREATE_STATE(sNotificationpersistentserviceShutdownDataSave)
+
+ // ========Connect states
+ NPP_CONNECT_DEFAULTSTATE(sNotificationpersistentserviceNPPRoot, sNotificationpersistentserviceNPPStart)
+ NPP_CONNECT_STATE(sNotificationpersistentserviceNPPRoot, sNotificationpersistentserviceNPPStart)
+ NPP_CONNECT_STATE(sNotificationpersistentserviceNPPRoot, sNotificationpersistentserviceNPPError)
+
+ NPP_CONNECT_ORTHOGONAL_REGION(sNotificationpersistentserviceNPPStart, sNotificationpersistentservicePersistence)
+ NPP_CONNECT_ORTHOGONAL_REGION(sNotificationpersistentserviceNPPStart, sNotificationpersistentserviceShutdown)
+ NPP_CONNECT_ORTHOGONAL_REGION(sNotificationpersistentserviceNPPStart, sNotificationpersistentserviceNotification)
+
+ NPP_CONNECT_DEFAULTSTATE(sNotificationpersistentservicePersistence, sNotificationpersistentservicePersistenceReady)
+ NPP_CONNECT_STATE(sNotificationpersistentservicePersistence, sNotificationpersistentservicePersistenceError)
+
+ NPP_CONNECT_DEFAULTSTATE(sNotificationpersistentserviceShutdown, sNotificationpersistentserviceShutdownIdle)
+ NPP_CONNECT_STATE(sNotificationpersistentserviceShutdown, sNotificationpersistentserviceShutdownDataSave)
+
+ NPP_CONNECT_DEFAULTSTATE(sNotificationpersistentserviceNotification, sNotificationpersistentserviceNotificationReady)
+ NPP_CONNECT_STATE(sNotificationpersistentserviceNotification, sNotificationpersistentserviceNotificationError)
+
+ // ========Create external transitions
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentserviceNPPStart)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentserviceNPPError)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentservicePersistenceReady)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentservicePersistenceError)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentserviceShutdownIdle)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentserviceShutdownDataSave)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentserviceNotificationReady)
+ CREATE_EXTERNALTRANSITION(sNotificationpersistentserviceNotificationError)
+
+ // ========Create internal transitions
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPReadPersistedData)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPReleaseFileAck)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnUserChange)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPNorDataSaveAck)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFile)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFile)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFile)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFolder)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFolder)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFolder)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFilePersistentType)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFolderPersistentType)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPPersistentSync)
+
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPShutdown)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnShutdownTimeout)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceCheckAllReleaseRequestsProcessed)
+
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishNotification)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterNotifications)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotification)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotifications)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnRegisterNotifications)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotification)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotifications)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPGetReadyStatus)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterImmediateNotifications)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPClearPersistedData)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetDefaultPersistentData)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetNotfnPersistentType)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishImmediateNotification)
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfileNotifications)
+ CREATE_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfilePersistence)
+
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPProfileNotification, NotificationpersistentserviceOnNPProfileNotifications)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPProfilePersistence, NotificationpersistentserviceOnNPProfilePersistence)
+
+#endif
+
+ // ========Connect events
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNPPRoot, evNPClearPersistedData, NotificationpersistentserviceOnNPClearPersistedData)
+
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNPPStart, evError, sNotificationpersistentserviceNPPError)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNPPError, evReady, sNotificationpersistentserviceNPPStart)
+
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evError, sNotificationpersistentservicePersistenceError)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceError, evReady, sNotificationpersistentservicePersistenceReady)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPReadPersistedData, NotificationpersistentserviceOnNPReadPersistedData)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPReleaseLoadAck, NotificationpersistentserviceOnNPReleaseFileAck)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPRegisterPersistentFile, NotificationpersistentserviceOnRegisterPersistentFile)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPReleasePersistentFile, NotificationpersistentserviceOnReleasePersistentFile)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPLoadPersistentFile, NotificationpersistentserviceOnLoadPersistentFile)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPRegisterPersistentFolder, NotificationpersistentserviceOnRegisterPersistentFolder)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPLoadPersistentFolder, NotificationpersistentserviceOnLoadPersistentFolder)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPReleasePersistentFolder, NotificationpersistentserviceOnReleasePersistentFolder)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPGetReadyStatus, NotificationpersistentserviceOnNPGetReadyStatus)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPSetFilePersistentType, NotificationpersistentserviceOnNPSetFilePersistentType)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPSetFolderPersistentType, NotificationpersistentserviceOnNPSetFolderPersistentType)
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evNPPersistentSync, NotificationpersistentserviceOnNPPersistentSync)
+
+ NPP_CONNECT_EVENT(sNotificationpersistentservicePersistenceReady, evUserChange, NotificationpersistentserviceOnUserChange)
+
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceShutdownIdle, evShutdown, NotificationpersistentserviceOnNPShutdown)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceShutdownIdle, evNPShutdownDataSave, sNotificationpersistentserviceShutdownDataSave)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceShutdownDataSave, evIdle, sNotificationpersistentserviceShutdownIdle)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceShutdownDataSave, evShutdownTimeout, NotificationpersistentserviceOnShutdownTimeout)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceShutdownDataSave, evCheckAllFilesPersisted, NotificationpersistentserviceCheckAllReleaseRequestsProcessed)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceShutdownDataSave, evNPNorShutdownAck, NotificationpersistentserviceOnNPNorDataSaveAck)
+
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evError, sNotificationpersistentserviceNotificationError)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationError, evReady, sNotificationpersistentserviceNotificationReady)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPPublishNotification, NotificationpersistentserviceOnNPPublishNotification)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPRegisterNotifications, NotificationpersistentserviceOnNPRegisterNotifications)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPSubscribeToNotification, NotificationpersistentserviceOnNPSubscribeToNotification)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPSubscribeToNotifications, NotificationpersistentserviceOnNPSubscribeToNotifications)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPUnRegisterNotifications, NotificationpersistentserviceOnNPUnRegisterNotifications)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPUnSubscribeFromNotification, NotificationpersistentserviceOnNPUnSubscribeFromNotification)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPUnSubscribeFromNotifications, NotificationpersistentserviceOnNPUnSubscribeFromNotifications)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPRegisterImmediateNotifications, NotificationpersistentserviceOnNPRegisterImmediateNotifications)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPSetDefaultPersistentData, NotificationpersistentserviceOnNPSetDefaultPersistentData)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPSetNotfnPersistentType, NotificationpersistentserviceOnNPSetNotfnPersistentType)
+ NPP_CONNECT_EVENT(sNotificationpersistentserviceNotificationReady, evNPPublishImmediateNotification, NotificationpersistentserviceOnNPPublishImmediateNotification)
+
+ NPP_CONNECTROOT(sNotificationpersistentserviceNPPRoot)
+
+ NPP_PRINTSTATEMACHINE() // NOLINT (whitespace/empty_if_body)
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentservicePersistAll
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::NotificationpersistentservicePersistAll(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedQuickShutdown == f_eshutdowntype) {
+ if (NULL != m_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: m_pPersistenceManager can't be NULL
+ // set all file persisted status as TRUE
+ m_pPersistenceManager->SetFilePersistedStatus(TRUE);
+
+ // send request to immediate persistence thread to stop all the immediate notification timer
+ m_pPersistenceManager->PersistNORData(f_eshutdowntype, f_uinotificationpersistentservicepersistcategoryflag);
+ }
+ } else {
+ if (eFrameworkunifiedNormalShutdown == f_eshutdowntype) {
+ f_uinotificationpersistentservicepersistcategoryflag = 0x0;
+ }
+
+ // save global notification data of persisted state notification
+ if (eFrameworkunifiedStatusOK != NotificationpersistentserviceSaveNotificationPersistentData(eFrameworkunifiedPersistedStateVar, f_uinotificationpersistentservicepersistcategoryflag)) { // LCOV_EXCL_BR_LINE 6: NotificationpersistentserviceSaveNotificationPersistentData will always return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: NotificationpersistentserviceSaveNotificationPersistentData will always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while saving notification persistent data.");
+ // LCOV_EXCL_STOP
+ }
+
+ // save user notification data for the current user
+ if (eFrameworkunifiedStatusOK != NotificationpersistentserviceSaveNotificationPersistentData(eFrameworkunifiedPersistedStateUserVar, f_uinotificationpersistentservicepersistcategoryflag)) { // LCOV_EXCL_BR_LINE 6: NotificationpersistentserviceSaveNotificationPersistentData will always return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: NotificationpersistentserviceSaveNotificationPersistentData will always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while saving user notification persistent data.");
+ // LCOV_EXCL_STOP
+ }
+
+ // NOR data is saved immediately,
+ // but during shutdown it can be possible that because of delay in consecutive save to NOR
+ // the latest data may not get persisted. So if we get shutdown we will need to persist the data immediately.
+ if (NULL != m_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: m_pPersistenceManager can't be NULL
+ m_pPersistenceManager->PersistNORData(f_eshutdowntype, f_uinotificationpersistentservicepersistcategoryflag);
+ }
+
+ // delete all persistent files and folders for all applications
+ if ((eFrameworkunifiedUserData | eFrameworkunifiedFactoryData | eFrameworkunifiedFactoryCustomerData | eFrameworkunifiedDealerData) == f_uinotificationpersistentservicepersistcategoryflag) {
+ if (NULL != m_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: m_pPersistenceManager can't be NULL
+ m_pPersistenceManager->SetFilePersistedStatus(TRUE);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: m_pPersistenceManager can't be NULL
+ }
+ } else {
+ // writes the temporary global and user files to permanent memory
+ if (m_pPersistenceManager) { // LCOV_EXCL_BR_LINE 6: m_pPersistenceManager can't be NULL
+ if (eFrameworkunifiedStatusOK == m_pPersistenceManager->PersistAllReleaseRequests(f_uinotificationpersistentservicepersistcategoryflag)) { // LCOV_EXCL_BR_LINE 6: PersistAllReleaseRequests will always return ok // NOLINT[whitespace/line_length]
+ // this is needed to check in case when there are no file to persist
+ if (TRUE == m_pPersistenceManager->HaveAllReleaseRequestsPersisted()) { // LCOV_EXCL_BR_LINE 6: HaveAllReleaseRequestsPersisted will always return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: HaveAllReleaseRequestsPersisted will always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All file release requests processed");
+ m_pPersistenceManager->SetFilePersistedStatus(TRUE);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: PersistAllReleaseRequests will always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while persisting temporary files.");
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DeletePersistedDataFolder
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::DeletePersistedDataFolder(UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ struct timeb timebuf;
+ struct tm *theTime;
+
+ ftime(&timebuf);
+ theTime = gmtime(&timebuf.time); // NOLINT (runtime/threadsafe_fn)
+
+ // get the current date and time to append to the folder name
+ PCHAR l_cDateTime = new CHAR[MAX_STRING_SIZE_TAG];
+ snprintf(l_cDateTime, MAX_STRING_SIZE_TAG, "_%02d%02d%02d_%02d%02d%02d", theTime->tm_mon + 1, theTime->tm_mday,
+ theTime->tm_year + 1900, theTime->tm_hour, theTime->tm_min, theTime->tm_sec);
+
+ std::string l_cBasePath = CPersistence::GetStoragePath();
+ std::string l_cSrcPath = "";
+ std::string l_cDestPath = "";
+
+ if (eFrameworkunifiedUserData == (eFrameworkunifiedUserData & f_uinotificationpersistentservicepersistcategoryflag)) {
+ l_cSrcPath.assign(l_cBasePath);
+ l_cSrcPath.append(USERDATA);
+
+ if (CFSDirectory::DoesDirecotryExist(l_cSrcPath)) {
+ l_cDestPath.assign(l_cSrcPath);
+ l_cDestPath.append(l_cDateTime);
+
+ // instead of deleting the data, rename the persistence folder before shutdown
+ if (0 != rename(l_cSrcPath.c_str(), l_cDestPath.c_str())) { // LCOV_EXCL_BR_LINE 6: rename must return ok
+ // LCOV_EXCL_START 6: rename must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error renaming folder %s to %s, errno = %d",
+ l_cSrcPath.c_str(),
+ l_cDestPath.c_str(),
+ errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ if (eFrameworkunifiedFactoryData == (eFrameworkunifiedFactoryData & f_uinotificationpersistentservicepersistcategoryflag)) {
+ l_cSrcPath.assign(l_cBasePath);
+ l_cSrcPath.append(FACTORYDATA);
+
+ if (CFSDirectory::DoesDirecotryExist(l_cSrcPath)) {
+ l_cDestPath.assign(l_cSrcPath);
+ l_cDestPath.append(l_cDateTime);
+
+ // instead of deleting the data, rename the persistence folder before shutdown
+ if (0 != rename(l_cSrcPath.c_str(), l_cDestPath.c_str())) { // LCOV_EXCL_BR_LINE 6: rename must return ok
+ // LCOV_EXCL_START 6: rename must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error renaming folder %s to %s, errno = %d",
+ l_cSrcPath.c_str(),
+ l_cDestPath.c_str(),
+ errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ if (eFrameworkunifiedFactoryCustomerData == (eFrameworkunifiedFactoryCustomerData & f_uinotificationpersistentservicepersistcategoryflag)) {
+ l_cSrcPath.assign(l_cBasePath);
+ l_cSrcPath.append(FACTORYCUSTOMERDATA);
+
+ if (CFSDirectory::DoesDirecotryExist(l_cSrcPath)) {
+ l_cDestPath.assign(l_cSrcPath);
+ l_cDestPath.append(l_cDateTime);
+
+ // instead of deleting the data, rename the persistence folder before shutdown
+ if (0 != rename(l_cSrcPath.c_str(), l_cDestPath.c_str())) { // LCOV_EXCL_BR_LINE 6: rename must return ok
+ // LCOV_EXCL_START 6: rename must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error renaming folder %s to %s, errno = %d",
+ l_cSrcPath.c_str(),
+ l_cDestPath.c_str(),
+ errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ if (eFrameworkunifiedDealerData == (eFrameworkunifiedDealerData & f_uinotificationpersistentservicepersistcategoryflag)) {
+ l_cSrcPath.assign(l_cBasePath);
+ l_cSrcPath.append(DEALERDATA);
+
+ if (CFSDirectory::DoesDirecotryExist(l_cSrcPath)) {
+ l_cDestPath.assign(l_cSrcPath);
+ l_cDestPath.append(l_cDateTime);
+
+ // instead of deleting the data, rename the persistence folder before shutdown
+ if (0 != rename(l_cSrcPath.c_str(), l_cDestPath.c_str())) { // LCOV_EXCL_BR_LINE 6: rename must return ok
+ // LCOV_EXCL_START 6: rename must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error renaming folder %s to %s, errno = %d",
+ l_cSrcPath.c_str(),
+ l_cDestPath.c_str(),
+ errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+
+ if (NULL != l_cDateTime) { // LCOV_EXCL_BR_LINE 6: l_cDateTime can't be NULL
+ delete[] l_cDateTime;
+ l_cDateTime = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSaveNotificationPersistentData
+/// In this function, all the data related to persistent notification is retrieved from
+/// notification manager and stored in persistent file by persistent manager.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::NotificationpersistentserviceSaveNotificationPersistentData(EFrameworkunifiedNotificationType f_epersistenttype,
+ UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // pointer of Notification Manager
+ CNotificationManager *l_pNotificationManager = NULL;
+
+ // pointer of Persistence Manager
+ CPersistenceManager *l_pCNotificationpersistentservicePersistenceManager = NULL;
+
+ Persistent_Notification_List_Type *l_vPersistentNotificationList = NULL;
+
+ // get the instance of notification manager
+ l_pNotificationManager = m_pNotificationManager;
+
+ // get the instance of persistence manager
+ l_pCNotificationpersistentservicePersistenceManager = m_pPersistenceManager;
+
+ if (NULL != l_pNotificationManager && NULL != l_pCNotificationpersistentservicePersistenceManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager and l_pCNotificationpersistentservicePersistenceManager can't be NULL // NOLINT[whitespace/line_length]
+ // create new vector to retrieve persistent notification data
+ l_vPersistentNotificationList = new(std::nothrow) Persistent_Notification_List_Type();
+
+ if (NULL != l_vPersistentNotificationList) { // LCOV_EXCL_BR_LINE 5: l_vPersistentNotificationList can't be NULL
+ // get all the persistent notification data in vector from notification manager
+ l_pNotificationManager->NotificationpersistentserviceGetPersistentNotificationData(l_vPersistentNotificationList,
+ f_epersistenttype,
+ f_uinotificationpersistentservicepersistcategoryflag);
+ } else {
+ // LCOV_EXCL_START 5: l_vPersistentNotificationList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_vPersistentNotificationList is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ if (NULL != l_vPersistentNotificationList) { // LCOV_EXCL_BR_LINE 5: l_vPersistentNotificationList can't be NULL
+ if (eFrameworkunifiedPersistedStateVar == f_epersistenttype) {
+ // save persistent notification data from vector to file
+ l_estatus = l_pCNotificationpersistentservicePersistenceManager->NotificationpersistentserviceSaveNotificationData(l_vPersistentNotificationList);
+ } else if (eFrameworkunifiedPersistedStateUserVar == f_epersistenttype) { // LCOV_EXCL_BR_LINE 200: f_epersistenttype must be eFrameworkunifiedPersistedStateVar or eFrameworkunifiedPersistedStateUserVar // NOLINT[whitespace/line_length]
+ l_estatus = l_pCNotificationpersistentservicePersistenceManager->NotificationpersistentserviceSaveUserNotificationData(l_vPersistentNotificationList);
+ } else {
+ // LCOV_EXCL_START 200: f_epersistenttype must be eFrameworkunifiedPersistedStateVar or eFrameworkunifiedPersistedStateUserVar
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Save data for %d PersistentVarType not supported", f_epersistenttype);
+ // LCOV_EXCL_STOP
+ }
+
+
+ // delete the locally created vector
+ if (!l_vPersistentNotificationList->empty()) {
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_vPersistentNotificationList->size();
+ l_uiCount++) {
+ if (NULL != l_vPersistentNotificationList->at(l_uiCount)) { // LCOV_EXCL_BR_LINE 6: can't be NULL
+ delete l_vPersistentNotificationList->at(l_uiCount);
+ }
+ }
+
+ // clear the vector
+ l_vPersistentNotificationList->clear();
+ }
+
+ delete l_vPersistentNotificationList;
+ l_vPersistentNotificationList = NULL;
+ } else {
+ // LCOV_EXCL_START 5: l_vPersistentNotificationList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_vPersistentNotificationList is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager and l_pCNotificationpersistentservicePersistenceManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationManager is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceOnLoadPersistentData
+/// In this transition, persistent file is loaded by persistent manager and
+/// persistent notifications and its data is stored by notification manager.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::NotificationpersistentserviceLoadPersistentNotificationData(EFrameworkunifiedNotificationType f_epersistenttype) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // pointer of Notification Manager
+ CNotificationManager *l_pNotificationManager = NULL;
+
+ // pointer of Persistence Manager
+ CPersistenceManager *l_pNotificationpersistentservicePersistenceManager = NULL;
+
+ // iterator of CNotificationToPersist vector
+ Persistent_Notification_List_Type *l_vPersistentNotificationList = NULL;
+
+ // get the instance of notification manager
+ l_pNotificationManager = m_pNotificationManager;
+
+ // get the instance of persistent manager
+ l_pNotificationpersistentservicePersistenceManager = m_pPersistenceManager;
+
+ // create new vector for persistent notifications
+ l_vPersistentNotificationList = new(std::nothrow) Persistent_Notification_List_Type();
+
+ if (NULL != l_vPersistentNotificationList) { // LCOV_EXCL_BR_LINE 5: l_vPersistentNotificationList can't be NULL
+ if (NULL != l_pNotificationManager && NULL != l_pNotificationpersistentservicePersistenceManager) { // LCOV_EXCL_BR_LINE 6: l_pNotificationManager and l_pNotificationpersistentservicePersistenceManager can't be NULL // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedPersistedStateVar == f_epersistenttype) {
+ // read persistent notification data from file and store in vector
+ l_estatus = l_pNotificationpersistentservicePersistenceManager->NotificationpersistentserviceReadNotificationData(l_vPersistentNotificationList);
+ } else if (eFrameworkunifiedPersistedStateUserVar == f_epersistenttype) {
+ l_estatus = l_pNotificationpersistentservicePersistenceManager->NotificationpersistentserviceReadUserNotificationData(l_vPersistentNotificationList);
+ } else if (eFrameworkunifiedImmediatePersistedStateVar == f_epersistenttype) { // LCOV_EXCL_BR_LINE 200: f_epersistenttype must be eFrameworkunifiedPersistedStateVar or eFrameworkunifiedPersistedStateUserVar or eFrameworkunifiedImmediatePersistedStateVar // NOLINT[whitespace/line_length]
+ l_estatus = l_pNotificationpersistentservicePersistenceManager->NotificationpersistentserviceReadNorNotificationData(l_vPersistentNotificationList);
+ } else {
+ // LCOV_EXCL_START 200: f_epersistenttype must be eFrameworkunifiedPersistedStateVar or eFrameworkunifiedPersistedStateUserVar or eFrameworkunifiedImmediatePersistedStateVar // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Read data for %d PersistentVarType not supported", f_epersistenttype);
+ // LCOV_EXCL_STOP
+ }
+
+ if (0 < l_vPersistentNotificationList->size()) {
+ // send the notification list to notification manager
+ l_estatus = l_pNotificationManager->NotificationpersistentserviceSetPersistentNotificationData(l_vPersistentNotificationList);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationManager and l_pNotificationpersistentservicePersistenceManager can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationManager or l_pNotificationpersistentservicePersistenceManager is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ if (!l_vPersistentNotificationList->empty()) {
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_vPersistentNotificationList->size();
+ l_uiCount++) {
+ if (NULL != l_vPersistentNotificationList->at(l_uiCount)) { // LCOV_EXCL_BR_LINE 6: can't be NULL
+ delete l_vPersistentNotificationList->at(l_uiCount);
+ }
+ }
+
+ // clear the vector
+ l_vPersistentNotificationList->clear();
+ }
+
+ delete l_vPersistentNotificationList;
+ l_vPersistentNotificationList = NULL;
+ } else {
+ // LCOV_EXCL_START 5: l_vPersistentNotificationList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation error for l_vPersistentNotificationList");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateAndStartChildThreads
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNSNPP::CreateAndStartChildThreads(HANDLE f_happ) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == f_happ) { // LCOV_EXCL_BR_LINE 6: f_happ can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: f_happ can't be NULL
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus is eFrameworkunifiedStatusOK
+ // create reader thread
+ if (NULL != (m_hNSReadThread = FrameworkunifiedCreateChildThreadWithPriority(f_happ, m_cReadThreadName.c_str(), NSPCopyWorkerOnStart, NSPCopyWorkerOnStop, CNSNPP::m_siReadThreadPrio))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Thread %s created, Prio=%d",
+ m_cReadThreadName.c_str(),
+ CNSNPP::m_siReadThreadPrio);
+
+ // start the reader thread
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedStartChildThread(f_happ, m_hNSReadThread, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ m_pPersistenceManager->SetReadThreadHandle(m_hNSReadThread);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Fail to Start Read Worker thread. Status:0x%x", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error creating NPP Read Worker thread");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus is eFrameworkunifiedStatusOK
+ // create writer thread
+ if (NULL != (m_hNSWriteThread = FrameworkunifiedCreateChildThreadWithPriority(f_happ, m_cWriteThreadName.c_str(), NSPCopyWorkerOnStart, NSPCopyWorkerOnStop, CNSNPP::m_siWriteThreadPrio))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Thread %s created, Prio=%d",
+ m_cWriteThreadName.c_str(),
+ CNSNPP::m_siWriteThreadPrio);
+
+ // start the writer thread
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedStartChildThread(f_happ, m_hNSWriteThread, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ m_pPersistenceManager->SetWriteThreadHandle(m_hNSWriteThread);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Fail to Start Write Worker thread. Status:0x%x", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error creating NPP Write Worker thread");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus is eFrameworkunifiedStatusOK
+ // create immediate Persistence thread
+ if (NULL != (m_hNSImmediatePersistenceThread = FrameworkunifiedCreateChildThreadWithPriority(f_happ, m_cImmediatePersistenceThreadName.c_str(), NSPNorPersistenceWorkerOnStart, NSPNorPersistenceWorkerOnStop, CNSNPP::m_siImmediatePersistenceThreadPrio))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Thread %s created, Prio=%d", m_cImmediatePersistenceThreadName.c_str(),
+ CNSNPP::m_siImmediatePersistenceThreadPrio);
+
+ // start the immediate Persistence thread
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedStartChildThread(f_happ, m_hNSImmediatePersistenceThread, 0, NULL))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ m_pPersistenceManager->SetNorPersistenceThreadHandle(m_hNSImmediatePersistenceThread);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Fail to Start immediate persistence thread. Status:0x%x", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error creating NPP immediate persistence Worker thread");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_archive.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_archive.cpp
new file mode 100644
index 00000000..b54faebd
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_archive.cpp
@@ -0,0 +1,846 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains the implementation for archiving and extracting files and folders.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef AGL_STUB
+#include <other_service/strlcpy.h>
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <zlib.h>
+#include <dirent.h>
+#include <zconf.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <libtar_listhash.h>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_fs_directory.h"
+#include "ns_npp_copy_worker.h"
+
+
+tartype_t g_gztype = { (openfunc_t) OpenArchive, (closefunc_t) CloseArchive,
+ (readfunc_t) ReadArchive, (writefunc_t) WriteArchive
+ };
+
+GZFiles g_gzfiles;
+
+// CHUNK Size 256 Kb
+// Buffer size for feeding data to and pulling data from the zlib routines
+const size_t kChunkSize = 1U << 18;
+// buff size 32KB
+const size_t kBufSize = 1U << 15;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CArchive
+/// Constructor of CArchive class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CCopyWorker::CArchive::CArchive() {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CArchive
+/// Destructor of CArchive class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CCopyWorker::CArchive::~CArchive() {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FolderOperation
+/// Method to perform archive or extract operations
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::Archive(NSP_CopyInfoCmd &f_tarchiveinfocmd,
+ NSP_CopyStatusResponse &f_tarchivestatusresponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ std::string l_pSourcePath = f_tarchiveinfocmd.m_csourcepath;
+ std::string l_pDestPath = f_tarchiveinfocmd.m_cdestinationpath;
+
+ if (!l_pSourcePath.empty() || !l_pDestPath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, l_pSourcePath and l_pDestPath can't be empty // NOLINT[whitespace/line_length]
+ size_t l_ifound = l_pDestPath.rfind("/");
+ // get string from start to last occurrence of '/'. Which will return directory path
+ std::string l_cOutDirPath = l_pDestPath.substr(0, l_ifound);
+ // check for load file or release file
+ if (LOADTYPE_RELEASE == f_tarchiveinfocmd.m_eloadtype) {
+ if (CFSDirectory::DoesDirecotryExist(l_pSourcePath)) {
+ // check if destination directory exist
+ if (!CFSDirectory::DoesDirecotryExist(l_cOutDirPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s DOESN'T exist, Creating...",
+ l_cOutDirPath.c_str());
+ l_estatus = CFSDirectory::CreateDirectory(l_cOutDirPath);
+ }
+ // Create archive
+ if (eFrameworkunifiedStatusOK == (l_estatus = CreateTar(l_pSourcePath, l_pDestPath, // LCOV_EXCL_BR_LINE 6: CreateTar always return eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ f_tarchivestatusresponse))) {
+ // sync tar file to persistent memory
+ SI_32 l_iTarHandle = LIBTARFAIL;
+ if (LIBTARFAIL != (l_iTarHandle = open(l_pDestPath.c_str() , O_RDONLY))) {
+ struct stat l_objStat;
+ if (-1 != fstat(l_iTarHandle , &l_objStat)) { // LCOV_EXCL_BR_LINE 6: fstat always return ok
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written in NAND memory, %ld, file=%s", l_objStat.st_size,
+ l_pDestPath.c_str());
+ }
+
+ close(l_iTarHandle);
+ } else {
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ // LCOV_EXCL_START 6: CreateTar always return eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Create tar Failed.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "CP_WRK_FAILURE_SRC_NOT_FND for %s ",
+ l_pSourcePath.c_str());
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ // check if destination directory exist
+ if (!CFSDirectory::DoesDirecotryExist(l_pDestPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s DOESN'T exist, Creating...",
+ l_pDestPath.c_str());
+ l_estatus = CFSDirectory::CreateDirectory(l_pDestPath);
+ }
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus will be always eFrameworkunifiedStatusOK
+ // Extract archive
+ l_estatus = ExtractTar(l_pSourcePath, l_pDestPath, f_tarchivestatusresponse);
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pSourcePath and l_pDestPath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateTar
+/// Method to create tar
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::CreateTar(const std::string &f_csourepath,
+ const std::string &f_cdestpath,
+ NSP_CopyStatusResponse &f_tarchivestatusresponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ std::string l_cDestPath = f_cdestpath;
+ std::string l_pcRootDirPath = f_csourepath;
+
+ libtar_list_t *l_pLibTarList = NULL;
+ l_pLibTarList = libtar_list_new(LIST_QUEUE, NULL);
+ libtar_list_add(l_pLibTarList, (void *)l_pcRootDirPath.c_str()); // NOLINT (readability/casting)
+
+ if (!l_cDestPath.empty() || !l_pcRootDirPath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, l_cDestPath and l_pcRootDirPath cannot be empty // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK != Create(l_cDestPath, l_pcRootDirPath, l_pLibTarList)) { // LCOV_EXCL_BR_LINE 6: Create always return eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: Create always return eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // not copied properly so remove temporary file
+ if (TRUE == CFSDirectory::RemoveDirectory(l_cDestPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete persistent directory successful.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete persistent directory unsuccessful.");
+ }
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Archiving fails for %s to %s", l_pcRootDirPath.c_str(),
+ l_cDestPath.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Folder archived %s ", l_cDestPath.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Source Path %s", l_pcRootDirPath.c_str());
+
+ if (TRUE == CFSDirectory::RemoveDirectory(l_pcRootDirPath)) { // LCOV_EXCL_BR_LINE 6: always return true
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete temporary directory successful.");
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete temporary directory unsuccessful."); // LCOV_EXCL_LINE 6: always return true // NOLINT[whitespace/line_length]
+ }
+ l_estatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_cDestPath and l_pcRootDirPath cannot be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ libtar_list_free(l_pLibTarList, NULL);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ExtractTar
+/// Method to extract tar
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::ExtractTar(const std::string &f_csourepath,
+ const std::string &f_cdestpath,
+ NSP_CopyStatusResponse &f_tarchivestatusresponse) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ std::string l_pcTarFileDestPath = f_cdestpath;
+ std::string l_pcRootDirPath = f_csourepath;
+
+ if (!l_pcTarFileDestPath.empty() || !l_pcRootDirPath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be empty // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK != Extract(l_pcRootDirPath, l_pcTarFileDestPath)) {
+ // not copied properly so remove temporary file
+ if (TRUE == CFSDirectory::RemoveDirectory(l_pcTarFileDestPath)) { // LCOV_EXCL_BR_LINE 6: RemoveDirectory always return true // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete retrieved directory successful.");
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete retrieved directory unsuccessful."); // LCOV_EXCL_LINE 6: RemoveDirectory always return true // NOLINT[whitespace/line_length]
+ }
+
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "ABORT WAS CALLED!");
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Extraction fails for %s to %s",
+ l_pcTarFileDestPath.c_str(), l_pcTarFileDestPath.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Folder extracted %s ", l_pcTarFileDestPath.c_str());
+ l_estatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Create
+/// Method to create tar
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::Create(std::string &f_pctarfiledestpath,
+ std::string &f_pcrootdirpath,
+ libtar_list_t *f_plibtarlist) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (FILEERROR == access(f_pcrootdirpath.c_str(), R_OK)) { // LCOV_EXCL_BR_LINE 6: access always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 6: access always return ok
+ }
+
+ TAR *l_pTarInfo = NULL;
+ CHAR l_cBuffer[MAX_PATH_LENGTH];
+ libtar_listptr_t l_pTarListPtr;
+
+ PCHAR l_pcTarFileDestPath = const_cast<PCHAR >(f_pctarfiledestpath.c_str());
+ PCHAR l_pcRootDirPath = const_cast<PCHAR >(f_pcrootdirpath.c_str());
+
+ CHAR l_temp[] = "/";
+
+ if (l_pcTarFileDestPath || l_pcRootDirPath) { // LCOV_EXCL_BR_LINE 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be NULL // NOLINT[whitespace/line_length]
+ // open tar archive
+ if (LIBTARFAIL == (tar_open(&l_pTarInfo, l_pcTarFileDestPath, &g_gztype, O_WRONLY | O_CREAT, // LCOV_EXCL_BR_LINE 6: tar_open always return ok // NOLINT[whitespace/line_length]
+ TARMODE, TAR_GNU))) {
+ // LCOV_EXCL_START 6: tar_open always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_open(): %s", std::strerror(errno));
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ libtar_listptr_reset(&l_pTarListPtr);
+
+ while (libtar_list_next(f_plibtarlist, &l_pTarListPtr) != LIBTARSUCCESS) {
+ if (l_pcRootDirPath[0] != '/') { // LCOV_EXCL_BR_LINE 6: l_pcRootDirPath must begin with '/'
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s", l_pcRootDirPath); // LCOV_EXCL_LINE 6: l_pcRootDirPath must begin with '/' // NOLINT[whitespace/line_length]
+ } else {
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_cBuffer, l_pcRootDirPath, sizeof(l_cBuffer));
+#endif
+ }
+
+ if (tar_append_tree(l_pTarInfo, l_cBuffer, l_temp) != LIBTARSUCCESS) { // LCOV_EXCL_BR_LINE 6: tar_append_tree always return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: tar_append_tree always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__,
+ "tar_append_tree(\"%s\", \"%s\"): %s", l_cBuffer,
+ l_temp, std::strerror(errno));
+ tar_close(l_pTarInfo);
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+ if (tar_append_eof(l_pTarInfo) != LIBTARSUCCESS) { // LCOV_EXCL_BR_LINE 6: tar_append_eof always return ok
+ // LCOV_EXCL_START 6: tar_append_eof always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_append_eof(): %s", std::strerror(errno));
+ tar_close(l_pTarInfo);
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (tar_close(l_pTarInfo) != LIBTARSUCCESS) { // LCOV_EXCL_BR_LINE 6: tar_close always return ok
+ // LCOV_EXCL_START 6: tar_close always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_close(): %s", std::strerror(errno));
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pcTarFileDestPath and l_pcRootDirPath can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// create
+/// Method to extract tar
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::Extract(std::string &f_pcrootdirpath, std::string &f_pctarfiledestpath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (FILEERROR == access(f_pcrootdirpath.c_str(), R_OK)) { // LCOV_EXCL_BR_LINE 6: access always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 6: access always return ok
+ }
+
+ PCHAR l_pcRootDirPath = const_cast<PCHAR >(f_pcrootdirpath.c_str());
+ PCHAR l_pcTarFileDestPath = const_cast<PCHAR >(f_pctarfiledestpath.c_str());
+
+ TAR *l_pTarInfo = NULL;
+
+ if (l_pcRootDirPath || l_pcTarFileDestPath) { // LCOV_EXCL_BR_LINE 6: double check, l_pcRootDirPath and l_pcTarFileDestPath can't be NULL // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Extraction open for %s to ", l_pcRootDirPath);
+
+ if (LIBTARFAIL == (tar_open(&l_pTarInfo, l_pcRootDirPath, &g_gztype, O_RDONLY, LIBTARSUCCESS, TAR_GNU))) { // LCOV_EXCL_BR_LINE 6: tar_open always return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: tar_open always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_open(): %s", std::strerror(errno));
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (LIBTARSUCCESS != tar_extract_all(l_pTarInfo, l_pcTarFileDestPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_extract_all(): %s", std::strerror(errno));
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (LIBTARSUCCESS != tar_close(l_pTarInfo)) { // LCOV_EXCL_BR_LINE 6: tar_close always return ok
+ // LCOV_EXCL_START 6: tar_close always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_close(): %s", std::strerror(errno));
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pcRootDirPath and l_pcTarFileDestPath can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source path or Dest Path empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+SI_32 OpenArchive(PCHAR f_pcpathname, SI_32 f_sioflags, SI_32 f_simode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ gzFile l_gzfile = Z_NULL;
+ SI_32 l_sifiledescriptor = LIBTARFAIL;
+ if (f_pcpathname) { // LCOV_EXCL_BR_LINE 6: double check, f_pcpathname can't be NULL
+ PCHAR l_pcgzoflags;
+
+ switch (f_sioflags & O_ACCMODE) {
+ case O_WRONLY: {
+ l_pcgzoflags = (PCHAR)"wb";
+ break;
+ }
+ case O_RDONLY: {
+ l_pcgzoflags = (PCHAR)"rb";
+ break;
+ }
+ case O_RDWR:
+ default: {
+ // LCOV_EXCL_START 6: must be O_WRONLY or O_RDONLY
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EINVAL;
+ return LIBTARFAIL;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ l_sifiledescriptor = open(f_pcpathname, f_sioflags, f_simode);
+
+ if (LIBTARFAIL == l_sifiledescriptor) { // LCOV_EXCL_BR_LINE 6: l_sifiledescriptor always be ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return LIBTARFAIL; // LCOV_EXCL_LINE 6: l_sifiledescriptor always be ok
+ }
+
+ if (((f_sioflags & O_CREAT) && fchmod(l_sifiledescriptor, f_simode))) { // LCOV_EXCL_BR_LINE 6: always be ok
+ // LCOV_EXCL_START 6: always be ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_sifiledescriptor);
+ return LIBTARFAIL;
+ // LCOV_EXCL_STOP
+ }
+
+ l_gzfile = gzdopen(l_sifiledescriptor, l_pcgzoflags);
+ if (!l_gzfile) { // LCOV_EXCL_BR_LINE 6: l_gzfile always be not null
+ // LCOV_EXCL_START 6: l_gzfile always be not null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_sifiledescriptor);
+
+ errno = ENOMEM;
+ return LIBTARFAIL;
+ // LCOV_EXCL_STOP
+ } else {
+ g_gzfiles.insert(std::make_pair(l_sifiledescriptor, l_gzfile));
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path empty."); // LCOV_EXCL_LINE 6: double check, f_pcpathname can't be NULL // NOLINT[whitespace/line_length]
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_sifiledescriptor;
+}
+
+int CloseArchive(int fd) {
+ int ret;
+ gzFile gzfile = Z_NULL;
+
+ /* checks */
+ if (g_gzfiles.empty()) { // LCOV_EXCL_BR_LINE 6: g_gzfiles always be not empty
+ // LCOV_EXCL_START 6: g_gzfiles always be not empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EBADF;
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ GZFiles::iterator gzfiles_it = g_gzfiles.find(fd);
+ if (gzfiles_it == g_gzfiles.end()) { // LCOV_EXCL_BR_LINE 6: fd will always be found
+ // LCOV_EXCL_START 6: fd will always be found
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EINVAL;
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ /* call zlib */
+ gzfile = gzfiles_it->second;
+ ret = gzclose(gzfile);
+
+ /* remove gzFile* association from our list */
+ g_gzfiles.erase(gzfiles_it);
+
+ return ret;
+}
+
+ssize_t ReadArchive(int fd, void *buf, size_t count) {
+ gzFile gzfile = Z_NULL;
+
+ if (g_gzfiles.empty()) { // LCOV_EXCL_BR_LINE 6: g_gzfiles always be not empty
+ // LCOV_EXCL_START 6: g_gzfiles always be not empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EBADF;
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ GZFiles::iterator gzfiles_it = g_gzfiles.find(fd);
+ if (gzfiles_it == g_gzfiles.end()) { // LCOV_EXCL_BR_LINE 6: fd will always be found
+ // LCOV_EXCL_START 6: fd will always be found
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EINVAL;
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ gzfile = gzfiles_it->second;
+ return gzread(gzfile, buf, static_cast<UI_32>(count));
+}
+
+ssize_t WriteArchive(int fd, const void *buf, size_t count) {
+ gzFile gzfile = Z_NULL;
+
+ if (g_gzfiles.empty()) { // LCOV_EXCL_BR_LINE 6: g_gzfiles always be not empty
+ // LCOV_EXCL_START 6: g_gzfiles always be not empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EBADF;
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ GZFiles::iterator gzfiles_it = g_gzfiles.find(fd);
+ if (gzfiles_it == g_gzfiles.end()) { // LCOV_EXCL_BR_LINE 6: fd will always be found
+ // LCOV_EXCL_START 6: fd will always be found
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ errno = EINVAL;
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ gzfile = gzfiles_it->second;
+ return gzwrite(gzfile, buf, static_cast<UI_32>(count));
+}
+
+// LCOV_EXCL_START 6: unused code
+////////////////////////////////////////////////////////////////////////////////////////////
+/// FileOperationUsingLibz
+/// Method to determine whether to compress/decompress file using libz
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::FileOperationUsingLibz(NSP_CopyInfoCmd &f_toperainfocmd,
+ NSP_CopyStatusResponse &f_toperarespstatus) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ std::string l_pSourcePath = f_toperainfocmd.m_csourcepath;
+ std::string l_pDestPath = f_toperainfocmd.m_cdestinationpath;
+
+ if (!l_pSourcePath.empty() || !l_pDestPath.empty()) {
+ size_t l_ifound = l_pDestPath.rfind("/");
+ // get string from start to last occurrence of '/'. Which will return directory path
+ std::string l_cOutDirPath = l_pDestPath.substr(0, l_ifound);
+
+ // check if destination directory exist
+ if (!CFSDirectory::DoesDirecotryExist(l_cOutDirPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "%s DOESN'T exist, Creating...",
+ l_cOutDirPath.c_str());
+ l_estatus = CFSDirectory::CreateDirectory(l_cOutDirPath);
+ }
+
+ // check for load file or release file
+ if (LOADTYPE_RELEASE == f_toperainfocmd.m_eloadtype) {
+ // Zip
+ if (eFrameworkunifiedStatusOK == (l_estatus = CompressUsingZlib(l_pSourcePath, l_pDestPath, Z_BEST_COMPRESSION))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "File Compression successful.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "File Compression failed.");
+ f_toperarespstatus.m_bpersistencechk = FALSE;
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else if (LOADTYPE_LOAD == f_toperainfocmd.m_eloadtype) {
+ // Unzip
+ if (eFrameworkunifiedStatusOK == (l_estatus = DeCompressUsingZlib(l_pSourcePath, l_pDestPath))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "File DeCompression successful.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "File DeCompression failed.");
+ f_toperarespstatus.m_bpersistencechk = FALSE;
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Wrong Request or No request for compression or decompression!");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path or Destination Path Empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 6: unused code
+////////////////////////////////////////////////////////////////////////////////////////////
+/// CompressUsingZlib
+/// Method to compress file using libz
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::CompressUsingZlib(const std::string &f_csourepath,
+ const std::string &f_cdestpath,
+ SI_32 f_iziplevel) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (!f_csourepath.empty() || !f_cdestpath.empty()) {
+ std::string l_cSourePath = f_csourepath;
+ std::string l_cDestPath = f_cdestpath;
+
+ std::string l_TempFile = "";
+ l_TempFile.append(l_cDestPath.c_str());
+ l_TempFile.append(".nps_tmp");
+
+ FILE *l_pSrcFilePtr = fopen(l_cSourePath.c_str(), "rb");
+
+ if (NULL != l_pSrcFilePtr) {
+ FILE *l_pDestFilePtr = fopen(l_TempFile.c_str(), "wb");
+ if (NULL != l_pDestFilePtr) {
+ setvbuf(l_pSrcFilePtr, NULL, _IOFBF, kBufSize);
+ setvbuf(l_pDestFilePtr, NULL, _IOFBF, kBufSize);
+
+ // structure used to pass information to and from the zlib routines
+ z_stream l_tZstreamInfo = {};
+
+ // Allocate deflate state
+ l_tZstreamInfo.zalloc = Z_NULL;
+ l_tZstreamInfo.zfree = Z_NULL;
+ l_tZstreamInfo.opaque = Z_NULL;
+
+ // Initialize deflates
+ SI_32 l_iDeflateStatus = deflateInit(&l_tZstreamInfo, f_iziplevel);
+
+ // Deflate Flush Status to determine end of input file
+ SI_32 l_iDeflateFlushState = Z_FINISH;
+
+ std::vector< UI_8 > l_vInBuffer(kChunkSize);
+ std::vector< UI_8 > l_vOutBuffer(kChunkSize);
+
+ // pointer to the read bytes from the input file
+ UI_8 *l_pReadBuffer = &l_vInBuffer[0];
+ // pointer to the next available byte space to write to output file
+ UI_8 *l_pWriteBuffer = &l_vOutBuffer[0];
+
+ size_t l_uiDeflateRetData = 0;
+
+ if (Z_OK == l_iDeflateStatus) {
+ do {
+ // bytes read from input file
+ l_tZstreamInfo.avail_in = static_cast<uInt>(fread(l_pReadBuffer, 1, kChunkSize, l_pSrcFilePtr));
+
+ if (0 == ferror(l_pSrcFilePtr)) {
+ // if the eof input file reached set the flush state to Z_FINISH
+ // Z_NO_FLUSH to indicate that we still have uncompressed data
+ l_iDeflateFlushState = feof(l_pSrcFilePtr) ? Z_FINISH : Z_NO_FLUSH;
+ l_tZstreamInfo.next_in = l_pReadBuffer;
+
+ // run deflate() on input until output buffer not full, finish
+ // compression if all of source has been read in
+ do {
+ l_tZstreamInfo.avail_out = kChunkSize;
+ l_tZstreamInfo.next_out = l_pWriteBuffer;
+ // no bad return value
+ l_iDeflateStatus = deflate(&l_tZstreamInfo, l_iDeflateFlushState);
+ // state not clobbered
+ if (Z_STREAM_ERROR == l_iDeflateStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "zlib stream error");
+ } else {
+ l_uiDeflateRetData = kChunkSize - l_tZstreamInfo.avail_out;
+ if ((fwrite(l_pWriteBuffer, 1, l_uiDeflateRetData, l_pDestFilePtr) != l_uiDeflateRetData) ||
+ // all data not written properly
+ (0 != ferror(l_pDestFilePtr))) { // file error in writing
+ deflateEnd(&l_tZstreamInfo);
+ l_estatus = eFrameworkunifiedStatusFail;
+ l_tZstreamInfo.avail_out = 0;
+ l_iDeflateFlushState = Z_FINISH;
+ }
+ }
+ } while (0 == l_tZstreamInfo.avail_out); //<< check if deflate() has no more output
+ } else { // by seeing that it did not fill the output buffer
+ deflateEnd(&l_tZstreamInfo); // leaving avail_out greater than zero >>//
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ // all input will be used
+ if (0 != l_tZstreamInfo.avail_in) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All inputs in z-stream avail_in not used");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ // done when last data in file processed
+ } while (Z_FINISH != l_iDeflateFlushState);
+ // stream will be complete
+ if (Z_STREAM_END != l_iDeflateStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "z-stream not completed");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Compressed %lu bytes down to %lu bytes",
+ l_tZstreamInfo.total_in, l_tZstreamInfo.total_out);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written in NAND memory, %lu, file=%s", l_tZstreamInfo.total_out,
+ f_cdestpath.c_str());
+
+ // clean up and return
+ deflateEnd(&l_tZstreamInfo);
+ } else {
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "deflateInit Failed");
+ }
+
+ fclose(l_pDestFilePtr);
+
+ if (0 != rename(l_TempFile.c_str(), l_cDestPath.c_str())) {
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error renaming file %s to %s",
+ l_TempFile.c_str(), l_cDestPath.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Destination File Opening Error");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ fclose(l_pSrcFilePtr);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "Source File Opening Error");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path or Destination Path Empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 6: unused code
+////////////////////////////////////////////////////////////////////////////////////////////
+/// DeCompressUsingZlib
+/// Method to decompress file using libz
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CArchive::DeCompressUsingZlib(const std::string &f_csourepath,
+ const std::string &f_cdestpath) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (!f_csourepath.empty() || !f_cdestpath.empty()) {
+ std::string l_cSourePath = f_csourepath;
+ std::string l_cDestPath = f_cdestpath;
+
+ std::string l_TempFile = "";
+ l_TempFile.append(l_cDestPath.c_str());
+ l_TempFile.append(".nps_tmp");
+
+ FILE *l_pSrcFilePtr = fopen(l_cSourePath.c_str(), "rb");
+
+ if (NULL != l_pSrcFilePtr) {
+ FILE *l_pDestFilePtr = fopen(l_TempFile.c_str(), "wb");
+ if (NULL != l_pDestFilePtr) {
+ setvbuf(l_pSrcFilePtr, NULL, _IOFBF, kBufSize);
+ setvbuf(l_pDestFilePtr, NULL, _IOFBF, kBufSize);
+
+ z_stream l_tZstreamInfo = {};
+
+ // allocate inflate state
+ l_tZstreamInfo.zalloc = Z_NULL;
+ l_tZstreamInfo.zfree = Z_NULL;
+ l_tZstreamInfo.opaque = Z_NULL;
+ l_tZstreamInfo.avail_in = 0;
+ l_tZstreamInfo.next_in = Z_NULL;
+
+ SI_32 l_iInflateStatus = inflateInit(&l_tZstreamInfo);
+
+ if (Z_OK == l_iInflateStatus) {
+ std::vector< UI_8 > l_vInBuffer(kChunkSize);
+ std::vector< UI_8 > l_vOutBuffer(kChunkSize);
+
+ // pointer to the read bytes from the input file
+ UI_8 *l_pReadBuffer = &l_vInBuffer[0];
+ // pointer to the next available byte space to write to output file
+ UI_8 *l_pWriteBuffer = &l_vOutBuffer[0];
+
+ size_t l_uiDeflateRetData = 0;
+
+ do {
+ l_tZstreamInfo.avail_in = static_cast<uInt>(fread(l_pReadBuffer, 1, kChunkSize, l_pSrcFilePtr));
+ if (0 == ferror(l_pSrcFilePtr)) {
+ if (0 == l_tZstreamInfo.avail_in) {
+ break;
+ }
+ l_tZstreamInfo.next_in = l_pReadBuffer;
+ // run inflate() on input until output buffer not full
+ do {
+ l_tZstreamInfo.avail_out = kChunkSize;
+ l_tZstreamInfo.next_out = l_pWriteBuffer;
+ l_iInflateStatus = inflate(&l_tZstreamInfo, Z_NO_FLUSH);
+
+ // state clobbered
+ if (Z_STREAM_ERROR == l_iInflateStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "zlib stream error");
+ l_estatus = eFrameworkunifiedStatusFail;
+ } else if (Z_NEED_DICT == l_iInflateStatus) {
+ l_iInflateStatus = Z_DATA_ERROR;
+ l_estatus = eFrameworkunifiedStatusFail;
+ } else if (Z_MEM_ERROR == l_iInflateStatus) {
+ inflateEnd(&l_tZstreamInfo);
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Out of Memory");
+ } else {
+ l_uiDeflateRetData = kChunkSize - l_tZstreamInfo.avail_out;
+ // all data not written
+ if ((fwrite(l_pWriteBuffer, 1, l_uiDeflateRetData, l_pDestFilePtr) != l_uiDeflateRetData) ||
+ (0 != ferror(l_pDestFilePtr))) { // or file writing error
+ inflateEnd(&l_tZstreamInfo);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ } while (0 == l_tZstreamInfo.avail_out);
+ } else {
+ inflateEnd(&l_tZstreamInfo);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ // done when inflate() says it's done
+ } while (Z_STREAM_END != l_iInflateStatus);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " De-compressed %lu bytes to %lu bytes",
+ l_tZstreamInfo.total_in, l_tZstreamInfo.total_out);
+ // clean up and return
+ inflateEnd(&l_tZstreamInfo);
+ } else {
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ fclose(l_pDestFilePtr);
+
+ if (0 != rename(l_TempFile.c_str(), l_cDestPath.c_str())) {
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error renaming file %s to %s",
+ l_TempFile.c_str(), l_cDestPath.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Destination File Opening Error");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ fclose(l_pSrcFilePtr);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Source File Opening Error");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path or Destination Path Empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_binary_accesser.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_binary_accesser.cpp
new file mode 100644
index 00000000..e0a749f7
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_binary_accesser.cpp
@@ -0,0 +1,649 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains definition of CBinaryAccesser class.
+/// This class stores data in a file in binary format.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#ifdef AGL_STUB
+#include <other_service/strlcpy.h>
+#endif
+#include <cerrno>
+#include <string>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_fs_directory.h"
+#include "ns_npp_binary_accesser.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_persistent_accesser.h"
+
+struct PersistFileHeder {
+ char check_code[4];
+ unsigned int crc;
+};
+#define NPP_CHECK_CODE "NPPD"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CBinaryAccesser
+/// Constructor of CBinaryAccesser class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CBinaryAccesser::CBinaryAccesser() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_uiCurStrOffset = 0;
+ m_uiCurStrSize = 0;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CBinaryAccesser
+/// Destructor of CBinaryAccesser class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CBinaryAccesser::~CBinaryAccesser() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// PersistData
+/// Persist data in persistent memory in a file in binary format.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::PersistData(std::string f_cmemfilepath,
+ Persistent_Notification_List_Type *f_vdata,
+ EFrameworkunifiedNotificationType f_epersistenttype,
+ EFrameworkunifiedPersistCategory f_epersistcategory) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ int l_OutFd;
+
+ if (NULL != f_vdata) { // LCOV_EXCL_BR_LINE 6: f_vdata can't be NULL
+ // Open global file in write mode.
+ if ((eFrameworkunifiedStatusOK == OpenFileForWriting(&l_OutFd, f_cmemfilepath))) {
+ Persistent_Notification_List_Iterator l_itNotificationList = f_vdata->begin();
+
+ // Iterate through a vector f_vdata
+ for (; l_itNotificationList != f_vdata->end(); l_itNotificationList++) {
+ if (eFrameworkunifiedPersistedStateVar == (*l_itNotificationList)->m_ePersistentType) {
+ if (f_epersistcategory == (*l_itNotificationList)->m_ePersistCategory) {
+ // write header and data
+ if (eFrameworkunifiedStatusOK != WriteHeaderAndData((*l_itNotificationList),
+ (*l_itNotificationList)->m_pPersistentData->m_pMessage,
+ l_OutFd)) {
+ l_estatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ }
+ } else {
+ // write header and data
+ if (eFrameworkunifiedStatusOK != WriteHeaderAndData((*l_itNotificationList),
+ (*l_itNotificationList)->m_pPersistentData->m_pMessage,
+ l_OutFd)) {
+ l_estatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != WriteFileHeaderAndDuplicate(l_OutFd, f_cmemfilepath)) {
+ l_estatus = eFrameworkunifiedStatusFail;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written in NAND memory, %ld, file=%s",
+ static_cast<long int>(m_uiCurStrOffset - sizeof(PersistFileHeder)), f_cmemfilepath.c_str()); // NOLINT (runtime/int)
+ }
+ close(l_OutFd);
+ } else {
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to open file %s", f_cmemfilepath.c_str());
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// RetrieveData
+/// Retrieve data in persistent memory in a file in binary format.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::RetrieveData(std::string f_cmemfilepath,
+ Persistent_Notification_List_Type *&f_vdata,
+ EFrameworkunifiedPersistCategory f_epersistcategory) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ int l_InFd;
+
+ if (NULL != f_vdata) { // LCOV_EXCL_BR_LINE 6: f_vdata can't be NULL
+ if ((eFrameworkunifiedStatusOK == (l_estatus = OpenFileForReading(&l_InFd, f_cmemfilepath)))) {
+ l_estatus = FillNotificationList(l_InFd, f_vdata, f_epersistcategory);
+
+ close(l_InFd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to open file %s, status=%d", f_cmemfilepath.c_str(), l_estatus);
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_vdata can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "f_pdata is NULL");
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// FillNotificationList
+/// This function retrieve the notification data from file and fill it in map.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::FillNotificationList(int f_infd,
+ Persistent_Notification_List_Type *&f_vdata,
+ EFrameworkunifiedPersistCategory f_epersistcategory) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL == f_vdata) { // LCOV_EXCL_BR_LINE 6: f_vdata can't be NULL
+ // LCOV_EXCL_START 6: f_vdata can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "f_pdata is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ while (eFrameworkunifiedStatusOK == l_estatus) {
+ CPersistDataHeader l_objCPersistDataHeader;
+ CHAR *l_pData = NULL;
+
+ // Read header and data.
+ l_estatus = ReadHeaderAndData(l_objCPersistDataHeader, l_pData, f_infd);
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ CNotificationsToPersist *l_objCNotificationsToPersist = new(std::nothrow) CNotificationsToPersist();
+ CPersistentData *l_objCPersistentData = new(std::nothrow) CPersistentData();
+
+ // fill the appropriate values in l_objCNotificationsToPersist
+ if ((NULL != l_objCPersistentData) && (NULL != l_objCNotificationsToPersist)) { // LCOV_EXCL_BR_LINE 5: new's error case // NOLINT[whitespace/line_length]
+ l_objCPersistentData->m_pMessage = new(std::nothrow) CHAR[l_objCPersistDataHeader.m_uiSize];
+ if (NULL != l_objCPersistentData->m_pMessage) { // LCOV_EXCL_BR_LINE 5: new's error case
+ std::memcpy(l_objCPersistentData->m_pMessage, l_pData, l_objCPersistDataHeader.m_uiSize);
+ l_objCPersistentData->m_uiMsgSize = l_objCPersistDataHeader.m_uiSize;
+ l_objCNotificationsToPersist->m_ePersistentType = l_objCPersistDataHeader.m_ePersistentType;
+ l_objCNotificationsToPersist->m_ePersistCategory = f_epersistcategory;
+
+ l_objCNotificationsToPersist->m_cNotificationName = l_objCPersistDataHeader.m_cNotificationName;
+ l_objCNotificationsToPersist->m_cPublisherName = l_objCPersistDataHeader.m_cPublisherName;
+
+ l_objCNotificationsToPersist->m_pPersistentData = l_objCPersistentData;
+
+ l_objCNotificationsToPersist->m_uiMaxMsgLength = l_objCPersistDataHeader.m_uiMaxMsgLength;
+ f_vdata->push_back(l_objCNotificationsToPersist);
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::memset(&l_objCPersistDataHeader, 0, sizeof(CPersistDataHeader));
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::memset(&l_objCPersistDataHeader, 0, sizeof(CPersistDataHeader));
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } else if (eFrameworkunifiedStatusErrOther == l_estatus) {
+ // EOF
+ l_estatus = eFrameworkunifiedStatusOK;
+ break;
+ } else {
+ std::memset(&l_objCPersistDataHeader, 0, sizeof(CPersistDataHeader));
+ break;
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::OpenFileForReading(int *f_infd,
+ std::string f_cfilepath) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // raw & raw.bak file unlink
+ std::string l_cUnlinkPath(f_cfilepath);
+ unlink(l_cUnlinkPath.c_str());
+ l_cUnlinkPath.append(".bak");
+ unlink(l_cUnlinkPath.c_str());
+
+ // add .valid
+ std::string l_cValidPath(f_cfilepath);
+ l_cValidPath.append(".valid");
+
+ if ((*f_infd = open(l_cValidPath.c_str(), O_RDONLY)) >= 0) {
+ if (eFrameworkunifiedStatusOK == CheckFileHeader(*f_infd)) {
+ struct stat st;
+ if (fstat(*f_infd, &st) == 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case
+ if (st.st_size == 0) {
+ // If original file is 0byte, to confirm bak file
+ int bak_fd;
+ if (eFrameworkunifiedStatusOK == OpenBakFileForReading(&bak_fd, l_cValidPath)) {
+ close(*f_infd);
+ *f_infd = bak_fd;
+ }
+ }
+ }
+ l_estatus = eFrameworkunifiedStatusOK;
+ } else {
+ close(*f_infd);
+ l_estatus = OpenBakFileForReading(f_infd, l_cValidPath);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open(%s) fail: %s", l_cValidPath.c_str(), strerror(errno));
+ l_estatus = OpenBakFileForReading(f_infd, l_cValidPath);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// OpenFileForWriting
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::OpenFileForWriting(int *f_outfd,
+ std::string f_cfilepath) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+
+ std::string l_cPath(f_cfilepath);
+ size_t l_ifound = l_cPath.rfind("/");
+ std::string l_cOutDirPath = l_cPath.substr(0, l_ifound);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Path for persistence %s ", l_cOutDirPath.c_str());
+
+ // if parent directory path doesn't exists, create it
+ if (!CFSDirectory::DoesDirecotryExist(l_cOutDirPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s DOESN'T exist, Creating...", l_cOutDirPath.c_str());
+ if (eFrameworkunifiedStatusOK != (l_estatus = CFSDirectory::CreateDirectory(l_cOutDirPath))) { // LCOV_EXCL_BR_LINE 6: CreateDirectory always return ok // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Failed to create %s ", l_cOutDirPath.c_str()); // LCOV_EXCL_LINE 6: CreateDirectory always return ok // NOLINT[whitespace/line_length]
+ }
+ }
+
+ // add .valid
+ std::string l_cValidPath(f_cfilepath);
+ l_cValidPath.append(".valid");
+
+ if ((*f_outfd = open(l_cValidPath.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0660)) >= 0) {
+ if (lseek(*f_outfd, sizeof(PersistFileHeder), SEEK_SET) == sizeof(PersistFileHeder)) { // LCOV_EXCL_BR_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ l_estatus = eFrameworkunifiedStatusOK;
+ m_uiCurStrOffset = sizeof(PersistFileHeder);
+ } else {
+ // LCOV_EXCL_START 5: lseek's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lseek fail: %s", strerror(errno));
+ close(*f_outfd);
+ *f_outfd = -1;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open(%s) fail: %s", l_cValidPath.c_str(), strerror(errno));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// WriteHeaderAndData
+/// Write header and data in a file.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::WriteHeaderAndData(CNotificationsToPersist *f_pnotificationstopersist,
+ PVOID f_pdata,
+ int f_outfd) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+
+ if ((NULL == f_pdata) || (NULL == f_pnotificationstopersist)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "f_pdata is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ } else {
+ CPersistDataHeader l_objCPersistDataHeader;
+
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_objCPersistDataHeader.m_cNotificationName, f_pnotificationstopersist->m_cNotificationName.c_str(),
+ sizeof(l_objCPersistDataHeader.m_cNotificationName));
+ strlcpy(l_objCPersistDataHeader.m_cPublisherName, f_pnotificationstopersist->m_cPublisherName.c_str(),
+ sizeof(l_objCPersistDataHeader.m_cPublisherName));
+#endif
+
+ // size check
+ if (UINT32_MAX >= static_cast<size_t>(sizeof(CPersistDataHeader) + l_objCPersistDataHeader.m_uiSize)) { // LCOV_EXCL_BR_LINE 5: the size is not bigger than UINT32_MAX // NOLINT[whitespace/line_length]
+ l_objCPersistDataHeader.m_uiOffset = static_cast<UI_32>(m_uiCurStrOffset + sizeof(CPersistDataHeader));
+ l_objCPersistDataHeader.m_uiSize = f_pnotificationstopersist->m_pPersistentData->m_uiMsgSize;
+ l_objCPersistDataHeader.m_ePersistentType = f_pnotificationstopersist->m_ePersistentType;
+ l_objCPersistDataHeader.m_uiMaxMsgLength = f_pnotificationstopersist->m_uiMaxMsgLength;
+
+ // write header
+ if (write(f_outfd, (PCHAR)&l_objCPersistDataHeader, sizeof(CPersistDataHeader)) == sizeof(CPersistDataHeader)) { // LCOV_EXCL_BR_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ // write data
+ if (write(f_outfd, (PCHAR)f_pdata, // LCOV_EXCL_BR_LINE 5: write's error case
+ l_objCPersistDataHeader.m_uiSize) == (ssize_t)l_objCPersistDataHeader.m_uiSize) {
+ // save offset of end of current record's data
+ m_uiCurStrOffset += static_cast<UI_32>(sizeof(CPersistDataHeader) + l_objCPersistDataHeader.m_uiSize);
+ l_estatus = eFrameworkunifiedStatusOK;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while writing data: %s", strerror(errno)); // LCOV_EXCL_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while writing header: %s", strerror(errno)); // LCOV_EXCL_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CBinaryAccesser::ReadHeaderAndData(CPersistDataHeader &f_objcpersistdataheader,
+ CHAR *&f_pdata, int f_infd) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ static UI_32 l_uisPrevAllocSz = 0;
+ ssize_t l_iRet;
+
+ // read header
+ l_iRet = read(f_infd, (PCHAR)&f_objcpersistdataheader, sizeof(f_objcpersistdataheader));
+ if (l_iRet != sizeof(f_objcpersistdataheader)) {
+ if (l_iRet < 0) { // LCOV_EXCL_BR_LINE 5: read's error case
+ // LCOV_EXCL_START 5: read's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while reading header: %s", strerror(errno));
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ l_estatus = eFrameworkunifiedStatusErrOther; // TODO(my_username): set specific error as eNotificationpersistentserviceStatusEOFReadched
+ }
+ std::memset(&f_objcpersistdataheader, 0, sizeof(CPersistDataHeader));
+ } else { // read data
+ m_uiCurStrOffset += static_cast<UI_32>(sizeof(CPersistDataHeader));
+ if (static_cast<int>(f_objcpersistdataheader.m_uiSize) > 0 &&
+ m_uiCurStrOffset + f_objcpersistdataheader.m_uiSize <= m_uiCurStrSize) {
+ // if f_pdata has space allocated and if the allocated size less than new size,
+ // free and reallocate
+ if ((NULL != f_pdata) && (l_uisPrevAllocSz < f_objcpersistdataheader.m_uiSize)) { // LCOV_EXCL_BR_LINE 6: f_pdata must be null // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: f_pdata must be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ delete[] f_pdata;
+ f_pdata = NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ if (NULL == f_pdata) { // LCOV_EXCL_BR_LINE 200: f_pdata must be null
+ f_pdata = new(std::nothrow) CHAR[f_objcpersistdataheader.m_uiSize];
+ } else {
+ // memory already allcoated.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+
+ if (NULL != f_pdata) { // LCOV_EXCL_BR_LINE 6: f_pdata can't be null
+ l_uisPrevAllocSz = f_objcpersistdataheader.m_uiSize;
+ l_iRet = read(f_infd, (PCHAR)f_pdata, f_objcpersistdataheader.m_uiSize);
+ if (l_iRet == (ssize_t)f_objcpersistdataheader.m_uiSize) { // LCOV_EXCL_BR_LINE 5: read's error case
+ m_uiCurStrOffset += f_objcpersistdataheader.m_uiSize;
+ l_estatus = eFrameworkunifiedStatusOK;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while reading data: %s", strerror(errno)); // LCOV_EXCL_LINE 5: read's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_pdata can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Mem Allocation failure");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invlide data size: %u", f_objcpersistdataheader.m_uiSize);
+ std::memset(&f_objcpersistdataheader, 0, sizeof(CPersistDataHeader));
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+EFrameworkunifiedStatus CBinaryAccesser::WriteFileHeaderAndDuplicate(int f_outfd, std::string f_cfilepath) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ struct stat st;
+
+ if (fstat(f_outfd, &st) == 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case
+ if (st.st_size > static_cast<long>(sizeof(PersistFileHeder))) { // NOLINT (runtime/int)
+ size_t body_size = static_cast<size_t>(st.st_size - sizeof(PersistFileHeder));
+ char *buf = new(std::nothrow) char[body_size];
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ if (lseek(f_outfd, sizeof(PersistFileHeder), SEEK_SET) == sizeof(PersistFileHeder)) { // LCOV_EXCL_BR_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ if (read(f_outfd, buf, body_size) == static_cast<ssize_t>(body_size)) { // LCOV_EXCL_BR_LINE 5: read's error case // NOLINT[whitespace/line_length]
+ PersistFileHeder f_header;
+ std::memcpy(&f_header.check_code, NPP_CHECK_CODE, sizeof(f_header.check_code));
+ f_header.crc = static_cast<UI_32>(CalcCRC(buf, static_cast<UI_32>(body_size)));
+ if (lseek(f_outfd, 0, SEEK_SET) == 0) { // LCOV_EXCL_BR_LINE 5: lseek's error case
+ if (write(f_outfd, &f_header, sizeof(f_header)) == sizeof(f_header)) { // LCOV_EXCL_BR_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ eStatus = eFrameworkunifiedStatusOK;
+
+ // file duplicate
+ std::string bak_file_path = f_cfilepath;
+ bak_file_path.append(".valid.bak");
+ int bak_fd = open(bak_file_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0660);
+ if (bak_fd >= 0) { // LCOV_EXCL_BR_LINE 5: open's error case
+ if (write(bak_fd, &f_header, sizeof(f_header)) == sizeof(f_header)) { // LCOV_EXCL_BR_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ if (write(bak_fd, buf, body_size) != static_cast<ssize_t>(body_size)) { // LCOV_EXCL_BR_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ }
+ close(bak_fd);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: open's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: write's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lseek fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: read's error case
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lseek fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: lseek's error case
+ }
+ delete[] buf;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Mem Allocation failure"); // LCOV_EXCL_LINE 5: new's error case
+ }
+ } else {
+ // 0byte file through
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "fstat fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: fstat's error case
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CBinaryAccesser::CheckFileHeader(int f_infd) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ struct stat st;
+
+ if (fstat(f_infd, &st) == 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case
+ if (st.st_size > static_cast<long>(sizeof(PersistFileHeder))) { // NOLINT (runtime/int)
+ size_t body_size = static_cast<size_t>(st.st_size - sizeof(PersistFileHeder));
+ char *buf = new(std::nothrow) char[body_size];
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ if (lseek(f_infd, sizeof(PersistFileHeder), SEEK_SET) == sizeof(PersistFileHeder)) { // LCOV_EXCL_BR_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ if (read(f_infd, buf, body_size) == static_cast<ssize_t>(body_size)) {
+ UI_32 crc32 = static_cast<UI_32>(CalcCRC(buf, static_cast<UI_32>(body_size)));
+ PersistFileHeder f_header;
+ if (lseek(f_infd, 0, SEEK_SET) == 0) { // LCOV_EXCL_BR_LINE 5: lseek's error case
+ if (read(f_infd, &f_header, sizeof(f_header)) == sizeof(f_header)) { // LCOV_EXCL_BR_LINE 5: read's error case // NOLINT[whitespace/line_length]
+ if (std::memcmp(&f_header.check_code, NPP_CHECK_CODE, sizeof(f_header.check_code)) == 0
+ && f_header.crc == crc32) {
+ m_uiCurStrOffset = sizeof(f_header);
+ m_uiCurStrSize = static_cast<UI_32>(st.st_size);
+ eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "file header fail: %02x %02x %02x %02x %#x:%#x",
+ f_header.check_code[0], f_header.check_code[1],
+ f_header.check_code[2], f_header.check_code[3], crc32, f_header.crc);
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: read's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lseek fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: lseek's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail: %s", strerror(errno));
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "lseek fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: lseek's error case
+ }
+ delete[] buf;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Mem Allocation failure"); // LCOV_EXCL_LINE 5: new's error case
+ }
+ } else {
+ // 0byte file through
+ eStatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "fstat fail: %s", strerror(errno)); // LCOV_EXCL_LINE 5: fstat's error case
+ }
+
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CBinaryAccesser::OpenBakFileForReading(int *f_infd, std::string f_cfilepath) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+ std::string bak_file_path = f_cfilepath;
+ bak_file_path.append(".bak");
+
+ *f_infd = open(bak_file_path.c_str(), O_RDONLY);
+ if (*f_infd >= 0) {
+ struct stat st;
+ if (fstat(*f_infd, &st) == 0) {
+ // Error if bak file is 0byte
+ if (st.st_size > 0) {
+ if (eFrameworkunifiedStatusOK == CheckFileHeader(*f_infd)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s fail. bak file correct.", f_cfilepath.c_str());
+ eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ close(*f_infd);
+ *f_infd = -1;
+ }
+ } else {
+ close(*f_infd);
+ *f_infd = -1;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "fstat fail: %s", strerror(errno));
+ close(*f_infd);
+ *f_infd = -1;
+ }
+ }
+
+ return eStatus;
+}
+
+/*
+ * CRC-32C lookup table
+ *
+ * Polynomial 0x1EDC6F41
+ */
+static const UI_32 crc32_lookup[4][256] = { // NOLINT (readability/naming)
+ {
+ },
+ {
+ },
+ {
+ },
+ {
+ }
+};
+
+UI_32 CBinaryAccesser::CalcCRC(PVOID f_pdata, UI_32 f_size) {
+ UI_32 crc = 0xFFFFFFFF;
+ const UI_32 *current = (const UI_32 *)f_pdata;
+
+ while (f_size >= 4) {
+ UI_32 one = *current++ ^ crc;
+ crc = crc32_lookup[0][(one >> 24) & 0xFF] ^
+ crc32_lookup[1][(one >> 16) & 0xFF] ^
+ crc32_lookup[2][(one >> 8) & 0xFF] ^
+ crc32_lookup[3][one & 0xFF];
+ f_size -= 4;
+ }
+
+ const UI_8 *current_char = (const UI_8 *)current;
+ while (f_size-- > 0) {
+ crc = (crc >> 8) ^ crc32_lookup[0][(crc & 0xFF) ^ *current_char++];
+ }
+
+ return ~crc;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_copy_worker.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_copy_worker.cpp
new file mode 100644
index 00000000..4638a7d4
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_copy_worker.cpp
@@ -0,0 +1,1153 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file implements the CCopyWorker class.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <native_service/ns_util_crc.h>
+#include <native_service/ns_logger_if.h>
+
+// standard headers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <dirent.h>
+
+#include <string>
+#include <utility>
+
+// ns headers
+#include "ns_npp_copy_worker.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_fs_directory.h"
+#include "ns_npp_persistence.h"
+#include "ns_npp_threads.h"
+#include "ns_npp.h"
+
+#ifdef AGL_STUB
+#include <other_service/strlcpy.h>
+/*#include "PosixBasedOS001legacy_types.h"*/
+#include <unistd.h>
+#include <sys/syscall.h>
+#endif
+
+#define NS_NPP_WRITESIZE1 4096
+#define NS_NPP_WRITESIZE2 32768
+#define NS_NPP_REMOVE_DIR_DELAY 100 // in ms
+#define NS_NPP_FILEWRITE_DELAY 50 // in ms
+
+pthread_mutex_t g_mutworkerthread = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t CCopyWorker::m_sAbortMutex = PTHREAD_MUTEX_INITIALIZER;
+BOOL CCopyWorker::m_sbAbortCopy = FALSE;
+
+template <typename C, eFrameworkunifiedStatus(C::*M)(HANDLE)> EFrameworkunifiedStatus WorkerCallback(HANDLE hthread) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ C *l_pClass = static_cast<C *>(FrameworkunifiedGetThreadSpecificData(hthread));
+
+ if (l_pClass) { // LCOV_EXCL_BR_LINE 6: l_pClass can't be NULL
+ l_estatus = (l_pClass->*M)(hthread);
+ }
+
+ return l_estatus;
+}
+
+// Initialize static members
+TMServiceTagCRC CCopyWorker::CCopyWorker::g_mservicetagcrc;
+CMutex CCopyWorker::CCopyWorker::g_objmtxservicetag;
+
+static FrameworkunifiedProtocolCallbackHandler aServiceHandlers[] = { // NOLINT (readability/naming) // LCOV_EXCL_BR_LINE 11: unexpected branch
+ { CP_WRK_CMD_COPY, WorkerCallback<CCopyWorker, &CCopyWorker::OnWrkCmdCopy> },
+ { CP_WRK_CMD_RESUME, WorkerCallback<CCopyWorker, &CCopyWorker::OnWrkCmdResume> },
+ { AR_CMD_ARCHIVE, WorkerCallback<CCopyWorker, &CCopyWorker::OnWrkCmdArchive> },
+ { CMD_WRK_SHUTDOWN_REQ, WorkerCallback<CCopyWorker, &CCopyWorker::OnCmdShutdownRequest>},
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CCopyWorker
+/// Constructor of CCopyWorker class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CCopyWorker::CCopyWorker() {
+ pthread_mutex_init(&m_sAbortMutex, NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CCopyWorker
+/// Destructor of CCopyWorker class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CCopyWorker::~CCopyWorker() {
+ pthread_mutex_destroy(&m_sAbortMutex);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Abort
+/// Method to abort worker thread.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CCopyWorker::Abort() { // LCOV_EXCL_START 8: not used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ pthread_mutex_lock(&m_sAbortMutex);
+ m_sbAbortCopy = TRUE;
+ pthread_mutex_unlock(&m_sAbortMutex);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// InAbortState
+/// Method to check for abort state.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CCopyWorker::InAbortState() const {
+ BOOL l_bAbortStatus = FALSE;
+ pthread_mutex_lock(&m_sAbortMutex);
+ l_bAbortStatus = m_sbAbortCopy;
+ pthread_mutex_unlock(&m_sAbortMutex);
+
+ return l_bAbortStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetCopyStatusToFailure
+/// Method to set the copy status failure.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::SetCopyStatusToFailure(NSP_CopyStatusResponse &f_tcopystatusresponse, // LCOV_EXCL_START 8: not used // NOLINT[whitespace/line_length]
+ const ENPS_CopyWorkerFailures f_eworkerfailcmd) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ f_tcopystatusresponse.m_bpersistencechk = FALSE;
+ f_tcopystatusresponse.m_ecopyfailures = f_eworkerfailcmd;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnWrkCmdCopy
+/// Callback method on copy command.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::OnWrkCmdCopy(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ NSP_CopyStatusResponse l_tCopyStatus = {};
+ NSP_CopyInfoCmd l_tCopyInfo = {};
+ UI_32 l_uiFileSize = 0;
+ UI_32 l_ui32FileCRC = 0;
+ PSTR l_cTmpStorageFile = NULL;
+
+ if (NULL != hthread) { // LCOV_EXCL_BR_LINE 6: hthread can't be NULL
+ if (FrameworkunifiedGetMsgLength(hthread) == sizeof(l_tCopyInfo)) { // LCOV_EXCL_BR_LINE 200: the size of msg must be sizeof(NSP_CopyInfoCmd) // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(hthread, &l_tCopyInfo, sizeof(NSP_CopyInfoCmd), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ l_tCopyStatus.m_eloadtype = l_tCopyInfo.m_eloadtype;
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(l_tCopyStatus.m_cpersistenttag, l_tCopyInfo.m_cpersistenttag, sizeof(l_tCopyStatus.m_cpersistenttag));
+ strlcpy(l_tCopyStatus.m_crequesterappname,
+ l_tCopyInfo.m_crequesterappname,
+ sizeof(l_tCopyStatus.m_crequesterappname));
+#endif
+
+ l_tCopyStatus.m_epersisttype = l_tCopyInfo.m_epersisttype;
+
+ if (ENOTIFICATIONPERSISTENTSERVICECOMPRESSUSINGLIBZ == l_tCopyInfo.m_ecompressiontype) { // LCOV_EXCL_BR_LINE 6: l_tCopyInfo.m_ecompressiontype can't be ENOTIFICATIONPERSISTENTSERVICECOMPRESSUSINGLIBZ // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: l_tCopyInfo.m_ecompressiontype can't be ENOTIFICATIONPERSISTENTSERVICECOMPRESSUSINGLIBZ
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CCopyWorker::CArchive *l_pCArchive = new(std::nothrow) CCopyWorker::CArchive();
+
+ if (NULL != l_pCArchive) {
+ // Start the folder archive or extract operation
+ if (eFrameworkunifiedStatusOK == (l_estatus = l_pCArchive->FileOperationUsingLibz(l_tCopyInfo, l_tCopyStatus))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Compress/Decompress Successful");
+ } else {
+ l_estatus = eFrameworkunifiedStatusFail; // Set the archive status to failure
+ }
+ delete l_pCArchive;
+ l_pCArchive = NULL;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Tag: %s SourceFile: %s DestFile: %s",
+ l_tCopyInfo.m_cpersistenttag != 0 ? l_tCopyInfo.m_cpersistenttag : NULL,
+ l_tCopyInfo.m_csourcepath != 0 ? l_tCopyInfo.m_csourcepath : NULL,
+ l_tCopyInfo.m_cdestinationpath != 0 ? l_tCopyInfo.m_cdestinationpath : NULL);
+
+ if (LOADTYPE_RELEASE == l_tCopyStatus.m_eloadtype) {
+ // if release, source file needs to check whether it's changed or not
+ l_cTmpStorageFile = l_tCopyInfo.m_csourcepath;
+ } else if (LOADTYPE_LOAD == l_tCopyStatus.m_eloadtype) { // LCOV_EXCL_BR_LINE 6: m_eloadtype must be LOADTYPE_RELEASE or LOADTYPE_LOAD // NOLINT[whitespace/line_length]
+ // if load, dest file needs to check whether it's changed or not
+ l_cTmpStorageFile = l_tCopyInfo.m_cdestinationpath;
+
+ // check if file on temporary location exists, then no need to load from persistent memory
+ if (0 == access(l_tCopyInfo.m_cdestinationpath, F_OK)) { // LCOV_EXCL_BR_LINE 5: access's error case
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "File to load::%s for source::%s "
+ "is already present on path:: %s.",
+ l_tCopyInfo.m_cpersistenttag != 0 ? l_tCopyInfo.m_cpersistenttag : NULL,
+ l_tCopyStatus.m_crequesterappname != 0 ? l_tCopyStatus.m_crequesterappname : NULL,
+ l_tCopyInfo.m_cdestinationpath != 0 ? l_tCopyInfo.m_cdestinationpath : NULL);
+ l_estatus = eFrameworkunifiedStatusFileLoadSuccess;
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // let l_cTmpStorageFile be NULL.
+ }
+
+ if (eFrameworkunifiedStatusFileLoadSuccess == l_estatus) {
+ l_estatus = eFrameworkunifiedStatusOK;
+ } else {
+ if (NULL != l_cTmpStorageFile) { // LCOV_EXCL_BR_LINE 6: l_cTmpStorageFile can't be NULL
+ if (!VerifyWithStoredCRC(l_tCopyStatus.m_crequesterappname,
+ l_tCopyStatus.m_cpersistenttag,
+ l_cTmpStorageFile,
+ l_ui32FileCRC)) { // l_ui32FileCRC: out param
+ // Check if file release and CRC verification is enabled
+ if ((LOADTYPE_RELEASE == l_tCopyStatus.m_eloadtype) && (CNSNPP::m_siCRCCheckCount > 0)) { // LCOV_EXCL_BR_LINE 200: cannot test code // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200: cannot test code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = TryFileCopyWithCRCCheck(l_tCopyInfo.m_csourcepath,
+ l_tCopyInfo.m_cdestinationpath,
+ CNSNPP::m_siCRCCheckCount);
+ // LCOV_EXCL_STOP
+ } else {
+ if (LOADTYPE_RELEASE == l_tCopyStatus.m_eloadtype) {
+ l_estatus = CopyFile(l_tCopyInfo.m_csourcepath,
+ l_tCopyInfo.m_cdestinationpath,
+ l_uiFileSize,
+ TRUE);
+ } else {
+ l_estatus = CopyFile(l_tCopyInfo.m_csourcepath,
+ l_tCopyInfo.m_cdestinationpath,
+ l_uiFileSize,
+ FALSE);
+ }
+ }
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written:%d file=%s",
+ l_uiFileSize, l_tCopyInfo.m_cdestinationpath != 0 ? l_tCopyInfo.m_cdestinationpath : NULL);
+ if (0 == l_ui32FileCRC) {
+ if (eFrameworkunifiedStatusOK != CalculateCRC32(l_cTmpStorageFile, l_ui32FileCRC)) { // LCOV_EXCL_BR_LINE 200: CalculateCRC32() return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200: CalculateCRC32() return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warn: getting crc. File:%s, crc:%d",
+ l_cTmpStorageFile, l_ui32FileCRC);
+ // LCOV_EXCL_STOP
+ }
+ }
+ UpdateTagCRC(l_tCopyStatus.m_crequesterappname, l_tCopyInfo.m_cpersistenttag, l_ui32FileCRC);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FileCopy Error, status : 0x%x", l_estatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
+ "File %s not changed. No copy done. Load type:%d. Tag:%s for Requester:%s.",
+ l_cTmpStorageFile,
+ l_tCopyStatus.m_eloadtype,
+ l_tCopyStatus.m_cpersistenttag != 0 ? l_tCopyStatus.m_cpersistenttag : NULL,
+ l_tCopyStatus.m_crequesterappname != 0 ? l_tCopyStatus.m_crequesterappname : NULL);
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_cTmpStorageFile can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unknown load type:%d, for tag:%s",
+ l_tCopyStatus.m_eloadtype,
+ l_tCopyStatus.m_cpersistenttag != 0 ? l_tCopyStatus.m_cpersistenttag : NULL);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_estatus) {
+ l_tCopyStatus.m_bpersistencechk = FALSE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "COPY_FAILED_ID sending parent message. Tag:%s for Requester:%s.",
+ l_tCopyStatus.m_cpersistenttag != 0 ? l_tCopyStatus.m_cpersistenttag : NULL,
+ l_tCopyStatus.m_crequesterappname != 0 ? l_tCopyStatus.m_crequesterappname : NULL);
+
+ FrameworkunifiedSendParent(hthread, CP_WRK_NTFY, sizeof(NSP_CopyStatusResponse), &l_tCopyStatus);
+ } else {
+ l_tCopyStatus.m_bpersistencechk = TRUE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "COPY_COMPLETE_ID sending parent message. Tag:%s for Requester:%s.",
+ l_tCopyStatus.m_cpersistenttag != 0 ? l_tCopyStatus.m_cpersistenttag : NULL,
+ l_tCopyStatus.m_crequesterappname != 0 ? l_tCopyStatus.m_crequesterappname : NULL);
+
+ FrameworkunifiedSendParent(hthread, CP_WRK_NTFY, sizeof(NSP_CopyStatusResponse), &l_tCopyStatus);
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:FrameworkunifiedGetMsgDataOfSize returned:%d", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 200: the size of msg must be sizeof(NSP_CopyInfoCmd)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:MsgLength: Expected:%ld, Received:%d.",
+ static_cast<long int>(sizeof(l_tCopyInfo)), FrameworkunifiedGetMsgLength(hthread)); // NOLINT (runtime/int)
+ // LCOV_EXCL_STOP
+ }
+ l_estatus = SendAck(hthread, CP_WRK_CMD_COPY);
+ } else {
+ // LCOV_EXCL_START 6: hthread can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetCopyBufSize
+/// Get the proper buffer size.
+////////////////////////////////////////////////////////////////////////////////////////////////
+SI_32 CCopyWorker::GetCopyBufSize(SI_32 f_si32openfd, UI_32 &f_ui32filesize) {
+ UI_32 l_ui32BufSize = NS_NPP_WRITESIZE1;
+ // to get the size of file
+ struct stat l_tSrcFstat = {};
+
+ if (-1 == fstat(f_si32openfd , &l_tSrcFstat)) { // LCOV_EXCL_BR_LINE 5: fstat's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "fstat failure, errno:%d", errno); // LCOV_EXCL_LINE 5: fstat's error case
+ } else {
+ f_ui32filesize = static_cast<UI_32>(l_tSrcFstat.st_size); // set out param
+ if (l_tSrcFstat.st_size < NS_NPP_WRITESIZE1) {
+ l_ui32BufSize = NS_NPP_WRITESIZE1;
+ } else {
+ l_ui32BufSize = NS_NPP_WRITESIZE2;
+ }
+ }
+ return l_ui32BufSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CopyFile
+/// Copy the content of source file f_csrcpath to destination file f_cdestpath
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::CopyFile(PCSTR f_csrcpath, PCSTR f_cdestpath, UI_32 &f_uiNS_NPP_WRITESIZE, BOOL btmpfile) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // declare variables
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ SI_32 l_iSourceFileFd = -1; // file descriptor of source file
+ SI_32 l_iDestFileFd = -1; // file descriptor of destination file
+ PSTR l_cWriteBuffer = NULL;
+ SI_32 l_si32BufSize = NS_NPP_WRITESIZE1;
+ size_t l_iReadBuffLength = 0; // size of data read from source file
+ UI_32 l_ui32SrcFileSize = 0;
+ std::string l_cTempDestPath; // temporary file path
+ if (btmpfile == FALSE) {
+ l_cTempDestPath = f_cdestpath;
+ } else {
+ l_cTempDestPath = CPersistence::GetStoragePath(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ if (l_cTempDestPath.length() > 0) { // LCOV_EXCL_BR_LINE 6: l_cTempDestPath.length() is bigger than 0
+ l_cTempDestPath.append(RELEASETEMP_DIR); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ // create the destination folder path if does not exists
+ if (!CFSDirectory::DoesDirecotryExist(l_cTempDestPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s DOESN'T exist, Creating...", l_cTempDestPath.c_str());
+ if (eFrameworkunifiedStatusOK != (l_estatus = CFSDirectory::CreateDirectory(l_cTempDestPath))) { // LCOV_EXCL_BR_LINE 200: CreateDirectory() is eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200: CreateDirectory() is eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to create %s, errno:%d", l_cTempDestPath.c_str(), errno);
+ return l_estatus;
+ // LCOV_EXCL_STOP
+ }
+ }
+ l_cTempDestPath.append(RELEASETEMP_FILENAME);
+
+ } else {
+ // LCOV_EXCL_START 6: l_cTempDestPath.length() is bigger than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_cTempDestPath.length():%ld", static_cast<long int>(l_cTempDestPath.length())); // NOLINT (runtime/int)
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+ // get the destination folder path from full file path
+ std::string l_cOutDirPath(f_cdestpath);
+ size_t l_ifound = l_cOutDirPath.rfind("/");
+ l_cOutDirPath = l_cOutDirPath.substr(0, l_ifound);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Full Path for persistence %s.", f_cdestpath);
+
+ // create the destination folder path if does not exists
+ if (!CFSDirectory::DoesDirecotryExist(l_cOutDirPath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s DOESN'T exist, Creating...", l_cOutDirPath.c_str());
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = CFSDirectory::CreateDirectory(l_cOutDirPath))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to create %s, errno:%d", l_cOutDirPath.c_str(), errno);
+ return eFrameworkunifiedStatusFail;
+ }
+ }
+
+ // open source file
+ if (-1 == (l_iSourceFileFd = open(f_csrcpath, O_RDONLY, S_IRUSR))) { // LCOV_EXCL_BR_LINE 5: open's error case
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Warning :: CP_WRK_FAILURE_SRC_NOT_FND, errno:%d", errno);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ // open the destination file for writing or create if does not exists
+ if (-1 == (l_iDestFileFd = open(l_cTempDestPath.c_str(), O_WRONLY | O_CREAT | O_TRUNC, // LCOV_EXCL_BR_LINE 5: open's error case // NOLINT[whitespace/line_length]
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))) {
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CP_WRK_FAILURE_DST_CREATE, errno:%d", errno);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ l_si32BufSize = GetCopyBufSize(l_iSourceFileFd, l_ui32SrcFileSize);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Src file:%s, size:%d", f_csrcpath, l_ui32SrcFileSize);
+ l_cWriteBuffer = (PSTR) std::malloc(l_si32BufSize);
+ f_uiNS_NPP_WRITESIZE = 0;
+
+ if (NULL != l_cWriteBuffer) { // LCOV_EXCL_BR_LINE 5: malloc's error case
+#ifdef AGL_STUB
+ while (1) {
+ std::memset(l_cWriteBuffer, 0, l_si32BufSize);
+ l_iReadBuffLength = read(l_iSourceFileFd, l_cWriteBuffer, l_si32BufSize);
+ if (0 == l_iReadBuffLength) {
+ break;
+ } else if (0 < l_iReadBuffLength) { // LCOV_EXCL_BR_LINE 5: read's error case
+ f_uiNS_NPP_WRITESIZE += static_cast<UI_32>(l_iReadBuffLength);
+
+ if (-1 == write(l_iDestFileFd, l_cWriteBuffer, l_iReadBuffLength)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CP_WRK_FAILURE_WRITE_ERROR_CP, errno:%d", errno);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (InAbortState()) { // LCOV_EXCL_START 200: the state can't be aborted
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CP_WRK_FAILURE_ABORT_DURING_CP");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ // LCOV_EXCL_START 5: read's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error reading from source file, errno:%d", errno);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK != l_estatus) {
+ break;
+ }
+ }
+#else
+ while (!eof(l_iSourceFileFd)) {
+ std::memset(l_cWriteBuffer, 0, l_si32BufSize);
+ if (-1 != (l_iReadBuffLength = read(l_iSourceFileFd, l_cWriteBuffer, l_si32BufSize))) {
+ f_uiNS_NPP_WRITESIZE += static_cast<UI_32>(l_iReadBuffLength);
+
+ if (-1 == write(l_iDestFileFd, l_cWriteBuffer, l_iReadBuffLength)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CP_WRK_FAILURE_WRITE_ERROR_CP, errno:%d", errno);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (InAbortState()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CP_WRK_FAILURE_ABORT_DURING_CP");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error reading from source file, errno:%d", errno);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (eFrameworkunifiedStatusOK != l_estatus) {
+ break;
+ }
+ }
+#endif
+
+ free(l_cWriteBuffer);
+ l_cWriteBuffer = NULL;
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Mem alloc error for l_cWriteBuffer");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ close(l_iDestFileFd);
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ if (btmpfile == TRUE) {
+ if (0 != rename(l_cTempDestPath.c_str(), f_cdestpath)) { // LCOV_EXCL_START 5: rename's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Error renaming file %s to %s, errno: %d", l_cTempDestPath.c_str(), f_cdestpath,
+ errno);
+ }
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // remove the source file after successful copy
+ if (0 != remove(l_cTempDestPath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Temporary file not deleted::%s, errno:%d", l_cTempDestPath.c_str(), errno);
+ }
+ }
+ }
+
+ close(l_iSourceFileFd);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnWrkCmdResume
+/// Callback on resume worker thread command
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::OnWrkCmdResume(HANDLE hthread) { // LCOV_EXCL_START 8: not used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (hthread) {
+ pthread_mutex_lock(&m_sAbortMutex);
+ m_sbAbortCopy = FALSE;
+ pthread_mutex_unlock(&m_sAbortMutex);
+ l_estatus = SendAck(hthread, CP_WRK_CMD_RESUME);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnWrkCmdStart
+/// Callback method on start worker thread command.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::OnWrkCmdStart(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (hthread) { // LCOV_EXCL_BR_LINE 6:hthread can't be NULL
+ l_estatus = SendAck(hthread, CP_WRK_CMD_START);
+ } else {
+ // LCOV_EXCL_START 6:hthread can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnWrkCmdStop
+/// Callback method on stop worker thread command.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::OnWrkCmdStop(HANDLE hthread) { // LCOV_EXCL_START 200: can't test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (hthread) {
+ l_estatus = SendAck(hthread, CP_WRK_CMD_STOP);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnCmdShutdownRequest
+/// Callback method for shutdown request command.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::OnCmdShutdownRequest(HANDLE hthread) { // LCOV_EXCL_START 8: not used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (hthread) {
+ NSP_CopyShutdownAck l_tCopyShutdownAck = {};
+ if (FrameworkunifiedGetMsgLength(hthread) == sizeof(l_tCopyShutdownAck)) {
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(hthread, &l_tCopyShutdownAck, sizeof(NSP_CopyShutdownAck),
+ eSMRRelease))) {
+ FrameworkunifiedSendParent(hthread, CMD_WRK_SHUTDOWN_ACK, sizeof(NSP_CopyShutdown), &l_tCopyShutdownAck);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:FrameworkunifiedGetMsgDataOfSize returned:%d", l_estatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:MsgLength: Expected:%ld, Received:%d.",
+ static_cast<long int>(sizeof(l_tCopyShutdownAck)), FrameworkunifiedGetMsgLength(hthread)); // NOLINT (runtime/int)
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SendAck
+/// Method to send ack to the parent thread
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::SendAck(HANDLE hthread, const ENSP_CopyWorkerProtocol &f_eworkercmd) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (hthread) { // LCOV_EXCL_BR_LINE 6: hthread can't be NULL
+ NSP_CopyAckMsg l_tCopyAckMs = {};
+ l_tCopyAckMs.m_eworkerprotocol = f_eworkercmd;
+ l_estatus = FrameworkunifiedSendParent(hthread, CP_WRK_ACK_CMD_COMPLETE, sizeof(l_tCopyAckMs), &l_tCopyAckMs);
+ } else {
+ // LCOV_EXCL_START 6: hthread can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnWrkCmdArchive
+/// Callback method on archive command
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::OnWrkCmdArchive(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // Archive response struct
+ NSP_CopyStatusResponse l_tArchiveStatusResponse;
+
+ if (f_hThread) { // LCOV_EXCL_BR_LINE 6: f_hThread can't be NULL
+ // Archive info struct
+ NSP_CopyInfoCmd l_tArchiveInfo = {};
+
+ if (FrameworkunifiedGetMsgLength(f_hThread) == sizeof(l_tArchiveInfo)) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(f_hThread, &l_tArchiveInfo, sizeof(NSP_CopyInfoCmd), // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ eSMRRelease))) {
+ // Copy archive status response
+ l_tArchiveStatusResponse.m_eloadtype = l_tArchiveInfo.m_eloadtype;
+ l_tArchiveStatusResponse.m_epersisttype = l_tArchiveInfo.m_epersisttype;
+ std::strncpy(l_tArchiveStatusResponse.m_cpersistenttag, l_tArchiveInfo.m_cpersistenttag, (MAX_PATH_LENGTH - 1));
+ std::strncpy(l_tArchiveStatusResponse.m_crequesterappname,
+ l_tArchiveInfo.m_crequesterappname, (MAX_PATH_LENGTH - 1));
+
+ CCopyWorker::CArchive *l_pCArchive = new CCopyWorker::CArchive();
+
+ // Start the folder archive or extract operation
+ if (eFrameworkunifiedStatusOK == (l_estatus = l_pCArchive->Archive(l_tArchiveInfo, l_tArchiveStatusResponse))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Archive/Extract Successful!");
+ } else {
+ // Set the archive status to failure
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ if (NULL != l_pCArchive) { // LCOV_EXCL_BR_LINE 5: l_pCArchive can't be null
+ delete l_pCArchive;
+ l_pCArchive = NULL;
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:FrameworkunifiedGetMsgDataOfSize returned:%d", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error:MsgLength: Expected:%ld, Received:%d.",
+ static_cast<long int>(sizeof(l_tArchiveInfo)), FrameworkunifiedGetMsgLength(f_hThread)); // NOLINT (runtime/int)
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK != l_estatus) {
+ l_tArchiveStatusResponse.m_bpersistencechk = FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Archive/Extract fail.Sending parent message!");
+ } else {
+ l_tArchiveStatusResponse.m_bpersistencechk = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Archive/Extract success.Sending parent message!");
+ }
+
+ FrameworkunifiedSendParent(f_hThread, CP_WRK_NTFY, sizeof(NSP_CopyStatusResponse), &l_tArchiveStatusResponse);
+ } else {
+ // LCOV_EXCL_START 6: f_hThread can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread Application Handle NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPCopyWorkerOnStart
+/// Callback method on start of worker thread
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPCopyWorkerOnStart(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (hthread) { // LCOV_EXCL_BR_LINE 6: hthread can't be NULL
+ pthread_mutex_lock(&g_mutworkerthread);
+
+ // Note: this variable is made static just to ignore the resource leak showing in coverity analysis
+ static CCopyWorker *l_pccopyworker = NULL;
+
+ l_pccopyworker = new(std::nothrow) CCopyWorker; // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ if (NULL != l_pccopyworker) { // LCOV_EXCL_BR_LINE 5: l_pccopyworker can't be NULL
+ if (eFrameworkunifiedStatusOK == (l_estatus = l_pccopyworker->OnWrkCmdStart(hthread))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ l_estatus = FrameworkunifiedSetThreadSpecificData(hthread, l_pccopyworker);
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ l_estatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hthread, AppName, aServiceHandlers, static_cast<UI_32>(_countof(aServiceHandlers)));
+
+ if (0 == std::strcmp(NS_NPP_WRITE_THREAD_NAME, FrameworkunifiedGetAppName(hthread))) {
+ l_estatus = FrameworkunifiedAttachCallbackToDispatcher(hthread, AppName,
+ CMD_DELETE_OLD_DATA, NPServiceOnDeleteOldDataCmd);
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ delete l_pccopyworker;
+ l_pccopyworker = NULL;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ delete l_pccopyworker;
+ l_pccopyworker = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread Start failed.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 5: l_pccopyworker can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Worker Object Null.");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ pthread_mutex_unlock(&g_mutworkerthread);
+ } else {
+ // LCOV_EXCL_START 6: hthread can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPCopyWorkerOnStop
+/// Callback method on stop of worker thread
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPCopyWorkerOnStop(HANDLE hthread) { // LCOV_EXCL_START 200: can't test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hthread) {
+ pthread_mutex_lock(&g_mutworkerthread);
+ CCopyWorker *l_pccopyworker = static_cast<CCopyWorker *>(FrameworkunifiedGetThreadSpecificData(hthread));
+
+ if (NULL != l_pccopyworker) {
+ l_pccopyworker->OnWrkCmdStop(hthread);
+
+ delete l_pccopyworker;
+ l_pccopyworker = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Worker Object Null");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSetThreadSpecificData(hthread, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSetThreadSpecificData Error, status=%d", l_estatus);
+ }
+
+ PCSTR l_cservice = FrameworkunifiedGetAppName(hthread);
+ if (NULL != l_cservice) {
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedDetachServiceFromDispatcher(hthread, l_cservice))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Detaching service %s from dispatcher, status=%d", l_cservice, l_estatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetAppName returned NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ pthread_mutex_unlock(&g_mutworkerthread);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPServiceOnDeleteOldDataCmd
+/// This callback is used to delete the data which was requested to be deleted during
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPServiceOnDeleteOldDataCmd(HANDLE f_happ) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ SI_32 l_ithreadcreate = 0;
+ pthread_attr_t l_tattr;
+ struct sched_param l_tschedparam = {};
+
+ // thread id
+ pthread_t childthread = 0;
+
+ if (EOK == pthread_attr_init(&l_tattr)) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // detach the thread from parent thread
+ if (EOK != pthread_attr_setdetachstate(&l_tattr, PTHREAD_CREATE_DETACHED)) { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // LCOV_EXCL_START 11:except,C++ STL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error setting detach state attribute for thread %s", NS_NPP_DATA_RESET_THREAD_NAME);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 200: l_estatus must be eFrameworkunifiedStatusOK
+ // set the schedule property of thread
+ if (EOK != pthread_attr_setinheritsched(&l_tattr, PTHREAD_EXPLICIT_SCHED)) { // LCOV_EXCL_BR_LINE 5:except,C++ STL // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:except,C++ STL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error setting inherit schedule attribute for thread %s", NS_NPP_DATA_RESET_THREAD_NAME);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 200: l_estatus must be eFrameworkunifiedStatusOK
+ if (EOK != pthread_attr_getschedparam(&l_tattr, &l_tschedparam)) { // LCOV_EXCL_BR_LINE 5:except,C++ STL
+ // LCOV_EXCL_START 5:except,C++ STL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error getting schedule param attribute for thread %s", NS_NPP_DATA_RESET_THREAD_NAME);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 200: l_estatus must be eFrameworkunifiedStatusOK
+ // set the schedule priority of thread
+ l_tschedparam.sched_priority = NS_NPP_DATA_RESET_THREAD_PRIO;
+ if (EOK != pthread_attr_setschedparam(&l_tattr, &l_tschedparam)) { // LCOV_EXCL_BR_LINE 5:except,C++ STL
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error setting schedule param attribute for thread %s", NS_NPP_DATA_RESET_THREAD_NAME);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ // start the child thread
+ if (EOK == (l_ithreadcreate = pthread_create(&childthread, &l_tattr, NSPDataResetThreadCallback, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Thread id %ld created, name=%s, prio=%d", childthread, NS_NPP_DATA_RESET_THREAD_NAME,
+ NS_NPP_DATA_RESET_THREAD_PRIO);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "pthread_create failed for %s, error = %d", NS_NPP_DATA_RESET_THREAD_NAME,
+ l_ithreadcreate);
+ }
+ }
+
+ // release the thread attribute object
+ pthread_attr_destroy(&l_tattr);
+ } else {
+ // LCOV_EXCL_START 11:except,C++ STL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to initialize attribute for thread %s", NS_NPP_DATA_RESET_THREAD_NAME);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPDataResetThreadCallback
+/// Callback of data reset thread.
+///////////////////////////////////////////////////////////////////////////////////////////
+PVOID NSPDataResetThreadCallback(PVOID f_parg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string f_csourcepath = "";
+ std::string f_ctargetpath = "";
+ std::string l_ctargetdir = "";
+
+ DIR *l_pdir = NULL;
+ struct dirent *l_pdirent = NULL;
+
+ // set the name of thread
+ if (EOK == pthread_setname_np(0, NS_NPP_DATA_RESET_THREAD_NAME)) { // LCOV_EXCL_BR_LINE 5:pthread_setname_np's error case // NOLINT[whitespace/line_length]
+#ifdef AGL_STUB
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Name of thread id %ld set to %s",
+ syscall(__NR_gettid), NS_NPP_DATA_RESET_THREAD_NAME);
+#else
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Name of thread id %d set to %s", gettid(), NS_NPP_DATA_RESET_THREAD_NAME);
+#endif
+ } else {
+ // LCOV_EXCL_START 5:pthread_setname_np's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+#ifdef AGL_STUB
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error setting name %s for thread-id %ld", NS_NPP_DATA_RESET_THREAD_NAME,
+ syscall(__NR_gettid));
+#else
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error setting name %s for thread-id %d", NS_NPP_DATA_RESET_THREAD_NAME, gettid());
+#endif
+ // LCOV_EXCL_STOP
+ }
+
+ f_csourcepath = CPersistence::GetStoragePath();
+ l_pdir = opendir(f_csourcepath.c_str());
+
+ if (NULL != l_pdir) { // LCOV_EXCL_BR_LINE 5:opendir's error case
+ if ('/' != f_csourcepath[f_csourcepath.length() - 1]) { // LCOV_EXCL_BR_LINE 200: there must be '/' in f_csourcepath // NOLINT[whitespace/line_length]
+ f_csourcepath.append("/");
+ }
+
+ /*
+ * Old Persistent data folders which needs to be deleted are renamed with the orignal folder name
+ * followed by underscore and date and time.
+ */
+ std::string l_colduserdata = USERDATA;
+ l_colduserdata.append("_");
+
+ std::string l_coldfactorydata = FACTORYDATA;
+ l_coldfactorydata.append("_");
+
+ std::string l_coldfactorycustomerdata = FACTORYCUSTOMERDATA;
+ l_coldfactorycustomerdata.append("_");
+
+ std::string l_colddealerdata = DEALERDATA;
+ l_colddealerdata.append("_");
+
+ while (NULL != (l_pdirent = readdir(l_pdir))) {
+ l_ctargetdir = l_pdirent->d_name;
+
+ if (0 == l_ctargetdir.find(l_colduserdata) ||
+ 0 == l_ctargetdir.find(l_coldfactorydata) ||
+ 0 == l_ctargetdir.find(l_coldfactorycustomerdata) ||
+ 0 == l_ctargetdir.find(l_colddealerdata)) {
+ f_ctargetpath.assign(f_csourcepath);
+ f_ctargetpath.append(l_ctargetdir);
+
+ if (!CFSDirectory::RemoveDirectory(f_ctargetpath, NS_NPP_REMOVE_DIR_DELAY)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to delete directory :: %s", f_ctargetpath.c_str());
+ }
+ }
+ }
+ closedir(l_pdir); // close the directory
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Directory does not exists :: %s", f_csourcepath.c_str()); // LCOV_EXCL_LINE 5:opendir's error case // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// VerifyWithStoredCRC
+/// Check if crc of the file passed matches with existing crc of a file
+///////////////////////////////////////////////////////////////////////////////////////////
+BOOL CCopyWorker::VerifyWithStoredCRC(PCSTR f_crequesterappname, PCSTR f_cpersistenttag, PCSTR f_cFile,
+ UI_32 &f_ui32crc) {
+ UI_32 l_ui32StoredCrc = 0;
+ BOOL l_bRet = FALSE;
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ TMServiceTagCRC::iterator l_itServiceTag;
+ TMTagCRC::iterator l_itTagCRC;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ f_ui32crc = 0; // initialize with default
+
+ if ((NULL != f_crequesterappname) && (NULL != f_cpersistenttag) && (NULL != f_cFile)) { // LCOV_EXCL_BR_LINE 6: f_crequesterappname, f_cpersistenttag, f_cFile can't be null // NOLINT[whitespace/line_length]
+ // Get the existing crc of a file from the map
+ CCopyWorker::g_objmtxservicetag.ReadLock();
+ l_itServiceTag = CCopyWorker::g_mservicetagcrc.find(f_crequesterappname);
+ if (l_itServiceTag != CCopyWorker::g_mservicetagcrc.end()) {
+ l_itTagCRC = (l_itServiceTag->second).find(f_cpersistenttag);
+ if (l_itTagCRC != (l_itServiceTag->second).end()) {
+ l_ui32StoredCrc = (l_itTagCRC->second);
+ l_estatus = eFrameworkunifiedStatusOK;
+ } else {
+ // Do nothing.
+ }
+ } else {
+ // Do nothing.
+ }
+ CCopyWorker::g_objmtxservicetag.Unlock();
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ // get the crc of a file
+ l_estatus = CalculateCRC32(f_cFile, f_ui32crc);
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 200: CalculateCRC32() return ok
+ if (f_ui32crc == l_ui32StoredCrc) {
+ l_bRet = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "CRC matched. crc:%u", l_ui32StoredCrc);
+ } else {
+ // Do nothing. Return value already set.
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "CRC different. stored:%u, new:%u",
+ l_ui32StoredCrc, f_ui32crc);
+ }
+ } else {
+ // LCOV_EXCL_START: CalculateCRC32() return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warn: getting crc:file:%s, status:%d, errno:%d",
+ f_cFile, l_estatus, errno);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // Do nothing. Return value already set.
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_crequesterappname, f_cpersistenttag, f_cFile can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid param::f_crequesterappname:%p, f_cpersistenttag:%p, f_cFile:%p",
+ f_crequesterappname, f_cpersistenttag, f_cFile);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// UpdateTagCRC
+/// Update the internal map with new crc
+///////////////////////////////////////////////////////////////////////////////////////////
+VOID CCopyWorker::UpdateTagCRC(PCSTR f_crequesterappname, PCSTR f_cpersistenttag, UI_32 f_ui32crc) {
+ TMServiceTagCRC::iterator l_itServiceTag;
+ TMTagCRC::iterator l_itTagCRC;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CCopyWorker::g_objmtxservicetag.ReadLock();
+ l_itServiceTag = CCopyWorker::g_mservicetagcrc.find(f_crequesterappname);
+ if (l_itServiceTag != CCopyWorker::g_mservicetagcrc.end()) {
+ l_itTagCRC = (l_itServiceTag->second).find(f_cpersistenttag);
+ if (l_itTagCRC != (l_itServiceTag->second).end()) {
+ l_itTagCRC->second = f_ui32crc;
+ } else {
+ (l_itServiceTag->second).insert(std::make_pair(f_cpersistenttag, f_ui32crc));
+ }
+ } else {
+ TMTagCRC l_mTagCRC;
+ l_mTagCRC.insert(std::make_pair(f_cpersistenttag, f_ui32crc));
+ CCopyWorker::g_mservicetagcrc.insert(std::make_pair(f_crequesterappname, l_mTagCRC));
+ }
+ CCopyWorker::g_objmtxservicetag.Unlock();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// TryFileCopyWithCRCCheck
+/// Try file copy with CRC validation
+///////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CCopyWorker::TryFileCopyWithCRCCheck(PCSTR f_csource, PCSTR f_cdest, UI_32 f_ui32checkcount) { // LCOV_EXCL_START 200: cannot test code // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ UI_32 l_uiSrcFileCrc = 0;
+ UI_32 l_uiDestFileCrc = 0;
+ UI_32 l_uiFileSize = 0;
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ for (UI_16 l_uiCrcCnt = 1; l_uiCrcCnt <= CNSNPP::m_siCRCCheckCount; l_uiCrcCnt++) {
+ l_uiSrcFileCrc = 0;
+ l_uiDestFileCrc = 0;
+ l_uiFileSize = 0;
+
+ l_estatus = CopyFile(f_csource, f_cdest, l_uiFileSize, TRUE);
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ // calculate crc of file in temp memory(RAM)
+ l_estatus = CalculateCRC32(f_csource, l_uiSrcFileCrc);
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ // calculate crc of file stored in persistent memory
+ l_estatus = CalculateCRC32(f_cdest, l_uiDestFileCrc);
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ if (l_uiSrcFileCrc == l_uiDestFileCrc) { // if checksum matches for both the files
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "CRC Checksum matches for file:%s :: 0x%x", f_csource, l_uiSrcFileCrc);
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO3, __FUNCTION__, "Bytes written:%d file=%s",
+ l_uiFileSize, f_cdest);
+ break;
+ } else { // else delete the file from target
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CRC doesn't match for src:%s::0x%x and dest:%s::0x%x, CRC cnt=%d",
+ f_csource, l_uiSrcFileCrc, f_cdest, l_uiDestFileCrc, l_uiCrcCnt);
+ // if the checksum does not matches even for the last time, do not delete the file from target
+ if (l_uiCrcCnt < (CNSNPP::m_siCRCCheckCount)) {
+ if (0 != remove(f_cdest)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error deleting file:%s, errno:%d", f_cdest, errno);
+ }
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Calculating Checksum for DestFile:%s",
+ f_cdest != 0 ? f_cdest : NULL);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Calculating Checksum for SrcFile:%s",
+ f_csource != 0 ? f_csource : NULL);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FileCopy Error:%d", l_estatus);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_fs_directory.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_fs_directory.cpp
new file mode 100644
index 00000000..8f4f98a0
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_fs_directory.cpp
@@ -0,0 +1,232 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains the implementation for class CFSDirectory.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef AGL_STUB
+#include <other_service/PosixBasedOS001TimeApi.h>
+#endif
+
+#include <stdio.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef AGL_STUB
+#include <cstring>
+#endif
+#include <string>
+
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_types.h"
+#include "ns_npp_fs_directory.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFSDirectory
+/// Constructor of CFSDirectory class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFSDirectory::CFSDirectory() { // LCOV_EXCL_START 8: all methods are static
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFSDirectory
+/// Destructor of CFSDirectory class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFSDirectory::~CFSDirectory() { // LCOV_EXCL_START 8: all methods are static
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDirectory
+/// Method to create a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFSDirectory::CreateDirectory(const std::string &f_cdirpath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (!f_cdirpath.empty()) {
+ PSTR l_cTempDirPath;
+ PSTR l_cParsedDirPath;
+ PCSTR l_cCopypath = f_cdirpath.c_str();
+
+ l_cTempDirPath = const_cast<PSTR >(f_cdirpath.c_str());
+ while (l_estatus == eFrameworkunifiedStatusOK && (l_cParsedDirPath = std::strchr(l_cTempDirPath, '/')) != 0) {
+ if (l_cParsedDirPath != l_cTempDirPath) {
+ /* Neither root nor double slash in path */
+ *l_cParsedDirPath = '\0';
+ if (0 != mkdir(l_cCopypath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { // LCOV_EXCL_BR_LINE 5: mkdir's error case // NOLINT[whitespace/line_length]
+ if (EEXIST != errno) { // LCOV_EXCL_BR_LINE 5: errno can't be changed
+ // LCOV_EXCL_START 5: errno can't be changed
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Cannot Create directory %s", l_cCopypath);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ // file already exist
+ }
+ }
+ *l_cParsedDirPath = '/';
+ }
+ l_cTempDirPath = l_cParsedDirPath + 1;
+ }
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 200: l_estatus must be eFrameworkunifiedStatusOK
+ if (0 != mkdir(l_cCopypath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { // LCOV_EXCL_BR_LINE 5: mkdir's error case // NOLINT[whitespace/line_length]
+ if (EEXIST != errno) { // LCOV_EXCL_BR_LINE 5: errno can't be changed
+ // LCOV_EXCL_START 5: errno can't be changed
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Cannot Create directory %s", l_cCopypath);
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ // file already exist
+ }
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Directory path is empty.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DoesDirecotryExist
+/// Method to check if a directory exists.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::DoesDirecotryExist(const std::string &f_cdirpath) {
+ DIR *l_pDirDescriptor = opendir(f_cdirpath.c_str());
+ if (NULL != l_pDirDescriptor) {
+ closedir(l_pDirDescriptor);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsDirectory
+/// Method to check if the entity is a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::IsDirectory(const std::string &f_cpath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = FALSE;
+
+ if (!f_cpath.empty()) { // LCOV_EXCL_BR_LINE 200: f_cpath can't be empty
+ struct stat st_buf;
+
+ if (0 == stat(f_cpath.c_str(), &st_buf)) { // LCOV_EXCL_BR_LINE 5: stat's error case
+ // Get the status of the file
+ if (S_ISREG(st_buf.st_mode)) {
+ l_bReturn = FALSE; // return false if f_cpath is a regular file
+ }
+ if (S_ISDIR(st_buf.st_mode)) {
+ l_bReturn = TRUE; // return true if f_cpath is a directory
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving status of path : %s", f_cpath.c_str()); // LCOV_EXCL_LINE 5: stat's error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Directory path is empty."); // LCOV_EXCL_LINE 200: f_cpath can't be empty
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveDirectory
+/// Method to remove a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::RemoveDirectory(std::string f_cpath, const UI_32 f_uidelay) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = FALSE;
+
+ if (!f_cpath.empty()) { // LCOV_EXCL_BR_LINE 200: f_cpath can't be empty.
+ std::string l_cFilePath = "";
+
+ struct dirent *l_pdirent = NULL;
+ DIR *l_pdir = NULL;
+
+ l_pdir = opendir(f_cpath.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (NULL != l_pdir) {
+ if ('/' != f_cpath[f_cpath.length() - 1]) {
+ f_cpath.append("/");
+ }
+
+ while (NULL != (l_pdirent = readdir(l_pdir))) {
+ if (0 != std::strcmp(l_pdirent->d_name, ".") &&
+ 0 != std::strcmp(l_pdirent->d_name, "..")) {
+ l_cFilePath.assign(f_cpath);
+ l_cFilePath.append(l_pdirent->d_name); // concatenate the strings to get the complete f_cpath
+
+ if (TRUE == IsDirectory(l_cFilePath)) {
+ (void)RemoveDirectory(l_cFilePath, f_uidelay);
+ } else {
+ // it's a file, we can use unlink
+ unlink(l_cFilePath.c_str());
+
+ if (0 < f_uidelay) { // LCOV_EXCL_START 200: f_uidelay is 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ delay(f_uidelay);
+#endif
+ }
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ closedir(l_pdir); // close the directory
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pdir is NULL");
+ }
+
+ // delete the directory
+ if (0 == rmdir(f_cpath.c_str())) {
+ if (0 < f_uidelay) { // LCOV_EXCL_START 200: f_uidelay is 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ delay(f_uidelay);
+#endif
+ }
+ // LCOV_EXCL_STOP
+ l_bReturn = TRUE;
+ }
+ } else {
+ // LCOV_EXCL_START 200: f_cpath can't be empty.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Directory path is empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_handlelist.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_handlelist.cpp
new file mode 100644
index 00000000..c9e88a8c
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_handlelist.cpp
@@ -0,0 +1,149 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup tag_NS_NPPService
+/// \ingroup tag_NS_NPPService
+///
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This class holds the message queue handles for notification subscribers
+///
+/// This is a singleton class which holds the message queue handles for notification subscribers.
+/// This will ensure that NS_NPPService will hold only one handle per subscriber.
+//////////////////////////////////////////////////////////////////////////////////////////////////
+#include <utility>
+#include <string>
+#include "ns_npp_handlelist.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+
+// define static member of class CHandleList
+CHandleList *CHandleList::m_psHandleList = NULL;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CHandleList
+/// Class Constructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CHandleList::CHandleList() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CHandleList
+/// Class Destructor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CHandleList::~CHandleList() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetHandleList
+/// This function is used to get the singleton instance of class.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CHandleList *CHandleList::GetHandleList() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // create the instance of class
+ if (NULL == m_psHandleList) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Creating handle list."); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ m_psHandleList = new(std::nothrow) CHandleList(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return m_psHandleList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ReleaseHandleList
+/// This function is used to release the instance of class.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CHandleList::ReleaseHandleList() { // LCOV_EXCL_START 100: not used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_psHandleList) {
+ delete m_psHandleList;
+ m_psHandleList = NULL;
+ } else {
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddHandleInList
+/// Add pair of subscriber name and corresponding handle in map.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CHandleList::AddHandleInList(std::string f_csubscribername, HANDLE f_hmqhandle) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ HandleListRetStatus_Type l_prRetValue;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_prRetValue = m_mHandleList.insert(make_pair(f_csubscribername, f_hmqhandle));
+ if (false == l_prRetValue.second) {
+ l_estatus = eFrameworkunifiedStatusDuplicate;
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Handle exists in list for %s.", f_csubscribername.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Handle added in list for %s.", f_csubscribername.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ }
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveHandleFromList
+/// Remove handle for subscriber from the list.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CHandleList::RemoveHandleFromList(std::string f_csubscribername) { // LCOV_EXCL_START 100: not used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // TODO(my_username): Implementation of this function.
+ // NOTE: Right now this feature is not required. Let the NS_NPPService hold one handle for
+ // each subscriber, even if all the notifications are unsubscribed by subscriber.
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetSubscriberMqHandle
+/// Get the message queue handle of a subscriber.
+////////////////////////////////////////////////////////////////////////////////////////////////
+HANDLE CHandleList::GetSubscriberMqHandle(std::string f_csubscribername) {
+ HANDLE l_hMqHandle = NULL;
+ HandleList_Type::iterator l_itHandleList;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_itHandleList = m_mHandleList.find(f_csubscribername);
+ if (l_itHandleList != m_mHandleList.end()) {
+ l_hMqHandle = l_itHandleList->second;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_hMqHandle;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_nor_persistence_worker_thread.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_nor_persistence_worker_thread.cpp
new file mode 100644
index 00000000..d4b1604f
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_nor_persistence_worker_thread.cpp
@@ -0,0 +1,747 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contain declaration of class CNorPersistenceWorker and CArchive.
+/// Class CNorPersistenceWorker holds the implementation for worker thread.
+/// Class CArchive holds the implementation for archive.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns_timer_if.hpp>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_utility_sys.hpp>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/ns_np_service_nor_persistence.h>
+
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <boost/bind.hpp>
+#include <map>
+#include <utility>
+#include <string>
+
+#include <native_service/ns_np_service_nor_persistence_internal.h>
+#include "ns_npp_types.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_fs_directory.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_nor_persistence_worker_thread.h"
+
+
+
+typedef std::string NotificationName;
+typedef std::map<NotificationName, CTimerHelper *> TTimerList;
+static TTimerList g_mtimers; /// List of all the timers for immediate persistence notifications
+CMutex g_objmutextimerdata; /// Mutex object on g_mtimers
+
+// Template function for NorWorkerCallback
+template <typename C, eFrameworkunifiedStatus(C::*M)(HANDLE)> EFrameworkunifiedStatus NorWorkerCallback(HANDLE hthread) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ C *l_pClass = static_cast<C *>(FrameworkunifiedGetThreadSpecificData(hthread));
+
+ if (l_pClass) { // LCOV_EXCL_BR_LINE 6: l_pClass can't be NULL
+ l_estatus = (l_pClass->*M)(hthread);
+ }
+ return l_estatus;
+}
+
+static FrameworkunifiedProtocolCallbackHandler aServiceHandlers[] = { // NOLINT (readability/naming)
+ { NOR_PERSISTENCE_TIMER_START, NorWorkerCallback<CNorPersistenceWorker,
+ &CNorPersistenceWorker::OnNorPersistenceTimerStart>},
+ { NOR_PERSISTENCE_REGISTER, NorWorkerCallback<CNorPersistenceWorker,
+ &CNorPersistenceWorker::RegisterImmediatePersistNotification>},
+ { NOR_PERSISTENCE_UNREGISTER, NorWorkerCallback<CNorPersistenceWorker,
+ &CNorPersistenceWorker::UnregisterImmediatePersistNotification>},
+ { NOR_PERSISTENCE_ONSHUTDOWN, NorWorkerCallback<CNorPersistenceWorker,
+ &CNorPersistenceWorker::OnShutdown>},
+ { NOR_PERSISTENCE_CHANGE_CATEGORY, NorWorkerCallback<CNorPersistenceWorker,
+ &CNorPersistenceWorker::OnCategoryChange>}
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPNorPersistenceWorkerOnStart
+/// Callback method on start of worker thread
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStart(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hthread) { // LCOV_EXCL_BR_LINE 6: hthread can't be NULL
+ // Note: this variable is made static just to ignore the resource leak showing in coverity analysis
+ static CNorPersistenceWorker *l_pcnorpersistenceworker = new(std::nothrow) CNorPersistenceWorker;
+
+ if (NULL != l_pcnorpersistenceworker) { // LCOV_EXCL_BR_LINE 5: new's error case
+ l_estatus = FrameworkunifiedSetThreadSpecificData(hthread, l_pcnorpersistenceworker);
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ l_estatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hthread, AppName, aServiceHandlers, static_cast<UI_32>(_countof(aServiceHandlers)));
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ delete l_pcnorpersistenceworker;
+ l_pcnorpersistenceworker = NULL;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Worker Object Null.");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: hthread can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NSPNorPersistenceWorkerOnStop
+/// Callback method on stop of worker thread
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NSPNorPersistenceWorkerOnStop(HANDLE hthread) { // LCOV_EXCL_START 200: can't test
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (NULL != hthread) {
+ CNorPersistenceWorker *l_pcnorpersistenceworker = static_cast<CNorPersistenceWorker *>(FrameworkunifiedGetThreadSpecificData(
+ hthread));
+
+ if (NULL != l_pcnorpersistenceworker) {
+ delete l_pcnorpersistenceworker;
+ l_pcnorpersistenceworker = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Worker Object Null");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSetThreadSpecificData(hthread, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSetThreadSpecificData error, status=%d", l_estatus);
+ }
+
+ PCSTR l_cservice = FrameworkunifiedGetAppName(hthread);
+ if (NULL != l_cservice) {
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedDetachServiceFromDispatcher(hthread, l_cservice))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error detaching service %s from dispatcher, status=%d", l_cservice, l_estatus);
+ }
+ } else {
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetAppName returned NULL");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Thread App Handle Null.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Class : CNorPersistenceWorker
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNorPersistenceWorker
+/// Constructor of CNorPersistenceWorker class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNorPersistenceWorker::CNorPersistenceWorker() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNorPersistenceWorker
+/// Destructor of CNorPersistenceWorker class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNorPersistenceWorker::~CNorPersistenceWorker() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnNorPersistenceTimerStart
+/// This function starts the respective timer of the notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNorPersistenceWorker::OnNorPersistenceTimerStart(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ TNorPersistenceNotifInfoHeader *l_ptNorPersistentData = NULL;
+ UI_32 l_ui32ReceivedDataLength = FrameworkunifiedGetMsgLength(f_hThread);
+ UI_8 *l_pui32ReceivedData = new(std::nothrow) UI_8[l_ui32ReceivedDataLength];
+
+ if (l_ui32ReceivedDataLength >= sizeof(TNorPersistenceNotifInfoHeader)) { // LCOV_EXCL_BR_LINE 200: l_ui32ReceivedDataLength is bigger than sizeof(TNorPersistenceNotifInfoHeader) // NOLINT[whitespace/line_length]
+ if (NULL != l_pui32ReceivedData) { // LCOV_EXCL_BR_LINE 5: new's error case
+ std::memset(l_pui32ReceivedData, 0, l_ui32ReceivedDataLength);
+ l_estatus = FrameworkunifiedGetMsgDataOfSize(f_hThread, l_pui32ReceivedData, l_ui32ReceivedDataLength, eSMRRelease);
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ TTimerList::iterator l_itTimerList;
+ l_ptNorPersistentData = static_cast<TNorPersistenceNotifInfoHeader *>(static_cast<PVOID>(l_pui32ReceivedData));
+
+ g_objmutextimerdata.WriteLock();
+ // find the corresponding timer object in the list of timers
+ l_itTimerList = g_mtimers.find(l_ptNorPersistentData->m_cnotificationname);
+ if (g_mtimers.end() != l_itTimerList) { // LCOV_EXCL_BR_LINE 200: the notification must be registered
+ if (NULL != (l_itTimerList->second)) { // LCOV_EXCL_BR_LINE 200: l_itTimerList->second can't be null
+ if (NULL != (l_itTimerList->second)->m_pui8HeaderAndData) {
+ delete[](l_itTimerList->second)->m_pui8HeaderAndData;
+ (l_itTimerList->second)->m_pui8HeaderAndData = NULL;
+ }
+
+ // Update specific immediate persistence notification data
+ (l_itTimerList->second)->m_pui8HeaderAndData = l_pui32ReceivedData;
+
+ // if corresponding timer is not already running start it.
+ if (!(l_itTimerList->second)->IsRunning()) {
+ (l_itTimerList->second)->Start();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Timer started, Notfn=%s", l_ptNorPersistentData->m_cnotificationname);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Timer already running for notfn %s. Data updated",
+ l_ptNorPersistentData->m_cnotificationname);
+ }
+
+ l_estatus = eFrameworkunifiedStatusOK;
+ } else {
+ // LCOV_EXCL_START 200: l_itTimerList->second can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Immediate persistence: Timer object NULL for Notfn:%s.",
+ l_ptNorPersistentData->m_cnotificationname);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: the notification must be registered
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Immediate persistence notification not registered. Notification: %s ",
+ l_ptNorPersistentData->m_cnotificationname != 0 ? l_ptNorPersistentData->m_cnotificationname : NULL);
+ // LCOV_EXCL_STOP
+ }
+ g_objmutextimerdata.Unlock();
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedGetMsgDataOfSize failed while retrieving immediate persistence notfn data. Status:0x%x ", l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to allocate data. Can't persist.");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: l_ui32ReceivedDataLength is bigger than sizeof(TNorPersistenceNotifInfoHeader)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldBuf;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid data length received. Can't persist.");
+ // LCOV_EXCL_STOP
+ }
+
+ if ((eFrameworkunifiedStatusOK != l_estatus) && (NULL != l_pui32ReceivedData)) {
+ delete[] l_pui32ReceivedData;
+ l_pui32ReceivedData = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RegisterImmediatePersistNotification
+/// It creates a timer corresponding to the notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNorPersistenceWorker::RegisterImmediatePersistNotification(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ TImmediatePersistenceRegisterNotifInfo l_tRegisterNotifInfo = {};
+
+ if (sizeof(l_tRegisterNotifInfo) == FrameworkunifiedGetMsgLength(hthread)) { // LCOV_EXCL_BR_LINE 200: the size of msg must be sizeof(TImmediatePersistenceUnregisterNotifInfo) // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(hthread, &l_tRegisterNotifInfo, // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ sizeof(TImmediatePersistenceRegisterNotifInfo), eSMRRelease))) {
+ g_objmutextimerdata.WriteLock();
+
+ TTimerList::iterator l_itTimerList = g_mtimers.find(l_tRegisterNotifInfo.m_cnotificationname);
+ if (l_itTimerList != g_mtimers.end()) { // LCOV_EXCL_BR_LINE 6: notification can't be registered again
+ // LCOV_EXCL_START 6: notification can't be registered again
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification %s is already registered for immediate data persistence ",
+ l_tRegisterNotifInfo.m_cnotificationname);
+ // LCOV_EXCL_STOP
+ } else {
+ // create timer corresponding to notification
+ CTimerHelper *l_pTimerHelper = new CTimerHelper();
+ if (NULL != l_pTimerHelper) { // LCOV_EXCL_BR_LINE 5: new's error case
+ l_pTimerHelper->SetTime(l_tRegisterNotifInfo.m_uidelay, 0);
+ // todo: modify SetNotifyMethod of timer NSTimer class to accept sender handle as well.
+ // This will help to have only one handle, instead of one handle per timer.
+ l_pTimerHelper->SetNotifyMethod(static_cast<UI_16>(l_pTimerHelper->GetCmdId()), FrameworkunifiedGetAppName(hthread));
+
+ // associate timer's timeout with the callback function.
+ FrameworkunifiedAttachCallbackToDispatcher(hthread, TIMER_QUE, l_pTimerHelper->GetCmdId(),
+ boost::bind(&CTimerHelper::OnTimeOut, l_pTimerHelper, hthread));
+ // add created timer in timers list
+ g_mtimers.insert(std::make_pair(l_tRegisterNotifInfo.m_cnotificationname, l_pTimerHelper));
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification %s is registered for immediate data persistence ",
+ l_tRegisterNotifInfo.m_cnotificationname != 0 ? l_tRegisterNotifInfo.m_cnotificationname : NULL);
+ }
+ }
+
+ g_objmutextimerdata.Unlock();
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error getting message data for registering Immediate persistent notification, status: 0x%x", l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: the size of msg must be sizeof(TImmediatePersistenceUnregisterNotifInfo)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedGetMsgLength and size of TImmediatePersistenceRegisterNotifInfo mismatched."
+ "Length received %d, buffer available: %ld ",
+ FrameworkunifiedGetMsgLength(hthread), static_cast<long int>(sizeof(TImmediatePersistenceRegisterNotifInfo))); // NOLINT (runtime/int)
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// UnregisterImmediatePersistNotification
+/// It deletes a timer corresponding to the notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNorPersistenceWorker::UnregisterImmediatePersistNotification(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ TImmediatePersistenceUnregisterNotifInfo l_tRegisterNotifInfo = {};
+
+ if (sizeof(l_tRegisterNotifInfo) == FrameworkunifiedGetMsgLength(hthread)) { // LCOV_EXCL_BR_LINE 200: the size of msg must be sizeof(TImmediatePersistenceUnregisterNotifInfo) // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(hthread, &l_tRegisterNotifInfo, // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ sizeof(TImmediatePersistenceUnregisterNotifInfo), eSMRRelease))) {
+ g_objmutextimerdata.WriteLock();
+
+ TTimerList::iterator l_itTimerList = g_mtimers.find(l_tRegisterNotifInfo.m_cnotificationname);
+ if (l_itTimerList != g_mtimers.end()) { // LCOV_EXCL_BR_LINE 6: notification can't be unregistered again
+ if (NULL != (l_itTimerList->second)) { // LCOV_EXCL_BR_LINE 200: l_itTimerList->second can't be null
+ EFrameworkunifiedStatus eStatus;
+ // detach callbacks
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbackFromDispatcher(hthread, TIMER_QUE, // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ (l_itTimerList->second)->GetCmdId()))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedDetachCallbackFromDispatcher Failed Status:0x%x ", eStatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ delete l_itTimerList->second;
+ l_itTimerList->second = NULL;
+ }
+ g_mtimers.erase(l_itTimerList);
+ } else {
+ // LCOV_EXCL_START 6: notification can't be registered again
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Can't unregister. Notification %s is not a registered notification for immediate data persistence.",
+ l_tRegisterNotifInfo.m_cnotificationname != 0 ? l_tRegisterNotifInfo.m_cnotificationname : NULL);
+ // LCOV_EXCL_STOP
+ }
+
+ g_objmutextimerdata.Unlock();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Notification %s is unregistered for immediate data persistence, FrameworkunifiedGetMsgDataOfSize Error, status: 0x%x",
+ l_tRegisterNotifInfo.m_cnotificationname != 0 ? l_tRegisterNotifInfo.m_cnotificationname : NULL,
+ l_estatus);
+ }
+ } else {
+ // LCOV_EXCL_START 200: the size of msg must be sizeof(TImmediatePersistenceUnregisterNotifInfo)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedGetMsgLength and size of TImmediatePersistenceUnregisterNotifInfo mismatched."
+ "Length received %d, buffer available: %ld ",
+ FrameworkunifiedGetMsgLength(hthread), static_cast<long int>(sizeof(TImmediatePersistenceUnregisterNotifInfo))); // NOLINT (runtime/int)
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnShutdown
+/// This API saves or deletes the data of NOR irrespective of delay depending on the message data
+/// received from parent thread during shutdown.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNorPersistenceWorker::OnShutdown(HANDLE f_hThread) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ UI_32 l_uiPersistCategoryFlag = 0;
+
+ TImmediateShutdown l_tImmShutdown = {};
+
+ CTimerHelper *l_pTimerHelper = NULL;
+
+ // iterator of list of nor notifications and its timers
+ TTimerList::iterator l_itTimerList;
+
+ TNorPersistenceNotifInfoHeader *l_ptImmediateNotfnHeader = NULL;
+
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(f_hThread, &l_tImmShutdown, sizeof(l_tImmShutdown), // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ eSMRRelease))) {
+ l_uiPersistCategoryFlag = l_tImmShutdown.f_uinotificationpersistentservicepersistcategoryflag;
+
+ // if quick shutdown is received then just stop the timer and dont save the data
+ if (eFrameworkunifiedQuickShutdown == l_tImmShutdown.f_eshutdowntype) {
+ for (l_itTimerList = g_mtimers.begin(); l_itTimerList != g_mtimers.end(); l_itTimerList++) {
+ l_pTimerHelper = l_itTimerList->second;
+
+ if (NULL != l_pTimerHelper && l_pTimerHelper->IsRunning()) {
+ // stop the timer
+ l_pTimerHelper->Stop();
+ }
+ }
+ } else { // stop the timer and save the data
+ for (l_itTimerList = g_mtimers.begin(); l_itTimerList != g_mtimers.end(); l_itTimerList++) {
+ l_pTimerHelper = l_itTimerList->second;
+
+ if (NULL != l_pTimerHelper && l_pTimerHelper->IsRunning()) {
+ // stop the timer
+ l_pTimerHelper->Stop();
+
+ l_ptImmediateNotfnHeader = static_cast<TNorPersistenceNotifInfoHeader *>
+ (static_cast<PVOID>(l_pTimerHelper->m_pui8HeaderAndData));
+
+ if (NULL != l_ptImmediateNotfnHeader) { // LCOV_EXCL_BR_LINE 200: l_ptImmediateNotfnHeader can't be null
+ if (eFrameworkunifiedUserData != (l_ptImmediateNotfnHeader->m_epersistcategory & l_uiPersistCategoryFlag) &&
+ eFrameworkunifiedFactoryData != (l_ptImmediateNotfnHeader->m_epersistcategory & l_uiPersistCategoryFlag) &&
+ eFrameworkunifiedFactoryCustomerData != (l_ptImmediateNotfnHeader->m_epersistcategory & l_uiPersistCategoryFlag) &&
+ eFrameworkunifiedDealerData != (l_ptImmediateNotfnHeader->m_epersistcategory & l_uiPersistCategoryFlag)) {
+ // save the new data to persistent memory
+ l_pTimerHelper->OnTimeOut(f_hThread);
+ }
+ } else {
+ // LCOV_EXCL_START 200: l_ptImmediateNotfnHeader can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Immediate notification data header is NULL");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize failed for protocol NOR_PERSISTENCE_ONSHUTDOWN, status : %d",
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendParent(f_hThread, NOR_PERSISTENCE_ONSHUTDOWN_ACK, // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ sizeof(l_uiPersistCategoryFlag), &l_uiPersistCategoryFlag))) {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendParent failed for protocol NOR_PERSISTENCE_ONSHUTDOWN_ACK, status : %d",
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnCategoryChange
+/// This callback is called when category of immediate persistence is changed
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNorPersistenceWorker::OnCategoryChange(HANDLE hthread) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != hthread) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ UI_32 l_ui32ReceivedDataLength = FrameworkunifiedGetMsgLength(hthread);
+
+ if (l_ui32ReceivedDataLength >= sizeof(TImmediatePersistenceChangeCategory)) { // LCOV_EXCL_BR_LINE 200: l_ui32ReceivedDataLength is bigger than sizeof(TImmediatePersistenceChangeCategory) // NOLINT[whitespace/line_length]
+ UI_8 *l_pui32ReceivedData = new(std::nothrow) UI_8[l_ui32ReceivedDataLength];
+
+ if (NULL != l_pui32ReceivedData) { // LCOV_EXCL_BR_LINE 5: new's error case
+ std::memset(l_pui32ReceivedData, 0, l_ui32ReceivedDataLength);
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(hthread, l_pui32ReceivedData, l_ui32ReceivedDataLength, // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ eSMRRelease))) {
+ TImmediatePersistenceChangeCategory *l_pChangePersistentCategory =
+ static_cast<TImmediatePersistenceChangeCategory *>(static_cast<PVOID>(l_pui32ReceivedData));
+ PUI_8 l_pui8Data = l_pui32ReceivedData + sizeof(TImmediatePersistenceChangeCategory);
+
+ TTimerList::iterator l_itTimerList;
+
+ g_objmutextimerdata.WriteLock();
+ // find the corresponding timer object in the list of timers
+ l_itTimerList = g_mtimers.find(l_pChangePersistentCategory->m_tnornotifInfoheader.m_cnotificationname);
+ if (g_mtimers.end() != l_itTimerList) { // LCOV_EXCL_BR_LINE 6: notification must be in list
+ CTimerHelper *l_pTimerHelper = l_itTimerList->second;
+
+ if (NULL != l_pTimerHelper && l_pTimerHelper->IsRunning()) {
+ TNorPersistenceNotifInfoHeader *l_ptImmediateNotfnHeader =
+ static_cast<TNorPersistenceNotifInfoHeader *>(static_cast<PVOID>(l_pTimerHelper->m_pui8HeaderAndData));
+
+ if (NULL != l_ptImmediateNotfnHeader) { // LCOV_EXCL_BR_LINE 200: l_ptImmediateNotfnHeader can't be null
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Changing category from %d to %d for notfn %s in dataHdr",
+ l_ptImmediateNotfnHeader->m_epersistcategory,
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_epersistcategory,
+ l_ptImmediateNotfnHeader->m_cnotificationname);
+
+ l_ptImmediateNotfnHeader->m_epersistcategory =
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_epersistcategory;
+ }
+ }
+
+ EFrameworkunifiedPersistCategory l_eOldPersistCategory = l_pChangePersistentCategory->m_eoldpersistcategory;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Changing persist category of %s from %d to %d",
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_cnotificationname,
+ l_eOldPersistCategory,
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_epersistcategory);
+
+ // write data to emmc
+ l_estatus = SynchronousWritePersistentData(
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_cpublishername,
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_cnotificationname,
+ static_cast<PVOID>(l_pui8Data),
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_uimsgsize,
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_uidelay,
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_uimaxmsglength,
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_epersistcategory);
+
+ // Create the old file path string to be removed
+ std::string l_cPath = IMMEDIATE_PERSISTENCE_STORAGE_V2;
+ std::string l_cTempPath = l_pChangePersistentCategory->m_tnornotifInfoheader.m_cnotificationname;
+ size_t l_uiTempPathSize = 0;
+
+ // replace all '/' by '_'
+ l_uiTempPathSize = l_cTempPath.find_first_of("/");
+ while (std::string::npos != l_uiTempPathSize) {
+ l_cTempPath[l_uiTempPathSize] = '_';
+ l_uiTempPathSize = l_cTempPath.find_first_of("/", l_uiTempPathSize + 1);
+ }
+
+ switch (l_eOldPersistCategory) {
+ case eFrameworkunifiedFactoryData:
+ l_cPath.append(FACTORYDATADIR);
+ break;
+ case eFrameworkunifiedFactoryCustomerData:
+ l_cPath.append(FACTORYCUSTOMERDATADIR);
+ break;
+ case eFrameworkunifiedDealerData:
+ l_cPath.append(DEALERDATADIR);
+ break;
+ case eFrameworkunifiedUserData:
+ default: {
+ l_cPath.append(USERDATADIR);
+ l_cPath.append(ALLUSERAPPDATADIR);
+ }
+ break;
+ }
+
+ l_cPath.append(IMMEDIATEDATADIR);
+ l_cPath.append(l_cTempPath);
+
+ l_cPath.append(l_pChangePersistentCategory->m_tnornotifInfoheader.m_cpublishername);
+
+ if (0 != unlink(l_cPath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error deleting file %s, errno=%d", l_cPath.c_str(), errno);
+ }
+ } else {
+ // LCOV_EXCL_START 6: notification must be in list
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't update persistent category, notfn %s not found in g_mtimers map",
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_cnotificationname != 0 ?
+ l_pChangePersistentCategory->m_tnornotifInfoheader.m_cnotificationname : NULL);
+ // LCOV_EXCL_STOP
+ }
+ g_objmutextimerdata.Unlock();
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize failed while retrieving"
+ "immediate persistence notfn data. Status:0x%x ", l_estatus);
+ // LCOV_EXCL_STOP
+ }
+
+ delete[] l_pui32ReceivedData;
+ l_pui32ReceivedData = NULL;
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to allocate data. Can't persist, errno=%d", errno);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: l_ui32ReceivedDataLength is bigger than sizeof(TImmediatePersistenceChangeCategory)
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldBuf;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid data length received %d. Can't persist.", l_ui32ReceivedDataLength);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid param, hthread is NULL");
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+/////////////////////////////
+/// Class: CTimerHelper
+/////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CTimerHelper
+/// Constructor of CTimerHelper class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CTimerHelper::CTimerHelper() {
+ static UI_32 l_uiTimerCounter = PROTOCOL_FRAMEWORKUNIFIED_BASE_CMD;
+ l_uiTimerCounter++;
+ m_uiCmdId = l_uiTimerCounter;
+ m_pui8HeaderAndData = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CTimerHelper
+/// Destructor of CTimerHelper class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CTimerHelper::~CTimerHelper() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pui8HeaderAndData) {
+ delete[] m_pui8HeaderAndData;
+ m_pui8HeaderAndData = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetCmdId
+/// Returns id for timer
+////////////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CTimerHelper::GetCmdId() {
+ return m_uiCmdId;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// OnTimeOut
+/// This function writes the corresponding data in NOR when timer expires.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CTimerHelper::OnTimeOut(HANDLE hthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ g_objmutextimerdata.ReadLock();
+ if (NULL != m_pui8HeaderAndData) { // LCOV_EXCL_BR_LINE 200: m_pui8HeaderAndData can't be null
+ TNorPersistenceNotifInfoHeader *l_ptImmediateNotfnHeader =
+ static_cast<TNorPersistenceNotifInfoHeader *>(static_cast<PVOID>(m_pui8HeaderAndData));
+ PUI_8 l_pui8Data = m_pui8HeaderAndData + sizeof(TNorPersistenceNotifInfoHeader);
+ HANDLE l_hReceiverMq = McOpenSender(l_ptImmediateNotfnHeader->m_cpublishername);
+
+ // write data to emmc
+ l_estatus = SynchronousWritePersistentData(l_ptImmediateNotfnHeader->m_cpublishername,
+ l_ptImmediateNotfnHeader->m_cnotificationname,
+ static_cast<PVOID>(l_pui8Data),
+ l_ptImmediateNotfnHeader->m_uimsgsize,
+ l_ptImmediateNotfnHeader->m_uidelay,
+ l_ptImmediateNotfnHeader->m_uimaxmsglength,
+ l_ptImmediateNotfnHeader->m_epersistcategory);
+
+ // update corresponding application about data written status.
+ if (NULL != l_hReceiverMq) { // LCOV_EXCL_BR_LINE 5: NSFW error case
+ NC_ImmediateWriteAck l_tWriteAck = {};
+ std::strncpy(l_tWriteAck.notificationName, l_ptImmediateNotfnHeader->m_cnotificationname,
+ sizeof(l_tWriteAck.notificationName) - 1);
+ l_tWriteAck.eStatus = l_estatus;
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = McSend(l_hReceiverMq, AppName, NPS_IMMEDIATE_WRITE_ACK, sizeof(l_tWriteAck), // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ &l_tWriteAck))) {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error Sending NPS_IMMEDIATE_WRITE_ACK to %s for %s, Status: %d",
+ l_ptImmediateNotfnHeader->m_cpublishername != 0 ? l_ptImmediateNotfnHeader->m_cpublishername : NULL,
+ l_ptImmediateNotfnHeader->m_cnotificationname != 0 ?
+ l_ptImmediateNotfnHeader->m_cnotificationname : NULL,
+ l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ McClose(l_hReceiverMq);
+ l_hReceiverMq = NULL;
+ } else {
+ // LCOV_EXCL_START 5: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error creating sender handle for service %s, Notification name %s Write Status: %d",
+ l_ptImmediateNotfnHeader->m_cpublishername != 0 ? l_ptImmediateNotfnHeader->m_cpublishername : NULL,
+ l_ptImmediateNotfnHeader->m_cnotificationname != 0 ?
+ l_ptImmediateNotfnHeader->m_cnotificationname : NULL,
+ l_estatus);
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: m_pui8HeaderAndData can't be null
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Not writing immediate persistence data. Data is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // LCOV_EXCL_STOP
+ }
+ g_objmutextimerdata.Unlock();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+/// EOF
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_notification.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_notification.cpp
new file mode 100644
index 00000000..8e2bb2d6
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_notification.cpp
@@ -0,0 +1,485 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of CNotification class.
+/// It define functionalities common to all types of notification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <utility>
+#include <iostream>
+#include <string>
+#include <native_service/ns_mc_system_info.h>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_handlelist.h"
+#include "ns_npp_notification.h"
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNotification
+/// Constructor of CNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotification::CNotification() { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_cNotificationName = "";
+ m_uiMaxMsgSize = 0;
+ m_ePersistentType = eFrameworkunifiedUnknown;
+
+ m_cServiceName = "";
+
+ m_pmSubscribersList = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNotification
+/// Constructor of CNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotification::CNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_cNotificationName = "";
+ m_uiMaxMsgSize = 0;
+ m_ePersistentType = eFrameworkunifiedUnknown;
+ m_pmSubscribersList = NULL;
+
+ if (!f_cnotificationname.empty()) { // LCOV_EXCL_BR_LINE 200: f_cnotificationname can't be empty
+ m_cNotificationName = f_cnotificationname;
+ m_uiMaxMsgSize = f_uimaxmsgsize;
+// m_ePersistentType = eFrameworkunifiedUnknown;
+
+ m_cServiceName = "";
+
+ m_pmSubscribersList = new(std::nothrow) NotifReceiver_Type(); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ } else {
+ // LCOV_EXCL_START 200: f_cnotificationname can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification String is Empty");
+
+ CNotification();
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNotification
+/// Destructor of CNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotification::~CNotification() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // iterator of CNotificationReceiver map
+ NotifReceiver_Iterator_Type l_itNotifReceiver;
+
+ CNotificationReceiver *l_pNotificationReceiver = NULL;
+
+ if (NULL != m_pmSubscribersList) { // LCOV_EXCL_BR_LINE 6: m_pmSubscribersList can't be NULL
+ if (!m_pmSubscribersList->empty()) {
+ for (l_itNotifReceiver = m_pmSubscribersList->begin();
+ l_itNotifReceiver != m_pmSubscribersList->end();
+ l_itNotifReceiver++) {
+ l_pNotificationReceiver = (*l_itNotifReceiver).second;
+
+ if (NULL != l_pNotificationReceiver) { // LCOV_EXCL_BR_LINE 6: l_pNotificationReceiver can't be NULL
+ // NOTE: Uncomment following code when implementation of the function RemoveHandleFromList
+ // is available. To find the reason why it is not implemented, see the function definition.
+ // CHandleList *l_hHandleList = CHandleList::GetHandleList();
+ // l_hHandleList->RemoveHandleFromList((*l_itNotifReceiver).first);
+
+ delete l_pNotificationReceiver; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_pNotificationReceiver = NULL;
+ }
+ }
+
+ // clear the map
+ m_pmSubscribersList->clear();
+ }
+
+ delete m_pmSubscribersList; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ m_pmSubscribersList = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddEventReciever
+/// This function adds the name of the application to receiver list of particular notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::AddEventReciever(const std::string &f_csubscribername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (!f_csubscribername.empty()) { // LCOV_EXCL_BR_LINE 6: f_csubscribername can't be empty
+ l_estatus = AddReceiverInMap(f_csubscribername);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_csubscribername can't be empty
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Publish
+/// This function publishes the notification to subscribed clients.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DeleteEventReciever
+/// This function deletes the name of application from receivers list.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::DeleteEventReciever(const std::string &f_csubscribername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // iterator of CNotificationReceiver map
+ NotifReceiver_Iterator_Type l_iterator;
+
+ CNotificationReceiver *l_pNotificationReceiver = NULL;
+
+ if (!f_csubscribername.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_csubscribername can't be empty
+ l_iterator = m_pmSubscribersList->find(f_csubscribername);
+
+
+ if (l_iterator != m_pmSubscribersList->end()) {
+ l_pNotificationReceiver = (*l_iterator).second;
+
+ if (NULL != l_pNotificationReceiver) { // LCOV_EXCL_BR_LINE 6: l_pNotificationReceiver can't be NULL
+ // NOTE: Uncomment following code when implementation of the function RemoveHandleFromList
+ // is available. To find the reason why it is not implemented, see the function definition.
+ // CHandleList *l_hHandleList = CHandleList::GetHandleList();
+ // l_hHandleList->RemoveHandleFromList((*l_iterator).first);
+
+ delete l_pNotificationReceiver; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_pNotificationReceiver = NULL;
+ }
+
+ m_pmSubscribersList->erase(l_iterator);
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Subscriber successfully deleted"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Invalid Iterator");
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, f_csubscribername can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Subscriber Name String is Empty");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetNewSubscribersList
+/// This function sets the subscribers list of notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::SetNewSubscribersList(CNotification *f_pnotification) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // iterator of CNotificationReceiver map
+ NotifReceiver_Iterator_Type l_itNotifReceiver;
+
+ std::string l_cSubscriberName;
+
+ if (NULL != f_pnotification && NULL != f_pnotification->m_pmSubscribersList) { // LCOV_EXCL_BR_LINE 6: f_pnotification and f_pnotification->m_pmSubscribersList can't be empty // NOLINT[whitespace/line_length]
+ if (!f_pnotification->m_pmSubscribersList->empty()) {
+ for (l_itNotifReceiver = f_pnotification->m_pmSubscribersList->begin();
+ l_itNotifReceiver != f_pnotification->m_pmSubscribersList->end();
+ l_itNotifReceiver++) {
+ l_cSubscriberName = (*l_itNotifReceiver).first;
+ AddReceiverInMap(l_cSubscriberName); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Subscriber List Empty");
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: f_pnotification and f_pnotification->m_pmSubscribersList can't be empty // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetEventPublisher
+/// This function set the publisher name to current received service name
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::SetEventPublisher(const std::string &f_cservicename) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (!f_cservicename.empty()) {
+ m_cServiceName = f_cservicename;
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Service successfully set"); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Service Name String is Empty");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ResetEventPublisher
+/// This function resets the publisher name
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::ResetEventPublisher(const std::string &f_cservicename) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_cservicename.empty()) { // LCOV_EXCL_BR_LINE 6: f_cservicename can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_cservicename can't be empty
+ } else {
+ if (0 == m_cServiceName.compare(f_cservicename)) {
+ m_cServiceName = "";
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Service successfully reset"); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Service Name Not Registered"); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+EFrameworkunifiedStatus CNotification::AddReceiverInMap(const std::string &f_csubscribername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Message Queue Handle for passsing messages
+ HANDLE l_hMsgSenQueHandle = NULL;
+
+ // Pointer to class CNotificationReceiver
+ CNotificationReceiver *l_pCNotificationReceiver = NULL;
+
+ // Iterator for Notification Receiver map
+ NotifReceiver_Iterator_Type l_itrNotifReceiver;
+
+ if (!f_csubscribername.empty()) { // LCOV_EXCL_BR_LINE 6: f_csubscribername can't be empty
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Message Queue Handle Set"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ CHandleList *l_hHandleList = CHandleList::GetHandleList();
+
+ l_hMsgSenQueHandle = l_hHandleList->GetSubscriberMqHandle(f_csubscribername); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ // If handle not found
+ if (NULL == l_hMsgSenQueHandle) {
+ // Open a handle for sending messages to another message queue
+ l_hMsgSenQueHandle = McOpenSender(f_csubscribername.c_str());
+ l_hHandleList->AddHandleInList(f_csubscribername, l_hMsgSenQueHandle); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ }
+
+ if (NULL != m_pmSubscribersList) { // LCOV_EXCL_BR_LINE 6: m_pmSubscribersList can't be NULL
+ l_pCNotificationReceiver = new(std::nothrow) CNotificationReceiver(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ if (NULL != l_pCNotificationReceiver) { // LCOV_EXCL_BR_LINE 5: l_pCNotificationReceiver can't be NULL
+ l_pCNotificationReceiver->m_MsgQHandle = l_hMsgSenQueHandle;
+
+ // Insert Subscriber name and associated message queue handle in the map
+ m_pmSubscribersList->insert(make_pair(f_csubscribername, l_pCNotificationReceiver));
+ } else {
+ // LCOV_EXCL_START 5: l_pCNotificationReceiver can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pCNotificationReceiver is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: m_pmSubscribersList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_pmSubscribersList is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusNullPointer == l_estatus) {
+ // close the queue handle
+ // NOTE: Uncomment following code when implementation of the function RemoveHandleFromList
+ // is available. To find the reason why it is not implemented, see the function definition.
+ // CHandleList *l_hHandleList = CHandleList::GetHandleList();
+ // l_hHandleList->RemoveHandleFromList(f_csubscribername);
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_csubscribername can't be empty
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// PublishData
+/// This function publishes the notification to client.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::PublishData(HANDLE f_hmsgqhandle,
+ const PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != f_hmsgqhandle) { // LCOV_EXCL_BR_LINE 6: f_hmsgqhandle can't be NULL
+ // Notification Name
+ PSTR l_cNotificationName = const_cast<PSTR>(m_cNotificationName.c_str());
+
+ if (eFrameworkunifiedStatusOK != (l_estatus = McSendWithSysInfo(f_hmsgqhandle, AppName, NPS_NOTIFY_EV_REQ, l_cNotificationName, f_uimsgsize, f_pmessage, 0))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PublishData failed while McSend for Notification %s, Error Status: 0x%x",
+ l_cNotificationName, l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_hmsgqhandle can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgQ Handle NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsServiceRegistered
+/// This function checks whether the notification is registered with any service or not.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CNotification::IsServiceRegistered() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (!m_cServiceName.empty()) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsSubscribersListEmpty
+/// This function is used to check whether any service is subscribed to notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CNotification::IsSubscribersListEmpty() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pmSubscribersList) { // LCOV_EXCL_BR_LINE 6: m_pmSubscribersList can't be NULL
+ if (m_pmSubscribersList->empty()) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetNotificationName
+/// This function is used to get the notification name.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+std::string CNotification::GetNotificationName() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ return m_cNotificationName;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPublisherName
+/// This function is used to get the publisher name of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+std::string CNotification::GetPublisherName() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ return m_cServiceName;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistenceType
+/// This function is used to get the type of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedNotificationType CNotification::GetNotificationType() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ return m_ePersistentType;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetMaxMessageSize
+/// This function is used to get the max size of data of notification message.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CNotification::GetMaxMessageSize() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ return m_uiMaxMsgSize;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ResetMaxMessageSize
+/// This function reset the max size of data that can be published with notification.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotification::ResetMaxMessageSize(const UI_32 f_uilength) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_uiMaxMsgSize = f_uilength;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetSubscriberList
+/// Returns the list of subscribers subscribed to notification
+////////////////////////////////////////////////////////////////////////////////////////////////
+NotifReceiver_Type *CNotification::GetSubscriberList() {
+ return m_pmSubscribersList;
+}
+
+#endif
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_notification_manager.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_notification_manager.cpp
new file mode 100644
index 00000000..73ce8382
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_notification_manager.cpp
@@ -0,0 +1,1558 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of singleton class CNotificationManager.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <algorithm>
+#include <utility>
+#include <string>
+#include <vector>
+#include "ns_npp_types.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_threads.h"
+#include "ns_npp_notification.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_state_notification.h"
+#include "ns_npp_regular_notification.h"
+#include "ns_npp_notification_manager.h"
+#include "ns_npp_state_persistence_notification.h"
+#include "ns_npp_state_nor_persistence_notification.h"
+#include "ns_npp_state_persistence_user_notification.h"
+
+#ifdef NPP_PROFILEINFO_ENABLE
+#include <sstream>
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNotificationManager
+/// Constructor of CNotificationManager class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotificationManager::CNotificationManager() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_pmNotificationList = new(std::nothrow) Notification_Type(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ m_pvPersistentList = new(std::nothrow) std::vector<std::string>(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ m_pvUserPersistentList = new(std::nothrow) std::vector<std::string>(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ if (NULL == CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread =
+ McOpenSender(NS_NPP_IMMEDIATE_PERSIST_THREAD_NAME);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNotificationManager
+/// Destructor of CNotificationManager class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotificationManager::~CNotificationManager() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // iterator to find notification from map of notifications
+ Notification_Iterator_Type l_itNotification;
+
+ CNotification *l_pNotification = NULL;
+
+ // delete the members in map of Notification
+ if (NULL != m_pmNotificationList) {
+ if (!m_pmNotificationList->empty()) {
+ for (l_itNotification = m_pmNotificationList->begin();
+ l_itNotification != m_pmNotificationList->end();
+ l_itNotification++) {
+ l_pNotification = (*l_itNotification).second;
+
+ if (NULL != l_pNotification) {
+ delete l_pNotification;
+ l_pNotification = NULL;
+ }
+ }
+
+ // clear the map
+ m_pmNotificationList->clear();
+ }
+
+ delete m_pmNotificationList;
+ m_pmNotificationList = NULL;
+ }
+
+ // delete the members in vector of persistent notification
+ if (NULL != m_pvPersistentList) {
+ if (!m_pvPersistentList->empty()) {
+ // clear the vector
+ m_pvPersistentList->clear();
+ }
+
+ delete m_pvPersistentList;
+ m_pvPersistentList = NULL;
+ }
+
+ // delete the members in vector of user persistent notification
+ if (NULL != m_pvUserPersistentList) {
+ if (!m_pvUserPersistentList->empty()) {
+ // clear the vector
+ m_pvUserPersistentList->clear();
+ }
+
+ delete m_pvUserPersistentList;
+ m_pvUserPersistentList = NULL;
+ }
+
+ if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) {
+ McClose(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread);
+ CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateNotificationObject
+/// This function is used to get notification object from map. If doesn't exists, it create new
+/// object as per type of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotification *CNotificationManager::CreateNotificationObject(const std::string &f_cnotificationname,
+ const UI_32 f_uimsglength,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ const UI_32 f_uidelay) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // pointer of notification object
+ CNotification *l_pNotification = NULL;
+
+ // iterator to find notification from map of CNotification
+ Notification_Iterator_Type l_itNotification;
+
+ if (NULL == m_pmNotificationList || NULL == m_pvPersistentList || NULL == m_pvUserPersistentList) { // LCOV_EXCL_START 6: double check, m_pmNotificationList, m_pvPersistentList, m_pvUserPersistentList can't be NULL // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map/vector object is NULL"); // LCOV_EXCL_LINE 6: m_pmNotificationList, m_pvPersistentList, m_pvUserPersistentList can't be NULL // NOLINT[whitespace/line_length]
+ return NULL;
+ }
+ // LCOV_EXCL_STOP
+
+ // check if notification already exists
+ l_itNotification = m_pmNotificationList->find(f_cnotificationname);
+
+ // if exists remove previous entry
+ if (m_pmNotificationList->end() != l_itNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Removing previous entry of notification %s from map", f_cnotificationname.c_str());
+ m_pmNotificationList->erase(l_itNotification);
+ }
+
+ switch (f_enotificationtype) {
+ // if notification is regular notification
+ case eFrameworkunifiedNotificationVar: {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Regular Notification :: %s", f_cnotificationname.c_str());
+ l_pNotification = new(std::nothrow) CRegularNotification(f_cnotificationname,
+ f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ break;
+ }
+
+ // if notification is state notification
+ case eFrameworkunifiedStateVar: {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "State Notification :: %s", f_cnotificationname.c_str());
+ l_pNotification = new(std::nothrow) CStateNotification(f_cnotificationname,
+ f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ break;
+ }
+
+ // if notification is persistence notification
+ case eFrameworkunifiedPersistedStateVar: {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "PersistedState Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_pNotification = new(std::nothrow) CStatePersistenceNotification(f_cnotificationname,
+ f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
+ // insert notification in persistent notification vector
+ m_pvPersistentList->push_back(f_cnotificationname);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory not allocated"); // LCOV_EXCL_LINE 5: It's impossible to mock new() function // NOLINT[whitespace/line_length]
+ }
+
+ break;
+ }
+
+ // if notification is user persistence notification
+ case eFrameworkunifiedPersistedStateUserVar: {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "PersistedStateUser Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_pNotification = new(std::nothrow) CStatePersistenceUserNotification(f_cnotificationname,
+ f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
+ // insert notification in user persistent notification vector
+ m_pvUserPersistentList->push_back(f_cnotificationname);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NULL pointer error"); // LCOV_EXCL_LINE 5: It's impossible to mock new() function // NOLINT[whitespace/line_length]
+ }
+
+ break;
+ }
+
+ // if notification is immediate persistence notification
+ case eFrameworkunifiedImmediatePersistedStateVar: {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Immediate PersistedState Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_pNotification = new(std::nothrow) CStateNorPersistenceNotification(f_cnotificationname,
+ f_uimsglength,
+ f_uidelay); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (NULL != l_pNotification) {
+ // insert notification in notification map
+ m_pmNotificationList->insert(make_pair(f_cnotificationname, l_pNotification));
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object creation failed for %s.", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pNotification;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SearchNotification
+/// This function is used to search whether notification object is present in map or not.
+/// If present it sends the reference.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotification *CNotificationManager::SearchNotification(const std::string &f_cnotificationname) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+
+ // iterator to find notification from map of notifications
+ Notification_Iterator_Type l_itNotification;
+
+ if (NULL == m_pmNotificationList || f_cnotificationname.empty()) { // LCOV_EXCL_BR_LINE 6: double check, m_pmNotificationList can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map pointer is NULL"); // LCOV_EXCL_LINE 6: m_pmNotificationList can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
+ } else {
+ // check if this notification's object present in map
+ l_itNotification = m_pmNotificationList->find(f_cnotificationname);
+
+ // if notification found in map
+ if (m_pmNotificationList->end() != l_itNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification found in map :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ // get the notification object pointer from map
+ l_pNotification = (*l_itNotification).second;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Notification not found :: %s", f_cnotificationname.c_str());
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pNotification;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SearchPersistenceNotification
+/// This function is used to search for the given persistent notification in map.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStateNotification *CNotificationManager::SearchPersistenceNotification(const std::string &f_cnotificationname) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // pointer of notification object
+ CNotification *l_pNotification = NULL;
+ CStateNotification *l_pStateNotification = NULL;
+
+ // search the notification in the map
+ l_pNotification = SearchNotification(f_cnotificationname);
+
+ if (NULL != l_pNotification) {
+ if (eFrameworkunifiedPersistedStateVar == l_pNotification->GetNotificationType() ||
+ eFrameworkunifiedPersistedStateUserVar == l_pNotification->GetNotificationType() ||
+ eFrameworkunifiedImmediatePersistedStateVar == l_pNotification->GetNotificationType()) {
+ l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "There is no persistence notification registered with name :: %s",
+ f_cnotificationname.c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pStateNotification;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceServiceOnRegisterEvents
+/// This function creates notification object depending on its type and if already created it adds
+/// the service name to the list in the notification object.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnRegisterEvents(const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ const UI_32 f_uimsglength,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ const UI_32 f_uidelay) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+
+ if (f_cservicename.empty() || f_cnotificationname.empty()) {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ // get the notification object from map or create new object
+ l_pNotification = SearchNotification(f_cnotificationname);
+
+ // if new notification is registered
+ if (NULL == l_pNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Create new notification object :: %s", f_cnotificationname.c_str());
+
+ // create the new notification object depending on type and insert in map and vector
+ l_pNotification = CreateNotificationObject(f_cnotificationname,
+ f_uimsglength,
+ f_enotificationtype,
+ f_uidelay);
+
+ if (NULL != l_pNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Set Notification publisher %s for notification %s", f_cservicename.c_str(),
+ f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+
+ // set publisher name
+ l_estatus = l_pNotification->SetEventPublisher(f_cservicename);
+ }
+ } else { // if notification object already exists
+ EFrameworkunifiedNotificationType l_eNotificationType = l_pNotification->GetNotificationType();
+
+ // <<notification type is eFrameworkunifiedUnknown
+ // if some service had already subscribed to the notification before registering it.>>
+ if (eFrameworkunifiedUnknown == l_eNotificationType) {
+ // creates new notification object depending on the type and insert it in notification map
+ l_estatus = ChangeNotificationType(l_pNotification, f_cservicename, f_cnotificationname, f_uimsglength,
+ f_enotificationtype, f_uidelay);
+
+ // delete the old notification object
+ delete l_pNotification; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_pNotification = NULL;
+ } else { // notification is already registered by some service
+ // update the notification property, if re-registered by the same publisher
+ if (f_cservicename == l_pNotification->GetPublisherName() || // if re-register by service
+ "" == l_pNotification->GetPublisherName()) { // if previously unregistered by service
+ // if type is same just update the length of notification data
+ if (l_eNotificationType == f_enotificationtype) {
+ if (l_pNotification->GetMaxMessageSize() != f_uimsglength) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Updating max size of notification %s to %d from %d", f_cnotificationname.c_str(),
+ f_uimsglength, l_pNotification->GetMaxMessageSize());
+ l_estatus = l_pNotification->ResetMaxMessageSize(f_uimsglength);
+ }
+
+ if ("" == l_pNotification->GetPublisherName()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Updating publisher name of notification %s to %s from %s", f_cservicename.c_str(),
+ f_cnotificationname.c_str(), l_pNotification->GetPublisherName().c_str());
+ l_pNotification->SetEventPublisher(f_cservicename);
+ }
+ } else if (eFrameworkunifiedImmediatePersistedStateVar != l_eNotificationType &&
+ eFrameworkunifiedImmediatePersistedStateVar != f_enotificationtype) {
+ // else create new notification object depending on the type and delete the old one
+ // note: do not change immediate notification type
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Changing type of notfn %s from %d to %d", f_cnotificationname.c_str(),
+ l_eNotificationType, f_enotificationtype);
+
+ std::vector<std::string>::iterator l_itNotificationName;
+
+ // remove the notification name from the persistent list of notification(if any)
+ if (eFrameworkunifiedPersistedStateVar == l_eNotificationType) {
+ l_itNotificationName = find(m_pvPersistentList->begin(), m_pvPersistentList->end(), f_cnotificationname);
+
+ if (m_pvPersistentList->end() != l_itNotificationName) {
+ m_pvPersistentList->erase(l_itNotificationName);
+ }
+ } else if (eFrameworkunifiedPersistedStateUserVar == l_eNotificationType) {
+ l_itNotificationName = find(m_pvUserPersistentList->begin(),
+ m_pvUserPersistentList->end(),
+ f_cnotificationname);
+
+ if (m_pvUserPersistentList->end() != l_itNotificationName) {
+ m_pvUserPersistentList->erase(l_itNotificationName);
+ }
+ } else {
+ // do nothing
+ }
+
+ // creates new notification object depending on the new type and insert it in map and delete the old one
+ l_estatus = ChangeNotificationType(l_pNotification, f_cservicename, f_cnotificationname, f_uimsglength,
+ f_enotificationtype, f_uidelay);
+
+ // delete the old notification object
+ delete l_pNotification;
+ l_pNotification = NULL;
+ } else {
+ // do nothing
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notfn: %s already registered by %s, skipping register request by %s",
+ f_cnotificationname.c_str(), l_pNotification->GetPublisherName().c_str(), f_cservicename.c_str());
+
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ChangeNotificationType
+/// This function creates new notification object depending on the type and replaces the old one.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::ChangeNotificationType(CNotification *f_pnotification,
+ const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ const UI_32 f_uimsglength,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ const UI_32 f_uidelay) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNewNotification = NULL;
+
+ if (NULL != f_pnotification) { // LCOV_EXCL_BR_LINE 6: f_pnotification can't be NULL
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Create New Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ // create new notification object as per notification type
+ l_pNewNotification = CreateNotificationObject(f_cnotificationname, f_uimsglength, f_enotificationtype, f_uidelay);
+
+ if (NULL != l_pNewNotification) {
+ l_estatus = l_pNewNotification->SetEventPublisher(f_cservicename);
+
+ // assign subscribers list to newly created notification
+ l_pNewNotification->SetNewSubscribersList(f_pnotification);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error creating notification object for notification:%s",
+ f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: f_pnotification can't be NULL
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceServiceOnUnRegisterEvents
+/// This function removes the name of the service from the notification object.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnUnRegisterEvents(const std::string &f_cservicename,
+ const std::string &f_cnotificationname) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+ std::vector<std::string> *l_pvPersistentList = NULL;
+
+ // iterator to find notification from map of notifications
+ Notification_Iterator_Type l_itNotification;
+
+ if (f_cservicename.empty() || f_cnotificationname.empty()) {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ // check if this notification's object present in map
+ l_itNotification = m_pmNotificationList->find(f_cnotificationname);
+
+ // if notification found in map
+ if (m_pmNotificationList->end() != l_itNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification found in map"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ // get the notification object pointer from map
+ l_pNotification = (*l_itNotification).second;
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: f_pnotification can't be NULL
+ if (eFrameworkunifiedPersistedStateUserVar == l_pNotification->GetNotificationType()) {
+ l_pvPersistentList = m_pvUserPersistentList;
+ } else if (eFrameworkunifiedPersistedStateVar == l_pNotification->GetNotificationType()) {
+ l_pvPersistentList = m_pvPersistentList;
+ }
+
+ // reset the publisher name
+ l_estatus = l_pNotification->ResetEventPublisher(f_cservicename);
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ // if no other service is subscribed to this notification and no service is registered
+ // to this notification remove the notification object from map
+ if (!l_pNotification->IsServiceRegistered() &&
+ l_pNotification->IsSubscribersListEmpty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Deleting Notification Object"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ // delete the notification
+ delete l_pNotification; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_pNotification = NULL;
+
+ m_pmNotificationList->erase(l_itNotification);
+
+ if (l_pvPersistentList) {
+ // find the notification in vector
+ std::vector<std::string>::iterator l_itNotificationName;
+
+ l_itNotificationName = find(l_pvPersistentList->begin(),
+ l_pvPersistentList->end(),
+ f_cnotificationname);
+
+ if (l_pvPersistentList->end() != l_itNotificationName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification name from vector");
+ l_pvPersistentList->erase(l_itNotificationName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Persistent list empty"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Services still registered or subscriber list empty"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s is not registered by service %s",
+ f_cnotificationname.c_str(), f_cservicename.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_pnotification can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not registered", f_cnotificationname.c_str());
+
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not found.", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceServiceOnPublishEvent
+/// This function stores the published data in the notification object in case of state and
+/// persistent notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnPublishEvent(const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+
+ if (f_cservicename.empty() || f_cnotificationname.empty()) { // LCOV_EXCL_BR_LINE 6: f_cservicename and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_cservicename and f_cnotificationname can't be empty
+ } else {
+ // get the notification object from map
+ l_pNotification = SearchNotification(f_cnotificationname);
+
+ if (NULL != l_pNotification) {
+ // publish the notification
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotification->Publish(f_cservicename,
+ f_pmessage,
+ f_uimsgsize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error publishing notification %s published by %s, status: %d",
+ f_cnotificationname.c_str(), f_cservicename.c_str(), l_estatus); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification not registered"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceServiceOnSubscribeToEvent
+/// This function adds the name of the application to subscribers list in notification object.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnSubscribeToEvent(const std::string &f_csubscribername,
+ const std::string &f_cnotificationname) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // iterator to find notification from map of notifications
+ Notification_Iterator_Type l_itNotification;
+
+ CNotification *l_pNotification = NULL;
+
+ if (f_cnotificationname.empty() || f_csubscribername.empty()) {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ } else if (NULL == m_pmNotificationList) { // LCOV_EXCL_BR_LINE 6 m_pmNotificationList can't be NULL
+ // LCOV_EXCL_START 6: m_pmNotificationList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map pointer is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ // get the notification object from map or create new object
+ l_pNotification = SearchNotification(f_cnotificationname);
+
+ if (NULL == l_pNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "CNotification object created for %s", f_cnotificationname.c_str());
+
+ l_pNotification = new(std::nothrow) CNotification(f_cnotificationname, 0); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ m_pmNotificationList->insert(make_pair(f_cnotificationname, l_pNotification));
+ }
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: double check, l_pNotification can't be NULL
+ // add subscribers name in subscribers list of notification
+ l_estatus = l_pNotification->AddEventReciever(f_csubscribername);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory not allocated for l_pNotification"); // LCOV_EXCL_LINE 6: double check, l_pNotification can't be NULL // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceServiceOnUnSubscribeFromEvent
+/// This function removes the name of the application from the subscribers list in notification object.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnUnSubscribeFromEvent(const std::string &f_csubscribername,
+ const std::string &f_cnotificationname) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+
+ // iterator to find notification from map of notifications
+ Notification_Iterator_Type l_itNotificationType;
+
+ std::vector<std::string> *l_pvPersistentList = NULL;
+
+ if (f_cnotificationname.empty() || f_csubscribername.empty()) {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ } else if (NULL == m_pmNotificationList) { // LCOV_EXCL_BR_LINE 6: m_pmNotificationList can't be NULL
+ // LCOV_EXCL_START 6: m_pmNotificationList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification list pointer is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ // check if this notification's object present in map
+ l_itNotificationType = m_pmNotificationList->find(f_cnotificationname);
+
+ // if notification found in map
+ if (m_pmNotificationList->end() != l_itNotificationType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification %s found in map", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ l_pNotification = (*l_itNotificationType).second;
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: l_pNotification can't be NULL
+ if (eFrameworkunifiedPersistedStateUserVar == l_pNotification->GetNotificationType()) {
+ l_pvPersistentList = m_pvUserPersistentList;
+ } else if (eFrameworkunifiedPersistedStateVar == l_pNotification->GetNotificationType()) {
+ l_pvPersistentList = m_pvPersistentList;
+ }
+
+ // removes the subscribers name from subscribers list of notification
+ l_estatus = l_pNotification->DeleteEventReciever(f_csubscribername);
+
+ // if no other service is subscribed to this notification and no service is registered
+ // to this notification remove the notification object from map
+ if (!l_pNotification->IsServiceRegistered() &&
+ l_pNotification->IsSubscribersListEmpty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification Object from map"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ // delete notification object from map
+ delete l_pNotification; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_pNotification = NULL;
+
+ m_pmNotificationList->erase(l_itNotificationType);
+
+ if (l_pvPersistentList) {
+ // find notification in vector
+ std::vector<std::string>::iterator l_itNotificationName;
+ l_itNotificationName = find(l_pvPersistentList->begin(),
+ l_pvPersistentList->end(),
+ f_cnotificationname);
+
+ if (l_pvPersistentList->end() != l_itNotificationName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification from vector"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_pvPersistentList->erase(l_itNotificationName);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Persistent list Empty."); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotification can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Notification %s not registered", f_cnotificationname.c_str());
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Notification %s not found.", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NPGetPersistentNotificationData
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NPGetPersistentNotificationData(const std::string &f_cnotificationname,
+ PVOID f_pnotificationdata,
+ const UI_32 f_uidatasize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+ CStateNotification *l_pStateNotification = NULL;
+ const CPersistentData *l_pPersistentData = NULL;
+
+ if (f_cnotificationname.empty() || NULL == f_pnotificationdata) { // LCOV_EXCL_BR_LINE 6: f_pnotificationdata can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_pnotificationdata can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
+ } else {
+ l_pNotification = SearchNotification(f_cnotificationname);
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 200: f_cnotificationname must be NTFY_NPPService_UserChange, NTFY_NPPService_UserChange must be registered in FrameworkunifiedOnEntry() by itself. // NOLINT[whitespace/line_length]
+ const EFrameworkunifiedNotificationType l_eNotificationType = l_pNotification->GetNotificationType();
+
+ if (eFrameworkunifiedStateVar == l_eNotificationType ||
+ eFrameworkunifiedPersistedStateVar == l_eNotificationType ||
+ eFrameworkunifiedPersistedStateUserVar == l_eNotificationType ||
+ eFrameworkunifiedImmediatePersistedStateVar == l_eNotificationType) { // LCOV_EXCL_BR_LINE 200: NTFY_NPPService_UserChange's type is eFrameworkunifiedPersistedStateVar. // NOLINT[whitespace/line_length]
+ l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
+
+ l_pPersistentData = l_pStateNotification->GetPersistentData();
+
+ if (NULL != l_pPersistentData) {
+ if (f_uidatasize >= l_pPersistentData->m_uiMsgSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending Data Size %d", l_pPersistentData->m_uiMsgSize);
+
+ if (NULL != l_pPersistentData->m_pMessage) {
+ std::memcpy(f_pnotificationdata, l_pPersistentData->m_pMessage, l_pPersistentData->m_uiMsgSize);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification data is NULL");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Smaller buffer size %d is received for notification data of size %d", f_uidatasize,
+ l_pPersistentData->m_uiMsgSize);
+ }
+ } else {
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Persistent data object is NULL for notification %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 200: NTFY_NPPService_UserChange's type is eFrameworkunifiedPersistedStateVar.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Get notification data failed, Notification %s is registered as type %d",
+ f_cnotificationname.c_str(), l_eNotificationType);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: f_cnotificationname must be NTFY_NPPService_UserChange, NTFY_NPPService_UserChange must be registered in FrameworkunifiedOnEntry() by itself. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not found.", f_cnotificationname.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceServiceOnGetPersistentData
+/// This function is used to get the persistent data stored related to notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnGetPersistentData(const std::string &f_cnotificationname,
+ const std::string &f_creceivername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+ CStateNotification *l_pStateNotification = NULL;
+ const CPersistentData *l_pPersistentData = NULL;
+
+ if (f_cnotificationname.empty() || f_creceivername.empty()) { // LCOV_EXCL_BR_LINE 6: f_creceivername can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: f_creceivername can't be NULL and f_cnotificationname can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ // open the receiver message queue
+ HANDLE l_hReceiverMq = McOpenSender(f_creceivername.c_str());
+
+ if (NULL == l_hReceiverMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // catastrophic failure!
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to open MessageQ %s ", f_creceivername.c_str());
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ // get the notification object from map or create new object
+ l_pNotification = SearchNotification(f_cnotificationname);
+
+ if (NULL != l_pNotification) {
+ l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
+
+ if (NULL != l_pStateNotification) { // LCOV_EXCL_BR_LINE 5: fail safe for static_cast<CStateNotification *>
+ l_pPersistentData = l_pStateNotification->GetPersistentData();
+
+ if (NULL != l_pPersistentData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending Data Size %d", l_pPersistentData->m_uiMsgSize);
+
+ if (NULL == l_pPersistentData->m_pMessage) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending Data is NULL");
+ }
+
+ // sent the notification data to requester
+ l_estatus = McSend(l_hReceiverMq,
+ AppName,
+ NPS_GET_PERS_DATA_ACK,
+ l_pPersistentData->m_uiMsgSize,
+ l_pPersistentData->m_pMessage);
+ FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Persistent data found for notification %s. "
+ "Sent NPS_GET_PERS_DATA_ACK to %s. Status: %d."
+ , f_cnotificationname.c_str(), f_creceivername.c_str(), l_estatus);
+ } else { // In case of failure, we send back a failure ACK
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "No persistent data found for notification %s. "
+ , f_cnotificationname.c_str());
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not found", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+ // Close the mq handle
+ McClose(l_hReceiverMq);
+ l_hReceiverMq = NULL;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceGetPersistentNotificationData
+/// This function is used to get the list of persistent notifications and data associated with it.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceGetPersistentNotificationData(std::vector<CNotificationsToPersist *>
+ *f_pvpersistnotification,
+ const EFrameworkunifiedNotificationType f_enotificationtype,
+ UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+ CStateNotification *l_pStateNotification = NULL;
+ CStatePersistenceNotification *l_pStatePersistenceNotification = NULL;
+
+ std::string l_cNotificationName = "";
+ CNotificationsToPersist *l_pNotificationsToPersist = NULL;
+ const CPersistentData *l_pPData = NULL;
+
+ std::vector<std::string> *l_pvPersistentList = NULL;
+
+ // iterator for retrieving notifications from map of notifications
+ Notification_Iterator_Type l_itNotification;
+
+ if (eFrameworkunifiedPersistedStateUserVar == f_enotificationtype) {
+ l_pvPersistentList = m_pvUserPersistentList;
+ } else if (eFrameworkunifiedPersistedStateVar == f_enotificationtype) { // LCOV_EXCL_BR_LINE 6: f_enotificationtype must be eFrameworkunifiedPersistedStateUserVar or eFrameworkunifiedPersistedStateVar // NOLINT[whitespace/line_length]
+ l_pvPersistentList = m_pvPersistentList;
+ }
+
+ // copy all the notification data in map to received vector
+ if (NULL != f_pvpersistnotification && NULL != l_pvPersistentList) { // LCOV_EXCL_BR_LINE 6: f_pvpersistnotification and l_pvPersistentList can't be null // NOLINT[whitespace/line_length]
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < l_pvPersistentList->size();
+ l_uiCount++) {
+ // get the persistent notification name from vector
+ l_cNotificationName = l_pvPersistentList->at(l_uiCount);
+
+ // search for notification in map
+ l_itNotification = m_pmNotificationList->find(l_cNotificationName);
+
+ // notification found in map
+ if (m_pmNotificationList->end() != l_itNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Persistent Notification: %s", l_cNotificationName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ // get notification object from map
+ l_pNotification = (*l_itNotification).second;
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: l_pNotification can't be NULL
+ if (eFrameworkunifiedPersistedStateVar == f_enotificationtype) {
+ l_pStatePersistenceNotification = static_cast<CStatePersistenceNotification *>(l_pNotification);
+
+ // get the notification's default data
+ if ((eFrameworkunifiedUserData == l_pStatePersistenceNotification->GetPersistentCategory() &&
+ (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedUserData)) ||
+ (eFrameworkunifiedFactoryData == l_pStatePersistenceNotification->GetPersistentCategory() &&
+ (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedFactoryData)) ||
+ (eFrameworkunifiedFactoryCustomerData == l_pStatePersistenceNotification->GetPersistentCategory() &&
+ (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedFactoryCustomerData)) ||
+ (eFrameworkunifiedDealerData == l_pStatePersistenceNotification->GetPersistentCategory() &&
+ (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedDealerData))) {
+ l_pPData = l_pStatePersistenceNotification->GetDefaultPersistentData();
+ } else {
+ l_pStateNotification = l_pStatePersistenceNotification;
+
+ // get the published notification data
+ if (l_pStateNotification->IsPublished()) {
+ l_pPData = l_pStateNotification->GetPersistentData();
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification not published");
+ }
+ }
+ } else {
+ l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
+
+ // if not to reset userdata
+ if (0 == (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedUserData)) {
+ if (l_pStateNotification->IsPublished()) {
+ l_pPData = l_pStateNotification->GetPersistentData();
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification not published");
+ }
+ }
+ }
+
+ if ((NULL != l_pStateNotification) && (NULL != l_pPData)) {
+ l_pNotificationsToPersist = CreateNotificationObjectToPersist(l_pStateNotification, l_pPData); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ // insert the persistent data in map
+ f_pvpersistnotification->push_back(l_pNotificationsToPersist); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ l_pPData = NULL;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "no data is stored in notification %s", l_cNotificationName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object is NULL for %s", l_cNotificationName.c_str()); // LCOV_EXCL_LINE 6: l_pNotification can't be NULL // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Non Persistent Notification: %s", l_cNotificationName.c_str());
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: f_pvpersistnotification and l_pvPersistentList can't be null // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateNotificationObjectToPersist
+/// Creates the CNotificationsToPersist object from notification object and the persistent data.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotificationsToPersist *CNotificationManager::CreateNotificationObjectToPersist(CStateNotification
+ *f_pStateNotification,
+ const CPersistentData *f_pdata) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotificationsToPersist *l_pNotificationsToPersist = NULL;
+ CPersistentData *l_pData = NULL;
+
+ if (NULL != f_pStateNotification && NULL != f_pdata) { // LCOV_EXCL_BR_LINE 6: f_pStateNotification and f_pdata can't be NULL // NOLINT[whitespace/line_length]
+ if (f_pStateNotification->GetMaxMessageSize() >= f_pdata->m_uiMsgSize) {
+ l_pNotificationsToPersist = new(std::nothrow) CNotificationsToPersist(); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ if (NULL != l_pNotificationsToPersist) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
+ l_pNotificationsToPersist->m_pPersistentData = new(std::nothrow) CPersistentData(); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ l_pData = l_pNotificationsToPersist->m_pPersistentData;
+
+ if (NULL != l_pData) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
+ l_pNotificationsToPersist->m_cNotificationName = f_pStateNotification->GetNotificationName();
+ l_pNotificationsToPersist->m_uiMaxMsgLength = f_pStateNotification->GetMaxMessageSize();
+ l_pNotificationsToPersist->m_ePersistentType = f_pStateNotification->GetNotificationType();
+
+ if (eFrameworkunifiedPersistedStateVar == l_pNotificationsToPersist->m_ePersistentType) {
+ l_pNotificationsToPersist->m_ePersistCategory = (static_cast<CStatePersistenceNotification *>
+ (f_pStateNotification))->GetPersistentCategory();
+ }
+
+ l_pNotificationsToPersist->m_cPublisherName = f_pStateNotification->GetPublisherName();
+
+ l_pData->m_uiMsgSize = f_pdata->m_uiMsgSize;
+ l_pData->m_pMessage = new(std::nothrow) CHAR[l_pNotificationsToPersist->m_uiMaxMsgLength];
+
+ if (NULL != l_pData->m_pMessage) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
+ std::memset(l_pData->m_pMessage, 0, l_pNotificationsToPersist->m_uiMaxMsgLength);
+ std::memcpy(l_pData->m_pMessage, f_pdata->m_pMessage, f_pdata->m_uiMsgSize);
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "memory not allocated for l_pNotificationsToPersist"); // LCOV_EXCL_LINE 5: It's impossible to mock new() function // NOLINT[whitespace/line_length]
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error persisting notfn, Data size of notification %s is %d greater than max registered size %d",
+ f_pStateNotification->GetNotificationName().c_str(),
+ f_pdata->m_uiMsgSize, f_pStateNotification->GetMaxMessageSize());
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid parameter received"); // LCOV_EXCL_LINE 6: f_pStateNotification and f_pdata can't be NULL // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_pNotificationsToPersist;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSetPersistentNotificationData
+/// This function is used to create the persistent notifications object and fill the data related
+/// with it on system load.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceSetPersistentNotificationData(std::vector<CNotificationsToPersist *>
+ *f_pvpersistnotification) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CStateNotification *l_pNotification = NULL;
+ CNotificationsToPersist *l_pNotificationsToPersist = NULL;
+
+ std::vector<std::string> *l_pvPersistentList = NULL;
+
+ Persistent_Iterator_Type l_itPersistentData;
+
+ // store all the notification data received in vector to map of CNotification and to vector of
+ // persistent notification in case of persistent and user persistent notification
+ if (NULL != f_pvpersistnotification) { // LCOV_EXCL_BR_LINE 6: double check, f_pvpersistnotification can't be NULL
+ for (UI_32 l_uiCount = 0;
+ l_uiCount < f_pvpersistnotification->size();
+ l_uiCount++) {
+ // get the persistent data object
+ l_pNotificationsToPersist = f_pvpersistnotification->at(l_uiCount);
+
+ if (NULL != l_pNotificationsToPersist) { // LCOV_EXCL_BR_LINE 6: double check, l_pNotificationsToPersist can't be NULL // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Persistent Type %d", l_pNotificationsToPersist->m_ePersistentType);
+
+ if (eFrameworkunifiedPersistedStateVar == l_pNotificationsToPersist->m_ePersistentType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "PersistentState Notification");
+
+ l_pNotification = new(std::nothrow) CStatePersistenceNotification(
+ l_pNotificationsToPersist->m_cNotificationName,
+ l_pNotificationsToPersist->m_uiMaxMsgLength,
+ l_pNotificationsToPersist->m_ePersistCategory);
+
+ l_pvPersistentList = m_pvPersistentList;
+ } else if (eFrameworkunifiedPersistedStateUserVar == l_pNotificationsToPersist->m_ePersistentType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "PersistentStateUser Notification");
+
+ l_pNotification = new(std::nothrow) CStatePersistenceUserNotification(
+ l_pNotificationsToPersist->m_cNotificationName,
+ l_pNotificationsToPersist->m_uiMaxMsgLength);
+
+ l_pvPersistentList = m_pvUserPersistentList;
+ } else if (eFrameworkunifiedImmediatePersistedStateVar == l_pNotificationsToPersist->m_ePersistentType) { // LCOV_EXCL_BR_LINE 6: l_pNotificationsToPersist->m_ePersistentType must be eFrameworkunifiedPersistedStateVar, eFrameworkunifiedPersistedStateUserVar, eFrameworkunifiedImmediatePersistedStateVar // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "PersistentStateUser Notification");
+
+ l_pNotification = new(std::nothrow) CStateNorPersistenceNotification(
+ l_pNotificationsToPersist->m_cNotificationName,
+ l_pNotificationsToPersist->m_uiMaxMsgLength,
+ l_pNotificationsToPersist->m_uiDelay,
+ l_pNotificationsToPersist->m_ePersistCategory);
+ }
+
+ if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: l_pNotification can't be NULL
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Insert persistent notification object in map");
+
+ l_pNotification->SetPersistentData(l_pNotificationsToPersist->m_pPersistentData->m_pMessage,
+ l_pNotificationsToPersist->m_pPersistentData->m_uiMsgSize);
+
+ l_pNotification->SetEventPublisher(l_pNotificationsToPersist->m_cPublisherName);
+
+ if (NULL != m_pmNotificationList) { // LCOV_EXCL_BR_LINE 6: double check, m_pmNotificationList can't be NULL
+ m_pmNotificationList->insert(make_pair(l_pNotificationsToPersist->m_cNotificationName, l_pNotification));
+
+ if (NULL != l_pvPersistentList) {
+ l_pvPersistentList->push_back(l_pNotificationsToPersist->m_cNotificationName);
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Inserted persistent notification object in map");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Inserted persistent notification object in vector");
+ } else {
+ // LCOV_EXCL_START 6: double check, m_pmNotificationList can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ delete l_pNotification;
+ l_pNotification = NULL;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object not inserted in map/vector");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotification can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "notification object is NULL");
+
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pNotificationsToPersist can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationsToPersist is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, f_pvpersistnotification can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistent data pointer is NULL");
+
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveUserSpecificNotificationEntry
+/// This function is used to remove the user persistent notifications entry
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::RemoveUserSpecificNotificationEntry() { // LCOV_EXCL_START 100: never be used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string l_cNotificationName;
+
+ std::vector<std::string>::iterator l_itNotificationName;
+
+ // iterator to find notification from map of notifications
+ Notification_Iterator_Type l_itNotification;
+
+ CNotification *l_pNotification = NULL;
+
+ for (l_itNotificationName = m_pvUserPersistentList->begin() ; l_itNotificationName < m_pvUserPersistentList->end() ;
+ l_itNotificationName++) {
+ l_cNotificationName = *(l_itNotificationName);
+
+ // check if this notification's object present in map
+ l_itNotification = m_pmNotificationList->find(l_cNotificationName);
+
+ if (m_pmNotificationList->end() != l_itNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification found in map");
+
+ // get the notification object pointer from map
+ l_pNotification = (*l_itNotification).second;
+
+ if (NULL != l_pNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification Object");
+
+ // delete the notification
+ delete l_pNotification;
+ l_pNotification = NULL;
+
+ m_pmNotificationList->erase(l_itNotification);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification name from vector");
+ m_pvUserPersistentList->erase(l_itNotificationName);
+
+ l_itNotificationName = m_pvUserPersistentList->begin();
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification not found.");
+
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CNotificationManager::GetNotificationInfo(const std::string &f_cnotificationname, // LCOV_EXCL_START 100: never be used // NOLINT[whitespace/line_length]
+ CNotificationsToPersist *&f_pnotificationstopersist) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification *l_pNotification = NULL;
+ CStateNotification *l_pStateNotification = NULL;
+ const CPersistentData *l_pPData = NULL;
+
+ l_pNotification = SearchNotification(f_cnotificationname);
+ l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
+
+ if (NULL != l_pStateNotification) {
+ if (l_pStateNotification->IsPublished()) {
+ l_pPData = l_pStateNotification->GetPersistentData();
+
+ if (NULL != l_pPData) {
+ f_pnotificationstopersist = new(std::nothrow) CNotificationsToPersist();
+
+ if (NULL == f_pnotificationstopersist) {
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation error for f_pnotificationstopersist");
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ f_pnotificationstopersist->m_pPersistentData = new(std::nothrow) CPersistentData();
+
+ if (NULL == f_pnotificationstopersist->m_pPersistentData) {
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation error for f_pnotificationstopersist->m_pPersistentData");
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ f_pnotificationstopersist->m_cNotificationName = l_pStateNotification->GetNotificationName();
+ f_pnotificationstopersist->m_uiMaxMsgLength = l_pStateNotification->GetMaxMessageSize();
+ f_pnotificationstopersist->m_cPublisherName = l_pStateNotification->GetPublisherName();
+ f_pnotificationstopersist->m_ePersistentType = l_pStateNotification->GetNotificationType();
+
+ if (eFrameworkunifiedPersistedStateVar == f_pnotificationstopersist->m_ePersistentType) {
+ f_pnotificationstopersist->m_ePersistCategory = (static_cast<CStatePersistenceNotification *>
+ (l_pStateNotification))->GetPersistentCategory();
+ }
+
+ if (eFrameworkunifiedImmediatePersistedStateVar == f_pnotificationstopersist->m_ePersistentType) {
+ CStateNorPersistenceNotification *l_pStateNorPersistenceNotification =
+ static_cast<CStateNorPersistenceNotification *>(l_pStateNotification);
+ f_pnotificationstopersist->m_uiDelay = l_pStateNorPersistenceNotification->GetPersistenceDelay();
+ f_pnotificationstopersist->m_ePersistCategory = (static_cast<CStateNorPersistenceNotification *>
+ (l_pStateNotification))->GetPersistentCategory();
+ }
+
+ f_pnotificationstopersist->m_pPersistentData->m_pMessage = new(std::nothrow)
+ CHAR[f_pnotificationstopersist->m_uiMaxMsgLength];
+ std::memset(f_pnotificationstopersist->m_pPersistentData->m_pMessage, 0,
+ f_pnotificationstopersist->m_uiMaxMsgLength);
+ std::memcpy(f_pnotificationstopersist->m_pPersistentData->m_pMessage,
+ l_pPData->m_pMessage, l_pPData->m_uiMsgSize);
+
+ f_pnotificationstopersist->m_pPersistentData->m_uiMsgSize = l_pPData->m_uiMsgSize;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "No data is stored in notification %s", f_cnotificationname.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification %s not published", f_cnotificationname.c_str());
+ }
+ } else {
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSetDefaultPersistentNotificationData
+/// This function is used to set the default data of persistent notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceSetDefaultPersistentNotificationData(const std::string &f_cnotificationname,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // pointer of notification object
+ CStateNotification *l_pStateNotification = SearchPersistenceNotification(f_cnotificationname);
+
+ if (NULL != l_pStateNotification) {
+ l_estatus = l_pStateNotification->SetDefaultPersistentData(f_pmessage, f_uimsgsize);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to set default notification data for %s, notification does not exists",
+ f_cnotificationname.c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSetPersistentCategory
+/// This function is used to set the persistent type of persistent notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceSetPersistentCategory(const std::string &f_cnotificationname,
+ const EFrameworkunifiedPersistCategory f_epersistcategory) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // pointer of notification object
+ CStateNotification *l_pStateNotification = SearchPersistenceNotification(f_cnotificationname);
+
+ if (NULL != l_pStateNotification) {
+ EFrameworkunifiedNotificationType l_eNotificationType = l_pStateNotification->GetNotificationType();
+
+ if (eFrameworkunifiedPersistedStateVar == l_eNotificationType) {
+ l_estatus = (static_cast<CStatePersistenceNotification *>(l_pStateNotification))->SetPersistentCategory(
+ f_epersistcategory);
+ } else if (eFrameworkunifiedImmediatePersistedStateVar == l_eNotificationType) {
+ l_estatus = (static_cast<CStateNorPersistenceNotification *>(l_pStateNotification))->SetPersistentCategory(
+ f_epersistcategory);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Cannot set category %d for notification %s of type %d", f_epersistcategory,
+ f_cnotificationname.c_str(), l_eNotificationType);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Cannot set category %d for %s, Either not registered or not a persistent notification",
+ f_epersistcategory, f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentservicePublishImmediateNotification
+/// This function publish the immediate notification f_cnotificationname to all its subscribers.
+/// This API is called when service updates the immediate notification data in persistent memory
+/// using synchronous API.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CNotificationManager::NotificationpersistentservicePublishImmediateNotification(const std::string &f_cservicename,
+ const std::string &f_cnotificationname,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_cservicename.empty() || f_cnotificationname.empty()) {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ // get the notification object from map
+ CStateNotification *l_pStateNotf = SearchPersistenceNotification(f_cnotificationname);
+
+ if (NULL != l_pStateNotf) {
+ if (eFrameworkunifiedImmediatePersistedStateVar == l_pStateNotf->GetNotificationType()) {
+ CStateNorPersistenceNotification *l_pImmediateNotf =
+ static_cast<CStateNorPersistenceNotification *>(l_pStateNotf);
+
+ // publish the notification
+ if (eFrameworkunifiedStatusOK != (l_estatus = l_pImmediateNotf->PublishNotification(f_cservicename,
+ f_pmessage,
+ f_uimsgsize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error publishing notification %s published by %s, status: %d",
+ f_cnotificationname.c_str(), f_cservicename.c_str(), l_estatus);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s is not registered as immediate persistence by service %s",
+ f_cnotificationname.c_str(), f_cservicename.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not registered by service %s", f_cnotificationname.c_str(),
+ f_cservicename.c_str());
+
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+EFrameworkunifiedStatus CNotificationManager::GetNotificationProfilingData(std::string &f_cnotificationprofileInfo) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ Notification_Iterator_Type l_itNotification;
+ NotifReceiver_Iterator_Type l_itNotifReceiver_Iterator;
+
+ CNotification *l_pNotification = NULL;
+ NotifReceiver_Type *l_pSubscriberList = NULL;
+
+ std::stringstream ss;
+ UI_32 l_uiSubscriberCnt = 0;
+
+ std::string l_cPublisher = "";
+ std::string l_cNotification = "";
+
+ try {
+ if (NULL == m_pmNotificationList) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification List m_pmNotificationList is NULL in notification manager");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus && m_pmNotificationList->empty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification List m_pmNotificationList Empty in notification manager");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ f_cnotificationprofileInfo.append("Application Name,");
+ f_cnotificationprofileInfo.append("Notification Name,");
+ f_cnotificationprofileInfo.append("Type,");
+ f_cnotificationprofileInfo.append("Length,");
+ f_cnotificationprofileInfo.append("Subscribed By,");
+ f_cnotificationprofileInfo.append("Subscribers Count");
+
+ for (l_itNotification = m_pmNotificationList->begin();
+ l_itNotification != m_pmNotificationList->end();
+ l_itNotification++) {
+ l_pNotification = (*l_itNotification).second;
+ if (NULL == l_pNotification) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object ptr is NULL");
+ l_estatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_cPublisher = l_pNotification->GetPublisherName();
+ if (l_cPublisher.empty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Publisher name empty");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ l_cNotification = l_pNotification->GetNotificationName();
+ if (l_cNotification.empty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification name empty");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ l_pSubscriberList = l_pNotification->GetSubscriberList();
+ if (NULL == l_pSubscriberList) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Subscribers List ptr is NULL");
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) {
+ f_cnotificationprofileInfo.append("\n");
+
+ f_cnotificationprofileInfo.append(l_cPublisher);
+ f_cnotificationprofileInfo.append(",");
+
+ f_cnotificationprofileInfo.append(l_cNotification);
+ f_cnotificationprofileInfo.append(",");
+
+ switch (l_pNotification->GetNotificationType()) {
+ case eFrameworkunifiedNotificationVar : {
+ f_cnotificationprofileInfo.append("Regular");
+ }
+ break;
+
+ case eFrameworkunifiedStateVar : {
+ f_cnotificationprofileInfo.append("State");
+ }
+ break;
+
+ case eFrameworkunifiedPersistedStateVar : {
+ f_cnotificationprofileInfo.append("PersistenceState");
+ }
+ break;
+
+ case eFrameworkunifiedPersistedStateUserVar : {
+ f_cnotificationprofileInfo.append("UserPersistenceState");
+ }
+ break;
+
+ case eFrameworkunifiedImmediatePersistedStateVar : {
+ f_cnotificationprofileInfo.append("ImmediatePersistenceState");
+ }
+ break;
+
+ case eFrameworkunifiedUnknown: {
+ f_cnotificationprofileInfo.append("Unknown");
+ }
+ break;
+
+ default:
+ break;
+ }
+ f_cnotificationprofileInfo.append(",");
+
+ ss << l_pNotification->GetMaxMessageSize();
+ f_cnotificationprofileInfo.append(ss.str());
+ ss.str("");
+ f_cnotificationprofileInfo.append(",\"");
+
+ l_uiSubscriberCnt = 0;
+ for (l_itNotifReceiver_Iterator = l_pSubscriberList->begin();
+ l_pSubscriberList->end() != l_itNotifReceiver_Iterator;) {
+ f_cnotificationprofileInfo.append(l_itNotifReceiver_Iterator->first);
+ ++l_uiSubscriberCnt;
+
+ ++l_itNotifReceiver_Iterator;
+
+ if (l_pSubscriberList->end() != l_itNotifReceiver_Iterator) {
+ f_cnotificationprofileInfo.append(",");
+ }
+ }
+
+ f_cnotificationprofileInfo.append("\",");
+
+ ss << l_uiSubscriberCnt;
+ f_cnotificationprofileInfo.append(ss.str());
+ ss.str("");
+ }
+
+ l_estatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ } catch (std::exception &exp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Exception:: %s", exp.what());
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+#endif
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_notification_receiver.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_notification_receiver.cpp
new file mode 100644
index 00000000..53b9eab8
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_notification_receiver.cpp
@@ -0,0 +1,50 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CNotificationReceiver.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include "ns_npp_notification_receiver.h"
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CNotificationReceiver
+/// Constructor of CNotificationReceiver class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotificationReceiver::CNotificationReceiver() {
+ m_MsgQHandle = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CNotificationReceiver
+/// Destructor of CNotificationReceiver class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CNotificationReceiver::~CNotificationReceiver() {
+ m_MsgQHandle = NULL;
+}
+
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_persist_file.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_persist_file.cpp
new file mode 100644
index 00000000..4b0e4522
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_persist_file.cpp
@@ -0,0 +1,100 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains definition of CFilePersistence class.
+/// This class is responsible for persisting and retrieving of files.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <unistd.h>
+#include <string>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_copy_worker.h"
+#include "ns_npp_persist_file.h"
+#include "ns_npp_registry_entry.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFilePersistence
+/// Constructor of CFilePersistence class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFilePersistence::CFilePersistence() {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFilePersistence
+/// Destructor of CFilePersistence class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFilePersistence::~CFilePersistence() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Release
+/// Entry for the file is stored in map for persistence.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFilePersistence::Release(std::string f_crequesterappname,
+ std::string f_ctag,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_cmempath.empty() || f_crequesterappname.empty() || f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cmempath, f_crequesterappname and f_ctag can't be empty
+ // LCOV_EXCL_START 6: f_cmempath, f_crequesterappname and f_ctag can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid file path, requester or tag.");
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ l_estatus = ProcessReleaseRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE, f_cmempath, enotificationpersistentservicereleasetype,
+ f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- l_estatus:0x%x", l_estatus);
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Load
+/// Load file from persistent memory to the specified location.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFilePersistence::Load(std::string f_crequesterappname,
+ std::string f_ctag,
+ std::string f_cretrievepath,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+
+ if (!f_ctag.empty() && !f_crequesterappname.empty() && !f_cretrievepath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_ctag, f_crequesterappname and f_cretrievepath can't be empty
+ l_estatus = ProcessLoadRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE, f_cretrievepath, f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ } else {
+ // LCOV_EXCL_START 6: f_ctag, f_crequesterappname and f_cretrievepath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid argument passed (RetrievePath:%s ,tag:%s, requester:%s)",
+ f_cretrievepath.c_str(), f_ctag.c_str(), f_crequesterappname.c_str());
+
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_persist_folder.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_persist_folder.cpp
new file mode 100644
index 00000000..87b1ed49
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_persist_folder.cpp
@@ -0,0 +1,96 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <unistd.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <string>
+#include "ns_npp_persistence.h"
+#include "ns_npp_persist_folder.h"
+#include "ns_npp_registry_entry.h"
+
+// Constructor of class CFolderPersistence
+CFolderPersistence::CFolderPersistence() {
+}
+
+// Destructor of class CFolderPersistence
+CFolderPersistence::~CFolderPersistence() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+// Method to release folder for persistence.
+EFrameworkunifiedStatus CFolderPersistence::Release(std::string f_crequesterappname,
+ std::string f_ctag,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_cmempath.empty() || f_crequesterappname.empty() || f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cmempath, f_crequesterappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: f_ctag, f_crequesterappname and f_cmempath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid folder path, requester or tag.");
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ // Call to method requesting to release the folder for persistence.
+ l_estatus = ProcessReleaseRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER, f_cmempath, enotificationpersistentservicereleasetype,
+ f_cusername);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- l_estatus:0x%x", l_estatus);
+ return l_estatus;
+}
+
+// Method to load folder from persistent memory.
+EFrameworkunifiedStatus CFolderPersistence::Load(std::string f_crequesterappname,
+ std::string f_ctag,
+ std::string f_cretrievepath,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+
+ if (!f_ctag.empty() && !f_crequesterappname.empty() && !f_cretrievepath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cretrievepath, f_crequesterappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ // Call to method requesting to load the folder from persistent memory.
+ l_estatus = ProcessLoadRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER, f_cretrievepath, f_cusername);
+ } else {
+ // LCOV_EXCL_START 6: f_ctag, f_crequesterappname and f_cretrievepath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid argument passed (RetrievePath:%s ,tag:%s, requester:%s)",
+ f_cretrievepath.c_str(), f_ctag.c_str(), f_crequesterappname.c_str());
+
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_persistence.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_persistence.cpp
new file mode 100644
index 00000000..a39b8360
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_persistence.cpp
@@ -0,0 +1,743 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CPersistence.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifdef AGL_STUB
+#include <other_service/strlcpy.h>
+// #include "frameworkunified_stub.h"
+#endif
+#include <unistd.h>
+#include <stdlib.h> // for getenv()
+#ifdef AGL_STUB
+#include <cstdio>
+#endif
+#include <utility>
+#include <string>
+#include "ns_npp_persistence.h"
+#include "ns_npp_registry_entry.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CPersistence
+/// Constructor of CPersistence class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CPersistence::CPersistence():
+ m_cStoragePath(GetStoragePath()),
+ m_eCompressionType(ENOTIFICATIONPERSISTENTSERVICEDEFAULTCOMPRESSION),
+ m_hNSWriteToPersistentMem(NULL),
+ m_hNSReadFromPersistentMem(NULL),
+ m_hAppHandle(NULL),
+ m_bPersist(FALSE),
+ m_uiNotificationpersistentservicePersistCategoryFlag(0) {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CPersistence
+/// Destructor of CPersistence class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CPersistence::~CPersistence() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetReadThreadHandle
+/// Set read thread handle.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistence::SetReadThreadHandle(HANDLE f_hreadthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_hNSReadFromPersistentMem = f_hreadthread;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetWriteThreadHandle
+/// Set write thread handle.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistence::SetWriteThreadHandle(HANDLE f_hwritethread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_hNSWriteToPersistentMem = f_hwritethread;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetStoragePath
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+std::string CPersistence::GetStoragePath() {
+ std::string l_cStoragePath(STORAGE_PATH);
+
+ return l_cStoragePath;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Register
+/// Register tag for persistence.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::Register(std::string f_crequestorappname, std::string f_ctag, BOOL bisuserpersistence) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (f_ctag.empty() || f_crequestorappname.empty()) { // LCOV_EXCL_BR_LINE 6: f_ctag and f_crequestorappname can't be empty // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: f_ctag and f_crequestorappname can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid tag or requester.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ TSourceRegistryListItr l_itRegistry = m_mPersistRegistry.find(f_crequestorappname);
+ if (l_itRegistry != m_mPersistRegistry.end()) {
+ // source available, check for file/folder availability
+ TTagRegistryListItr l_itRegistryList = (l_itRegistry->second).find(f_ctag);
+ if (l_itRegistryList != (l_itRegistry->second).end()) {
+ // found already in the registry
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Already exists %s , %s", f_ctag.c_str(), f_crequestorappname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ } else {
+ // tag not found .. so add to the registry
+ CRegistryEntry l_objRegistryEntry(f_ctag, f_crequestorappname, m_cStoragePath,
+ bisuserpersistence); // f_eRegisterType, f_cUser);
+
+ (l_itRegistry->second).insert(make_pair(f_ctag, l_objRegistryEntry));
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s found adding tag %s", f_crequestorappname.c_str(), f_ctag.c_str());
+ }
+ } else {
+ // source not found, so creating a new entry
+ CRegistryEntry l_objRegistryEntry(f_ctag, f_crequestorappname, m_cStoragePath,
+ bisuserpersistence); // f_eRegisterType, f_cUser);
+
+ TTagRegistryList l_mRegList;
+ l_mRegList.insert(make_pair(f_ctag, l_objRegistryEntry)); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ m_mPersistRegistry.insert(std::make_pair(f_crequestorappname, l_mRegList)); // LCOV_EXCL_BR_LINE 11:except,C++ STL // NOLINT[whitespace/line_length]
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "none exists %s , %s. So, added entry.", // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ f_ctag.c_str(), f_crequestorappname.c_str()); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- l_estatus:0x%x", l_estatus);
+
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessReleaseRequest
+/// Persist file/folder that need to be persisted.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::ProcessReleaseRequest(std::string f_crequesterappname,
+ std::string f_ctag,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (f_cmempath.empty() || f_crequesterappname.empty() || f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6:f_cmempath, f_crequesterappname and f_ctag can`t be empty // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: f_cmempath, f_crequesterappname and f_ctag can`t be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG0(ZONE_ERR, __FUNCTION__, "Invalid file path, requester or tag.");
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ // Persistence Registry map iterator
+ TSourceRegistryListItr l_itTSourceRegistryListItr = m_mPersistRegistry.find(f_crequesterappname);
+
+ if (l_itTSourceRegistryListItr != m_mPersistRegistry.end()) {
+ // source available, check for file if registered
+ TTagRegistryListItr l_itTRegistryList = (l_itTSourceRegistryListItr->second).find(f_ctag);
+ if (l_itTRegistryList != (l_itTSourceRegistryListItr->second).end()) {
+ if (eFrameworkunifiedNotOnRelease != enotificationpersistentservicereleasetype) {
+ // Set release path
+ l_itTRegistryList->second.SetReleasePath(f_cmempath);
+ // Set persist path
+ l_itTRegistryList->second.SetPersistProperties(f_epersisttype, f_cusername); // LCOV_EXCL_BR_LINE 11:except,C++ STL // NOLINT[whitespace/line_length]
+
+ // file/folder found in registry
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "%s released %s. Found in registry. queued up to persist from %s",
+ f_crequesterappname.c_str(), f_ctag.c_str(), l_itTRegistryList->second.GetReleasePath().c_str());
+
+ // check if persist flag is set due to shutdown or user change
+ if ((m_bPersist // It will be set to TRUE either on shutdown or userchange
+ && l_itTRegistryList->second.HasntBeenPersisted()) // File/Folder persisted or not
+ || (eFrameworkunifiedPersistInstantly == enotificationpersistentservicereleasetype)) {
+ // reset the data
+ if (((eFrameworkunifiedUserData == l_itTRegistryList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedUserData & m_uiNotificationpersistentservicePersistCategoryFlag)) ||
+ ((eFrameworkunifiedFactoryData == l_itTRegistryList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedFactoryData & m_uiNotificationpersistentservicePersistCategoryFlag)) ||
+ ((eFrameworkunifiedFactoryCustomerData == l_itTRegistryList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedFactoryCustomerData & m_uiNotificationpersistentservicePersistCategoryFlag)) ||
+ ((eFrameworkunifiedDealerData == l_itTRegistryList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedDealerData & m_uiNotificationpersistentservicePersistCategoryFlag))) {
+ // set the status of file/folder persisted as reset has been called on these data
+ l_itTRegistryList->second.SetCurrentAction(LOADTYPE_RELEASE);
+ l_itTRegistryList->second.SetBeingPersisted();
+ } else { // persist the data
+ if (eFrameworkunifiedStatusOK != (l_estatus = Persist(static_cast<CRegistryEntry &>(l_itTRegistryList->second)))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ }
+ } else {
+ // Don't persist now. Persist on shutdown.
+ }
+ } else { // not on release
+ // set the status of file/folder as released and persisted as these data need not to be persisted on shutdown
+ l_itTRegistryList->second.SetReleasePath("");
+ l_itTRegistryList->second.SetCurrentAction(LOADTYPE_RELEASE);
+ l_itTRegistryList->second.SetBeingPersisted();
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warning: %s didn't register %s, not persisting",
+ f_crequesterappname.c_str(), f_ctag.c_str()); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ // source not registered, cannot persist
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warning: %s is not registered ignoring release of %s",
+ f_ctag.c_str(), f_crequesterappname.c_str());
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+ }
+ return l_estatus;
+}
+
+EFrameworkunifiedStatus CPersistence::Persist(CRegistryEntry &f_objregistryentry) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // Persistence Info Structure
+ NSP_CopyInfoCmd l_tCpInfo = {};
+
+
+ std::string l_cSourcePath = f_objregistryentry.GetReleasePath();
+ std::string l_cPersistPath = f_objregistryentry.GetPersistPath(); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ // Fill the persistence info structure
+ AddRequestData(l_tCpInfo,
+ l_cSourcePath,
+ l_cPersistPath,
+ f_objregistryentry.GetRequester(),
+ f_objregistryentry.GetTag(),
+ LOADTYPE_RELEASE,
+ f_objregistryentry.GetPersistType());
+
+ // Persist only if file was released.
+ // Release means application has asked NPPService to persist file at shutdown.)
+ // Persist means actual persisting a file at persistent storage
+ if (f_objregistryentry.IsReleased()) {
+ if (ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEINPROCESS == f_objregistryentry.m_eJobState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Another job with source: %s and tag %s is in process. "
+ "Therefore adding release request to the pending queue.",
+ f_objregistryentry.GetRequester().c_str(), f_objregistryentry.GetTag().c_str());
+ // if job corresponding to the tag is already in process, add it in pending queue
+ m_lPendingJobs.push_back(l_tCpInfo);
+ } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE == f_objregistryentry.m_eJobState) {
+ if (eFrameworkunifiedStatusOK == (SendRequestMessage(l_tCpInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Release message passed to writer thread."); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ f_objregistryentry.SetCurrentAction(LOADTYPE_RELEASE);
+ f_objregistryentry.m_eJobState = ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEINPROCESS;
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failure in passing release message to writer thread.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File/Folder not released yet.");
+ }
+
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ProcessLoadRequest
+/// Load persisted file/folder.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::ProcessLoadRequest(std::string f_crequesterappname,
+ std::string f_ctag,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cretrievepath,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // file/folder found in registry
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Load request received: Requester: %s and Tag: %s Load at: %s.",
+ f_crequesterappname.c_str(), f_ctag.c_str(), f_cretrievepath.c_str()); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ if (f_ctag.empty() || f_crequesterappname.empty() || f_cretrievepath.empty()) { // LCOV_EXCL_BR_LINE 6: both f_ctag and f_crequesterappname and f_cretrievepath can`t be empty // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: both f_ctag and f_crequesterappname and f_cretrievepath can`t be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid argument passed (RetrievePath:%s ,tag:%s, requester:%s)",
+ f_cretrievepath.c_str(), f_ctag.c_str(), f_crequesterappname.c_str());
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ // Persistence Registry Map Iterator
+ TSourceRegistryListItr l_itTRegistry = m_mPersistRegistry.find(f_crequesterappname);
+
+ // Persistence Info Struct
+ NSP_CopyInfoCmd l_tCopyInfo = {};
+
+ if (l_itTRegistry != m_mPersistRegistry.end()) {
+ // source available, check for file/folder
+ TTagRegistryListItr l_itTRegistryList = (l_itTRegistry->second).find(f_ctag);
+ if (l_itTRegistryList != (l_itTRegistry->second).end()) {
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATERELEASEABORTED == l_itTRegistryList->second.m_eJobState)) { // LCOV_EXCL_BR_LINE 6: m_eJobState can`t be ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATERELEASEABORTED // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: m_eJobState can`t be ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATERELEASEABORTED // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::string l_cReleasePath(l_itTRegistryList->second.GetReleasePath());
+ // if job was aborted due to some reason like abort shutdown.
+ // Then persistent storage doesn't have updated file/folder. Just restore
+ // aborted released file.
+ // just rename it
+ if (0 == std::rename(l_cReleasePath.c_str(), f_cretrievepath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File loaded at requested location.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error while processing load request when tried to move. source: %s dest: %s",
+ l_cReleasePath.c_str(), f_cretrievepath.c_str());
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ l_itTRegistryList->second.m_eJobState = ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE;
+ // LCOV_EXCL_STOP
+ } else {
+ std::string l_cLoadPath(l_itTRegistryList->second.GetLoadPath(f_epersisttype, f_cusername)); // LCOV_EXCL_BR_LINE 11:except,C++ STL // NOLINT[whitespace/line_length]
+
+ if (0 == access(l_cLoadPath.c_str(), R_OK)) {
+ // file/folder found in registry
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Found in registry. checking in persistence...(%s)", l_cLoadPath.c_str());
+
+ AddRequestData(l_tCopyInfo,
+ l_cLoadPath,
+ f_cretrievepath,
+ f_crequesterappname,
+ f_ctag,
+ LOADTYPE_LOAD,
+ f_epersisttype);
+
+ if (ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEINPROCESS == (l_itTRegistryList->second).m_eJobState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Another job with source: %s and tag %s is in process. "
+ "Therefore adding load request to the pending queue.",
+ f_crequesterappname.c_str(), f_ctag.c_str());
+ m_lPendingJobs.push_back(l_tCopyInfo);
+ } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE == (l_itTRegistryList->second).m_eJobState) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Found in persistence.");
+ if (eFrameworkunifiedStatusOK == (SendRequestMessage(l_tCopyInfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Load message passed to reader thread. Retrieving..");
+ // file/folder is requested for loading so reset the persisted flag.
+ l_itTRegistryList->second.ResetPersistedFlag();
+ l_itTRegistryList->second.SetCurrentAction(LOADTYPE_LOAD);
+ l_itTRegistryList->second.m_eJobState = ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEINPROCESS;
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failure in passing load message to reader thread.");
+ l_estatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "%s requested by %s. Not found in persistence memory.", // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ f_ctag.c_str(), f_crequesterappname.c_str()); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ l_estatus = eFrameworkunifiedStatusAccessError;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warning: %s requesting %s .. Tag not found",
+ f_crequesterappname.c_str(), f_ctag.c_str()); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ // source not found
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warning: %s requesting %s .. Requester not found",
+ f_crequesterappname.c_str(), f_ctag.c_str());
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ return l_estatus;
+}
+
+VOID CPersistence::AddRequestData(NSP_CopyInfoCmd &f_tcpinfo,
+ std::string f_sourcepath,
+ std::string f_destpath,
+ std::string f_crequesterappname,
+ std::string f_ctag,
+ ENPS_Loadtype f_eloadtype,
+ ENotificationpersistentservicePersistType f_epersisttype) {
+#ifdef AGL_PosixBasedOS001LEGACY_USED
+ strlcpy(f_tcpinfo.m_csourcepath, f_sourcepath.c_str(), sizeof(f_tcpinfo.m_csourcepath));
+ strlcpy(f_tcpinfo.m_cdestinationpath, f_destpath.c_str(), sizeof(f_tcpinfo.m_cdestinationpath));
+ strlcpy(f_tcpinfo.m_crequesterappname, f_crequesterappname.c_str(), sizeof(f_tcpinfo.m_crequesterappname));
+ strlcpy(f_tcpinfo.m_cpersistenttag, f_ctag.c_str(), sizeof(f_tcpinfo.m_cpersistenttag));
+#endif
+ f_tcpinfo.m_eloadtype = f_eloadtype;
+ f_tcpinfo.m_epersisttype = f_epersisttype;
+ // f_tcpinfo.m_eCompressionType = ENOTIFICATIONPERSISTENTSERVICECOMPRESSUSINGLIBZ;
+}
+
+EFrameworkunifiedStatus CPersistence::SendRequestMessage(NSP_CopyInfoCmd &f_tcpinfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hThreadHandle = NULL;
+ // Worker Command Protocol
+ ENSP_CopyWorkerProtocol l_eWorkerProtocol = CP_WRK_CMD_COPY;
+
+ if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == f_tcpinfo.m_epersisttype) {
+ l_eWorkerProtocol = CP_WRK_CMD_COPY;
+ } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == f_tcpinfo.m_epersisttype) {
+ l_eWorkerProtocol = AR_CMD_ARCHIVE;
+ }
+
+ if (LOADTYPE_RELEASE == f_tcpinfo.m_eloadtype) {
+ l_hThreadHandle = m_hNSWriteToPersistentMem;
+ } else if (LOADTYPE_LOAD == f_tcpinfo.m_eloadtype) {
+ l_hThreadHandle = m_hNSReadFromPersistentMem;
+ }
+
+ if (l_hThreadHandle) {
+ // issue a copy to the worker thread
+ if (eFrameworkunifiedStatusOK != (l_estatus = McSend(l_hThreadHandle, AppName, l_eWorkerProtocol, sizeof(NSP_CopyInfoCmd), &f_tcpinfo))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend for thread failed %d", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// AckReceivedFromWorker
+/// This is callback function for ack that file is released to persistenet memory.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::AckReceivedFromWorker(PCSTR f_csource, PCSTR f_ctag, BOOL f_bcopystatus,
+ ENPS_Loadtype f_eloadtype) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus retVal = eFrameworkunifiedStatusOK;
+
+ std::string l_cRequester(f_csource);
+ std::string l_cTag(f_ctag); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ TSourceRegistryListItr l_itTReg = m_mPersistRegistry.find(l_cRequester);
+ if (l_itTReg != m_mPersistRegistry.end()) {
+ // source available, check for file
+ TTagRegistryListItr l_itTRegList = (l_itTReg->second).find(l_cTag);
+ if (l_itTRegList != (l_itTReg->second).end()) {
+ if (LOADTYPE_RELEASE == f_eloadtype) {
+ l_itTRegList->second.SetBeingPersisted(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ if (f_bcopystatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "File persisted %s / %s", f_csource, f_ctag);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
+ "File not persisted %s / %s, Negative ack received from copy worker thread",
+ f_csource,
+ f_ctag); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ }
+
+ // Job processed. Set job state as idle
+ l_itTRegList->second.m_eJobState = ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE;
+
+ // check if there are any pending jobs for corresponding source and tag
+ if (!m_lPendingJobs.empty()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Retrieving next pending job for persistence...");
+ TPendingJobsItr l_itrPendingJobs;
+ for (l_itrPendingJobs = m_lPendingJobs.begin(); l_itrPendingJobs != m_lPendingJobs.end(); ++l_itrPendingJobs) {
+ if (0 == std::strcmp((*l_itrPendingJobs).m_crequesterappname, f_csource)
+ && (0 == std::strcmp((*l_itrPendingJobs).m_cpersistenttag, f_ctag))) {
+ if (eFrameworkunifiedStatusOK == (retVal = (SendRequestMessage((*l_itrPendingJobs))))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ // set job state as processing
+ l_itTRegList->second.m_eJobState = ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEINPROCESS;
+ // set current action
+ l_itTRegList->second.SetCurrentAction((*l_itrPendingJobs).m_eloadtype);
+ // Reset persisted flag. It requires to process release request for this tag.
+ // Because, file will be persisted only once. Unless, anyone loads the file again.
+ if (LOADTYPE_LOAD == (*l_itrPendingJobs).m_eloadtype) {
+ l_itTRegList->second.ResetPersistedFlag();
+ }
+
+ // remove job from pending list
+ m_lPendingJobs.erase(l_itrPendingJobs);
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failure in passing load/release message to the worker threads.");
+ retVal = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ break;
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No pending jobs"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // tag not found ..
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " ERROR %s, tag %s not found ", f_csource, f_ctag);
+ }
+ } else {
+ // source not found
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "ERROR none exists %s , %s", f_csource, f_ctag);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return retVal;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// PersistAllReleaseRequests
+/// Persist all files which are not persisted yet.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::PersistAllReleaseRequests(UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ m_bPersist = TRUE; // set to true because persist of all release requests have been triggered.
+ // Trigger reason: shutdown
+
+ m_uiNotificationpersistentservicePersistCategoryFlag = f_uinotificationpersistentservicepersistcategoryflag;
+
+ TSourceRegistryListItr l_itTReg = m_mPersistRegistry.begin();
+
+ for (; l_itTReg != m_mPersistRegistry.end(); ++l_itTReg) {
+ TTagRegistryListItr l_itTRegList = (l_itTReg->second).begin();
+ for (; l_itTRegList != (l_itTReg->second).end(); ++l_itTRegList) {
+ if (l_itTRegList->second.HasntBeenPersisted()) {
+ // reset the data
+ if (((eFrameworkunifiedUserData == l_itTRegList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedUserData & f_uinotificationpersistentservicepersistcategoryflag)) ||
+ ((eFrameworkunifiedFactoryData == l_itTRegList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedFactoryData & f_uinotificationpersistentservicepersistcategoryflag)) ||
+ ((eFrameworkunifiedFactoryCustomerData == l_itTRegList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedFactoryCustomerData & f_uinotificationpersistentservicepersistcategoryflag)) ||
+ ((eFrameworkunifiedDealerData == l_itTRegList->second.GetPersistentCategory()) &&
+ (eFrameworkunifiedDealerData & f_uinotificationpersistentservicepersistcategoryflag))) {
+ // set the status of file/folder as released and persisted as these data need not to be persisted on shutdown
+ l_itTRegList->second.SetCurrentAction(LOADTYPE_RELEASE);
+ l_itTRegList->second.SetBeingPersisted();
+ } else { // persist the data
+ if (eFrameworkunifiedStatusOK != Persist(static_cast<CRegistryEntry &>(l_itTRegList->second))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+BOOL CPersistence::HaveAllReleaseRequestsPersisted(std::string &f_ctagnotreleased) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bRetVal = TRUE;
+
+ TSourceRegistryListItr l_itTReg = m_mPersistRegistry.begin();
+
+ f_ctagnotreleased.assign("");
+
+ for (; l_itTReg != m_mPersistRegistry.end(); ++l_itTReg) {
+ TTagRegistryListItr l_itTRegList = (l_itTReg->second).begin();
+ for (; l_itTRegList != (l_itTReg->second).end(); ++l_itTRegList) {
+ if (l_itTRegList->second.HasntBeenPersisted()) {
+ l_bRetVal = FALSE;
+
+ if (!l_itTRegList->second.IsReleased()) {
+ f_ctagnotreleased.append("\n");
+ f_ctagnotreleased.append(l_itTRegList->second.GetTag());
+ f_ctagnotreleased.append(" [");
+ f_ctagnotreleased.append(l_itTRegList->second.GetRequester());
+ f_ctagnotreleased.append("]");
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bRetVal;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// PersistAllUserRequests
+/// Persist all user files which are not persisted yet.
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::PersistAllUserRequests() {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ // TODO(my_username): Persist data on userchange. Uncomment following.
+ // m_bPersist = TRUE; // set to true because persist of all user release requests have been triggered.
+ // Trigger reason: user change
+
+ TSourceRegistryListItr l_itTReg = m_mPersistRegistry.begin();
+
+ for (; l_itTReg != m_mPersistRegistry.end(); ++l_itTReg) {
+ TTagRegistryListItr l_itTRegList = (l_itTReg->second).begin();
+ for (; l_itTRegList != (l_itTReg->second).end(); ++l_itTRegList) {
+ if (l_itTRegList->second.IsUserPersistence()) {
+ if (eFrameworkunifiedStatusOK != Persist(static_cast<CRegistryEntry &>(l_itTRegList->second))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ }
+ }
+ }
+ return l_estatus;
+}
+
+BOOL CPersistence::IsUserPersistence(std::string f_ctag) {
+ BOOL l_bUserPersistence = FALSE;
+
+ TSourceRegistryListItr l_itTReg = m_mPersistRegistry.begin();
+
+ for (; l_itTReg != m_mPersistRegistry.end(); ++l_itTReg) {
+ TTagRegistryListItr l_itTRegList = (l_itTReg->second).begin();
+ for (; l_itTRegList != (l_itTReg->second).end(); ++l_itTRegList) {
+ if (l_itTRegList->second.GetTag() == f_ctag) {
+ if (l_itTRegList->second.IsUserPersistence()) {
+ l_bUserPersistence = TRUE;
+ }
+ break;
+ }
+ }
+ }
+
+ return l_bUserPersistence;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersistentCategory
+/// Sets the persist type of file/folder
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistence::SetPersistentCategory(const std::string &f_crequesterappname,
+ const std::string &f_ctag,
+ EFrameworkunifiedPersistCategory f_epersistcategory) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // Persistence Registry map iterator
+ TSourceRegistryListItr l_itTSourceRegistryListItr = m_mPersistRegistry.find(f_crequesterappname);
+
+ if (m_mPersistRegistry.end() != l_itTSourceRegistryListItr) {
+ // source available, check for file if registered
+ TTagRegistryListItr l_itTRegistryList = (l_itTSourceRegistryListItr->second).find(f_ctag);
+
+ if ((l_itTSourceRegistryListItr->second).end() != l_itTRegistryList) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "AppName:: %s, Tag:: %s found in registry", f_crequesterappname.c_str(),
+ f_ctag.c_str());
+
+ l_estatus = (l_itTRegistryList->second).SetPersistentCategory(f_epersistcategory);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warning: %s didn't register %s", f_crequesterappname.c_str(), f_ctag.c_str());
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ // source not registered, cannot persist
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Warning: %s is not registered", f_ctag.c_str());
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ResetPersistFlag
+/// Resets the persist flag.
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistence::ResetPersistFlag() {
+ m_bPersist = FALSE;
+
+ m_uiNotificationpersistentservicePersistCategoryFlag = 0;
+}
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+EFrameworkunifiedStatus CPersistence::GetPersistenceProfilingData(std::string &f_cpersistenceprofileinfo) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ TSourceRegistryListItr l_itrTSourceRegistryListItr;
+ TTagRegistryListItr l_itrTTagRegistryListItr;
+
+ for (l_itrTSourceRegistryListItr = m_mPersistRegistry.begin();
+ l_itrTSourceRegistryListItr != m_mPersistRegistry.end();
+ l_itrTSourceRegistryListItr++) {
+ for (l_itrTTagRegistryListItr = (l_itrTSourceRegistryListItr->second).begin();
+ l_itrTTagRegistryListItr != (l_itrTSourceRegistryListItr->second).end();
+ l_itrTTagRegistryListItr++) {
+ f_cpersistenceprofileinfo.append("\n");
+ f_cpersistenceprofileinfo.append((*l_itrTSourceRegistryListItr).first);
+ f_cpersistenceprofileinfo.append(",");
+
+ f_cpersistenceprofileinfo.append(l_itrTTagRegistryListItr->first);
+ f_cpersistenceprofileinfo.append(",");
+
+ switch ((l_itrTTagRegistryListItr->second).GetPersistType()) {
+ case ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE: {
+ f_cpersistenceprofileinfo.append("File,");
+ }
+ break;
+
+ case ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER: {
+ f_cpersistenceprofileinfo.append("Folder,");
+ }
+ break;
+
+ default: {
+ f_cpersistenceprofileinfo.append(",");
+ }
+ break;
+ }
+
+ if ((l_itrTTagRegistryListItr->second).IsUserPersistence()) {
+ f_cpersistenceprofileinfo.append("Yes,");
+ } else {
+ f_cpersistenceprofileinfo.append("No,");
+ }
+
+ if ((l_itrTTagRegistryListItr->second).IsReleased()) {
+ f_cpersistenceprofileinfo.append("Yes,");
+ } else {
+ f_cpersistenceprofileinfo.append("No,");
+ }
+
+ if ((l_itrTTagRegistryListItr->second).IsPersisted()) {
+ f_cpersistenceprofileinfo.append("Yes");
+ } else {
+ f_cpersistenceprofileinfo.append("No");
+ }
+ }
+ }
+ return l_estatus;
+}
+
+#endif
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_persistence_manager.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_persistence_manager.cpp
new file mode 100644
index 00000000..7f5d292f
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_persistence_manager.cpp
@@ -0,0 +1,1132 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief This file contains implementation of class CPersistenceManager.
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <stdio.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_if.h>
+#include <native_service/ns_util_directory.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/frameworkunified_sm_framework_dispatch.h>
+#include <string>
+#include <native_service/ns_np_service_nor_persistence_internal.h>
+#include "ns_npp.h"
+#include "ns_npp_types.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_copy_worker.h"
+#include "ns_npp_persistence.h"
+#include "ns_npp_persist_file.h"
+#include "ns_npp_fs_directory.h"
+#include "ns_npp_persist_folder.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_binary_accesser.h"
+#include "ns_npp_persistence_manager.h"
+#include "ns_npp_nor_persistence_worker_thread.h"
+#include "ns_npp_state_nor_persistence_notification.h"
+
+extern const CHAR AppName[]; // NOLINT (readability/naming)
+
+// Initialisation of static class member for disabling persistence
+BOOL CPersistenceManager::m_bPersistenceDisabled = FALSE;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CPersistenceManager
+/// Constructor of CPersistenceManager class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CPersistenceManager::CPersistenceManager() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_cUserNotificationTag = USERNOTIFICATIONFILE;
+
+ m_poDataAccesser = NULL;
+
+ m_cNotificationPersistFilepath = CPersistence::GetStoragePath(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Storage path for persistence=%s", m_cNotificationPersistFilepath.c_str()); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+
+ m_cNotificationPersistFilepath += AppName;
+ m_cNotificationPersistFilepath += "/";
+
+ m_hNSImmediatePersistenceThread = NULL;
+ m_bAllFilePersisted = FALSE;
+ m_bImmediatedDataPersisted = FALSE;
+
+ if (eFrameworkunifiedStatusOK != Init()) { // LCOV_EXCL_BR_LINE 6: Init() must be return eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to initialize Persistent Manager."); // LCOV_EXCL_LINE 6: Init() must be return eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CPersistenceManager
+/// Destructor of CPersistenceManager class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CPersistenceManager::~CPersistenceManager() { // LCOV_EXCL_START 14: Resident process, global instance not released
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_poDataAccesser) {
+ delete m_poDataAccesser;
+ }
+
+ Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
+ // Remove memory allocated for persistence objects
+ for (; l_itPersist_Type != m_mPersist_Type.end(); ++l_itPersist_Type) {
+ if (NULL != (*l_itPersist_Type).second) {
+ delete(*l_itPersist_Type).second;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CPersistenceManager::Init() {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE] = new(std::nothrow) CFilePersistence(); // LCOV_EXCL_BR_LINE 11:unexpected branch
+
+ m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER] = new(std::nothrow) CFolderPersistence(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT[whitespace/line_length]
+
+ m_poDataAccesser = new(std::nothrow) CBinaryAccesser(); // Save data in binary format. // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT[whitespace/line_length]
+
+ // check if all object creation is successful
+ if (NULL != m_poDataAccesser) { // LCOV_EXCL_BR_LINE 5:m_poDataAccesser can`t be NULL
+ Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
+
+ // check if all object creation is successful
+ for (; l_itPersist_Type != m_mPersist_Type.end();
+ ++l_itPersist_Type) {
+ if (NULL == (*l_itPersist_Type).second) { // LCOV_EXCL_START 6:(*l_itPersist_Type).second can`t be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 5: m_poDataAccesser can`t be NULL
+ }
+
+ if (eFrameworkunifiedStatusOK != l_estatus) { // LCOV_EXCL_START 6: l_estatus must be eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (NULL != m_poDataAccesser) {
+ delete m_poDataAccesser;
+ }
+
+ Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
+ // check if all object creation is successful
+ for (; l_itPersist_Type != m_mPersist_Type.end(); ++l_itPersist_Type) {
+ if (NULL != (*l_itPersist_Type).second) {
+ delete(*l_itPersist_Type).second;
+ }
+ }
+ // LCOV_EXCL_STOP
+ }
+ std::string f_csourcepath = CPersistence::GetStoragePath();
+ if (f_csourcepath.length() > 0) { // LCOV_EXCL_BR_LINE 6: f_csourcepath.length() is always bigger then 0
+ f_csourcepath.append(RELEASETEMP_DIR); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ if (CFSDirectory::DoesDirecotryExist(f_csourcepath)) {
+ f_csourcepath.append(RELEASETEMP_FILENAME);
+ if (0 != remove(f_csourcepath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Temporary file not deleted::%s, errno:%d", f_csourcepath.c_str(), errno);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceRegister
+/// Registers a tag for the file/folder. This tag will be used for releasing or loading
+/// a file/folder.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceRegister(std::string f_cappname,
+ std::string f_ctag,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ BOOL bisuserpersistence) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+
+ if (f_cappname.empty() || f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Appname & tag should not be empty."); // LCOV_EXCL_LINE 6: f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ } else {
+ // check boundary conditions
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
+ // register tag
+ l_estatus = m_mPersist_Type[f_epersisttype]->Register(f_cappname, f_ctag,
+ bisuserpersistence); // f_eRegisterType, f_cUser); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ // m_mPersist_Type[f_ePersistFileType]->ListAllInMap();
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always biger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceRelease
+/// Entry for the file/folder is stored in map for persistence.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceRelease(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cmempath,
+ EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cusername) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+
+ if (f_cappname.empty() || f_ctag.empty() || f_cmempath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cappname, f_cmempath and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Appname & tag should not be empty."); // LCOV_EXCL_LINE 6: double check, f_cappname, f_cmempath and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ } else {
+ // check boundary conditions
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ // release file
+ if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
+ l_estatus = m_mPersist_Type[f_epersisttype]->Release(f_cappname,
+ f_ctag,
+ f_cmempath,
+ enotificationpersistentservicereleasetype,
+ f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceLoad
+/// Load file/folder from persistent memory to the specified location.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceLoad(std::string f_cappname,
+ std::string f_ctag,
+ std::string f_cretrievepath,
+ ENotificationpersistentservicePersistType f_epersisttype,
+ std::string f_cusername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_cappname.empty() || f_ctag.empty() || f_cretrievepath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cretrievepath, f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Appname, tag & retrieve path should not be empty."); // LCOV_EXCL_LINE 6: double check, f_cretrievepath, f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
+ } else {
+ // check boundary conditions
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
+ // load file
+ l_estatus = m_mPersist_Type[f_epersisttype]->Load(f_cappname, f_ctag, f_cretrievepath, f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// AckReceivedFromWorker
+/// Send release ack to file/folder persistence object.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::AckReceivedFromWorker(PCSTR f_csource, PCSTR f_ctag, ENotificationpersistentservicePersistType f_epersisttype,
+ BOOL f_bcopystatus, ENPS_Loadtype f_eloadtype) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if ((NULL == f_csource) || (NULL == f_ctag)) { // LCOV_EXCL_BR_LINE 6: f_csource and f_ctag can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "f_csource or f_ctag is NULL."); // LCOV_EXCL_LINE 6: f_csource and f_ctag can't be NULL // NOLINT[whitespace/line_length]
+ } else {
+ // check boundary conditions
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ if (NULL != m_mPersist_Type[f_epersisttype]) {
+ // Send release ack to file/folder persistence object.
+ l_estatus = m_mPersist_Type[f_epersisttype]->AckReceivedFromWorker(f_csource, f_ctag,
+ f_bcopystatus, f_eloadtype);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype);
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSaveNotificationData
+/// Save notification data in a persistent file.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSaveNotificationData(Persistent_Notification_List_Type
+ *f_vpersistentnotificationlist) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if ((NULL == m_poDataAccesser) || (NULL == f_vpersistentnotificationlist)) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_poDataAccesser or f_vpersistentnotificationlist is NULL."); // LCOV_EXCL_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
+ } else {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ std::string l_cNotificationFilePath = "";
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += NOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedPersistedStateVar,
+ eFrameworkunifiedUserData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += FACTORYNOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedPersistedStateVar,
+ eFrameworkunifiedFactoryData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += FACTORYCUSTOMERNOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedPersistedStateVar,
+ eFrameworkunifiedFactoryCustomerData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += DEALERNOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedPersistedStateVar,
+ eFrameworkunifiedDealerData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSaveUserNotificationData
+/// Save user notification data in a persistent file.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSaveUserNotificationData(Persistent_Notification_List_Type
+ *f_vpersistentnotificationlist) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if ((NULL == m_poDataAccesser) || (NULL == f_vpersistentnotificationlist)) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_poDataAccesser or f_vpersistentnotificationlist is NULL."); // LCOV_EXCL_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
+ } else {
+ l_estatus = m_poDataAccesser->PersistData(m_cNotificationUserMemFilepath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedPersistedStateUserVar); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceReadNotificationData
+/// Get the list of all persistent notifications from a persistent memory and store it in a map.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceReadNotificationData(Persistent_Notification_List_Type
+ * &f_vpersistentnotificationlist) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_poDataAccesser) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser would not be null
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ std::string l_cNotificationFilePath = "";
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += NOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedUserData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += FACTORYNOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedFactoryData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += FACTORYCUSTOMERNOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedFactoryCustomerData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+
+ l_cNotificationFilePath = m_cNotificationPersistFilepath;
+ l_cNotificationFilePath += DEALERNOTIFICATIONFILE;
+ if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedDealerData))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
+ l_cNotificationFilePath.c_str(), l_estatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceReadUserNotificationData
+/// Get the list of all user persistent notifications from a persistent memory and store it in a map.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceReadUserNotificationData(Persistent_Notification_List_Type
+ * &f_vpersistentnotificationlist) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_poDataAccesser) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser would not be null
+ l_estatus = m_poDataAccesser->RetrieveData(m_cNotificationUserMemFilepath,
+ f_vpersistentnotificationlist,
+ eFrameworkunifiedUserData); // LCOV_EXCL_BR_LINE 11:unexpected branch
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// PersistAllReleaseRequests
+/// Persist all released files and folder contained in the map in persistent memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::PersistAllReleaseRequests(UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+
+ // Persist all i.e files and folders
+ while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
+ if (NULL != m_mPersist_Type[l_ePersistType]) {
+ if (eFrameworkunifiedStatusFail == m_mPersist_Type[l_ePersistType]->PersistAllReleaseRequests(f_uinotificationpersistentservicepersistcategoryflag)) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentservicePersistAllUserRequests
+/// Persist all user files and folder contained in the map in persistent memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentservicePersistAllUserRequests() {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+
+ // Persist all i.e files and folders
+ while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
+ if (NULL != m_mPersist_Type[l_ePersistType]) {
+ l_estatus = m_mPersist_Type[l_ePersistType]->PersistAllUserRequests();
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType);
+ }
+
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetReadThreadHandle
+/// Pass the handle of the read thread to the object of file/folder persistence
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::SetReadThreadHandle(HANDLE f_hreadthread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_hreadthread != NULL) { // LCOV_EXCL_BR_LINE 6: f_hreadthread would not be null
+ // Set thread handle for object persistfile objects. i.e. for file/folder
+ for (Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
+ l_itPersist_Type != m_mPersist_Type.end();
+ ++l_itPersist_Type) {
+ if (NULL != (*l_itPersist_Type).second) { // LCOV_EXCL_BR_LINE 6: (*l_itPersist_Type).second can't be NULL
+ (*l_itPersist_Type).second->SetReadThreadHandle(f_hreadthread);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetWriteThreadHandle
+/// Pass the handle of the write thread to the object of file/folder persistence
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::SetWriteThreadHandle(HANDLE f_hwritethread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != f_hwritethread) { // LCOV_EXCL_BR_LINE 6: f_hwritethread would not be null
+ // Set thread handle for object persist objects. i.e. for file/folder
+ for (Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
+ l_itPersist_Type != m_mPersist_Type.end();
+ ++l_itPersist_Type) {
+ if (NULL != (*l_itPersist_Type).second) { // LCOV_EXCL_BR_LINE 6: (*l_itPersist_Type).second can't be NULL
+ (*l_itPersist_Type).second->SetWriteThreadHandle(f_hwritethread);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetWriteThreadHandle
+/// Pass the handle of the write thread to the object of file/folder persistence
+////////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::SetNorPersistenceThreadHandle(HANDLE f_hwritethread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != f_hwritethread) { // LCOV_EXCL_BR_LINE 6: f_hwritethread would not be null
+ m_hNSImmediatePersistenceThread = f_hwritethread;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// NPServiceOnCpWorkerAckCmd
+/// Handles when the CopyWorker sends an ack back for a message received .
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus NPServiceOnCpWorkerAckCmd(HANDLE f_happ) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ NSP_CopyAckMsg l_tack = {};
+ if (f_happ) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(f_happ, (PVOID)&l_tack, sizeof(NSP_CopyAckMsg), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length] // NOLINT[whitespace/line_length]
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "CP_WRK_ACK_CMD_COMPLETE for cmd 0x%X", l_tack.m_eworkerprotocol); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Unable to get message data in NPServiceOnCpWorkerAckCmd, status : 0x%x", l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 4: NSFW error case.
+ }
+
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetUserPersistentPath
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::SetUserPersistentPath(std::string f_cusername) {
+ m_cNotificationUserMemFilepath = CPersistence::GetStoragePath();
+ m_cNotificationUserMemFilepath += AppName;
+ m_cNotificationUserMemFilepath += "/";
+ m_cNotificationUserMemFilepath += f_cusername;
+ m_cNotificationUserMemFilepath += "/";
+ m_cNotificationUserMemFilepath += m_cUserNotificationTag;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsUserPersistence
+/// Check if tag is user persistence
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CPersistenceManager::IsUserPersistence(std::string f_ctag, ENotificationpersistentservicePersistType f_epersisttype) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ BOOL l_bUserPersistence = FALSE;
+
+ // check boundary conditions
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
+ // load file
+ l_bUserPersistence = m_mPersist_Type[f_epersisttype]->IsUserPersistence(f_ctag); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT[whitespace/line_length]
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bUserPersistence;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// HaveAllReleaseRequestsPersisted
+/// Check if all release requests processed or not
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CPersistenceManager::HaveAllReleaseRequestsPersisted() {
+ BOOL l_bRetVal = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // check if all files are persisted
+ if (FALSE == m_bAllFilePersisted) {
+ ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+
+ std::string l_cTagNotReleased = "";
+ std::string l_cTagList = ""; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ // Persist all i.e files and folders
+ while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
+ if (NULL != m_mPersist_Type[l_ePersistType]) {
+ l_cTagNotReleased.assign(""); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // if(eFrameworkunifiedStatusFail == m_mPersist_Type[l_ePersistType]->PersistAllReleaseRequests())
+ if (FALSE == m_mPersist_Type[l_ePersistType]->HaveAllReleaseRequestsPersisted(l_cTagNotReleased)) {
+ l_bRetVal = FALSE;
+ l_cTagList.append(l_cTagNotReleased);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+ }
+
+ if (0 != l_cTagList.size()) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Tags not released:: %s", l_cTagList.c_str());
+ }
+ }
+
+ if (TRUE == l_bRetVal) {
+ m_bAllFilePersisted = TRUE;
+
+ // if all files are persisted set the return value to the status of immediate data persistency
+ l_bRetVal = m_bImmediatedDataPersisted;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bRetVal;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ResetPersistFlag
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::ResetPersistFlag() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+
+ // Persist all i.e files and folders
+ while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
+ if (NULL != m_mPersist_Type[l_ePersistType]) {
+ m_mPersist_Type[l_ePersistType]->ResetPersistFlag();
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
+ }
+
+ m_bAllFilePersisted = FALSE;
+
+ m_bImmediatedDataPersisted = FALSE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceReadNorNotificationData
+/// Get the list of all user persistent notifications from a persistent memory and store it in a map.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceReadNorNotificationData(Persistent_Notification_List_Type
+ * &f_vpersistentnotificationlist) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedUserData)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate User data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedFactoryData)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate Factory data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedFactoryCustomerData)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate Factory Customer data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedDealerData)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate Dealer data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ClearPersistenceData
+/// Deletes the data from the persistent memory.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::ClearPersistenceData(const EFrameworkunifiedClearPersistence &f_enotificationpersistentserviceclearpersistencescope) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ // persistence memory path to be cleared
+ std::string l_cPath = "";
+
+ switch (f_enotificationpersistentserviceclearpersistencescope) { // LCOV_EXCL_BR_LINE 6: f_enotificationpersistentserviceclearpersistencescope must be eFrameworkunifiedClearAllData, eFrameworkunifiedClearAllApplicationData, eFrameworkunifiedClearAllNotificationData, eFrameworkunifiedClearCurrentUserData, eFrameworkunifiedClearCurrentUserApplicationData, eFrameworkunifiedClearCurrentUserNotificationData. // NOLINT[whitespace/line_length]
+ case eFrameworkunifiedClearAllData: {
+ // clears all the data from the persistent memory
+ l_cPath.append(CPersistence::GetStoragePath());
+ }
+ break;
+
+ case eFrameworkunifiedClearAllApplicationData: {
+ // TODO(my_username): clears all the application folder in persistence memory
+ // don't delete the NS_NPS folder
+ }
+ break;
+
+ case eFrameworkunifiedClearAllNotificationData: {
+ // TODO(my_username): deletes the NS_NPS folder
+ }
+ break;
+
+ case eFrameworkunifiedClearCurrentUserData: {
+ // TODO(my_username): deletes the user folder from all the application folder in persisted memory
+ // as well as from the NS_NPS folder
+ }
+ break;
+
+ case eFrameworkunifiedClearCurrentUserApplicationData: {
+ // TODO(my_username): deletes the user folder from all the application folder
+ }
+ break;
+
+ case eFrameworkunifiedClearCurrentUserNotificationData: {
+ // TODO(my_username): deletes the user folder from the NS_NPS folder
+ }
+ break;
+
+ default: {
+ // LCOV_EXCL_START 6: f_enotificationpersistentserviceclearpersistencescope must be eFrameworkunifiedClearAllData, eFrameworkunifiedClearAllApplicationData, eFrameworkunifiedClearAllNotificationData, eFrameworkunifiedClearCurrentUserData, eFrameworkunifiedClearCurrentUserApplicationData, eFrameworkunifiedClearCurrentUserNotificationData. // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid _EFrameworkunifiedClearPersistence Parameter:: %d", f_enotificationpersistentserviceclearpersistencescope);
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+ break;
+ }
+
+ if (0 != l_cPath.size()) {
+ if (CFSDirectory::DoesDirecotryExist(l_cPath)) {
+ if (TRUE == CFSDirectory::RemoveDirectory(l_cPath)) { // LCOV_EXCL_BR_LINE 6: RemoveDirectory always return ok
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete persistent directory successful : %s", l_cPath.c_str());
+ } else {
+ // LCOV_EXCL_START 6: RemoveDirectory always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete persistent directory unsuccessful : %s", l_cPath.c_str());
+ l_estatus = eFrameworkunifiedStatusErrOther;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ l_estatus = eFrameworkunifiedStatusErrOther;
+ }
+
+ // delete NOR data
+ l_cPath.clear();
+ l_cPath.append(IMMEDIATE_PERSISTENCE_STORAGE_V2);
+ if (0 != l_cPath.size()) { // LCOV_EXCL_BR_LINE 6: l_cPath.size can't be 0
+ if (CFSDirectory::DoesDirecotryExist(l_cPath)) {
+ if (TRUE == CFSDirectory::RemoveDirectory(l_cPath)) { // LCOV_EXCL_BR_LINE 6: RemoveDirectory always return ok
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete nor persistent directory successful : %s", l_cPath.c_str());
+ } else {
+ // LCOV_EXCL_START 6: RemoveDirectory always return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete nor persistent directory unsuccessful : %s", l_cPath.c_str());
+ l_estatus = eFrameworkunifiedStatusErrOther;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusErrOther; // LCOV_EXCL_LINE 6: l_cPath.size can't be 0
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSetPersistentCategory
+/// Sets the persist type of file or folder.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSetPersistentCategory(std::string f_crequestorname,
+ std::string f_ctag,
+ EFrameworkunifiedPersistCategory f_epersistcategory,
+ ENotificationpersistentservicePersistType f_epersisttype) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ if (f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_ctag.size can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Tag name is empty."); // LCOV_EXCL_LINE 6: double check, f_ctag.size can't be empty
+ } else {
+ // check boundary conditions
+ if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
+ // set the persist type
+ l_estatus = m_mPersist_Type[f_epersisttype]->SetPersistentCategory(f_crequestorname,
+ f_ctag,
+ f_epersistcategory);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// PersistNORData
+/// Sends the message to Immediate Persistence Thread to Persists the data immediately or reset
+/// the NOR data depending on persist category flag during shutdown irrespective of delay.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::PersistNORData(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ TImmediateShutdown l_tImmShutdown = {};
+ l_tImmShutdown.f_eshutdowntype = f_eshutdowntype;
+ l_tImmShutdown.f_uinotificationpersistentservicepersistcategoryflag = f_uinotificationpersistentservicepersistcategoryflag;
+
+ // send the message to NOR to persist or reset the data during shutdown
+ if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK != (l_estatus = McSend(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread, AppName, NOR_PERSISTENCE_ONSHUTDOWN, sizeof(l_tImmShutdown), &l_tImmShutdown))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend for cmd 0x%X failed", NOR_PERSISTENCE_ONSHUTDOWN); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetImmediateDataPersistedStatus
+/// Set/Reset the persistence status of immediate persistence data
+///////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::SetImmediateDataPersistedStatus(BOOL f_bstatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_bImmediatedDataPersisted = f_bstatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetFilePersistedStatus
+/// Set/Reset the persistence status of files and folders
+///////////////////////////////////////////////////////////////////////////////////////////
+VOID CPersistenceManager::SetFilePersistedStatus(BOOL f_bstatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_bAllFilePersisted = f_bstatus;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ReadImmediateNotificationData
+/// Get the list of all immediate persistent notifications of f_epersistcategory from a
+/// persistent memory and store it in a map.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CPersistenceManager::ReadImmediateNotificationData(Persistent_Notification_List_Type
+ * &f_vpersistentnotificationlist,
+ const EFrameworkunifiedPersistCategory f_epersistcategory) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string l_pcPath = IMMEDIATE_PERSISTENCE_STORAGE_V2;
+ std::string l_cNotificationName = ""; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ // stores the list of invalid immediate notification files at persistent location
+ std::string l_cInvalidFileList = ""; // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ PCSTR l_pPublisherName = NULL;
+ PSTR l_pData = NULL;
+ UI_32 l_uiDataSize = 0;
+
+ NC_NorPersistentData l_ptNorPersistentData = {};
+
+ TFileList l_pTFileList;
+
+ if ('/' != l_pcPath[l_pcPath.length() - 1]) { // LCOV_EXCL_BR_LINE 6: the last char is always '/'
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_pcPath.append("/"); // LCOV_EXCL_LINE 6: the last char is always '/'
+ }
+
+ switch (f_epersistcategory) {
+ case eFrameworkunifiedFactoryData: {
+ l_pcPath.append(FACTORYDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ break;
+
+ case eFrameworkunifiedFactoryCustomerData: {
+ l_pcPath.append(FACTORYCUSTOMERDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ break;
+
+ case eFrameworkunifiedDealerData: {
+ l_pcPath.append(DEALERDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ break;
+
+ case eFrameworkunifiedUserData:
+ default: {
+ l_pcPath.append(USERDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ l_pcPath.append(ALLUSERAPPDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ break;
+ }
+
+ l_pcPath.append(IMMEDIATEDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ if (eFrameworkunifiedStatusOK == GetFileList(&l_pTFileList, l_pcPath.c_str())) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ if (!l_pTFileList.empty()) { // LCOV_EXCL_BR_LINE 200: if GetFileList() returns eFrameworkunifiedStatusOK, l_pTFileList can't be empty // NOLINT[whitespace/line_length]
+ for (UI_32 l_uiCount = 0; l_uiCount < l_pTFileList.size(); l_uiCount++) {
+ l_uiDataSize = 0;
+
+ // get the persistent notification name from vector
+ l_cNotificationName = l_pTFileList.at(l_uiCount);
+
+ if (eFrameworkunifiedStatusOK == NPSynchronousGetPersistentDataSize(l_cNotificationName.c_str(), &l_uiDataSize, // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ f_epersistcategory) && (0 != l_uiDataSize)) {
+ l_pData = new(std::nothrow) CHAR[l_uiDataSize];
+ std::memset(l_pData, 0, l_uiDataSize);
+
+ if (NULL != l_pData) { // LCOV_EXCL_BR_LINE 6: l_pData can't be null
+ l_pPublisherName = NULL;
+
+ // clear the memory
+ std::memset(&l_ptNorPersistentData, 0, sizeof(NC_NorPersistentData));
+
+ // As NS_NPP does a recursive filename read from directory it has the complete filename.
+ // So it does not require to pass the Publisher name i.e. l_pPublisherName.So it is being passed as NULL.
+ if (eFrameworkunifiedStatusOK == NPSynchronousGetPersistentData(l_pPublisherName, // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
+ l_cNotificationName.c_str(),
+ (PVOID)l_pData,
+ l_uiDataSize,
+ l_ptNorPersistentData,
+ f_epersistcategory)) {
+ CNotificationsToPersist *l_objCNotificationsToPersist = new(std::nothrow) CNotificationsToPersist();
+ if (NULL != l_objCNotificationsToPersist) { // LCOV_EXCL_BR_LINE 6: l_objCNotificationsToPersist can't be null // NOLINT[whitespace/line_length]
+ CPersistentData *l_objCPersistentData = new(std::nothrow) CPersistentData();
+
+ // fill the appropriate values in l_objCNotificationsToPersist
+ if (NULL != l_objCPersistentData) { // LCOV_EXCL_BR_LINE 6: l_objCPersistentData can't be null
+ l_objCPersistentData->m_pMessage = new(std::nothrow) CHAR[l_ptNorPersistentData.dataSize];
+ std::memset(l_objCPersistentData->m_pMessage, 0, l_ptNorPersistentData.dataSize);
+
+ if (NULL != l_objCPersistentData->m_pMessage) { // LCOV_EXCL_BR_LINE 6: l_objCPersistentData->m_pMessage can't be null // NOLINT[whitespace/line_length]
+ std::memcpy(l_objCPersistentData->m_pMessage, l_pData, l_ptNorPersistentData.dataSize);
+
+ l_objCNotificationsToPersist->m_uiMaxMsgLength = l_ptNorPersistentData.uiMaxSize;
+ l_objCPersistentData->m_uiMsgSize = l_ptNorPersistentData.dataSize;
+ l_objCNotificationsToPersist->m_ePersistentType = eFrameworkunifiedImmediatePersistedStateVar;
+
+ l_objCNotificationsToPersist->m_cNotificationName = l_ptNorPersistentData.notificationName;
+ l_objCNotificationsToPersist->m_cPublisherName = l_ptNorPersistentData.pPublisherName;
+ l_objCNotificationsToPersist->m_uiDelay = l_ptNorPersistentData.uiDelay;
+
+ l_objCNotificationsToPersist->m_pPersistentData = l_objCPersistentData;
+
+ l_objCNotificationsToPersist->m_ePersistCategory = f_epersistcategory;
+
+ f_vpersistentnotificationlist->push_back(l_objCNotificationsToPersist);
+ } else {
+ // LCOV_EXCL_START 6: l_objCPersistentData->m_pMessage can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Memory allocation error for notification data of size %d",
+ l_ptNorPersistentData.dataSize);
+
+ if (NULL != l_objCNotificationsToPersist) {
+ delete l_objCNotificationsToPersist;
+ l_objCNotificationsToPersist = NULL;
+ }
+
+ if (NULL != l_objCPersistentData) {
+ delete l_objCPersistentData;
+ l_objCPersistentData = NULL;
+ }
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_objCPersistentData can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Memory allocation error for CPersistentData object");
+
+ if (NULL != l_objCNotificationsToPersist) {
+ delete l_objCNotificationsToPersist;
+ l_objCNotificationsToPersist = NULL;
+ }
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Memory allocation error for CNotificationsToPersist object"); // LCOV_EXCL_LINE 6: l_objCNotificationsToPersist can't be null // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_cInvalidFileList.append(l_cNotificationName);
+ l_cInvalidFileList.append(",");
+ // LCOV_EXCL_STOP
+ }
+
+ delete[] l_pData;
+ l_pData = NULL;
+ } else {
+ // LCOV_EXCL_START 6: l_pData can't be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Persistent data received as NULL from immediate notification file :: %s",
+ l_cNotificationName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_cInvalidFileList.append(l_cNotificationName);
+ l_cInvalidFileList.append(",");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (0 != l_cInvalidFileList.size()) { // LCOV_EXCL_START 200: l_cInvalidFileList's size must be 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Unable to get persistent data for following immediate notification files :: %s",
+ l_cInvalidFileList.c_str());
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "No Immediate persistence data available at :: %s", l_pcPath.c_str()); // LCOV_EXCL_LINE 200: if GetFileList() returns eFrameworkunifiedStatusOK, l_pTFileList can't be empty // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to get the list of files from Immediate persistent location :: %s",
+ l_pcPath.c_str());
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+#ifdef NPP_PROFILEINFO_ENABLE
+
+EFrameworkunifiedStatus CPersistenceManager::GetPersistenceProfilingData(std::string &f_cpersistenceprofileinfo) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ f_cpersistenceprofileinfo.append("Application Name,");
+ f_cpersistenceprofileinfo.append("Tag Name,");
+ f_cpersistenceprofileinfo.append("Type,");
+ f_cpersistenceprofileinfo.append("UserSpecific,");
+ f_cpersistenceprofileinfo.append("Released,");
+ f_cpersistenceprofileinfo.append("Persisted");
+
+ CPersistence *l_pPersistence = m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE];
+ l_pPersistence->GetPersistenceProfilingData(f_cpersistenceprofileinfo);
+
+ l_pPersistence = m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER];
+ l_pPersistence->GetPersistenceProfilingData(f_cpersistenceprofileinfo);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+#endif
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_persistent_data.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_persistent_data.cpp
new file mode 100644
index 00000000..8a9127ef
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_persistent_data.cpp
@@ -0,0 +1,58 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CPersistentData.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include "ns_npp_persistent_data.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// CPersistentData
+/// Constructor of CPersistentData class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CPersistentData::CPersistentData() {
+ m_pMessage = NULL;
+ m_uiMsgSize = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CPersistentData
+/// Destructor of CPersistentData class
+////////////////////////////////////////////////////////////////////////////////////////////////
+CPersistentData::~CPersistentData() {
+ if (NULL != m_pMessage) {
+ delete[](static_cast<PCHAR>(m_pMessage)); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ m_pMessage = NULL;
+ }
+}
+
+
+
+
+
+
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_personalization_manager.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_personalization_manager.cpp
new file mode 100644
index 00000000..43714653
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_personalization_manager.cpp
@@ -0,0 +1,181 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CnotificationpersistentservicePersonalizationManager.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <utility>
+#include <string>
+#ifdef AGL_STUB
+#include "ns_npp_personalization_manager.h"
+#else
+#include "ns_npp_Personalization_manager.h"
+#endif
+#include "ns_npp_notificationpersistentservicelog.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CnotificationpersistentservicePersonalizationManager
+/// Constructor of CnotificationpersistentservicePersonalizationManager class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CnotificationpersistentservicePersonalizationManager::CnotificationpersistentservicePersonalizationManager() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_uiUserId = 0;
+
+ m_cCurrentPersonality.clear();
+
+ m_pmPersonality = new(std::nothrow) Personality_Type(); // LCOV_EXCL_BR_LINE 11: except,C++ STL
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CnotificationpersistentservicePersonalizationManager
+/// Destructor of CnotificationpersistentservicePersonalizationManager class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CnotificationpersistentservicePersonalizationManager::~CnotificationpersistentservicePersonalizationManager() { // LCOV_EXCL_START 14: Resident process, global instance not released // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pmPersonality) {
+ m_pmPersonality->clear();
+
+ delete m_pmPersonality;
+ m_pmPersonality = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceGetPersonality
+/// This function is used to get the current personality.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CnotificationpersistentservicePersonalizationManager::NotificationpersistentserviceGetPersonality(std::string &f_cpersonalityname) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ f_cpersonalityname = m_cCurrentPersonality;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceSetPersonality
+/// This function is used to set the new personality.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CnotificationpersistentservicePersonalizationManager::NotificationpersistentserviceSetPersonality(const std::string f_cpersonalityname) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // iterator to find personality name from map of personality
+ Personality_Type::iterator l_itPersonality;
+
+ if (!f_cpersonalityname.empty()) {
+ if (NULL != m_pmPersonality) { // LCOV_EXCL_BR_LINE 6: double check, m_pmPersonality can't be NULL
+ l_itPersonality = m_pmPersonality->find(f_cpersonalityname);
+
+ // if personality found in map
+ if (m_pmPersonality->end() != l_itPersonality) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Personality found in map");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Personality not found in map");
+
+ l_estatus = CreatePersonality(f_cpersonalityname);
+ }
+
+ m_cCurrentPersonality = f_cpersonalityname;
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map object is NULL"); // LCOV_EXCL_LINE 6: m_pmPersonality can't be NULL
+ }
+ } else {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreatePersonality
+/// This function is used to create new Personality.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CnotificationpersistentservicePersonalizationManager::CreatePersonality(const std::string &f_cpersonalityname) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pmPersonality) { // LCOV_EXCL_BR_LINE 6: m_pmPersonality can't be NULL
+ CNotificationpersistentservicePersonality *l_pPersonality = new(std::nothrow) CNotificationpersistentservicePersonality(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+
+ if (NULL != l_pPersonality) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
+ l_pPersonality->m_uiUserId = ++m_uiUserId;
+ l_pPersonality->m_cUserName = f_cpersonalityname;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Inserting new personality in map"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ m_pmPersonality->insert(make_pair(f_cpersonalityname, l_pPersonality));
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map object is NULL"); // LCOV_EXCL_LINE 6: m_pmPersonality can't be NULL
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// NotificationpersistentserviceIsValidPersonality
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CnotificationpersistentservicePersonalizationManager::NotificationpersistentserviceIsValidPersonality(const std::string f_cpersonalityname) {
+ BOOL l_bReturnValue = FALSE;
+ // iterator to find personality name from map of personality
+ Personality_Type::iterator l_itPersonality;
+ if (NULL != m_pmPersonality) { // LCOV_EXCL_BR_LINE 6: m_pmPersonality can't be NULL
+ l_itPersonality = m_pmPersonality->find(f_cpersonalityname);
+
+ // if personality found in map
+ if (m_pmPersonality->end() != l_itPersonality) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Personality found in map");
+ l_bReturnValue = TRUE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Personality not found in map");
+ }
+ } else {
+ // LCOV_EXCL_START 6: m_pmPersonality can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map object is NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ return l_bReturnValue;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_registry_entry.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_registry_entry.cpp
new file mode 100644
index 00000000..dc745808
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_registry_entry.cpp
@@ -0,0 +1,333 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NPPService
+/// \brief The file contains declaration of CRegistryEntry class.
+///
+///
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_registry_entry.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Constructor
+////////////////////////////////////////////////////////////////////////////////////////////
+CRegistryEntry::CRegistryEntry(const std::string &f_ctag, const std::string &f_crequester,
+ const std::string &f_cstoragepath,
+ const BOOL f_bisuserpersistence):
+ m_eJobState(ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE),
+ m_cTag(f_ctag),
+ m_cRequestor(f_crequester),
+ m_bIsReleased(FALSE),
+ m_bIsPersisted(FALSE),
+ m_bIsUserPersistence(f_bisuserpersistence),
+ m_eCurrentAction(LOADTYPE_NONE),
+ m_ePersistType(ENOTIFICATIONPERSISTENTSERVICEPERSISTNONE),
+ m_ePersistCategory(eFrameworkunifiedUserData) {
+ m_cBasePath.clear();
+
+ // set base path.
+ m_cBasePath += f_cstoragepath;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Copy Constructor
+////////////////////////////////////////////////////////////////////////////////////////////
+CRegistryEntry::CRegistryEntry(const CRegistryEntry &in):
+ m_eJobState(ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE),
+ m_cTag(in.m_cTag),
+ m_cRequestor(in.m_cRequestor),
+ m_bIsReleased(in.m_bIsReleased),
+ m_bIsPersisted(in.m_bIsPersisted),
+ m_cPersistPath(in.m_cPersistPath),
+ m_cBasePath(in.m_cBasePath),
+ m_bIsUserPersistence(in.m_bIsUserPersistence),
+ m_eCurrentAction(in.m_eCurrentAction),
+ m_ePersistType(in.m_ePersistType),
+ m_ePersistCategory(in.m_ePersistCategory) {
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// Operator overload
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+CRegistryEntry &CRegistryEntry::operator=(const CRegistryEntry &in) { // LCOV_EXCL_START 8: never be used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this != &in) {
+ m_eJobState = in.m_eJobState;
+ m_cTag = in.m_cTag;
+ m_cRequestor = in.m_cRequestor;
+ m_bIsReleased = in.m_bIsReleased;
+ m_bIsPersisted = in.m_bIsPersisted;
+ m_cPersistPath = in.m_cPersistPath;
+ m_cBasePath = in.m_cBasePath;
+ m_bIsUserPersistence = in.m_bIsUserPersistence;
+ m_ePersistType = in.m_ePersistType;
+ }
+ return *this;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetReleasePath
+/// Set release path.
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CRegistryEntry::SetReleasePath(const std::string &f_creleasepath) {
+ m_bIsReleased = TRUE;
+ m_cReleasePath = f_creleasepath;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetBeingPersisted
+/// Set the file/folder is being persisted.
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CRegistryEntry::SetBeingPersisted() {
+ if (LOADTYPE_RELEASE == m_eCurrentAction) {
+ m_bIsPersisted = TRUE;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsReleased
+/// File/folder released or not.
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CRegistryEntry::IsReleased() const {
+ return m_bIsReleased;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// HasntBeenPersisted
+/// File/Folder persisted or not
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CRegistryEntry::HasntBeenPersisted() const {
+ return !m_bIsPersisted;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsPersisted
+/// File persisted or not
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CRegistryEntry::IsPersisted() const {
+ return m_bIsPersisted;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistPath
+/// Get the persist path.
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string CRegistryEntry::GetPersistPath() const {
+ return m_cPersistPath;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetReleasePath
+/// Get the release path.
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string CRegistryEntry::GetReleasePath() const {
+ return m_cReleasePath;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetLoadPath
+/// Get the load path.
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string CRegistryEntry::GetLoadPath(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername) const {
+ std::string l_cLoadPath = "";
+
+ if (f_epersisttype > ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST && f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be in range. // NOLINT[whitespace/line_length]
+ l_cLoadPath = m_cBasePath;
+
+ switch (m_ePersistCategory) {
+ case eFrameworkunifiedUserData: {
+ l_cLoadPath += USERDATADIR;
+
+ // Check if to persist for user
+ if (m_bIsUserPersistence) {
+ // if its a user file, user name can't be empty
+ if (!f_cusername.empty()) { // LCOV_EXCL_BR_LINE 6: f_cusername can't be empty
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Tag %s is registered for user %s", m_cTag.c_str(), f_cusername.c_str());
+ l_cLoadPath += f_cusername;
+ l_cLoadPath += "/";
+ }
+ } else {
+ l_cLoadPath += ALLUSERAPPDATADIR;
+ }
+
+ break;
+ }
+ case eFrameworkunifiedFactoryData: {
+ l_cLoadPath += FACTORYDATADIR;
+ break;
+ }
+ case eFrameworkunifiedFactoryCustomerData: {
+ l_cLoadPath += FACTORYCUSTOMERDATADIR;
+ break;
+ }
+ case eFrameworkunifiedDealerData: {
+ l_cLoadPath += DEALERDATADIR;
+ break;
+ }
+ }
+
+ l_cLoadPath += m_cRequestor;
+ l_cLoadPath += "/";
+
+ // file and folder persistency has different storage paths mapped
+ if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == f_epersisttype) {
+ l_cLoadPath += "NSFile/";
+ } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == f_epersisttype) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE or ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER. // NOLINT[whitespace/line_length]
+ l_cLoadPath += "NSFolder/";
+ }
+
+ l_cLoadPath += m_cTag;
+ }
+
+ return l_cLoadPath;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetRequester
+/// Get the name of requester.
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string CRegistryEntry::GetRequester() const {
+ return m_cRequestor;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetTag
+/// Get the tag.
+////////////////////////////////////////////////////////////////////////////////////////////
+std::string CRegistryEntry::GetTag() const {
+ return m_cTag;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// IsUserPersistence
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CRegistryEntry::IsUserPersistence() {
+ return m_bIsUserPersistence;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetCurrentAction
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CRegistryEntry::SetCurrentAction(ENPS_Loadtype f_ecurrentaction) {
+ m_eCurrentAction = f_ecurrentaction;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// ResetPersistedFlag
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CRegistryEntry::ResetPersistedFlag() {
+ m_bIsPersisted = FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersistProperties
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+VOID CRegistryEntry::SetPersistProperties(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername) {
+ if (f_epersisttype > ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST && f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be in range. // NOLINT[whitespace/line_length]
+ // set the persist type
+ m_ePersistType = f_epersisttype;
+
+ // set the persist file based on the persist type and username (if a user file)
+ m_cPersistPath = m_cBasePath;
+
+ switch (m_ePersistCategory) {
+ case eFrameworkunifiedUserData: {
+ m_cPersistPath += USERDATADIR;
+
+ // Check if to persist for user
+ if (m_bIsUserPersistence) {
+ // if its a user file, user name can't be empty
+ if (!f_cusername.empty()) { // LCOV_EXCL_BR_LINE 6: f_cusername can't be empty
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Tag %s is registered for user %s", m_cTag.c_str(), f_cusername.c_str());
+ m_cPersistPath += f_cusername;
+ m_cPersistPath += "/";
+ }
+ } else {
+ m_cPersistPath += ALLUSERAPPDATADIR;
+ }
+
+ break;
+ }
+ case eFrameworkunifiedFactoryData: {
+ m_cPersistPath += FACTORYDATADIR;
+ break;
+ }
+ case eFrameworkunifiedFactoryCustomerData: {
+ m_cPersistPath += FACTORYCUSTOMERDATADIR;
+ break;
+ }
+ case eFrameworkunifiedDealerData: {
+ m_cPersistPath += DEALERDATADIR;
+ break;
+ }
+ }
+
+ m_cPersistPath += m_cRequestor;
+ m_cPersistPath += "/";
+
+ // file and folder persistency has different storage paths mapped
+ if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == f_epersisttype) {
+ m_cPersistPath += "NSFile/";
+ } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == f_epersisttype) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE or ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER. // NOLINT[whitespace/line_length]
+ m_cPersistPath += "NSFolder/";
+ }
+
+ m_cPersistPath += m_cTag;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistType
+///
+////////////////////////////////////////////////////////////////////////////////////////////
+ENotificationpersistentservicePersistType CRegistryEntry::GetPersistType() const {
+ return m_ePersistType;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersistentCategory
+/// Sets the persistent type related to tag
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CRegistryEntry::SetPersistentCategory(EFrameworkunifiedPersistCategory f_epersistcategory) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+
+ m_ePersistCategory = f_epersistcategory;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistentCategory
+/// Gets the persistent type of a tag
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedPersistCategory CRegistryEntry::GetPersistentCategory() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return m_ePersistCategory;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_regular_notification.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_regular_notification.cpp
new file mode 100644
index 00000000..6d75091e
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_regular_notification.cpp
@@ -0,0 +1,158 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CRegularNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/ns_message_center_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <mqueue.h>
+#include <iostream>
+#include <string>
+#include <native_service/ns_mc_system_info.h>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_regular_notification.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CRegularNotification
+/// Constructor of CRegularNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CRegularNotification::CRegularNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize):
+ CNotification(f_cnotificationname, f_uimaxmsgsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_ePersistentType = eFrameworkunifiedNotificationVar;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CRegularNotification
+/// Destructor of CRegularNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CRegularNotification::~CRegularNotification() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddEventReciever
+/// This function adds the name of the application to receiver list of particular notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CRegularNotification::AddEventReciever(const std::string &f_csubscribername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (!f_csubscribername.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_csubscribername can't be empty
+ l_estatus = AddReceiverInMap(f_csubscribername);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_csubscribername can't be empty
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Publish
+/// This function publishes the notification to subscribed clients.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CRegularNotification::Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Message Queue Handle
+ HANDLE l_hMsgQHandle = NULL;
+
+ // Pointer to class CNotificationReceiver
+ CNotificationReceiver *l_pNotificationReceiver = NULL;
+
+ // Iterator for Notification Receiver map
+ NotifReceiver_Iterator_Type l_itrNotifReceiver;
+
+ if (m_uiMaxMsgSize >= f_uimsgsize) {
+ if (0 == m_cServiceName.compare(f_cservicename)) {
+ for (l_itrNotifReceiver = m_pmSubscribersList->begin();
+ l_itrNotifReceiver != m_pmSubscribersList->end();
+ l_itrNotifReceiver++) {
+ l_pNotificationReceiver = l_itrNotifReceiver->second;
+
+ if (NULL != l_pNotificationReceiver) { // LCOV_EXCL_BR_LINE 6: l_pNotificationReceiver can't be NULL
+ l_hMsgQHandle = l_pNotificationReceiver->m_MsgQHandle;
+
+ if (NULL != l_hMsgQHandle) { // LCOV_EXCL_BR_LINE 6: l_hMsgQHandle can't be NULL
+ if (eFrameworkunifiedStatusOK != (l_estatus = PublishData(l_hMsgQHandle, f_pmessage, f_uimsgsize))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error Publishing notification %s to %s published by %s, error status: 0x%x",
+ m_cNotificationName.c_str(), l_itrNotifReceiver->first.c_str(), f_cservicename.c_str(), l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_hMsgQHandle can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgQ Handle NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: l_pNotificationReceiver can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationReceiver is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't publish notification %s. Registered by %s and published by %s.",
+ m_cNotificationName.c_str(), m_cServiceName.c_str(), f_cservicename.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in "native_service/ns_logger_if.h"
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't publish notification %s. Message data size (%d) is greater than maximum registered data size (%d)",
+ m_cNotificationName.c_str(), f_uimsgsize, m_uiMaxMsgSize);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_state_nor_persistence_notification.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_state_nor_persistence_notification.cpp
new file mode 100644
index 00000000..7898f38e
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_state_nor_persistence_notification.cpp
@@ -0,0 +1,305 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CStateNorPersistenceNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <errno.h>
+#include <native_service/ns_message_center_if.h>
+#include <string>
+#include <iostream>
+
+#include "ns_npp_types.h"
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_state_nor_persistence_notification.h"
+
+HANDLE CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread = NULL;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CStateNorPersistenceNotification
+/// Constructor of CStateNorPersistenceNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStateNorPersistenceNotification::CStateNorPersistenceNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize,
+ const UI_32 f_uidelay,
+ const EFrameworkunifiedPersistCategory f_epersistcategory):
+ CStateNotification(f_cnotificationname, f_uimaxmsgsize),
+ m_uiDelay(f_uidelay),
+ m_ePersistCategory(f_epersistcategory) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_ePersistentType = eFrameworkunifiedImmediatePersistedStateVar;
+
+ // also, register the notification with worker thread responsible for writing notification data
+ if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 6: CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread can not be null // NOLINT[whitespace/line_length]
+ TImmediatePersistenceRegisterNotifInfo l_tRegisterNotifInfo = {};
+ std::strncpy(l_tRegisterNotifInfo.m_cnotificationname,
+ f_cnotificationname.c_str(),
+ sizeof(l_tRegisterNotifInfo.m_cnotificationname) - 1);
+ l_tRegisterNotifInfo.m_uidelay = f_uidelay;
+ l_tRegisterNotifInfo.m_epersistcategory = f_epersistcategory;
+
+ if (eFrameworkunifiedStatusOK != McSend(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread, AppName, NOR_PERSISTENCE_REGISTER, sizeof(l_tRegisterNotifInfo), &l_tRegisterNotifInfo)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend for cmd 0x%X failed", NOR_PERSISTENCE_REGISTER); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CStateNorPersistenceNotification
+/// Constructor of CStateNorPersistenceNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStateNorPersistenceNotification::~CStateNorPersistenceNotification() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // also, unregister the notification with worker thread responsible for writing notification data
+ if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 6: CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread can not be null // NOLINT[whitespace/line_length]
+ TImmediatePersistenceUnregisterNotifInfo l_tUnregisterNotifInfo = {};
+ std::strncpy(l_tUnregisterNotifInfo.m_cnotificationname,
+ GetNotificationName().c_str(), // LCOV_EXCL_BR_LINE 11: except,C++ STL
+ sizeof(l_tUnregisterNotifInfo.m_cnotificationname) - 1);
+
+ if (eFrameworkunifiedStatusOK != McSend(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread, AppName, NOR_PERSISTENCE_UNREGISTER, sizeof(l_tUnregisterNotifInfo), &l_tUnregisterNotifInfo)) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend for cmd 0x%X failed", NOR_PERSISTENCE_UNREGISTER); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistenceDelay
+/// Method to get the persistence time delay.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+UI_32 CStateNorPersistenceNotification::GetPersistenceDelay() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return m_uiDelay;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Publish
+/// This function publishes the notification to subscribed clients and saves the data
+/// immediately to persistent memory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNorPersistenceNotification::Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (eFrameworkunifiedStatusOK == (l_estatus = PublishNotification(f_cservicename,
+ f_pmessage,
+ f_uimsgsize))) {
+ if (eFrameworkunifiedStatusOK != (l_estatus = SaveDataToNor(f_pmessage, f_uimsgsize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in saving persistent data on nor for %s published by %s, status: %d",
+ m_cNotificationName.c_str(), f_cservicename.c_str(), l_estatus); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// PublishNotification
+/// This function publishes the notification to subscribed clients.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNorPersistenceNotification::PublishNotification(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ l_estatus = CStateNotification::Publish(f_cservicename, f_pmessage, f_uimsgsize);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SaveDataToNor
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNorPersistenceNotification::SaveDataToNor(PVOID f_pmessage, const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != f_pmessage && f_uimsgsize > 0) {
+ TNorPersistenceNotifInfoHeader l_tNorPersistentData = {};
+ UI_32 l_ui32SendDataTotalLength = static_cast<UI_32>(sizeof(TNorPersistenceNotifInfoHeader) + f_uimsgsize);
+ UI_8 *l_ui8SendData = new(std::nothrow) UI_8[l_ui32SendDataTotalLength];
+ UI_8 *l_ui8TmpOffset = l_ui8SendData;
+
+ if (NULL != l_ui8SendData) { // LCOV_EXCL_BR_LINE 6: l_ui8SendData can't be NULL
+ std::strncpy(l_tNorPersistentData.m_cnotificationname,
+ this->GetNotificationName().c_str(),
+ sizeof(l_tNorPersistentData.m_cnotificationname) - 1);
+ std::strncpy(l_tNorPersistentData.m_cpublishername,
+ this->GetPublisherName().c_str(),
+ sizeof(l_tNorPersistentData.m_cpublishername) - 1);
+ l_tNorPersistentData.m_epersistenttype = this->GetNotificationType();
+ l_tNorPersistentData.m_uimaxmsglength = this->GetMaxMessageSize();
+ l_tNorPersistentData.m_uidelay = this->GetPersistenceDelay();
+ l_tNorPersistentData.m_uimsgsize = f_uimsgsize;
+ l_tNorPersistentData.m_epersistcategory = m_ePersistCategory;
+
+ std::memset(l_ui8SendData, 0, l_ui32SendDataTotalLength);
+ std::memcpy(l_ui8SendData, &l_tNorPersistentData, sizeof(l_tNorPersistentData));
+ l_ui8TmpOffset += sizeof(l_tNorPersistentData);
+ std::memcpy(l_ui8TmpOffset, f_pmessage, f_uimsgsize);
+
+ // issue a copy to the worker thread
+ if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 6: CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread can not be null // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK != (l_estatus = McSend(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread, AppName, NOR_PERSISTENCE_TIMER_START, l_ui32SendDataTotalLength, l_ui8SendData))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend for nor worker thread failed %d ", l_estatus); // LCOV_EXCL_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ }
+ } else {
+ // LCOV_EXCL_START 6: CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Sender handle of nor worker thread is NULL. Can't send message.");
+ // LCOV_EXCL_STOP
+ }
+
+ delete[] l_ui8SendData; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ l_ui8SendData = NULL;
+ } else {
+ // LCOV_EXCL_START 6: l_ui8SendData can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification data is NULL, size is %d", f_uimsgsize); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistentCategory
+/// Gets the persist type of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedPersistCategory CStateNorPersistenceNotification::GetPersistentCategory() { // LCOV_EXCL_START 100: never be used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return m_ePersistCategory;
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersistentCategory
+/// Sets the persist type of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNorPersistenceNotification::SetPersistentCategory(const EFrameworkunifiedPersistCategory f_epersistcategory) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (f_epersistcategory != m_ePersistCategory) {
+ if (NULL != m_pData && NULL != m_pData->m_pMessage) { // LCOV_EXCL_BR_LINE 6: if m_pData is not null, the m_pData->m_pMessage can not be null // NOLINT[whitespace/line_length]
+ if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 6: CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread can not be null // NOLINT[whitespace/line_length]
+ TImmediatePersistenceChangeCategory l_tChangeCategory = {};
+ UI_32 l_ui32SendDataTotalLength =
+ static_cast<UI_32>(sizeof(TImmediatePersistenceChangeCategory) + m_pData->m_uiMsgSize);
+ UI_8 *l_ui8SendData = new(std::nothrow) UI_8[l_ui32SendDataTotalLength];
+ UI_8 *l_ui8TmpOffset = l_ui8SendData;
+
+ if (NULL != l_ui8SendData) { // LCOV_EXCL_BR_LINE 6: l_ui8SendData can't be NULL
+ std::strncpy(l_tChangeCategory.m_tnornotifInfoheader.m_cnotificationname, this->GetNotificationName().c_str(),
+ sizeof(l_tChangeCategory.m_tnornotifInfoheader.m_cnotificationname) - 1);
+ std::strncpy(l_tChangeCategory.m_tnornotifInfoheader.m_cpublishername, this->GetPublisherName().c_str(),
+ sizeof(l_tChangeCategory.m_tnornotifInfoheader.m_cpublishername) - 1);
+ l_tChangeCategory.m_tnornotifInfoheader.m_epersistenttype = this->GetNotificationType();
+ l_tChangeCategory.m_tnornotifInfoheader.m_uimaxmsglength = this->GetMaxMessageSize();
+ l_tChangeCategory.m_tnornotifInfoheader.m_uidelay = this->GetPersistenceDelay();
+ l_tChangeCategory.m_tnornotifInfoheader.m_uimsgsize = m_pData->m_uiMsgSize;
+ l_tChangeCategory.m_tnornotifInfoheader.m_epersistcategory = f_epersistcategory;
+
+ l_tChangeCategory.m_eoldpersistcategory = m_ePersistCategory;
+
+ std::memset(l_ui8SendData, 0, l_ui32SendDataTotalLength);
+ std::memcpy(l_ui8SendData, &l_tChangeCategory, sizeof(l_tChangeCategory));
+ l_ui8TmpOffset += sizeof(l_tChangeCategory);
+ std::memcpy(l_ui8TmpOffset, m_pData->m_pMessage, m_pData->m_uiMsgSize);
+
+ // issue a copy to the worker thread
+ if (eFrameworkunifiedStatusOK != (l_estatus = McSend(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread, // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ AppName,
+ NOR_PERSISTENCE_CHANGE_CATEGORY,
+ l_ui32SendDataTotalLength,
+ l_ui8SendData))) {
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "McSend failed while changing category for notfn %s from %d to %d, status=%d",
+ m_cNotificationName.c_str(), m_ePersistCategory, f_epersistcategory, l_estatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__,
+ "Msg sent to immediate pers. thread to change persist category of %s from %d to %d",
+ m_cNotificationName.c_str(), m_ePersistCategory, f_epersistcategory);
+ }
+
+ delete[] l_ui8SendData;
+ l_ui8SendData = NULL;
+ } else {
+ // LCOV_EXCL_START 6: l_ui8SendData can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory alloc error for l_ui8SendData, errno=%d", errno);
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Sender handle of nor worker thread is NULL. Can't send message.");
+ l_estatus = eFrameworkunifiedStatusInvldHandle;
+ // LCOV_EXCL_STOP
+ }
+ } else { // no data is persisted in emmc for this notfn, so no need to send msg to worker thread
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notfn %s has no data to persist", m_cNotificationName.c_str());
+ }
+
+ m_ePersistCategory = f_epersistcategory;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_state_notification.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_state_notification.cpp
new file mode 100644
index 00000000..ff8f054f
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_state_notification.cpp
@@ -0,0 +1,402 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CStateNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <string>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_persistent_data.h"
+#include "ns_npp_state_notification.h"
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CStateNotification
+/// Constructor of CStateNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStateNotification::CStateNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize):
+ CNotification(f_cnotificationname, f_uimaxmsgsize),
+ m_pData(NULL),
+ m_pDefaultData(NULL),
+ m_bWasPublished(FALSE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_ePersistentType = eFrameworkunifiedStateVar;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CStateNotification
+/// Destructor of CStateNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStateNotification::~CStateNotification() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != m_pData) {
+ delete m_pData; // LCOV_EXCL_BR_LINE 11: unexpected branch
+ m_pData = NULL;
+ }
+
+ if (NULL != m_pDefaultData) {
+ delete m_pDefaultData;
+ m_pDefaultData = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistentData
+/// This function is used to get the persistent data pointer
+////////////////////////////////////////////////////////////////////////////////////////////////////
+const CPersistentData *CStateNotification::GetPersistentData() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return m_pData;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersistentData
+/// This function is used to set the data related to notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNotification::SetPersistentData(PVOID f_pmessage,
+ const UI_32 f_msgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL == m_pData) {
+ m_pData = new(std::nothrow) CPersistentData(); // LCOV_EXCL_BR_LINE 11: unexpected branch
+ }
+
+ l_estatus = SetData(m_pData, f_pmessage, f_msgsize);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetDefaultPersistentData
+/// This function get the default data(if any) related to notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+const CPersistentData *CStateNotification::GetDefaultPersistentData() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return m_pDefaultData;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetDefaultPersistentData
+/// This function is used to set the default data related to notification
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNotification::SetDefaultPersistentData(PVOID f_pmessage,
+ const UI_32 f_msgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL == m_pDefaultData) {
+ m_pDefaultData = new(std::nothrow) CPersistentData(); // LCOV_EXCL_BR_LINE 11: except,C++ STL
+ }
+
+ // set the default persistent data
+ if (eFrameworkunifiedStatusOK == (l_estatus = SetData(m_pDefaultData, f_pmessage, f_msgsize))) {
+ if (NULL == m_pData) {
+ // set the default data as persistent data if notification is not yet published
+ l_estatus = SetPersistentData(f_pmessage, f_msgsize);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Setting Persistent data");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistent data already set");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error setting default persistent data for notification:: %s",
+ m_cNotificationName.c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetData
+/// This function is used to set the persistent data
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNotification::SetData(CPersistentData *f_pdata,
+ PVOID f_pmessage,
+ const UI_32 f_msgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (NULL != f_pdata) { // LCOV_EXCL_BR_LINE 6: double check, f_pdata can't be NULL
+ if (m_uiMaxMsgSize >= f_msgsize) {
+ f_pdata->m_uiMsgSize = f_msgsize;
+
+ if (NULL != f_pmessage && 0 != f_msgsize) {
+ if (NULL == f_pdata->m_pMessage) {
+ f_pdata->m_pMessage = new(std::nothrow) CHAR[m_uiMaxMsgSize];
+ }
+
+ if (NULL != f_pdata->m_pMessage) { // LCOV_EXCL_BR_LINE 5: new error case
+ std::memset(f_pdata->m_pMessage, 0, m_uiMaxMsgSize);
+ std::memcpy(f_pdata->m_pMessage, f_pmessage, f_msgsize);
+ } else {
+ // LCOV_EXCL_START 5: new error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation error, unable to set persistent data for notification: %s",
+ m_cNotificationName.c_str());
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ if (NULL != f_pdata->m_pMessage) {
+ delete[](static_cast<PCHAR>(f_pdata->m_pMessage));
+ f_pdata->m_pMessage = NULL;
+ }
+ }
+
+ m_bWasPublished = TRUE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't set notification data. Message data size (%d) is greater than maximum registered data size (%d)"
+ " of notification (%s).", f_msgsize, m_uiMaxMsgSize, GetNotificationName().c_str());
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, f_pdata can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to set persistent data for notification: %s, persistent object is NULL",
+ m_cNotificationName.c_str());
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// AddEventReciever
+/// This function adds the name of the application to receiver list of particular notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNotification::AddEventReciever(const std::string &f_csubscribername) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Message Queue Handle
+ HANDLE l_hMsgQHandle = NULL;
+
+ // iterator of CNotificationReceiver map
+ NotifReceiver_Iterator_Type l_iterator;
+
+ CNotificationReceiver *l_pNotificationReceiver = NULL;
+
+ if (!f_csubscribername.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_csubscribername can't be empty
+ l_estatus = AddReceiverInMap(f_csubscribername);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: double check, f_csubscribername can't be empty
+ }
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: double check, l_estatus must be eFrameworkunifiedStatusOK
+ if (m_bWasPublished) {
+ FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Republish Notification to subscriber :: %s", f_csubscribername.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
+
+ if (NULL != m_pData) {
+ l_iterator = m_pmSubscribersList->find(f_csubscribername);
+
+ if (m_pmSubscribersList->end() != l_iterator) {
+ l_pNotificationReceiver = (*l_iterator).second;
+
+ if (NULL != l_pNotificationReceiver) { // LCOV_EXCL_BR_LINE 6: double check, l_pNotificationReceiver can't be NULL // NOLINT[whitespace/line_length]
+ l_hMsgQHandle = l_pNotificationReceiver->m_MsgQHandle;
+
+ if (NULL != l_hMsgQHandle) { // LCOV_EXCL_BR_LINE 6: double check, l_hMsgQHandle can't be NULL
+ if (eFrameworkunifiedStatusOK != (l_estatus = PublishData(l_pNotificationReceiver->m_MsgQHandle, m_pData->m_pMessage, m_pData->m_uiMsgSize))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error Publishing notification %s to %s published by %s, error status: 0x%x",
+ m_cNotificationName.c_str(), l_iterator->first.c_str(), m_cServiceName.c_str(), l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_hMsgQHandle can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgQ Handle NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pNotificationReceiver can't be NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationReceiver is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_pData pointer is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Subscribing Notfn, src=%s name=%s. Notification not published.",
+ f_csubscribername.c_str(), m_cNotificationName.c_str());
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_estatus must be eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_estatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Receiver Not Added in map");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// Publish
+/// This function publishes the notification to subscribed clients.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNotification::Publish(const std::string &f_cservicename,
+ PVOID f_pmessage,
+ const UI_32 f_uimsgsize) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Message Queue Handle
+ HANDLE l_hMsgQHandle = NULL;
+
+ // Pointer to class CNotificationReceiver
+ CNotificationReceiver *l_pNotificationReceiver = NULL;
+
+ // Iterator for Notification Receiver map
+ NotifReceiver_Iterator_Type l_itrNotifReceiver;
+
+ if (m_uiMaxMsgSize >= f_uimsgsize) {
+ if (0 == m_cServiceName.compare(f_cservicename)) {
+ l_estatus = SetPersistentData(f_pmessage,
+ f_uimsgsize);
+
+ if (eFrameworkunifiedStatusOK == l_estatus) { // LCOV_EXCL_BR_LINE 6: l_estatus is always eFrameworkunifiedStatusOK
+ for (l_itrNotifReceiver = m_pmSubscribersList->begin();
+ l_itrNotifReceiver != m_pmSubscribersList->end();
+ l_itrNotifReceiver++) {
+ l_pNotificationReceiver = l_itrNotifReceiver->second;
+
+ if (NULL != l_pNotificationReceiver) { // LCOV_EXCL_BR_LINE 6:double check, l_pNotificationReceiver can not be null // NOLINT[whitespace/line_length]
+ l_hMsgQHandle = l_pNotificationReceiver->m_MsgQHandle;
+
+ if (NULL != l_hMsgQHandle && NULL != m_pData) { // LCOV_EXCL_BR_LINE 6:double check, l_hMsgQHandle and m_pData can not be null // NOLINT[whitespace/line_length]
+ if (eFrameworkunifiedStatusOK != (l_estatus = PublishData(l_hMsgQHandle, m_pData->m_pMessage, f_uimsgsize))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4: NSFW error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error Publishing notification %s to %s published by %s, error status: 0x%x",
+ m_cNotificationName.c_str(),
+ l_itrNotifReceiver->first.c_str(),
+ f_cservicename.c_str(), l_estatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_hMsgQHandle and m_pData can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "MsgQ Handle NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: double check, l_pNotificationReceiver can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationReceiver is NULL");
+ l_estatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistent Data Not Set"); // LCOV_EXCL_LINE 6: double check, l_estatus is always eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't publish notification %s. Registered by %s and published by %s.",
+ GetNotificationName().c_str(), m_cServiceName.c_str(), f_cservicename.c_str());
+ l_estatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Can't publish notification %s. Message data size (%d) is greater than maximum registered data size (%d)",
+ GetNotificationName().c_str(), f_uimsgsize, m_uiMaxMsgSize);
+ l_estatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsPublished
+/// This functions returns the published status of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CStateNotification::IsPublished() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ return m_bWasPublished;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+/// ResetMaxMessageSize
+/// This function reset the max size of data that can be published with notification.
+/// Also deletes the old persistent data and default data.
+////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStateNotification::ResetMaxMessageSize(const UI_32 f_uilength) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ CNotification::ResetMaxMessageSize(f_uilength);
+
+ // delete the old data as the size is changed the data may become invalid
+ if (NULL != m_pData) {
+ delete m_pData;
+ m_pData = NULL;
+ }
+
+ if (NULL != m_pDefaultData) {
+ delete m_pDefaultData;
+ m_pDefaultData = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_notification.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_notification.cpp
new file mode 100644
index 00000000..1bb9dd11
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_notification.cpp
@@ -0,0 +1,87 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CStatePersistenceNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <string>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_state_persistence_notification.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CStatePersistenceNotification
+/// Constructor of CStatePersistenceNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStatePersistenceNotification::CStatePersistenceNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize,
+ const EFrameworkunifiedPersistCategory f_epersistcategory):
+ CStateNotification(f_cnotificationname, f_uimaxmsgsize),
+ m_ePersistCategory(f_epersistcategory) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_ePersistentType = eFrameworkunifiedPersistedStateVar;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CStatePersistenceNotification
+/// Constructor of CStatePersistenceNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStatePersistenceNotification::~CStatePersistenceNotification() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// GetPersistentCategory
+/// Gets the persist type of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedPersistCategory CStatePersistenceNotification::GetPersistentCategory() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return m_ePersistCategory;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// SetPersistentCategory
+/// Sets the persist type of notification.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CStatePersistenceNotification::SetPersistentCategory(const EFrameworkunifiedPersistCategory f_epersistcategory) {
+ EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_ePersistCategory = f_epersistcategory;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_estatus;
+}
diff --git a/nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_user_notification.cpp b/nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_user_notification.cpp
new file mode 100644
index 00000000..222ada31
--- /dev/null
+++ b/nsframework/notification_persistent_service/server/src/ns_npp_state_persistence_user_notification.cpp
@@ -0,0 +1,61 @@
+/*
+ * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \defgroup <<Group Tag>> <<Group Name>>
+/// \ingroup tag_NS_NPPService
+/// .
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_NPPService
+/// \brief This file contains implementation of class CStatePersistenceUserNotification.
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Files
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <string>
+#include "ns_npp_notificationpersistentservicelog.h"
+#include "ns_npp_state_persistence_user_notification.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CStatePersistenceUserNotification
+/// Constructor of CStatePersistenceUserNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStatePersistenceUserNotification::CStatePersistenceUserNotification(const std::string &f_cnotificationname,
+ const UI_32 f_uimaxmsgsize):
+ CStateNotification(f_cnotificationname, f_uimaxmsgsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_ePersistentType = eFrameworkunifiedPersistedStateUserVar;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// ~CStatePersistenceUserNotification
+/// Destructor of CStatePersistenceUserNotification class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CStatePersistenceUserNotification::~CStatePersistenceUserNotification() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}