Tizen 2.0 Release 2.0_release
authorHyungKyu Song <hk76.song@samsung.com>
Thu, 14 Feb 2013 13:04:12 +0000 (22:04 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Thu, 14 Feb 2013 13:04:12 +0000 (22:04 +0900)
477 files changed:
3rdparty/CMakeLists.txt
3rdparty/fastdelegate/Demo.cpp
3rdparty/minizip/ioapi.c
3rdparty/minizip/miniunz.c
3rdparty/minizip/minizip.c
3rdparty/minizip/mztools.c
3rdparty/minizip/unzip.c
3rdparty/minizip/zip.c
CMakeLists.txt
build/CMakeLists.txt
build/auto_save_dao/CMakeLists.txt [new file with mode: 0644]
build/auto_save_dao/wrt-commons-auto-save-dao-ro.pc.in [new file with mode: 0644]
build/auto_save_dao/wrt-commons-auto-save-dao-rw.pc.in [new file with mode: 0644]
build/auto_save_dao/wrt-commons-auto-save-dao.pc.in [new file with mode: 0644]
build/core/CMakeLists.txt
build/core/dpl-efl.pc.in [new file with mode: 0644]
build/custom_handler_dao/CMakeLists.txt [new file with mode: 0644]
build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in [new file with mode: 0644]
build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in [new file with mode: 0644]
build/db/CMakeLists.txt
build/db/dpl-db-efl.pc.in [new file with mode: 0644]
build/dbus/CMakeLists.txt
build/dbus/dpl-dbus-efl.pc.in [new file with mode: 0644]
build/encryption/CMakeLists.txt [new file with mode: 0644]
build/encryption/dpl-encryption.pc.in [new file with mode: 0644]
build/encryption/libs/libcal.a [new file with mode: 0755]
build/encryption/libs/libcal.arm.a [new file with mode: 0755]
build/encryption/libs/libcal.i586.a [new file with mode: 0755]
build/event/CMakeLists.txt
build/event/dpl-event-efl.pc.in [new file with mode: 0644]
build/log/CMakeLists.txt
build/log/dpl-log-efl.pc.in [new file with mode: 0644]
build/rpc/CMakeLists.txt
build/rpc/dpl-rpc-efl.pc.in [new file with mode: 0644]
build/security_origin_dao/CMakeLists.txt [new file with mode: 0644]
build/security_origin_dao/wrt-commons-security-origin-dao.pc.in [new file with mode: 0644]
build/socket/CMakeLists.txt
build/socket/dpl-socket-efl.pc.in [new file with mode: 0644]
build/support/CMakeLists.txt [new file with mode: 0644]
build/support/wrt-plugins-types.pc.in [new file with mode: 0644]
build/test/CMakeLists.txt
build/test/dpl-test-efl.pc.in [new file with mode: 0644]
build/utils/CMakeLists.txt
build/utils/dpl-utils-efl.pc.in [new file with mode: 0644]
build/widget_dao/CMakeLists.txt
debian/changelog
debian/control
debian/rules
debian/wrt-commons.install
debian/wrt-commons.postinst
dir-struct.py
etc/CMakeLists.txt
etc/wrt_commons_create_clean_db.sh [new file with mode: 0755]
etc/wrt_commons_reset_db.sh [new file with mode: 0755]
examples/CMakeLists.txt
examples/binary_queue/binary_queue.cpp
examples/copy/copy.cpp
examples/crypto_hash/crypto_hash.cpp
examples/dbus/client-example/client-example.cpp
examples/dbus/server-example/server-example.cpp
examples/fake_rpc/fake_rpc.cpp
examples/metronome/metronome_client.cpp
examples/metronome/metronome_server.cpp
examples/rpc/rpc.cpp
examples/simple/simple.cpp
examples/single_instance/single_instance.cpp
examples/socket/socket.cpp
examples/tcpsock/tcpsock.cpp
examples/timed_event/timed_event.cpp
modules/CMakeLists.txt
modules/auto_save_dao/CMakeLists.txt [new file with mode: 0644]
modules/auto_save_dao/dao/AutoSaveDatabase.cpp [new file with mode: 0644]
modules/auto_save_dao/dao/auto_save_dao.cpp [new file with mode: 0644]
modules/auto_save_dao/dao/auto_save_dao_read_only.cpp [new file with mode: 0644]
modules/auto_save_dao/dao/common_dao_types.cpp [new file with mode: 0644]
modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h [new file with mode: 0644]
modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h [new file with mode: 0644]
modules/auto_save_dao/include/wrt-commons/auto-save-dao/AutoSaveDatabase.h [new file with mode: 0644]
modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h [new file with mode: 0644]
modules/auto_save_dao/orm/autosave_db [new file with mode: 0644]
modules/auto_save_dao/orm/autosave_db_definitions [new file with mode: 0644]
modules/auto_save_dao/orm/autosave_db_sql_generator.h [new file with mode: 0644]
modules/auto_save_dao/orm/gen_db_md5.sh [new file with mode: 0755]
modules/auto_save_dao/orm/orm_generator_autosave.h [new file with mode: 0644]
modules/auto_save_dao/orm/version_db [new file with mode: 0644]
modules/core/config.cmake
modules/core/include/dpl/abstract_input.h
modules/core/include/dpl/abstract_input_output.h
modules/core/include/dpl/abstract_output.h
modules/core/include/dpl/abstract_waitable_input.h
modules/core/include/dpl/abstract_waitable_input_adapter.h
modules/core/include/dpl/abstract_waitable_input_output.h
modules/core/include/dpl/abstract_waitable_input_output_adapter.h
modules/core/include/dpl/abstract_waitable_output.h
modules/core/include/dpl/abstract_waitable_output_adapter.h
modules/core/include/dpl/address.h
modules/core/include/dpl/aligned.h
modules/core/include/dpl/application.h
modules/core/include/dpl/apply.h
modules/core/include/dpl/assert.h
modules/core/include/dpl/atomic.h
modules/core/include/dpl/auto_ptr.h [new file with mode: 0644]
modules/core/include/dpl/binary_queue.h
modules/core/include/dpl/char_traits.h
modules/core/include/dpl/colors.h
modules/core/include/dpl/copy.h
modules/core/include/dpl/enable_shared_from_this.h
modules/core/include/dpl/errno_string.h
modules/core/include/dpl/exception.h
modules/core/include/dpl/fast_delegate.h
modules/core/include/dpl/file_input.h
modules/core/include/dpl/file_output.h
modules/core/include/dpl/foreach.h
modules/core/include/dpl/generic_event.h
modules/core/include/dpl/lexical_cast.h
modules/core/include/dpl/main.h
modules/core/include/dpl/mutex.h
modules/core/include/dpl/named_base_pipe.h
modules/core/include/dpl/named_input_pipe.h
modules/core/include/dpl/named_output_pipe.h
modules/core/include/dpl/noncopyable.h
modules/core/include/dpl/once.h
modules/core/include/dpl/optional.h
modules/core/include/dpl/optional_typedefs.h
modules/core/include/dpl/preprocessor.h
modules/core/include/dpl/read_write_mutex.h
modules/core/include/dpl/recursive_mutex.h
modules/core/include/dpl/scoped_array.h
modules/core/include/dpl/scoped_close.h
modules/core/include/dpl/scoped_fclose.h
modules/core/include/dpl/scoped_free.h
modules/core/include/dpl/scoped_gpointer.h
modules/core/include/dpl/scoped_ptr.h
modules/core/include/dpl/scoped_resource.h
modules/core/include/dpl/semaphore.h
modules/core/include/dpl/serialization.h
modules/core/include/dpl/shared_ptr.h
modules/core/include/dpl/single_instance.h
modules/core/include/dpl/singleton.h
modules/core/include/dpl/singleton_impl.h
modules/core/include/dpl/singleton_safe_impl.h
modules/core/include/dpl/sstream.h
modules/core/include/dpl/string.h
modules/core/include/dpl/task.h
modules/core/include/dpl/task_list.h
modules/core/include/dpl/thread.h
modules/core/include/dpl/type_list.h
modules/core/include/dpl/union_cast.h
modules/core/include/dpl/unused.h
modules/core/include/dpl/waitable_event.h
modules/core/include/dpl/waitable_handle.h
modules/core/include/dpl/waitable_handle_watch_support.h
modules/core/include/dpl/zip_input.h
modules/core/src/abstract_waitable_input_adapter.cpp
modules/core/src/abstract_waitable_input_output_adapter.cpp
modules/core/src/abstract_waitable_output_adapter.cpp
modules/core/src/address.cpp
modules/core/src/application.cpp
modules/core/src/apply.cpp
modules/core/src/assert.cpp
modules/core/src/atomic.cpp
modules/core/src/binary_queue.cpp
modules/core/src/char_traits.cpp
modules/core/src/colors.cpp
modules/core/src/copy.cpp
modules/core/src/errno_string.cpp
modules/core/src/exception.cpp
modules/core/src/fast_delegate.cpp
modules/core/src/file_input.cpp
modules/core/src/file_output.cpp
modules/core/src/generic_event.cpp
modules/core/src/lexical_cast.cpp
modules/core/src/main.cpp
modules/core/src/mutex.cpp
modules/core/src/named_base_pipe.cpp
modules/core/src/named_output_pipe.cpp
modules/core/src/noncopyable.cpp
modules/core/src/once.cpp
modules/core/src/read_write_mutex.cpp
modules/core/src/recursive_mutex.cpp
modules/core/src/semaphore.cpp
modules/core/src/serialization.cpp
modules/core/src/single_instance.cpp
modules/core/src/singleton.cpp
modules/core/src/string.cpp
modules/core/src/task.cpp
modules/core/src/task_list.cpp
modules/core/src/thread.cpp
modules/core/src/type_list.cpp
modules/core/src/union_cast.cpp
modules/core/src/waitable_event.cpp
modules/core/src/waitable_handle.cpp
modules/core/src/waitable_handle_watch_support.cpp
modules/core/src/zip_input.cpp
modules/custom_handler_dao/CMakeLists.txt [new file with mode: 0644]
modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp [new file with mode: 0644]
modules/custom_handler_dao/dao/custom_handler_dao.cpp [new file with mode: 0644]
modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h [new file with mode: 0644]
modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h [new file with mode: 0644]
modules/custom_handler_dao/orm/custom_handler_db [new file with mode: 0644]
modules/custom_handler_dao/orm/custom_handler_db_definitions [new file with mode: 0644]
modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h [new file with mode: 0644]
modules/custom_handler_dao/orm/gen_db_md5.sh [new file with mode: 0755]
modules/custom_handler_dao/orm/orm_generator_custom_handler.h [new file with mode: 0644]
modules/custom_handler_dao/orm/version_db [new file with mode: 0644]
modules/db/include/dpl/db/naive_synchronization_object.h
modules/db/include/dpl/db/orm.h
modules/db/include/dpl/db/orm_generator.h
modules/db/include/dpl/db/orm_interface.h
modules/db/include/dpl/db/orm_macros.h
modules/db/include/dpl/db/sql_connection.h
modules/db/include/dpl/db/thread_database_support.h
modules/db/src/naive_synchronization_object.cpp
modules/db/src/orm.cpp
modules/db/src/sql_connection.cpp
modules/db/src/thread_database_support.cpp
modules/dbus/config.cmake
modules/dbus/include/dpl/dbus/connection.h
modules/dbus/include/dpl/dbus/dbus_client.h
modules/dbus/include/dpl/dbus/dbus_deserialization.h
modules/dbus/include/dpl/dbus/dbus_interface_dispatcher.h
modules/dbus/include/dpl/dbus/dbus_serialization.h
modules/dbus/include/dpl/dbus/dbus_server_deserialization.h
modules/dbus/include/dpl/dbus/dbus_server_serialization.h
modules/dbus/include/dpl/dbus/dbus_signature.h
modules/dbus/include/dpl/dbus/dispatcher.h
modules/dbus/include/dpl/dbus/exception.h
modules/dbus/include/dpl/dbus/glib_util.h [new file with mode: 0644]
modules/dbus/include/dpl/dbus/interface.h
modules/dbus/include/dpl/dbus/method_proxy.h
modules/dbus/include/dpl/dbus/object.h
modules/dbus/include/dpl/dbus/object_proxy.h
modules/dbus/include/dpl/dbus/server.h
modules/dbus/src/connection.cpp
modules/dbus/src/dispatcher.cpp
modules/dbus/src/interface.cpp
modules/dbus/src/object.cpp
modules/dbus/src/object_proxy.cpp
modules/dbus/src/server.cpp
modules/encryption/config.cmake [new file with mode: 0644]
modules/encryption/include/dpl/encryption/resource_decryption.h [new file with mode: 0644]
modules/encryption/include/dpl/encryption/resource_encryption.h [new file with mode: 0644]
modules/encryption/src/resource_decryption.cpp [new file with mode: 0644]
modules/encryption/src/resource_encryption.cpp [new file with mode: 0644]
modules/event/config.cmake
modules/event/include/dpl/event/abstract_event_call.h
modules/event/include/dpl/event/abstract_event_dispatcher.h
modules/event/include/dpl/event/controller.h
modules/event/include/dpl/event/event_listener.h
modules/event/include/dpl/event/event_support.h
modules/event/include/dpl/event/generic_event_call.h
modules/event/include/dpl/event/inter_context_delegate.h
modules/event/include/dpl/event/main_event_dispatcher.h
modules/event/include/dpl/event/model.h
modules/event/include/dpl/event/model_bind_to_dao.h
modules/event/include/dpl/event/property.h
modules/event/include/dpl/event/thread_event_dispatcher.h
modules/event/src/abstract_event_call.cpp
modules/event/src/abstract_event_dispatcher.cpp
modules/event/src/controller.cpp
modules/event/src/event_listener.cpp
modules/event/src/event_support.cpp
modules/event/src/generic_event_call.cpp
modules/event/src/inter_context_delegate.cpp
modules/event/src/main_event_dispatcher.cpp
modules/event/src/model.cpp
modules/event/src/thread_event_dispatcher.cpp
modules/localization/config.cmake
modules/localization/include/LanguageTagsProvider.h [new file with mode: 0644]
modules/localization/include/dpl/localization/localization_utils.h
modules/localization/include/dpl/localization/w3c_file_localization.h
modules/localization/src/LanguageTagsProvider.cpp [new file with mode: 0644]
modules/localization/src/localization_utils.cpp
modules/localization/src/w3c_file_localization.cpp
modules/log/include/dpl/log/abstract_log_provider.h
modules/log/include/dpl/log/dlog_log_provider.h
modules/log/include/dpl/log/log.h
modules/log/include/dpl/log/old_style_log_provider.h
modules/log/src/abstract_log_provider.cpp
modules/log/src/dlog_log_provider.cpp
modules/log/src/log.cpp
modules/log/src/old_style_log_provider.cpp
modules/rpc/include/dpl/rpc/abstract_rpc_connection.h
modules/rpc/include/dpl/rpc/abstract_rpc_connector.h
modules/rpc/include/dpl/rpc/generic_rpc_connection.h
modules/rpc/include/dpl/rpc/generic_socket_rpc_client.h
modules/rpc/include/dpl/rpc/generic_socket_rpc_connection.h
modules/rpc/include/dpl/rpc/generic_socket_rpc_server.h
modules/rpc/include/dpl/rpc/rpc_function.h
modules/rpc/include/dpl/rpc/unix_socket_rpc_client.h
modules/rpc/include/dpl/rpc/unix_socket_rpc_connection.h
modules/rpc/include/dpl/rpc/unix_socket_rpc_server.h
modules/rpc/src/abstract_rpc_connection.cpp
modules/rpc/src/abstract_rpc_connector.cpp
modules/rpc/src/generic_rpc_connection.cpp
modules/rpc/src/generic_socket_rpc_client.cpp
modules/rpc/src/generic_socket_rpc_connection.cpp
modules/rpc/src/generic_socket_rpc_server.cpp
modules/rpc/src/unix_socket_rpc_client.cpp
modules/rpc/src/unix_socket_rpc_connection.cpp
modules/rpc/src/unix_socket_rpc_server.cpp
modules/security_origin_dao/CMakeLists.txt [new file with mode: 0644]
modules/security_origin_dao/dao/security_origin_dao.cpp [new file with mode: 0644]
modules/security_origin_dao/dao/security_origin_dao_types.cpp [new file with mode: 0644]
modules/security_origin_dao/dao/security_origin_database.cpp [new file with mode: 0644]
modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h [new file with mode: 0644]
modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao_types.h [new file with mode: 0644]
modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_database.h [new file with mode: 0644]
modules/security_origin_dao/orm/orm_generator_security_origin.h [new file with mode: 0644]
modules/security_origin_dao/orm/security_origin_db [new file with mode: 0644]
modules/security_origin_dao/orm/security_origin_db_definitions [new file with mode: 0644]
modules/security_origin_dao/orm/security_origin_db_sql_generator.h [new file with mode: 0644]
modules/socket/include/dpl/socket/abstract_socket.h
modules/socket/include/dpl/socket/generic_socket.h
modules/socket/include/dpl/socket/unix_socket.h
modules/socket/include/dpl/socket/waitable_input_output_execution_context_support.h
modules/socket/src/generic_socket.cpp
modules/socket/src/unix_socket.cpp
modules/socket/src/waitable_input_output_execution_context_support.cpp
modules/support/config.cmake [new file with mode: 0644]
modules/support/wrt_plugin_export.h [new file with mode: 0644]
modules/test/config.cmake
modules/test/include/dpl/test/test_results_collector.h
modules/test/include/dpl/test/test_runner.h
modules/test/include/dpl/test/test_runner_child.h [new file with mode: 0644]
modules/test/src/test_results_collector.cpp
modules/test/src/test_runner.cpp
modules/test/src/test_runner_child.cpp [new file with mode: 0644]
modules/utils/config.cmake
modules/utils/include/dpl/utils/bash_utils.h [new file with mode: 0644]
modules/utils/include/dpl/utils/file_utils.h [new file with mode: 0644]
modules/utils/include/dpl/utils/folder_size.h [new file with mode: 0644]
modules/utils/include/dpl/utils/mime_type_utils.h [new file with mode: 0644]
modules/utils/include/dpl/utils/warp_iri.h [new file with mode: 0644]
modules/utils/include/dpl/utils/widget_version.h [new file with mode: 0644]
modules/utils/include/dpl/utils/wrt_global_settings.h [new file with mode: 0644]
modules/utils/include/dpl/utils/wrt_utility.h [new file with mode: 0644]
modules/utils/src/bash_utils.cpp [new file with mode: 0644]
modules/utils/src/file_utils.cpp
modules/utils/src/folder_size.cpp
modules/utils/src/mime_type_utils.cpp
modules/utils/src/warp_iri.cpp
modules/utils/src/widget_version.cpp
modules/utils/src/wrt_global_settings.cpp
modules/utils/src/wrt_utility.cpp
modules/widget_dao/CMakeLists.txt
modules/widget_dao/dao/WrtDatabase.cpp
modules/widget_dao/dao/common_dao_types.cpp
modules/widget_dao/dao/config_parser_data.cpp
modules/widget_dao/dao/feature_dao.cpp
modules/widget_dao/dao/feature_dao_read_only.cpp
modules/widget_dao/dao/global_dao.cpp
modules/widget_dao/dao/global_dao_read_only.cpp
modules/widget_dao/dao/path_builder.cpp
modules/widget_dao/dao/plugin_dao.cpp
modules/widget_dao/dao/plugin_dao_read_only.cpp
modules/widget_dao/dao/property_dao.cpp
modules/widget_dao/dao/property_dao_read_only.cpp
modules/widget_dao/dao/webruntime_database.cpp
modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/WrtDatabase.h
modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h
modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h
modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h
modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h
modules/widget_dao/include/dpl/wrt-dao-ro/global_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/path_builder.h
modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/property_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h [new file with mode: 0644]
modules/widget_dao/include/dpl/wrt-dao-ro/webruntime_database.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_config.h
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h [new file with mode: 0644]
modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h
modules/widget_dao/include/dpl/wrt-dao-rw/global_dao.h
modules/widget_dao/include/dpl/wrt-dao-rw/plugin_dao.h
modules/widget_dao/include/dpl/wrt-dao-rw/property_dao.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h
modules/widget_dao/orm/wrt_db [changed mode: 0644->0755]
modules/widget_dao/orm/wrt_db_sql_generator.h
packaging/wrt-commons.spec [new file with mode: 0644]
tests/CMakeLists.txt
tests/CMakeUtils.txt [new file with mode: 0644]
tests/common/include/glib_interface.h [new file with mode: 0644]
tests/common/include/loop_control.h [new file with mode: 0644]
tests/common/src/loop_control.cpp [new file with mode: 0644]
tests/dao/CMakeLists.txt [new file with mode: 0644]
tests/dao/README [new file with mode: 0644]
tests/dao/TestCases_CustomHandlerDAO.cpp [new file with mode: 0644]
tests/dao/TestCases_FeatureDAO.cpp [new file with mode: 0644]
tests/dao/TestCases_GlobalDAO.cpp [new file with mode: 0644]
tests/dao/TestCases_PluginDAO.cpp [new file with mode: 0644]
tests/dao/TestCases_PropertyDAO.cpp [new file with mode: 0644]
tests/dao/TestCases_WidgetDAO.cpp [new file with mode: 0644]
tests/dao/tests_dao.cpp [new file with mode: 0644]
tests/dao/wrt_dao_tests_prepare_db.sh [new file with mode: 0755]
tests/dpl/CMakeLists.txt [new file with mode: 0644]
tests/dpl/README [new file with mode: 0644]
tests/dpl/core/.swp [new file with mode: 0644]
tests/dpl/core/CMakeLists.txt [new file with mode: 0644]
tests/dpl/core/DESCRIPTION [new file with mode: 0644]
tests/dpl/core/data/sample.zip [new file with mode: 0644]
tests/dpl/core/main.cpp [new file with mode: 0644]
tests/dpl/core/test_address.cpp [new file with mode: 0644]
tests/dpl/core/test_binary_queue.cpp [new file with mode: 0644]
tests/dpl/core/test_fast_delegate.cpp [new file with mode: 0644]
tests/dpl/core/test_foreach.cpp [new file with mode: 0644]
tests/dpl/core/test_log_unhandled_exception.cpp [new file with mode: 0644]
tests/dpl/core/test_once.cpp [new file with mode: 0644]
tests/dpl/core/test_scoped_array.cpp [new file with mode: 0644]
tests/dpl/core/test_scoped_close.cpp [new file with mode: 0644]
tests/dpl/core/test_scoped_fclose.cpp [new file with mode: 0644]
tests/dpl/core/test_scoped_free.cpp [new file with mode: 0644]
tests/dpl/core/test_scoped_ptr.cpp [new file with mode: 0644]
tests/dpl/core/test_semaphore.cpp [new file with mode: 0644]
tests/dpl/core/test_serialization.cpp [new file with mode: 0644]
tests/dpl/core/test_shared_ptr.cpp [new file with mode: 0644]
tests/dpl/core/test_string.cpp [new file with mode: 0644]
tests/dpl/core/test_thread.cpp [new file with mode: 0644]
tests/dpl/core/test_type_list.cpp [new file with mode: 0644]
tests/dpl/core/test_zip_input.cpp [new file with mode: 0644]
tests/dpl/db/CMakeLists.txt [new file with mode: 0644]
tests/dpl/db/main.cpp [new file with mode: 0644]
tests/dpl/db/orm/CMakeLists.txt [new file with mode: 0644]
tests/dpl/db/orm/dpl_orm_test_db [new file with mode: 0644]
tests/dpl/db/orm/dpl_orm_test_db_definitions [new file with mode: 0644]
tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h [new file with mode: 0644]
tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h.gch [new file with mode: 0644]
tests/dpl/db/orm/generator_dpl_orm_test.h [new file with mode: 0644]
tests/dpl/db/test_orm.cpp [new file with mode: 0644]
tests/dpl/db/test_sql_connection.cpp [new file with mode: 0644]
tests/dpl/dbus/CMakeLists.txt [new file with mode: 0644]
tests/dpl/dbus/data/org.tizen.DBusTestService.service [new file with mode: 0644]
tests/dpl/dbus/dbus_test.cpp [new file with mode: 0644]
tests/dpl/dbus/dbus_test.h [new file with mode: 0644]
tests/dpl/dbus/main.cpp [new file with mode: 0644]
tests/dpl/dbus/test_cases.cpp [new file with mode: 0644]
tests/dpl/dbus/test_service.cpp [new file with mode: 0644]
tests/dpl/event/CMakeLists.txt [new file with mode: 0644]
tests/dpl/event/main.cpp [new file with mode: 0644]
tests/dpl/event/test_controller.cpp [new file with mode: 0644]
tests/dpl/event/test_event_support.cpp [new file with mode: 0644]
tests/dpl/event/test_ic_delegate.cpp [new file with mode: 0644]
tests/dpl/event/test_property.cpp [new file with mode: 0644]
tests/dpl/localization/CMakeLists.txt [new file with mode: 0644]
tests/dpl/localization/files/CMakeLists.txt [new file with mode: 0644]
tests/dpl/localization/files/one [new file with mode: 0644]
tests/dpl/localization/files/two [new file with mode: 0644]
tests/dpl/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h [new file with mode: 0644]
tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h [new file with mode: 0644]
tests/dpl/localization/mockup_src/widget_dao.cpp [new file with mode: 0644]
tests/dpl/localization/test_localization.cpp [new file with mode: 0644]
tests/dpl/localization/test_suite01.cpp [new file with mode: 0644]
tests/dpl/test/CMakeLists.txt [new file with mode: 0644]
tests/dpl/test/main.cpp [new file with mode: 0644]
tests/dpl/test/runner_child.cpp [new file with mode: 0644]
tests/dpl/unused/test_caller.cpp [new file with mode: 0644]
tests/dpl/unused/test_crypto_hash.cpp [new file with mode: 0644]
tests/dpl/unused/test_message_queue.cpp [new file with mode: 0644]
tests/dpl/unused/test_shm.cpp [new file with mode: 0644]
tests/dpl/unused/test_sql_connection.cpp [new file with mode: 0644]
tests/dpl/unused/test_task.cpp [new file with mode: 0644]
tests/dpl/utils/CMakeLists.txt [new file with mode: 0644]
tests/dpl/utils/bash_utils.cpp [new file with mode: 0644]
tests/dpl/utils/main.cpp [new file with mode: 0644]
tests/dpl/utils/widget_version.cpp [new file with mode: 0644]
tests/dpl/utils/wrt_utility.cpp [new file with mode: 0644]
uncrustify.cfg [new file with mode: 0644]
uncrustify.sh [new file with mode: 0755]
wrt-commons [new file with mode: 0644]
wrt-commons.manifest [new file with mode: 0644]

index 4783a46..e71fc4c 100644 (file)
@@ -54,7 +54,7 @@ SET(TARGET_3RDPARTY "lib3rdparty")
 INCLUDE_DIRECTORIES(${DPL_3RDPARTY_INCLUDE_DIR})
 
 # Add system include files
 INCLUDE_DIRECTORIES(${DPL_3RDPARTY_INCLUDE_DIR})
 
 # Add system include files
-INCLUDE_DIRECTORIES(${SYS_3RDPARTY_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_3RDPARTY_INCLUDE_DIRS})
 LINK_DIRECTORIES(${SYS_3RDPARTY_LIBRARY_DIRS})
 
 # Build shared library
 LINK_DIRECTORIES(${SYS_3RDPARTY_LIBRARY_DIRS})
 
 # Build shared library
index 2b4d6f6..93720f9 100644 (file)
@@ -1,3 +1,4 @@
+#include <stddef.h>\r
 #include <stdio.h>\r
 #include "FastDelegate.h"\r
 // Demonstrate the syntax for FastDelegates.\r
 #include <stdio.h>\r
 #include "FastDelegate.h"\r
 // Demonstrate the syntax for FastDelegates.\r
index 49958f6..41ab314 100644 (file)
@@ -22,6 +22,8 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
         return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
     else
     {
         return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
     else
     {
+        if (pfilefunc->zopen32_file == NULL)
+            return NULL;
         return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
     }
 }
         return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
     }
 }
@@ -33,7 +35,7 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
     else
     {
         uLong offsetTruncated = (uLong)offset;
     else
     {
         uLong offsetTruncated = (uLong)offset;
-        if (offsetTruncated != offset)
+        if (offsetTruncated != offset || pfilefunc->zseek32_file == NULL)
             return -1;
         else
             return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
             return -1;
         else
             return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
@@ -46,6 +48,8 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
         return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
     else
     {
         return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
     else
     {
+        if (pfilefunc->ztell32_file == NULL)
+            return (ZPOS64_T)-1;
         uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
         if ((tell_uLong) == ((uLong)-1))
             return (ZPOS64_T)-1;
         uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
         if ((tell_uLong) == ((uLong)-1))
             return (ZPOS64_T)-1;
index 9ed009f..c8c4904 100644 (file)
@@ -37,6 +37,7 @@
 #ifdef unix
 # include <unistd.h>
 # include <utime.h>
 #ifdef unix
 # include <unistd.h>
 # include <utime.h>
+# include <sys/stat.h>
 #else
 # include <direct.h>
 # include <io.h>
 #else
 # include <direct.h>
 # include <io.h>
@@ -311,7 +312,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
     uInt size_buf;
 
     unz_file_info64 file_info;
     uInt size_buf;
 
     unz_file_info64 file_info;
-    uLong ratio=0;
     err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
 
     if (err!=UNZ_OK)
     err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
 
     if (err!=UNZ_OK)
@@ -469,7 +469,6 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
     uLong i;
     unz_global_info64 gi;
     int err;
     uLong i;
     unz_global_info64 gi;
     int err;
-    FILE* fout=NULL;
 
     err = unzGetGlobalInfo64(uf,&gi);
     if (err!=UNZ_OK)
 
     err = unzGetGlobalInfo64(uf,&gi);
     if (err!=UNZ_OK)
@@ -503,7 +502,6 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
     int opt_overwrite;
     const char* password;
 {
     int opt_overwrite;
     const char* password;
 {
-    int err = UNZ_OK;
     if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
     {
         printf("file %s not found in the zipfile\n",filename);
     if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
     {
         printf("file %s not found in the zipfile\n",filename);
index 7a4fa5a..ad2f4c7 100644 (file)
@@ -215,7 +215,7 @@ int isLargeFile(const char* filename)
 
   if(pFile != NULL)
   {
 
   if(pFile != NULL)
   {
-    int n = fseeko64(pFile, 0, SEEK_END);
+    (void)fseeko64(pFile, 0, SEEK_END);
 
     pos = ftello64(pFile);
 
 
     pos = ftello64(pFile);
 
@@ -382,7 +382,7 @@ int main(argc,argv)
                    ((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
                   (strlen(argv[i]) == 2)))
             {
                    ((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
                   (strlen(argv[i]) == 2)))
             {
-                FILE * fin;
+                FILE * fin = NULL;
                 int size_read;
                 const char* filenameinzip = argv[i];
                 const char *savefilenameinzip;
                 int size_read;
                 const char* filenameinzip = argv[i];
                 const char *savefilenameinzip;
index f9092e6..edf6b7f 100644 (file)
@@ -41,7 +41,7 @@ uLong* bytesRecovered;
   if (fpZip != NULL &&  fpOut != NULL) {
     int entries = 0;
     uLong totalBytes = 0;
   if (fpZip != NULL &&  fpOut != NULL) {
     int entries = 0;
     uLong totalBytes = 0;
-    char header[30];
+    char header[30] = {0,};
     char filename[256];
     char extra[1024];
     int offset = 0;
     char filename[256];
     char extra[1024];
     int offset = 0;
index 7617f41..9e61cfb 100644 (file)
@@ -586,7 +586,9 @@ local unzFile unzOpenInternal (const void *path,
                                int is64bitOpenFunction)
 {
     unz64_s us;
                                int is64bitOpenFunction)
 {
     unz64_s us;
-    unz64_s *s;
+    memset(&us,0,sizeof(unz64_s));
+
+    unz64_s *s = NULL;
     ZPOS64_T central_pos;
     uLong   uL;
 
     ZPOS64_T central_pos;
     uLong   uL;
 
@@ -782,6 +784,7 @@ extern unzFile ZEXPORT unzOpen2_64 (const void *path,
     {
         zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
         zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
     {
         zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
         zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
+        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
         zlib_filefunc64_32_def_fill.ztell32_file = NULL;
         zlib_filefunc64_32_def_fill.zseek32_file = NULL;
         return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
         zlib_filefunc64_32_def_fill.ztell32_file = NULL;
         zlib_filefunc64_32_def_fill.zseek32_file = NULL;
         return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
index 3c34fc8..96b2ba3 100644 (file)
@@ -935,6 +935,7 @@ extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc*
     {
         zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
         zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
     {
         zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
         zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
+        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
         zlib_filefunc64_32_def_fill.ztell32_file = NULL;
         zlib_filefunc64_32_def_fill.zseek32_file = NULL;
         return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);
         zlib_filefunc64_32_def_fill.ztell32_file = NULL;
         zlib_filefunc64_32_def_fill.zseek32_file = NULL;
         return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);
index 42a1e50..64704d2 100644 (file)
 # @brief
 #
 
 # @brief
 #
 
-#
 # Check minimum CMake version
 # Check minimum CMake version
-#
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-#
 # Project name
 # Project name
-#
 PROJECT(dpl)
 
 PROJECT(dpl)
 
-#
-# Logs
-#
+STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
+ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
 
 
+# Comment this to disable control of global settings with environment variable
+ADD_DEFINITIONS("-DGLOBAL_SETTINGS_CONTROL")
 
 
-OPTION(DPL_LOG "DPL logs status" OFF)
+# Build type
+IF(NOT CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE "Release")
+ENDIF(NOT CMAKE_BUILD_TYPE)
 
 
-IF(DPL_LOG)
+# Options
+OPTION(DPL_LOG "DPL logs status" OFF)
+IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
     MESSAGE(STATUS "Logging enabled for DPL")
     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
     MESSAGE(STATUS "Logging enabled for DPL")
     ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
-ELSE(DPL_LOG)
+ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
     MESSAGE(STATUS "Logging disabled for DPL")
     MESSAGE(STATUS "Logging disabled for DPL")
-ENDIF(DPL_LOG)
-ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION")
+ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
 
 
-# Gtk
-OPTION(DISABLE_GTK "Disable GTK stuff" ON)
-
-#
-# Build type
-#
+OPTION(WITH_TESTS "Build tests" OFF)
 
 
-SET(CMAKE_BUILD_TYPE "Release")
+# Compiler flags
+SET(CMAKE_C_FLAGS_PROFILING    "-O2")
+SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
+SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
+SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
+SET(CMAKE_C_FLAGS_RELEASE      "-O2 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE    "-O2 -std=c++0x -g")
+SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
 
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
-SET(CMAKE_CXX_FLAGS "-O2 -g -fPIC -D_FORTIFY_SOURCE=0")
+ADD_DEFINITIONS("-fPIC")                        # If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC. (BJ: our ARM too?)
 
 
-#
 # CMake settings
 # CMake settings
-#
 MESSAGE(STATUS "========================================")
 MESSAGE(STATUS "CMAKE_BINARY_DIR:         " ${CMAKE_BINARY_DIR})
 MESSAGE(STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR})
 MESSAGE(STATUS "========================================")
 MESSAGE(STATUS "CMAKE_BINARY_DIR:         " ${CMAKE_BINARY_DIR})
 MESSAGE(STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR})
@@ -107,17 +107,13 @@ MESSAGE(STATUS "CMAKE_COMPILER_IS_GNUCC: " ${CMAKE_COMPILER_IS_GNUCC})
 MESSAGE(STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX})
 MESSAGE(STATUS "CMAKE_AR: " ${CMAKE_AR})
 MESSAGE(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB})
 MESSAGE(STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX})
 MESSAGE(STATUS "CMAKE_AR: " ${CMAKE_AR})
 MESSAGE(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB})
+MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
 MESSAGE(STATUS "========================================")
 
 MESSAGE(STATUS "========================================")
 
-#
 # Build 3rd party libraries first
 # Build 3rd party libraries first
-#
 ADD_SUBDIRECTORY(3rdparty)
 
 ADD_SUBDIRECTORY(3rdparty)
 
-#
 # Compiler flags
 # Compiler flags
-#
-
 ADD_DEFINITIONS("-fvisibility=default")         # mark all exported symbols as visible
 
 # Warnings mode
 ADD_DEFINITIONS("-fvisibility=default")         # mark all exported symbols as visible
 
 # Warnings mode
@@ -186,18 +182,27 @@ SET(TARGET_DPL_SOCKET_EFL "lib${PROJECT_NAME}-socket-efl")
 SET(TARGET_DPL_RPC_EFL "lib${PROJECT_NAME}-rpc-efl")
 SET(TARGET_DPL_TEST_ENGINE_EFL "lib${PROJECT_NAME}-test-efl")
 SET(TARGET_DPL_LOG_EFL "lib${PROJECT_NAME}-log-efl")
 SET(TARGET_DPL_RPC_EFL "lib${PROJECT_NAME}-rpc-efl")
 SET(TARGET_DPL_TEST_ENGINE_EFL "lib${PROJECT_NAME}-test-efl")
 SET(TARGET_DPL_LOG_EFL "lib${PROJECT_NAME}-log-efl")
-SET(TARGET_DPL_POPUP "lib${PROJECT_NAME}-popup-efl")
 SET(TARGET_WRT_DAO_RW_LIB "dpl-wrt-dao-rw")
 SET(TARGET_WRT_DAO_RO_LIB "dpl-wrt-dao-ro")
 SET(TARGET_WRT_DAO_RW_LIB "dpl-wrt-dao-rw")
 SET(TARGET_WRT_DAO_RO_LIB "dpl-wrt-dao-ro")
+SET(TARGET_AUTO_SAVE_DAO_LIB "wrt-commons-auto-save-dao")
+SET(TARGET_AUTO_SAVE_DAO_RW_LIB "wrt-commons-auto-save-dao-rw")
+SET(TARGET_AUTO_SAVE_DAO_RO_LIB "wrt-commons-auto-save-dao-ro")
+SET(TARGET_CUSTOM_HANDLER_DAO_RW_LIB "wrt-commons-custom-handler-dao-rw")
+SET(TARGET_CUSTOM_HANDLER_DAO_RO_LIB "wrt-commons-custom-handler-dao-ro")
+SET(TARGET_SECURITY_ORIGIN_DAO_LIB "wrt-commons-security-origin-dao")
 SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl")
 SET(TARGET_DPL_UTILS_EFL "lib${PROJECT_NAME}-utils-efl")
-SET(TARGET_ACE_DAO_RO_LIB "dpl-ace-dao-ro")
-SET(TARGET_ACE_DAO_RW_LIB "dpl-ace-dao-rw")
-SET(TARGET_ACE_LIB "dpl-ace")
-SET(TARGET_VCORE_LIB "dpl-vcore")
+SET(TARGET_DPL_ENCRYPTION "lib${PROJECT_NAME}-encryption")
+
+macro(configure_and_install_pkg PKG_FILE)
+    CONFIGURE_FILE(${PKG_FILE}.in ${PKG_FILE} @ONLY)
+    INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG_FILE} DESTINATION lib/pkgconfig)
+endmacro(configure_and_install_pkg)
 
 ADD_SUBDIRECTORY(modules)
 
 ADD_SUBDIRECTORY(build)
 
 ADD_SUBDIRECTORY(modules)
 
 ADD_SUBDIRECTORY(build)
-ADD_SUBDIRECTORY(tests)
 ADD_SUBDIRECTORY(etc)
 
 ADD_SUBDIRECTORY(etc)
 
+IF(WITH_TESTS)
+  ADD_SUBDIRECTORY(tests)
+ENDIF(WITH_TESTS)
index 835f856..b27d01f 100644 (file)
@@ -26,8 +26,10 @@ ADD_SUBDIRECTORY(socket)
 ADD_SUBDIRECTORY(rpc)
 ADD_SUBDIRECTORY(test)
 #ADD_SUBDIRECTORY(log)
 ADD_SUBDIRECTORY(rpc)
 ADD_SUBDIRECTORY(test)
 #ADD_SUBDIRECTORY(log)
-ADD_SUBDIRECTORY(vcore)
-ADD_SUBDIRECTORY(ace)
 ADD_SUBDIRECTORY(widget_dao)
 ADD_SUBDIRECTORY(widget_dao)
-ADD_SUBDIRECTORY(popup)
+ADD_SUBDIRECTORY(auto_save_dao)
+ADD_SUBDIRECTORY(security_origin_dao)
+ADD_SUBDIRECTORY(custom_handler_dao)
 ADD_SUBDIRECTORY(utils)
 ADD_SUBDIRECTORY(utils)
+ADD_SUBDIRECTORY(support)
+ADD_SUBDIRECTORY(encryption)
diff --git a/build/auto_save_dao/CMakeLists.txt b/build/auto_save_dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..62e656a
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Jihoon Chung (jihoon.chung@samsung.com)
+# @brief
+#
+
+configure_and_install_pkg(wrt-commons-auto-save-dao.pc)
+configure_and_install_pkg(wrt-commons-auto-save-dao-ro.pc)
+configure_and_install_pkg(wrt-commons-auto-save-dao-rw.pc)
diff --git a/build/auto_save_dao/wrt-commons-auto-save-dao-ro.pc.in b/build/auto_save_dao/wrt-commons-auto-save-dao-ro.pc.in
new file mode 100644 (file)
index 0000000..2784bef
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+
+libdir=${prefix}/lib
+includedir=${prefix}/include
+Name: wrt-commons-auto-save-dao-ro
+Description: wrt-commons-auto-save-dao-ro
+
+Version: @VERSION@
+Requires: dpl-efl wrt-commons-auto-save-dao libxml-2.0
+Libs: -lwrt-commons-auto-save-dao-ro -lwrt-commons-auto-save-dao -L${libdir}
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/auto_save_dao/wrt-commons-auto-save-dao-rw.pc.in b/build/auto_save_dao/wrt-commons-auto-save-dao-rw.pc.in
new file mode 100644 (file)
index 0000000..bb4bd70
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+
+libdir=${prefix}/lib
+includedir=${prefix}/include
+Name: wrt-commons-auto-save-dao-rw
+Description: wrt-commons-auto-save-dao-rw
+
+Version: @VERSION@
+Requires: dpl-efl wrt-commons-auto-save-dao wrt-commons-auto-save-dao-ro libxml-2.0
+Libs: -lwrt-commons-auto-save-dao-rw -lwrt-commons-auto-save-dao-ro -lwrt-commons-auto-save-dao -L${libdir}
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/auto_save_dao/wrt-commons-auto-save-dao.pc.in b/build/auto_save_dao/wrt-commons-auto-save-dao.pc.in
new file mode 100644 (file)
index 0000000..11e3ca9
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+
+libdir=${prefix}/lib
+includedir=${prefix}/include
+Name: wrt-commons-auto-save-dao
+Description: wrt-commons-auto-save-dao
+
+Version: @VERSION@
+Requires: dpl-efl libxml-2.0
+Libs: -lwrt-commons-auto-save-dao -L${libdir}
+Cflags: -I${includedir}/dpl-efl
index a6dc980..080d65c 100644 (file)
@@ -35,9 +35,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_3RDPARTY_INCLUDE_DIR}
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_3RDPARTY_INCLUDE_DIR}
-    ${SYS_EFL_INCLUDE_DIRS}
 )
 
 )
 
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_INCLUDE_DIRS})
+
 LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
 
 # Base EFL based DPL library
 LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
 
 # Base EFL based DPL library
@@ -58,14 +59,14 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_EFL} lib3rdparty)
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_CORE_EFL_DETAIL_HEADERS}
 
 # Install detail headers
 INSTALL(FILES ${DPL_CORE_EFL_DETAIL_HEADERS}
@@ -84,5 +85,4 @@ INSTALL(FILES ${DPL_3RDPARTY_HEADERS}
         DESTINATION include/dpl-efl/dpl/3rdparty/fastdelegate)
 
 # Install pkgconfig script
         DESTINATION include/dpl-efl/dpl/3rdparty/fastdelegate)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-efl.pc)
diff --git a/build/core/dpl-efl.pc.in b/build/core/dpl-efl.pc.in
new file mode 100644 (file)
index 0000000..6d2a882
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-efl
+Description: DPL - EFL based
+Version: @VERSION@
+Requires: ecore appcore-efl openssl dlog vconf
+Libs: -L${libdir} -ldpl-efl
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/custom_handler_dao/CMakeLists.txt b/build/custom_handler_dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..26e701c
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @brief
+#
+
+configure_and_install_pkg(wrt-commons-custom-handler-dao-ro.pc)
+configure_and_install_pkg(wrt-commons-custom-handler-dao-rw.pc)
diff --git a/build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in b/build/custom_handler_dao/wrt-commons-custom-handler-dao-ro.pc.in
new file mode 100644 (file)
index 0000000..7cda187
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+
+libdir=${prefix}/lib
+includedir=${prefix}/include
+Name: wrt-commons-custom-handler-dao-ro
+Description: wrt-commons-custom-handler-dao-ro
+
+Version: @VERSION@
+Requires: dpl-efl
+Libs: -lwrt-commons-custom-handler-dao-ro -L${libdir}
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in b/build/custom_handler_dao/wrt-commons-custom-handler-dao-rw.pc.in
new file mode 100644 (file)
index 0000000..4cd2737
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+
+libdir=${prefix}/lib
+includedir=${prefix}/include
+Name: wrt-commons-custom-handler-dao-rw
+Description: wrt-commons-custom-handler-dao-rw
+
+Version: @VERSION@
+Requires: dpl-efl wrt-commons-custom-handler-dao-ro
+Libs: -lwrt-commons-custom-handler-dao-rw -lwrt-commons-custom-handler-dao-ro -L${libdir}
+Cflags: -I${includedir}/dpl-efl
index 7426d5b..29dd495 100644 (file)
@@ -30,7 +30,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_DB_INCLUDE_DIR}
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_DB_INCLUDE_DIR}
-    ${SYS_EFL_INCLUDE_DIRS})
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_DB_INCLUDE_DIRS})
 
 LINK_DIRECTORIES(
     ${SYS_EFL_DB_LIBRARY_DIRS}
 
 LINK_DIRECTORIES(
     ${SYS_EFL_DB_LIBRARY_DIRS}
@@ -50,19 +53,18 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_DB_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_DB_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_DB_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_DB_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_DB_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_DB_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_DB_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_DB_HEADERS}
         DESTINATION include/dpl-efl/dpl/db)
 
 # Install pkgconfig script
 
 # Install detail headers
 INSTALL(FILES ${DPL_DB_HEADERS}
         DESTINATION include/dpl-efl/dpl/db)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-db-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-db-efl.pc)
diff --git a/build/db/dpl-db-efl.pc.in b/build/db/dpl-db-efl.pc.in
new file mode 100644 (file)
index 0000000..866bb0f
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-db-efl
+Description: DPL DB - EFL based
+Version: @VERSION@
+Requires: dpl-efl sqlite3 db-util
+Libs: -L${libdir} -ldpl-db-efl
+Cflags: -I${includedir}/dpl-efl
index 71e883a..59b2db1 100644 (file)
@@ -22,6 +22,7 @@
 INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(SYS_EFL_DBUS
     dbus-1
 INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(SYS_EFL_DBUS
     dbus-1
+    gio-2.0
     REQUIRED)
 
 # Add core include directories
     REQUIRED)
 
 # Add core include directories
@@ -30,7 +31,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_DBUS_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_DBUS_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
-    ${SYS_EFL_INCLUDE_DIRS})
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_DBUS_INCLUDE_DIRS})
 
 LINK_DIRECTORIES(
     ${SYS_EFL_DBUS_LIBRARY_DIRS}
 
 LINK_DIRECTORIES(
     ${SYS_EFL_DBUS_LIBRARY_DIRS}
@@ -51,19 +55,18 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_DBUS_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_DBUS_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_DBUS_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_DBUS_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_DBUS_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_DBUS_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_DBUS_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_DBUS_HEADERS}
         DESTINATION include/dpl-efl/dpl/dbus)
 
 # Install pkgconfig script
 
 # Install detail headers
 INSTALL(FILES ${DPL_DBUS_HEADERS}
         DESTINATION include/dpl-efl/dpl/dbus)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-dbus-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-dbus-efl.pc)
diff --git a/build/dbus/dpl-dbus-efl.pc.in b/build/dbus/dpl-dbus-efl.pc.in
new file mode 100644 (file)
index 0000000..73f2c03
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-dbus-efl
+Description: DPL DBus - EFL based
+Version: @VERSION@
+Requires: dbus-1 dpl-efl dpl-event-efl
+Libs: -L${libdir} -ldpl-dbus-efl
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/encryption/CMakeLists.txt b/build/encryption/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bf38cae
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Soyoung Kim (sy037.kim@samsung.com)
+# @version     1.0
+# @brief
+#
+
+# Check required modules
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(SYS_ENCRYPTION
+    dlog
+    openssl
+    REQUIRED
+)
+
+# Add core include directories
+INCLUDE_DIRECTORIES(
+    ${DPL_LOG_INCLUDE_DIR}
+    ${DPL_CORE_INCLUDE_DIR}
+    ${DPL_DB_INCLUDE_DIR}
+    ${DPL_ENCRYPTION_INCLUDE_DIR}
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_ENCRYPTION_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+    ${SYS_ENCRYPTION_LIBRARY_DIRS}
+)
+
+# Base EFL based DPL library
+SET(DPL_ENCRYPTION_LIBRARY "${PROJECT_NAME}-encryption")
+
+# Build shared library
+
+ADD_LIBRARY(${TARGET_DPL_ENCRYPTION} SHARED
+    ${DPL_ENCRYPTION_SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_DPL_ENCRYPTION}
+    ${SYS_ENCRYPTION_LIBRARIES}
+    ${TARGET_DPL_EFL}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_DPL_ENCRYPTION} -L./libs -lcal)
+
+# Target library properties
+SET_TARGET_PROPERTIES(${TARGET_DPL_ENCRYPTION} PROPERTIES
+    SOVERSION ${API_VERSION}
+ VERSION ${VERSION}
+    CLEAN_DIRECT_OUTPUT 1
+    OUTPUT_NAME ${DPL_ENCRYPTION_LIBRARY})
+
+# Install libraries
+INSTALL(TARGETS ${TARGET_DPL_ENCRYPTION}
+        DESTINATION lib)
+
+# Install detail headers
+
+INSTALL(FILES ${DPL_ENCRYPTION_HEADERS}
+        DESTINATION include/dpl-efl/dpl/encryption)
+
+# Install pkgconfig script
+configure_and_install_pkg(dpl-encryption.pc)
diff --git a/build/encryption/dpl-encryption.pc.in b/build/encryption/dpl-encryption.pc.in
new file mode 100644 (file)
index 0000000..dfddda3
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-encryption
+Description: DPL UTILS - EFL based
+Version: @VERSION@
+Requires: dpl-efl
+Libs: -L${libdir} -ldpl-encryption
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/encryption/libs/libcal.a b/build/encryption/libs/libcal.a
new file mode 100755 (executable)
index 0000000..8400c5f
Binary files /dev/null and b/build/encryption/libs/libcal.a differ
diff --git a/build/encryption/libs/libcal.arm.a b/build/encryption/libs/libcal.arm.a
new file mode 100755 (executable)
index 0000000..f1d622b
Binary files /dev/null and b/build/encryption/libs/libcal.arm.a differ
diff --git a/build/encryption/libs/libcal.i586.a b/build/encryption/libs/libcal.i586.a
new file mode 100755 (executable)
index 0000000..b02e413
Binary files /dev/null and b/build/encryption/libs/libcal.i586.a differ
index 305434a..b023e0a 100644 (file)
@@ -24,7 +24,6 @@ PKG_CHECK_MODULES(SYS_EFL_EVENT
     ecore
     appcore-efl
     vconf
     ecore
     appcore-efl
     vconf
-    heynoti
     REQUIRED
 )
 
     REQUIRED
 )
 
@@ -33,7 +32,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
-    ${SYS_EFL_EVENT_INCLUDE_DIRS})
+    ${DPL_EVENT_INCLUDE_DIR}
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_EVENT_INCLUDE_DIRS})
 
 LINK_DIRECTORIES(
     ${SYS_EFL_EVENT_LIBRARY_DIRS}
 
 LINK_DIRECTORIES(
     ${SYS_EFL_EVENT_LIBRARY_DIRS}
@@ -53,19 +55,18 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_EVENT_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_EVENT_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_EVENT_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_EVENT_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_EVENT_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_EVENT_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_EVENT_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_EVENT_HEADERS}
         DESTINATION include/dpl-efl/dpl/event)
 
 # Install pkgconfig script
 
 # Install detail headers
 INSTALL(FILES ${DPL_EVENT_HEADERS}
         DESTINATION include/dpl-efl/dpl/event)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-event-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-event-efl.pc)
diff --git a/build/event/dpl-event-efl.pc.in b/build/event/dpl-event-efl.pc.in
new file mode 100644 (file)
index 0000000..d4befbe
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-event-efl
+Description: DPL Event - EFL based
+Version: @VERSION@
+Requires: dpl-efl ecore appcore-efl vconf
+Libs: -L${libdir} -ldpl-event-efl
+Cflags: -I${includedir}/dpl-efl
index 6669aaa..47379d5 100644 (file)
@@ -28,9 +28,10 @@ PKG_CHECK_MODULES(SYS_EFL_LOG
 # Add core include directories
 INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
 # Add core include directories
 INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
-    ${SYS_EFL_LOG_INCLUDE_DIRS}
 )
 
 )
 
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_LOG_INCLUDE_DIRS})
+
 LINK_DIRECTORIES(
     ${SYS_EFL_LOG_LIBRARY_DIRS}
 )
 LINK_DIRECTORIES(
     ${SYS_EFL_LOG_LIBRARY_DIRS}
 )
@@ -48,18 +49,17 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_LOG_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_LOG_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_LOG_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_LOG_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_LOG_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_LOG_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_LOG_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 INSTALL(FILES ${DPL_LOG_HEADERS}
         DESTINATION include/dpl-efl/dpl/log)
 
 # Install pkgconfig script
 
 INSTALL(FILES ${DPL_LOG_HEADERS}
         DESTINATION include/dpl-efl/dpl/log)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-log-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-log-efl.pc)
diff --git a/build/log/dpl-log-efl.pc.in b/build/log/dpl-log-efl.pc.in
new file mode 100644 (file)
index 0000000..7f18689
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-log-efl
+Description: DPL Log Engine - EFL based
+Version: @VERSION@
+Requires: dpl-efl dlog
+Libs: -L${libdir} -ldpl-log-efl
+Cflags: -I${includedir}/dpl-efl
index 553c52f..9c52217 100644 (file)
@@ -1,3 +1,4 @@
+
 # Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 # Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,9 +34,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_SOCKET_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
     ${DPL_RPC_INCLUDE_DIR}
     ${DPL_SOCKET_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
     ${DPL_RPC_INCLUDE_DIR}
-    ${SYS_EFL_RPC_INCLUDE_DIRS}
 )
 
 )
 
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_RPC_INCLUDE_DIRS})
+
 LINK_DIRECTORIES(
     ${SYS_EFL_RPC_LIBRARY_DIRS}
 )
 LINK_DIRECTORIES(
     ${SYS_EFL_RPC_LIBRARY_DIRS}
 )
@@ -56,19 +58,18 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_RPC_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_RPC_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_RPC_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_RPC_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_RPC_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_RPC_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_RPC_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_RPC_HEADERS}
         DESTINATION include/dpl-efl/dpl/rpc)
 
 # Install pkgconfig script
 
 # Install detail headers
 INSTALL(FILES ${DPL_RPC_HEADERS}
         DESTINATION include/dpl-efl/dpl/rpc)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-rpc-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-rpc-efl.pc)
diff --git a/build/rpc/dpl-rpc-efl.pc.in b/build/rpc/dpl-rpc-efl.pc.in
new file mode 100644 (file)
index 0000000..d857bbe
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-rpc-efl
+Description: DPL RPC - EFL based
+Version: @VERSION@
+Requires: dpl-efl dpl-event-efl dpl-socket-efl
+Libs: -L${libdir} -ldpl-rpc-efl
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/security_origin_dao/CMakeLists.txt b/build/security_origin_dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ee0dcf8
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Jihoon Chung (jihoon.chung@samsung.com)
+# @brief
+#
+
+configure_and_install_pkg(wrt-commons-security-origin-dao.pc)
+
diff --git a/build/security_origin_dao/wrt-commons-security-origin-dao.pc.in b/build/security_origin_dao/wrt-commons-security-origin-dao.pc.in
new file mode 100644 (file)
index 0000000..2ab81cb
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+
+libdir=${prefix}/lib
+includedir=${prefix}/include
+Name: wrt-commons-security-origin-dao
+Description: wrt-commons-security-origin-dao
+
+Version: @VERSION@
+Requires: dpl-efl
+Libs: -lwrt-commons-security-origin-dao -L${libdir}
+Cflags: -I${includedir}/dpl-efl
index ea7df4b..3ef033f 100644 (file)
@@ -32,9 +32,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_SOCKET_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_SOCKET_INCLUDE_DIR}
     ${DPL_EVENT_INCLUDE_DIR}
-    ${SYS_EFL_SOCKET_INCLUDE_DIRS}
 )
 
 )
 
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_SOCKET_INCLUDE_DIRS})
+
 LINK_DIRECTORIES(
     ${SYS_EFL_SOCKET_LIBRARY_DIRS}
 )
 LINK_DIRECTORIES(
     ${SYS_EFL_SOCKET_LIBRARY_DIRS}
 )
@@ -54,19 +55,18 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_SOCKET_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_SOCKET_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_SOCKET_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_SOCKET_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_SOCKET_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_SOCKET_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_SOCKET_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_SOCKET_HEADERS}
         DESTINATION include/dpl-efl/dpl/socket)
 
 # Install pkgconfig script
 
 # Install detail headers
 INSTALL(FILES ${DPL_SOCKET_HEADERS}
         DESTINATION include/dpl-efl/dpl/socket)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-socket-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-socket-efl.pc)
diff --git a/build/socket/dpl-socket-efl.pc.in b/build/socket/dpl-socket-efl.pc.in
new file mode 100644 (file)
index 0000000..1e1409a
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-socket-efl
+Description: DPL Socket - EFL based
+Version: @VERSION@
+Requires: dpl-efl dpl-event-efl
+Libs: -L${libdir} -ldpl-socket-efl
+Cflags: -I${includedir}/dpl-efl
diff --git a/build/support/CMakeLists.txt b/build/support/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f0a67a4
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Lukasz Marek (l.marek@samsung.com)
+# @version     1.0
+# @brief
+#
+
+# Install headers
+INSTALL(FILES ${DPL_WRT_ENGINE_HEADERS}
+        DESTINATION include/dpl-efl/wrt-commons)
+
+# Install pkgconfig script
+configure_and_install_pkg(wrt-plugins-types.pc)
diff --git a/build/support/wrt-plugins-types.pc.in b/build/support/wrt-plugins-types.pc.in
new file mode 100644 (file)
index 0000000..b35b9b4
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: wrt-plugins-types
+Description: Header for plugins types
+Version: @VERSION@
+Requires:
+Libs:
+Cflags: -I${includedir}/dpl-efl/wrt-commons
index 22cb230..710fc4e 100644 (file)
@@ -29,9 +29,11 @@ INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_TEST_ENGINE_INCLUDE_DIR}
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_TEST_ENGINE_INCLUDE_DIR}
-    ${SYS_EFL_TEST_ENGINE_INCLUDE_DIRS}
+    ${DPL_UTILS_INCLUDE_DIR}
 )
 
 )
 
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_TEST_ENGINE_INCLUDE_DIRS})
+
 LINK_DIRECTORIES(
     ${SYS_EFL_TEST_ENGINE_LIBRARY_DIRS}
 )
 LINK_DIRECTORIES(
     ${SYS_EFL_TEST_ENGINE_LIBRARY_DIRS}
 )
@@ -45,23 +47,23 @@ ADD_LIBRARY(${TARGET_DPL_TEST_ENGINE_EFL} SHARED  ${DPL_TEST_ENGINE_SOURCES})
 
 TARGET_LINK_LIBRARIES(${TARGET_DPL_TEST_ENGINE_EFL}
     ${TARGET_DPL_EFL}
 
 TARGET_LINK_LIBRARIES(${TARGET_DPL_TEST_ENGINE_EFL}
     ${TARGET_DPL_EFL}
+    ${TARGET_DPL_UTILS_EFL}
 )
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_TEST_ENGINE_EFL} PROPERTIES
 )
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_TEST_ENGINE_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_TEST_ENGINE_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_TEST_ENGINE_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_TEST_ENGINE_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_TEST_ENGINE_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_TEST_ENGINE_HEADERS}
         DESTINATION include/dpl-efl/dpl/test)
 
 # Install pkgconfig script
 
 # Install detail headers
 INSTALL(FILES ${DPL_TEST_ENGINE_HEADERS}
         DESTINATION include/dpl-efl/dpl/test)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-test-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-test-efl.pc)
diff --git a/build/test/dpl-test-efl.pc.in b/build/test/dpl-test-efl.pc.in
new file mode 100644 (file)
index 0000000..9d6f871
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-test-efl
+Description: DPL Test Engine - EFL based
+Version: @VERSION@
+Requires: dpl-efl
+Libs: -L${libdir} -ldpl-test-efl
+Cflags: -I${includedir}/dpl-efl
index 6a4f875..ccc52ae 100644 (file)
@@ -33,10 +33,10 @@ INCLUDE_DIRECTORIES(
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_DB_INCLUDE_DIR}
     ${DPL_LOG_INCLUDE_DIR}
     ${DPL_CORE_INCLUDE_DIR}
     ${DPL_DB_INCLUDE_DIR}
-    ${SYS_EFL_UTILS_INCLUDE_DIRS}
     ${DPL_UTILS_INCLUDE_DIR}
     ${DPL_LOCALIZATION_INCLUDE_DIR}
 )
     ${DPL_UTILS_INCLUDE_DIR}
     ${DPL_LOCALIZATION_INCLUDE_DIR}
 )
+INCLUDE_DIRECTORIES(SYSTEM ${SYS_EFL_UTILS_INCLUDE_DIRS})
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/widget_dao/include)
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/vcore/src/vcore)
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/widget_dao/include)
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules/vcore/src/vcore)
@@ -64,14 +64,14 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_UTILS_EFL}
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_UTILS_EFL} PROPERTIES
 
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_UTILS_EFL} PROPERTIES
-    SOVERSION ${VERSION}
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_UTILS_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_UTILS_EFL}
     CLEAN_DIRECT_OUTPUT 1
     OUTPUT_NAME ${DPL_EFL_UTILS_LIBRARY})
 
 # Install libraries
 INSTALL(TARGETS ${TARGET_DPL_UTILS_EFL}
-        DESTINATION lib
-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+        DESTINATION lib)
 
 # Install detail headers
 INSTALL(FILES ${DPL_UTILS_HEADERS}
 
 # Install detail headers
 INSTALL(FILES ${DPL_UTILS_HEADERS}
@@ -81,5 +81,4 @@ INSTALL(FILES ${DPL_LOCALIZATION_HEADERS}
         DESTINATION include/dpl-efl/dpl/localization)
 
 # Install pkgconfig script
         DESTINATION include/dpl-efl/dpl/localization)
 
 # Install pkgconfig script
-INSTALL(FILES dpl-utils-efl.pc
-        DESTINATION lib/pkgconfig)
+configure_and_install_pkg(dpl-utils-efl.pc)
diff --git a/build/utils/dpl-utils-efl.pc.in b/build/utils/dpl-utils-efl.pc.in
new file mode 100644 (file)
index 0000000..8e1d4c9
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: dpl-utils-efl
+Description: DPL UTILS - EFL based
+Version: @VERSION@
+Requires: dpl-efl
+Libs: -L${libdir} -ldpl-utils-efl
+Cflags: -I${includedir}/dpl-efl
index 2703ae5..0590e56 100644 (file)
 # @brief
 #
 
 # @brief
 #
 
-CONFIGURE_FILE(dpl-wrt-dao-ro.pc.in dpl-wrt-dao-ro.pc @ONLY)
-CONFIGURE_FILE(dpl-wrt-dao-rw.pc.in dpl-wrt-dao-rw.pc @ONLY)
-INSTALL(FILES
-        ${CMAKE_BINARY_DIR}/build/widget_dao/dpl-wrt-dao-ro.pc
-        ${CMAKE_BINARY_DIR}/build/widget_dao/dpl-wrt-dao-rw.pc
-        DESTINATION
-        lib/pkgconfig)
+configure_and_install_pkg(dpl-wrt-dao-ro.pc)
+configure_and_install_pkg(dpl-wrt-dao-rw.pc)
index 6326243..3f1818c 100644 (file)
+wrt-commons (0.2.98) unstable; urgency=low
+
+  * wrt_commons_reset.sh fix
+  * User agent database update
+  * Compilation warnings. Deprecated code. Part 1
+  * Add function get appid from pkgid
+  * Source code formating unification
+  * Compilation warnings. Part 2
+  * Fix to test framework.
+  * DPL testcase description moved from wrt-extra
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 08 Feb 2013 18:18:31 +0900
+
+wrt-commons (0.2.97) unstable; urgency=low
+
+  * Support for "process per testcase" framework.
+  * Prepare database to support CSP policy for whole widget.
+  * minizip prevent issues fixes
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Wed, 06 Feb 2013 21:32:00 +0900
+
+wrt-commons (0.2.96) unstable; urgency=low
+
+  * Add specific fields to config parser struct for livebox
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.96
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 30 Jan 2013 17:09:01 +0900
+
+wrt-commons (0.2.95) unstable; urgency=low
+
+  * Change pkgname to appid and add package id PART 1.
+  * change pkgname to appid PART 2.
+  * Change pkgname to appid Part 3.
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 28 Jan 2013 17:41:56 +0900
+
+wrt-commons (0.2.94) unstable; urgency=low
+
+  * Revert "Change pkgname to appid and add package id PART 1."
+  * Revert "change pkgname to appid PART 2."
+  * Fix build break in tests after API has been changed.
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Fri, 25 Jan 2013 22:32:36 +0900
+
+wrt-commons (0.2.93) unstable; urgency=low
+
+  * Changed PkgName type from Optional<String> to String PART 5
+  * Support for GCC 4.7
+  * Removing hard-coding in ORDER BY statement
+  * Fixing saving locale for each icon
+  * Singleton guard thread removal
+  * Change pkgname to appid and add package id PART 1.
+  * change pkgname to appid PART 2.
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 24 Jan 2013 15:53:03 +0900
+
+wrt-commons (0.2.92) unstable; urgency=low
+
+  * Removal of popup implementation
+  * Clean up unnecessary cmake log
+  * Improve XML test results collector
+  * Add method for reset crossEventCallHandler
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 16 Jan 2013 10:49:45 +0900
+
+wrt-commons (0.2.91) unstable; urgency=low
+
+  * Fix issue Prevent Defect -17677
+  * Fixing issues: 17677
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.91
+
+ -- leerang <leerang.song@samsung.com>  Wed, 09 Jan 2013 18:03:04 +0900
+
+wrt-commons (0.2.90) unstable; urgency=low
+
+  * Changed PkgName type from DPL::Optional<DPL::String> to DPL::String. PART 4
+  * User agent database update
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 08 Jan 2013 11:12:49 +0900
+
+wrt-commons (0.2.89) unstable; urgency=low
+
+  * Handle return value from pthread_setspecific
+  * Deleted array to 0 comparison
+  * Deleted unreachable code
+  * Add vconf key for memory saving mode
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.89
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 02 Jan 2013 11:00:02 +0900
+
+wrt-commons (0.2.88) unstable; urgency=low
+
+  * Add path builder for vconf key
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.88
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Sat, 29 Dec 2012 14:02:18 +0900
+
+wrt-commons (0.2.87) unstable; urgency=low
+
+  * changed to get encryption/decryption key from device unique key
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.87
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 28 Dec 2012 20:47:21 +0900
+
+wrt-commons (0.2.86) unstable; urgency=low
+
+  * Revert "Modify get encryption/decryption key from device unique key"
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.86
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 28 Dec 2012 17:42:06 +0900
+
+wrt-commons (0.2.85) unstable; urgency=low
+
+  * For livebox configuration
+  * livebox configuration valuables have been changed
+  * Modify get encryption/decryption key from device unique key
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.85
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 28 Dec 2012 14:05:27 +0900
+
+wrt-commons (0.2.83) unstable; urgency=low
+
+  * Replacing widget handle with tizenid in property DAO
+
+ -- KEONGEUN <lke01.lee@samsung.com>  Fri, 21 Dec 2012 17:03:54 +0900
+
+wrt-commons (0.2.82) unstable; urgency=low
+
+  * CustomHandlersDB API updated to handle new functionalities.
+  * Add tests - DAO, DPL
+  * Custom Handlers DAO extended with new api
+  * registerWidgetSecuritySettings - nested transaction removal. New widget dao testcase
+  * Unit test for custom handler dao stub
+  * CustomHandlersDAO test
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.82
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 20 Dec 2012 09:04:59 +0900
+
+wrt-commons (0.2.81) unstable; urgency=low
+
+  * Fix dependencies in DAO modules
+  * Missing boilerplate added
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.81
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Sun, 16 Dec 2012 09:09:42 +0900
+
+wrt-commons (0.2.80) unstable; urgency=low
+
+  * Implement privilege database table
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.80
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 14 Dec 2012 10:30:48 +0900
+
+wrt-commons (0.2.79) unstable; urgency=low
+
+  * Replacing DbWidgetHandle with WidgetPkgName in SecurityOriginDAO
+  * Handle remove() return value
+  * Delete unreachable code
+  * Handle chmod return value
+  * CustomHandlerDAO implementation
+  * Unhandled isWidgetInstalled return value
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.79
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 13 Dec 2012 11:15:24 +0900
+
+wrt-commons (0.2.78) unstable; urgency=low
+
+  * Removing copy&paste code, part 2
+  * Changed SharedPtr to std:shared_ptr
+  * Changed ScopedPtr to std::unique_ptr
+  * Klocwork analysis related fix
+  * SharedFromTHis replace by STL C++0x ones
+  * Overload methods to run with tizen id instead of widgetHandle
+  * Changed PkgName type from DPL::Optional<DPL::String> to DPL::String
+  * Default "en" language tag removed from provider
+  * CustomHandlers DAO libraries stubs added
+  * Replacing widget handle with tizenid in property DAO
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.78
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 10 Dec 2012 10:11:26 +0900
+
+wrt-commons (0.2.76) unstable; urgency=low
+
+  * Add share directory
+  * Add category element for manifest.xml
+  * Modify installed path for preload widget.
+  * Updated widget resources path in wrt_reset_all.sh
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.76
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 30 Nov 2012 17:47:24 +0900
+
+wrt-commons (0.2.75) unstable; urgency=low
+
+  * Throw an exception when pthread_key_create fails
+  * Symbolic link pointed by GetVCoreDatabaseFilePath will be removed.
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.75
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Fri, 23 Nov 2012 22:01:00 +0900
+
+wrt-commons (0.2.74) unstable; urgency=low
+
+  * Removing copy&paste code, part 1
+  * Removal of factory_widget attribute and related functions
+  * Implement security origin dao for allow,deny one time
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.74
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 23 Nov 2012 10:09:27 +0900
+
+wrt-commons (0.2.73) unstable; urgency=low
+
+  * Distinguish between system headers and project headers
+  * Implement security origin dao for setting menu
+  * Implement security settings in the widgetDAO
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.73
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 22 Nov 2012 20:46:40 +0900
+
+wrt-commons (0.2.72) unstable; urgency=low
+
+  * Change widget installed path request by app fw
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.72
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Tue, 13 Nov 2012 17:16:16 +0900
+
+wrt-commons (0.2.71) unstable; urgency=low
+
+  * Implement Security origin database
+  * hidden symbol for enhancement shared library loading time (orm.h)
+  * Default widget locale adding to language tags
+  * WrtDAO clean up - unused function with widget handle usage
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.71
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 12 Nov 2012 16:55:19 +0900
+
+wrt-commons (0.2.70) unstable; urgency=low
+
+  * Additional Include: stddef.h
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.70
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 05 Nov 2012 17:43:04 +0900
+
+wrt-commons (0.2.69) unstable; urgency=low
+
+  * [Commons] Modify package type
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.69
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Mon, 05 Nov 2012 16:46:34 +0900
+
+wrt-commons (0.2.68) unstable; urgency=low
+
+  * Change profiling build
+  * Removing unused WtrUtilStringToLower
+  * Fix for localization URI ended with '/'
+  * Code refactoring and removal of factory_widget attribute
+  * WidgetDAO from WidgetHandle construction depracated
+  * WrtDAO - getPkgnameList
+  * Removal of compilation warnings
+  * W3c file localization - from pkgname construction
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.68
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 02 Nov 2012 11:20:52 +0900
+
+wrt-commons (0.2.67) unstable; urgency=low
+
+  * Localization cleaning from unused API (restore)
+  * Removing old, unused _WrtUtil* functions
+  * Database reset affects security-server
+  * Removing FileUtils
+  * Replacing recursive opendir with fts
+
+  * Release wrt-commons_0.2.67
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.67
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 24 Oct 2012 17:02:50 +0900
+
+wrt-commons (0.2.66) unstable; urgency=low
+
+  * Release wrt-commons_0.2.66
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.66
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Thu, 18 Oct 2012 11:33:54 +0900
+
+wrt-commons (0.2.65) unstable; urgency=low
+
+  * [Engine] Add method to get widget list
+  * [Commons] New utility functions in wrt_utility
+  * [Commons] Escaping bash sequences in argument programs
+  * [Engine] Allow to call methods using dao pointer
+  * [Engine] Remove mutex from log system.
+  * [Engine] Support for authors certificates (part 4).
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.65
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 17 Oct 2012 22:08:33 +0900
+
+wrt-commons (0.2.64) unstable; urgency=low
+
+  * Revert "Localization cleaning from unused API"
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.64
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 12 Oct 2012 14:21:43 +0900
+
+wrt-commons (0.2.63) unstable; urgency=low
+
+  * Support for authors certificate
+  * WidgetDAO new CTOR (based on TizenID)
+  * Localization related cleanup
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.63
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 11 Oct 2012 12:53:19 +0200
+
+wrt-commons (0.2.62) unstable; urgency=low
+
+  * [Engine] Add license installing
+  * [Engine] clean up .gitignore
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.62
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 11 Oct 2012 08:02:04 +0900
+
+wrt-commons (0.2.61) unstable; urgency=low
+
+  * [Commons] Support for Debug and Release build configuration
+  * Deprecated localization API removal
+  * Localization refactoring and cleaning
+  * [Commons] Refactoring featureDAO, pluginDAO table
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.61
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 05 Oct 2012 07:29:49 +0900
+
+wrt-commons (0.2.60) unstable; urgency=low
+
+  * for SEL verification
+  * [Commons] POWDER remains removed
+  * [Commons] Fixed PLM P120926-3287
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.60
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 28 Sep 2012 15:27:25 +0900
+
+wrt-commons (0.2.59) unstalbe; urgency=low
+
+  * Add smack manifest
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.59
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 20 Sep 2012 20:08:44 +0900
+
+wrt-commons (0.2.58) unstalbe; urgency=low
+
+  * for SEL verification
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.58
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 20 Sep 2012 12:02:41 +0900
+
+wrt-commons (0.2.57) unstalbe; urgency=low
+
+  * Proper list support in LanguageTagsProvider
+  * User Agent Database update
+  * Language tags providing class added
+  * Add a feature dao function giving requested features' data
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.57
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Wed, 19 Sep 2012 12:03:09 +0900
+
+wrt-commons (0.2.56) unstalbe; urgency=low
+
+  * [Commons] Test mode environment variable changed
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.56
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 12 Sep 2012 15:46:28 +0900
+
+wrt-commons (0.2.55) unstable; urgency=low
+
+  * [Commons] Table ExternalFiles renamed to ExternalLocations
+  * [Commons] Fix in base path removal in localization module.
+  * [Commons] Add multiple output types in test framework
+  * [Commons] Slash added to global config paths
+  * [Commons] Background page support in WidgetModel
+  * [Commons] New table - WidgetExternalFiles
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.55
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Thu, 06 Sep 2012 00:34:12 +0900
+
+wrt-commons (0.2.54) unstable; urgency=low
+
+  * [common] Add XML test collector
+  * [common] Add encryption api
+  * [Engine] Fix for wrt-popup
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.54
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 29 Aug 2012 13:37:28 +0900
+
+wrt-commons (0.2.53) unstable; urgency=low
+
+  * Added new build type for code coverage
+  * User Agent Database update
+  * Added new SQLConnection flag - CRW and null query check
+  * Remove "auto" for fixed build break
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.53
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 09 Aug 2012 15:16:30 +0900
+
+wrt-commons (0.2.52) unstable; urgency=low
+
+  * Re-upload package
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.52
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 31 Jul 2012 11:15:58 +0900
+
+wrt-commons (0.2.51) unstable; urgency=low
+
+  * Re-upload package
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.51
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 30 Jul 2012 10:06:49 +0900
+
+wrt-commons (0.2.50) unstable; urgency=low
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.50
+
+ -- Leerang Song <leerang.song@samsung.com>  Fri, 27 Jul 2012 12:02:06 +0900
+
+wrt-commons (0.2.49) unstable; urgency=low
+
+  * Add splash screen
+  * Fix circular dependency to cert-svc
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.49 
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Wed, 25 Jul 2012 14:36:40 +0200
+
+wrt-commons (0.2.48) unstable; urgency=low
+
+  * Fixed CCR(#N_SE-3620)
+  * FeatureDAOReadOnly - performance improvement
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.48
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 25 Jul 2012 09:58:22 +0900
+
+wrt-commons (0.2.47) unstable; urgency=low
+
+  * Change installed resource path & Add PackageType
+  * support tizen extension requirement regarding application id / required version
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.47
+
+ -- Leerang Song <leerang.song@samsung.com>  Thu, 19 Jul 2012 19:19:39 +0900
+
+wrt-commons (0.2.46-1) unstable; urgency=low
+
+  * Add tag for auto SR
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.46-1
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 12 Jul 2012 15:25:36 +0900
+
+wrt-commons (0.2.46) unstable; urgency=low
+
+  * Remove auto save for WK1
+  * Support auto save id/password for WK2
+  * Multiple INVALID_WIDGET_HANDLE definition
+  * Wrt DB DefferedWidgetPackageInstallation clean up
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.46
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 12 Jul 2012 10:56:48 +0900
+
+wrt-commons (0.2.45) unstable; urgency=low
+
+  * Fingerprint list should not contain empty strings
+  * Add frame load and unload callback
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.45
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 28 Jun 2012 16:30:53 +0900
+
+wrt-commons (0.2.44) unstable; urgency=low
+
+  * Move create directory("/opt/apps/widget/")
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.44
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 21 Jun 2012 11:13:38 +0900
+
+wrt-commons (0.2.43) unstable; urgency=low
+
+  * Remove WK1
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.43
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 19 Jun 2012 09:46:13 +0900
+
+wrt-commons (0.2.42) unstable; urgency=low
+
+  * Fix build break in wrt-security
+  * Remove warning when reset .wrt.db
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.42
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 15 Jun 2012 10:31:34 +0900
+
+wrt-commons (0.2.41) unstable; urgency=low
+
+  * Clean up unused api in FeatureDAO
+  * Nested loop removal
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.41
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 31 May 2012 11:40:41 +0900
+
+wrt-commons (0.2.40) unstable; urgency=low
+
+  * Unused code removal
+  * wrt_reset_all.sh changed to remove all widgets files
+  * Modify desktop default icon path for installer
+  * Add wrt-client prefix for wk2
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.40
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 24 May 2012 18:04:34 +0900
+
+wrt-commons (0.2.39) unstable; urgency=low
+
+  * Separated singleton implementation removal
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.39
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 21 May 2012 15:26:54 +0200
+
+wrt-commons (0.2.38) unstable; urgency=low
+
+  * Refactoring common_dao for auto_save
+  * ZipInput simplified
+  * Nested loop removall
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.38
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 21 May 2012 17:13:15 +0900
+
+wrt-commons (0.2.37) unstable; urgency=low
+
+  * Tests leftovers removal
+  * Remove unused DPL::MultiTaskDecl
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.37
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 17 May 2012 19:49:51 +0900
+
+wrt-commons (0.2.36) unstable; urgency=low
+
+  * Script to reset wrt (wrt_reset_all.sh)
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.36
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 14 May 2012 18:28:43 +0900
+
+wrt-commons (0.2.35) unstable; urgency=low
+
+  * Prepare widgetDAO to get different widget IDs
+  * depends on "add recovery mechanism.." commit
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.35
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 07 May 2012 17:35:10 +0900
+
+wrt-commons (0.2.34) unstable; urgency=low
+
+  * Patch for compliance test widget-api/NoInterfaceObject
+  * TLV pthread reference issue
+  * Changing WidgetDAO rw to ro permissions where appropriate
+  * JIL and WAC1.0 leftovers removal
+  * Widget StartFile localizedPath fix
+  * Switching to the TestModeFlag - final step
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.34
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 03 May 2012 10:11:41 +0900
+
+wrt-commons (0.2.33) unstable; urgency=low
+
+  * UserAgent locales removed
+  * Deprecated api removed
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.33
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 23 Apr 2012 14:10:21 +0900
+
+wrt-commons (0.2.32) unstable; urgency=low
+
+  * Language changed callback move to WRT engine
+  * Modify the access rights for Semaphore method
+  * Ultimate solution to test mode flag
+  * Web App data sharing From orange requirement
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.32
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 16 Apr 2012 09:48:09 +0900
+
+wrt-commons (0.2.31) unstable; urgency=low
+
+  * Mapping from features to device caps is obtained from .so
+  * Exposed pc file for wrt-plugin-export header
+  * Common environment test flag
+  * getUserAgentLocales added to WidgetDAOReadOnly
+  * TAP tests results collector
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.31
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 09 Apr 2012 10:25:57 +0900
+
+wrt-commons (0.2.30) unstable; urgency=low
+
+  * clean-up powder, parental mode
+  * Revert "[wrt-commons] Added global config API and desktop_file_name_field in wrt_db"
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.30
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Wed, 28 Mar 2012 18:25:06 +0900
+
+wrt-commons (0.2.29) unstable; urgency=low
+
+  * Change user name to user id
+  * Adding cookie sharing mode field
+  * Added global config API and desktop_file_name_field in wrt_db
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.29
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 27 Mar 2012 17:05:15 +0900
+
+wrt-commons (0.2.28) unstable; urgency=low
+
+  * Optimize OBS
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.28
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Fri, 23 Mar 2012 10:10:42 +0900
+
+wrt-commons (0.2.27) unstable; urgency=low
+
+  * add libxml2-dev to 'Depends' of wrt-commons-dev package 
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.27
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Mon, 19 Mar 2012 19:01:09 +0900
+
+wrt-commons (0.2.26) unstable; urgency=low
+
+  * Create ".wrt_autosave.db"
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.26
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 19 Mar 2012 13:31:14 +0900
+
+wrt-commons (0.2.25-1) unstable; urgency=low
+
+  * Apply changed EFL APIs 
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.25-1
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 14 Mar 2012 10:04:41 +0900
+
+wrt-commons (0.2.25) unstable; urgency=low
+
+  * Support OBS, SMACK
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.25
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Tue, 13 Mar 2012 19:51:25 +0900
+
+wrt-commons (0.2.24) unstable; urgency=low
+
+  * Clean-up heynoti depedency
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.24
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 06 Mar 2012 21:12:40 +0900
+
+wrt-commons (0.2.23) unstable; urgency=low
+
+  * Move certificates and finterprint settings from wrt-commons repository into wrt-security
+  * Add exception for "create directory"
+  * Clean-up unused event source
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.23
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 06 Mar 2012 20:29:32 +0900
+
+wrt-commons (0.2.22) unstable; urgency=low
+
+  * Modified libraries' names
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.22
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Tue, 28 Feb 2012 17:01:07 +0100
+
+wrt-commons (0.2.21) unstable; urgency=low
+
+  * Vcore and ACE removed
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.21
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Fri, 24 Feb 2012 16:51:27 +0100
+
+wrt-commons (0.2.20) unstable; urgency=low
+
+  * User Agent lists update
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.20
+
+ -- Hoseon LEE <hoseon46.lee@samsung.com>  Fri, 24 Feb 2012 09:28:47 +0100
+
+wrt-commons (0.2.19) unstable; urgency=low
+
+  * WAC Compliance test WL-3240 fix. 
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.19
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Wed, 22 Feb 2012 09:28:47 +0100
+
 wrt-commons (0.2.18) unstable; urgency=low
 
 wrt-commons (0.2.18) unstable; urgency=low
 
-  * Boilerplate update
+  * Fixed static dev cap setting.
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.18
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Wed, 22 Feb 2012 07:59:18 +0100
+
+wrt-commons (0.2.17) unstable; urgency=low
+
+  * WAC policy test suite bugfix.
+  
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.17
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Mon, 20 Feb 2012 14:05:41 +0100
+
+wrt-commons (0.2.16) unstable; urgency=low
+
+  * Localization API minor change
+  * test package reenabled
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.16
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 13 Feb 2012 16:04:58 +0100
+
+wrt-commons (0.2.15) unstable; urgency=low
+
+  * Tapi dependency added
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.15
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 13 Feb 2012 12:53:12 +0100
+
+wrt-commons (0.2.14) unstable; urgency=low
+
+  * MEID check added
+  * Added safe singleton implementation, that prevents dubletons.
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.14
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 13 Feb 2012 12:29:16 +0100
+
+wrt-commons (0.2.13) unstable; urgency=low
+
+  * Removing SLP, Bada ... strings for Source Open
+  * Update User-agent
+  * Popup manage initialization flag fixed
+  * Add weather widget is installed by package name
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.13
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 13 Feb 2012 10:46:30 +0100
+
+wrt-commons (0.2.12) unstable; urgency=low
+
+  * disabling test package to be build 
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.12
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Wed, 08 Feb 2012 17:45:57 +0100
+
+wrt-commons (0.2.11) unstable; urgency=low
+
+  * Ace and Vcore tests moved to wrt-commons
+  * "efl" suffic removed
+  * certificate names changes
+  * bugfix:
+  ** undetermined attributes
+  ** Attributes sorting algorithm
+  ** Vcore init
+  * New tests added (to OCSP)
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.11
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Wed, 08 Feb 2012 17:10:30 +0100
+
+wrt-commons (0.2.10) unstable; urgency=low
+
+  * Files access with FILE API bug fix
+  * Add global dao APIs for operation of white document list
+  * fixed WidgetDAO for ugid
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.10
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Thu, 02 Feb 2012 15:43:01 +0900
+
+wrt-commons (0.2.9) unstable; urgency=low
+
+  * Refactoring Phase2
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.9
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Tue, 31 Jan 2012 12:56:00 +0900
+
+wrt-commons (0.2.8) unstable; urgency=low
+
+  * documentation included to repository
+  * dbus fix (crash issue with bool type)
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.8
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Wed, 25 Jan 2012 14:47:21 +0100
+
+wrt-commons (0.2.7) unstable; urgency=low
+
+  * Debianize latest source
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.7
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 25 Jan 2012 10:30:05 +0900
+
+wrt-commons (0.2.6) unstable; urgency=low
+
+  * Wrt-commons split into several libraries
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.6
+
+ -- Grzegorz Krawczyk <g.krawczyk@samsung.com>  Fri, 20 Jan 2012 16:20:27 +0100
+
+wrt-commons (0.2.5) unstable; urgency=low
+
+  * DBUS module moved from wrt
+  * Dir structure has been changed (modules extracted)
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.5
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 17 Jan 2012 18:20:27 +0100
+
+wrt-commons (0.2.4) unstable; urgency=low
+
+  * Webkit2(Refactoring) branch merged
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.4
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 16 Jan 2012 15:57:06 +0900
+
+wrt-commons (0.2.3) unstable; urgency=low
+
+  * Webkit2(Refactoring) branch merged
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.3
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Mon, 16 Jan 2012 15:30:07 +0900
+
+wrt-commons (0.2.2) unstable; urgency=low
+
+  * Master and Webkit2 branch merged (ORM change merged)
+  * Mechanisms moved from wrt: NestedLoop, ScopedGPointer
+
+  * Git : slp/pkgs/w/wrt-commons
+  * Tag : wrt-commons_0.2.2
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 12 Jan 2012 11:19:00 +0100
+
+wrt-commons (0.2.1) unstable; urgency=low
+
+  * ORM interface changed
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : wrt-commons_0.2.1
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 12 Dec 2011 11:33:07 +0100
+
+wrt-commons (0.2.0) unstable; urgency=low
+
+  * Debianize for changing package name (wrt-commons)
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : wrt-commons_0.2.0
+
+ -- Hoseon LEE <hoseon46.lee@samsung.com>  Thu, 08 Dec 2011 10:51:40 +0900
+
+wrt-commons (0.1.65) unstable; urgency=low
+
+  * Debianize latest source
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.65
+
+ -- Hoseon LEE <hoseon46.lee@samsung.com>  Wed, 07 Dec 2011 12:11:02 +0900
+
+wrt-commons (0.1.64) unstable; urgency=low
+
+  * Fixes, FakeRPC connection added
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.64
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 29 Nov 2011 12:20:39 +0100
+
+dpl (0.1.63) unstable; urgency=low
+
+  * ThreadDatabase Support moved to dpl
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.63
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 22 Nov 2011 16:48:43 +0100
+
+dpl (0.1.62) unstable; urgency=low
+
+  * ICDelegate, apply, caller functions extended
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.62
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 17 Nov 2011 17:19:13 +0100
+
+dpl (0.1.61) unstable; urgency=low
+
+  * Adding ORM, Apply, ICD mechanism to DPL
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.61
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Wed, 09 Nov 2011 13:33:16 +0100
+
+dpl (0.1.60) unstable; urgency=low
+
+  * debianization due to icu upversioning
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.60
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 25 Oct 2011 10:40:26 +0200
+
+dpl (0.1.59) unstable; urgency=low
+
+  * modification of build option to build only EFL DPL package 
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.59
+
+ -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 07 Sep 2011 13:42:54 +0900
+
+dpl (0.1.58) unstable; urgency=low
+
+  * Debianized for open source 
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.58
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Tue, 06 Sep 2011 13:52:05 +0900
+
+dpl (0.1.57) unstable; urgency=low
+
+  * Waitables reloaded after HandleWatcher is called
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.57
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com>  Thu, 28 Jul 2011 11:35:42 +0200
+
+dpl (0.1.56) unstable; urgency=low
+
+  * add policyClass as template param, genericsocket fixed
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.56
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 27 Jun 2011 11:55:42 +0200
+
+dpl (0.1.55) unstable; urgency=low
+
+  * once, automatic listeners cleaning, property fix
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.55
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 14 Jun 2011 10:50:56 +0200
+
+dpl (0.1.54) unstable; urgency=low
+
+  * fix build dep
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.54
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 09 Jun 2011 14:12:31 +0200
+
+dpl (0.1.53) unstable; urgency=low
+
+  * scoped patterns extended, StringCompare with ICU
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.53
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 09 Jun 2011 12:50:44 +0200
+
+dpl (0.1.52) unstable; urgency=low
+
+  * scoped patterns extanded
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.52
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 06 Jun 2011 15:59:44 +0200
+
+dpl (0.1.51) unstable; urgency=low
+
+  * string errno, get/set virtual for property
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.51
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 06 Jun 2011 14:43:48 +0200
+
+dpl (0.1.50) unstable; urgency=low
+
+  * fix namespace, fix network change message publishing, 
+  * size functionality added int TypeLists
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.50
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 19 May 2011 15:06:39 +0200
+
+dpl (0.1.49) unstable; urgency=low
+
+  * license cleanup, small bug fixes
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.49
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 12 May 2011 12:57:54 +0200
+
+dpl (0.1.48) unstable; urgency=low
+
+  * MessageQueue, static remove for semaphores
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.48
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 22 Apr 2011 11:32:15 +0200
+
+dpl (0.1.47) unstable; urgency=low
+
+  * model/property system, TLS fixed
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.47
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 14 Apr 2011 14:35:38 +0200
+
+dpl (0.1.46) unstable; urgency=low
+
+  * delegate mechanism, sql connection, test runner fix
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.46
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 31 Mar 2011 10:18:22 +0200
+
+dpl (0.1.45) unstable; urgency=low
+
+  * ThreadLocal variables, named semaphore, Waitable fix,
+  * symbols visibility fix
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.45
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 21 Mar 2011 16:57:31 +0100
+
+dpl (0.1.44) unstable; urgency=low
+
+  * Disable Werror flag, bb fixed 
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.44
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Thu, 10 Mar 2011 21:06:51 +0900
+
+dpl (0.1.43) unstable; urgency=low
+
+  * ecore_main_loop_select_func_get return type changed
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.43
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 08 Mar 2011 11:05:54 +0900
+
+dpl (0.1.42) unstable; urgency=low
+
+  * MultiTask added. union_cast, lexical_cast
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.42
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 04 Mar 2011 14:05:23 +0100
+
+dpl (0.1.41) unstable; urgency=low
+
+  * klocwork fixes, release method added to scoped array
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.41
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 01 Mar 2011 09:38:53 +0100
+
+dpl (0.1.40) unstable; urgency=low
+
+  * Zip-input fixed.
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.40
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 28 Feb 2011 10:42:44 +0100
+
+dpl (0.1.39-1) unstable; urgency=low
+
+  * redebianized
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.39-1
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 25 Feb 2011 09:33:12 +0100
+
+dpl (0.1.39) unstable; urgency=low
+
+  * Semaphore added, Mutex fixed, Zip enhanced
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.39
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 22 Feb 2011 09:54:11 +0100
+
+dpl (0.1.38) unstable; urgency=low
+
+  * GetCurrentTask, EventDispatcher fix, Append for DPL::String
+  * Zip file support
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.38
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 15 Feb 2011 17:52:24 +0100
+
+dpl (0.1.37-1) unstable; urgency=low
+
+  * redebianize
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.37-1
 
 
-  * Git : tizen2/pkgs/w/wrt-commons
-  * Tag : wrt-commons_0.2.18
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 04 Feb 2011 11:11:13 +0100
 
 
- -- Tae-Jeong Lee <taejeong.lee@samsung.com>  Thu, 23 Feb 2012 16:12:49 +0900
+dpl (0.1.37) unstable; urgency=low
 
 
-wrt-commons (0.2.17) unstable; urgency=low
+  * EventSupport fixes.
 
 
-  * debianize
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.37
 
 
-  * Git : tizen2/pkgs/w/wrt-commons
-  * Tag : wrt-commons_0.2.17
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Thu, 03 Feb 2011 17:44:49 +0100
 
 
- -- Yunchan Cho <yunchan.cho@samsung.com>  Wed, 22 Feb 2012 16:57:31 +0900
+dpl (0.1.36) unstable; urgency=low
 
 
-wrt-commons (0.2.16) unstable; urgency=low
+  * header fix.
 
 
-  * Init changelog
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.36
 
 
-  * Git : tizen2/pkgs/w/wrt-commons
-  * Tag : wrt-commons_0.2.16
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 01 Feb 2011 12:19:53 +0100
+
+dpl (0.1.35-1) unstable; urgency=low
+
+  * debianization fix.
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.35-1
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 01 Feb 2011 09:58:40 +0100
+
+dpl (0.1.35) unstable; urgency=low
+
+  * DPL::CharTraits fixed
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.35
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 01 Feb 2011 09:46:04 +0100
+
+dpl (0.1.34) unstable; urgency=low
+
+  * bundled value usage added.
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.34
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 28 Jan 2011 14:13:03 +0100
+
+dpl (0.1.33) unstable; urgency=low
+
+  * Synchronized events support.
+  * FOREACH macro.
+  * BinaryQueue reimplementation
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.33
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 21 Jan 2011 10:43:38 +0100
+
+dpl (0.1.32-3) unstable; urgency=low
+
+  * dpl path fix
+
+  * Git : 165.213.180.234:slp/pkgs/d/dpl
+  * Tag : dpl_0.1.32-3
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 11 Jan 2011 18:19:25 +0100
+
+dpl (0.1.32-2) unstable; urgency=low
+
+  * build break fixed
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.32-2
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 11 Jan 2011 17:29:55 +0100
+
+dpl (0.1.32-1) unstable; urgency=low
+
+  * redebianizing
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.32-1
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 11 Jan 2011 12:46:19 +0100
+
+dpl (0.1.32) unstable; urgency=low
+
+  * moving vconf header to dirty headers
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.32
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 10 Jan 2011 10:13:07 +0100
+
+dpl (0.1.31) unstable; urgency=low
+
+  * debianized - 0.1.31
+  
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.31
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Wed, 08 Dec 2010 20:22:25 +0900
+
+dpl (0.1.30-2) unstable; urgency=low
+
+  * debianized - 0.1.30-2
+  * Ignored category for test runner
+  * TypeListGenerator to TypeListDecl
+  
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.30-2
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Mon, 15 Nov 2010 16:00:52 +0900
+
+dpl (0.1.30) unstable; urgency=low
+
+  * Ignored category for test runner
+
+ -- Przemyslaw Dobrowolski <p.dobrowolsk@samsung.com>  Fri, 12 Nov 2010 14:55:15 +0100
+
+dpl (0.1.29) unstable; urgency=low
+
+  * Renamed TypeListGenerator to TypeListDecl
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.29
+
+ -- Przemyslaw Dobrowolski <p.dobrowolsk@samsung.com>  Fri, 12 Nov 2010 14:14:54 +0100
+
+dpl (0.1.28) unstable; urgency=low
+
+  * New controller mechanism 
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.28
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Fri, 12 Nov 2010 12:22:01 +0100
+
+dpl (0.1.27) unstable; urgency=low
+
+  * Added threads' guarded singletons
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.27
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 09 Nov 2010 10:13:16 +0100
+
+dpl (0.1.26) unstable; urgency=low
+
+  * Bug fixes
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.26
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Mon, 08 Nov 2010 14:43:15 +0100
+
+ dpl (0.1.25-1) unstable; urgency=low
+
+  * Redebianized.
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.25-1
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Thu, 28 Oct 2010 12:12:45 +0900
+
+dpl (0.1.25) unstable; urgency=low
+
+  * Fixed exception handing while parsing RPC protocol
+  * commit : a19efed5a210fb1f8f91de18009b0d86e03326db
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.25
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Mon, 25 Oct 2010 15:21:48 +0900
+
+
+dpl (0.1.24) unstable; urgency=low
+
+  * Added 21 Controler support
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.24
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Wed, 20 Oct 2010 16:15:42 +0200
+
+dpl (0.1.23) unstable; urgency=low
+
+  * Reverted: main event dispatcher fix
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.23
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Wed, 13 Oct 2010 11:09:48 +0200
+
+dpl (0.1.22-1) unstable; urgency=low
+
+  * Main event dispatcher fix
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.22-1
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Fri, 08 Oct 2010 16:17:51 +0200
+
+dpl (0.1.22) unstable; urgency=low
+
+  * Main event dispatcher fix
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.22 
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Fri, 08 Oct 2010 14:45:45 +0200
+
+dpl (0.1.21) unstable; urgency=low
+
+  * Fixed RPC bug which caused white screen
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.21
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Thu, 07 Oct 2010 12:17:18 +0200
+
+dpl (0.1.20-1) unstable; urgency=low
+
+  * Reupload to fix debianization error (again)
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.20-1
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Wed, 06 Oct 2010 15:07:32 +0200
+
+dpl (0.1.19) unstable; urgency=low
+
+  * Fixed bug in generic RPC protocol parser & package name is changed(svn is removed)
+  
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.19
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Thu, 30 Sep 2010 19:17:20 +0900
+
+dpl (0.1.18) unstable; urgency=low
+
+  * support string conversion (i18n) and char traits
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.18
+
+ -- Ming Jin <ming79.jin@samsung.com>  Fri, 17 Sep 2010 14:32:23 +0900
+
+dpl (0.1.17) unstable; urgency=low
+
+  * Upgrade to EFL1.0 alpha 
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.17
+
+ -- Piotr Fatyga <p.fatyga@samsung.com>  Fri, 10 Sep 2010 17:41:55 +0200
+
+dpl (0.1.16) unstable; urgency=low
+
+  * changed assert routine. Building changed to Release. 
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.16
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Wed, 01 Sep 2010 11:39:41 +0200
+
+dpl (0.1.15) unstable; urgency=low
+
+  * Hibernation fixed 
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.15
+  
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 31 Aug 2010 19:00:52 +0200
+
+dpl (0.1.14) unstable; urgency=low
+
+  * Improvements in shared ptr, logging mechanism and unit testing
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.14
+
+ -- Pawel Sikorski <p.sikorski@samsung.com>  Tue, 24 Aug 2010 09:59:48 +0200
+
+dpl (0.1.12) unstable; urgency=low
+
+  * Fixed problem with bool operator in smart pointers
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.12
+
+ -- Przemyslaw Dobrowolski <p.dobrowolsk@samsung.com>  Wed, 18 Aug 2010 11:01:52 +0200
+
+dpl (0.1.11) unstable; urgency=low
+
+  * appcore updated 
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.11
+  
+ -- Koeun Choi <koeun.choi@samsung.com>  Fri, 06 Aug 2010 10:28:44 +0900
+
+dpl (0.1.10) unstable; urgency=low
+
+  * Added support for handling late EFL events
+
+  * Git : 165.213.180.234:/git/slp/pkgs/dpl
+  * Tag : dpl_0.1.10
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 03 Aug 2010 19:34:53 +0900
+
+dpl (0.1.9) unstable; urgency=low
+
+  * Fixed bug in shared pointer copy operator
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.9
+
+ -- Andrew Lee <hyunchul2.lee@samsung.com>  Mon, 12 Jul 2010 13:54:01 +0900
+
+dpl (0.1.8) unstable; urgency=low
+
+  * Fixed prevent defects
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.8
+
+ -- Andrew Lee <hyunchul2.lee@samsung.com>  Tue, 22 Jun 2010 12:14:32 +0900
+
+dpl (0.1.7) unstable; urgency=low
+
+  * DLOG API change update 
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.7
+
+ -- Ming Jin <ming79.jin@samsung.com>  Wed, 16 Jun 2010 17:00:00 +0900
+
+dpl (0.1.6-1) unstable; urgency=low
+
+  * Strange tag verification error.
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.6-1
+
+ -- Andrew Lee <hyunchul2.lee@samsung.com>  Fri, 11 Jun 2010 11:37:41 +0900
+
+dpl (0.1.6) unstable; urgency=low
+
+  * Repackaging due to efl update.
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.6
+
+ -- Andrew Lee <hyunchul2.lee@samsung.com>  Fri, 11 Jun 2010 09:38:01 +0900
+
+dpl (0.1.5) unstable; urgency=low
+
+  * Changed usage of deprecated appfwk to appcore-efl
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.5
+ -- Andrew Lee <hyunchul2.lee@samsung.com>  Tue, 08 Jun 2010 19:11:38 +0900
+
+dpl (0.1.4) unstable; urgency=low
+
+  * appfwk api removed
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.4
+
+ -- Andrew Lee <hyunchul2.lee@samsung.com>  Fri, 04 Jun 2010 11:22:28 +0900
+
+dpl (0.1.3) unstable; urgency=low
+
+  * single instance locking mechanism supported 
+  
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.3
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Wed, 19 May 2010 20:19:00 +0900
+
+dpl (0.1.2) unstable; urgency=low
+
+  * HIBERNATION_LEAVE_BEFORE_WS added 
+  
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.2
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 18 May 2010 08:27:14 +0900
+
+dpl (0.1.1) unstable; urgency=low
+
+  * permission changed by new SLP security guideline  
+  
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.1
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Fri, 14 May 2010 14:07:16 +0900
+
+dpl (0.1.0) unstable; urgency=medium
+
+  * below details are written by Przemek. :)
+
+  * Added main window visibility optional flag to application class.
+
+  * Removed debug logs from application (switched to pedantic ones)
+    Fixed close sequence in RPC example
+
+  * Fixed critical leak in rpc connection related to acquisition of abstract waitable input/output.
+
+  * Added RPC Client/Server example
+
+  * Removed useParam from ConnectionEstablished event in RPC Server/Client
+    Added ConnectionID to ConnectionEstablishedEvent in RPC Server/Client
+    Added convience Open methods to (Tcp/Unix)SocketRPC(Server/Client)
+
+  * Removed purpose-specific static call code.
+
+  * Added implementation of GenericSocketRPCServer, TcpSocketRPCServer, UnixSocketRPCServer.
+
+  * Implementation in progress: Client/Server architecture for RPC - client and connection part.
+
+  * Temporary fix to build break caused by problems with in DLOG include files
+
+  * Fixed unregister global noti signal routine
+
+  * Added dedicated RPCFunction include file
+    All current RPC mechanisms marked as deprecated
+    Added RPC Client/Server/Connection stub files
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.1.0
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Fri, 07 May 2010 11:10:09 +0200
+
+dpl (0.0.9) unstable; urgency=low
+
+  * HibernationEnter and HibernationLeave system events added to EventDeliverySystem
+
+  * Added support for old style pedantic logs
+
+  * Added initial support (i386,gcc) for dynamically created static methods (static interception)
+
+  * Added protocol argument size checks in RPC
+
+  * Fixed non-reentrant version of serialized string parser in EventDeliverySystem
+
+  * Fixed multiple event handling routines to return all signaled handles list (starvation related fix)
+
+  * Workaround definition file added. Moved GLIB-loop-intergration workaround to workaround definition file.
+
+  * Fixed typo in exception messages
+
+  * Workaround for SLP select
+
+  * Added postinstallation scripts for EFL and GTL version of DPL
+
+  * Fixed bug related to improper reinitialization of socket descriptor after Close/Open sequence
+
+  * Added GenericSocketRPC
+    Added TcpSocketRPC
+    Implementation of UnixSocketRPC rebased to GenericSocketRPC
+    Fixed template-based problems with declaring nested generic exceptions
+
+  * Added support for old style plain logs (export DPL_USE_OLD_STYLE_LOGS=1)
+
+  * Fixed bug in WaitableInputOutputExecutionContextSupport related to continous event insisting
+    Fixed bug in WaitableHandle related to improper handling of Read/Write events
+    Added support for retrieving other errors in WatableHandle
+    Added runtime-check for invalid WaitableHandles
+
+  * Fixed DPL debug package name
+
+  * More DPL doxygen documentation added.
+
+  * Added more tests for BinaryQueue (21)
+    Added doxygen documentation for BinaryQueue
+
+  * BinaryQueue basic unit tests added (13)
+
+  * Added generic framework for unit-testing for DPL
+
+  * Added support for handling manipulations with waitable handle watcher/listeners lists during event handling
+    Added TcpSocket
+    Added tcpsock example
+    Added support for defining maximum number of bytes to read in AbstractInput
+    Added support for DNS resolve for tcp Address
+
+  * Added support for retrieving doubles from database in SqlConnection.
+    Added exceptions on retrieving column out of bounds.
+
+  * Added support for retrieveing last insert row ID in SqlConnnection (reported by b.grzelewski)
+
+  * Fixed bug in GenericRPC related to inproper interpretation of incoming data stream (reported by p.sikorski)
+
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.0.8
+
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Thu, 29 Apr 2010 17:41:02 +0200
+
+dpl (0.0.8) unstable; urgency=medium
+
+  * debianized : commit 210d5f7ecd396ff9aeeafcb0d34272a4c4e6c77d 
+  
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.0.8
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Fri, 23 Apr 2010 00:51:27 +0900
+
+dpl (0.0.7) unstable; urgency=low
+
+  * debianized  
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/dpl-0
+  * Tag : dpl_0.0.7
+  
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 20 Apr 2010 14:16:18 +0900
+
+dpl (0.0.6) unstable; urgency=medium
+
+  * LogSystem switched to DLOG
+
+  * Initial support for Application in gtk version added
+
+  * Fixed link problems in example projects build scripts
+
+  * Added missing sender in events from GenericSocket
+
+  * Added missing dependencies to db-util in pkgconfig files
+
+  * Fixed memory leak in MainEventDispatcher for EFL, related to timed events (reported by valgrind)
+
+  * Fixed memory leak in Thread event list (reported by valgrind)
+
+  * Minimum version of libslp-setting-0 defined (reported by p.misiak)
+
+  * Fixed bug in UnixSocketRPC in scenario when cannot connect (reported by p.sikorski)
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Fri, 16 Apr 2010 11:08:46 +0200
+
+dpl (0.0.5) unstable; urgency=high
+
+  * Minimum required version od db-util changed to 0.1.0-23 due to link problems
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Thu, 15 Apr 2010 08:28:08 +0200
+
+dpl (0.0.4) unstable; urgency=medium
+
+  * SQLConnection: Added support for Lucene indexer
+
+  * Replaced deprecated API from vconf and util in EventDeliveryDetail for EFL
+
+  * Added doxygen configuration file
+    Added deprecated DPL declarator file
+    Added support for handling broken connections in GenericSocket and RPC
+
+  * DLOG: dlog_init/dlog_deinit is not needed and deprecated. Removed.
+
+  * Fixed bug related to multiple close/connect on socket (reported by p.sikorski)
+
+  * Reference manual stub added
+
+  * Added WaitableInputOutputExecutionContextSupport
+    Various bugfixes related to WaitableHandleSupport
+    Added RPC ClosedEvent support
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Wed, 14 Apr 2010 14:27:54 +0200
+
+dpl (0.0.3) unstable; urgency=low
+
+  * Experimental RPC over unix-sockets added.
+
+  * Fixed bug in Main. Various bugfixes in UnixSocket and GenericSocket. GenericRPC implementation in progress
+
+  * Removed NamedPipeRPCCall
+    Added UnixSocketRPC
+    Renaming RPCCall -> RPC
+
+  * GenericSocket implementation finished
+
+  * Generic socket implementation in progress.
+    Added DPL debug package
+
+  * Added Main
+
+  * Fixed DPL-GTK library dependency problem
+
+  * Added WaitableHandleWatchSupport
+
+  * Fixed BUG in EFL-MainEventDispatcher, regarding too late deinitialization
+
+  * Fixed bug in controller touch check assertions.
+    Generic socket implementation in progress.
+
+  * Added support for mode in waitable handle wait procedures.
+    Added support for multi-mode watchers in thread.
+    Added UnixSocket implementation.
+    Added GenericSocket implementation.
+    Added AbstractSocket.
+    Added Address concept.
+    Added example socket test program.
+
+  * Controller extended to handle maximum of 20 events
+
+  * Added WaitableHandle
+
+  * Added AbstractWaitableInput, AbstractWaitableOutput, AbstractWaitableInputOutput,
+    NamedBasePipe, NamedInputPipe, NamedOutputPipe, partial implementation of GenericRPCCall,
+    full implementation of NamedPipeRPCCall
+
+  * Added NamedPipe (blocking mode)
+
+  * Added AbstractInput, AbstractOutput, AbstractInputOutput, NamedPipe stub, GenericRPCCall stub
+
+  * Added RecursiveMutex.
+    Added support for waitable event watchers in Thread.
+
+  * Added BinaryQueue
+
+  * Debian/changelog updated
+
+  * Fixed build-depends
+
+  * Package build dependencies defined properly
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Thu, 08 Apr 2010 15:54:02 +0200
+
+dpl (0.0.2) unstable; urgency=low
+
+  * Toolchain upgrades and fixes
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 23 Mar 2010 11:40:32 +0100
+
+dpl (0.0.1) unstable; urgency=low
+
+  * Initial release
+
+ -- Koeun Choi <koeun.choi@samsung.com>  Tue, 23 Mar 2010 11:40:32 +0100
 
 
- -- Pawel Sikorski <p.sikorski@samsung.com>  Mon, 13 Feb 2012 16:04:58 +0100
index a786fd3..e8aeeed 100644 (file)
@@ -4,9 +4,9 @@ Priority: extra
 Maintainer: Lukasz Wrzosek<l.wrzosek@samsung.com>,  Taejeong.lee <taejeong.lee@samsung.com>
 Standards-Version: 3.7.2
 Uploaders: Yunchan Cho <yunchan.cho@samsung.com>,Przemyslaw Dobrowolski <p.dobrowolsk@samsung.com>, Pawel Sikorski <p.sikorski@samsung.com>, Zbigniew Kostrzewa <z.kostrzewa@samsung.com>
 Maintainer: Lukasz Wrzosek<l.wrzosek@samsung.com>,  Taejeong.lee <taejeong.lee@samsung.com>
 Standards-Version: 3.7.2
 Uploaders: Yunchan Cho <yunchan.cho@samsung.com>,Przemyslaw Dobrowolski <p.dobrowolsk@samsung.com>, Pawel Sikorski <p.sikorski@samsung.com>, Zbigniew Kostrzewa <z.kostrzewa@samsung.com>
-Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libheynoti-dev, libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), zlib1g-dev, libpcre-dev, libicu-dev, libxmlsec1-dev, openssl, libxml2-dev, libsoup2.4-dev, libcert-svc-dev, libiri-dev, libidn11-dev, libslp-tapi-dev
+Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), zlib1g-dev, libpcre-dev, libicu-dev, libxmlsec1-dev, openssl, libxml2-dev, libsoup2.4-dev, libiri-dev, libidn11-dev
 # If you want to build version of gtk, comment out above one live and use the following one line
 # If you want to build version of gtk, comment out above one live and use the following one line
-#Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libheynoti-dev, libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), libgtk2.0-dev, zlib1g-dev, libpcre-dev, libicu-dev
+#Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), libgtk2.0-dev, zlib1g-dev, libpcre-dev, libicu-dev
 
 Package: wrt-commons
 Section: libs
 
 Package: wrt-commons
 Section: libs
@@ -35,7 +35,7 @@ Provides: dpl-efl-dev
 Conflicts: dpl-efl-dev
 Replaces: dpl-efl-dev
 Architecture: any
 Conflicts: dpl-efl-dev
 Replaces: dpl-efl-dev
 Architecture: any
-Depends: wrt-commons (= ${Source-Version}), libecore-dev, libslp-setting-dev (>=0.2.5-2), libheynoti-dev, libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libslp-db-util-dev (>= 0.1.0-23), zlib1g-dev, libpcre-dev
+Depends: wrt-commons (= ${Source-Version}), libecore-dev, libslp-setting-dev (>=0.2.5-2), libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libslp-db-util-dev (>= 0.1.0-23), zlib1g-dev, libpcre-dev, libxml2-dev
 Description: Design patterns library - EFL based developer files
  Design patterns library is a collection of useful C++ utilities
  to easily develop window applications. The most important part of
 Description: Design patterns library - EFL based developer files
  Design patterns library is a collection of useful C++ utilities
  to easily develop window applications. The most important part of
index 3c1584f..12505a7 100755 (executable)
@@ -1,30 +1,26 @@
 #!/usr/bin/make -f
 
 #export DH_VERBOSE=1
 #!/usr/bin/make -f
 
 #export DH_VERBOSE=1
-PACKAGE_VERSION ?= $(shell sed -n "1 p" debian/changelog | sed 's/.*([0-9]*.\([0-9]*\).*).*/\1/')
-CFLAGS = -Wall -g
-LDFLAGS = -Wl,--as-needed -Wl,--hash-style=both 
+PACKAGE_VERSION ?= $(shell dpkg-parsechangelog | sed -n 's/^Version: // p')
 
 
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
+ifneq (,$(findstring yes,$(DPL_LOGS)))
+DPL_LOGS_STATUS = "ON"
 else
 else
-       CFLAGS += -O2
-endif
-
-ifneq (,$(findstring yes,$(DPL_LOG)))
-       DPL_LOGS_STATUS = "ON"
-else
-       DPL_LOGS_STATUS = "OFF"
+DPL_LOGS_STATUS = "OFF"
 endif
 
 BUILD_DIR = cmake-build
 
 configure: configure-stamp
 configure-stamp:
 endif
 
 BUILD_DIR = cmake-build
 
 configure: configure-stamp
 configure-stamp:
-       dh_testdir      
+       dh_testdir
        rm -rf $(BUILD_DIR)
        mkdir $(BUILD_DIR)
        rm -rf $(BUILD_DIR)
        mkdir $(BUILD_DIR)
-       ( cd $(BUILD_DIR); cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DDPL_LOG=$(DPL_LOGS_STATUS) -DVERSION=${PACKAGE_VERSION}; )
+       ( cd $(BUILD_DIR); cmake ..          \
+                -DCMAKE_INSTALL_PREFIX=/usr  \
+                -DDPL_LOG=$(DPL_LOGS_STATUS) \
+               -DVERSION=${PACKAGE_VERSION};)
+
        touch configure-stamp
 
 build: build-stamp
        touch configure-stamp
 
 build: build-stamp
index dce5a2d..e35c8f5 100644 (file)
@@ -1,10 +1,4 @@
 usr/lib/*.so*
 /usr/share/wrt-engine/*
 usr/lib/*.so*
 /usr/share/wrt-engine/*
-/usr/bin/wrt_reset_db.sh
-/usr/bin/wrt_create_clean_db.sh
-/usr/etc/ace/config*
-/usr/etc/ace/bondixml*
-/usr/etc/ace/demo.*
-/usr/etc/ace/WACPolicy.xml
-/usr/etc/ace/UnrestrictedPolicy.xml
-/opt/share/cert-svc/certs/code-signing/wac/*
+/usr/bin/wrt_commons_reset_db.sh
+/usr/bin/wrt_commons_create_clean_db.sh
index ed20a1f..5cadde4 100755 (executable)
@@ -2,45 +2,41 @@
 
 if [ -z ${2} ]; then
     echo "This is new install of wrt-commons"
 
 if [ -z ${2} ]; then
     echo "This is new install of wrt-commons"
-    echo "Calling /usr/bin/wrt_reset_db.sh"
-    /usr/bin/wrt_reset_db.sh
+    echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+    /usr/bin/wrt_commons_reset_db.sh
 else
     # Find out old and new version of databases
     WRT_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt.db ".tables" | grep "DB_VERSION_"`
     WRT_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
 else
     # Find out old and new version of databases
     WRT_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt.db ".tables" | grep "DB_VERSION_"`
     WRT_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
-    ACE_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.ace.db ".tables" | grep "DB_VERSION_"`
-    ACE_NEW_DB_VERSION=`cat /usr/share/wrt-engine/ace_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
-    VCORE_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.vcore.db ".tables" | grep "DB_VERSION_"`
-    VCORE_NEW_DB_VERSION=`cat /usr/share/wrt-engine/vcore_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
+    AUTOSAVE_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt_autosave.db ".tables" | grep "DB_VERSION_"`
+    AUTOSAVE_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_autosave_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
+    CUSTOM_HANDLER_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt_custom_handler.db ".tables" | grep "DB_VERSION_"`
+    CUSTOM_HANDLER_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_custom_handler_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
     echo "OLD wrt database version ${WRT_OLD_DB_VERSION}"
     echo "NEW wrt database version ${WRT_NEW_DB_VERSION}"
     echo "OLD wrt database version ${WRT_OLD_DB_VERSION}"
     echo "NEW wrt database version ${WRT_NEW_DB_VERSION}"
-    echo "OLD ace database version ${ACE_OLD_DB_VERSION}"
-    echo "NEW ace database version ${ACE_NEW_DB_VERSION}"
-    echo "OLD vcore database version ${VCORE_OLD_DB_VERSION}"
-    echo "NEW vcore database version ${VCORE_NEW_DB_VERSION}"
+    echo "OLD wrt_autosave database version ${AUTOSAVE_OLD_DB_VERSION}"
+    echo "NEW wrt_autosave database version ${AUTOSAVE_NEW_DB_VERSION}"
+    echo "OLD wrt_custom_handler database version ${CUSTOM_HANDLER_OLD_DB_VERSION}"
+    echo "NEW wrt_custom_handler database version ${CUSTOM_HANDLER_NEW_DB_VERSION}"
 
 
-
-    if [ ${WRT_OLD_DB_VERSION} -a ${WRT_NEW_DB_VERSION} -a ${ACE_OLD_DB_VERSION} -a ${ACE_NEW_DB_VERSION} -a ${VCORE_OLD_DB_VERSION} -a ${VCORE_NEW_DB_VERSION} ]
+    if [ ${WRT_OLD_DB_VERSION} -a ${WRT_NEW_DB_VERSION} -a ${AUTOSAVE_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} -a ${CUSTOM_HANDLER_OLD_DB_VERSION} -a ${CUSTOM_HANDLER_NEW_DB_VERSION}]
     then
     then
-        if [ ${WRT_NEW_DB_VERSION} = ${WRT_OLD_DB_VERSION} -a ${ACE_NEW_DB_VERSION} = ${ACE_OLD_DB_VERSION} -a ${VCORE_OLD_DB_VERSION} = ${VCORE_NEW_DB_VERSION} ]
+        if [ ${WRT_NEW_DB_VERSION} = ${WRT_OLD_DB_VERSION} -a ${AUTOSAVE_NEW_DB_VERSION} = ${AUTOSAVE_OLD_DB_VERSION} -a ${CUSTOM_HANDLER_NEW_DB_VERSION} = ${CUSTOM_HANDLER_OLD_DB_VERSION}]
         then
             echo "Equal database detected so db installation ignored"
         else
         then
             echo "Equal database detected so db installation ignored"
         else
-            echo "Calling /usr/bin/wrt_reset_db.sh"
-            /usr/bin/wrt_reset_db.sh
+            echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+            /usr/bin/wrt_commons_reset_db.sh
         fi
     else
         fi
     else
-        echo "Calling /usr/bin/wrt_reset_db.sh"
-        /usr/bin/wrt_reset_db.sh
+        echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+        /usr/bin/wrt_commons_reset_db.sh
     fi
 fi
 
 mkdir -p /usr/etc/ace
 mkdir -p /usr/apps/org.tizen.policy
 
     fi
 fi
 
 mkdir -p /usr/etc/ace
 mkdir -p /usr/apps/org.tizen.policy
 
-# 3. configurations
-chown root:root /usr/etc/ace/config.xml
-
 # DBUS services fix
 # WARNING: THIS IS TEMPORARY SOLUTION, AS THIS SHOULD NOT BE OUR
 # RESPONSIBILITY!!! WE HAVE TO CONTACT TO DBUS MAINAINERS
 # DBUS services fix
 # WARNING: THIS IS TEMPORARY SOLUTION, AS THIS SHOULD NOT BE OUR
 # RESPONSIBILITY!!! WE HAVE TO CONTACT TO DBUS MAINAINERS
index a1fc0f0..13eb011 100755 (executable)
@@ -1,4 +1,18 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
+# Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
 
 import os
 import re
 
 import os
 import re
index 3eab79c..f3436e6 100644 (file)
@@ -2,24 +2,7 @@
 SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc)
 
 INSTALL(FILES
 SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc)
 
 INSTALL(FILES
-    ${ETC_DIR}/wrt_reset_db.sh
-    ${ETC_DIR}/wrt_create_clean_db.sh
+    ${ETC_DIR}/wrt_commons_reset_db.sh
+    ${ETC_DIR}/wrt_commons_create_clean_db.sh
     DESTINATION /usr/bin
     )
     DESTINATION /usr/bin
     )
-
-INSTALL(FILES
-    ${ETC_DIR}/schema.xsd
-    DESTINATION share/wrt-engine
-    )
-
-INSTALL(FILES
-    ${ETC_DIR}/fingerprint_list.xsd
-    DESTINATION share/wrt-engine/
-    )
-
-INSTALL(FILES
-    ${ETC_DIR}/fingerprint_list.xml
-    DESTINATION share/wrt-engine/
-    )
-
-ADD_SUBDIRECTORY(certificates)
diff --git a/etc/wrt_commons_create_clean_db.sh b/etc/wrt_commons_create_clean_db.sh
new file mode 100755 (executable)
index 0000000..d333d9d
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+for name in wrt wrt_autosave wrt_custom_handler
+do
+    rm -f /opt/dbspace/.$name.db
+    rm -f /opt/dbspace/.$name.db-journal
+    SQL="PRAGMA journal_mode = PERSIST;"
+    sqlite3 /opt/dbspace/.$name.db "$SQL"
+    SQL=".read /usr/share/wrt-engine/"$name"_db.sql"
+    sqlite3 /opt/dbspace/.$name.db "$SQL"
+    touch /opt/dbspace/.$name.db-journal
+    chown 0:6026 /opt/dbspace/.$name.db
+    chown 0:6026 /opt/dbspace/.$name.db-journal
+    chmod 660 /opt/dbspace/.$name.db
+    chmod 660 /opt/dbspace/.$name.db-journal
+    pkill -9 security-serv
+done
+
+
diff --git a/etc/wrt_commons_reset_db.sh b/etc/wrt_commons_reset_db.sh
new file mode 100755 (executable)
index 0000000..7236341
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+rm -rf /opt/share/widget/system/*
+
+#Removing of widget desktop icons
+WIDGET_EXEC_PATH=/opt/usr/apps/
+WIDGET_DESKTOP_PATH=/opt/share/applications/
+WRT_DB=/opt/dbspace/.wrt.db
+PLUGINS_INSTALLATION_REQUIRED_PATH=/opt/share/widget/
+PLUGINS_INSTALLATION_REQUIRED=plugin-installation-required
+
+if [ -f ${WRT_DB} ]
+then
+    PKG_NAME_SET=$(sqlite3 $WRT_DB 'select tizen_appid from WidgetInfo;')
+    for appid in $PKG_NAME_SET
+    do
+        pkgId=`echo "$appid" | cut -f1 -d"."`
+        rm -rf ${WIDGET_EXEC_PATH}${pkgId}
+        widget_desktop_file="${WIDGET_DESKTOP_PATH}${appid}.desktop";
+        if [ -f ${widget_desktop_file} ]; then
+            rm -f $widget_desktop_file;
+        fi
+    done
+else
+    echo "${WRT_DB} doesn't exist"
+fi
+
+wrt_commons_create_clean_db.sh
+if [ -e ${PLUGINS_INSTALLATION_REQUIRED_PATH} ] && [ -d ${PLUGINS_INSTALLATION_REQUIRED_PATH} ]
+then
+    touch ${PLUGINS_INSTALLATION_REQUIRED_PATH}${PLUGINS_INSTALLATION_REQUIRED}
+fi
index a5546f4..82e583f 100644 (file)
@@ -37,6 +37,5 @@ ADD_SUBDIRECTORY(tcpsock)
 ADD_SUBDIRECTORY(timed_event)
 ADD_SUBDIRECTORY(single_instance)
 ADD_SUBDIRECTORY(crypto_hash)
 ADD_SUBDIRECTORY(timed_event)
 ADD_SUBDIRECTORY(single_instance)
 ADD_SUBDIRECTORY(crypto_hash)
-ADD_SUBDIRECTORY(event_delivery_test)
 ADD_SUBDIRECTORY(metronome)
 ADD_SUBDIRECTORY(copy)
 ADD_SUBDIRECTORY(metronome)
 ADD_SUBDIRECTORY(copy)
index a978a6d..063b6af 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of binary queue example
  */
  * @version     1.0
  * @brief       This file is the implementation file of binary queue example
  */
+#include <stddef.h>
 #include <dpl/binary_queue.h>
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
 #include <dpl/binary_queue.h>
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
index 1ab7607..5fa9484 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of copy example
  */
  * @version     1.0
  * @brief       This file is the implementation file of copy example
  */
+#include <stddef.h>
 #include <dpl/file_input.h>
 #include <dpl/file_output.h>
 #include <dpl/copy.h>
 #include <dpl/file_input.h>
 #include <dpl/file_output.h>
 #include <dpl/copy.h>
index 0fffefa..791b971 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of crypto hash example
  */
  * @version     1.0
  * @brief       This file is the implementation file of crypto hash example
  */
+#include <stddef.h>
 #include <dpl/crypto_hash.h>
 #include <iostream>
 #include <string>
 #include <dpl/crypto_hash.h>
 #include <iostream>
 #include <string>
index 964333e..878febf 100644 (file)
@@ -19,7 +19,7 @@
  * @version     1.0
  * @brief       Implementation for simple echo service DBus client.
  */
  * @version     1.0
  * @brief       Implementation for simple echo service DBus client.
  */
-
+#include <stddef.h>
 #include <iostream>
 #include <string>
 
 #include <iostream>
 #include <string>
 
index 3a54d2a..a733c70 100644 (file)
@@ -13,7 +13,7 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-
+#include <stddef.h>
 #include <memory>
 #include <iostream>
 #include <gio/gio.h>
 #include <memory>
 #include <iostream>
 #include <gio/gio.h>
index 9750c62..3396a59 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of RPC example
  */
  * @version     1.0
  * @brief       This file is the implementation file of RPC example
  */
-
+#include <stddef.h>
 #include <dpl/unix_socket_rpc_client.h>
 #include <dpl/unix_socket_rpc_server.h>
 #include <dpl/unix_socket_rpc_connection.h>
 #include <dpl/fake_rpc_connection.h>
 #include <dpl/unix_socket_rpc_client.h>
 #include <dpl/unix_socket_rpc_server.h>
 #include <dpl/unix_socket_rpc_connection.h>
 #include <dpl/fake_rpc_connection.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
 #include <dpl/application.h>
 #include <dpl/controller.h>
 #include <dpl/thread.h>
 #include <dpl/application.h>
 #include <dpl/controller.h>
 #include <dpl/thread.h>
@@ -62,8 +62,8 @@ private:
     int m_sentData;
     int m_receivedData;
 
     int m_sentData;
     int m_receivedData;
 
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
 
     virtual void OnEventReceived(const AsyncCallEvent &event)
     {
 
     virtual void OnEventReceived(const AsyncCallEvent &event)
     {
@@ -81,14 +81,14 @@ private:
         if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
             ++m_connections;
             LogInfo("CLIENT: Acquiring new fake connection");
         if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
             ++m_connections;
             LogInfo("CLIENT: Acquiring new fake connection");
-            m_rpcFakeConnection.Reset(event.GetArg1());
+            m_rpcFakeConnection.reset(event.GetArg1());
             //this is not used on this side
 //            m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         else{
             ++m_connections;
             LogInfo("CLIENT: Acquiring new unix connection");
             //this is not used on this side
 //            m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         else{
             ++m_connections;
             LogInfo("CLIENT: Acquiring new unix connection");
-            m_rpcUnixConnection.Reset(event.GetArg1());
+            m_rpcUnixConnection.reset(event.GetArg1());
             m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         if(m_connections == 2){
             m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         if(m_connections == 2){
@@ -125,19 +125,19 @@ public:
         LogInfo("CLIENT: Starting thread event loop");
         int ret = Exec();
 
         LogInfo("CLIENT: Starting thread event loop");
         int ret = Exec();
 
-        if (m_rpcUnixConnection.Get()){
+        if (m_rpcUnixConnection.get()){
             LogInfo("CLIENT: Removing Unix connection");
             m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
             LogInfo("CLIENT: Removing Unix connection");
             m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
-            m_rpcUnixConnection.Reset();
+            m_rpcUnixConnection.reset();
         }
 
         LogInfo("CLIENT: Closing");
 
         }
 
         LogInfo("CLIENT: Closing");
 
-        if (m_rpcFakeConnection.Get()){
+        if (m_rpcFakeConnection.get()){
             LogInfo("CLIENT: Removing Fake connection");
             //this is not used on this side
 //            m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
             LogInfo("CLIENT: Removing Fake connection");
             //this is not used on this side
 //            m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
-            m_rpcFakeConnection.Reset();
+            m_rpcFakeConnection.reset();
         }
 
         // Detach RPC client listener
         }
 
         // Detach RPC client listener
@@ -169,8 +169,8 @@ private:
     DPL::UnixSocketRPCServer m_rpcUnixServer;
     DPL::FakeRpcServer m_rpcFakeServer;
 
     DPL::UnixSocketRPCServer m_rpcUnixServer;
     DPL::FakeRpcServer m_rpcFakeServer;
 
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
 
     MyThread m_thread;
 
 
     MyThread m_thread;
 
@@ -180,15 +180,15 @@ private:
         LogInfo("SERVER: Closing RPC connection...");
 
         // Detach RPC connection listeners
         LogInfo("SERVER: Closing RPC connection...");
 
         // Detach RPC connection listeners
-        if (m_rpcUnixConnection.Get()) {
+        if (m_rpcUnixConnection.get()) {
             //this is not used on this side
 //            m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
             //this is not used on this side
 //            m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
-            m_rpcUnixConnection.Reset();
+            m_rpcUnixConnection.reset();
         }
 
         }
 
-        if (m_rpcFakeConnection.Get()) {
+        if (m_rpcFakeConnection.get()) {
             m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
             m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
-            m_rpcFakeConnection.Reset();
+            m_rpcFakeConnection.reset();
         }
 
         LogInfo("SERVER: Closing Server");
         }
 
         LogInfo("SERVER: Closing Server");
@@ -227,12 +227,12 @@ private:
         // Save connection pointer
         if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
             LogInfo("SERVER: Acquiring Fake RPC connection");
         // Save connection pointer
         if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
             LogInfo("SERVER: Acquiring Fake RPC connection");
-            m_rpcFakeConnection.Reset(event.GetArg1());
+            m_rpcFakeConnection.reset(event.GetArg1());
             m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         else{
             LogInfo("SERVER: Acquiring Unix RPC connection");
             m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         else{
             LogInfo("SERVER: Acquiring Unix RPC connection");
-            m_rpcUnixConnection.Reset(event.GetArg1());
+            m_rpcUnixConnection.reset(event.GetArg1());
             //this is not used on this side
 //            m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
             //this is not used on this side
 //            m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
index 2411d09..4184f54 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of metronome client example
  */
  * @version     1.0
  * @brief       This file is the implementation file of metronome client example
  */
+#include <stddef.h>
 #include <dpl/tcp_socket_rpc_client.h>
 #include <dpl/tcp_socket_rpc_connection.h>
 #include <dpl/application.h>
 #include <dpl/tcp_socket_rpc_client.h>
 #include <dpl/tcp_socket_rpc_connection.h>
 #include <dpl/application.h>
@@ -33,7 +34,7 @@ class MetronomeClientApplication
 {
 private:
     DPL::TcpSocketRPCClient m_rpcClient;
 {
 private:
     DPL::TcpSocketRPCClient m_rpcClient;
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcConnection;
 
     virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event)
     {
 
     virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event)
     {
@@ -67,7 +68,7 @@ private:
     {
         // Save connection pointer
         LogInfo("Connected to metronome server");
     {
         // Save connection pointer
         LogInfo("Connected to metronome server");
-        m_rpcConnection.Reset(event.GetArg1());
+        m_rpcConnection.reset(event.GetArg1());
 
         // Attach event listeners
         m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::AddListener(this);
 
         // Attach event listeners
         m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::AddListener(this);
@@ -92,12 +93,12 @@ public:
     virtual ~MetronomeClientApplication()
     {
         // Delete all RPC connections
     virtual ~MetronomeClientApplication()
     {
         // Delete all RPC connections
-        if (m_rpcConnection.Get())
+        if (m_rpcConnection.get())
         {
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionClosedEvent>::RemoveListener(this);
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent>::RemoveListener(this);
         {
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionClosedEvent>::RemoveListener(this);
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent>::RemoveListener(this);
-            m_rpcConnection.Reset();
+            m_rpcConnection.reset();
         }
 
         // Close RPC server
         }
 
         // Close RPC server
index 7efa458..508f61d 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of metronome server example
  */
  * @version     1.0
  * @brief       This file is the implementation file of metronome server example
  */
+#include <stddef.h>
 #include <dpl/tcp_socket_rpc_server.h>
 #include <dpl/tcp_socket_rpc_connection.h>
 #include <dpl/controller.h>
 #include <dpl/tcp_socket_rpc_server.h>
 #include <dpl/tcp_socket_rpc_connection.h>
 #include <dpl/controller.h>
index 833a20f..e1e2a64 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of RPC example
  */
  * @version     1.0
  * @brief       This file is the implementation file of RPC example
  */
+#include <stddef.h>
 #include <dpl/unix_socket_rpc_client.h>
 #include <dpl/unix_socket_rpc_server.h>
 #include <dpl/unix_socket_rpc_connection.h>
 #include <dpl/unix_socket_rpc_client.h>
 #include <dpl/unix_socket_rpc_server.h>
 #include <dpl/unix_socket_rpc_connection.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
 #include <dpl/application.h>
 #include <dpl/controller.h>
 #include <dpl/thread.h>
 #include <dpl/application.h>
 #include <dpl/controller.h>
 #include <dpl/thread.h>
@@ -40,7 +41,7 @@ class MyThread
 {
 private:
     DPL::UnixSocketRPCClient m_rpcClient;
 {
 private:
     DPL::UnixSocketRPCClient m_rpcClient;
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcConnection;
 
     virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event)
     {
 
     virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event)
     {
@@ -69,7 +70,7 @@ private:
     {
         // Save connection pointer
         LogInfo("CLIENT: Acquiring new connection");
     {
         // Save connection pointer
         LogInfo("CLIENT: Acquiring new connection");
-        m_rpcConnection.Reset(event.GetArg1());
+        m_rpcConnection.reset(event.GetArg1());
 
         // Attach listener to new connection
         LogInfo("CLIENT: Attaching connection event listeners");
 
         // Attach listener to new connection
         LogInfo("CLIENT: Attaching connection event listeners");
@@ -108,7 +109,7 @@ public:
         int ret = Exec();
 
         // Detach RPC listeners
         int ret = Exec();
 
         // Detach RPC listeners
-        if (m_rpcConnection.Get())
+        if (m_rpcConnection.get())
         {
             LogInfo("CLIENT: Detaching RPC connection events");
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
         {
             LogInfo("CLIENT: Detaching RPC connection events");
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
@@ -116,7 +117,7 @@ public:
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent>::RemoveListener(this);
 
             LogInfo("CLIENT: Resetting connection");
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent>::RemoveListener(this);
 
             LogInfo("CLIENT: Resetting connection");
-            m_rpcConnection.Reset();
+            m_rpcConnection.reset();
         }
 
         // Detach RPC client listener
         }
 
         // Detach RPC client listener
@@ -146,7 +147,7 @@ class MyApplication
 {
 private:
     DPL::UnixSocketRPCServer m_rpcServer;
 {
 private:
     DPL::UnixSocketRPCServer m_rpcServer;
-    DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcConnection;
+    std::unique_ptr<DPL::AbstractRPCConnection> m_rpcConnection;
 
     MyThread m_thread;
 
 
     MyThread m_thread;
 
@@ -184,7 +185,7 @@ private:
         LogInfo("SERVER: Closing RPC connection on event...");
 
         // Detach RPC connection listeners
         LogInfo("SERVER: Closing RPC connection on event...");
 
         // Detach RPC connection listeners
-        if (m_rpcConnection.Get())
+        if (m_rpcConnection.get())
         {
             LogInfo("SERVER: Detaching connection events");
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
         {
             LogInfo("SERVER: Detaching connection events");
             m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
@@ -208,7 +209,7 @@ private:
     {
         // Save connection pointer
         LogInfo("SERVER: Acquiring RPC connection");
     {
         // Save connection pointer
         LogInfo("SERVER: Acquiring RPC connection");
-        m_rpcConnection.Reset(event.GetArg1());
+        m_rpcConnection.reset(event.GetArg1());
 
         // Attach event listeners
         LogInfo("SERVER: Attaching connection listeners");
 
         // Attach event listeners
         LogInfo("SERVER: Attaching connection listeners");
index e09af81..6da8409 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of simple example
  */
  * @version     1.0
  * @brief       This file is the implementation file of simple example
  */
+#include <stddef.h>
 #include <dpl/log/log.h>
 
 int main(int argc, char *argv[])
 #include <dpl/log/log.h>
 
 int main(int argc, char *argv[])
index cadb4f4..038594b 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of single instance example
  */
  * @version     1.0
  * @brief       This file is the implementation file of single instance example
  */
+#include <stddef.h>
 #include <dpl/single_instance.h>
 #include <iostream>
 
 #include <dpl/single_instance.h>
 #include <iostream>
 
index c8a2894..fca68ab 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of socket example
  */
  * @version     1.0
  * @brief       This file is the implementation file of socket example
  */
+#include <stddef.h>
 #include <dpl/unix_socket.h>
 #include <dpl/abstract_socket.h>
 #include <dpl/application.h>
 #include <dpl/unix_socket.h>
 #include <dpl/abstract_socket.h>
 #include <dpl/application.h>
index c2697cd..1bae958 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of tcpsock example
  */
  * @version     1.0
  * @brief       This file is the implementation file of tcpsock example
  */
+#include <stddef.h>
 #include <dpl/tcp_socket.h>
 #include <dpl/abstract_socket.h>
 #include <dpl/application.h>
 #include <dpl/tcp_socket.h>
 #include <dpl/abstract_socket.h>
 #include <dpl/application.h>
index 28c74a4..4e32cef 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of timed event example
  */
  * @version     1.0
  * @brief       This file is the implementation file of timed event example
  */
+#include <stddef.h>
 #include <dpl/generic_event.h>
 #include <dpl/application.h>
 #include <dpl/controller.h>
 #include <dpl/generic_event.h>
 #include <dpl/application.h>
 #include <dpl/controller.h>
index 7d34aaf..4d39189 100644 (file)
@@ -27,9 +27,11 @@ include(socket/config.cmake)
 include(rpc/config.cmake)
 include(test/config.cmake)
 include(log/config.cmake)
 include(rpc/config.cmake)
 include(test/config.cmake)
 include(log/config.cmake)
-ADD_SUBDIRECTORY(vcore)
-ADD_SUBDIRECTORY(ace)
 ADD_SUBDIRECTORY(widget_dao)
 ADD_SUBDIRECTORY(widget_dao)
-include(popup/config.cmake)
+ADD_SUBDIRECTORY(auto_save_dao)
+ADD_SUBDIRECTORY(security_origin_dao)
+ADD_SUBDIRECTORY(custom_handler_dao)
 include(utils/config.cmake)
 include(localization/config.cmake)
 include(utils/config.cmake)
 include(localization/config.cmake)
+include(support/config.cmake)
+include(encryption/config.cmake)
diff --git a/modules/auto_save_dao/CMakeLists.txt b/modules/auto_save_dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..232f836
--- /dev/null
@@ -0,0 +1,98 @@
+SET(TARGET_AUTO_SAVE_DAO_DB "Sqlite3DbAutoSave")
+
+ADD_CUSTOM_COMMAND(
+   OUTPUT ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h
+   COMMAND ${CMAKE_SOURCE_DIR}/modules/auto_save_dao/orm/gen_db_md5.sh
+   ARGS ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h
+        ${CMAKE_SOURCE_DIR}/modules/auto_save_dao/orm/autosave_db
+   DEPENDS ${CMAKE_SOURCE_DIR}/modules/auto_save_dao/orm/autosave_db
+        ${CMAKE_SOURCE_DIR}/modules/auto_save_dao/orm/gen_db_md5.sh
+   COMMENT "Generating WRT auto save database checksum"
+   )
+
+ADD_CUSTOM_COMMAND( OUTPUT .wrt_autosave.db
+   COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/.wrt_autosave.db
+   COMMAND gcc -Wall -include ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h -I${PROJECT_SOURCE_DIR}/modules/db/include -I${PROJECT_SOURCE_DIR}/modules/auto_save_dao/orm -E ${PROJECT_SOURCE_DIR}/modules/auto_save_dao/orm/autosave_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_BINARY_DIR}/wrt_autosave_db.sql
+   COMMAND sqlite3 ${CMAKE_CURRENT_BINARY_DIR}/.wrt_autosave.db ".read ${CMAKE_CURRENT_BINARY_DIR}/wrt_autosave_db.sql" || rm -f ${CMAKE_CURRENT_BINARY_DIR}/.wrt_autosave.db
+   DEPENDS ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h ${PROJECT_SOURCE_DIR}/modules/auto_save_dao/orm/autosave_db_sql_generator.h ${PROJECT_SOURCE_DIR}/modules/auto_save_dao/orm/autosave_db
+   )
+
+ADD_CUSTOM_COMMAND( OUTPUT .wrt_autosave.db-journal
+   COMMAND touch
+   ARGS  ${CMAKE_CURRENT_BINARY_DIR}/.wrt_autosave.db-journal
+   )
+
+ADD_CUSTOM_TARGET(${TARGET_AUTO_SAVE_DAO_DB} ALL DEPENDS .wrt_autosave.db .wrt_autosave.db-journal)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_autosave_db.sql DESTINATION share/wrt-engine/)
+
+###############################################################################
+
+INCLUDE(FindPkgConfig)
+
+PKG_CHECK_MODULES(AUTO_SAVE_DAO_DEPS
+    glib-2.0
+    REQUIRED)
+
+SET(AUTO_SAVE_DAO_INCLUDE_DIRS
+    ${PROJECT_SOURCE_DIR}/modules/auto_save_dao/include
+    ${PROJECT_SOURCE_DIR}/modules/auto_save_dao/orm
+    ${PROJECT_SOURCE_DIR}/modules/core/include
+    ${PROJECT_SOURCE_DIR}/modules/db/include
+    ${PROJECT_SOURCE_DIR}/modules/log/include
+)
+
+
+SET(AUTO_SAVE_DAO_SOURCES
+    dao/common_dao_types.cpp
+    dao/AutoSaveDatabase.cpp
+)
+
+SET(AUTO_SAVE_DAO_RO_SOURCES
+    dao/auto_save_dao_read_only.cpp
+)
+
+SET(AUTO_SAVE_DAO_RW_SOURCES
+    dao/auto_save_dao.cpp
+)
+
+
+INCLUDE_DIRECTORIES(${AUTO_SAVE_DAO_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${AUTO_SAVE_DAO_DEPS_INCLUDE_DIRS})
+
+ADD_LIBRARY(${TARGET_AUTO_SAVE_DAO_LIB} SHARED ${AUTO_SAVE_DAO_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_AUTO_SAVE_DAO_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${TARGET_AUTO_SAVE_DAO_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h")
+TARGET_LINK_LIBRARIES(${TARGET_AUTO_SAVE_DAO_LIB} ${TARGET_DPL_EFL} ${TARGET_DPL_DB_EFL} ${AUTO_SAVE_DAO_DEPS_LIBRARIES})
+ADD_DEPENDENCIES(${TARGET_AUTO_SAVE_DAO_LIB} ${TARGET_AUTO_SAVE_DAO_DB})
+
+ADD_LIBRARY(${TARGET_AUTO_SAVE_DAO_RO_LIB} SHARED ${AUTO_SAVE_DAO_RO_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_AUTO_SAVE_DAO_RO_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${TARGET_AUTO_SAVE_DAO_RO_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h")
+TARGET_LINK_LIBRARIES(${TARGET_AUTO_SAVE_DAO_RO_LIB} ${TARGET_AUTO_SAVE_DAO_LIB})
+ADD_DEPENDENCIES(${TARGET_AUTO_SAVE_DAO_RO_LIB} ${TARGET_AUTO_SAVE_DAO_DB})
+
+ADD_LIBRARY(${TARGET_AUTO_SAVE_DAO_RW_LIB} SHARED ${AUTO_SAVE_DAO_RW_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_AUTO_SAVE_DAO_RW_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${TARGET_AUTO_SAVE_DAO_RW_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/auto_save_dao/database_checksum_autosave.h")
+TARGET_LINK_LIBRARIES(${TARGET_AUTO_SAVE_DAO_RW_LIB} ${TARGET_AUTO_SAVE_DAO_RO_LIB})
+ADD_DEPENDENCIES(${TARGET_AUTO_SAVE_DAO_RW_LIB} ${TARGET_AUTO_SAVE_DAO_DB})
+
+INSTALL(TARGETS ${TARGET_AUTO_SAVE_DAO_LIB} DESTINATION lib)
+INSTALL(TARGETS ${TARGET_AUTO_SAVE_DAO_RO_LIB} DESTINATION lib)
+INSTALL(TARGETS ${TARGET_AUTO_SAVE_DAO_RW_LIB} DESTINATION lib)
+
+INSTALL(FILES
+    include/wrt-commons/auto-save-dao/common_dao_types.h
+    include/wrt-commons/auto-save-dao/AutoSaveDatabase.h
+    DESTINATION include/dpl-efl/wrt-commons/auto-save-dao
+)
+
+INSTALL(FILES
+    include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h
+    DESTINATION include/dpl-efl/wrt-commons/auto-save-dao-ro
+)
+
+INSTALL(FILES
+    include/wrt-commons/auto-save-dao-rw/auto_save_dao.h
+    DESTINATION include/dpl-efl/wrt-commons/auto-save-dao-rw
+)
diff --git a/modules/auto_save_dao/dao/AutoSaveDatabase.cpp b/modules/auto_save_dao/dao/AutoSaveDatabase.cpp
new file mode 100644 (file)
index 0000000..5b21316
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 <stddef.h>
+#include <wrt-commons/auto-save-dao/AutoSaveDatabase.h>
+
+using namespace AutoSaveDB;
+
+namespace {
+const char* AUTOSAVE_DB_DATABASE = "/opt/dbspace/.wrt_autosave.db";
+DPL::DB::SqlConnection::Flag::Type AUTOSAVE_DB_FLAGS =
+    DPL::DB::SqlConnection::Flag::UseLucene;
+}
+
+DPL::Mutex g_autoSaveDbQueriesMutex;
+DPL::DB::ThreadDatabaseSupport Interface::m_autoSavedbInterface(
+    AUTOSAVE_DB_DATABASE, AUTOSAVE_DB_FLAGS);
+
diff --git a/modules/auto_save_dao/dao/auto_save_dao.cpp b/modules/auto_save_dao/dao/auto_save_dao.cpp
new file mode 100644 (file)
index 0000000..8c9ecf5
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    auto_save_dao.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief    This file contains the definition of auto save dao class.
+ */
+#include <stddef.h>
+#include <wrt-commons/auto-save-dao-rw/auto_save_dao.h>
+#include <wrt-commons/auto-save-dao/AutoSaveDatabase.h>
+#include <orm_generator_autosave.h>
+#include <dpl/foreach.h>
+
+using namespace DPL::DB::ORM;
+using namespace DPL::DB::ORM::autosave;
+using namespace AutoSaveDB::Interface;
+
+namespace AutoSaveDB {
+#define SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN          Try
+
+#define SQL_CONNECTION_EXCEPTION_HANDLER_END(message)   \
+    Catch(DPL::DB::SqlConnection::Exception::Base) {       \
+        LogError(message);                              \
+        ReThrowMsg(AutoSaveDAO::Exception::DatabaseError, \
+                   message);                            \
+    }
+
+AutoSaveDAO::AutoSaveDAO() :
+    AutoSaveDAOReadOnly()
+{}
+
+AutoSaveDAO::~AutoSaveDAO()
+{}
+
+void AutoSaveDAO::attachDatabaseRW(void)
+{
+    m_autoSavedbInterface.AttachToThread(
+        DPL::DB::SqlConnection::Flag::RW);
+}
+
+void AutoSaveDAO::detachDatabase(void)
+{
+    m_autoSavedbInterface.DetachFromThread();
+}
+
+void AutoSaveDAO::setAutoSaveSubmitFormData(
+    const DPL::String &url,
+    const SubmitFormData &
+    submitFormData)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        ScopedTransaction transaction(&m_autoSavedbInterface);
+
+        SubmitFormData submitData = getAutoSaveSubmitFormData(url);
+        if (!submitData.empty()) {
+            AUTOSAVE_DB_DELETE(del,
+                               AutoSaveSubmitFormElement,
+                               &m_autoSavedbInterface)
+            del->Where(Equals<AutoSaveSubmitFormElement::address>(url));
+            del->Execute();
+        }
+
+        FOREACH(pSubmitFormData, submitFormData) {
+            AutoSaveSubmitFormElement::Row row;
+            row.Set_address(url);
+            row.Set_key(pSubmitFormData->key);
+            row.Set_value(pSubmitFormData->value);
+
+            AUTOSAVE_DB_INSERT(
+                insert, AutoSaveSubmitFormElement, &m_autoSavedbInterface);
+            insert->Values(row);
+            insert->Execute();
+        }
+
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END(
+        "Fail to register id, passwd for autosave")
+}
+#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
+} // namespace AutoSaveDB
diff --git a/modules/auto_save_dao/dao/auto_save_dao_read_only.cpp b/modules/auto_save_dao/dao/auto_save_dao_read_only.cpp
new file mode 100644 (file)
index 0000000..0089e19
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of auto save dao class.
+ *
+ * @file    auto_save_dao_read_only.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of auto save dao
+ */
+#include <stddef.h>
+#include <wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h>
+#include <wrt-commons/auto-save-dao/AutoSaveDatabase.h>
+#include <orm_generator_autosave.h>
+#include <dpl/foreach.h>
+
+using namespace DPL::DB::ORM;
+using namespace DPL::DB::ORM::autosave;
+using namespace AutoSaveDB::Interface;
+
+namespace AutoSaveDB {
+#define SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN          Try
+
+#define SQL_CONNECTION_EXCEPTION_HANDLER_END(message)   \
+    Catch(DPL::DB::SqlConnection::Exception::Base) {       \
+        LogError(message);                              \
+        ReThrowMsg(AutoSaveDAOReadOnly::Exception::DatabaseError, \
+                   message);                            \
+    }
+
+AutoSaveDAOReadOnly::AutoSaveDAOReadOnly()
+{}
+
+AutoSaveDAOReadOnly::~AutoSaveDAOReadOnly()
+{}
+
+void AutoSaveDAOReadOnly::attachDatabaseRO(void)
+{
+    m_autoSavedbInterface.AttachToThread(
+        DPL::DB::SqlConnection::Flag::RO);
+}
+
+void AutoSaveDAOReadOnly::detachDatabase(void)
+{
+    m_autoSavedbInterface.DetachFromThread();
+}
+
+SubmitFormData AutoSaveDAOReadOnly::getAutoSaveSubmitFormData(
+    const DPL::String &url)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        AUTOSAVE_DB_SELECT(select,
+                           AutoSaveSubmitFormElement,
+                           &m_autoSavedbInterface);
+        select->Where(Equals<AutoSaveSubmitFormElement::address>(url));
+        AutoSaveSubmitFormElement::Select::RowList rows = select->GetRowList();
+
+        SubmitFormData submitFormData;
+        FOREACH(it, rows) {
+            SubmitFormElement element;
+            element.key = it->Get_key();
+            element.value = it->Get_value();
+            submitFormData.push_back(element);
+        }
+        return submitFormData;
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get autosave data string")
+}
+
+#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
+} // namespace AutoSaveDB
diff --git a/modules/auto_save_dao/dao/common_dao_types.cpp b/modules/auto_save_dao/dao/common_dao_types.cpp
new file mode 100644 (file)
index 0000000..5dec0e7
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    common_dao_types.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the implementation of
+ *             common data types for autoSavedb
+ */
+#include <stddef.h>
+#include <wrt-commons/auto-save-dao/common_dao_types.h>
+#include <dpl/log/log.h>
+
+namespace AutoSaveDB {} // namespace AutoSaveDB
diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h
new file mode 100644 (file)
index 0000000..7c1c449
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of auto save dao class.
+ *
+ * @file    auto_save_dao_read_only.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of auto save dao
+ */
+
+#ifndef _AUTO_SAVE_DAO_READ_ONLY_H_
+#define _AUTO_SAVE_DAO_READ_ONLY_H_
+
+#include <dpl/string.h>
+#include <dpl/exception.h>
+#include <dpl/optional.h>
+#include <wrt-commons/auto-save-dao/common_dao_types.h>
+
+namespace AutoSaveDB {
+class AutoSaveDAOReadOnly
+{
+  public:
+    /**
+     * AutoSaveDAOReadOnly Exception classes
+     */
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
+    };
+
+  public:
+
+    AutoSaveDAOReadOnly();
+    virtual ~AutoSaveDAOReadOnly();
+
+    static void attachDatabaseRO(void);
+    static void detachDatabase(void);
+
+    /**
+     * This method gets Autofill for Webkit
+     */
+    static SubmitFormData getAutoSaveSubmitFormData(
+        const DPL::String &url);
+};
+} // namespace AutoSaveDB
+
+#endif // _AUTO_SAVE_DAO_READ_ONLY_H_
+
diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h
new file mode 100644 (file)
index 0000000..d0bd940
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of auto save dao class.
+ *
+ * @file    auto_save_dao.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of auto save dao
+ */
+#ifndef _AUTO_SAVE_DAO_H_
+#define _AUTO_SAVE_DAO_H_
+
+#include <wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h>
+
+namespace AutoSaveDB {
+class AutoSaveDAO : public AutoSaveDAOReadOnly
+{
+  public:
+
+    AutoSaveDAO();
+    virtual ~AutoSaveDAO();
+
+    static void attachDatabaseRW(void);
+    static void detachDatabase(void);
+
+    /**
+     * This method sets Autofill for Webkit
+     */
+    static void setAutoSaveSubmitFormData(
+        const DPL::String& url, const SubmitFormData &submitFormData);
+};
+} // namespace AutoSaveDB
+
+#endif // _AUTO_SAVE_DAO_H_
diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao/AutoSaveDatabase.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao/AutoSaveDatabase.h
new file mode 100644 (file)
index 0000000..3d7bcd2
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _AUTOSAVEDATABASE_H_
+#define _AUTOSAVEDATABASE_H_
+
+#include <dpl/thread.h>
+#include <dpl/mutex.h>
+#include <dpl/db/thread_database_support.h>
+
+extern DPL::Mutex g_autoSaveDbQueriesMutex;
+
+#define AUTOSAVE_DB_INTERNAL(tlsCommand, InternalType, interface)            \
+    static DPL::ThreadLocalVariable<InternalType> *tlsCommand##Ptr = NULL; \
+    {                                                                        \
+        DPL::Mutex::ScopedLock lock(&g_autoSaveDbQueriesMutex);              \
+        if (!tlsCommand##Ptr) {                                            \
+            static DPL::ThreadLocalVariable<InternalType> tmp;               \
+            tlsCommand##Ptr = &tmp;                                        \
+        }                                                                    \
+    }                                                                        \
+    DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand##Ptr; \
+    if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); }
+
+#define AUTOSAVE_DB_SELECT(name, type, interface) \
+    AUTOSAVE_DB_INTERNAL(name, type::Select, interface)
+
+#define AUTOSAVE_DB_INSERT(name, type, interface) \
+    AUTOSAVE_DB_INTERNAL(name, type::Insert, interface)
+
+#define AUTOSAVE_DB_UPDATE(name, type, interface) \
+    AUTOSAVE_DB_INTERNAL(name, type::Update, interface)
+
+#define AUTOSAVE_DB_DELETE(name, type, interface) \
+    AUTOSAVE_DB_INTERNAL(name, type::Delete, interface)
+
+namespace AutoSaveDB {
+namespace Interface {
+extern DPL::DB::ThreadDatabaseSupport m_autoSavedbInterface;
+} // namespace Interface
+} // namespace AutoSaveDB
+
+#endif /* _AUTOSAVEDATABASE_H_ */
+
diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h
new file mode 100644 (file)
index 0000000..f0c22b6
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    common_dao_types.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief This file contains the declaration of
+ *           common data types for auto save database.
+ */
+#ifndef SHARE_COMMON_DAO_TYPES_H_
+#define SHARE_COMMON_DAO_TYPES_H_
+
+#include <list>
+#include <dpl/string.h>
+
+namespace AutoSaveDB {
+struct SubmitFormElement
+{
+    DPL::String key;
+    DPL::String value;
+
+    SubmitFormElement()
+    {}
+
+    SubmitFormElement(
+        const DPL::String& keyData,
+        const DPL::String& valueData) :
+        key(keyData),
+        value(valueData)
+    {}
+
+    bool operator== (const SubmitFormElement& other) const
+    {
+        return (!DPL::StringCompare(key, other.key) &&
+                !DPL::StringCompare(value, other.value));
+    }
+
+    bool operator!= (const SubmitFormElement& other) const
+    {
+        return !(*this == other);
+    }
+};
+typedef std::list<SubmitFormElement> SubmitFormData;
+} // namespace AutoSaveDB
+
+#endif /* SHARE_COMMON_DAO_TYPES_H_ */
diff --git a/modules/auto_save_dao/orm/autosave_db b/modules/auto_save_dao/orm/autosave_db
new file mode 100644 (file)
index 0000000..5f79edf
--- /dev/null
@@ -0,0 +1,13 @@
+SQL(
+    BEGIN TRANSACTION;
+)
+
+CREATE_TABLE(AutoSaveSubmitFormElement)
+    COLUMN_NOT_NULL(address,    VARCHAR(256),)
+    COLUMN_NOT_NULL(key,        TEXT,)
+    COLUMN_NOT_NULL(value,      TEXT,)
+CREATE_TABLE_END()
+
+SQL(
+    COMMIT;
+)
diff --git a/modules/auto_save_dao/orm/autosave_db_definitions b/modules/auto_save_dao/orm/autosave_db_definitions
new file mode 100644 (file)
index 0000000..5674d7b
--- /dev/null
@@ -0,0 +1,6 @@
+DATABASE_START(autosave)
+
+#include "autosave_db"
+#include "version_db"
+
+DATABASE_END()
diff --git a/modules/auto_save_dao/orm/autosave_db_sql_generator.h b/modules/auto_save_dao/orm/autosave_db_sql_generator.h
new file mode 100644 (file)
index 0000000..e6720a0
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        autosave_db_sql_generator.h
+ * @author      Jihoon Chung (jihoon.chung@samsung.com)
+ * @version     1.0
+ * @brief       Macro definitions for generating the SQL
+ *                input file from database definition.
+ */
+
+//Do not include this file directly! It is used only for SQL code generation.
+#include <dpl/db/orm_macros.h>
+
+#include "autosave_db_definitions"
diff --git a/modules/auto_save_dao/orm/gen_db_md5.sh b/modules/auto_save_dao/orm/gen_db_md5.sh
new file mode 100755 (executable)
index 0000000..38587b7
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+CHECKSUM=`cat ${2} ${3} 2>/dev/null | md5sum 2>/dev/null | cut -d\  -f1 2>/dev/null`
+echo "#define DB_CHECKSUM DB_VERSION_${CHECKSUM}" > ${1}
+echo "#define DB_CHECKSUM_STR \"DB_VERSION_${CHECKSUM}\"" >> ${1}
+
diff --git a/modules/auto_save_dao/orm/orm_generator_autosave.h b/modules/auto_save_dao/orm/orm_generator_autosave.h
new file mode 100644 (file)
index 0000000..57765cd
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _ORM_GENERATOR_AUTOSAVE_H_
+#define _ORM_GENERATOR_AUTOSAVE_H_
+
+#define ORM_GENERATOR_DATABASE_NAME autosave_db_definitions
+#include <dpl/db/orm_generator.h>
+#undef ORM_GENERATOR_DATABASE_NAME
+
+#endif // _ORM_GENERATOR_AUTOSAVE_H_
diff --git a/modules/auto_save_dao/orm/version_db b/modules/auto_save_dao/orm/version_db
new file mode 100644 (file)
index 0000000..7e20d8d
--- /dev/null
@@ -0,0 +1,5 @@
+SQL(
+    BEGIN TRANSACTION;
+    CREATE TABLE DB_CHECKSUM (version INT);
+    COMMIT;
+)
index 10450d0..147f155 100644 (file)
@@ -36,12 +36,10 @@ SET(DPL_CORE_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/core/src/exception.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/fast_delegate.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/file_input.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/exception.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/fast_delegate.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/file_input.cpp
-    ${PROJECT_SOURCE_DIR}/modules/core/src/file_input_mapping.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/file_output.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/lexical_cast.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/mutex.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/named_base_pipe.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/file_output.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/lexical_cast.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/mutex.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/named_base_pipe.cpp
-    ${PROJECT_SOURCE_DIR}/modules/core/src/named_input_pipe.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/named_output_pipe.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/noncopyable.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/once.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/named_output_pipe.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/noncopyable.cpp
     ${PROJECT_SOURCE_DIR}/modules/core/src/once.cpp
@@ -84,6 +82,7 @@ SET(DPL_CORE_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/apply.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/assert.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/atomic.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/apply.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/assert.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/atomic.h
+    ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/auto_ptr.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/binary_queue.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/bool_operator.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/char_traits.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/binary_queue.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/bool_operator.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/char_traits.h
@@ -94,7 +93,6 @@ SET(DPL_CORE_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/exception.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/fast_delegate.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/exception.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/fast_delegate.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input.h
-    ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input_mapping.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_output.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/foreach.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/generic_event.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_output.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/foreach.h
     ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/generic_event.h
index 89ed8fc..8c0e16a 100644 (file)
 #include <dpl/exception.h>
 #include <memory>
 
 #include <dpl/exception.h>
 #include <memory>
 
-namespace DPL
-{
+namespace DPL {
 class BinaryQueue;
 typedef std::auto_ptr<BinaryQueue> BinaryQueueAutoPtr;
 
 class AbstractInput
 {
 class BinaryQueue;
 typedef std::auto_ptr<BinaryQueue> BinaryQueueAutoPtr;
 
 class AbstractInput
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, ReadFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, ReadFailed)
     };
 
-public:
+  public:
     virtual ~AbstractInput() {}
 
     /**
     virtual ~AbstractInput() {}
 
     /**
index f775afc..153d5c4 100644 (file)
 #include <dpl/abstract_input.h>
 #include <dpl/abstract_output.h>
 
 #include <dpl/abstract_input.h>
 #include <dpl/abstract_output.h>
 
-namespace DPL
+namespace DPL {
+class AbstractInputOutput :
+    public AbstractInput,
+    public AbstractOutput
 {
 {
-class AbstractInputOutput
-    : public AbstractInput,
-      public AbstractOutput
-{
-public:
+  public:
     virtual ~AbstractInputOutput() {}
 };
     virtual ~AbstractInputOutput() {}
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_INPUT_OUTPUT_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_INPUT_OUTPUT_H
index 160907c..56c86fb 100644 (file)
 #include <dpl/exception.h>
 #include <memory>
 
 #include <dpl/exception.h>
 #include <memory>
 
-namespace DPL
-{
+namespace DPL {
 class BinaryQueue;
 typedef std::auto_ptr<BinaryQueue> BinaryQueueAutoPtr;
 
 class AbstractOutput
 {
 class BinaryQueue;
 typedef std::auto_ptr<BinaryQueue> BinaryQueueAutoPtr;
 
 class AbstractOutput
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, WriteFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, WriteFailed)
     };
 
-public:
+  public:
     virtual ~AbstractOutput() {}
 
     /**
     virtual ~AbstractOutput() {}
 
     /**
@@ -50,7 +49,8 @@ public:
      *
      * @param[in] buffer Input buffer with data to be written
      * @param[in] bufferSize Maximum number of bytes to write from buffer
      *
      * @param[in] buffer Input buffer with data to be written
      * @param[in] bufferSize Maximum number of bytes to write from buffer
-     * @return Number of bytes success successfuly written or zero if output is blocked
+     * @return Number of bytes success successfuly written or zero if output is
+     * blocked
      * @throw WriteFailed
      */
     virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize) = 0;
      * @throw WriteFailed
      */
     virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize) = 0;
index 6b39ea7..9d957d6 100644 (file)
 #include <dpl/waitable_handle.h>
 #include <dpl/abstract_input.h>
 
 #include <dpl/waitable_handle.h>
 #include <dpl/abstract_input.h>
 
-namespace DPL
+namespace DPL {
+class AbstractWaitableInput :
+    public AbstractInput
 {
 {
-
-class AbstractWaitableInput
-    : public AbstractInput
-{
-public:
+  public:
     virtual ~AbstractWaitableInput() {}
 
     virtual WaitableHandle WaitableReadHandle() const = 0;
 };
     virtual ~AbstractWaitableInput() {}
 
     virtual WaitableHandle WaitableReadHandle() const = 0;
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_H
index a9d396a..43efaee 100644 (file)
 #include <dpl/waitable_event.h>
 #include <dpl/abstract_input.h>
 
 #include <dpl/waitable_event.h>
 #include <dpl/abstract_input.h>
 
-namespace DPL
+namespace DPL {
+class AbstractWaitableInputAdapter :
+    public AbstractWaitableInput
 {
 {
-
-class AbstractWaitableInputAdapter
-    : public AbstractWaitableInput
-{
-private:
+  private:
     AbstractInput *m_input;
     WaitableEvent m_waitableEvent;
 
     AbstractInput *m_input;
     WaitableEvent m_waitableEvent;
 
-public:
+  public:
     explicit AbstractWaitableInputAdapter(AbstractInput *input);
 
     virtual BinaryQueueAutoPtr Read(size_t size);
 
     virtual WaitableHandle WaitableReadHandle() const;
 };
     explicit AbstractWaitableInputAdapter(AbstractInput *input);
 
     virtual BinaryQueueAutoPtr Read(size_t size);
 
     virtual WaitableHandle WaitableReadHandle() const;
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_ADAPTER_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_ADAPTER_H
index 3d3e6f2..e858f51 100644 (file)
 #include <dpl/abstract_waitable_input.h>
 #include <dpl/abstract_waitable_output.h>
 
 #include <dpl/abstract_waitable_input.h>
 #include <dpl/abstract_waitable_output.h>
 
-namespace DPL
+namespace DPL {
+class AbstractWaitableInputOutput :
+    public AbstractWaitableInput,
+    public AbstractWaitableOutput
 {
 {
-
-class AbstractWaitableInputOutput
-    : public AbstractWaitableInput,
-      public AbstractWaitableOutput
-{
-public:
+  public:
     virtual ~AbstractWaitableInputOutput() {}
 };
     virtual ~AbstractWaitableInputOutput() {}
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_OUTPUT_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_OUTPUT_H
index 6ac2228..a0322d0 100644 (file)
 #include <dpl/abstract_waitable_output_adapter.h>
 #include <dpl/abstract_input_output.h>
 
 #include <dpl/abstract_waitable_output_adapter.h>
 #include <dpl/abstract_input_output.h>
 
-namespace DPL
+namespace DPL {
+class AbstractWaitableInputOutputAdapter :
+    public AbstractWaitableInputAdapter,
+    public AbstractWaitableOutputAdapter
 {
 {
-
-class AbstractWaitableInputOutputAdapter
-    : public AbstractWaitableInputAdapter,
-      public AbstractWaitableOutputAdapter
-{
-public:
-    explicit AbstractWaitableInputOutputAdapter(AbstractInputOutput *inputOutput);
+  public:
+    explicit AbstractWaitableInputOutputAdapter(
+        AbstractInputOutput *inputOutput);
 };
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_OUTPUT_ADAPTER_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_INPUT_OUTPUT_ADAPTER_H
index 6cc8d23..abcc3f8 100644 (file)
 #include <dpl/abstract_output.h>
 #include <dpl/waitable_handle.h>
 
 #include <dpl/abstract_output.h>
 #include <dpl/waitable_handle.h>
 
-namespace DPL
+namespace DPL {
+class AbstractWaitableOutput :
+    public AbstractOutput
 {
 {
-
-class AbstractWaitableOutput
-    : public AbstractOutput
-{
-public:
+  public:
     virtual ~AbstractWaitableOutput() {}
 
     virtual WaitableHandle WaitableWriteHandle() const = 0;
 };
     virtual ~AbstractWaitableOutput() {}
 
     virtual WaitableHandle WaitableWriteHandle() const = 0;
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_OUTPUT_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_OUTPUT_H
index 64fc3b3..9e40bc4 100644 (file)
 #include <dpl/waitable_event.h>
 #include <dpl/abstract_output.h>
 
 #include <dpl/waitable_event.h>
 #include <dpl/abstract_output.h>
 
-namespace DPL
+namespace DPL {
+class AbstractWaitableOutputAdapter :
+    public AbstractWaitableOutput
 {
 {
-
-class AbstractWaitableOutputAdapter
-    : public AbstractWaitableOutput
-{
-private:
+  private:
     AbstractOutput *m_output;
     WaitableEvent m_waitableEvent;
 
     AbstractOutput *m_output;
     WaitableEvent m_waitableEvent;
 
-public:
+  public:
     explicit AbstractWaitableOutputAdapter(AbstractOutput *output);
 
     virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize);
 
     virtual WaitableHandle WaitableWriteHandle() const;
 };
     explicit AbstractWaitableOutputAdapter(AbstractOutput *output);
 
     virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize);
 
     virtual WaitableHandle WaitableWriteHandle() const;
 };
-
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_OUTPUT_ADAPTER_H
 } // namespace DPL
 
 #endif // DPL_ABSTRACT_WAITABLE_OUTPUT_ADAPTER_H
index 7b1d8e8..05893f9 100644 (file)
 #include <dpl/exception.h>
 #include <string>
 
 #include <dpl/exception.h>
 #include <string>
 
-namespace DPL
-{
+namespace DPL {
 class Address
 {
 class Address
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, InvalidAddress)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, InvalidAddress)
     };
 
-private:
+  private:
     std::string m_address;
     unsigned short m_port;
 
     std::string m_address;
     unsigned short m_port;
 
-public:
+  public:
     Address();
     Address(const std::string &address);
     Address(const std::string &address, unsigned short port);
     Address();
     Address(const std::string &address);
     Address(const std::string &address, unsigned short port);
@@ -55,7 +54,6 @@ public:
 
     bool operator<(const Address &addr) const;
 };
 
     bool operator<(const Address &addr) const;
 };
-
 } // namespace DPL
 
 #endif // DPL_ADDRESS_H
 } // namespace DPL
 
 #endif // DPL_ADDRESS_H
index 902deb6..4400545 100644 (file)
@@ -17,7 +17,8 @@
  * @file        aligned.h
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version     1.0
  * @file        aligned.h
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of aligned attribute from gcc
+ * @brief       This file is the implementation file of aligned attribute from
+ * gcc
  */
 #ifndef DPL_ALIGNED_H
 #define DPL_ALIGNED_H
  */
 #ifndef DPL_ALIGNED_H
 #define DPL_ALIGNED_H
index f2c309e..d4d9754 100644 (file)
 #include <dpl/atomic.h>
 #include <string>
 
 #include <dpl/atomic.h>
 #include <string>
 
-namespace DPL
-{
+namespace DPL {
 class Application
 {
 class Application
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, TooManyInstances)
         DECLARE_EXCEPTION_TYPE(Base, FrameworkError)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, TooManyInstances)
         DECLARE_EXCEPTION_TYPE(Base, FrameworkError)
     };
 
-private:
+  private:
     static int app_create(void *data);
     static int app_terminate(void *data);
     static int app_pause(void *data);
     static int app_resume(void *data);
     static int app_reset(bundle *b, void *data);
 
     static int app_create(void *data);
     static int app_terminate(void *data);
     static int app_pause(void *data);
     static int app_resume(void *data);
     static int app_reset(bundle *b, void *data);
 
-protected:
+  protected:
     int m_argc;
     char **m_argv;
     std::string m_applicationName;
     int m_argc;
     char **m_argv;
     std::string m_applicationName;
@@ -67,15 +66,18 @@ protected:
     virtual void OnLowBattery();
     virtual void OnLanguageChanged();
 
     virtual void OnLowBattery();
     virtual void OnLanguageChanged();
 
-public:
-    Application(int argc, char **argv, const std::string &applicationName, bool showMainWindow = true);
+  public:
+    Application(int argc,
+                char **argv,
+                const std::string &applicationName,
+                bool showMainWindow = true);
     virtual ~Application();
 
     /**
      * @brief Execute application and start message processing
      */
     virtual int Exec();
     virtual ~Application();
 
     /**
      * @brief Execute application and start message processing
      */
     virtual int Exec();
-    
+
     /*
      * @brief Sends quit message to application message loop
      */
     /*
      * @brief Sends quit message to application message loop
      */
@@ -84,8 +86,11 @@ public:
 
 class ApplicationExt : public Application
 {
 
 class ApplicationExt : public Application
 {
-public:
-    ApplicationExt(int argc, char **argv, const std::string &applicationName, bool showMainWindow = true);
+  public:
+    ApplicationExt(int argc,
+                   char **argv,
+                   const std::string &applicationName,
+                   bool showMainWindow = true);
     virtual ~ApplicationExt();
 
     /**
     virtual ~ApplicationExt();
 
     /**
@@ -97,10 +102,10 @@ public:
      * @brief Sends quit message to application message loop
      */
     virtual void Quit();
      * @brief Sends quit message to application message loop
      */
     virtual void Quit();
-private:
+
+  private:
     static DPL::Atomic m_useCount;
 };
     static DPL::Atomic m_useCount;
 };
-
 } // namespace DPL
 
 #endif // DPL_APPLICATION_H
 } // namespace DPL
 
 #endif // DPL_APPLICATION_H
index f441072..fc1be53 100644 (file)
@@ -29,8 +29,7 @@
 #include <tuple>
 #include <utility>
 
 #include <tuple>
 #include <utility>
 
-namespace DPL
-{
+namespace DPL {
 enum class ExtraArgsInsertPolicy
 {
     /**
 enum class ExtraArgsInsertPolicy
 {
     /**
@@ -59,7 +58,7 @@ Result Apply(Operation op,
              ArgsE && ... extra)
 {
     return _ApplyDispatchByPolicy<insertPolicy>::
              ArgsE && ... extra)
 {
     return _ApplyDispatchByPolicy<insertPolicy>::
-            template Apply<Result>(op, t, std::forward<ArgsE>(extra) ...);
+               template Apply<Result>(op, t, std::forward<ArgsE>(extra) ...);
 }
 
 template<size_t N, size_t M>
 }
 
 template<size_t N, size_t M>
@@ -76,11 +75,11 @@ struct _ApplyTuple
                         Args && ... args)
     {
         return _ApplyTuple<N - 1, M>::
                         Args && ... args)
     {
         return _ApplyTuple<N - 1, M>::
-                template Apply<Result>(op,
-                                       t1,
-                                       t2,
-                                       std::get<N - 1>(t1),
-                                       std::forward<Args>(args) ...);
+                   template Apply<Result>(op,
+                                          t1,
+                                          t2,
+                                          std::get<N - 1>(t1),
+                                          std::forward<Args>(args) ...);
     }
 };
 
     }
 };
 
@@ -98,11 +97,11 @@ struct _ApplyTuple<0, M>
                         Args && ... args)
     {
         return _ApplyTuple<0, M - 1>::
                         Args && ... args)
     {
         return _ApplyTuple<0, M - 1>::
-                template Apply<Result>(op,
-                                       t1,
-                                       t2,
-                                       std::get<M - 1>(t2),
-                                       std::forward<Args>(args) ...);
+                   template Apply<Result>(op,
+                                          t1,
+                                          t2,
+                                          std::get<M - 1>(t2),
+                                          std::forward<Args>(args) ...);
     }
 };
 
     }
 };
 
@@ -131,14 +130,14 @@ struct _ApplyArgs
              typename ... ArgsT,
              typename ... Args>
     static Result Apply(Operation op,
              typename ... ArgsT,
              typename ... Args>
     static Result Apply(Operation op,
-            const std::tuple<ArgsT ...>& t,
-            Args && ... args)
+                        const std::tuple<ArgsT ...>& t,
+                        Args && ... args)
     {
         return _ApplyArgs<N - 1>::
     {
         return _ApplyArgs<N - 1>::
-                       template Apply<Result>(op,
-                                              t,
-                                              std::get<N - 1>(t),
-                                              std::forward<Args>(args) ...);
+                   template Apply<Result>(op,
+                                          t,
+                                          std::get<N - 1>(t),
+                                          std::forward<Args>(args) ...);
     }
 };
 
     }
 };
 
@@ -169,9 +168,9 @@ struct _ApplyDispatchByPolicy<ExtraArgsInsertPolicy::Append>
                         ArgsE && ... extra)
     {
         return _ApplyArgs<sizeof ... (ArgsT)>::
                         ArgsE && ... extra)
     {
         return _ApplyArgs<sizeof ... (ArgsT)>::
-                       template Apply<Result>(op,
-                                              t,
-                                              std::forward<ArgsE>(extra) ...);
+                   template Apply<Result>(op,
+                                          t,
+                                          std::forward<ArgsE>(extra) ...);
     }
 };
 
     }
 };
 
@@ -187,9 +186,10 @@ struct _ApplyDispatchByPolicy<ExtraArgsInsertPolicy::Prepend>
                         ArgsE && ... extra)
     {
         return _ApplyTuple<sizeof ... (ArgsT), sizeof ... (ArgsE)>::
                         ArgsE && ... extra)
     {
         return _ApplyTuple<sizeof ... (ArgsT), sizeof ... (ArgsE)>::
-                       template Apply<Result>(op,
-                               t,
-                               std::make_tuple(std::forward<ArgsE>(extra) ...));
+                   template Apply<Result>(op,
+                                          t,
+                                          std::make_tuple(std::forward<ArgsE>(
+                                                              extra) ...));
     }
 };
 } // namespace DPL
     }
 };
 } // namespace DPL
index f0b62f7..59331a0 100644 (file)
 
 #include <dpl/noreturn.h>
 
 
 #include <dpl/noreturn.h>
 
-namespace DPL
-{
+namespace DPL {
 // Assertion handler procedure
 // Do not call directly
 // Always use Assert macro
 // Assertion handler procedure
 // Do not call directly
 // Always use Assert macro
-DPL_NORETURN void AssertProc(const char *condition, const char *file, int line, const char *function);
+DPL_NORETURN void AssertProc(const char *condition,
+                             const char *file,
+                             int line,
+                             const char *function);
 } // namespace DPL
 
 } // namespace DPL
 
-#define Assert(Condition) do { if (!(Condition)) DPL::AssertProc(#Condition, __FILE__, __LINE__, __FUNCTION__); } while (0)
+#define Assert(Condition) do { if (!(Condition)) { DPL::AssertProc(#Condition, \
+                                                                   __FILE__, \
+                                                                   __LINE__, \
+                                                                   __FUNCTION__); \
+                               } } while (0)
 
 #endif // DPL_ASSERT_H
 
 #endif // DPL_ASSERT_H
index 33ea8a9..50c4a1a 100644 (file)
 #pragma GCC system_header
 #include <glib.h>
 
 #pragma GCC system_header
 #include <glib.h>
 
-namespace DPL
-{
+namespace DPL {
 class Atomic
 {
 class Atomic
 {
-public:
+  public:
     typedef gint ValueType;
 
     typedef gint ValueType;
 
-private:
+  private:
     volatile ValueType m_value;
 
     volatile ValueType m_value;
 
-public:
+  public:
     Atomic(ValueType value = static_cast<ValueType>(0));
 
     ValueType ExchangeAndAdd(ValueType value);
     Atomic(ValueType value = static_cast<ValueType>(0));
 
     ValueType ExchangeAndAdd(ValueType value);
diff --git a/modules/core/include/dpl/auto_ptr.h b/modules/core/include/dpl/auto_ptr.h
new file mode 100644 (file)
index 0000000..f5838d8
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        auto_ptr.h
+ * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @author      Tomasz Swierczek (t.swierczek@samsung.com)
+ * @version     1.0
+ * @brief       This file contais definictions of specific AutoPtr class.
+ */
+#ifndef _AUTO_PTR_H_
+#define _AUTO_PTR_H_
+
+#include <list>
+#include <set>
+#include <string>
+
+namespace DPL {
+/*
+ * base deleter func
+ */
+template <typename T>
+struct UniversalFree {};
+
+// Template Specialization
+#define DECLARE_DELETER(type, function)           \
+    template <> \
+    struct UniversalFree <type> {           \
+        void universal_free(type * ptr){                  \
+            if (ptr) {                                      \
+                function(ptr); }                           \
+        }                                                \
+    };
+
+template <typename T>
+class AutoPtr
+{
+  public:
+    AutoPtr(T *ptr) :
+        m_data(ptr)
+    {}
+
+    AutoPtr(const AutoPtr<T> &second)
+    {
+        m_data = second.m_data;
+        second.m_data = 0;
+    }
+
+    AutoPtr & operator=(const AutoPtr &second)
+    {
+        if (this != &second) {
+            UniversalFree<T> deleter;
+            deleter.universal_free(m_data);
+            m_data = second.m_data;
+            second.m_data = 0;
+        }
+        return *this;
+    }
+
+    /**
+     * overloaded -> operator, so smart ptr could act as ordinary ptr
+     */
+    T* operator->()
+    {
+        return m_data;
+    }
+
+    ~AutoPtr()
+    {
+        UniversalFree<T> deleter;
+        deleter.universal_free(m_data);
+    }
+
+    /**
+     * get internal pointer
+     */
+    T* get(void)
+    {
+        return m_data;
+    }
+
+  private:
+    mutable T *m_data;
+};
+} // namespace DPL
+
+#endif // AUTO_PTR
index ae85ceb..f4fa278 100644 (file)
 #include <memory>
 #include <list>
 
 #include <memory>
 #include <list>
 
-namespace DPL
-{
+namespace DPL {
 /**
  * Binary stream implemented as constant size bucket list
  *
  * @todo Add optimized implementation for FlattenConsume
  */
 /**
  * Binary stream implemented as constant size bucket list
  *
  * @todo Add optimized implementation for FlattenConsume
  */
-class BinaryQueue
-    public AbstractInputOutput
+class BinaryQueue :
+    public AbstractInputOutput
 {
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OutOfData)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OutOfData)
     };
 
-    typedef void (*BufferDeleter)(const void *buffer, size_t bufferSize, void *userParam);
-    static void BufferDeleterFree(const void *buffer, size_t bufferSize, void *userParam);
+    typedef void (*BufferDeleter)(const void *buffer, size_t bufferSize,
+                                  void *userParam);
+    static void BufferDeleterFree(const void *buffer,
+                                  size_t bufferSize,
+                                  void *userParam);
 
     class BucketVisitor
     {
 
     class BucketVisitor
     {
-    public:
+      public:
         /**
          * Destructor
          */
         /**
          * Destructor
          */
@@ -67,9 +69,9 @@ public:
         virtual void OnVisitBucket(const void *buffer, size_t bufferSize) = 0;
     };
 
         virtual void OnVisitBucket(const void *buffer, size_t bufferSize) = 0;
     };
 
-private:
-    struct Bucket
-        private Noncopyable
+  private:
+    struct Bucket :
+        private Noncopyable
     {
         const void *buffer;
         const void *ptr;
     {
         const void *buffer;
         const void *ptr;
@@ -79,7 +81,10 @@ private:
         BufferDeleter deleter;
         void *param;
 
         BufferDeleter deleter;
         void *param;
 
-        Bucket(const void *buffer, size_t bufferSize, BufferDeleter deleter, void *userParam);
+        Bucket(const void *buffer,
+               size_t bufferSize,
+               BufferDeleter deleter,
+               void *userParam);
         virtual ~Bucket();
     };
 
         virtual ~Bucket();
     };
 
@@ -91,17 +96,17 @@ private:
 
     class BucketVisitorCall
     {
 
     class BucketVisitorCall
     {
-    private:
+      private:
         BucketVisitor *m_visitor;
 
         BucketVisitor *m_visitor;
 
-    public:
+      public:
         BucketVisitorCall(BucketVisitor *visitor);
         virtual ~BucketVisitorCall();
 
         void operator()(Bucket *bucket) const;
     };
 
         BucketVisitorCall(BucketVisitor *visitor);
         virtual ~BucketVisitorCall();
 
         void operator()(Bucket *bucket) const;
     };
 
-public:
+  public:
     /**
      * Construct empty binary queue
      */
     /**
      * Construct empty binary queue
      */
@@ -148,17 +153,24 @@ public:
      * @return none
      * @param[in] buffer Pointer to data buffer
      * @param[in] bufferSize Number of bytes available in buffer
      * @return none
      * @param[in] buffer Pointer to data buffer
      * @param[in] bufferSize Number of bytes available in buffer
-     * @param[in] deleter Pointer to deleter procedure used to free provided buffer
+     * @param[in] deleter Pointer to deleter procedure used to free provided
+     * buffer
      * @param[in] userParam User parameter passed to deleter routine
      * @exception std::bad_alloc Cannot allocate memory to hold additional data
      */
      * @param[in] userParam User parameter passed to deleter routine
      * @exception std::bad_alloc Cannot allocate memory to hold additional data
      */
-    void AppendUnmanaged(const void *buffer, size_t bufferSize, BufferDeleter deleter = &BinaryQueue::BufferDeleterFree, void *userParam = NULL);
+    void AppendUnmanaged(
+        const void *buffer,
+        size_t bufferSize,
+        BufferDeleter deleter =
+            &BinaryQueue::BufferDeleterFree,
+        void *userParam = NULL);
 
     /**
      * Append copy of other binary queue to the end of this binary queue
      *
      * @return none
 
     /**
      * Append copy of other binary queue to the end of this binary queue
      *
      * @return none
-     * @param[in] other Constant reference to other binary queue to copy data from
+     * @param[in] other Constant reference to other binary queue to copy data
+     * from
      * @exception std::bad_alloc Cannot allocate memory to hold additional data
      * @warning One cannot assume that bucket structure is preserved during copy
      */
      * @exception std::bad_alloc Cannot allocate memory to hold additional data
      * @warning One cannot assume that bucket structure is preserved during copy
      */
index 1b50c51..eb2988f 100644 (file)
  * @file        char_traits.h
  * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
  * @version     1.0
  * @file        char_traits.h
  * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
  * @version     1.0
- * @brief       Char traits are used to create basic_string extended with additional features
- *              Current char traits could be extended in feature to boost performance
+ * @brief       Char traits are used to create basic_string extended with
+ * additional features
+ *              Current char traits could be extended in feature to boost
+ * performance
  */
 #ifndef DPL_CHAR_TRAITS
 #define DPL_CHAR_TRAITS
  */
 #ifndef DPL_CHAR_TRAITS
 #define DPL_CHAR_TRAITS
 #include <algorithm>
 #include <dpl/exception.h>
 
 #include <algorithm>
 #include <dpl/exception.h>
 
-namespace DPL
-{
-
+namespace DPL {
 typedef std::char_traits<wchar_t> CharTraits;
 typedef std::char_traits<wchar_t> CharTraits;
-
 } // namespace DPL
 
 #endif // DPL_CHAR_TRAITS
 } // namespace DPL
 
 #endif // DPL_CHAR_TRAITS
index efc104d..c7cfd53 100644 (file)
 #ifndef DPL_COLORS_H
 #define DPL_COLORS_H
 
 #ifndef DPL_COLORS_H
 #define DPL_COLORS_H
 
-namespace DPL
-{
-
-namespace Colors
-{
-
-namespace Text
-{
-
+namespace DPL {
+namespace Colors {
+namespace Text {
 extern const char* BOLD_GREEN_BEGIN;
 extern const char* BOLD_GREEN_END;
 extern const char* PURPLE_BEGIN;
 extern const char* BOLD_GREEN_BEGIN;
 extern const char* BOLD_GREEN_END;
 extern const char* PURPLE_BEGIN;
@@ -51,12 +45,9 @@ extern const char* BOLD_GOLD_BEGIN;
 extern const char* BOLD_GOLD_END;
 extern const char* BOLD_WHITE_BEGIN;
 extern const char* BOLD_WHITE_END;
 extern const char* BOLD_GOLD_END;
 extern const char* BOLD_WHITE_BEGIN;
 extern const char* BOLD_WHITE_END;
-
 } //namespace Text
 
 } //namespace Text
 
-namespace Html
-{
-
+namespace Html {
 extern const char* BOLD_GREEN_BEGIN;
 extern const char* BOLD_GREEN_END;
 extern const char* PURPLE_BEGIN;
 extern const char* BOLD_GREEN_BEGIN;
 extern const char* BOLD_GREEN_END;
 extern const char* PURPLE_BEGIN;
@@ -75,11 +66,8 @@ extern const char* BOLD_GOLD_BEGIN;
 extern const char* BOLD_GOLD_END;
 extern const char* BOLD_WHITE_BEGIN;
 extern const char* BOLD_WHITE_END;
 extern const char* BOLD_GOLD_END;
 extern const char* BOLD_WHITE_BEGIN;
 extern const char* BOLD_WHITE_END;
-
 } //namespace Html
 } //namespace Html
-
 } //namespace Colors
 } //namespace Colors
-
 } //namespace DPL
 
 #endif /* DPL_COLORS_H */
 } //namespace DPL
 
 #endif /* DPL_COLORS_H */
index d91fbbc..e796a61 100644 (file)
@@ -26,8 +26,7 @@
 #include <dpl/abstract_waitable_output.h>
 #include <dpl/exception.h>
 
 #include <dpl/abstract_waitable_output.h>
 #include <dpl/exception.h>
 
-namespace DPL
-{
+namespace DPL {
 /**
  * Copy failed exception
  */
 /**
  * Copy failed exception
  */
@@ -38,18 +37,23 @@ DECLARE_EXCEPTION_TYPE(Exception, CopyFailed)
  *
  * @param[in] input Abstract waitable input to copy from
  * @param[in] output Abstract waitable output to copy to
  *
  * @param[in] input Abstract waitable input to copy from
  * @param[in] output Abstract waitable output to copy to
- * @throw CopyFailed An error occurred while copying. Look into exception trace for details.
+ * @throw CopyFailed An error occurred while copying. Look into exception trace
+ * for details.
  */
 void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output);
 
 /**
  */
 void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output);
 
 /**
- * Copy exactly totalBytes bytes abstract waitable input to abstract waitable output
+ * Copy exactly totalBytes bytes abstract waitable input to abstract waitable
+ * output
  *
  * @param[in] input Abstract waitable input to copy from
  * @param[in] output Abstract waitable output to copy to
  *
  * @param[in] input Abstract waitable input to copy from
  * @param[in] output Abstract waitable output to copy to
- * @throw CopyFailed An error occurred while copying. Look into exception trace for details.
+ * @throw CopyFailed An error occurred while copying. Look into exception trace
+ * for details.
  */
  */
-void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output, size_t totalBytes);
+void Copy(AbstractWaitableInput *input,
+          AbstractWaitableOutput *output,
+          size_t totalBytes);
 } // namespace DPL
 
 #endif // DPL_COPY_H
 } // namespace DPL
 
 #endif // DPL_COPY_H
index ed84130..0a0fb3a 100644 (file)
 #include <dpl/noncopyable.h>
 #include <dpl/assert.h>
 
 #include <dpl/noncopyable.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 template<typename Class>
 class EnableSharedFromThis : private Noncopyable
 {
 template<typename Class>
 class EnableSharedFromThis : private Noncopyable
 {
-
-private:
+  private:
     // A weak pointer to shared counter
     SharedCounter *m_counter;
     Class *m_ptr;
 
     // A weak pointer to shared counter
     SharedCounter *m_counter;
     Class *m_ptr;
 
-public:
+  public:
     DPL::SharedPtr<Class> SharedFromThis()
     {
         Assert(m_counter != NULL && "Pointer is not shared!");
     DPL::SharedPtr<Class> SharedFromThis()
     {
         Assert(m_counter != NULL && "Pointer is not shared!");
@@ -57,15 +55,13 @@ public:
         m_ptr = ptr;
     }
 
         m_ptr = ptr;
     }
 
-    EnableSharedFromThis()
-        : m_counter(NULL),
-          m_ptr(NULL)
-    {
-    }
+    EnableSharedFromThis() :
+        m_counter(NULL),
+        m_ptr(NULL)
+    {}
 
     virtual ~EnableSharedFromThis()
 
     virtual ~EnableSharedFromThis()
-    {
-    }
+    {}
 };
 } // namespace DPL
 
 };
 } // namespace DPL
 
index d3da348..446dbc9 100644 (file)
@@ -26,8 +26,7 @@
 #include <string>
 #include <cerrno>
 
 #include <string>
 #include <cerrno>
 
-namespace DPL
-{
+namespace DPL {
 DECLARE_EXCEPTION_TYPE(DPL::Exception, InvalidErrnoValue)
 
 std::string GetErrnoString(int error = errno);
 DECLARE_EXCEPTION_TYPE(DPL::Exception, InvalidErrnoValue)
 
 std::string GetErrnoString(int error = errno);
index a2e3dcf..cdbdc53 100644 (file)
 #include <cstdlib>
 #include <sstream>
 
 #include <cstdlib>
 #include <sstream>
 
-namespace DPL
-{
+namespace DPL {
 void LogUnhandledException(const std::string &str);
 void LogUnhandledException(const std::string &str);
-void LogUnhandledException(const std::string &str, const char *filename, int line, const char *function);
+void LogUnhandledException(const std::string &str,
+                           const char *filename,
+                           int line,
+                           const char *function);
 }
 
 }
 
-namespace DPL
-{
+namespace DPL {
 class Exception
 {
 class Exception
 {
-private:
+  private:
     static unsigned int m_exceptionCount;
     static Exception* m_lastException;
     static void (*m_terminateHandler)();
 
     static void AddRef(Exception* exception)
     {
     static unsigned int m_exceptionCount;
     static Exception* m_lastException;
     static void (*m_terminateHandler)();
 
     static void AddRef(Exception* exception)
     {
-        if (!m_exceptionCount)
-            m_terminateHandler  = std::set_terminate(&TerminateHandler);
+        if (!m_exceptionCount) {
+            m_terminateHandler = std::set_terminate(&TerminateHandler);
+        }
 
         ++m_exceptionCount;
         m_lastException = exception;
 
         ++m_exceptionCount;
         m_lastException = exception;
@@ -55,13 +57,13 @@ private:
 
     static void UnRef(Exception* e)
     {
 
     static void UnRef(Exception* e)
     {
-        if (m_lastException == e)
+        if (m_lastException == e) {
             m_lastException = NULL;
             m_lastException = NULL;
+        }
 
         --m_exceptionCount;
 
 
         --m_exceptionCount;
 
-        if (!m_exceptionCount)
-        {
+        if (!m_exceptionCount) {
             std::set_terminate(m_terminateHandler);
             m_terminateHandler = NULL;
         }
             std::set_terminate(m_terminateHandler);
             m_terminateHandler = NULL;
         }
@@ -69,13 +71,10 @@ private:
 
     static void TerminateHandler()
     {
 
     static void TerminateHandler()
     {
-        if (m_lastException != NULL)
-        {
+        if (m_lastException != NULL) {
             DisplayKnownException(*m_lastException);
             abort();
             DisplayKnownException(*m_lastException);
             abort();
-        }
-        else
-        {
+        } else {
             DisplayUnknownException();
             abort();
         }
             DisplayUnknownException();
             abort();
         }
@@ -86,15 +85,16 @@ private:
     std::string m_function;
     int m_line;
 
     std::string m_function;
     int m_line;
 
-protected:
+  protected:
     std::string m_message;
     std::string m_className;
 
     std::string m_message;
     std::string m_className;
 
-public:
+  public:
     static std::string KnownExceptionToString(const Exception &e)
     {
         std::ostringstream message;
     static std::string KnownExceptionToString(const Exception &e)
     {
         std::ostringstream message;
-        message << "\033[1;5;31m\n=== Unhandled DPL exception occurred ===\033[m\n\n";
+        message <<
+        "\033[1;5;31m\n=== Unhandled DPL exception occurred ===\033[m\n\n";
         message << "\033[1;33mException trace:\033[m\n\n";
         message << e.DumpToString();
         message << "\033[1;31m\n=== Will now abort ===\033[m\n";
         message << "\033[1;33mException trace:\033[m\n\n";
         message << e.DumpToString();
         message << "\033[1;31m\n=== Will now abort ===\033[m\n";
@@ -105,8 +105,9 @@ public:
     static std::string UnknownExceptionToString()
     {
         std::ostringstream message;
     static std::string UnknownExceptionToString()
     {
         std::ostringstream message;
-        message << "\033[1;5;31m\n=== Unhandled non-DPL exception occurred ===\033[m\n\n";
-        message <<  "\033[1;31m\n=== Will now abort ===\033[m\n";
+        message <<
+        "\033[1;5;31m\n=== Unhandled non-DPL exception occurred ===\033[m\n\n";
+        message << "\033[1;31m\n=== Will now abort ===\033[m\n";
 
         return message.str();
     }
 
         return message.str();
     }
@@ -124,10 +125,11 @@ public:
     Exception(const Exception &other)
     {
         // Deep copy
     Exception(const Exception &other)
     {
         // Deep copy
-        if (other.m_reason != NULL)
+        if (other.m_reason != NULL) {
             m_reason = new Exception(*other.m_reason);
             m_reason = new Exception(*other.m_reason);
-        else
+        } else {
             m_reason = NULL;
             m_reason = NULL;
+        }
 
         m_message = other.m_message;
         m_path = other.m_path;
 
         m_message = other.m_message;
         m_path = other.m_path;
@@ -141,14 +143,16 @@ public:
 
     const Exception &operator =(const Exception &other)
     {
 
     const Exception &operator =(const Exception &other)
     {
-        if (this == &other)
+        if (this == &other) {
             return *this;
             return *this;
+        }
 
         // Deep copy
 
         // Deep copy
-        if (other.m_reason != NULL)
+        if (other.m_reason != NULL) {
             m_reason = new Exception(*other.m_reason);
             m_reason = new Exception(*other.m_reason);
-        else
+        } else {
             m_reason = NULL;
             m_reason = NULL;
+        }
 
         m_message = other.m_message;
         m_path = other.m_path;
 
         m_message = other.m_message;
         m_path = other.m_path;
@@ -162,30 +166,36 @@ public:
         return *this;
     }
 
         return *this;
     }
 
-    Exception(const char *path, const char *function, int line, const std::string &message)
-        : m_reason(NULL),
-          m_path(path),
-          m_function(function),
-          m_line(line),
-          m_message(message)
+    Exception(const char *path,
+              const char *function,
+              int line,
+              const std::string &message) :
+        m_reason(NULL),
+        m_path(path),
+        m_function(function),
+        m_line(line),
+        m_message(message)
     {
         AddRef(this);
     }
 
     {
         AddRef(this);
     }
 
-    Exception(const char *path, const char *function, int line, const Exception &reason, const std::string &message)
-        : m_reason(new Exception(reason)),
-          m_path(path),
-          m_function(function),
-          m_line(line),
-          m_message(message)
+    Exception(const char *path,
+              const char *function,
+              int line,
+              const Exception &reason,
+              const std::string &message) :
+        m_reason(new Exception(reason)),
+        m_path(path),
+        m_function(function),
+        m_line(line),
+        m_message(message)
     {
         AddRef(this);
     }
 
     virtual ~Exception() throw()
     {
     {
         AddRef(this);
     }
 
     virtual ~Exception() throw()
     {
-        if (m_reason != NULL)
-        {
+        if (m_reason != NULL) {
             delete m_reason;
             m_reason = NULL;
         }
             delete m_reason;
             m_reason = NULL;
         }
@@ -196,16 +206,18 @@ public:
     void Dump() const
     {
         // Show reason first
     void Dump() const
     {
         // Show reason first
-        if (m_reason != NULL)
+        if (m_reason != NULL) {
             m_reason->Dump();
             m_reason->Dump();
+        }
 
         // Afterward, dump exception
         const char *file = strchr(m_path.c_str(), '/');
 
 
         // Afterward, dump exception
         const char *file = strchr(m_path.c_str(), '/');
 
-        if (file == NULL)
+        if (file == NULL) {
             file = m_path.c_str();
             file = m_path.c_str();
-        else
+        } else {
             ++file;
             ++file;
+        }
 
         printf("\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
                file, m_line,
 
         printf("\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
                file, m_line,
@@ -217,24 +229,29 @@ public:
     std::string DumpToString() const
     {
         std::string ret;
     std::string DumpToString() const
     {
         std::string ret;
-        if (m_reason != NULL)
+        if (m_reason != NULL) {
             ret = m_reason->DumpToString();
             ret = m_reason->DumpToString();
+        }
 
         const char *file = strchr(m_path.c_str(), '/');
 
 
         const char *file = strchr(m_path.c_str(), '/');
 
-        if (file == NULL)
+        if (file == NULL) {
             file = m_path.c_str();
             file = m_path.c_str();
-        else
+        } else {
             ++file;
             ++file;
+        }
 
         char buf[1024];
 
         char buf[1024];
-        snprintf(buf, sizeof(buf), "\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
-               file, m_line,
-               m_function.c_str(),
-               m_className.c_str(),
-               m_message.empty() ? "<EMPTY>" : m_message.c_str());
-
-        buf[sizeof(buf)-1] = '\n';
+        snprintf(buf,
+                 sizeof(buf),
+                 "\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
+                 file,
+                 m_line,
+                 m_function.c_str(),
+                 m_className.c_str(),
+                 m_message.empty() ? "<EMPTY>" : m_message.c_str());
+
+        buf[sizeof(buf) - 1] = '\n';
         ret += buf;
 
         return ret;
         ret += buf;
 
         return ret;
@@ -283,30 +300,41 @@ public:
         std::ostringstream dplLoggingStream;                                         \
         dplLoggingStream << Message;                                                 \
         throw ClassName(__FILE__, __FUNCTION__, __LINE__, dplLoggingStream.str());   \
         std::ostringstream dplLoggingStream;                                         \
         dplLoggingStream << Message;                                                 \
         throw ClassName(__FILE__, __FUNCTION__, __LINE__, dplLoggingStream.str());   \
-    }while(0)
+    } while (0)
 
 #define ReThrow(ClassName) \
     throw ClassName(__FILE__, __FUNCTION__, __LINE__, _rethrown_exception)
 
 #define ReThrowMsg(ClassName, Message) \
 
 #define ReThrow(ClassName) \
     throw ClassName(__FILE__, __FUNCTION__, __LINE__, _rethrown_exception)
 
 #define ReThrowMsg(ClassName, Message) \
-    throw ClassName(__FILE__, __FUNCTION__, __LINE__, _rethrown_exception, Message)
+    throw ClassName(__FILE__, \
+                    __FUNCTION__, \
+                    __LINE__, \
+                    _rethrown_exception, \
+                    Message)
 
 #define Catch(ClassName) \
     catch (const ClassName &_rethrown_exception)
 
 #define DECLARE_EXCEPTION_TYPE(BaseClass, Class)                                                                                          \
 
 #define Catch(ClassName) \
     catch (const ClassName &_rethrown_exception)
 
 #define DECLARE_EXCEPTION_TYPE(BaseClass, Class)                                                                                          \
-    class Class                                                                                                                           \
-        public BaseClass                                                                                                                \
+    class Class :                                                                                                                                 \
+        public BaseClass                                                                                                                \
     {                                                                                                                                     \
     {                                                                                                                                     \
-    public:                                                                                                                               \
-        Class(const char *path, const char *function, int line, const std::string &message = std::string())                               \
-            : BaseClass(path, function, line, message)                                                                                    \
+      public:                                                                                                                               \
+        Class(const char *path, \
+              const char *function, \
+              int line, \
+              const std::string & message = std::string()) :                                                                                                                             \
+            BaseClass(path, function, line, message)                                                                                    \
         {                                                                                                                                 \
             BaseClass::m_className = #Class;                                                                                              \
         }                                                                                                                                 \
                                                                                                                                           \
         {                                                                                                                                 \
             BaseClass::m_className = #Class;                                                                                              \
         }                                                                                                                                 \
                                                                                                                                           \
-        Class(const char *path, const char *function, int line, const DPL::Exception &reason, const std::string &message = std::string()) \
-            : BaseClass(path, function, line, reason, message)                                                                            \
+        Class(const char *path, \
+              const char *function, \
+              int line, \
+              const DPL::Exception & reason, \
+              const std::string & message = std::string()) :                                                                                                                             \
+            BaseClass(path, function, line, reason, message)                                                                            \
         {                                                                                                                                 \
             BaseClass::m_className = #Class;                                                                                              \
         }                                                                                                                                 \
         {                                                                                                                                 \
             BaseClass::m_className = #Class;                                                                                              \
         }                                                                                                                                 \
@@ -339,10 +367,8 @@ public:
         abort();                                                                                          \
     }
 
         abort();                                                                                          \
     }
 
-namespace DPL
-{
-namespace CommonException
-{
+namespace DPL {
+namespace CommonException {
 /**
  * Internal exception definitions
  *
 /**
  * Internal exception definitions
  *
@@ -350,7 +376,9 @@ namespace CommonException
  * Usually, exception trace with internal error includes
  * important messages.
  */
  * Usually, exception trace with internal error includes
  * important messages.
  */
-DECLARE_EXCEPTION_TYPE(Exception, InternalError) ///< Unexpected error from underlying libraries or kernel
+DECLARE_EXCEPTION_TYPE(Exception, InternalError) ///< Unexpected error from
+                                                 // underlying libraries or
+                                                 // kernel
 }
 }
 
 }
 }
 
index 501c801..8bc1a4b 100644 (file)
@@ -30,8 +30,7 @@
 #include <dpl/3rdparty/fastdelegate/FastDelegate.h>
 #include <dpl/3rdparty/fastdelegate/FastDelegateBind.h>
 
 #include <dpl/3rdparty/fastdelegate/FastDelegate.h>
 #include <dpl/3rdparty/fastdelegate/FastDelegateBind.h>
 
-namespace DPL
-{
+namespace DPL {
 using namespace fastdelegate;
 } // namespace DPL
 
 using namespace fastdelegate;
 } // namespace DPL
 
index d1e4641..3adcf21 100644 (file)
 #include <dpl/exception.h>
 #include <dpl/abstract_waitable_input.h>
 
 #include <dpl/exception.h>
 #include <dpl/abstract_waitable_input.h>
 
-namespace DPL
+namespace DPL {
+class FileInput :
+    private Noncopyable,
+    public AbstractWaitableInput
 {
 {
-class FileInput
-    : private Noncopyable,
-      public AbstractWaitableInput
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
-protected:
+  protected:
     int m_fd;
 
     int m_fd;
 
-public:
+  public:
     FileInput();
     FileInput(const std::string &fileName);
     virtual ~FileInput();
     FileInput();
     FileInput(const std::string &fileName);
     virtual ~FileInput();
index 48532dc..90be8cd 100644 (file)
 #include <dpl/exception.h>
 #include <dpl/abstract_waitable_output.h>
 
 #include <dpl/exception.h>
 #include <dpl/abstract_waitable_output.h>
 
-namespace DPL
+namespace DPL {
+class FileOutput :
+    private Noncopyable,
+    public AbstractWaitableOutput
 {
 {
-class FileOutput
-    : private Noncopyable,
-      public AbstractWaitableOutput
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
-protected:
+  protected:
     int m_fd;
 
     int m_fd;
 
-public:
+  public:
     FileOutput();
     FileOutput(const std::string &fileName);
     virtual ~FileOutput();
     FileOutput();
     FileOutput(const std::string &fileName);
     virtual ~FileOutput();
index 0923609..bbe477a 100644 (file)
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version     1.0
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of foreach macro for stl containers
+ * @brief       This file is the implementation file of foreach macro for stl
+ * containers
  */
 #ifndef DPL_FOREACH_H
 #define DPL_FOREACH_H
 
 #include <dpl/preprocessor.h>
 
  */
 #ifndef DPL_FOREACH_H
 #define DPL_FOREACH_H
 
 #include <dpl/preprocessor.h>
 
-namespace DPL
-{
-namespace Private
-{
-
+namespace DPL {
+namespace Private {
 /*
  * Used to detect type of valid reference to value object.
  */
 /*
  * Used to detect type of valid reference to value object.
  */
@@ -44,23 +42,20 @@ const T& ValueReference(const T& t)
 {
     return(t);
 }
 {
     return(t);
 }
-
-
 } //Private
 } //DPL
 
 } //Private
 } //DPL
 
-
 #define DPL_FOREACH_IMPL(temporaryName, iterator, container)            \
     __typeof__ (DPL::Private::ValueReference((container))) &            \
     temporaryName = (container);                                        \
 #define DPL_FOREACH_IMPL(temporaryName, iterator, container)            \
     __typeof__ (DPL::Private::ValueReference((container))) &            \
     temporaryName = (container);                                        \
-    for (__typeof__ (temporaryName.begin()) iterator =                  \
+    for (__typeof__ (temporaryName.begin())iterator =                  \
              temporaryName.begin();                                     \
          (iterator) != temporaryName.end(); ++iterator)
 
 #define FOREACH(iterator, container)                                    \
     DPL_FOREACH_IMPL(                                                   \
         DPL_MACRO_CONCAT(foreachContainerReference, __COUNTER__),       \
              temporaryName.begin();                                     \
          (iterator) != temporaryName.end(); ++iterator)
 
 #define FOREACH(iterator, container)                                    \
     DPL_FOREACH_IMPL(                                                   \
         DPL_MACRO_CONCAT(foreachContainerReference, __COUNTER__),       \
-                         iterator,                                      \
-                         container)
+        iterator,                                      \
+        container)
 
 #endif // DPL_FOREACH_H
 
 #endif // DPL_FOREACH_H
index 371717a..b20d913 100644 (file)
 #ifndef DPL_GENERIC_EVENT_H
 #define DPL_GENERIC_EVENT_H
 
 #ifndef DPL_GENERIC_EVENT_H
 #define DPL_GENERIC_EVENT_H
 
-namespace DPL
-{
-
+namespace DPL {
 class EventSender
 {
 class EventSender
 {
-public:
-    explicit EventSender(void *sender)
-        : m_sender(sender)
-    {
-    }
+  public:
+    explicit EventSender(void *sender) :
+        m_sender(sender)
+    {}
 
     void* GetSender() const
     {
         return m_sender;
     }
 
 
     void* GetSender() const
     {
         return m_sender;
     }
 
-private:
+  private:
     void *m_sender;
 };
 
 class GenericEvent
 {
     void *m_sender;
 };
 
 class GenericEvent
 {
-protected:
+  protected:
     void *m_sender;
 
     void *m_sender;
 
-public:
-    explicit GenericEvent(const EventSender &sender)
-        : m_sender(sender.GetSender())
-    {
-    }
+  public:
+    explicit GenericEvent(const EventSender &sender) :
+        m_sender(sender.GetSender())
+    {}
 
     virtual ~GenericEvent()
 
     virtual ~GenericEvent()
-    {
-    }
+    {}
 
     void *GetSender() const
     {
 
     void *GetSender() const
     {
@@ -63,46 +58,40 @@ public:
     }
 };
 
     }
 };
 
-class GenericEvent0
-    public GenericEvent
+class GenericEvent0 :
+    public GenericEvent
 {
 {
-public:
-    explicit GenericEvent0(const EventSender &sender)
-        : GenericEvent(sender)
-    {
-    }
+  public:
+    explicit GenericEvent0(const EventSender &sender) :
+        GenericEvent(sender)
+    {}
 
     virtual ~GenericEvent0()
 
     virtual ~GenericEvent0()
-    {
-    }
-
+    {}
 };
 
 template<typename Arg0Type>
 };
 
 template<typename Arg0Type>
-class GenericEvent1
-    public GenericEvent0
+class GenericEvent1 :
+    public GenericEvent0
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
 
     typedef Arg0Type Arg0;
 
-protected:
+  protected:
     Arg0 m_arg0;
 
     Arg0 m_arg0;
 
-public:
-    explicit GenericEvent1(const EventSender &sender)
-        : GenericEvent0(sender)
-    {
-    }
+  public:
+    explicit GenericEvent1(const EventSender &sender) :
+        GenericEvent0(sender)
+    {}
 
 
-    GenericEvent1(Arg0 arg0, const EventSender &sender)
-        : GenericEvent0(sender),
-          m_arg0(arg0)
-    {
-    }
+    GenericEvent1(Arg0 arg0, const EventSender &sender) :
+        GenericEvent0(sender),
+        m_arg0(arg0)
+    {}
 
     virtual ~GenericEvent1()
 
     virtual ~GenericEvent1()
-    {
-    }
+    {}
 
     Arg0 GetArg0() const
     {
 
     Arg0 GetArg0() const
     {
@@ -111,31 +100,28 @@ public:
 };
 
 template<typename Arg0Type, typename Arg1Type>
 };
 
 template<typename Arg0Type, typename Arg1Type>
-class GenericEvent2
-    public GenericEvent1<Arg0Type>
+class GenericEvent2 :
+    public GenericEvent1<Arg0Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
 
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
 
-protected:
+  protected:
     Arg1 m_arg1;
 
     Arg1 m_arg1;
 
-public:
-    explicit GenericEvent2(const EventSender &sender)
-        : GenericEvent1<Arg0Type>(sender)
-    {
-    }
+  public:
+    explicit GenericEvent2(const EventSender &sender) :
+        GenericEvent1<Arg0Type>(sender)
+    {}
 
 
-    GenericEvent2(Arg0 arg0, Arg1 arg1, const EventSender &sender)
-        : GenericEvent1<Arg0Type>(arg0, sender),
-          m_arg1(arg1)
-    {
-    }
+    GenericEvent2(Arg0 arg0, Arg1 arg1, const EventSender &sender) :
+        GenericEvent1<Arg0Type>(arg0, sender),
+        m_arg1(arg1)
+    {}
 
     virtual ~GenericEvent2()
 
     virtual ~GenericEvent2()
-    {
-    }
+    {}
 
     Arg1 GetArg1() const
     {
 
     Arg1 GetArg1() const
     {
@@ -144,32 +130,29 @@ public:
 };
 
 template<typename Arg0Type, typename Arg1Type, typename Arg2Type>
 };
 
 template<typename Arg0Type, typename Arg1Type, typename Arg2Type>
-class GenericEvent3
-    public GenericEvent2<Arg0Type, Arg1Type>
+class GenericEvent3 :
+    public GenericEvent2<Arg0Type, Arg1Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
 
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
 
-protected:
+  protected:
     Arg2 m_arg2;
 
     Arg2 m_arg2;
 
-public:
-    explicit GenericEvent3(const EventSender &sender)
-        : GenericEvent2<Arg0Type, Arg1Type>(sender)
-    {
-    }
+  public:
+    explicit GenericEvent3(const EventSender &sender) :
+        GenericEvent2<Arg0Type, Arg1Type>(sender)
+    {}
 
 
-    GenericEvent3(Arg0 arg0, Arg1 arg1, Arg2 arg2, const EventSender &sender)
-        : GenericEvent2<Arg0Type, Arg1Type>(arg0, arg1, sender),
-          m_arg2(arg2)
-    {
-    }
+    GenericEvent3(Arg0 arg0, Arg1 arg1, Arg2 arg2, const EventSender &sender) :
+        GenericEvent2<Arg0Type, Arg1Type>(arg0, arg1, sender),
+        m_arg2(arg2)
+    {}
 
     virtual ~GenericEvent3()
 
     virtual ~GenericEvent3()
-    {
-    }
+    {}
 
     Arg2 GetArg2() const
     {
 
     Arg2 GetArg2() const
     {
@@ -177,34 +160,36 @@ public:
     }
 };
 
     }
 };
 
-template<typename Arg0Type, typename Arg1Type, typename Arg2Type, typename Arg3Type>
-class GenericEvent4
-    : public GenericEvent3<Arg0Type, Arg1Type, Arg2Type>
+template<typename Arg0Type, typename Arg1Type, typename Arg2Type,
+         typename Arg3Type>
+class GenericEvent4 :
+    public GenericEvent3<Arg0Type, Arg1Type, Arg2Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg3Type Arg3;
 
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg3Type Arg3;
 
-protected:
+  protected:
     Arg3 m_arg3;
 
     Arg3 m_arg3;
 
-public:
-    explicit GenericEvent4(const EventSender &sender)
-        : GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(sender)
-    {
-    }
+  public:
+    explicit GenericEvent4(const EventSender &sender) :
+        GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(sender)
+    {}
 
 
-    GenericEvent4(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3, const EventSender &sender)
-        : GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(arg0, arg1, arg2, sender),
-          m_arg3(arg3)
-    {
-    }
+    GenericEvent4(Arg0 arg0,
+                  Arg1 arg1,
+                  Arg2 arg2,
+                  Arg3 arg3,
+                  const EventSender &sender) :
+        GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(arg0, arg1, arg2, sender),
+        m_arg3(arg3)
+    {}
 
     virtual ~GenericEvent4()
 
     virtual ~GenericEvent4()
-    {
-    }
+    {}
 
     Arg3 GetArg3() const
     {
 
     Arg3 GetArg3() const
     {
@@ -212,35 +197,39 @@ public:
     }
 };
 
     }
 };
 
-template<typename Arg0Type, typename Arg1Type, typename Arg2Type, typename Arg3Type, typename Arg4Type>
-class GenericEvent5
-    : public GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>
+template<typename Arg0Type, typename Arg1Type, typename Arg2Type,
+         typename Arg3Type, typename Arg4Type>
+class GenericEvent5 :
+    public GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg3Type Arg3;
     typedef Arg4Type Arg4;
 
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg3Type Arg3;
     typedef Arg4Type Arg4;
 
-protected:
+  protected:
     Arg4 m_arg4;
 
     Arg4 m_arg4;
 
-public:
-    explicit GenericEvent5(const EventSender &sender)
-        : GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(sender)
-    {
-    }
-
-    GenericEvent5(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, const EventSender &sender)
-        : GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(arg0, arg1, arg2, arg3, sender),
-          m_arg4(arg4)
-    {
-    }
+  public:
+    explicit GenericEvent5(const EventSender &sender) :
+        GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(sender)
+    {}
+
+    GenericEvent5(Arg0 arg0,
+                  Arg1 arg1,
+                  Arg2 arg2,
+                  Arg3 arg3,
+                  Arg4 arg4,
+                  const EventSender &sender) :
+        GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(arg0, arg1, arg2,
+                                                              arg3, sender),
+        m_arg4(arg4)
+    {}
 
     virtual ~GenericEvent5()
 
     virtual ~GenericEvent5()
-    {
-    }
+    {}
 
     Arg4 GetArg4() const
     {
 
     Arg4 GetArg4() const
     {
@@ -248,11 +237,12 @@ public:
     }
 };
 
     }
 };
 
-template<typename Arg0Type, typename Arg1Type, typename Arg2Type, typename Arg3Type, typename Arg4Type, typename Arg5Type>
-class GenericEvent6
-    : public GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>
+template<typename Arg0Type, typename Arg1Type, typename Arg2Type,
+         typename Arg3Type, typename Arg4Type, typename Arg5Type>
+class GenericEvent6 :
+    public GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
@@ -260,24 +250,32 @@ public:
     typedef Arg4Type Arg4;
     typedef Arg5Type Arg5;
 
     typedef Arg4Type Arg4;
     typedef Arg5Type Arg5;
 
-protected:
+  protected:
     Arg5 m_arg5;
 
     Arg5 m_arg5;
 
-public:
-    explicit GenericEvent6(const EventSender &sender)
-        : GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>(sender)
-    {
-    }
-
-    GenericEvent6(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, const EventSender &sender)
-        : GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>(arg0, arg1, arg2, arg3, arg4, sender),
-          m_arg5(arg5)
-    {
-    }
+  public:
+    explicit GenericEvent6(const EventSender &sender) :
+        GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>(sender)
+    {}
+
+    GenericEvent6(Arg0 arg0,
+                  Arg1 arg1,
+                  Arg2 arg2,
+                  Arg3 arg3,
+                  Arg4 arg4,
+                  Arg5 arg5,
+                  const EventSender &sender) :
+        GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>(arg0,
+                                                                        arg1,
+                                                                        arg2,
+                                                                        arg3,
+                                                                        arg4,
+                                                                        sender),
+        m_arg5(arg5)
+    {}
 
     virtual ~GenericEvent6()
 
     virtual ~GenericEvent6()
-    {
-    }
+    {}
 
     Arg5 GetArg5() const
     {
 
     Arg5 GetArg5() const
     {
@@ -285,11 +283,14 @@ public:
     }
 };
 
     }
 };
 
-template<typename Arg0Type, typename Arg1Type, typename Arg2Type, typename Arg3Type, typename Arg4Type, typename Arg5Type, typename Arg6Type>
-class GenericEvent7
-    : public GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type>
+template<typename Arg0Type, typename Arg1Type, typename Arg2Type,
+         typename Arg3Type, typename Arg4Type, typename Arg5Type,
+         typename Arg6Type>
+class GenericEvent7 :
+    public GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type,
+                         Arg5Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
@@ -298,24 +299,30 @@ public:
     typedef Arg5Type Arg5;
     typedef Arg6Type Arg6;
 
     typedef Arg5Type Arg5;
     typedef Arg6Type Arg6;
 
-protected:
+  protected:
     Arg6 m_arg6;
 
     Arg6 m_arg6;
 
-public:
-    explicit GenericEvent7(const EventSender &sender)
-        : GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type>(sender)
-    {
-    }
-
-    GenericEvent7(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, const EventSender &sender)
-        : GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type>(arg0, arg1, arg2, arg3, arg4, arg5, sender),
-          m_arg6(arg6)
-    {
-    }
+  public:
+    explicit GenericEvent7(const EventSender &sender) :
+        GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type,
+                      Arg5Type>(sender)
+    {}
+
+    GenericEvent7(Arg0 arg0,
+                  Arg1 arg1,
+                  Arg2 arg2,
+                  Arg3 arg3,
+                  Arg4 arg4,
+                  Arg5 arg5,
+                  Arg6 arg6,
+                  const EventSender &sender) :
+        GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type,
+                      Arg5Type>(arg0, arg1, arg2, arg3, arg4, arg5, sender),
+        m_arg6(arg6)
+    {}
 
     virtual ~GenericEvent7()
 
     virtual ~GenericEvent7()
-    {
-    }
+    {}
 
     Arg6 GetArg6() const
     {
 
     Arg6 GetArg6() const
     {
@@ -323,11 +330,15 @@ public:
     }
 };
 
     }
 };
 
-template<typename Arg0Type, typename Arg1Type, typename Arg2Type, typename Arg3Type, typename Arg4Type, typename Arg5Type, typename Arg6Type, typename Arg7Type>
-class GenericEvent8
-    : public GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type>
+template<typename Arg0Type, typename Arg1Type, typename Arg2Type,
+         typename Arg3Type, typename Arg4Type, typename Arg5Type,
+         typename Arg6Type,
+         typename Arg7Type>
+class GenericEvent8 :
+    public GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type,
+                         Arg5Type, Arg6Type>
 {
 {
-public:
+  public:
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
     typedef Arg0Type Arg0;
     typedef Arg1Type Arg1;
     typedef Arg2Type Arg2;
@@ -337,176 +348,290 @@ public:
     typedef Arg6Type Arg6;
     typedef Arg7Type Arg7;
 
     typedef Arg6Type Arg6;
     typedef Arg7Type Arg7;
 
-protected:
+  protected:
     Arg7 m_arg7;
 
     Arg7 m_arg7;
 
-public:
-    explicit GenericEvent8(const EventSender &sender)
-        : GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type>(sender)
-    {
-    }
-
-    GenericEvent8(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7, const EventSender &sender)
-        : GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, sender),
-          m_arg7(arg7)
-    {
-    }
+  public:
+    explicit GenericEvent8(const EventSender &sender) :
+        GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type,
+                      Arg5Type, Arg6Type>(sender)
+    {}
+
+    GenericEvent8(Arg0 arg0,
+                  Arg1 arg1,
+                  Arg2 arg2,
+                  Arg3 arg3,
+                  Arg4 arg4,
+                  Arg5 arg5,
+                  Arg6 arg6,
+                  Arg7 arg7,
+                  const EventSender &sender) :
+        GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type,
+                      Arg5Type, Arg6Type>(arg0, arg1, arg2, arg3, arg4, arg5,
+                                          arg6, sender),
+        m_arg7(arg7)
+    {}
 
     virtual ~GenericEvent8()
 
     virtual ~GenericEvent8()
-    {
-    }
+    {}
 
     Arg7 GetArg7() const
     {
         return m_arg7;
     }
 };
 
     Arg7 GetArg7() const
     {
         return m_arg7;
     }
 };
-
 } // namespace DPL
 
 #define DECLARE_GENERIC_EVENT_0(ClassName)                                  \
 } // namespace DPL
 
 #define DECLARE_GENERIC_EVENT_0(ClassName)                                  \
-    class ClassName                                                         \
-        public DPL::GenericEvent0                                         \
+    class ClassName :                                                                   \
+        public DPL::GenericEvent0                                         \
     {                                                                       \
     {                                                                       \
-    public:                                                                 \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL)) \
-            : DPL::GenericEvent0(sender)                                    \
+      public:                                                                 \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                       \
+            DPL::GenericEvent0(sender)                                    \
         {                                                                   \
         }                                                                   \
     };
 
 #define DECLARE_GENERIC_EVENT_1(ClassName, Arg0Type)                          \
         {                                                                   \
         }                                                                   \
     };
 
 #define DECLARE_GENERIC_EVENT_1(ClassName, Arg0Type)                          \
-    class ClassName                                                           \
-        public DPL::GenericEvent1<Arg0Type>                                 \
+    class ClassName :                                                                     \
+        public DPL::GenericEvent1<Arg0Type>                                 \
     {                                                                         \
     {                                                                         \
-    public:                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL)) \
-            : DPL::GenericEvent1<Arg0Type>(sender)                            \
+      public:                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                       \
+            DPL::GenericEvent1<Arg0Type>(sender)                            \
         {                                                                     \
         }                                                                     \
                                                                               \
         explicit ClassName(Arg0Type arg0,                                     \
         {                                                                     \
         }                                                                     \
                                                                               \
         explicit ClassName(Arg0Type arg0,                                     \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))    \
-            : DPL::GenericEvent1<Arg0Type>(arg0, sender)                      \
+                           const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                 \
+            DPL::GenericEvent1<Arg0Type>(arg0, sender)                      \
         {                                                                     \
         }                                                                     \
     };
 
 #define DECLARE_GENERIC_EVENT_2(ClassName, Arg0Type, Arg1Type)                \
         {                                                                     \
         }                                                                     \
     };
 
 #define DECLARE_GENERIC_EVENT_2(ClassName, Arg0Type, Arg1Type)                \
-    class ClassName                                                           \
-        public DPL::GenericEvent2<Arg0Type, Arg1Type>                       \
+    class ClassName :                                                                     \
+        public DPL::GenericEvent2<Arg0Type, Arg1Type>                       \
     {                                                                         \
     {                                                                         \
-    public:                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL)) \
-            : DPL::GenericEvent2<Arg0Type, Arg1Type>(sender)                  \
+      public:                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                       \
+            DPL::GenericEvent2<Arg0Type, Arg1Type>(sender)                  \
         {                                                                     \
         }                                                                     \
                                                                               \
         ClassName(Arg0Type arg0, Arg1Type arg1,                               \
         {                                                                     \
         }                                                                     \
                                                                               \
         ClassName(Arg0Type arg0, Arg1Type arg1,                               \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))    \
-            DPL::GenericEvent2<Arg0Type, Arg1Type>(arg0, arg1, sender)      \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                 \
+            DPL::GenericEvent2<Arg0Type, Arg1Type>(arg0, arg1, sender)      \
         {                                                                     \
         }                                                                     \
     };
 
 #define DECLARE_GENERIC_EVENT_3(ClassName, Arg0Type, Arg1Type, Arg2Type)                      \
         {                                                                     \
         }                                                                     \
     };
 
 #define DECLARE_GENERIC_EVENT_3(ClassName, Arg0Type, Arg1Type, Arg2Type)                      \
-    class ClassName                                                                           \
-        public DPL::GenericEvent3<Arg0Type, Arg1Type, Arg2Type>                             \
+    class ClassName :                                                                                     \
+        public DPL::GenericEvent3<Arg0Type, Arg1Type, Arg2Type>                             \
     {                                                                                         \
     {                                                                                         \
-    public:                                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL))           \
-            : DPL::GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(sender)                        \
+      public:                                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                                 \
+            DPL::GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(sender)                        \
         {                                                                                     \
         }                                                                                     \
                                                                                               \
         ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2,                                \
         {                                                                                     \
         }                                                                                     \
                                                                                               \
         ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2,                                \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))                    \
-            : DPL::GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(arg0, arg1, arg2, sender)      \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                                 \
+            DPL::GenericEvent3<Arg0Type, Arg1Type, Arg2Type>(arg0, \
+                                                             arg1, \
+                                                             arg2, \
+                                                             sender)      \
         {                                                                                     \
         }                                                                                     \
     };
 
         {                                                                                     \
         }                                                                                     \
     };
 
-#define DECLARE_GENERIC_EVENT_4(ClassName, Arg0Type, Arg1Type, Arg2Type, Arg3Type)                            \
-    class ClassName                                                                                           \
-        : public DPL::GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>                                   \
+#define DECLARE_GENERIC_EVENT_4(ClassName, \
+                                Arg0Type, \
+                                Arg1Type, \
+                                Arg2Type, \
+                                Arg3Type)                            \
+    class ClassName :                                                                                                     \
+        public DPL::GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>                                   \
     {                                                                                                         \
     {                                                                                                         \
-    public:                                                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL))                           \
-            : DPL::GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(sender)                              \
+      public:                                                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                                                 \
+            DPL::GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(sender)                              \
         {                                                                                                     \
         }                                                                                                     \
                                                                                                               \
         ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3,                                 \
         {                                                                                                     \
         }                                                                                                     \
                                                                                                               \
         ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3,                                 \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))                                    \
-            : DPL::GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(arg0, arg1, arg2, arg3, sender)      \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                                                 \
+            DPL::GenericEvent4<Arg0Type, Arg1Type, Arg2Type, Arg3Type>(arg0, \
+                                                                       arg1, \
+                                                                       arg2, \
+                                                                       arg3, \
+                                                                       sender)      \
         {                                                                                                     \
         }                                                                                                     \
     };
 
         {                                                                                                     \
         }                                                                                                     \
     };
 
-#define DECLARE_GENERIC_EVENT_5(ClassName, Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type)                                  \
-    class ClassName                                                                                                           \
-        : public DPL::GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>                                         \
+#define DECLARE_GENERIC_EVENT_5(ClassName, \
+                                Arg0Type, \
+                                Arg1Type, \
+                                Arg2Type, \
+                                Arg3Type, \
+                                Arg4Type)                                  \
+    class ClassName :                                                                                                                     \
+        public DPL::GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, \
+                                  Arg4Type>                                         \
     {                                                                                                                         \
     {                                                                                                                         \
-    public:                                                                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL))                                           \
-            : DPL::GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>(sender)                                    \
+      public:                                                                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                                                                 \
+            DPL::GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>( \
+                sender)                                    \
         {                                                                                                                     \
         }                                                                                                                     \
                                                                                                                               \
         {                                                                                                                     \
         }                                                                                                                     \
                                                                                                                               \
-        ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4,                                  \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))                                                    \
-            : DPL::GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>(arg0, arg1, arg2, arg3, arg4, sender)      \
+        ClassName(Arg0Type arg0, \
+                  Arg1Type arg1, \
+                  Arg2Type arg2, \
+                  Arg3Type arg3, \
+                  Arg4Type arg4,                                  \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                                                                 \
+            DPL::GenericEvent5<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type>( \
+                arg0, \
+                arg1, \
+                arg2, \
+                arg3, \
+                arg4, \
+                sender)      \
         {                                                                                                                     \
         }                                                                                                                     \
     };
 
         {                                                                                                                     \
         }                                                                                                                     \
     };
 
-#define DECLARE_GENERIC_EVENT_6(ClassName, Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type)                                        \
-    class ClassName                                                                                                                           \
-        : public DPL::GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type>                                               \
+#define DECLARE_GENERIC_EVENT_6(ClassName, \
+                                Arg0Type, \
+                                Arg1Type, \
+                                Arg2Type, \
+                                Arg3Type, \
+                                Arg4Type, \
+                                Arg5Type)                                        \
+    class ClassName :                                                                                                                                     \
+        public DPL::GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, \
+                                  Arg4Type, Arg5Type>                                               \
     {                                                                                                                                         \
     {                                                                                                                                         \
-    public:                                                                                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL))                                                           \
-            : DPL::GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type>(sender)                                          \
+      public:                                                                                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                                                                                 \
+            DPL::GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, \
+                               Arg5Type>(sender)                                          \
         {                                                                                                                                     \
         }                                                                                                                                     \
                                                                                                                                               \
         {                                                                                                                                     \
         }                                                                                                                                     \
                                                                                                                                               \
-        ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5,                                   \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))                                                                    \
-            : DPL::GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type>(arg0, arg1, arg2, arg3, arg4, arg5, sender)      \
+        ClassName(Arg0Type arg0, \
+                  Arg1Type arg1, \
+                  Arg2Type arg2, \
+                  Arg3Type arg3, \
+                  Arg4Type arg4, \
+                  Arg5Type arg5,                                   \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                                                                                 \
+            DPL::GenericEvent6<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, \
+                               Arg5Type>(arg0, \
+                                         arg1, \
+                                         arg2, \
+                                         arg3, \
+                                         arg4, \
+                                         arg5, \
+                                         sender)      \
         {                                                                                                                                     \
         }                                                                                                                                     \
     };
 
         {                                                                                                                                     \
         }                                                                                                                                     \
     };
 
-#define DECLARE_GENERIC_EVENT_7(ClassName, Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type)                                              \
-    class ClassName                                                                                                                                           \
-        : public DPL::GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type>                                                     \
+#define DECLARE_GENERIC_EVENT_7(ClassName, \
+                                Arg0Type, \
+                                Arg1Type, \
+                                Arg2Type, \
+                                Arg3Type, \
+                                Arg4Type, \
+                                Arg5Type, \
+                                Arg6Type)                                              \
+    class ClassName :                                                                                                                                                     \
+        public DPL::GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, \
+                                  Arg4Type, Arg5Type, Arg6Type>                                                     \
     {                                                                                                                                                         \
     {                                                                                                                                                         \
-    public:                                                                                                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL))                                                                           \
-            : DPL::GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type>(sender)                                                \
+      public:                                                                                                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                                                                                                 \
+            DPL::GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, \
+                               Arg5Type, Arg6Type>(sender)                                                \
         {                                                                                                                                                     \
         }                                                                                                                                                     \
                                                                                                                                                               \
         {                                                                                                                                                     \
         }                                                                                                                                                     \
                                                                                                                                                               \
-        ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5, Arg6Type arg6,                                    \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))                                                                                    \
-            : DPL::GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, sender)      \
+        ClassName(Arg0Type arg0, \
+                  Arg1Type arg1, \
+                  Arg2Type arg2, \
+                  Arg3Type arg3, \
+                  Arg4Type arg4, \
+                  Arg5Type arg5, \
+                  Arg6Type arg6,                                    \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                                                                                                 \
+            DPL::GenericEvent7<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, \
+                               Arg5Type, Arg6Type>(arg0, \
+                                                   arg1, \
+                                                   arg2, \
+                                                   arg3, \
+                                                   arg4, \
+                                                   arg5, \
+                                                   arg6, \
+                                                   sender)      \
         {                                                                                                                                                     \
         }                                                                                                                                                     \
     };
 
         {                                                                                                                                                     \
         }                                                                                                                                                     \
     };
 
-#define DECLARE_GENERIC_EVENT_8(ClassName, Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type, Arg7Type)                                                    \
-    class ClassName                                                                                                                                                           \
-        : public DPL::GenericEvent8<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type, Arg7Type>                                                           \
+#define DECLARE_GENERIC_EVENT_8(ClassName, \
+                                Arg0Type, \
+                                Arg1Type, \
+                                Arg2Type, \
+                                Arg3Type, \
+                                Arg4Type, \
+                                Arg5Type, \
+                                Arg6Type, \
+                                Arg7Type)                                                    \
+    class ClassName :                                                                                                                                                                     \
+        public DPL::GenericEvent8<Arg0Type, Arg1Type, Arg2Type, Arg3Type, \
+                                  Arg4Type, Arg5Type, Arg6Type, Arg7Type>                                                           \
     {                                                                                                                                                                         \
     {                                                                                                                                                                         \
-    public:                                                                                                                                                                   \
-        explicit ClassName(const DPL::EventSender &sender = DPL::EventSender(NULL))                                                                                           \
-            : DPL::GenericEvent8<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type, Arg7Type>(sender)                                                      \
+      public:                                                                                                                                                                   \
+        explicit ClassName(const DPL::EventSender & sender = \
+                               DPL::EventSender(NULL)) :                                                                                                                                                                 \
+            DPL::GenericEvent8<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, \
+                               Arg5Type, Arg6Type, Arg7Type>(sender)                                                      \
         {                                                                                                                                                                     \
         }                                                                                                                                                                     \
                                                                                                                                                                               \
         {                                                                                                                                                                     \
         }                                                                                                                                                                     \
                                                                                                                                                                               \
-        ClassName(Arg0Type arg0, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, Arg4Type arg4, Arg5Type arg5, Arg6Type arg6, Arg7Type arg7,                                     \
-                  const DPL::EventSender &sender = DPL::EventSender(NULL))                                                                                                    \
-            : DPL::GenericEvent8<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, Arg6Type, Arg7Type>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, sender)      \
+        ClassName(Arg0Type arg0, \
+                  Arg1Type arg1, \
+                  Arg2Type arg2, \
+                  Arg3Type arg3, \
+                  Arg4Type arg4, \
+                  Arg5Type arg5, \
+                  Arg6Type arg6, \
+                  Arg7Type arg7,                                     \
+                  const DPL::EventSender & sender = DPL::EventSender(NULL)) :                                                                                                                                                                 \
+            DPL::GenericEvent8<Arg0Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, \
+                               Arg5Type, Arg6Type, Arg7Type>(arg0, \
+                                                             arg1, \
+                                                             arg2, \
+                                                             arg3, \
+                                                             arg4, \
+                                                             arg5, \
+                                                             arg6, \
+                                                             arg7, \
+                                                             sender)      \
         {                                                                                                                                                                     \
         }                                                                                                                                                                     \
     };
         {                                                                                                                                                                     \
         }                                                                                                                                                                     \
     };
index 57eb5e0..1b54026 100644 (file)
@@ -24,8 +24,7 @@
 
 #include <sstream>
 
 
 #include <sstream>
 
-namespace DPL
-{
+namespace DPL {
 template<typename TargetType, typename SourceType>
 TargetType lexical_cast(const SourceType &data)
 {
 template<typename TargetType, typename SourceType>
 TargetType lexical_cast(const SourceType &data)
 {
index 62bd7e0..cb088cf 100644 (file)
 #include <dpl/framework_efl.h>
 #include <list>
 
 #include <dpl/framework_efl.h>
 #include <list>
 
-namespace DPL
+namespace DPL {
+class Main :
+    public WaitableHandleWatchSupport
 {
 {
-class Main
-    : public WaitableHandleWatchSupport
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
     };
 
-protected:
+  protected:
     Ecore_Fd_Handler *m_invokerHandler;
 
     Ecore_Fd_Handler *m_invokerHandler;
 
-    static Eina_Bool StaticDispatchInvoker(void *data, Ecore_Fd_Handler *fd_handler);
-    static Eina_Bool StaticDispatchReadWatcher(void *data, Ecore_Fd_Handler *fd_handler);
-    static Eina_Bool StaticDispatchWriteWatcher(void *data, Ecore_Fd_Handler *fd_handler);
+    static Eina_Bool StaticDispatchInvoker(void *data,
+                                           Ecore_Fd_Handler *fd_handler);
+    static Eina_Bool StaticDispatchReadWatcher(void *data,
+                                               Ecore_Fd_Handler *fd_handler);
+    static Eina_Bool StaticDispatchWriteWatcher(void *data,
+                                                Ecore_Fd_Handler *fd_handler);
 
     typedef std::list<Ecore_Fd_Handler *> EcoreFdHandlerList;
 
 
     typedef std::list<Ecore_Fd_Handler *> EcoreFdHandlerList;
 
@@ -66,13 +68,18 @@ protected:
 
 #ifdef DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
     // GLIB loop intergration workaround
 
 #ifdef DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
     // GLIB loop intergration workaround
-    typedef int (*EcoreSelectType)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+    typedef int (*EcoreSelectType)(int nfds, fd_set *readfds, fd_set *writefds,
+                                   fd_set *exceptfds, struct timeval *timeout);
     EcoreSelectType m_oldEcoreSelect;
 
     EcoreSelectType m_oldEcoreSelect;
 
-    static int EcoreSelectInterceptor(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+    static int EcoreSelectInterceptor(int nfds,
+                                      fd_set *readfds,
+                                      fd_set *writefds,
+                                      fd_set *exceptfds,
+                                      struct timeval *timeout);
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 
-public:
+  public:
     explicit Main();
     virtual ~Main();
 };
     explicit Main();
     virtual ~Main();
 };
index fbc0c5b..315a92c 100644 (file)
 #include <dpl/exception.h>
 #include <pthread.h>
 
 #include <dpl/exception.h>
 #include <pthread.h>
 
-namespace DPL
+namespace DPL {
+class Mutex :
+    private Noncopyable
 {
 {
-class Mutex
-    : private Noncopyable
-{
-public:
-    class ScopedLock
-        : private Noncopyable
+  public:
+    class ScopedLock :
+        private Noncopyable
     {
     {
-    private:
+      private:
         Mutex *m_mutex;
 
         Mutex *m_mutex;
 
-    public:
+      public:
         explicit ScopedLock(Mutex *mutex);
         ~ScopedLock();
     };
 
     class Exception
     {
         explicit ScopedLock(Mutex *mutex);
         ~ScopedLock();
     };
 
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, LockFailed)
         DECLARE_EXCEPTION_TYPE(Base, UnlockFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, LockFailed)
         DECLARE_EXCEPTION_TYPE(Base, UnlockFailed)
     };
 
-private:
+  private:
     mutable pthread_mutex_t m_mutex;
 
     void Lock() const;
     void Unlock() const;
 
     mutable pthread_mutex_t m_mutex;
 
     void Lock() const;
     void Unlock() const;
 
-public:
+  public:
     Mutex();
     ~Mutex();
 };
     Mutex();
     ~Mutex();
 };
-
 } // namespace DPL
 
 #endif // DPL_MUTEX_H
 } // namespace DPL
 
 #endif // DPL_MUTEX_H
index ab7630b..45714ef 100644 (file)
 
 #include <dpl/exception.h>
 
 
 #include <dpl/exception.h>
 
-namespace DPL
-{
+namespace DPL {
 class NamedBasePipe
 {
 class NamedBasePipe
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, AlreadyExist)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, AlreadyExist)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
     };
 
-public:
+  public:
     virtual ~NamedBasePipe();
 
     static void Create(const std::string &fileName);
     virtual ~NamedBasePipe();
 
     static void Create(const std::string &fileName);
index 247890d..cf7b4b7 100644 (file)
 #ifndef DPL_NAMED_PIPE_H
 #define DPL_NAMED_PIPE_H
 
 #ifndef DPL_NAMED_PIPE_H
 #define DPL_NAMED_PIPE_H
 
-#include <dpl/noncopyable.h>
 #include <dpl/exception.h>
 #include <dpl/exception.h>
-#include <dpl/abstract_waitable_input.h>
 #include <dpl/named_base_pipe.h>
 #include <dpl/named_base_pipe.h>
+#include <dpl/file_input.h>
 
 
-namespace DPL
-{
-class NamedInputPipe
-    : private Noncopyable,
-      public NamedBasePipe,
-      public AbstractWaitableInput
-{
-public:
-    class Exception
-    {
-    public:
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
-        DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
-        DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
-    };
-
-protected:
-    int m_fifo;
-
-public:
-    NamedInputPipe();
-    virtual ~NamedInputPipe();
-
-    void Open(const std::string &fileName);
-    void Close();
-
-    // AbstractInput
-    virtual BinaryQueueAutoPtr Read(size_t size);
-
-    // AbstractWaitableInput
-    virtual WaitableHandle WaitableReadHandle() const;
-};
+namespace DPL {
+class NamedInputPipe :
+    public NamedBasePipe,
+    public FileInput
+{};
 } // namespace DPL
 
 #endif // DPL_NAMED_PIPE_H
 } // namespace DPL
 
 #endif // DPL_NAMED_PIPE_H
index 9855a81..573d1d2 100644 (file)
 #include <dpl/abstract_waitable_output.h>
 #include <dpl/named_base_pipe.h>
 
 #include <dpl/abstract_waitable_output.h>
 #include <dpl/named_base_pipe.h>
 
-namespace DPL
+namespace DPL {
+class NamedOutputPipe :
+    private Noncopyable,
+    public NamedBasePipe,
+    public AbstractWaitableOutput
 {
 {
-class NamedOutputPipe
-    : private Noncopyable,
-      public NamedBasePipe,
-      public AbstractWaitableOutput
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
-protected:
+  protected:
     int m_fifo;
 
     int m_fifo;
 
-public:
+  public:
     NamedOutputPipe();
     virtual ~NamedOutputPipe();
 
     NamedOutputPipe();
     virtual ~NamedOutputPipe();
 
index 2cc95d4..98d57dd 100644 (file)
 #ifndef DPL_NONCOPYABLE_H
 #define DPL_NONCOPYABLE_H
 
 #ifndef DPL_NONCOPYABLE_H
 #define DPL_NONCOPYABLE_H
 
-namespace DPL
-{
+namespace DPL {
 class Noncopyable
 {
 class Noncopyable
 {
-private:
+  private:
     Noncopyable(const Noncopyable &);
     const Noncopyable &operator=(const Noncopyable &);
     Noncopyable(const Noncopyable &);
     const Noncopyable &operator=(const Noncopyable &);
-public:
+
+  public:
     Noncopyable();
     virtual ~Noncopyable();
 };
     Noncopyable();
     virtual ~Noncopyable();
 };
-
 } // namespace DPL
 
 #endif // DPL_NONCOPYABLE_H
 } // namespace DPL
 
 #endif // DPL_NONCOPYABLE_H
index 2b9039e..610f366 100644 (file)
 #include <dpl/atomic.h>
 #include <dpl/mutex.h>
 
 #include <dpl/atomic.h>
 #include <dpl/mutex.h>
 
-namespace DPL
+namespace DPL {
+class Once :
+    private Noncopyable
 {
 {
-class Once
-    : private Noncopyable
-{
-public:
+  public:
     typedef FastDelegate<void ()> Delegate;
 
     void Call(Delegate delegate);
 
     typedef FastDelegate<void ()> Delegate;
 
     void Call(Delegate delegate);
 
-private:
+  private:
     Atomic m_atomic;
     Mutex m_mutex;
 };
     Atomic m_atomic;
     Mutex m_mutex;
 };
index 0a0736c..f1fb9ba 100644 (file)
 
 #include <dpl/exception.h>
 
 
 #include <dpl/exception.h>
 
-namespace DPL
-{
-
+namespace DPL {
 template <typename Type>
 class Optional
 {
     class Exception
     {
 template <typename Type>
 class Optional
 {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, NullReference)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, NullReference)
     };
 
-public:
+  public:
     Optional() :
         m_null(true),
         m_value()
     Optional() :
         m_null(true),
         m_value()
-    {
-    }
+    {}
 
     Optional(const Type& t) :
         m_null(false),
         m_value(t)
 
     Optional(const Type& t) :
         m_null(false),
         m_value(t)
-    {
-    }
+    {}
 
     bool IsNull() const
     {
 
     bool IsNull() const
     {
@@ -57,25 +53,33 @@ public:
 
     Type& operator*()
     {
 
     Type& operator*()
     {
-        if (m_null) Throw(typename Exception::NullReference);
+        if (m_null) {
+            Throw(typename Exception::NullReference);
+        }
         return m_value;
     }
 
     const Type& operator*() const
     {
         return m_value;
     }
 
     const Type& operator*() const
     {
-        if (m_null) Throw(typename Exception::NullReference);
+        if (m_null) {
+            Throw(typename Exception::NullReference);
+        }
         return m_value;
     }
 
     const Type* operator->() const
     {
         return m_value;
     }
 
     const Type* operator->() const
     {
-        if (m_null) Throw(typename Exception::NullReference);
+        if (m_null) {
+            Throw(typename Exception::NullReference);
+        }
         return &m_value;
     }
 
     Type* operator->()
     {
         return &m_value;
     }
 
     Type* operator->()
     {
-        if (m_null) Throw(typename Exception::NullReference);
+        if (m_null) {
+            Throw(typename Exception::NullReference);
+        }
         return &m_value;
     }
 
         return &m_value;
     }
 
@@ -93,7 +97,8 @@ public:
 
     bool operator==(const Optional<Type>& aSecond) const
     {
 
     bool operator==(const Optional<Type>& aSecond) const
     {
-        return LogicalOperator<true>(*this, aSecond, std::equal_to<Type>(), std::equal_to<bool>());
+        return LogicalOperator<true>(*this, aSecond,
+                                     std::equal_to<Type>(), std::equal_to<bool>());
     }
 
     bool operator==(const Type& aSecond) const
     }
 
     bool operator==(const Type& aSecond) const
@@ -108,12 +113,14 @@ public:
 
     bool operator<(const Optional<Type>& aSecond) const
     {
 
     bool operator<(const Optional<Type>& aSecond) const
     {
-        return LogicalOperator<false>(*this, aSecond, std::less<Type>(), std::less<bool>());
+        return LogicalOperator<false>(*this, aSecond,
+                                      std::less<Type>(), std::less<bool>());
     }
 
     bool operator>(const Optional<Type>& aSecond) const
     {
     }
 
     bool operator>(const Optional<Type>& aSecond) const
     {
-        return LogicalOperator<false>(*this, aSecond, std::greater<Type>(), std::greater<bool>());
+        return LogicalOperator<false>(*this, aSecond,
+                                      std::greater<Type>(), std::greater<bool>());
     }
 
     bool operator<=(const Optional<Type>& aSecond) const
     }
 
     bool operator<=(const Optional<Type>& aSecond) const
@@ -128,27 +135,23 @@ public:
 
     static Optional<Type> Null;
 
 
     static Optional<Type> Null;
 
-private:
+  private:
     bool m_null;
     Type m_value;
 
     template <bool taEquality, typename taComparator, typename taNullComparator>
     bool m_null;
     Type m_value;
 
     template <bool taEquality, typename taComparator, typename taNullComparator>
-    static bool LogicalOperator(const Optional<Type>& aFirst, const Optional<Type>& aSecond,
-                                taComparator aComparator, taNullComparator aNullComparator)
+    static bool LogicalOperator(const Optional<Type>& aFirst,
+                                const Optional<Type>& aSecond,
+                                taComparator aComparator,
+                                taNullComparator aNullComparator)
     {
     {
-        if (aFirst.m_null == aSecond.m_null)
-        {
-            if (aFirst.m_null)
-            {
+        if (aFirst.m_null == aSecond.m_null) {
+            if (aFirst.m_null) {
                 return taEquality;
                 return taEquality;
+            } else {
+                return aComparator(aFirst.m_value, aSecond.m_value);
             }
             }
-            else
-            {
-                return  aComparator(aFirst.m_value, aSecond.m_value);
-            }
-        }
-        else
-        {
+        } else {
             return aNullComparator(aFirst.m_null, aSecond.m_null);
         }
     }
             return aNullComparator(aFirst.m_null, aSecond.m_null);
         }
     }
@@ -156,18 +159,15 @@ private:
 
 template<typename Type>
 Optional<Type> Optional<Type>::Null = Optional<Type>();
 
 template<typename Type>
 Optional<Type> Optional<Type>::Null = Optional<Type>();
-
 } //namespace DPL
 
 template<typename Type>
 } //namespace DPL
 
 template<typename Type>
-std::ostream& operator<<(std::ostream& aStream, const DPL::Optional<Type>& aOptional)
+std::ostream& operator<<(std::ostream& aStream,
+                         const DPL::Optional<Type>& aOptional)
 {
 {
-    if (aOptional.IsNull())
-    {
+    if (aOptional.IsNull()) {
         return aStream << "null optional";
         return aStream << "null optional";
-    }
-    else
-    {
+    } else {
         return aStream << *aOptional;
     }
 }
         return aStream << *aOptional;
     }
 }
index 153e4df..356060a 100644 (file)
 #include <dpl/string.h>
 #include <dpl/optional.h>
 
 #include <dpl/string.h>
 #include <dpl/optional.h>
 
-namespace DPL
-{
-
+namespace DPL {
 typedef Optional<String> OptionalString;
 typedef Optional<int> OptionalInt;
 typedef Optional<bool> OptionalBool;
 typedef Optional<float> OptionalFloat;
 typedef Optional<String> OptionalString;
 typedef Optional<int> OptionalInt;
 typedef Optional<bool> OptionalBool;
 typedef Optional<float> OptionalFloat;
-
 } //namespace DPL
 
 #endif /* DPL_OPTIONAL_TYPEDEFS_H */
 } //namespace DPL
 
 #endif /* DPL_OPTIONAL_TYPEDEFS_H */
index 83a41e3..0118d76 100644 (file)
@@ -26,4 +26,4 @@
 #define DPL_MACRO_CONCAT_IMPL(x, y) x##y
 #define DPL_MACRO_CONCAT(x, y) DPL_MACRO_CONCAT_IMPL(x, y)
 
 #define DPL_MACRO_CONCAT_IMPL(x, y) x##y
 #define DPL_MACRO_CONCAT(x, y) DPL_MACRO_CONCAT_IMPL(x, y)
 
-#endif//DPL_PREPROCESSOR_H
+#endif //DPL_PREPROCESSOR_H
index 1e224de..75d9f06 100644 (file)
 #include <dpl/exception.h>
 #include <pthread.h>
 
 #include <dpl/exception.h>
 #include <pthread.h>
 
-namespace DPL
+namespace DPL {
+class ReadWriteMutex :
+    private Noncopyable
 {
 {
-class ReadWriteMutex
-    : private Noncopyable
-{
-public:
-    class ScopedReadLock
-        : private Noncopyable
+  public:
+    class ScopedReadLock :
+        private Noncopyable
     {
     {
-    private:
+      private:
         ReadWriteMutex *m_mutex;
 
         ReadWriteMutex *m_mutex;
 
-    public:
+      public:
         ScopedReadLock(ReadWriteMutex *mutex);
         virtual ~ScopedReadLock();
     };
 
         ScopedReadLock(ReadWriteMutex *mutex);
         virtual ~ScopedReadLock();
     };
 
-    class ScopedWriteLock
-        private Noncopyable
+    class ScopedWriteLock :
+        private Noncopyable
     {
     {
-    private:
+      private:
         ReadWriteMutex *m_mutex;
 
         ReadWriteMutex *m_mutex;
 
-    public:
+      public:
         ScopedWriteLock(ReadWriteMutex *mutex);
         virtual ~ScopedWriteLock();
     };
 
     class Exception
     {
         ScopedWriteLock(ReadWriteMutex *mutex);
         virtual ~ScopedWriteLock();
     };
 
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
@@ -65,18 +64,17 @@ public:
         DECLARE_EXCEPTION_TYPE(Base, UnlockFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(Base, UnlockFailed)
     };
 
-private:
+  private:
     mutable pthread_rwlock_t m_rwlock;
 
     void ReadLock() const;
     void WriteLock() const;
     void Unlock() const;
 
     mutable pthread_rwlock_t m_rwlock;
 
     void ReadLock() const;
     void WriteLock() const;
     void Unlock() const;
 
-public:
+  public:
     explicit ReadWriteMutex();
     virtual ~ReadWriteMutex();
 };
     explicit ReadWriteMutex();
     virtual ~ReadWriteMutex();
 };
-
 } // namespace DPL
 
 #endif // DPL_READ_WRITE_MUTEX_H
 } // namespace DPL
 
 #endif // DPL_READ_WRITE_MUTEX_H
index ec1e23c..e4744cc 100644 (file)
 #include <dpl/exception.h>
 #include <pthread.h>
 
 #include <dpl/exception.h>
 #include <pthread.h>
 
-namespace DPL
+namespace DPL {
+class RecursiveMutex :
+    private Noncopyable
 {
 {
-class RecursiveMutex
-    : private Noncopyable
-{
-public:
-    class ScopedLock
-        : private Noncopyable
+  public:
+    class ScopedLock :
+        private Noncopyable
     {
     {
-    private:
+      private:
         RecursiveMutex *m_mutex;
 
         RecursiveMutex *m_mutex;
 
-    public:
+      public:
         ScopedLock(RecursiveMutex *mutex);
         virtual ~ScopedLock();
     };
 
     class Exception
     {
         ScopedLock(RecursiveMutex *mutex);
         virtual ~ScopedLock();
     };
 
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
@@ -53,17 +52,16 @@ public:
         DECLARE_EXCEPTION_TYPE(Base, UnlockFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(Base, UnlockFailed)
     };
 
-private:
+  private:
     mutable pthread_mutex_t m_mutex;
 
     void Lock() const;
     void Unlock() const;
 
     mutable pthread_mutex_t m_mutex;
 
     void Lock() const;
     void Unlock() const;
 
-public:
+  public:
     explicit RecursiveMutex();
     virtual ~RecursiveMutex();
 };
     explicit RecursiveMutex();
     virtual ~RecursiveMutex();
 };
-
 } // namespace DPL
 
 #endif // DPL_RECURSIVE_MUTEX_H
 } // namespace DPL
 
 #endif // DPL_RECURSIVE_MUTEX_H
index fa0c540..48d970f 100644 (file)
 #include <dpl/assert.h>
 #include <dpl/scoped_resource.h>
 
 #include <dpl/assert.h>
 #include <dpl/scoped_resource.h>
 
-namespace DPL
-{
+namespace DPL {
 template<typename Class>
 struct ScopedArrayPolicy
 {
     typedef Class* Type;
 template<typename Class>
 struct ScopedArrayPolicy
 {
     typedef Class* Type;
-    static Type NullValue() { return NULL; }
-    static void Destroy(Type ptr) { delete [] ptr; }
+    static Type NullValue()
+    {
+        return NULL;
+    }
+    static void Destroy(Type ptr)
+    {
+        delete[] ptr;
+    }
 };
 
 template<typename Class>
 };
 
 template<typename Class>
index e51b7b4..45477af 100644 (file)
 #include <dpl/scoped_resource.h>
 #include <dpl/errno_string.h>
 
 #include <dpl/scoped_resource.h>
 #include <dpl/errno_string.h>
 
-namespace DPL
-{
+namespace DPL {
 struct ScopedClosePolicy
 {
     typedef int Type;
 struct ScopedClosePolicy
 {
     typedef int Type;
-    static Type NullValue() { return -1; }
+    static Type NullValue()
+    {
+        return -1;
+    }
     static void Destroy(Type handle)
     {
     static void Destroy(Type handle)
     {
-        if (handle != -1)
-        {
-            if (TEMP_FAILURE_RETRY(::fsync(handle)) == -1)
-            {
+        if (handle != -1) {
+            if (TEMP_FAILURE_RETRY(::fsync(handle)) == -1) {
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed to fsync scoped close error: "
                             << errString);
             }
 
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed to fsync scoped close error: "
                             << errString);
             }
 
-            if (::close(handle) == -1)
-            {
+            if (::close(handle) == -1) {
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed to scoped close error: "
                             << errString);
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed to scoped close error: "
                             << errString);
index 9758b8d..b029803 100644 (file)
@@ -22,7 +22,6 @@
 #ifndef DPL_SCOPED_FCLOSE_H
 #define DPL_SCOPED_FCLOSE_H
 
 #ifndef DPL_SCOPED_FCLOSE_H
 #define DPL_SCOPED_FCLOSE_H
 
-
 #include <unistd.h>
 #include <cerrno>
 #include <cstdio>
 #include <unistd.h>
 #include <cerrno>
 #include <cstdio>
 #include <dpl/scoped_resource.h>
 #include <dpl/errno_string.h>
 
 #include <dpl/scoped_resource.h>
 #include <dpl/errno_string.h>
 
-namespace DPL
-{
+namespace DPL {
 struct ScopedFClosePolicy
 {
     typedef FILE* Type;
 struct ScopedFClosePolicy
 {
     typedef FILE* Type;
-    static Type NullValue() { return NULL; }
+    static Type NullValue()
+    {
+        return NULL;
+    }
     static void Destroy(Type file)
     {
     static void Destroy(Type file)
     {
-        if (file != NULL)
-        {
+        if (file != NULL) {
             // Try to flush first
             // Try to flush first
-            if (TEMP_FAILURE_RETRY(fflush(file)) != 0)
-            {
+            if (TEMP_FAILURE_RETRY(fflush(file)) != 0) {
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed to fflush scoped fclose error: "
                             << errString);
             }
 
             // fclose cannot be retried, try to close once
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed to fflush scoped fclose error: "
                             << errString);
             }
 
             // fclose cannot be retried, try to close once
-            if (fclose(file) != 0)
-            {
+            if (fclose(file) != 0) {
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed scoped fclose error: " << errString);
             }
                 std::string errString = GetErrnoString();
                 LogPedantic("Failed scoped fclose error: " << errString);
             }
index 7b3bd5a..7bebe39 100644 (file)
 
 #include <dpl/scoped_resource.h>
 
 
 #include <dpl/scoped_resource.h>
 
-namespace DPL
-{
+namespace DPL {
 template<typename Class>
 struct ScopedFreePolicy
 {
     typedef Class* Type;
 template<typename Class>
 struct ScopedFreePolicy
 {
     typedef Class* Type;
-    static Type NullValue() { return NULL; }
-    static void Destroy(Type ptr) { free(ptr); }
+    static Type NullValue()
+    {
+        return NULL;
+    }
+    static void Destroy(Type ptr)
+    {
+        free(ptr);
+    }
 };
 
 template<typename Memory>
 };
 
 template<typename Memory>
index 2f78bec..289d469 100644 (file)
@@ -28,9 +28,7 @@
 #include <dpl/scoped_resource.h>
 #include <dpl/assert.h>
 
 #include <dpl/scoped_resource.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-
+namespace DPL {
 struct ScopedGPointerPolicy
 {
     typedef gpointer Type;
 struct ScopedGPointerPolicy
 {
     typedef gpointer Type;
@@ -54,10 +52,9 @@ class ScopedGPointer : public DPL::ScopedResource<ScopedGPointerPolicy>
 
   public:
     explicit ScopedGPointer(typename Policy::Type pointer =
 
   public:
     explicit ScopedGPointer(typename Policy::Type pointer =
-                Policy::NullValue()) :
+                                Policy::NullValue()) :
         BaseType(pointer)
         BaseType(pointer)
-    {
-    }
+    {}
 
     Class *operator->() const throw()
     {
 
     Class *operator->() const throw()
     {
@@ -73,7 +70,6 @@ class ScopedGPointer : public DPL::ScopedResource<ScopedGPointerPolicy>
         return *static_cast<Class *>(this->m_value);
     }
 };
         return *static_cast<Class *>(this->m_value);
     }
 };
-
 } // namespace DPL
 
 #endif // DPL_SCOPED_GPOINTER_H
 } // namespace DPL
 
 #endif // DPL_SCOPED_GPOINTER_H
index 3788dc1..27ab3bf 100644 (file)
 #include <dpl/scoped_resource.h>
 #include <dpl/assert.h>
 
 #include <dpl/scoped_resource.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 template<typename Class>
 struct ScopedPtrPolicy
 {
     typedef Class* Type;
 template<typename Class>
 struct ScopedPtrPolicy
 {
     typedef Class* Type;
-    static Type NullValue() { return NULL; }
-    static void Destroy(Type ptr) { delete ptr; }
+    static Type NullValue()
+    {
+        return NULL;
+    }
+    static void Destroy(Type ptr)
+    {
+        delete ptr;
+    }
 };
 
 template<typename Class, typename ClassPolicy = ScopedPtrPolicy<Class> >
 };
 
 template<typename Class, typename ClassPolicy = ScopedPtrPolicy<Class> >
index a902d72..63287da 100644 (file)
 
 #include <dpl/noncopyable.h>
 
 
 #include <dpl/noncopyable.h>
 
-namespace DPL
-{
+namespace DPL {
 template<typename ClassPolicy>
 template<typename ClassPolicy>
-class ScopedResource
-    private Noncopyable
+class ScopedResource :
+    private Noncopyable
 {
   public:
     typedef typename ClassPolicy::Type ValueType;
 {
   public:
     typedef typename ClassPolicy::Type ValueType;
@@ -45,7 +44,10 @@ class ScopedResource
         ClassPolicy::Destroy(m_value);
     }
 
         ClassPolicy::Destroy(m_value);
     }
 
-    ValueType Get() const { return m_value; }
+    ValueType Get() const
+    {
+        return m_value;
+    }
 
     void Reset(ValueType value = ClassPolicy::NullValue())
     {
 
     void Reset(ValueType value = ClassPolicy::NullValue())
     {
@@ -72,7 +74,6 @@ class ScopedResource
     {
         return m_value == ClassPolicy::NullValue();
     }
     {
         return m_value == ClassPolicy::NullValue();
     }
-
 };
 } // namespace DPL
 
 };
 } // namespace DPL
 
index 420d9a5..0505621 100644 (file)
 #include <semaphore.h>
 #include <string>
 
 #include <semaphore.h>
 #include <string>
 
-namespace DPL
+namespace DPL {
+class Semaphore :
+    private Noncopyable
 {
 {
-class Semaphore
-    : private Noncopyable
-{
-public:
-    class ScopedLock
-        : private Noncopyable
+  public:
+    class ScopedLock :
+        private Noncopyable
     {
     {
-    private:
+      private:
         Semaphore *m_semaphore;
 
         Semaphore *m_semaphore;
 
-    public:
+      public:
         explicit ScopedLock(Semaphore *semaphore);
         ~ScopedLock();
     };
 
     class Exception
     {
         explicit ScopedLock(Semaphore *semaphore);
         ~ScopedLock();
     };
 
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, LockFailed)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, LockFailed)
@@ -54,7 +53,7 @@ public:
         DECLARE_EXCEPTION_TYPE(Base, RemoveFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(Base, RemoveFailed)
     };
 
-private:
+  private:
     enum Type
     {
         Type_Unnamed,
     enum Type
     {
         Type_Unnamed,
@@ -81,10 +80,17 @@ private:
     sem_t *InternalGet() const;
     void InternalDestroy();
 
     sem_t *InternalGet() const;
     void InternalDestroy();
 
+  public:
+    /**
+     * decrement the semaphore counter
+     */
     void Lock() const;
     void Lock() const;
+
+    /**
+     * increment the semaphore counter
+     */
     void Unlock() const;
 
     void Unlock() const;
 
-public:
     /**
      * Remove a named semaphore
      *
     /**
      * Remove a named semaphore
      *
index 8369665..d72c488 100644 (file)
 #include <map>
 
 namespace DPL {
 #include <map>
 
 namespace DPL {
-
 // Abstract data stream buffer
 // Abstract data stream buffer
-class IStream {
+class IStream
+{
   public:
     virtual void Read(size_t num, void * bytes) = 0;
     virtual void Write(size_t num, const void * bytes) = 0;
   public:
     virtual void Read(size_t num, void * bytes) = 0;
     virtual void Write(size_t num, const void * bytes) = 0;
-    virtual ~IStream(){};
+    virtual ~IStream(){}
 };
 
 // Serializable interface
 };
 
 // Serializable interface
-class ISerializable {
+class ISerializable
+{
   public:
   public:
-/*    ISerializable(){};
-      ISerializable(IStream&){}; */
+    /*    ISerializable(){};
+     *    ISerializable(IStream&){}; */
     virtual void Serialize(IStream &) const = 0;
     virtual void Serialize(IStream &) const = 0;
-    virtual ~ISerializable(){};
+    virtual ~ISerializable(){}
 };
 
 struct Serialization {
 };
 
 struct Serialization {
-// serialization
-// normal functions
+    // serialization
+    // normal functions
 
 
-// ISerializable objects
-static void Serialize(IStream& stream, const ISerializable& object){
-    object.Serialize(stream);
-}
-static void Serialize(IStream& stream, const ISerializable* const object){
-    object->Serialize(stream);
-}
+    // ISerializable objects
+    static void Serialize(IStream& stream, const ISerializable& object)
+    {
+        object.Serialize(stream);
+    }
+    static void Serialize(IStream& stream, const ISerializable* const object)
+    {
+        object->Serialize(stream);
+    }
 
 
-// unsigned int
-static void Serialize(IStream& stream, const unsigned value){
-    stream.Write(sizeof(value),&value);
-}
-static void Serialize(IStream& stream, const unsigned* const value){
-    stream.Write(sizeof(*value),value);
-}
+    // unsigned int
+    static void Serialize(IStream& stream, const unsigned value)
+    {
+        stream.Write(sizeof(value), &value);
+    }
+    static void Serialize(IStream& stream, const unsigned* const value)
+    {
+        stream.Write(sizeof(*value), value);
+    }
 
 
-// int
-static void Serialize(IStream& stream, const int value){
-    stream.Write(sizeof(value),&value);
-}
-static void Serialize(IStream& stream, const int* const value){
-    stream.Write(sizeof(*value),value);
-}
+    // int
+    static void Serialize(IStream& stream, const int value)
+    {
+        stream.Write(sizeof(value), &value);
+    }
+    static void Serialize(IStream& stream, const int* const value)
+    {
+        stream.Write(sizeof(*value), value);
+    }
 
 
-// bool
-static void Serialize(IStream& stream, const bool value){
-    stream.Write(sizeof(value),&value);
-}
-static void Serialize(IStream& stream, const bool* const value){
-    stream.Write(sizeof(*value),value);
-}
+    // bool
+    static void Serialize(IStream& stream, const bool value)
+    {
+        stream.Write(sizeof(value), &value);
+    }
+    static void Serialize(IStream& stream, const bool* const value)
+    {
+        stream.Write(sizeof(*value), value);
+    }
 
 
-// std::string
-static void Serialize(IStream& stream, const std::string& str){
-    int length = str.size();
-    stream.Write(sizeof(length),&length);
-    stream.Write(length,str.c_str());
-}
-static void Serialize(IStream& stream, const std::string* const str){
-    int length = str->size();
-    stream.Write(sizeof(length),&length);
-    stream.Write(length,str->c_str());
-}
+    // std::string
+    static void Serialize(IStream& stream, const std::string& str)
+    {
+        int length = str.size();
+        stream.Write(sizeof(length), &length);
+        stream.Write(length, str.c_str());
+    }
+    static void Serialize(IStream& stream, const std::string* const str)
+    {
+        int length = str->size();
+        stream.Write(sizeof(length), &length);
+        stream.Write(length, str->c_str());
+    }
 
 
-// STL templates
+    // STL templates
 
 
-// std::list
-template <typename T>
-static void Serialize(IStream& stream, const std::list<T>& list){
-    int length = list.size();
-    stream.Write(sizeof(length),&length);
-    for(typename std::list<T>::const_iterator list_iter = list.begin();
-        list_iter != list.end(); list_iter++)
-    {
-        Serialize(stream, *list_iter);
-    }
-}
-template <typename T>
-static void Serialize(IStream& stream, const std::list<T>* const list){
-    Serialize(stream,*list);
-}
+    // std::list
+    template <typename T>
+    static void Serialize(IStream& stream, const std::list<T>& list)
+    {
+        int length = list.size();
+        stream.Write(sizeof(length), &length);
+        for (typename std::list<T>::const_iterator list_iter = list.begin();
+             list_iter != list.end(); list_iter++)
+        {
+            Serialize(stream, *list_iter);
+        }
+    }
+    template <typename T>
+    static void Serialize(IStream& stream, const std::list<T>* const list)
+    {
+        Serialize(stream, *list);
+    }
 
 
-// std::vector
-template <typename T>
-static void Serialize(IStream& stream, const std::vector<T>& vec){
-    int length = vec.size();
-    stream.Write(sizeof(length),&length);
-    for(typename std::vector<T>::const_iterator vec_iter = vec.begin();
-            vec_iter  != vec.end(); vec_iter ++)
-    {
-        Serialize(stream, *vec_iter);
-    }
-}
-template <typename T>
-static void Serialize(IStream& stream, const std::vector<T>* const vec){
-    Serialize(stream,*vec);
-}
+    // std::vector
+    template <typename T>
+    static void Serialize(IStream& stream, const std::vector<T>& vec)
+    {
+        int length = vec.size();
+        stream.Write(sizeof(length), &length);
+        for (typename std::vector<T>::const_iterator vec_iter = vec.begin();
+             vec_iter != vec.end(); vec_iter++)
+        {
+            Serialize(stream, *vec_iter);
+        }
+    }
+    template <typename T>
+    static void Serialize(IStream& stream, const std::vector<T>* const vec)
+    {
+        Serialize(stream, *vec);
+    }
 
 
-// std::pair
-template <typename A, typename B>
-static void Serialize(IStream& stream, const std::pair<A,B>& p){
-    Serialize(stream, p.first);
-    Serialize(stream, p.second);
-}
-template <typename A, typename B>
-static void Serialize(IStream& stream, const std::pair<A,B>* const p){
-    Serialize(stream,*p);
-}
+    // std::pair
+    template <typename A, typename B>
+    static void Serialize(IStream& stream, const std::pair<A, B>& p)
+    {
+        Serialize(stream, p.first);
+        Serialize(stream, p.second);
+    }
+    template <typename A, typename B>
+    static void Serialize(IStream& stream, const std::pair<A, B>* const p)
+    {
+        Serialize(stream, *p);
+    }
 
 
-// std::map
-template <typename K, typename T>
-static void Serialize(IStream& stream, const std::map<K,T>& map){
-    int length = map.size();
-    stream.Write(sizeof(length),&length);
-    typename std::map<K,T>::const_iterator it;
-    for (it = map.begin(); it != map.end(); ++it) {
-        Serialize(stream,(*it).first);
-        Serialize(stream,(*it).second);
-    }
-}
-template <typename K, typename T>
-static void Serialize(IStream& stream, const std::map<K,T>* const map){
-    Serialize(stream,*map);
-}
+    // std::map
+    template <typename K, typename T>
+    static void Serialize(IStream& stream, const std::map<K, T>& map)
+    {
+        int length = map.size();
+        stream.Write(sizeof(length), &length);
+        typename std::map<K, T>::const_iterator it;
+        for (it = map.begin(); it != map.end(); ++it) {
+            Serialize(stream, (*it).first);
+            Serialize(stream, (*it).second);
+        }
+    }
+    template <typename K, typename T>
+    static void Serialize(IStream& stream, const std::map<K, T>* const map)
+    {
+        Serialize(stream, *map);
+    }
 }; // struct Serialization
 
 struct Deserialization {
 }; // struct Serialization
 
 struct Deserialization {
-// deserialization
-// normal functions
+    // deserialization
+    // normal functions
 
 
-// ISerializable objects
-// T instead of ISerializable is needed to call proper constructor
-template <typename T>
-static void Deserialize(IStream& stream, T& object){
-    object = T(stream);
-}
-template <typename T>
-static void Deserialize(IStream& stream, T*& object){
-    object = new T(stream);
-}
+    // ISerializable objects
+    // T instead of ISerializable is needed to call proper constructor
+    template <typename T>
+    static void Deserialize(IStream& stream, T& object)
+    {
+        object = T(stream);
+    }
+    template <typename T>
+    static void Deserialize(IStream& stream, T*& object)
+    {
+        object = new T(stream);
+    }
 
 
-// unsigned int
-static void Deserialize(IStream& stream, unsigned& value){
-    stream.Read(sizeof(value),&value);
-}
-static void Deserialize(IStream& stream, unsigned*& value){
-    value = new unsigned;
-    stream.Read(sizeof(*value),value);
-}
+    // unsigned int
+    static void Deserialize(IStream& stream, unsigned& value)
+    {
+        stream.Read(sizeof(value), &value);
+    }
+    static void Deserialize(IStream& stream, unsigned*& value)
+    {
+        value = new unsigned;
+        stream.Read(sizeof(*value), value);
+    }
 
 
-// int
-static void Deserialize(IStream& stream, int& value){
-    stream.Read(sizeof(value),&value);
-}
-static void Deserialize(IStream& stream, int*& value){
-    value = new int;
-    stream.Read(sizeof(*value),value);
-}
+    // int
+    static void Deserialize(IStream& stream, int& value)
+    {
+        stream.Read(sizeof(value), &value);
+    }
+    static void Deserialize(IStream& stream, int*& value)
+    {
+        value = new int;
+        stream.Read(sizeof(*value), value);
+    }
 
 
-// bool
-static void Deserialize(IStream& stream, bool& value){
-    stream.Read(sizeof(value),&value);
-}
-static void Deserialize(IStream& stream, bool*& value){
-    value = new bool;
-    stream.Read(sizeof(*value),value);
-}
+    // bool
+    static void Deserialize(IStream& stream, bool& value)
+    {
+        stream.Read(sizeof(value), &value);
+    }
+    static void Deserialize(IStream& stream, bool*& value)
+    {
+        value = new bool;
+        stream.Read(sizeof(*value), value);
+    }
 
 
-// std::string
-static void Deserialize(IStream& stream, std::string& str){
-    int length;
-    stream.Read(sizeof(length),&length);
-    char * buf = new char[length+1];
-    stream.Read(length,buf);
-    buf[length] = 0;
-    str = std::string(buf);
-    delete [] buf;
-}
-static void Deserialize(IStream& stream, std::string*& str){
-    int length;
-    stream.Read(sizeof(length),&length);
-    char * buf = new char[length+1];
-    stream.Read(length,buf);
-    buf[length] = 0;
-    str = new std::string(buf);
-    delete [] buf;
-}
+    // std::string
+    static void Deserialize(IStream& stream, std::string& str)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        char * buf = new char[length + 1];
+        stream.Read(length, buf);
+        buf[length] = 0;
+        str = std::string(buf);
+        delete[] buf;
+    }
+    static void Deserialize(IStream& stream, std::string*& str)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        char * buf = new char[length + 1];
+        stream.Read(length, buf);
+        buf[length] = 0;
+        str = new std::string(buf);
+        delete[] buf;
+    }
 
 
-// STL templates
+    // STL templates
 
 
-// std::list
-template <typename T>
-static void Deserialize(IStream& stream, std::list<T>& list){
-    int length;
-    stream.Read(sizeof(length),&length);
-    for (int i = 0; i < length; ++i) {
-        T obj;
-        Deserialize(stream, obj);
-        list.push_back(obj);
-    }
-}
-template <typename T>
-static void Deserialize(IStream& stream, std::list<T>*& list){
-    list = new std::list<T>;
-    Deserialize(stream,*list);
-}
+    // std::list
+    template <typename T>
+    static void Deserialize(IStream& stream, std::list<T>& list)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        for (int i = 0; i < length; ++i) {
+            T obj;
+            Deserialize(stream, obj);
+            list.push_back(obj);
+        }
+    }
+    template <typename T>
+    static void Deserialize(IStream& stream, std::list<T>*& list)
+    {
+        list = new std::list<T>;
+        Deserialize(stream, *list);
+    }
 
 
-// std::vector
-template <typename T>
-static void Deserialize(IStream& stream, std::vector<T>& vec){
-    int length;
-    stream.Read(sizeof(length),&length);
-    for (int i = 0; i < length; ++i) {
-        T obj;
-        Deserialize(stream, obj);
-        vec.push_back(obj);
-    }
-}
-template <typename T>
-static void Deserialize(IStream& stream, std::vector<T>*& vec){
-    vec = new std::vector<T>;
-    Deserialize(stream,*vec);
-}
+    // std::vector
+    template <typename T>
+    static void Deserialize(IStream& stream, std::vector<T>& vec)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        for (int i = 0; i < length; ++i) {
+            T obj;
+            Deserialize(stream, obj);
+            vec.push_back(obj);
+        }
+    }
+    template <typename T>
+    static void Deserialize(IStream& stream, std::vector<T>*& vec)
+    {
+        vec = new std::vector<T>;
+        Deserialize(stream, *vec);
+    }
 
 
-// std::pair
-template <typename A, typename B>
-static void Deserialize(IStream& stream, std::pair<A,B>& p){
-    Deserialize(stream, p.first);
-    Deserialize(stream, p.second);
-}
-template <typename A, typename B>
-static void Deserialize(IStream& stream, std::pair<A,B>*& p){
-    p = new std::pair<A,B>;
-    Deserialize(stream,*p);
-}
+    // std::pair
+    template <typename A, typename B>
+    static void Deserialize(IStream& stream, std::pair<A, B>& p)
+    {
+        Deserialize(stream, p.first);
+        Deserialize(stream, p.second);
+    }
+    template <typename A, typename B>
+    static void Deserialize(IStream& stream, std::pair<A, B>*& p)
+    {
+        p = new std::pair<A, B>;
+        Deserialize(stream, *p);
+    }
 
 
-// std::map
-template <typename K, typename T>
-static void Deserialize(IStream& stream, std::map<K,T>& map){
-    int length;
-    stream.Read(sizeof(length),&length);
-    for (int i = 0; i < length; ++i) {
-        K key;
-        T obj;
-        Deserialize(stream,key);
-        Deserialize(stream,obj);
-        map[key] = obj;
-    }
-}
-template <typename K, typename T>
-static void Deserialize(IStream& stream, std::map<K,T>*& map){
-    map = new std::map<K,T>;
-    Deserialize(stream,*map);
-}
+    // std::map
+    template <typename K, typename T>
+    static void Deserialize(IStream& stream, std::map<K, T>& map)
+    {
+        int length;
+        stream.Read(sizeof(length), &length);
+        for (int i = 0; i < length; ++i) {
+            K key;
+            T obj;
+            Deserialize(stream, key);
+            Deserialize(stream, obj);
+            map[key] = obj;
+        }
+    }
+    template <typename K, typename T>
+    static void Deserialize(IStream& stream, std::map<K, T>*& map)
+    {
+        map = new std::map<K, T>;
+        Deserialize(stream, *map);
+    }
 }; // struct Deserialization
 }; // struct Deserialization
-
 } // namespace DPL
 
 #endif // SERIALIZATION_H
 } // namespace DPL
 
 #endif // SERIALIZATION_H
index c964fd9..0ae6245 100644 (file)
 #include <dpl/noncopyable.h>
 #include <dpl/atomic.h>
 #include <dpl/bool_operator.h>
 #include <dpl/noncopyable.h>
 #include <dpl/atomic.h>
 #include <dpl/bool_operator.h>
-#include <cstddef>
+#include <stddef.h>
 #include <dpl/assert.h>
 
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 struct StaticPointerCastTag {};
 struct ConstPointerCastTag {};
 struct DynamicPointerCastTag {};
 
 struct SharedCounter
 {
 struct StaticPointerCastTag {};
 struct ConstPointerCastTag {};
 struct DynamicPointerCastTag {};
 
 struct SharedCounter
 {
-    SharedCounter()
-        : ref(1)
-    {
-    }
+    SharedCounter() :
+        ref(1)
+    {}
 
     Atomic ref;
 };
 
     Atomic ref;
 };
@@ -48,7 +46,9 @@ template<typename Class>
 class EnableSharedFromThis;
 
 template<typename Other>
 class EnableSharedFromThis;
 
 template<typename Other>
-inline void _Internal_AcceptSharedPtr(SharedCounter *counter, Other *other, EnableSharedFromThis<Other> *otherBase)
+inline void _Internal_AcceptSharedPtr(SharedCounter *counter,
+                                      Other *other,
+                                      EnableSharedFromThis<Other> *otherBase)
 {
     otherBase->_Internal_AcceptSharedPtr(counter, other);
 }
 {
     otherBase->_Internal_AcceptSharedPtr(counter, other);
 }
@@ -57,22 +57,20 @@ struct AnyPointer
 {
     template<typename Other>
     AnyPointer(Other *)
 {
     template<typename Other>
     AnyPointer(Other *)
-    {        
-    }
+    {}
 };
 
 inline void _Internal_AcceptSharedPtr(SharedCounter *, AnyPointer, AnyPointer)
 };
 
 inline void _Internal_AcceptSharedPtr(SharedCounter *, AnyPointer, AnyPointer)
-{
-}
+{}
 
 template<typename Class>
 class SharedPtr
 {
 
 template<typename Class>
 class SharedPtr
 {
-public:
+  public:
     typedef Class ValueType;
     typedef SharedPtr<Class> ThisType;
 
     typedef Class ValueType;
     typedef SharedPtr<Class> ThisType;
 
-private:
+  private:
     SharedCounter *m_counter;
     Class *m_ptr;
 
     SharedCounter *m_counter;
     Class *m_ptr;
 
@@ -81,16 +79,15 @@ private:
         // Attention: R-Value const cast
         m_counter = const_cast<SharedCounter *>(counter);
 
         // Attention: R-Value const cast
         m_counter = const_cast<SharedCounter *>(counter);
 
-        if (m_counter != NULL)
+        if (m_counter != NULL) {
             ++m_counter->ref;
             ++m_counter->ref;
+        }
     }
 
     void DetachCounter()
     {
     }
 
     void DetachCounter()
     {
-        if (m_counter)
-        {
-            if (!--m_counter->ref)
-            {
+        if (m_counter) {
+            if (!--m_counter->ref) {
                 delete m_ptr;
                 delete m_counter;
             }
                 delete m_ptr;
                 delete m_counter;
             }
@@ -100,34 +97,32 @@ private:
         }
     }
 
         }
     }
 
-public:
-    SharedPtr()
-        : m_counter(NULL),
-          m_ptr(NULL)
-    {
-    }
+  public:
+    SharedPtr() :
+        m_counter(NULL),
+        m_ptr(NULL)
+    {}
 
 
-    explicit SharedPtr(Class *ptr)
-        m_counter(NULL),
-          m_ptr(ptr)
+    explicit SharedPtr(Class *ptr) :
+        m_counter(NULL),
+        m_ptr(ptr)
     {
     {
-        if (m_ptr != NULL)
-        {
+        if (m_ptr != NULL) {
             m_counter = new SharedCounter();
             _Internal_AcceptSharedPtr(m_counter, m_ptr, m_ptr);
         }
     }
 
             m_counter = new SharedCounter();
             _Internal_AcceptSharedPtr(m_counter, m_ptr, m_ptr);
         }
     }
 
-    SharedPtr(const SharedPtr &other)
-        m_counter(NULL),
-          m_ptr(other.m_ptr)
+    SharedPtr(const SharedPtr &other) :
+        m_counter(NULL),
+        m_ptr(other.m_ptr)
     {
         AttachCounter(other.m_counter);
     }
 
     {
         AttachCounter(other.m_counter);
     }
 
-    SharedPtr(SharedCounter *counter, Class *ptr)
-        m_counter(NULL),
-          m_ptr(ptr)
+    SharedPtr(SharedCounter *counter, Class *ptr) :
+        m_counter(NULL),
+        m_ptr(ptr)
     {
         AttachCounter(counter);
     }
     {
         AttachCounter(counter);
     }
@@ -136,32 +131,33 @@ public:
     friend class SharedPtr;
 
     template<typename Other>
     friend class SharedPtr;
 
     template<typename Other>
-    SharedPtr(const SharedPtr<Other> &other, const StaticPointerCastTag &)
-        m_counter(NULL),
-          m_ptr(NULL)
+    SharedPtr(const SharedPtr<Other> &other, const StaticPointerCastTag &) :
+        m_counter(NULL),
+        m_ptr(NULL)
     {
         m_ptr = static_cast<Class *>(other.m_ptr);
         AttachCounter(other.m_counter);
     }
 
     template<typename Other>
     {
         m_ptr = static_cast<Class *>(other.m_ptr);
         AttachCounter(other.m_counter);
     }
 
     template<typename Other>
-    SharedPtr(const SharedPtr<Other> &other, const ConstPointerCastTag &)
-        m_counter(NULL),
-          m_ptr(NULL)
+    SharedPtr(const SharedPtr<Other> &other, const ConstPointerCastTag &) :
+        m_counter(NULL),
+        m_ptr(NULL)
     {
         m_ptr = const_cast<Class *>(other.m_ptr);
         AttachCounter(other.m_counter);
     }
 
     template<typename Other>
     {
         m_ptr = const_cast<Class *>(other.m_ptr);
         AttachCounter(other.m_counter);
     }
 
     template<typename Other>
-    SharedPtr(const SharedPtr<Other> &other, const DynamicPointerCastTag &)
-        m_counter(NULL),
-          m_ptr(NULL)
+    SharedPtr(const SharedPtr<Other> &other, const DynamicPointerCastTag &) :
+        m_counter(NULL),
+        m_ptr(NULL)
     {
         Class *ptr = dynamic_cast<Class *>(other.Get());
 
     {
         Class *ptr = dynamic_cast<Class *>(other.Get());
 
-        if (ptr == NULL)
+        if (ptr == NULL) {
             return;
             return;
+        }
 
         m_ptr = ptr;
         AttachCounter(other.m_counter);
 
         m_ptr = ptr;
         AttachCounter(other.m_counter);
@@ -193,8 +189,7 @@ public:
     {
         DetachCounter();
 
     {
         DetachCounter();
 
-        if (ptr != NULL)
-        {
+        if (ptr != NULL) {
             m_ptr = ptr;
             m_counter = new SharedCounter();
             _Internal_AcceptSharedPtr(m_counter, m_ptr, m_ptr);
             m_ptr = ptr;
             m_counter = new SharedCounter();
             _Internal_AcceptSharedPtr(m_counter, m_ptr, m_ptr);
@@ -203,8 +198,7 @@ public:
 
     SharedPtr &operator=(const SharedPtr &other)
     {
 
     SharedPtr &operator=(const SharedPtr &other)
     {
-        if (this != &other)
-        {
+        if (this != &other) {
             DetachCounter();
             m_ptr = other.m_ptr;
             AttachCounter(other.m_counter);
             DetachCounter();
             m_ptr = other.m_ptr;
             AttachCounter(other.m_counter);
@@ -215,8 +209,9 @@ public:
 
     Atomic::ValueType GetUseCount() const
     {
 
     Atomic::ValueType GetUseCount() const
     {
-        if (m_counter == NULL)
+        if (m_counter == NULL) {
             return Atomic::ValueType(0);
             return Atomic::ValueType(0);
+        }
 
         return m_counter->ref;
     }
 
         return m_counter->ref;
     }
@@ -243,40 +238,45 @@ SharedPtr<Target> DynamicPointerCast(const SharedPtr<Source> &ptr)
 }
 
 template<typename First, typename Second>
 }
 
 template<typename First, typename Second>
-inline bool operator ==(const SharedPtr<First> &first, const SharedPtr<Second> &second)
+inline bool operator ==(const SharedPtr<First> &first,
+                        const SharedPtr<Second> &second)
 {
     return first.Get() == second.Get();
 }
 
 template<typename First, typename Second>
 {
     return first.Get() == second.Get();
 }
 
 template<typename First, typename Second>
-inline bool operator !=(const SharedPtr<First> &first, const SharedPtr<Second> &second)
+inline bool operator !=(const SharedPtr<First> &first,
+                        const SharedPtr<Second> &second)
 {
     return first.Get() != second.Get();
 }
 
 template<typename First, typename Second>
 {
     return first.Get() != second.Get();
 }
 
 template<typename First, typename Second>
-inline bool operator <(const SharedPtr<First> &first, const SharedPtr<Second> &second)
+inline bool operator <(const SharedPtr<First> &first,
+                       const SharedPtr<Second> &second)
 {
     return first.Get() < second.Get();
 }
 template<typename First, typename Second>
 {
     return first.Get() < second.Get();
 }
 template<typename First, typename Second>
-inline bool operator >(const SharedPtr<First> &first, const SharedPtr<Second> &second)
+inline bool operator >(const SharedPtr<First> &first,
+                       const SharedPtr<Second> &second)
 {
     return first.Get() > second.Get();
 }
 
 template<typename First, typename Second>
 {
     return first.Get() > second.Get();
 }
 
 template<typename First, typename Second>
-inline bool operator <=(const SharedPtr<First> &first, const SharedPtr<Second> &second)
+inline bool operator <=(const SharedPtr<First> &first,
+                        const SharedPtr<Second> &second)
 {
     return first.Get() <= second.Get();
 }
 
 template<typename First, typename Second>
 {
     return first.Get() <= second.Get();
 }
 
 template<typename First, typename Second>
-inline bool operator >=(const SharedPtr<First> &first, const SharedPtr<Second> &second)
+inline bool operator >=(const SharedPtr<First> &first,
+                        const SharedPtr<Second> &second)
 {
     return first.Get() >= second.Get();
 }
 {
     return first.Get() >= second.Get();
 }
-
 } // namespace DPL
 
 #endif // DPL_SHARED_PTR_H
 } // namespace DPL
 
 #endif // DPL_SHARED_PTR_H
index a480b2b..afcaf52 100644 (file)
 #include <dpl/exception.h>
 #include <string>
 
 #include <dpl/exception.h>
 #include <string>
 
-namespace DPL
+namespace DPL {
+class SingleInstance :
+    private Noncopyable
 {
 {
-class SingleInstance
-    : private Noncopyable
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, LockError)
         DECLARE_EXCEPTION_TYPE(Base, ReleaseError)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, LockError)
         DECLARE_EXCEPTION_TYPE(Base, ReleaseError)
     };
 
-private:
+  private:
     bool m_locked;
     int m_fdLock;
 
     bool m_locked;
     int m_fdLock;
 
-public:
+  public:
     SingleInstance();
     virtual ~SingleInstance();
 
     SingleInstance();
     virtual ~SingleInstance();
 
index 24d2e64..530f5c1 100644 (file)
 #include <dpl/thread.h>
 #include <dpl/assert.h>
 
 #include <dpl/thread.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 template<typename Class>
 template<typename Class>
-class Singleton
-    private Class
+class Singleton :
+    private Class
 {
     //
     // Note:
 {
     //
     // Note:
@@ -39,68 +38,20 @@ class Singleton
     // make Class' default constructor protected
     //
 
     // make Class' default constructor protected
     //
 
-private:
+  private:
     Singleton()
     Singleton()
-    {
-    }
+    {}
 
     typedef Optional<Thread *> OptionalThreadPtr;
 
     typedef Optional<Thread *> OptionalThreadPtr;
-    OptionalThreadPtr m_guard;
 
     static Singleton &InternalInstance();
 
 
     static Singleton &InternalInstance();
 
-public:
+  public:
     virtual ~Singleton()
     virtual ~Singleton()
-    {
-    }
+    {}
 
     static Class &Instance();
 
     static Class &Instance();
-
-    // Thread guarding
-    static void SetThreadGuard(Thread *thread);
-    static void ResetThreadGuard();
 };
 };
-
-//This is needed for backward compatibility
-#ifndef SEPARATED_SINGLETON_IMPLEMENTATION
-template<typename Class>
-Singleton<Class>& Singleton<Class>::InternalInstance()
-{
-    static Singleton<Class> instance;
-    return instance;
-}
-
-template<typename Class>
-Class &Singleton<Class>::Instance()
-{
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-
-    if (!!instance.m_guard)
-    {
-        Assert(Thread::GetCurrentThread() == *instance.m_guard &&
-               "Singleton thread guard failed. A forbidden call from foreign thread was detected!");
-    }
-
-    return instance;
-}
-
-// Thread guarding
-template<typename Class>
-void Singleton<Class>::SetThreadGuard(Thread *thread)
-{
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-    instance.m_guard = OptionalThreadPtr(thread);
-}
-
-template<typename Class>
-void Singleton<Class>::ResetThreadGuard()
-{
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-    instance.m_guard = OptionalThreadPtr::Null;
-}
-
-#endif
-
 } // namespace DPL
 
 #endif // DPL_SINGLETON_H
 } // namespace DPL
 
 #endif // DPL_SINGLETON_H
index 365ec15..12dbf32 100644 (file)
@@ -30,9 +30,7 @@
  * singleton_safe_impl.h if possible.
  */
 
  * singleton_safe_impl.h if possible.
  */
 
-namespace DPL
-{
-
+namespace DPL {
 template<typename Class>
 Singleton<Class>& Singleton<Class>::InternalInstance()
 {
 template<typename Class>
 Singleton<Class>& Singleton<Class>::InternalInstance()
 {
@@ -44,37 +42,12 @@ template<typename Class>
 Class &Singleton<Class>::Instance()
 {
     Singleton<Class>& instance = Singleton<Class>::InternalInstance();
 Class &Singleton<Class>::Instance()
 {
     Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-
-    if (!!instance.m_guard)
-    {
-        Assert(Thread::GetCurrentThread() == *instance.m_guard &&
-               "Singleton thread guard failed. A forbidden call from foreign thread was detected!");
-    }
-
     return instance;
 }
     return instance;
 }
-
-// Thread guarding
-template<typename Class>
-void Singleton<Class>::SetThreadGuard(Thread *thread)
-{
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-    instance.m_guard = OptionalThreadPtr(thread);
-}
-
-template<typename Class>
-void Singleton<Class>::ResetThreadGuard()
-{
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-    instance.m_guard = OptionalThreadPtr::Null;
-}
-
 } // namespace DPL
 
 #define IMPLEMENT_SINGLETON(Type)                                           \
 } // namespace DPL
 
 #define IMPLEMENT_SINGLETON(Type)                                           \
-template DPL::Singleton<Type>& DPL::Singleton<Type>::InternalInstance();    \
-template Type& DPL::Singleton<Type>::Instance();                            \
-template void DPL::Singleton<Type>::SetThreadGuard(DPL::Thread *thread);    \
-template void DPL::Singleton<Type>::ResetThreadGuard();
+    template DPL::Singleton<Type>&DPL::Singleton<Type>::InternalInstance();    \
+    template Type & DPL::Singleton<Type>::Instance();                            \
 
 #endif // DPL_SINGLETON_IMPL_H
 
 #endif // DPL_SINGLETON_IMPL_H
index 8fbe009..c8923b7 100644 (file)
 #define DPL_SINGLETON_SAFE_IMPL_H
 
 #define IMPLEMENT_SAFE_SINGLETON(Class)                                        \
 #define DPL_SINGLETON_SAFE_IMPL_H
 
 #define IMPLEMENT_SAFE_SINGLETON(Class)                                        \
-namespace DPL {                                                                \
-template<>                                                                     \
-Singleton<Class>& Singleton<Class>::InternalInstance()                         \
-{                                                                              \
-    static Singleton<Class> instance;                                          \
-    return instance;                                                           \
-}                                                                              \
+    namespace DPL {                                                                \
+    template<>                                                                     \
+    Singleton<Class>&Singleton<Class>::InternalInstance()                         \
+    {                                                                              \
+        static Singleton<Class> instance;                                          \
+        return instance;                                                           \
+    }                                                                              \
                                                                                \
                                                                                \
-template<>                                                                     \
-Class &Singleton<Class>::Instance()                                            \
-{                                                                              \
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();         \
-    if (!!instance.m_guard)                                                    \
-    {                                                                          \
-        Assert(Thread::GetCurrentThread() == *instance.m_guard &&              \
-               "Singleton thread guard failed. A forbidden call from foreign thread was detected!");\
-    }                                                                          \
-    return instance;                                                           \
-}                                                                              \
+    template<>                                                                     \
+    Class & Singleton<Class>::Instance()                                            \
+    {                                                                              \
+        Singleton<Class>& instance = Singleton<Class>::InternalInstance();         \
+        return instance;                                                           \
+    }                                                                              \
                                                                                \
                                                                                \
-template<>                                                                     \
-void Singleton<Class>::SetThreadGuard(Thread *thread)                          \
-{                                                                              \
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();         \
-    instance.m_guard = OptionalThreadPtr(thread);                              \
-}                                                                              \
-                                                                               \
-template<>                                                                     \
-void Singleton<Class>::ResetThreadGuard()                                      \
-{                                                                              \
-    Singleton<Class>& instance = Singleton<Class>::InternalInstance();         \
-    instance.m_guard = OptionalThreadPtr::Null;                                \
-}                                                                              \
-template Singleton<Class>& Singleton<Class>::InternalInstance();               \
-template Class& Singleton<Class>::Instance();                                  \
-template void Singleton<Class>::SetThreadGuard(Thread *thread);                \
-template void Singleton<Class>::ResetThreadGuard();                            \
-} // namespace DPL
-
+    template Singleton<Class>&Singleton<Class>::InternalInstance();               \
+    template Class & Singleton<Class>::Instance();                                  \
+    } // namespace DPL
 
 #endif // DPL_SINGLETON_SAFE_IMPL_H
 
 #endif // DPL_SINGLETON_SAFE_IMPL_H
index 32e21d3..aba4e0f 100644 (file)
@@ -25,9 +25,7 @@
 #include <sstream>
 #include <dpl/string.h>
 
 #include <sstream>
 #include <dpl/string.h>
 
-namespace DPL
-{
-
+namespace DPL {
 // @brief DPL IStringStream
 typedef std::basic_istringstream<CharTraits::char_type,
                                  CharTraits> IStringStream;
 // @brief DPL IStringStream
 typedef std::basic_istringstream<CharTraits::char_type,
                                  CharTraits> IStringStream;
@@ -35,8 +33,6 @@ typedef std::basic_istringstream<CharTraits::char_type,
 // @brief DPL OStringStream
 typedef std::basic_ostringstream<CharTraits::char_type,
                                  CharTraits> OStringStream;
 // @brief DPL OStringStream
 typedef std::basic_ostringstream<CharTraits::char_type,
                                  CharTraits> OStringStream;
-
 } //namespace DPL
 
 } //namespace DPL
 
-
 #endif // DPL_CORE_INCLUDE_SSTREAM_H_
 #endif // DPL_CORE_INCLUDE_SSTREAM_H_
index 7c35cdb..59cd5e1 100644 (file)
 #include <string>
 #include <ostream>
 
 #include <string>
 #include <ostream>
 
-namespace DPL
-{
+namespace DPL {
 // @brief DPL string
 typedef std::basic_string<wchar_t, CharTraits> String;
 
 // @brief String exception class
 class StringException
 {
 // @brief DPL string
 typedef std::basic_string<wchar_t, CharTraits> String;
 
 // @brief String exception class
 class StringException
 {
-public:
+  public:
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
 
     // @brief Invalid init for UTF8 to UTF32 converter
     DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
 
     // @brief Invalid init for UTF8 to UTF32 converter
@@ -76,33 +75,36 @@ int StringCompare(const String &left,
 
 //@brief Splits the string into substrings.
 //@param[in] str Input string
 
 //@brief Splits the string into substrings.
 //@param[in] str Input string
-//@param[in] delimiters array or string containing a sequence of substring delimiters. Can be also a single delimiter character.
+//@param[in] delimiters array or string containing a sequence of substring
+// delimiters. Can be also a single delimiter character.
 //@param[in] it InserterIterator that is used to save the generated substrings.
 template<typename StringType, typename Delimiters, typename InserterIterator>
 //@param[in] it InserterIterator that is used to save the generated substrings.
 template<typename StringType, typename Delimiters, typename InserterIterator>
-void Tokenize(const StringType& str, const Delimiters& delimiters, InserterIterator it, bool ignoreEmpty = false)
+void Tokenize(const StringType& str,
+              const Delimiters& delimiters,
+              InserterIterator it,
+              bool ignoreEmpty = false)
 {
     typename StringType::size_type nextSearchStart = 0;
     typename StringType::size_type pos;
     typename StringType::size_type length;
 
 {
     typename StringType::size_type nextSearchStart = 0;
     typename StringType::size_type pos;
     typename StringType::size_type length;
 
-    while ( true )
-    {
+    while (true) {
         pos = str.find_first_of(delimiters, nextSearchStart);
         pos = str.find_first_of(delimiters, nextSearchStart);
-        length = ((pos == StringType::npos) ? str.length() : pos) - nextSearchStart;
+        length =
+            ((pos == StringType::npos) ? str.length() : pos) - nextSearchStart;
 
 
-        if ( !ignoreEmpty || length > 0 )
-        {
+        if (!ignoreEmpty || length > 0) {
             *it = str.substr(nextSearchStart, length);
             it++;
         }
 
             *it = str.substr(nextSearchStart, length);
             it++;
         }
 
-        if ( pos == StringType::npos )
+        if (pos == StringType::npos) {
             return;
             return;
+        }
 
         nextSearchStart = pos + 1;
     }
 }
 
         nextSearchStart = pos + 1;
     }
 }
-
 } //namespace DPL
 
 std::ostream& operator<<(std::ostream& aStream, const DPL::String& aString);
 } //namespace DPL
 
 std::ostream& operator<<(std::ostream& aStream, const DPL::String& aString);
index 7e43253..393ab4d 100644 (file)
 #ifndef DPL_TASK_H
 #define DPL_TASK_H
 
 #ifndef DPL_TASK_H
 #define DPL_TASK_H
 
-#include <dpl/scoped_array.h>
 #include <dpl/noncopyable.h>
 #include <dpl/noncopyable.h>
-#include <dpl/union_cast.h>
-#include <dpl/semaphore.h>
 #include <dpl/foreach.h>
 #include <dpl/foreach.h>
-#include <dpl/mutex.h>
 #include <dpl/assert.h>
 #include <dpl/assert.h>
-#include <dpl/log/log.h>
 #include <algorithm>
 #include <algorithm>
-#include <sstream>
-#include <iomanip>
 #include <list>
 #include <list>
-#include <stack>
-#include <cctype>
 
 
-namespace DPL
-{
+namespace DPL {
 class TaskList;
 
 class TaskList;
 
-class Task
-    private Noncopyable
+class Task :
+    private Noncopyable
 {
 {
-public:
+  public:
     virtual ~Task() {}
 
     virtual bool NextStep() = 0;
     virtual ~Task() {}
 
     virtual bool NextStep() = 0;
@@ -54,13 +44,13 @@ public:
 };
 
 template<typename Impl>
 };
 
 template<typename Impl>
-class TaskDecl
-    public Task
+class TaskDecl :
+    public Task
 {
 {
-protected:
+  protected:
     typedef void (Impl::*Step)();
 
     typedef void (Impl::*Step)();
 
-private:
+  private:
     typedef std::list<Step> StepList;
 
     StepList m_steps;
     typedef std::list<Step> StepList;
 
     StepList m_steps;
@@ -72,26 +62,36 @@ private:
     Impl *m_impl;
     bool m_running;
 
     Impl *m_impl;
     bool m_running;
 
-protected:
+  protected:
     void AddStep(Step step)
     {
         Assert(!m_running && "AddStep is not allowed after calling NextStep!");
     void AddStep(Step step)
     {
         Assert(!m_running && "AddStep is not allowed after calling NextStep!");
-        Assert(m_steps.end() == std::find(m_steps.begin(), m_steps.end(), step) && "The same step started twice is not supported");
+        Assert(m_steps.end() == std::find(m_steps.begin(),
+                                          m_steps.end(),
+                                          step) &&
+               "The same step started twice is not supported");
         m_steps.push_back(step);
         m_nextStep = m_steps.begin();
     }
 
     void AddAbortStep(Step step)
     {
         m_steps.push_back(step);
         m_nextStep = m_steps.begin();
     }
 
     void AddAbortStep(Step step)
     {
-        Assert(!m_running && "AddAbortStep is not allowed after calling NextStep!");
-        Assert(m_abortSteps.end() == std::find(m_abortSteps.begin(), m_abortSteps.end(), step) && "The same step started twice is not supported");
+        Assert(
+            !m_running && "AddAbortStep is not allowed after calling NextStep!");
+        Assert(m_abortSteps.end() ==
+               std::find(m_abortSteps.begin(),
+                         m_abortSteps.end(),
+                         step) &&
+               "The same step started twice is not supported");
         m_abortSteps.push_front(step);
     }
 
     void SwitchToStep(Step step)
     {
         m_abortSteps.push_front(step);
     }
 
     void SwitchToStep(Step step)
     {
-        /// @TODO There can be problem here if user sets the same method two times in task list.
-        typename StepList::iterator i = std::find(m_steps.begin(), m_steps.end(), step);
+        /// @TODO There can be problem here if user sets the same method two
+        // times in task list.
+        typename StepList::iterator i = std::find(m_steps.begin(),
+                                                  m_steps.end(), step);
         Assert(i != m_steps.end());
         m_nextStep = i;
         m_switched = true;
         Assert(i != m_steps.end());
         m_nextStep = i;
         m_switched = true;
@@ -99,17 +99,18 @@ protected:
 
     Step GetCurrentStep() const
     {
 
     Step GetCurrentStep() const
     {
-        if(m_currentStep == m_steps.end())
+        if (m_currentStep == m_steps.end()) {
             return NULL;
             return NULL;
+        }
 
         return *m_currentStep;
     }
 
 
         return *m_currentStep;
     }
 
-public:
-    TaskDecl(Impl *impl)
-        m_switched(false),
-          m_impl(impl),
-          m_running(false)
+  public:
+    TaskDecl(Impl *impl) :
+        m_switched(false),
+        m_impl(impl),
+        m_running(false)
     {
         Assert(this == m_impl);
         m_currentStep = m_steps.end();
     {
         Assert(this == m_impl);
         m_currentStep = m_steps.end();
@@ -120,7 +121,9 @@ public:
     {
         m_running = true;
 
     {
         m_running = true;
 
-        Assert(m_nextStep != m_steps.end() && "Step list is empty or all steps done");
+        Assert(
+            m_nextStep != m_steps.end() &&
+            "Step list is empty or all steps done");
 
         m_switched = false;
 
 
         m_switched = false;
 
@@ -129,10 +132,11 @@ public:
 
         m_currentStep = m_nextStep;
 
 
         m_currentStep = m_nextStep;
 
-        if (m_switched)
+        if (m_switched) {
             return true;
             return true;
-        else
+        } else {
             return ++m_nextStep != m_steps.end();
             return ++m_nextStep != m_steps.end();
+        }
     }
 
     bool Abort()
     }
 
     bool Abort()
@@ -141,11 +145,12 @@ public:
 
         m_steps.clear();
 
 
         m_steps.clear();
 
-        if (m_abortSteps.empty())
+        if (m_abortSteps.empty()) {
             return false;
             return false;
+        }
 
 
-        FOREACH (it, m_abortSteps)
-            m_steps.push_back(*it);
+        FOREACH(it, m_abortSteps)
+        m_steps.push_back(*it);
 
         m_nextStep = m_steps.begin();
 
 
         m_nextStep = m_steps.begin();
 
@@ -159,377 +164,6 @@ public:
         return static_cast<size_t>(m_steps.size());
     }
 };
         return static_cast<size_t>(m_steps.size());
     }
 };
-
-template<typename ImplementationType>
-class MultiTaskDecl
-    : public Task
-{
-protected:
-    typedef void (ImplementationType::*Step)();
-    typedef std::list<Step> StepList;
-    typedef std::stack<Step> StepStack;
-
-private:
-    static std::string StepToString(Step step)
-    {
-        std::ostringstream pseudoAddressStream;
-        pseudoAddressStream << std::hex << union_cast<size_t>(step);
-
-        std::string pseudoAddress = pseudoAddressStream.str();
-
-        std::transform(pseudoAddress.begin(), pseudoAddress.end(),
-                       pseudoAddress.begin(), ::toupper);
-
-        return std::string("0x") + pseudoAddress;
-    }
-
-    struct ConditionalStep
-    {
-        Step step;
-
-        // Depencency lists
-        StepList unsatisfiedDependencies;
-        StepList satisfiedDependencies;
-
-        ConditionalStep()
-            : step(NULL)
-        {
-        }
-
-        ConditionalStep(Step stepArg,
-                        StepList dependenciesArg)
-            : step(stepArg),
-              unsatisfiedDependencies(dependenciesArg)
-        {
-        }
-    };
-
-    typedef std::list<ConditionalStep> ConditionalStepList;
-
-    // Synchronization
-    Semaphore m_activeStepsSemaphore;
-    mutable Mutex m_dependencyListMutex;
-
-    // Those steps that have their dependency lists satified and are ready
-    // to be executed
-    // Current step is defined to be the front of satisfied list
-    ConditionalStepList m_satisfiedSteps;
-
-    // Those steps that are going to be executed but their dependency
-    // lists have not been satified
-    ConditionalStepList m_unsatisfiedSteps;
-
-    // Those steps that have their dependency lists satified and are currently
-    // being executed
-    ConditionalStepList m_executingSteps;
-
-    // Those steps that have been executed with their dependency lists
-    // satisfied
-    ConditionalStepList m_historicSteps;
-
-    ///< Growing list of submitted abort steps
-    StepStack m_abortSteps;
-
-    // Deriving implementation
-    ImplementationType *m_implementation;
-
-    // Max parallel steps
-    size_t m_maxParallelCount;
-
-    ///< Valid in dependency list mutex only
-    void SatisfyDependencies(const ConditionalStep &conditionalStep)
-    {
-        LogPedantic("Satisfying steps with dependecy to step: "
-                    << StepToString(conditionalStep.step));
-
-        // Can satisfy conditional steps if and only if there are no more
-        // satisfied, unsatisfied or running same steps
-        // There is at least one historic step - this one
-        if (IsContainingStep(conditionalStep.step, m_unsatisfiedSteps) ||
-            IsContainingStep(conditionalStep.step, m_satisfiedSteps) ||
-            IsContainingStep(conditionalStep.step, m_executingSteps))
-        {
-            LogPedantic("Step " << StepToString(conditionalStep.step)
-                        << " cannot satify other steps yet");
-
-            return;
-        }
-
-        LogPedantic("Step " << StepToString(conditionalStep.step)
-                    << " can satify other steps");
-
-        // Do satisfy
-        typename ConditionalStepList::iterator unsatisfiedStepIterator =
-            m_unsatisfiedSteps.begin();;
-
-        while (unsatisfiedStepIterator != m_unsatisfiedSteps.end())
-        {
-            typename StepList::iterator iterator =
-                std::find(
-                    unsatisfiedStepIterator->unsatisfiedDependencies.begin(),
-                    unsatisfiedStepIterator->unsatisfiedDependencies.end(),
-                    conditionalStep.step);
-
-            // Does this conditional step need to be satisfied ?
-            if (iterator ==
-                unsatisfiedStepIterator->unsatisfiedDependencies.end())
-            {
-                continue;
-            }
-
-            LogPedantic("Satisfying step "
-                        << StepToString(unsatisfiedStepIterator->step)
-                        << " dependency to step "
-                        << StepToString(conditionalStep.step));
-
-            // Satisfy dependency
-            unsatisfiedStepIterator->unsatisfiedDependencies.erase(
-                iterator);
-
-            unsatisfiedStepIterator->satisfiedDependencies.push_back(
-                conditionalStep.step);
-
-            // If step is fully satisfied, transfer it to the satisfied
-            // steps list
-            if (unsatisfiedStepIterator->unsatisfiedDependencies.empty())
-            {
-                LogPedantic("Step "
-                            << StepToString(unsatisfiedStepIterator->step)
-                            << " is fully satisfied");
-
-                // Move step
-                m_satisfiedSteps.push_back(*unsatisfiedStepIterator);
-
-                unsatisfiedStepIterator =
-                    m_unsatisfiedSteps.erase(unsatisfiedStepIterator);
-
-                continue;
-            }
-
-            // Check next unsatisfied step
-            ++unsatisfiedStepIterator;
-        }
-    }
-
-    ///< Valid in dependency list mutex only
-    bool IsContainingStep(Step step, const ConditionalStepList &dependencies) const
-    {
-        FOREACH (iterator, dependencies)
-            if (iterator->step == step)
-                return true;
-
-        return false;
-    }
-
-    ///< Valid in dependency list mutex only
-    bool IsStepDependecyListSatisfied(
-        const StepList &dependencies) const
-    {
-        // All dependant step must be historic
-        FOREACH (iterator, dependencies)
-            if (!IsContainingStep(*iterator, m_historicSteps))
-                return false;
-
-        // Also, none dependant step can exist in
-        // unsatisfied/satisfied/inProgress lists
-        FOREACH (iterator, dependencies)
-        {
-            if (IsContainingStep(*iterator, m_unsatisfiedSteps) ||
-                IsContainingStep(*iterator, m_satisfiedSteps) ||
-                IsContainingStep(*iterator, m_executingSteps))
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    bool AbortInternal()
-    {
-        // Clear all steps and construct
-        // a single-dependency list of abort steps
-        m_unsatisfiedSteps.clear();
-        m_satisfiedSteps.clear();
-        m_executingSteps.clear();
-        m_historicSteps.clear();
-
-        if (m_abortSteps.empty())
-            return false;
-
-        // Register last abort step as satisfied
-        m_satisfiedSteps.push_back(
-            ConditionalStep(
-                m_abortSteps.top(),
-                StepList()));
-
-        Step lastStep = m_abortSteps.top();
-        m_abortSteps.pop();
-
-        // Create abort step list
-        while (!m_abortSteps.empty())
-        {
-            // Add next unsatisfied step
-            StepList dependencies;
-            dependencies.push_back(lastStep);
-
-            m_unsatisfiedSteps.push_back(
-                ConditionalStep(
-                    m_abortSteps.top(),
-                    dependencies));
-
-            // Remove top abort step
-            lastStep = m_abortSteps.top();
-            m_abortSteps.pop();
-        }
-
-        return true;
-    }
-
-protected:
-    void AddStep(Step step,
-                 const StepList &dependencies)
-    {
-        Mutex::ScopedLock lock(&m_dependencyListMutex);
-
-        LogPedantic("Adding step: " << StepToString(step));
-
-        FOREACH (iterator, dependencies)
-            LogPedantic("  Dependency: " << StepToString(*iterator));
-
-        // Add step to proper list
-        if (IsStepDependecyListSatisfied(dependencies))
-        {
-            m_satisfiedSteps.push_back(ConditionalStep(step, dependencies));
-
-            LogPedantic("Step " << StepToString(step) << " is satisfied");
-        }
-        else
-        {
-            m_unsatisfiedSteps.push_back(ConditionalStep(step, dependencies));
-
-            LogPedantic("Step " << StepToString(step) << " is unsatisfied");
-        }
-
-        LogPedantic("Satisfied step count: " << m_satisfiedSteps.size());
-        LogPedantic("Unsatisfied step count: " << m_unsatisfiedSteps.size());
-    }
-
-    void AddAbortStep(Step step)
-    {
-        Mutex::ScopedLock lock(&m_dependencyListMutex);
-
-        m_abortSteps.push_front(step);
-
-        LogPedantic("Abort step count: " << m_abortSteps.size());
-    }
-
-public:
-    MultiTaskDecl(ImplementationType *implementation,
-                  size_t maxParallelCount)
-        : m_activeStepsSemaphore(maxParallelCount),
-          m_implementation(implementation),
-          m_maxParallelCount(maxParallelCount)
-    {
-    }
-
-    bool NextStep()
-    {
-        ConditionalStep stepToExecute;
-        typename ConditionalStepList::iterator executingStepIterator;
-
-        // Take the main semaphore lock
-        Semaphore::ScopedLock semaphoreLock(&m_activeStepsSemaphore);
-
-        // Take the dependency list lock
-        {
-            Mutex::ScopedLock listLock(&m_dependencyListMutex);
-
-            // Get next step to execute
-            if (m_satisfiedSteps.empty())
-            {
-                LogPedantic("No more satisfied steps to execute");
-                return false;
-            }
-
-            // Get next satisfied step to execute
-            stepToExecute = m_satisfiedSteps.front();
-            m_satisfiedSteps.pop_front();
-
-            // Register it in executing step list
-            m_executingSteps.push_back(stepToExecute);
-            executingStepIterator = --m_executingSteps.end();
-
-            // Leave the dependency list lock
-        }
-
-        // Execute step
-        (*m_implementation.*stepToExecute.step)();
-
-        // Take a lock again
-        {
-            Mutex::ScopedLock listLock(&m_dependencyListMutex);
-
-            // Unregister executing step
-            m_executingSteps.erase(executingStepIterator);
-
-            // Add historic step
-            m_historicSteps.push_back(stepToExecute);
-
-            // Satisfy dependencies
-            SatisfyDependencies(stepToExecute);
-
-            // Leave lock
-        }
-
-        // Done
-        return true;
-    }
-
-    bool Abort()
-    {
-        // Wait until all active steps are done
-        // This is achieved by taking all semaphore slots
-        ScopedArray<Semaphore::ScopedLock *> semaphoreLocks(
-            new Semaphore::ScopedLock *[m_maxParallelCount]);
-
-        for (size_t i = 0; i < m_maxParallelCount; ++i)
-            semaphoreLocks[i] = new Semaphore::ScopedLock(
-                &m_activeStepsSemaphore);
-
-        // Result
-        bool result;
-
-        // Take step lists lock
-        {
-            Mutex::ScopedLock mutexLock(&m_dependencyListMutex);
-
-            // Do internal abort
-            result = AbortInternal();
-
-            // Leave steps list lock
-        }
-
-        // Leave semaphore locks
-        for (size_t i = 0; i < m_maxParallelCount; ++i)
-            delete semaphoreLocks[i];
-
-        // Return result
-        return result;
-    }
-
-    size_t GetStepCount() const
-    {
-        // Return sum of sizes of all lists
-        Mutex::ScopedLock lock(&m_dependencyListMutex);
-
-        return static_cast<size_t>(
-            m_unsatisfiedSteps.size() +
-            m_satisfiedSteps.size() +
-            m_executingSteps.size() +
-            m_historicSteps.size());
-    }
-};
 } // namespace DPL
 
 #endif // DPL_TASK_H
 } // namespace DPL
 
 #endif // DPL_TASK_H
index b010dfc..2b3d34a 100644 (file)
 #include <dpl/task.h>
 #include <list>
 
 #include <dpl/task.h>
 #include <list>
 
-namespace DPL
+namespace DPL {
+class TaskList :
+    public Task
 {
 {
-class TaskList
-    : public Task      
-{
-private:
+  private:
     typedef std::list<Task *> Tasks;
 
     Tasks m_tasks;
     typedef std::list<Task *> Tasks;
 
     Tasks m_tasks;
@@ -40,11 +39,11 @@ private:
 
     bool m_running;
 
 
     bool m_running;
 
-protected:
+  protected:
     void AddTask(Task *task);
     void SwitchToTask(Task *task);
 
     void AddTask(Task *task);
     void SwitchToTask(Task *task);
 
-public:
+  public:
     TaskList();
     virtual ~TaskList();
 
     TaskList();
     virtual ~TaskList();
 
index b49ee09..a0040eb 100644 (file)
 #include <list>
 #include <map>
 
 #include <list>
 #include <map>
 
-namespace DPL
+namespace DPL {
+class Thread :
+    private Noncopyable,
+    public WaitableHandleWatchSupport
 {
 {
-class Thread
-    : private Noncopyable,
-      public WaitableHandleWatchSupport
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
@@ -60,7 +59,7 @@ public:
     typedef void (*EventDeleteProc)(void *event, void *userParam);
     typedef void (*EventDispatchProc)(void *event, void *userParam);
 
     typedef void (*EventDeleteProc)(void *event, void *userParam);
     typedef void (*EventDispatchProc)(void *event, void *userParam);
 
-protected:
+  protected:
     /**
      * Main thread entry
      * The method is intended to be overloaded with custom code.
     /**
      * Main thread entry
      * The method is intended to be overloaded with custom code.
@@ -74,7 +73,7 @@ protected:
      */
     int Exec();
 
      */
     int Exec();
 
-private:
+  private:
     struct InternalEvent
     {
         void *event;
     struct InternalEvent
     {
         void *event;
@@ -85,17 +84,16 @@ private:
         InternalEvent(void *eventArg,
                       void *userParamArg,
                       EventDispatchProc eventDispatchProcArg,
         InternalEvent(void *eventArg,
                       void *userParamArg,
                       EventDispatchProc eventDispatchProcArg,
-                      EventDeleteProc eventDeleteProcArg)
-            : event(eventArg),
-              userParam(userParamArg),
-              eventDispatchProc(eventDispatchProcArg),
-              eventDeleteProc(eventDeleteProcArg)
-        {
-        }
+                      EventDeleteProc eventDeleteProcArg) :
+            event(eventArg),
+            userParam(userParamArg),
+            eventDispatchProc(eventDispatchProcArg),
+            eventDeleteProc(eventDeleteProcArg)
+        {}
     };
 
     };
 
-    struct InternalTimedEvent
-        InternalEvent
+    struct InternalTimedEvent :
+        InternalEvent
     {
         unsigned long dueTimeMiliseconds;
         unsigned long registerTimeMiliseconds;
     {
         unsigned long dueTimeMiliseconds;
         unsigned long registerTimeMiliseconds;
@@ -105,19 +103,19 @@ private:
                            unsigned long dueTimeMilisecondsArg,
                            unsigned long registerTimeMilisecondsArg,
                            EventDispatchProc eventDispatchProcArg,
                            unsigned long dueTimeMilisecondsArg,
                            unsigned long registerTimeMilisecondsArg,
                            EventDispatchProc eventDispatchProcArg,
-                           EventDeleteProc eventDeleteProcArg)
-            : InternalEvent(eventArg,
-                            userParamArg,
-                            eventDispatchProcArg,
-                            eventDeleteProcArg),
-              dueTimeMiliseconds(dueTimeMilisecondsArg),
-              registerTimeMiliseconds(registerTimeMilisecondsArg)
-        {
-        }
+                           EventDeleteProc eventDeleteProcArg) :
+            InternalEvent(eventArg,
+                          userParamArg,
+                          eventDispatchProcArg,
+                          eventDeleteProcArg),
+            dueTimeMiliseconds(dueTimeMilisecondsArg),
+            registerTimeMiliseconds(registerTimeMilisecondsArg)
+        {}
 
         bool operator<(const InternalTimedEvent &other)
         {
 
         bool operator<(const InternalTimedEvent &other)
         {
-            return registerTimeMiliseconds + dueTimeMiliseconds > other.registerTimeMiliseconds + other.dueTimeMiliseconds;
+            return registerTimeMiliseconds + dueTimeMiliseconds >
+                   other.registerTimeMiliseconds + other.dueTimeMiliseconds;
         }
     };
 
         }
     };
 
@@ -156,7 +154,7 @@ private:
 
     static void *StaticThreadEntry(void *param);
 
 
     static void *StaticThreadEntry(void *param);
 
-public:
+  public:
     explicit Thread();
     virtual ~Thread();
 
     explicit Thread();
     virtual ~Thread();
 
@@ -172,6 +170,12 @@ public:
     void Quit();
 
     /**
     void Quit();
 
     /**
+     * Checks if current thread is main one
+     * Returns true if it is main program thread, false otherwise
+     */
+    static bool IsMainThread();
+
+    /**
      * Current thread retrieval
      * Returns DPL thread handle or NULL if it is main program thread
      */
      * Current thread retrieval
      * Returns DPL thread handle or NULL if it is main program thread
      */
@@ -180,12 +184,19 @@ public:
     /**
      * Low-level event push, usually used only by EventSupport
      */
     /**
      * Low-level event push, usually used only by EventSupport
      */
-    void PushEvent(void *event, EventDispatchProc eventDispatchProc, EventDeleteProc eventDeleteProc, void *userParam);
+    void PushEvent(void *event,
+                   EventDispatchProc eventDispatchProc,
+                   EventDeleteProc eventDeleteProc,
+                   void *userParam);
 
     /**
      * Low-level timed event push, usually used only by EventSupport
      */
 
     /**
      * Low-level timed event push, usually used only by EventSupport
      */
-    void PushTimedEvent(void *event, double dueTimeSeconds, EventDispatchProc eventDispatchProc, EventDeleteProc eventDeleteProc, void *userParam);
+    void PushTimedEvent(void *event,
+                        double dueTimeSeconds,
+                        EventDispatchProc eventDispatchProc,
+                        EventDeleteProc eventDeleteProc,
+                        void *userParam);
 
     /**
      * Sleep for a number of seconds
 
     /**
      * Sleep for a number of seconds
@@ -217,20 +228,21 @@ extern bool g_TLSforMainCreated;
 // (process can become non-responsive)
 // TODO further investigation is required.
 template<typename Type>
 // (process can become non-responsive)
 // TODO further investigation is required.
 template<typename Type>
-class ThreadLocalVariable
-    public Noncopyable
+class ThreadLocalVariable :
+    public Noncopyable
 {
 {
-public:
+  public:
     typedef Type ValueType;
 
     class Exception
     {
     typedef Type ValueType;
 
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, NullReference)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, NullReference)
+        DECLARE_EXCEPTION_TYPE(Base, KeyCreateFailed)
     };
 
     };
 
-private:
+  private:
     pthread_key_t m_key;
 
     struct ManagedValue
     pthread_key_t m_key;
 
     struct ManagedValue
@@ -253,12 +265,9 @@ private:
     {
         // Destroy underlying type
         ManagedValue *instance = static_cast<ManagedValue *>(specific);
     {
         // Destroy underlying type
         ManagedValue *instance = static_cast<ManagedValue *>(specific);
-        if(instance->guardKey.IsNull())
-        {
+        if (instance->guardKey.IsNull()) {
             delete instance;
             delete instance;
-        }
-        else
-        {
+        } else {
             int result = pthread_setspecific(*(instance->guardKey), instance);
 
             Assert(result == 0 &&
             int result = pthread_setspecific(*(instance->guardKey), instance);
 
             Assert(result == 0 &&
@@ -271,18 +280,16 @@ private:
         ManagedValue *instance =
             static_cast<ManagedValue *>(pthread_getspecific(m_key));
 
         ManagedValue *instance =
             static_cast<ManagedValue *>(pthread_getspecific(m_key));
 
-        if (!instance)
-        {
+        if (!instance) {
             // Check if it is allowed to instantiate
             // Check if it is allowed to instantiate
-            if (!allowInstantiate)
+            if (!allowInstantiate) {
                 Throw(typename Exception::NullReference);
                 Throw(typename Exception::NullReference);
+            }
 
             // checking, if specific data is created for Main thread
             // If yes, pthread_exit(NULL) is required
 
             // checking, if specific data is created for Main thread
             // If yes, pthread_exit(NULL) is required
-            if (!g_TLSforMainCreated)
-            {
-                if (Thread::GetCurrentThread() == NULL)
-                {
+            if (!g_TLSforMainCreated) {
+                if (Thread::IsMainThread()) {
                     g_TLSforMainCreated = true;
                     atexit(&MainThreadExitClean);
                 }
                     g_TLSforMainCreated = true;
                     atexit(&MainThreadExitClean);
                 }
@@ -300,13 +307,14 @@ private:
         return instance->value;
     }
 
         return instance->value;
     }
 
-public:
+  public:
     ThreadLocalVariable()
     {
         int result = pthread_key_create(&m_key, &InternalDestroy);
     ThreadLocalVariable()
     {
         int result = pthread_key_create(&m_key, &InternalDestroy);
-
-        Assert(result == 0 &&
-               "Failed to allocate thread local variable");
+        if (result != 0) {
+            ThrowMsg(typename Exception::KeyCreateFailed,
+                     "Failed to allocate thread local variable: " << result);
+        }
     }
 
     ~ThreadLocalVariable()
     }
 
     ~ThreadLocalVariable()
@@ -356,8 +364,9 @@ public:
         ManagedValue *specific =
             static_cast<ManagedValue *>(pthread_getspecific(m_key));
 
         ManagedValue *specific =
             static_cast<ManagedValue *>(pthread_getspecific(m_key));
 
-        if (!specific)
+        if (!specific) {
             return;
             return;
+        }
 
         // TODO Should be an assert? is it developers fault to Reset Guarded
         // value?
 
         // TODO Should be an assert? is it developers fault to Reset Guarded
         // value?
index e5c0f77..88afaf2 100644 (file)
 
 #include <cstddef>
 
 
 #include <cstddef>
 
-namespace DPL
-{
+namespace DPL {
 class TypeListGuard
 {
 class TypeListGuard
 {
-public:
+  public:
     template<size_t Index>
     struct Element
     {
     template<size_t Index>
     struct Element
     {
@@ -42,15 +41,13 @@ public:
 template<typename HeadType, typename TailType>
 class TypeList
 {
 template<typename HeadType, typename TailType>
 class TypeList
 {
-private:
+  private:
     class DummyClass
     class DummyClass
-    {
-    };
+    {};
 
     template<typename List, size_t Enum>
 
     template<typename List, size_t Enum>
-    struct TypeCounter : public TypeCounter<typename List::Tail, Enum+1>
-    {
-    };
+    struct TypeCounter : public TypeCounter<typename List::Tail, Enum + 1>
+    {};
 
     template<size_t Enum>
     struct TypeCounter<TypeListGuard, Enum>
 
     template<size_t Enum>
     struct TypeCounter<TypeListGuard, Enum>
@@ -58,7 +55,7 @@ private:
         static const size_t Size = Enum;
     };
 
         static const size_t Size = Enum;
     };
 
-public:
+  public:
     typedef TailType Tail;
     typedef HeadType Head;
     typedef TypeList<HeadType, TailType> ThisType;
     typedef TailType Tail;
     typedef HeadType Head;
     typedef TypeList<HeadType, TailType> ThisType;
@@ -90,11 +87,11 @@ public:
     static const size_t Size = TypeCounter<ThisType, 0>::Size;
 };
 
     static const size_t Size = TypeCounter<ThisType, 0>::Size;
 };
 
-template<typename T1  = TypeListGuard, typename T2  = TypeListGuard,
-         typename T3  = TypeListGuard, typename T4  = TypeListGuard,
-         typename T5  = TypeListGuard, typename T6  = TypeListGuard,
-         typename T7  = TypeListGuard, typename T8  = TypeListGuard,
-         typename T9  = TypeListGuard, typename T10 = TypeListGuard,
+template<typename T1 = TypeListGuard, typename T2 = TypeListGuard,
+         typename T3 = TypeListGuard, typename T4 = TypeListGuard,
+         typename T5 = TypeListGuard, typename T6 = TypeListGuard,
+         typename T7 = TypeListGuard, typename T8 = TypeListGuard,
+         typename T9 = TypeListGuard, typename T10 = TypeListGuard,
          typename T11 = TypeListGuard, typename T12 = TypeListGuard,
          typename T13 = TypeListGuard, typename T14 = TypeListGuard,
          typename T15 = TypeListGuard, typename T16 = TypeListGuard,
          typename T11 = TypeListGuard, typename T12 = TypeListGuard,
          typename T13 = TypeListGuard, typename T14 = TypeListGuard,
          typename T15 = TypeListGuard, typename T16 = TypeListGuard,
@@ -126,8 +123,8 @@ struct TypeListDecl
 {
     typedef TypeList<T1,
                      typename TypeListDecl<
 {
     typedef TypeList<T1,
                      typename TypeListDecl<
-                         T2,  T3,  T4,  T5,  T6,  T7,  T8,
-                         T9,  T10, T11, T12, T13, T14, T15,
+                         T2, T3, T4, T5, T6, T7, T8,
+                         T9, T10, T11, T12, T13, T14, T15,
                          T16, T17, T18, T19, T20, T21, T22,
                          T23, T24, T25, T26, T27, T28, T29,
                          T30, T31, T32, T33, T34, T35, T36,
                          T16, T17, T18, T19, T20, T21, T22,
                          T23, T24, T25, T26, T27, T28, T29,
                          T30, T31, T32, T33, T34, T35, T36,
index 9576dbb..3f499a4 100644 (file)
@@ -24,8 +24,7 @@
 
 #include <cstring>
 
 
 #include <cstring>
 
-namespace DPL
-{
+namespace DPL {
 template<typename TargetType, typename SourceType>
 TargetType union_cast(const SourceType &data)
 {
 template<typename TargetType, typename SourceType>
 TargetType union_cast(const SourceType &data)
 {
index 18729db..2cbf133 100644 (file)
@@ -17,7 +17,8 @@
  * @file        unused.h
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version     1.0
  * @file        unused.h
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of unused attribute from gcc
+ * @brief       This file is the implementation file of unused attribute from
+ * gcc
  */
 #ifndef DPL_UNUSED_H
 #define DPL_UNUSED_H
  */
 #ifndef DPL_UNUSED_H
 #define DPL_UNUSED_H
index ee53dfc..364bc5c 100644 (file)
 #include <dpl/exception.h>
 #include <vector>
 
 #include <dpl/exception.h>
 #include <vector>
 
-namespace DPL
+namespace DPL {
+class WaitableEvent :
+    private Noncopyable
 {
 {
-
-class WaitableEvent
-    : private Noncopyable
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, DestroyFailed)
@@ -44,10 +42,10 @@ public:
         DECLARE_EXCEPTION_TYPE(Base, ResetFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(Base, ResetFailed)
     };
 
-private:
+  private:
     int m_pipe[2];
 
     int m_pipe[2];
 
-public:
+  public:
     WaitableEvent();
     virtual ~WaitableEvent();
 
     WaitableEvent();
     virtual ~WaitableEvent();
 
@@ -56,7 +54,6 @@ public:
     void Signal() const;
     void Reset() const;
 };
     void Signal() const;
     void Reset() const;
 };
-
 } // namespace DPL
 
 #endif // DPL_WAITABLE_EVENT_H
 } // namespace DPL
 
 #endif // DPL_WAITABLE_EVENT_H
index 865cca4..9864f78 100644 (file)
@@ -26,9 +26,7 @@
 #include <dpl/exception.h>
 #include <vector>
 
 #include <dpl/exception.h>
 #include <vector>
 
-namespace DPL
-{
-
+namespace DPL {
 /**
  * Waitable unix wait handle definition
  */
 /**
  * Waitable unix wait handle definition
  */
@@ -44,7 +42,7 @@ typedef std::vector<WaitableHandle> WaitableHandleList;
  */
 class WaitMode
 {
  */
 class WaitMode
 {
-public:
+  public:
     enum Type
     {
         Read,  ///< Wait for readability state changes
     enum Type
     {
         Read,  ///< Wait for readability state changes
@@ -55,7 +53,8 @@ public:
 /**
  * Waitable handle list ex
  */
 /**
  * Waitable handle list ex
  */
-typedef std::vector<std::pair<WaitableHandle, WaitMode::Type> > WaitableHandleListEx;
+typedef std::vector<std::pair<WaitableHandle,
+                              WaitMode::Type> > WaitableHandleListEx;
 
 /**
  * Waitable handle index list
 
 /**
  * Waitable handle index list
@@ -74,7 +73,10 @@ DECLARE_EXCEPTION_TYPE(DPL::Exception, WaitFailed)
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
-WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle, unsigned long miliseconds = 0xFFFFFFFF);
+WaitableHandleIndexList WaitForSingleHandle(
+    WaitableHandle handle,
+    unsigned long miliseconds =
+        0xFFFFFFFF);
 
 /**
  * Wait for single handle
 
 /**
  * Wait for single handle
@@ -83,7 +85,11 @@ WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle, unsigned long
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
-WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle, WaitMode::Type mode, unsigned long miliseconds = 0xFFFFFFFF);
+WaitableHandleIndexList WaitForSingleHandle(
+    WaitableHandle handle,
+    WaitMode::Type mode,
+    unsigned long miliseconds =
+        0xFFFFFFFF);
 
 /**
  * Wait for multiple handles readability
 
 /**
  * Wait for multiple handles readability
@@ -91,7 +97,9 @@ WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle, WaitMode::Typ
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
-WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleList &handleList, unsigned long miliseconds = 0xFFFFFFFF);
+WaitableHandleIndexList WaitForMultipleHandles(
+    const WaitableHandleList &handleList,
+    unsigned long miliseconds = 0xFFFFFFFF);
 
 /**
  * Wait for multiple handles readability
 
 /**
  * Wait for multiple handles readability
@@ -99,8 +107,9 @@ WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleList &handleL
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
  * @return Signaled waitable handle index list
  * @throw WaitFailed Fatal error occurred while waiting for signal
  */
-WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleListEx &handleListEx, unsigned long miliseconds = 0xFFFFFFFF);
-
+WaitableHandleIndexList WaitForMultipleHandles(
+    const WaitableHandleListEx &handleListEx,
+    unsigned long miliseconds = 0xFFFFFFFF);
 } // namespace DPL
 
 #endif // DPL_WAITABLE_HANDLE_H
 } // namespace DPL
 
 #endif // DPL_WAITABLE_HANDLE_H
index 0ff29b1..ac0987f 100644 (file)
@@ -17,7 +17,8 @@
  * @file        waitable_handle_watch_support.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        waitable_handle_watch_support.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of waitable handle watch support
+ * @brief       This file is the implementation file of waitable handle watch
+ * support
  */
 #ifndef DPL_WAITABLE_HANDLE_WATCH_SUPPORT_H
 #define DPL_WAITABLE_HANDLE_WATCH_SUPPORT_H
  */
 #ifndef DPL_WAITABLE_HANDLE_WATCH_SUPPORT_H
 #define DPL_WAITABLE_HANDLE_WATCH_SUPPORT_H
 #include <list>
 #include <map>
 
 #include <list>
 #include <map>
 
-namespace DPL
-{
-
+namespace DPL {
 class Thread;
 
 class WaitableHandleWatchSupport
 {
 class Thread;
 
 class WaitableHandleWatchSupport
 {
-public:
+  public:
     class WaitableHandleListener
     {
     class WaitableHandleListener
     {
-    public:
+      public:
         virtual ~WaitableHandleListener() {}
 
         virtual ~WaitableHandleListener() {}
 
-        virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle, WaitMode::Type mode) = 0;
+        virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle,
+                                           WaitMode::Type mode) = 0;
     };
 
     };
 
-protected:
+  protected:
     // Invoker waitable handle
     // Signaled by Add/Remove methods
     // After being signaled one must call Handle invoke to reset invoker
     // Invoker waitable handle
     // Signaled by Add/Remove methods
     // After being signaled one must call Handle invoke to reset invoker
@@ -67,18 +67,17 @@ protected:
     // Invoke direct invoker
     virtual void HandleDirectInvoker() = 0;
 
     // Invoke direct invoker
     virtual void HandleDirectInvoker() = 0;
 
-private:
+  private:
     // Waitable event watchers
     struct WaitableHandleWatcher
     {
         WaitableHandleListener *listener;
         WaitMode::Type mode;
 
     // Waitable event watchers
     struct WaitableHandleWatcher
     {
         WaitableHandleListener *listener;
         WaitMode::Type mode;
 
-        WaitableHandleWatcher(WaitableHandleListener *l, WaitMode::Type m)
-            : listener(l),
-              mode(m)
-        {
-        }
+        WaitableHandleWatcher(WaitableHandleListener *l, WaitMode::Type m) :
+            listener(l),
+            mode(m)
+        {}
     };
 
     typedef std::list<WaitableHandleWatcher> WaitableHandleListenerList;
     };
 
     typedef std::list<WaitableHandleWatcher> WaitableHandleListenerList;
@@ -89,14 +88,14 @@ private:
         size_t readListenersCount;
         size_t writeListenersCount;
 
         size_t readListenersCount;
         size_t writeListenersCount;
 
-        WaitableHandleWatchers()
-            : readListenersCount(0),
-              writeListenersCount(0)
-        {
-        }
+        WaitableHandleWatchers() :
+            readListenersCount(0),
+            writeListenersCount(0)
+        {}
     };
 
     };
 
-    typedef std::map<WaitableHandle, WaitableHandleWatchers> WaitableHandleWatchersMap;
+    typedef std::map<WaitableHandle,
+                     WaitableHandleWatchers> WaitableHandleWatchersMap;
 
     // Waitable event watch support
     mutable RecursiveMutex m_watchersMutex;
 
     // Waitable event watch support
     mutable RecursiveMutex m_watchersMutex;
@@ -107,7 +106,7 @@ private:
     // Invoke call
     void CommitInvoker();
 
     // Invoke call
     void CommitInvoker();
 
-public:
+  public:
     /**
      * Constructor
      */
     /**
      * Constructor
      */
@@ -127,7 +126,9 @@ public:
      * @return none
      * @see WaitMode::Type
      */
      * @return none
      * @see WaitMode::Type
      */
-    void AddWaitableHandleWatch(WaitableHandleListener *listener, WaitableHandle waitableHandle, WaitMode::Type mode);
+    void AddWaitableHandleWatch(WaitableHandleListener *listener,
+                                WaitableHandle waitableHandle,
+                                WaitMode::Type mode);
 
     /**
      * Remove listener for specific waitable event
 
     /**
      * Remove listener for specific waitable event
@@ -138,7 +139,9 @@ public:
      * @return none
      * @see WaitMode::Type
      */
      * @return none
      * @see WaitMode::Type
      */
-    void RemoveWaitableHandleWatch(WaitableHandleListener *listener, WaitableHandle waitableHandle, WaitMode::Type mode);
+    void RemoveWaitableHandleWatch(WaitableHandleListener *listener,
+                                   WaitableHandle waitableHandle,
+                                   WaitMode::Type mode);
 
     /**
      * Retrieve inherited context
 
     /**
      * Retrieve inherited context
@@ -147,7 +150,6 @@ public:
      */
     static WaitableHandleWatchSupport *InheritedContext();
 };
      */
     static WaitableHandleWatchSupport *InheritedContext();
 };
-
 } // namespace DPL
 
 #endif // DPL_WAITABLE_HANDLE_WATCH_SUPPORT_H
 } // namespace DPL
 
 #endif // DPL_WAITABLE_HANDLE_WATCH_SUPPORT_H
index f4b8e34..1363fac 100644 (file)
 #include <vector>
 #include <string>
 
 #include <vector>
 #include <string>
 
-namespace DPL
+namespace DPL {
+class ZipInput :
+    private Noncopyable
 {
 {
-class ZipInput
-    : private Noncopyable
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, ReadGlobalInfoFailed)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, ReadGlobalInfoFailed)
@@ -50,41 +49,6 @@ public:
 
     typedef std::pair<size_t, size_t> FileHandle;
 
 
     typedef std::pair<size_t, size_t> FileHandle;
 
-    struct FileDateTime
-    {
-        unsigned int second; //< seconds after the minute - [0,59]
-        unsigned int minute; //< minutes after the hour - [0,59]
-        unsigned int hour;   //< hours since midnight - [0,23]
-        unsigned int day;    //< day of the month - [1,31]
-        unsigned int month;  //< months since January - [0,11]
-        unsigned int year;   //< years - [1980..2044]
-
-        FileDateTime()
-            :   second(0),
-                minute(0),
-                hour(0),
-                day(0),
-                month(0),
-                year(0)
-        {
-        }
-
-        FileDateTime(unsigned int secondArg,
-                     unsigned int minuteArg,
-                     unsigned int hourArg,
-                     unsigned int dayArg,
-                     unsigned int monthArg,
-                     unsigned int yearArg)
-            :   second(secondArg),
-                minute(minuteArg),
-                hour(hourArg),
-                day(dayArg),
-                month(monthArg),
-                year(yearArg)
-        {
-        }
-    };
-
     struct FileInfo
     {
         // File handle
     struct FileInfo
     {
         // File handle
@@ -95,90 +59,47 @@ public:
         std::string comment;
 
         // File information
         std::string comment;
 
         // File information
-        unsigned long version;                //< version made by
-        unsigned long versionNeeded;          //< version needed to extract
-        unsigned long flag;                   //< general purpose bit flag
-        unsigned long compressionMethod;      //< compression method
-        unsigned long dosDate;                //< last mod file date in Dos fmt
-        unsigned long crc;                    //< crc-32
-        off64_t       compressedSize;         //< compressed size
-        off64_t       uncompressedSize;       //< uncompressed size
-        unsigned long diskNumberStart;        //< disk number start
-        unsigned long internalFileAttributes; //< internal file attributes
-        unsigned long externalFileAttributes; //< external file attributes
-
-        FileDateTime dateTime;
-
-        FileInfo()
-            : handle(),
-              name(),
-              comment(),
-              version(0),
-              versionNeeded(0),
-              flag(0),
-              compressionMethod(0),
-              dosDate(0),
-              crc(0),
-              compressedSize(0),
-              uncompressedSize(0),
-              diskNumberStart(0),
-              internalFileAttributes(0),
-              externalFileAttributes(0),
-              dateTime()
-        {
-        }
+        off64_t compressedSize;               //< compressed size
+        off64_t uncompressedSize;             //< uncompressed size
+
+        FileInfo() :
+            handle(),
+            name(),
+            comment(),
+            compressedSize(0),
+            uncompressedSize(0)
+        {}
 
         FileInfo(const FileHandle &handleArg,
                  const std::string &nameArg,
                  const std::string &commentArg,
 
         FileInfo(const FileHandle &handleArg,
                  const std::string &nameArg,
                  const std::string &commentArg,
-                 unsigned long versionArg,
-                 unsigned long versionNeededArg,
-                 unsigned long flagArg,
-                 unsigned long compressionMethodArg,
-                 unsigned long dosDateArg,
-                 unsigned long crcArg,
                  const off64_t &compressedSizeArg,
                  const off64_t &compressedSizeArg,
-                 const off64_t &uncompressedSizeArg,
-                 unsigned long diskNumberStartArg,
-                 unsigned long internalFileAttributesArg,
-                 unsigned long externalFileAttributesArg,
-                 const FileDateTime &dateTimeArg)
-            : handle(handleArg),
-              name(nameArg),
-              comment(commentArg),
-              version(versionArg),
-              versionNeeded(versionNeededArg),
-              flag(flagArg),
-              compressionMethod(compressionMethodArg),
-              dosDate(dosDateArg),
-              crc(crcArg),
-              compressedSize(compressedSizeArg),
-              uncompressedSize(uncompressedSizeArg),
-              diskNumberStart(diskNumberStartArg),
-              internalFileAttributes(internalFileAttributesArg),
-              externalFileAttributes(externalFileAttributesArg),
-              dateTime(dateTimeArg)
-        {
-        }
+                 const off64_t &uncompressedSizeArg) :
+            handle(handleArg),
+            name(nameArg),
+            comment(commentArg),
+            compressedSize(compressedSizeArg),
+            uncompressedSize(uncompressedSizeArg)
+        {}
     };
 
     };
 
-    class File
-        public DPL::AbstractInput
+    class File :
+        public DPL::AbstractInput
     {
     {
-    private:
+      private:
         void *m_file;
 
         friend class ZipInput;
         File(class Device *device, FileHandle handle);
 
         void *m_file;
 
         friend class ZipInput;
         File(class Device *device, FileHandle handle);
 
-    public:
+      public:
         ~File();
 
         virtual DPL::BinaryQueueAutoPtr Read(size_t size);
     };
 
         ~File();
 
         virtual DPL::BinaryQueueAutoPtr Read(size_t size);
     };
 
-private:
-    class Device *m_device;
+  private:
+    class Device * m_device;
     void *m_masterFile;
 
     size_t m_numberOfFiles;
     void *m_masterFile;
 
     size_t m_numberOfFiles;
@@ -193,12 +114,12 @@ private:
     void ReadGlobalComment(void *masterFile);
     void ReadInfos(void *masterFile);
 
     void ReadGlobalComment(void *masterFile);
     void ReadInfos(void *masterFile);
 
-public:
+  public:
     typedef FileInfoList::const_iterator const_iterator;
     typedef FileInfoList::const_reverse_iterator const_reverse_iterator;
     typedef FileInfoList::size_type size_type;
 
     typedef FileInfoList::const_iterator const_iterator;
     typedef FileInfoList::const_reverse_iterator const_reverse_iterator;
     typedef FileInfoList::size_type size_type;
 
-public:
+  public:
     /**
      * Open zip file from file
      */
     /**
      * Open zip file from file
      */
@@ -221,17 +142,6 @@ public:
     bool empty() const;
 
     /**
     bool empty() const;
 
     /**
-     * Open a binary file for given file handle
-     *
-     * @return file object
-     * @param[in] handle Zip file handle to open
-     * @exception std::bad_alloc Cannot allocate memory to hold additional data
-     * @exception SteamOpenFailed Cannot find file with given handle
-     * @see BinaryQueue::BufferDeleterFree
-     */
-    File *OpenFile(FileHandle handle);
-
-    /**
      * Open a binary file for given file name
      *
      * @return file object
      * Open a binary file for given file name
      *
      * @return file object
index e7964ea..a802a7f 100644 (file)
  * @file        abstract_waitable_input_adapter.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        abstract_waitable_input_adapter.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of abstract waitable input adapter
+ * @brief       This file is the implementation file of abstract waitable input
+ * adapter
  */
  */
+#include <stddef.h>
 #include <dpl/abstract_waitable_input_adapter.h>
 
 #include <dpl/abstract_waitable_input_adapter.h>
 
-namespace DPL
-{
-
+namespace DPL {
 AbstractWaitableInputAdapter::AbstractWaitableInputAdapter(AbstractInput *input)
 AbstractWaitableInputAdapter::AbstractWaitableInputAdapter(AbstractInput *input)
-    : m_input(input)
+    :
+    m_input(input)
 {
     m_waitableEvent.Signal();
 }
 {
     m_waitableEvent.Signal();
 }
@@ -39,5 +40,4 @@ WaitableHandle AbstractWaitableInputAdapter::WaitableReadHandle() const
 {
     return m_waitableEvent.GetHandle();
 }
 {
     return m_waitableEvent.GetHandle();
 }
-
 } // namespace DPL
 } // namespace DPL
index d07737b..e432b31 100644 (file)
  * @file        abstract_waitable_input_output_adapter.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        abstract_waitable_input_output_adapter.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of abstract waitable input output adapter
+ * @brief       This file is the implementation file of abstract waitable input
+ * output adapter
  */
  */
+#include <stddef.h>
 #include <dpl/abstract_waitable_input_output_adapter.h>
 
 #include <dpl/abstract_waitable_input_output_adapter.h>
 
-namespace DPL
-{
-
-AbstractWaitableInputOutputAdapter::AbstractWaitableInputOutputAdapter(AbstractInputOutput *inputOutput)
-    : AbstractWaitableInputAdapter(inputOutput),
-      AbstractWaitableOutputAdapter(inputOutput)
-{
-}
-
+namespace DPL {
+AbstractWaitableInputOutputAdapter::AbstractWaitableInputOutputAdapter(
+    AbstractInputOutput *inputOutput) :
+    AbstractWaitableInputAdapter(inputOutput),
+    AbstractWaitableOutputAdapter(inputOutput)
+{}
 } // namespace DPL
 } // namespace DPL
index f849579..82c2347 100644 (file)
  * @file        abstract_waitable_output_adapter.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        abstract_waitable_output_adapter.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of abstract waitable output adapter
+ * @brief       This file is the implementation file of abstract waitable output
+ * adapter
  */
  */
+#include <stddef.h>
 #include <dpl/abstract_waitable_output_adapter.h>
 
 #include <dpl/abstract_waitable_output_adapter.h>
 
-namespace DPL
-{
-
-AbstractWaitableOutputAdapter::AbstractWaitableOutputAdapter(AbstractOutput *output)
-    : m_output(output)
+namespace DPL {
+AbstractWaitableOutputAdapter::AbstractWaitableOutputAdapter(
+    AbstractOutput *output) :
+    m_output(output)
 {
     m_waitableEvent.Signal();
 }
 
 {
     m_waitableEvent.Signal();
 }
 
-size_t AbstractWaitableOutputAdapter::Write(const BinaryQueue &buffer, size_t bufferSize)
+size_t AbstractWaitableOutputAdapter::Write(const BinaryQueue &buffer,
+                                            size_t bufferSize)
 {
     return m_output->Write(buffer, bufferSize);
 }
 {
     return m_output->Write(buffer, bufferSize);
 }
@@ -39,5 +41,4 @@ WaitableHandle AbstractWaitableOutputAdapter::WaitableWriteHandle() const
 {
     return m_waitableEvent.GetHandle();
 }
 {
     return m_waitableEvent.GetHandle();
 }
-
 } // namespace DPL
 } // namespace DPL
index 624fe7e..34c8861 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of address
  */
  * @version     1.0
  * @brief       This file is the implementation file of address
  */
+#include <stddef.h>
 #include <dpl/address.h>
 #include <sstream>
 #include <dpl/assert.h>
 
 #include <dpl/address.h>
 #include <sstream>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-Address::Address()
-    : m_port(0)
-{
-}
+namespace DPL {
+Address::Address() :
+    m_port(0)
+{}
 
 
-Address::Address(const std::string &address)
-    : m_address(address),
-      m_port(0)
-{
-}
+Address::Address(const std::string &address) :
+    m_address(address),
+    m_port(0)
+{}
 
 
-Address::Address(const std::string &address, unsigned short port)
-    : m_address(address),
-      m_port(port)
-{
-}
+Address::Address(const std::string &address, unsigned short port) :
+    m_address(address),
+    m_port(port)
+{}
 
 Address::~Address()
 
 Address::~Address()
-{
-}
+{}
 
 std::string Address::GetAddress() const
 {
 
 std::string Address::GetAddress() const
 {
@@ -67,5 +63,4 @@ bool Address::operator<(const Address &addr) const
 {
     return ToString() < addr.ToString();
 }
 {
     return ToString() < addr.ToString();
 }
-
 } // namespace DPL
 } // namespace DPL
index f4a2147..b2c9cc0 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of MVC application support
  */
  * @version     1.0
  * @brief       This file is the implementation file of MVC application support
  */
+#include <stddef.h>
 #include <dpl/application.h>
 #include <dpl/log/log.h>
 
 #include <dpl/application.h>
 #include <dpl/log/log.h>
 
@@ -27,53 +28,54 @@ namespace // anonymous
 static DPL::Application *g_application = NULL;
 } // namespace anonymous
 
 static DPL::Application *g_application = NULL;
 } // namespace anonymous
 
-namespace DPL
-{
+namespace DPL {
 int Application::app_create(void *data)
 {
 int Application::app_create(void *data)
 {
-    Application *This=static_cast<Application *>(data);
+    Application *This = static_cast<Application *>(data);
     This->OnCreate();
     return 0;
 }
 
 int Application::app_terminate(void *data)
 {
     This->OnCreate();
     return 0;
 }
 
 int Application::app_terminate(void *data)
 {
-    Application *This=static_cast<Application *>(data);
+    Application *This = static_cast<Application *>(data);
     This->OnTerminate();
     return 0;
 }
 
 int Application::app_pause(void *data)
 {
     This->OnTerminate();
     return 0;
 }
 
 int Application::app_pause(void *data)
 {
-    Application *This=static_cast<Application *>(data);
+    Application *This = static_cast<Application *>(data);
     This->OnPause();
     return 0;
 }
 
 int Application::app_resume(void *data)
 {
     This->OnPause();
     return 0;
 }
 
 int Application::app_resume(void *data)
 {
-    Application *This=static_cast<Application *>(data);
+    Application *This = static_cast<Application *>(data);
     This->OnResume();
     return 0;
 }
 
 int Application::app_reset(bundle *b, void *data)
 {
     This->OnResume();
     return 0;
 }
 
 int Application::app_reset(bundle *b, void *data)
 {
-    Application *This=static_cast<Application *>(data);
+    Application *This = static_cast<Application *>(data);
     This->OnReset(b);
     return 0;
 }
 
 Application::Application(int argc, char** argv,
                          const std::string& applicationName,
     This->OnReset(b);
     return 0;
 }
 
 Application::Application(int argc, char** argv,
                          const std::string& applicationName,
-                         bool showMainWindow)
-    : m_argc(argc),
-      m_argv(argv),
-      m_applicationName(applicationName),
-      m_mainWindowVisible(showMainWindow)
-{
-    if (g_application != NULL)
-        ThrowMsg(Exception::TooManyInstances, "Only single instance of Application allowed at one time!");
+                         bool showMainWindow) :
+    m_argc(argc),
+    m_argv(argv),
+    m_applicationName(applicationName),
+    m_mainWindowVisible(showMainWindow)
+{
+    if (g_application != NULL) {
+        ThrowMsg(Exception::TooManyInstances,
+                 "Only single instance of Application allowed at one time!");
+    }
 
     g_application = this;
 }
 
     g_application = this;
 }
@@ -93,9 +95,10 @@ int Application::Exec()
     ops.pause = app_pause;
     ops.resume = app_resume;
     ops.reset = app_reset;
     ops.pause = app_pause;
     ops.resume = app_resume;
     ops.reset = app_reset;
-    ops.data=this;
+    ops.data = this;
 
 
-    int result = appcore_efl_main(m_applicationName.c_str(), &m_argc, &m_argv, &ops);
+    int result = appcore_efl_main(
+            m_applicationName.c_str(), &m_argc, &m_argv, &ops);
 
     LogPedantic("Exited application framework");
 
 
     LogPedantic("Exited application framework");
 
@@ -165,23 +168,21 @@ void Application::Quit()
 
 DPL::Atomic ApplicationExt::m_useCount(0);
 
 
 DPL::Atomic ApplicationExt::m_useCount(0);
 
-ApplicationExt::ApplicationExt(int argc, char** argv, const std::string& applicationName, bool showMainWindow) :
+ApplicationExt::ApplicationExt(int argc,
+                               char** argv,
+                               const std::string& applicationName,
+                               bool showMainWindow) :
     Application(argc, argv, applicationName, showMainWindow)
     Application(argc, argv, applicationName, showMainWindow)
-{
-}
+{}
 
 ApplicationExt::~ApplicationExt()
 
 ApplicationExt::~ApplicationExt()
-{
-}
+{}
 
 int ApplicationExt::Exec()
 {
 
 int ApplicationExt::Exec()
 {
-    if (0 == m_useCount.CompareAndExchange(0, 1))
-    {
+    if (0 == m_useCount.CompareAndExchange(0, 1)) {
         return Application::Exec();
         return Application::Exec();
-    }
-    else
-    {
+    } else {
         elm_run();
     }
     return 0;
         elm_run();
     }
     return 0;
index d299b57..7ba5180 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of apply functionality
  */
  * @version     1.0
  * @brief       This file is the implementation file of apply functionality
  */
+#include <stddef.h>
 #include <dpl/apply.h>
 
 //
 #include <dpl/apply.h>
 
 //
index 9a363dc..b8a12c8 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of assert
  */
  * @version     1.0
  * @brief       This file is the implementation file of assert
  */
+#include <stddef.h>
 #include <dpl/assert.h>
 #include <dpl/colors.h>
 #include <dpl/log/log.h>
 #include <cstdlib>
 
 #include <dpl/assert.h>
 #include <dpl/colors.h>
 #include <dpl/log/log.h>
 #include <cstdlib>
 
-namespace DPL
-{
-void AssertProc(const char *condition, const char *file, int line, const char *function)
+namespace DPL {
+void AssertProc(const char *condition,
+                const char *file,
+                int line,
+                const char *function)
 {
 #define INTERNAL_LOG(message)                                          \
     do                                                                 \
 {
 #define INTERNAL_LOG(message)                                          \
     do                                                                 \
@@ -36,22 +39,25 @@ void AssertProc(const char *condition, const char *file, int line, const char *f
         DPL::Log::LogSystemSingleton::Instance().Pedantic(             \
             platformLog.str().c_str(),                                 \
             __FILE__, __LINE__, __FUNCTION__);                         \
         DPL::Log::LogSystemSingleton::Instance().Pedantic(             \
             platformLog.str().c_str(),                                 \
             __FILE__, __LINE__, __FUNCTION__);                         \
-    } while (0)
+    } \
+    while (0)
 
     // Try to log failed assertion to log system
     Try
     {
 
     // Try to log failed assertion to log system
     Try
     {
-        INTERNAL_LOG("################################################################################");
-        INTERNAL_LOG("###                          DPL assertion failed!                           ###");
-        INTERNAL_LOG("################################################################################");
+        INTERNAL_LOG(
+            "################################################################################");
+        INTERNAL_LOG(
+            "###                          DPL assertion failed!                           ###");
+        INTERNAL_LOG(
+            "################################################################################");
         INTERNAL_LOG("### Condition: " << condition);
         INTERNAL_LOG("### File: " << file);
         INTERNAL_LOG("### Line: " << line);
         INTERNAL_LOG("### Function: " << function);
         INTERNAL_LOG("### Condition: " << condition);
         INTERNAL_LOG("### File: " << file);
         INTERNAL_LOG("### Line: " << line);
         INTERNAL_LOG("### Function: " << function);
-        INTERNAL_LOG("################################################################################");
-    }
-    catch (Exception)
-    {
+        INTERNAL_LOG(
+            "################################################################################");
+    } catch (Exception) {
         // Just ignore possible double errors
     }
 
         // Just ignore possible double errors
     }
 
index 65af06e..2f50074 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of atomic
  */
  * @version     1.0
  * @brief       This file is the implementation file of atomic
  */
+#include <stddef.h>
 #include <dpl/atomic.h>
 
 #include <dpl/atomic.h>
 
-namespace DPL
-{
-Atomic::Atomic(ValueType value)
-    : m_value(value)
-{
-}
+namespace DPL {
+Atomic::Atomic(ValueType value) :
+    m_value(value)
+{}
 
 Atomic::ValueType Atomic::ExchangeAndAdd(ValueType value)
 {
 
 Atomic::ValueType Atomic::ExchangeAndAdd(ValueType value)
 {
-    return g_atomic_int_exchange_and_add(&m_value, value);
+    return g_atomic_int_add(const_cast<gint* >(&m_value), value);
 }
 
 bool Atomic::CompareAndExchange(ValueType oldValue, ValueType newValue)
 {
 }
 
 bool Atomic::CompareAndExchange(ValueType oldValue, ValueType newValue)
 {
-    return g_atomic_int_compare_and_exchange(&m_value, oldValue, newValue);
+    return g_atomic_int_compare_and_exchange(const_cast<gint* >(&m_value),
+                                             oldValue,
+                                             newValue);
 }
 
 bool Atomic::operator--()
 {
 }
 
 bool Atomic::operator--()
 {
-    return g_atomic_int_dec_and_test(&m_value) != TRUE;
+    return g_atomic_int_dec_and_test(const_cast<gint* >(&m_value)) != TRUE;
 }
 
 void Atomic::operator++()
 {
 }
 
 void Atomic::operator++()
 {
-    g_atomic_int_inc(&m_value);
+    g_atomic_int_inc(const_cast<gint* >(&m_value));
 }
 
 Atomic::operator ValueType() const
 {
 }
 
 Atomic::operator ValueType() const
 {
-    return g_atomic_int_get(&m_value);
+    return g_atomic_int_get(const_cast<gint* >(&m_value));
 }
 } // namespace DPL
 }
 } // namespace DPL
index 42b351e..2234c8f 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of binary queue
  */
  * @version     1.0
  * @brief       This file is the implementation file of binary queue
  */
+#include <stddef.h>
 #include <dpl/binary_queue.h>
 #include <dpl/assert.h>
 #include <dpl/scoped_free.h>
 #include <dpl/binary_queue.h>
 #include <dpl/assert.h>
 #include <dpl/scoped_free.h>
 #include <cstring>
 #include <new>
 
 #include <cstring>
 #include <new>
 
-namespace DPL
-{
-BinaryQueue::BinaryQueue()
-    : m_size(0)
-{
-}
+namespace DPL {
+BinaryQueue::BinaryQueue() :
+    m_size(0)
+{}
 
 
-BinaryQueue::BinaryQueue(const BinaryQueue &other)
-    m_size(0)
+BinaryQueue::BinaryQueue(const BinaryQueue &other) :
+    m_size(0)
 {
     AppendCopyFrom(other);
 }
 {
     AppendCopyFrom(other);
 }
@@ -48,8 +47,7 @@ BinaryQueue::~BinaryQueue()
 
 const BinaryQueue &BinaryQueue::operator=(const BinaryQueue &other)
 {
 
 const BinaryQueue &BinaryQueue::operator=(const BinaryQueue &other)
 {
-    if (this != &other)
-    {
+    if (this != &other) {
         Clear();
         AppendCopyFrom(other);
     }
         Clear();
         AppendCopyFrom(other);
     }
@@ -62,16 +60,14 @@ void BinaryQueue::AppendCopyFrom(const BinaryQueue &other)
     // To speed things up, always copy as one bucket
     void *bufferCopy = malloc(other.m_size);
 
     // To speed things up, always copy as one bucket
     void *bufferCopy = malloc(other.m_size);
 
-    if (bufferCopy == NULL)
+    if (bufferCopy == NULL) {
         throw std::bad_alloc();
         throw std::bad_alloc();
+    }
 
 
-    try
-    {
+    try {
         other.Flatten(bufferCopy, other.m_size);
         AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, NULL);
         other.Flatten(bufferCopy, other.m_size);
         AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, NULL);
-    }
-    catch (const std::bad_alloc &)
-    {
+    } catch (const std::bad_alloc &) {
         // Free allocated memory
         free(bufferCopy);
         throw;
         // Free allocated memory
         free(bufferCopy);
         throw;
@@ -81,7 +77,8 @@ void BinaryQueue::AppendCopyFrom(const BinaryQueue &other)
 void BinaryQueue::AppendMoveFrom(BinaryQueue &other)
 {
     // Copy all buckets
 void BinaryQueue::AppendMoveFrom(BinaryQueue &other)
 {
     // Copy all buckets
-    std::copy(other.m_buckets.begin(), other.m_buckets.end(), std::back_inserter(m_buckets));
+    std::copy(other.m_buckets.begin(),
+              other.m_buckets.end(), std::back_inserter(m_buckets));
     m_size += other.m_size;
 
     // Clear other, but do not free memory
     m_size += other.m_size;
 
     // Clear other, but do not free memory
@@ -112,30 +109,30 @@ void BinaryQueue::AppendCopy(const void* buffer, size_t bufferSize)
     void *bufferCopy = malloc(bufferSize);
 
     // Check if allocation succeded
     void *bufferCopy = malloc(bufferSize);
 
     // Check if allocation succeded
-    if (bufferCopy == NULL)
+    if (bufferCopy == NULL) {
         throw std::bad_alloc();
         throw std::bad_alloc();
+    }
 
     // Copy user data
     memcpy(bufferCopy, buffer, bufferSize);
 
 
     // Copy user data
     memcpy(bufferCopy, buffer, bufferSize);
 
-    try
-    {
+    try {
         // Try to append new bucket
         AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, NULL);
         // Try to append new bucket
         AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, NULL);
-    }
-    catch (const std::bad_alloc &)
-    {
+    } catch (const std::bad_alloc &) {
         // Free allocated memory
         free(bufferCopy);
         throw;
     }
 }
 
         // Free allocated memory
         free(bufferCopy);
         throw;
     }
 }
 
-void BinaryQueue::AppendUnmanaged(const void* buffer, size_t bufferSize, BufferDeleter deleter, void* userParam)
+void BinaryQueue::AppendUnmanaged(const void* buffer,
+                                  size_t bufferSize,
+                                  BufferDeleter deleter,
+                                  void* userParam)
 {
     // Do not attach empty buckets
 {
     // Do not attach empty buckets
-    if (bufferSize == 0)
-    {
+    if (bufferSize == 0) {
         deleter(buffer, bufferSize, userParam);
         return;
     }
         deleter(buffer, bufferSize, userParam);
         return;
     }
@@ -160,24 +157,24 @@ bool BinaryQueue::Empty() const
 void BinaryQueue::Consume(size_t size)
 {
     // Check parameters
 void BinaryQueue::Consume(size_t size)
 {
     // Check parameters
-    if (size > m_size)
+    if (size > m_size) {
         Throw(Exception::OutOfData);
         Throw(Exception::OutOfData);
+    }
 
     size_t bytesLeft = size;
 
     // Consume data and/or remove buckets
 
     size_t bytesLeft = size;
 
     // Consume data and/or remove buckets
-    while (bytesLeft > 0)
-    {
+    while (bytesLeft > 0) {
         // Get consume size
         size_t count = std::min(bytesLeft, m_buckets.front()->left);
 
         // Get consume size
         size_t count = std::min(bytesLeft, m_buckets.front()->left);
 
-        m_buckets.front()->ptr = static_cast<const char *>(m_buckets.front()->ptr) + count;
+        m_buckets.front()->ptr =
+            static_cast<const char *>(m_buckets.front()->ptr) + count;
         m_buckets.front()->left -= count;
         bytesLeft -= count;
         m_size -= count;
 
         m_buckets.front()->left -= count;
         bytesLeft -= count;
         m_size -= count;
 
-        if (m_buckets.front()->left == 0)
-        {
+        if (m_buckets.front()->left == 0) {
             DeleteBucket(m_buckets.front());
             m_buckets.pop_front();
         }
             DeleteBucket(m_buckets.front());
             m_buckets.pop_front();
         }
@@ -187,11 +184,13 @@ void BinaryQueue::Consume(size_t size)
 void BinaryQueue::Flatten(void *buffer, size_t bufferSize) const
 {
     // Check parameters
 void BinaryQueue::Flatten(void *buffer, size_t bufferSize) const
 {
     // Check parameters
-    if (bufferSize == 0)
+    if (bufferSize == 0) {
         return;
         return;
+    }
 
 
-    if (bufferSize > m_size)
+    if (bufferSize > m_size) {
         Throw(Exception::OutOfData);
         Throw(Exception::OutOfData);
+    }
 
     size_t bytesLeft = bufferSize;
     void *ptr = buffer;
 
     size_t bytesLeft = bufferSize;
     void *ptr = buffer;
@@ -199,8 +198,7 @@ void BinaryQueue::Flatten(void *buffer, size_t bufferSize) const
     Assert(m_buckets.end() != bucketIterator);
 
     // Flatten data
     Assert(m_buckets.end() != bucketIterator);
 
     // Flatten data
-    while (bytesLeft > 0)
-    {
+    while (bytesLeft > 0) {
         // Get consume size
         size_t count = std::min(bytesLeft, (*bucketIterator)->left);
 
         // Get consume size
         size_t count = std::min(bytesLeft, (*bucketIterator)->left);
 
@@ -228,7 +226,9 @@ void BinaryQueue::DeleteBucket(BinaryQueue::Bucket *bucket)
     delete bucket;
 }
 
     delete bucket;
 }
 
-void BinaryQueue::BufferDeleterFree(const void* data, size_t dataSize, void* userParam)
+void BinaryQueue::BufferDeleterFree(const void* data,
+                                    size_t dataSize,
+                                    void* userParam)
 {
     (void)dataSize;
     (void)userParam;
 {
     (void)dataSize;
     (void)userParam;
@@ -237,13 +237,16 @@ void BinaryQueue::BufferDeleterFree(const void* data, size_t dataSize, void* use
     free(const_cast<void *>(data));
 }
 
     free(const_cast<void *>(data));
 }
 
-BinaryQueue::Bucket::Bucket(const void* data, size_t dataSize, BufferDeleter dataDeleter, void* userParam)
-    : buffer(data),
-      ptr(data),
-      size(dataSize),
-      left(dataSize),
-      deleter(dataDeleter),
-      param(userParam)
+BinaryQueue::Bucket::Bucket(const void* data,
+                            size_t dataSize,
+                            BufferDeleter dataDeleter,
+                            void* userParam) :
+    buffer(data),
+    ptr(data),
+    size(dataSize),
+    left(dataSize),
+    deleter(dataDeleter),
+    param(userParam)
 {
     Assert(data != NULL);
     Assert(deleter != NULL);
 {
     Assert(data != NULL);
     Assert(deleter != NULL);
@@ -256,17 +259,14 @@ BinaryQueue::Bucket::~Bucket()
 }
 
 BinaryQueue::BucketVisitor::~BucketVisitor()
 }
 
 BinaryQueue::BucketVisitor::~BucketVisitor()
-{    
-}
+{}
 
 
-BinaryQueue::BucketVisitorCall::BucketVisitorCall(BucketVisitor *visitor)
-    : m_visitor(visitor)
-{
-}
+BinaryQueue::BucketVisitorCall::BucketVisitorCall(BucketVisitor *visitor) :
+    m_visitor(visitor)
+{}
 
 BinaryQueue::BucketVisitorCall::~BucketVisitorCall()
 
 BinaryQueue::BucketVisitorCall::~BucketVisitorCall()
-{
-}
+{}
 
 void BinaryQueue::BucketVisitorCall::operator()(Bucket *bucket) const
 {
 
 void BinaryQueue::BucketVisitorCall::operator()(Bucket *bucket) const
 {
@@ -288,13 +288,15 @@ BinaryQueueAutoPtr BinaryQueue::Read(size_t size)
 
     ScopedFree<void> bufferCopy(malloc(available));
 
 
     ScopedFree<void> bufferCopy(malloc(available));
 
-    if (!bufferCopy)
+    if (!bufferCopy) {
         throw std::bad_alloc();
         throw std::bad_alloc();
+    }
 
     BinaryQueueAutoPtr result(new BinaryQueue());
 
     Flatten(bufferCopy.Get(), available);
 
     BinaryQueueAutoPtr result(new BinaryQueue());
 
     Flatten(bufferCopy.Get(), available);
-    result->AppendUnmanaged(bufferCopy.Get(), available, &BufferDeleterFree, NULL);
+    result->AppendUnmanaged(
+        bufferCopy.Get(), available, &BufferDeleterFree, NULL);
     bufferCopy.Release();
     Consume(available);
 
     bufferCopy.Release();
     Consume(available);
 
index 13ea72e..32b9197 100644 (file)
  * @file        char_traits.cpp
  * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
  * @version     1.0
  * @file        char_traits.cpp
  * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
  * @version     1.0
- * @biref       Char traits are used to create basic_string extended with additional features
- *              Current char traits could be extended in feature to boost performance
+ * @biref       Char traits are used to create basic_string extended with
+ * additional features
+ *              Current char traits could be extended in feature to boost
+ * performance
  */
  */
+#include <stddef.h>
 #include <dpl/char_traits.h>
 
 //
 #include <dpl/char_traits.h>
 
 //
index 19e6d3a..0b2fcd4 100644 (file)
  * @brief       Some constants with definition of colors for Console
  *              and html output
  */
  * @brief       Some constants with definition of colors for Console
  *              and html output
  */
-
+#include <stddef.h>
 #include <dpl/colors.h>
 
 #include <dpl/colors.h>
 
-
-namespace DPL
-{
-
-namespace Colors
-{
-
-namespace Text
-{
-
+namespace DPL {
+namespace Colors {
+namespace Text {
 const char* BOLD_GREEN_BEGIN = "\033[1;32m";
 const char* BOLD_GREEN_END = "\033[m";
 const char* RED_BEGIN = "\033[0;31m";
 const char* BOLD_GREEN_BEGIN = "\033[1;32m";
 const char* BOLD_GREEN_END = "\033[m";
 const char* RED_BEGIN = "\033[0;31m";
@@ -51,12 +44,9 @@ const char* BOLD_GOLD_BEGIN = "\033[0;33m";
 const char* BOLD_GOLD_END = "\033[m";
 const char* BOLD_WHITE_BEGIN = "\033[1;37m";
 const char* BOLD_WHITE_END = "\033[m";
 const char* BOLD_GOLD_END = "\033[m";
 const char* BOLD_WHITE_BEGIN = "\033[1;37m";
 const char* BOLD_WHITE_END = "\033[m";
-
 } //namespace Text
 
 } //namespace Text
 
-namespace Html
-{
-
+namespace Html {
 const char* BOLD_GREEN_BEGIN = "<font color=\"green\"><b>";
 const char* BOLD_GREEN_END = "</b></font>";
 const char* PURPLE_BEGIN = "<font color=\"purple\"><b>";
 const char* BOLD_GREEN_BEGIN = "<font color=\"green\"><b>";
 const char* BOLD_GREEN_END = "</b></font>";
 const char* PURPLE_BEGIN = "<font color=\"purple\"><b>";
@@ -75,9 +65,6 @@ const char* BOLD_GOLD_BEGIN = "<font color=\"gold\"><b>";
 const char* BOLD_GOLD_END = "</b></font>";
 const char* BOLD_WHITE_BEGIN = "<font color=\"white\"><b>";
 const char* BOLD_WHITE_END = "</b></font>";
 const char* BOLD_GOLD_END = "</b></font>";
 const char* BOLD_WHITE_BEGIN = "<font color=\"white\"><b>";
 const char* BOLD_WHITE_END = "</b></font>";
-
 } //namespace Html
 } //namespace Html
-
 } //namespace Colors
 } //namespace Colors
-
 } //namespace DPL
 } //namespace DPL
index 465a9b9..c05d06c 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of copy
  */
  * @version     1.0
  * @brief       This file is the implementation file of copy
  */
+#include <stddef.h>
 #include <dpl/copy.h>
 #include <dpl/waitable_handle.h>
 #include <dpl/binary_queue.h>
 
 #include <dpl/copy.h>
 #include <dpl/waitable_handle.h>
 #include <dpl/binary_queue.h>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 const size_t DEFAULT_COPY_BUFFER_SIZE = 16768;
 namespace // anonymous
 {
 const size_t DEFAULT_COPY_BUFFER_SIZE = 16768;
@@ -34,39 +34,36 @@ void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output)
 {
     Try
     {
 {
     Try
     {
-        while (true)
-        {
+        while (true) {
             BinaryQueueAutoPtr buffer;
 
             BinaryQueueAutoPtr buffer;
 
-            while (true)
-            {
+            while (true) {
                 // Try to get data immediately
                 buffer = input->Read(DEFAULT_COPY_BUFFER_SIZE);
 
                 // Do we need to wait for data ?
                 // Try to get data immediately
                 buffer = input->Read(DEFAULT_COPY_BUFFER_SIZE);
 
                 // Do we need to wait for data ?
-                if (!buffer.get())
-                {
-                    WaitForSingleHandle(input->WaitableReadHandle(), WaitMode::Read);
+                if (!buffer.get()) {
+                    WaitForSingleHandle(
+                        input->WaitableReadHandle(), WaitMode::Read);
                     continue;
                 }
 
                     continue;
                 }
 
-                if (buffer->Empty())
+                if (buffer->Empty()) {
                     return; // Done
                     return; // Done
-
+                }
                 // Ok, to process
                 break;
             }
 
             // Write out all data
                 // Ok, to process
                 break;
             }
 
             // Write out all data
-            while (!buffer->Empty())
-            {
+            while (!buffer->Empty()) {
                 // Try to write all data immediately
                 size_t count = output->Write(*buffer, buffer->Size());
 
                 // Do we need to wait for writing data ?
                 // Try to write all data immediately
                 size_t count = output->Write(*buffer, buffer->Size());
 
                 // Do we need to wait for writing data ?
-                if (count == 0)
-                {
-                    WaitForSingleHandle(output->WaitableWriteHandle(), WaitMode::Write);
+                if (count == 0) {
+                    WaitForSingleHandle(
+                        output->WaitableWriteHandle(), WaitMode::Write);
                     continue;
                 }
 
                     continue;
                 }
 
@@ -75,54 +72,55 @@ void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output)
             }
         }
     }
             }
         }
     }
-    Catch (DPL::Exception)
+    Catch(DPL::Exception)
     {
         ReThrow(CopyFailed);
     }
 }
 
     {
         ReThrow(CopyFailed);
     }
 }
 
-void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output, size_t totalBytes)
+void Copy(AbstractWaitableInput *input,
+          AbstractWaitableOutput *output,
+          size_t totalBytes)
 {
     Try
     {
         size_t bytesLeft = totalBytes;
 
 {
     Try
     {
         size_t bytesLeft = totalBytes;
 
-        while (bytesLeft > 0)
-        {
+        while (bytesLeft > 0) {
             BinaryQueueAutoPtr buffer;
 
             // Copy at most left bytes
             BinaryQueueAutoPtr buffer;
 
             // Copy at most left bytes
-            size_t bytesToCopy = bytesLeft > DEFAULT_COPY_BUFFER_SIZE ? DEFAULT_COPY_BUFFER_SIZE : bytesLeft;
+            size_t bytesToCopy = bytesLeft >
+                DEFAULT_COPY_BUFFER_SIZE ? DEFAULT_COPY_BUFFER_SIZE : bytesLeft;
 
 
-            while (true)
-            {
+            while (true) {
                 // Try to get data immediately
                 buffer = input->Read(bytesToCopy);
 
                 // Do we need to wait for data ?
                 // Try to get data immediately
                 buffer = input->Read(bytesToCopy);
 
                 // Do we need to wait for data ?
-                if (!buffer.get())
-                {
-                    WaitForSingleHandle(input->WaitableReadHandle(), WaitMode::Read);
+                if (!buffer.get()) {
+                    WaitForSingleHandle(
+                        input->WaitableReadHandle(), WaitMode::Read);
                     continue;
                 }
 
                     continue;
                 }
 
-                if (buffer->Empty())
+                if (buffer->Empty()) {
                     ThrowMsg(CopyFailed, "Unexpected end of abstract input");
                     ThrowMsg(CopyFailed, "Unexpected end of abstract input");
+                }
 
                 // Ok, to process
                 break;
             }
 
             // Write out all data
 
                 // Ok, to process
                 break;
             }
 
             // Write out all data
-            while (!buffer->Empty())
-            {
+            while (!buffer->Empty()) {
                 // Try to write all data immediately
                 size_t count = output->Write(*buffer, buffer->Size());
 
                 // Do we need to wait for writing data ?
                 // Try to write all data immediately
                 size_t count = output->Write(*buffer, buffer->Size());
 
                 // Do we need to wait for writing data ?
-                if (count == 0)
-                {
-                    WaitForSingleHandle(output->WaitableWriteHandle(), WaitMode::Write);
+                if (count == 0) {
+                    WaitForSingleHandle(
+                        output->WaitableWriteHandle(), WaitMode::Write);
                     continue;
                 }
 
                     continue;
                 }
 
@@ -132,7 +130,7 @@ void Copy(AbstractWaitableInput *input, AbstractWaitableOutput *output, size_t t
             }
         }
     }
             }
         }
     }
-    Catch (DPL::Exception)
+    Catch(DPL::Exception)
     {
         ReThrow(CopyFailed);
     }
     {
         ReThrow(CopyFailed);
     }
index 1637d87..cb607f5 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of errno string
  */
  * @version     1.0
  * @brief       This file is the implementation file of errno string
  */
+#include <stddef.h>
 #include <dpl/errno_string.h>
 #include <dpl/assert.h>
 #include <dpl/exception.h>
 #include <dpl/errno_string.h>
 #include <dpl/assert.h>
 #include <dpl/exception.h>
@@ -31,8 +32,7 @@
 #include <cerrno>
 #include <stdexcept>
 
 #include <cerrno>
 #include <stdexcept>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 const size_t DEFAULT_ERRNO_STRING_SIZE = 32;
 namespace // anonymous
 {
 const size_t DEFAULT_ERRNO_STRING_SIZE = 32;
@@ -43,13 +43,11 @@ std::string GetErrnoString(int error)
     size_t size = DEFAULT_ERRNO_STRING_SIZE;
     char *buffer = NULL;
 
     size_t size = DEFAULT_ERRNO_STRING_SIZE;
     char *buffer = NULL;
 
-    for (;;)
-    {
+    for (;;) {
         // Add one extra characted for end of string null value
         char *newBuffer = static_cast<char *>(::realloc(buffer, size + 1));
 
         // Add one extra characted for end of string null value
         char *newBuffer = static_cast<char *>(::realloc(buffer, size + 1));
 
-        if (!newBuffer)
-        {
+        if (!newBuffer) {
             // Failed to realloc
             ::free(buffer);
             throw std::bad_alloc();
             // Failed to realloc
             ::free(buffer);
             throw std::bad_alloc();
@@ -60,12 +58,11 @@ std::string GetErrnoString(int error)
         ::memset(buffer, 0, size + 1);
 
         // Try to retrieve error string
         ::memset(buffer, 0, size + 1);
 
         // Try to retrieve error string
-#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
         // The XSI-compliant version of strerror_r() is provided if:
         int result = ::strerror_r(error, buffer, size);
 
         // The XSI-compliant version of strerror_r() is provided if:
         int result = ::strerror_r(error, buffer, size);
 
-        if (result == 0)
-        {
+        if (result == 0) {
             ScopedFree<char> scopedBufferFree(buffer);
             return std::string(buffer);
         }
             ScopedFree<char> scopedBufferFree(buffer);
             return std::string(buffer);
         }
@@ -75,19 +72,17 @@ std::string GetErrnoString(int error)
         // Otherwise, the GNU-specific version is provided.
         char *result = ::strerror_r(error, buffer, size);
 
         // Otherwise, the GNU-specific version is provided.
         char *result = ::strerror_r(error, buffer, size);
 
-        if (result != NULL)
-        {
+        if (result != NULL) {
             ScopedFree<char> scopedBufferFree(buffer);
             return std::string(result);
         }
 #endif
 
         // Interpret errors
             ScopedFree<char> scopedBufferFree(buffer);
             return std::string(result);
         }
 #endif
 
         // Interpret errors
-        switch (errno)
-        {
+        switch (errno) {
         case EINVAL:
             // We got an invalid errno value
         case EINVAL:
             // We got an invalid errno value
-            ::free(buffer);
+                ::free(buffer);
             ThrowMsg(InvalidErrnoValue, "Invalid errno value: " << error);
 
         case ERANGE:
             ThrowMsg(InvalidErrnoValue, "Invalid errno value: " << error);
 
         case ERANGE:
index 9d6de98..d3673e6 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation of exception system
  */
  * @version     1.0
  * @brief       This file is the implementation of exception system
  */
+#include <stddef.h>
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
 #include <cstdio>
 
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
 #include <cstdio>
 
-namespace DPL
-{
+namespace DPL {
 Exception* Exception::m_lastException = NULL;
 unsigned int Exception::m_exceptionCount = 0;
 void (*Exception::m_terminateHandler)() = NULL;
 Exception* Exception::m_lastException = NULL;
 unsigned int Exception::m_exceptionCount = 0;
 void (*Exception::m_terminateHandler)() = NULL;
@@ -38,15 +38,20 @@ void LogUnhandledException(const std::string &str)
     LogPedantic(str);
 }
 
     LogPedantic(str);
 }
 
-void LogUnhandledException(const std::string &str, const char *filename, int line, const char *function)
+void LogUnhandledException(const std::string &str,
+                           const char *filename,
+                           int line,
+                           const char *function)
 {
     // Logging to console
     std::ostringstream msg;
 {
     // Logging to console
     std::ostringstream msg;
-    msg << "\033[1;5;31m\n=== [" << filename << ":" << line << "] " << function << " ===\033[m";
+    msg << "\033[1;5;31m\n=== [" << filename << ":" << line << "] " <<
+    function << " ===\033[m";
     msg << str;
     printf("%s\n", msg.str().c_str());
 
     // Logging to dlog
     msg << str;
     printf("%s\n", msg.str().c_str());
 
     // Logging to dlog
-    DPL::Log::LogSystemSingleton::Instance().Error(str.c_str(), filename, line, function);
+    DPL::Log::LogSystemSingleton::Instance().Error(
+        str.c_str(), filename, line, function);
 }
 } // namespace DPL
 }
 } // namespace DPL
index 94b3ca3..70821b2 100644 (file)
@@ -19,4 +19,5 @@
  * @version     1.0
  * @brief       This file is the implementation file of fast delegate
  */
  * @version     1.0
  * @brief       This file is the implementation file of fast delegate
  */
+#include <stddef.h>
 #include <dpl/fast_delegate.h>
 #include <dpl/fast_delegate.h>
index 6e536db..36fb4b5 100644 (file)
  *    limitations under the License.
  */
 /*
  *    limitations under the License.
  */
 /*
- * @file        named_input_pipe.cpp
+ * @file        file_input.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @brief       This file is the implementation file of named input pipe
  */
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @brief       This file is the implementation file of named input pipe
  */
+#include <stddef.h>
 #include <dpl/file_input.h>
 #include <dpl/binary_queue.h>
 #include <dpl/log/log.h>
 #include <dpl/file_input.h>
 #include <dpl/binary_queue.h>
 #include <dpl/log/log.h>
 #include <fcntl.h>
 #include <errno.h>
 
 #include <fcntl.h>
 #include <errno.h>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 const size_t DEFAULT_READ_BUFFER_SIZE = 4096;
 } // namespace anonymous
 
 namespace // anonymous
 {
 const size_t DEFAULT_READ_BUFFER_SIZE = 4096;
 } // namespace anonymous
 
-FileInput::FileInput()
-    : m_fd(-1)
-{
-}
+FileInput::FileInput() :
+    m_fd(-1)
+{}
 
 
-FileInput::FileInput(const std::string& fileName)
-    m_fd(-1)
+FileInput::FileInput(const std::string& fileName) :
+    m_fd(-1)
 {
     Open(fileName);
 }
 {
     Open(fileName);
 }
@@ -56,8 +55,9 @@ void FileInput::Open(const std::string& fileName)
     int fd = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_RDONLY | O_NONBLOCK));
 
     // Throw an exception if an error occurred
     int fd = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_RDONLY | O_NONBLOCK));
 
     // Throw an exception if an error occurred
-    if (fd == -1)
+    if (fd == -1) {
         ThrowMsg(Exception::OpenFailed, fileName);
         ThrowMsg(Exception::OpenFailed, fileName);
+    }
 
     // Close if any existing
     Close();
 
     // Close if any existing
     Close();
@@ -70,11 +70,13 @@ void FileInput::Open(const std::string& fileName)
 
 void FileInput::Close()
 {
 
 void FileInput::Close()
 {
-    if (m_fd == -1)
+    if (m_fd == -1) {
         return;
         return;
+    }
 
 
-    if (TEMP_FAILURE_RETRY(close(m_fd)) == -1)
+    if (TEMP_FAILURE_RETRY(close(m_fd)) == -1) {
         Throw(Exception::CloseFailed);
         Throw(Exception::CloseFailed);
+    }
 
     m_fd = -1;
 
 
     m_fd = -1;
 
@@ -83,14 +85,16 @@ void FileInput::Close()
 
 BinaryQueueAutoPtr FileInput::Read(size_t size)
 {
 
 BinaryQueueAutoPtr FileInput::Read(size_t size)
 {
-    size_t bytesToRead = size > DEFAULT_READ_BUFFER_SIZE ? DEFAULT_READ_BUFFER_SIZE : size;
+    size_t bytesToRead = size >
+        DEFAULT_READ_BUFFER_SIZE ? DEFAULT_READ_BUFFER_SIZE : size;
 
     // Malloc default read buffer size
     // It is unmanaged, so it can be then attached directly to binary queue
     void *buffer = malloc(bytesToRead);
 
 
     // Malloc default read buffer size
     // It is unmanaged, so it can be then attached directly to binary queue
     void *buffer = malloc(bytesToRead);
 
-    if (buffer == NULL)
+    if (buffer == NULL) {
         throw std::bad_alloc();
         throw std::bad_alloc();
+    }
 
     LogPedantic("Trying to read " << bytesToRead << " bytes");
 
 
     LogPedantic("Trying to read " << bytesToRead << " bytes");
 
@@ -98,27 +102,25 @@ BinaryQueueAutoPtr FileInput::Read(size_t size)
 
     LogPedantic("Read " << result << " bytes from file");
 
 
     LogPedantic("Read " << result << " bytes from file");
 
-    if (result > 0)
-    {
+    if (result > 0) {
         // Succedded to read socket data
         BinaryQueueAutoPtr binaryQueue(new BinaryQueue());
 
         // Append unmanaged memory
         // Succedded to read socket data
         BinaryQueueAutoPtr binaryQueue(new BinaryQueue());
 
         // Append unmanaged memory
-        binaryQueue->AppendUnmanaged(buffer, result, &BinaryQueue::BufferDeleterFree, NULL);
+        binaryQueue->AppendUnmanaged(buffer,
+                                     result,
+                                     &BinaryQueue::BufferDeleterFree,
+                                     NULL);
 
         // Return buffer
         return binaryQueue;
 
         // Return buffer
         return binaryQueue;
-    }
-    else if (result == 0)
-    {
+    } else if (result == 0) {
         // Socket was gracefuly closed
         free(buffer);
 
         // Return empty buffer
         return BinaryQueueAutoPtr(new BinaryQueue());
         // Socket was gracefuly closed
         free(buffer);
 
         // Return empty buffer
         return BinaryQueueAutoPtr(new BinaryQueue());
-    }
-    else
-    {
+    } else {
         // Must first save errno value, because it may be altered
         int lastErrno = errno;
 
         // Must first save errno value, because it may be altered
         int lastErrno = errno;
 
index 8b09042..8342698 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of file output
  */
  * @version     1.0
  * @brief       This file is the implementation file of file output
  */
+#include <stddef.h>
 #include <dpl/file_output.h>
 #include <dpl/binary_queue.h>
 #include <dpl/scoped_free.h>
 #include <dpl/file_output.h>
 #include <dpl/binary_queue.h>
 #include <dpl/scoped_free.h>
 #include <fcntl.h>
 #include <errno.h>
 
 #include <fcntl.h>
 #include <errno.h>
 
-namespace DPL
-{
-FileOutput::FileOutput()
-    : m_fd(-1)
-{
-}
+namespace DPL {
+FileOutput::FileOutput() :
+    m_fd(-1)
+{}
 
 
-FileOutput::FileOutput(const std::string& fileName)
-    m_fd(-1)
+FileOutput::FileOutput(const std::string& fileName) :
+    m_fd(-1)
 {
     Open(fileName);
 }
 {
     Open(fileName);
 }
@@ -49,11 +48,15 @@ FileOutput::~FileOutput()
 void FileOutput::Open(const std::string& fileName)
 {
     // Open non-blocking
 void FileOutput::Open(const std::string& fileName)
 {
     // Open non-blocking
-    int fd = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, 0664));
+    int fd =
+        TEMP_FAILURE_RETRY(open(fileName.c_str(), O_WRONLY | O_CREAT |
+                                O_TRUNC |
+                                O_NONBLOCK, 0664));
 
     // Throw an exception if an error occurred
 
     // Throw an exception if an error occurred
-    if (fd == -1)
+    if (fd == -1) {
         ThrowMsg(Exception::OpenFailed, fileName);
         ThrowMsg(Exception::OpenFailed, fileName);
+    }
 
     // Close if any existing
     Close();
 
     // Close if any existing
     Close();
@@ -66,11 +69,13 @@ void FileOutput::Open(const std::string& fileName)
 
 void FileOutput::Close()
 {
 
 void FileOutput::Close()
 {
-    if (m_fd == -1)
+    if (m_fd == -1) {
         return;
         return;
+    }
 
 
-    if (TEMP_FAILURE_RETRY(close(m_fd)) == -1)
+    if (TEMP_FAILURE_RETRY(close(m_fd)) == -1) {
         Throw(Exception::CloseFailed);
         Throw(Exception::CloseFailed);
+    }
 
     m_fd = -1;
 
 
     m_fd = -1;
 
@@ -80,8 +85,9 @@ void FileOutput::Close()
 size_t FileOutput::Write(const BinaryQueue &buffer, size_t bufferSize)
 {
     // Adjust write size
 size_t FileOutput::Write(const BinaryQueue &buffer, size_t bufferSize)
 {
     // Adjust write size
-    if (bufferSize > buffer.Size())
+    if (bufferSize > buffer.Size()) {
         bufferSize = buffer.Size();
         bufferSize = buffer.Size();
+    }
 
     // FIXME: User write visitor to write !
     // WriteVisitor visitor
 
     // FIXME: User write visitor to write !
     // WriteVisitor visitor
@@ -95,18 +101,14 @@ size_t FileOutput::Write(const BinaryQueue &buffer, size_t bufferSize)
 
     LogPedantic("Wrote " << result << " bytes to file");
 
 
     LogPedantic("Wrote " << result << " bytes to file");
 
-    if (result > 0)
-    {
+    if (result > 0) {
         // Successfuly written some bytes
         return static_cast<size_t>(result);
         // Successfuly written some bytes
         return static_cast<size_t>(result);
-    }
-    else if (result == 0)
-    {
+    } else if (result == 0) {
         // This is abnormal result
         // This is abnormal result
-        ThrowMsg(CommonException::InternalError, "Invalid write result, 0 bytes written");
-    }
-    else
-    {
+        ThrowMsg(CommonException::InternalError,
+                 "Invalid write result, 0 bytes written");
+    } else {
         // Interpret error result
         // FIXME: Handle errno
         Throw(AbstractOutput::Exception::WriteFailed);
         // Interpret error result
         // FIXME: Handle errno
         Throw(AbstractOutput::Exception::WriteFailed);
index 3ad97c4..f09ff2b 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of MVC generic event
  */
  * @version     1.0
  * @brief       This file is the implementation file of MVC generic event
  */
+#include <stddef.h>
 #include <dpl/generic_event.h>
 
 //
 #include <dpl/generic_event.h>
 
 //
index 1d9ad17..a89abc9 100644 (file)
@@ -19,6 +19,7 @@
  * @version 1.0
  * @brief   Implementation file for lexical cast
  */
  * @version 1.0
  * @brief   Implementation file for lexical cast
  */
+#include <stddef.h>
 #include <dpl/lexical_cast.h>
 
 //
 #include <dpl/lexical_cast.h>
 
 //
index 4e8078c..1d0326b 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of main for EFL
  */
  * @version     1.0
  * @brief       This file is the implementation file of main for EFL
  */
+#include <stddef.h>
 #include <dpl/main.h>
 #include <dpl/log/log.h>
 #include <sys/select.h>
 #include <dpl/main.h>
 #include <dpl/log/log.h>
 #include <sys/select.h>
@@ -29,8 +30,7 @@
 
 IMPLEMENT_SINGLETON(DPL::Main)
 
 
 IMPLEMENT_SINGLETON(DPL::Main)
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 // Late EFL event handling
 namespace // anonymous
 {
 // Late EFL event handling
@@ -39,7 +39,7 @@ Main *g_lateMain = NULL;
 
 Main::Main()
 #ifdef DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 
 Main::Main()
 #ifdef DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
-    // GLIB loop intergration workaround
+// GLIB loop intergration workaround
     : m_oldEcoreSelect(NULL)
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 {
     : m_oldEcoreSelect(NULL)
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 {
@@ -68,11 +68,17 @@ Main::Main()
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 
     // Register event invoker
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 
     // Register event invoker
-    m_invokerHandler = ecore_main_fd_handler_add(WaitableHandleWatchSupport::WaitableInvokerHandle(),
-                                                 ECORE_FD_READ, &StaticDispatchInvoker, this, NULL, NULL);
-
-    if (m_invokerHandler == NULL)
+    m_invokerHandler = ecore_main_fd_handler_add(
+            WaitableHandleWatchSupport::WaitableInvokerHandle(),
+            ECORE_FD_READ,
+            &StaticDispatchInvoker,
+            this,
+            NULL,
+            NULL);
+
+    if (m_invokerHandler == NULL) {
         ThrowMsg(Exception::CreateFailed, "Failed to register invoker handler!");
         ThrowMsg(Exception::CreateFailed, "Failed to register invoker handler!");
+    }
 
     // It is impossible that there exist watchers at this time
     // No need to add watchers
 
     // It is impossible that there exist watchers at this time
     // No need to add watchers
@@ -82,13 +88,21 @@ Main::Main()
 Main::~Main()
 {
     // Remove any watchers
 Main::~Main()
 {
     // Remove any watchers
-    for (EcoreFdHandlerList::iterator iterator = m_readWatchersList.begin(); iterator != m_readWatchersList.end(); ++iterator)
+    for (EcoreFdHandlerList::iterator iterator = m_readWatchersList.begin();
+         iterator != m_readWatchersList.end();
+         ++iterator)
+    {
         ecore_main_fd_handler_del(*iterator);
         ecore_main_fd_handler_del(*iterator);
+    }
 
     m_readWatchersList.clear();
 
 
     m_readWatchersList.clear();
 
-    for (EcoreFdHandlerList::iterator iterator = m_writeWatchersList.begin(); iterator != m_writeWatchersList.end(); ++iterator)
+    for (EcoreFdHandlerList::iterator iterator = m_writeWatchersList.begin();
+         iterator != m_writeWatchersList.end();
+         ++iterator)
+    {
         ecore_main_fd_handler_del(*iterator);
         ecore_main_fd_handler_del(*iterator);
+    }
 
     m_writeWatchersList.clear();
 
 
     m_writeWatchersList.clear();
 
@@ -96,6 +110,9 @@ Main::~Main()
     ecore_main_fd_handler_del(m_invokerHandler);
     m_invokerHandler = NULL;
 
     ecore_main_fd_handler_del(m_invokerHandler);
     m_invokerHandler = NULL;
 
+    //set old ecore select function, because after ecore_shutdown() call,
+    //it is being called once again and it may crash.
+    ecore_main_loop_select_func_set(m_oldEcoreSelect);
     // Decrement ECORE init count
     // We do not need ecore routines any more
     ecore_shutdown();
     // Decrement ECORE init count
     // We do not need ecore routines any more
     ecore_shutdown();
@@ -115,19 +132,17 @@ Eina_Bool Main::StaticDispatchInvoker(void *data, Ecore_Fd_Handler *fd_handler)
     Assert(This != NULL);
 
     // Late EFL event handling
     Assert(This != NULL);
 
     // Late EFL event handling
-    if (g_lateMain == NULL)
-    {
+    if (g_lateMain == NULL) {
         LogPedantic("WARNING: Late EFL invoker dispatch!");
         LogPedantic("WARNING: Late EFL invoker dispatch!");
-    }
-    else
-    {
+    } else {
         This->DispatchInvoker();
     }
 
     return ECORE_CALLBACK_RENEW;
 }
 
         This->DispatchInvoker();
     }
 
     return ECORE_CALLBACK_RENEW;
 }
 
-Eina_Bool Main::StaticDispatchReadWatcher(void* data, Ecore_Fd_Handler* fd_handler)
+Eina_Bool Main::StaticDispatchReadWatcher(void* data,
+                                          Ecore_Fd_Handler* fd_handler)
 {
     LogPedantic("Static ECORE dispatch read watcher");
 
 {
     LogPedantic("Static ECORE dispatch read watcher");
 
@@ -136,19 +151,18 @@ Eina_Bool Main::StaticDispatchReadWatcher(void* data, Ecore_Fd_Handler* fd_handl
     Assert(This != NULL);
 
     // Late EFL event handling
     Assert(This != NULL);
 
     // Late EFL event handling
-    if (g_lateMain == NULL)
-    {
+    if (g_lateMain == NULL) {
         LogPedantic("WARNING: Late EFL read watcher dispatch!");
         LogPedantic("WARNING: Late EFL read watcher dispatch!");
-    }
-    else
-    {
-        This->DispatchReadWatcher(static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(fd_handler)));
+    } else {
+        This->DispatchReadWatcher(static_cast<WaitableHandle>(
+                                      ecore_main_fd_handler_fd_get(fd_handler)));
     }
 
     return ECORE_CALLBACK_RENEW;
 }
 
     }
 
     return ECORE_CALLBACK_RENEW;
 }
 
-Eina_Bool Main::StaticDispatchWriteWatcher(void* data, Ecore_Fd_Handler* fd_handler)
+Eina_Bool Main::StaticDispatchWriteWatcher(void* data,
+                                           Ecore_Fd_Handler* fd_handler)
 {
     LogPedantic("Static ECORE dispatch write watcher");
 
 {
     LogPedantic("Static ECORE dispatch write watcher");
 
@@ -157,13 +171,11 @@ Eina_Bool Main::StaticDispatchWriteWatcher(void* data, Ecore_Fd_Handler* fd_hand
     Assert(This != NULL);
 
     // Late EFL event handling
     Assert(This != NULL);
 
     // Late EFL event handling
-    if (g_lateMain == NULL)
-    {
+    if (g_lateMain == NULL) {
         LogPedantic("WARNING: Late EFL write watcher dispatch!");
         LogPedantic("WARNING: Late EFL write watcher dispatch!");
-    }
-    else
-    {
-        This->DispatchWriteWatcher(static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(fd_handler)));
+    } else {
+        This->DispatchWriteWatcher(static_cast<WaitableHandle>(
+                                       ecore_main_fd_handler_fd_get(fd_handler)));
     }
 
     return ECORE_CALLBACK_RENEW;
     }
 
     return ECORE_CALLBACK_RENEW;
@@ -184,31 +196,36 @@ void Main::DispatchInvoker()
 
 void Main::ReloadWatchList()
 {
 
 void Main::ReloadWatchList()
 {
-    LogPedantic("Reloading watch list... (" << m_readWatchersList.size() << " + " << m_writeWatchersList.size() << ")");
+    LogPedantic(
+        "Reloading watch list... (" << m_readWatchersList.size() << " + " <<
+        m_writeWatchersList.size() << ")");
 
     // Reload list of watchers
 
     // Reload list of watchers
-    WaitableHandleListEx waitableWatcherHandles = WaitableHandleWatchSupport::WaitableWatcherHandles();
+    WaitableHandleListEx waitableWatcherHandles =
+        WaitableHandleWatchSupport::WaitableWatcherHandles();
 
     // Remove not existing read watchers
     EcoreFdHandlerList::iterator watchersIterator = m_readWatchersList.begin();
     WaitableHandleListEx::iterator handlesIterator;
 
 
     // Remove not existing read watchers
     EcoreFdHandlerList::iterator watchersIterator = m_readWatchersList.begin();
     WaitableHandleListEx::iterator handlesIterator;
 
-    while (watchersIterator != m_readWatchersList.end())
-    {
+    while (watchersIterator != m_readWatchersList.end()) {
         bool found = false;
 
         bool found = false;
 
-        for (handlesIterator = waitableWatcherHandles.begin(); handlesIterator != waitableWatcherHandles.end(); ++handlesIterator)
+        for (handlesIterator = waitableWatcherHandles.begin();
+             handlesIterator != waitableWatcherHandles.end();
+             ++handlesIterator)
         {
             if (handlesIterator->second == WaitMode::Read &&
         {
             if (handlesIterator->second == WaitMode::Read &&
-                handlesIterator->first == static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*watchersIterator)))
+                handlesIterator->first ==
+                static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*
+                                                                         watchersIterator)))
             {
                 found = true;
                 break;
             }
         }
 
             {
                 found = true;
                 break;
             }
         }
 
-        if (!found)
-        {
+        if (!found) {
             // Unregister handler
             ecore_main_fd_handler_del(*watchersIterator);
 
             // Unregister handler
             ecore_main_fd_handler_del(*watchersIterator);
 
@@ -218,9 +235,7 @@ void Main::ReloadWatchList()
 
             m_readWatchersList.erase(watchersIterator);
             watchersIterator = next;
 
             m_readWatchersList.erase(watchersIterator);
             watchersIterator = next;
-        }
-        else
-        {
+        } else {
             ++watchersIterator;
         }
     }
             ++watchersIterator;
         }
     }
@@ -228,22 +243,24 @@ void Main::ReloadWatchList()
     // Remove not existing write watchers
     watchersIterator = m_writeWatchersList.begin();
 
     // Remove not existing write watchers
     watchersIterator = m_writeWatchersList.begin();
 
-    while (watchersIterator != m_writeWatchersList.end())
-    {
+    while (watchersIterator != m_writeWatchersList.end()) {
         bool found = false;
 
         bool found = false;
 
-        for (handlesIterator = waitableWatcherHandles.begin(); handlesIterator != waitableWatcherHandles.end(); ++handlesIterator)
+        for (handlesIterator = waitableWatcherHandles.begin();
+             handlesIterator != waitableWatcherHandles.end();
+             ++handlesIterator)
         {
             if (handlesIterator->second == WaitMode::Write &&
         {
             if (handlesIterator->second == WaitMode::Write &&
-                handlesIterator->first == static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*watchersIterator)))
+                handlesIterator->first ==
+                static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*
+                                                                         watchersIterator)))
             {
                 found = true;
                 break;
             }
         }
 
             {
                 found = true;
                 break;
             }
         }
 
-        if (!found)
-        {
+        if (!found) {
             // Unregister handler
             ecore_main_fd_handler_del(*watchersIterator);
 
             // Unregister handler
             ecore_main_fd_handler_del(*watchersIterator);
 
@@ -253,71 +270,88 @@ void Main::ReloadWatchList()
 
             m_writeWatchersList.erase(watchersIterator);
             watchersIterator = next;
 
             m_writeWatchersList.erase(watchersIterator);
             watchersIterator = next;
-        }
-        else
-        {
+        } else {
             ++watchersIterator;
         }
     }
 
     // Add new read/write watchers
             ++watchersIterator;
         }
     }
 
     // Add new read/write watchers
-    for (handlesIterator = waitableWatcherHandles.begin(); handlesIterator != waitableWatcherHandles.end(); ++handlesIterator)
+    for (handlesIterator = waitableWatcherHandles.begin();
+         handlesIterator != waitableWatcherHandles.end();
+         ++handlesIterator)
     {
     {
-        if (handlesIterator->second == WaitMode::Read)
-        {
+        if (handlesIterator->second == WaitMode::Read) {
             bool found = false;
 
             bool found = false;
 
-            for (watchersIterator = m_readWatchersList.begin(); watchersIterator != m_readWatchersList.end(); ++watchersIterator)
+            for (watchersIterator = m_readWatchersList.begin();
+                 watchersIterator != m_readWatchersList.end();
+                 ++watchersIterator)
             {
             {
-                if (handlesIterator->first == static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*watchersIterator)))
+                if (handlesIterator->first ==
+                    static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*
+                                                                             watchersIterator)))
                 {
                     found = true;
                     break;
                 }
             }
 
                 {
                     found = true;
                     break;
                 }
             }
 
-            if (!found)
-            {
-                Ecore_Fd_Handler *handler = ecore_main_fd_handler_add(handlesIterator->first,
-                                                                      ECORE_FD_READ, &StaticDispatchReadWatcher, this, NULL, NULL);
-                if (handler == NULL)
-                    ThrowMsg(Exception::CreateFailed, "Failed to register read watcher handler!");
+            if (!found) {
+                Ecore_Fd_Handler *handler = ecore_main_fd_handler_add(
+                        handlesIterator->first,
+                        ECORE_FD_READ,
+                        &StaticDispatchReadWatcher,
+                        this,
+                        NULL,
+                        NULL);
+                if (handler == NULL) {
+                    ThrowMsg(Exception::CreateFailed,
+                             "Failed to register read watcher handler!");
+                }
 
                 // Push new watcher to list
                 m_readWatchersList.push_back(handler);
             }
 
                 // Push new watcher to list
                 m_readWatchersList.push_back(handler);
             }
-        }
-        else if (handlesIterator->second == WaitMode::Write)
-        {
+        } else if (handlesIterator->second == WaitMode::Write) {
             bool found = false;
 
             bool found = false;
 
-            for (watchersIterator = m_writeWatchersList.begin(); watchersIterator != m_writeWatchersList.end(); ++watchersIterator)
+            for (watchersIterator = m_writeWatchersList.begin();
+                 watchersIterator != m_writeWatchersList.end();
+                 ++watchersIterator)
             {
             {
-                if (handlesIterator->first == static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*watchersIterator)))
+                if (handlesIterator->first ==
+                    static_cast<WaitableHandle>(ecore_main_fd_handler_fd_get(*
+                                                                             watchersIterator)))
                 {
                     found = true;
                     break;
                 }
             }
 
                 {
                     found = true;
                     break;
                 }
             }
 
-            if (!found)
-            {
-                Ecore_Fd_Handler *handler = ecore_main_fd_handler_add(handlesIterator->first,
-                                                                      ECORE_FD_WRITE, &StaticDispatchWriteWatcher, this, NULL, NULL);
-                if (handler == NULL)
-                    ThrowMsg(Exception::CreateFailed, "Failed to register write watcher handler!");
+            if (!found) {
+                Ecore_Fd_Handler *handler = ecore_main_fd_handler_add(
+                        handlesIterator->first,
+                        ECORE_FD_WRITE,
+                        &StaticDispatchWriteWatcher,
+                        this,
+                        NULL,
+                        NULL);
+                if (handler == NULL) {
+                    ThrowMsg(Exception::CreateFailed,
+                             "Failed to register write watcher handler!");
+                }
 
                 // Push new watcher to list
                 m_writeWatchersList.push_back(handler);
             }
 
                 // Push new watcher to list
                 m_writeWatchersList.push_back(handler);
             }
-        }
-        else
-        {
+        } else {
             Assert(0);
         }
     }
 
             Assert(0);
         }
     }
 
-    LogPedantic("Watch list reloaded  (" << m_readWatchersList.size() << " + " << m_writeWatchersList.size() << ")");
+    LogPedantic(
+        "Watch list reloaded  (" << m_readWatchersList.size() << " + " <<
+        m_writeWatchersList.size() << ")");
 }
 
 void Main::DispatchReadWatcher(WaitableHandle waitableHandle)
 }
 
 void Main::DispatchReadWatcher(WaitableHandle waitableHandle)
@@ -353,105 +387,59 @@ void Main::HandleDirectInvoker()
 
 #ifdef DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 // GLIB loop intergration workaround
 
 #ifdef DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 // GLIB loop intergration workaround
-int Main::EcoreSelectInterceptor(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
+int Main::EcoreSelectInterceptor(int nfds,
+                                 fd_set *readfds,
+                                 fd_set *writefds,
+                                 fd_set *exceptfds,
+                                 struct timeval *timeout)
 {
 {
-#if 0
-    // Check each descriptor to see if it is valid
-    for (int i = 0; i < nfds; i++)
-    {
-        if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
-        {
-            // Try to get descriptor flags
-            int result = fcntl(i, F_GETFL);
-
-            if (result == -1)
-            {
-                if (errno == EBADF)
-                {
-                    // This a bad descriptor. Remove all occurrences of it.
-                    if (FD_ISSET(i, readfds))
-                    {
-                        LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad read descriptor: " << i);
-                        FD_CLR(i, readfds);
-                    }
-
-                    if (FD_ISSET(i, writefds))
-                    {
-                        LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad write descriptor: " << i);
-                        FD_CLR(i, writefds);
-                    }
-
-                    if (FD_ISSET(i, exceptfds))
-                    {
-                        LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad exception descriptor: " << i);
-                        FD_CLR(i, exceptfds);
-                    }
-                }
-                else
-                {
-                    // Unexpected error
-                    Assert(0);
-                }
-            }
-        }
-    }
-
-    // Find out new maximum
-    int newNfds = 0;
-
-    for (int i = 0; i < nfds; i++)
-    {
-        if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
-            newNfds = i;
-    }
-
-    return MainSingleton::Instance().m_oldEcoreSelect(newNfds + 1, readfds, writefds, exceptfds, timeout);
-
-#else
-
-    // We have to check error code here and make another try because of some glib error's.
+    // We have to check error code here and make another try because of some
+    // glib error's.
     fd_set rfds, wfds, efds;
     memcpy(&rfds, readfds, sizeof(fd_set));
     memcpy(&wfds, writefds, sizeof(fd_set));
     memcpy(&efds, exceptfds, sizeof(fd_set));
 
     fd_set rfds, wfds, efds;
     memcpy(&rfds, readfds, sizeof(fd_set));
     memcpy(&wfds, writefds, sizeof(fd_set));
     memcpy(&efds, exceptfds, sizeof(fd_set));
 
-    int ret = MainSingleton::Instance().m_oldEcoreSelect(nfds, readfds, writefds, exceptfds, timeout);
+    int ret = MainSingleton::Instance().m_oldEcoreSelect(nfds,
+                                                         readfds,
+                                                         writefds,
+                                                         exceptfds,
+                                                         timeout);
 
 
-    if (ret == -1)
-    {
+    if (ret == -1) {
         // Check each descriptor to see if it is valid
         // Check each descriptor to see if it is valid
-        for (int i = 0; i < nfds; i++)
-        {
-            if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
+        for (int i = 0; i < nfds; i++) {
+            if (FD_ISSET(i,
+                         readfds) ||
+                FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
             {
                 // Try to get descriptor flags
                 int result = fcntl(i, F_GETFL);
 
             {
                 // Try to get descriptor flags
                 int result = fcntl(i, F_GETFL);
 
-                if (result == -1)
-                {
-                    if (errno == EBADF)
-                    {
+                if (result == -1) {
+                    if (errno == EBADF) {
                         // This a bad descriptor. Remove all occurrences of it.
                         // This a bad descriptor. Remove all occurrences of it.
-                        if (FD_ISSET(i, readfds))
-                        {
-                            LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad read descriptor: " << i);
+                        if (FD_ISSET(i, readfds)) {
+                            LogPedantic(
+                                "GLIB_LOOP_INTEGRATION_WORKAROUND: Bad read descriptor: "
+                                << i);
                             FD_CLR(i, readfds);
                         }
 
                             FD_CLR(i, readfds);
                         }
 
-                        if (FD_ISSET(i, writefds))
-                        {
-                            LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad write descriptor: " << i);
+                        if (FD_ISSET(i, writefds)) {
+                            LogPedantic(
+                                "GLIB_LOOP_INTEGRATION_WORKAROUND: Bad write descriptor: "
+                                << i);
                             FD_CLR(i, writefds);
                         }
 
                             FD_CLR(i, writefds);
                         }
 
-                        if (FD_ISSET(i, exceptfds))
-                        {
-                            LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad exception descriptor: " << i);
+                        if (FD_ISSET(i, exceptfds)) {
+                            LogPedantic(
+                                "GLIB_LOOP_INTEGRATION_WORKAROUND: Bad exception descriptor: "
+                                << i);
                             FD_CLR(i, exceptfds);
                         }
                             FD_CLR(i, exceptfds);
                         }
-                    }
-                    else
-                    {
+                    } else {
                         // Unexpected error
                         Assert(0);
                     }
                         // Unexpected error
                         Assert(0);
                     }
@@ -459,7 +447,8 @@ int Main::EcoreSelectInterceptor(int nfds, fd_set *readfds, fd_set *writefds, fd
             }
         }
 
             }
         }
 
-        LogPedantic("GLIB_LOOP_INTEGRATION_WORKAROUND: Bad read descriptor. Retrying with default select.");
+        LogPedantic(
+            "GLIB_LOOP_INTEGRATION_WORKAROUND: Bad read descriptor. Retrying with default select.");
 
         //Retry with old values and return new error
         memcpy(readfds, &rfds, sizeof(fd_set));
 
         //Retry with old values and return new error
         memcpy(readfds, &rfds, sizeof(fd_set));
@@ -471,14 +460,14 @@ int Main::EcoreSelectInterceptor(int nfds, fd_set *readfds, fd_set *writefds, fd
         tm.tv_sec = 0;
         tm.tv_usec = 10;
 
         tm.tv_sec = 0;
         tm.tv_usec = 10;
 
-        if (timeout)
+        if (timeout) {
             ret = select(nfds, readfds, writefds, exceptfds, &tm);
             ret = select(nfds, readfds, writefds, exceptfds, &tm);
-        else
+        } else {
             ret = select(nfds, readfds, writefds, exceptfds, NULL);
             ret = select(nfds, readfds, writefds, exceptfds, NULL);
+        }
     }
 
     return ret;
     }
 
     return ret;
-#endif
 }
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 } // namespace DPL
 }
 #endif // DPL_ENABLE_GLIB_LOOP_INTEGRATION_WORKAROUND
 } // namespace DPL
index 7d18eda..eed1f2e 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of mutex
  */
  * @version     1.0
  * @brief       This file is the implementation file of mutex
  */
+#include <stddef.h>
 #include <dpl/mutex.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <errno.h>
 
 #include <dpl/mutex.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <errno.h>
 
-namespace DPL
-{
+namespace DPL {
 Mutex::Mutex()
 {
 Mutex::Mutex()
 {
-    if (pthread_mutex_init(&m_mutex, NULL) != 0)
-    {
+    if (pthread_mutex_init(&m_mutex, NULL) != 0) {
         int error = errno;
 
         LogPedantic("Failed to create mutex. Errno: " << error);
 
         ThrowMsg(Exception::CreateFailed,
         int error = errno;
 
         LogPedantic("Failed to create mutex. Errno: " << error);
 
         ThrowMsg(Exception::CreateFailed,
-            "Failed to create mutex. Errno: " << error);
+                 "Failed to create mutex. Errno: " << error);
     }
 }
 
 Mutex::~Mutex()
 {
     }
 }
 
 Mutex::~Mutex()
 {
-    if (pthread_mutex_destroy(&m_mutex) != 0)
-    {
+    if (pthread_mutex_destroy(&m_mutex) != 0) {
         int error = errno;
 
         LogPedantic("Failed to destroy mutex. Errno: " << error);
         int error = errno;
 
         LogPedantic("Failed to destroy mutex. Errno: " << error);
@@ -51,32 +49,30 @@ Mutex::~Mutex()
 
 void Mutex::Lock() const
 {
 
 void Mutex::Lock() const
 {
-    if (pthread_mutex_lock(&m_mutex) != 0)
-    {
+    if (pthread_mutex_lock(&m_mutex) != 0) {
         int error = errno;
 
         LogPedantic("Failed to lock mutex. Errno: " << error);
 
         ThrowMsg(Exception::LockFailed,
         int error = errno;
 
         LogPedantic("Failed to lock mutex. Errno: " << error);
 
         ThrowMsg(Exception::LockFailed,
-            "Failed to lock mutex. Errno: " << error);
+                 "Failed to lock mutex. Errno: " << error);
     }
 }
 
 void Mutex::Unlock() const
 {
     }
 }
 
 void Mutex::Unlock() const
 {
-    if (pthread_mutex_unlock(&m_mutex) != 0)
-    {
+    if (pthread_mutex_unlock(&m_mutex) != 0) {
         int error = errno;
 
         LogPedantic("Failed to unlock mutex. Errno: " << error);
 
         ThrowMsg(Exception::UnlockFailed,
         int error = errno;
 
         LogPedantic("Failed to unlock mutex. Errno: " << error);
 
         ThrowMsg(Exception::UnlockFailed,
-            "Failed to unlock mutex. Errno: " << error);
+                 "Failed to unlock mutex. Errno: " << error);
     }
 }
 
     }
 }
 
-Mutex::ScopedLock::ScopedLock(Mutex *mutex)
-    m_mutex(mutex)
+Mutex::ScopedLock::ScopedLock(Mutex *mutex) :
+    m_mutex(mutex)
 {
     Assert(mutex != NULL);
     m_mutex->Lock();
 {
     Assert(mutex != NULL);
     m_mutex->Lock();
@@ -88,7 +84,7 @@ Mutex::ScopedLock::~ScopedLock()
     {
         m_mutex->Unlock();
     }
     {
         m_mutex->Unlock();
     }
-    Catch (Mutex::Exception::UnlockFailed)
+    Catch(Mutex::Exception::UnlockFailed)
     {
         LogPedantic("Failed to leave mutex scoped lock");
     }
     {
         LogPedantic("Failed to leave mutex scoped lock");
     }
index 6d18bc6..9f91d30 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of named base pipe
  */
  * @version     1.0
  * @brief       This file is the implementation file of named base pipe
  */
+#include <stddef.h>
 #include <dpl/named_base_pipe.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dpl/named_base_pipe.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
 
 #include <fcntl.h>
 #include <errno.h>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 const mode_t FIFO_MODE = 0600;
 } // namespace anonymous
 
 NamedBasePipe::~NamedBasePipe()
 namespace // anonymous
 {
 const mode_t FIFO_MODE = 0600;
 } // namespace anonymous
 
 NamedBasePipe::~NamedBasePipe()
-{
-}
+{}
 
 void NamedBasePipe::Create(const std::string &pipeName)
 {
     // Create new fifo
     int status = mkfifo(pipeName.c_str(), FIFO_MODE);
 
 
 void NamedBasePipe::Create(const std::string &pipeName)
 {
     // Create new fifo
     int status = mkfifo(pipeName.c_str(), FIFO_MODE);
 
-    if (status == -1)
-    {
+    if (status == -1) {
         // Ignore error it it already exists
         // Ignore error it it already exists
-        if (errno == EEXIST)
+        if (errno == EEXIST) {
             ThrowMsg(Exception::AlreadyExist, pipeName);
             ThrowMsg(Exception::AlreadyExist, pipeName);
-        else
+        } else {
             ThrowMsg(Exception::CreateFailed, pipeName);
             ThrowMsg(Exception::CreateFailed, pipeName);
+        }
     }
 }
 
     }
 }
 
index 5dd7215..2a9a1fa 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of named output pipe
  */
  * @version     1.0
  * @brief       This file is the implementation file of named output pipe
  */
+#include <stddef.h>
 #include <dpl/named_output_pipe.h>
 #include <dpl/binary_queue.h>
 #include <dpl/scoped_free.h>
 #include <dpl/named_output_pipe.h>
 #include <dpl/binary_queue.h>
 #include <dpl/scoped_free.h>
 #include <fcntl.h>
 #include <errno.h>
 
 #include <fcntl.h>
 #include <errno.h>
 
-namespace DPL
-{
-NamedOutputPipe::NamedOutputPipe()
-    : m_fifo(-1)
-{
-}
+namespace DPL {
+NamedOutputPipe::NamedOutputPipe() :
+    m_fifo(-1)
+{}
 
 NamedOutputPipe::~NamedOutputPipe()
 {
 
 NamedOutputPipe::~NamedOutputPipe()
 {
@@ -45,19 +44,22 @@ void NamedOutputPipe::Open(const std::string& pipeName)
     // Then open it for reading or writing
     int fifo = TEMP_FAILURE_RETRY(open(pipeName.c_str(), O_WRONLY | O_NONBLOCK));
 
     // Then open it for reading or writing
     int fifo = TEMP_FAILURE_RETRY(open(pipeName.c_str(), O_WRONLY | O_NONBLOCK));
 
-    if (fifo == -1)
+    if (fifo == -1) {
         ThrowMsg(Exception::OpenFailed, pipeName);
         ThrowMsg(Exception::OpenFailed, pipeName);
+    }
 
     m_fifo = fifo;
 }
 
 void NamedOutputPipe::Close()
 {
 
     m_fifo = fifo;
 }
 
 void NamedOutputPipe::Close()
 {
-    if (m_fifo == -1)
+    if (m_fifo == -1) {
         return;
         return;
+    }
 
 
-    if (TEMP_FAILURE_RETRY(close(m_fifo)) == -1)
+    if (TEMP_FAILURE_RETRY(close(m_fifo)) == -1) {
         Throw(Exception::CloseFailed);
         Throw(Exception::CloseFailed);
+    }
 
     m_fifo = -1;
 }
 
     m_fifo = -1;
 }
@@ -65,8 +67,9 @@ void NamedOutputPipe::Close()
 size_t NamedOutputPipe::Write(const BinaryQueue &buffer, size_t bufferSize)
 {
     // Adjust write size
 size_t NamedOutputPipe::Write(const BinaryQueue &buffer, size_t bufferSize)
 {
     // Adjust write size
-    if (bufferSize > buffer.Size())
+    if (bufferSize > buffer.Size()) {
         bufferSize = buffer.Size();
         bufferSize = buffer.Size();
+    }
 
     // FIXME: User write visitor to write !
     // WriteVisitor visitor
 
     // FIXME: User write visitor to write !
     // WriteVisitor visitor
@@ -74,20 +77,17 @@ size_t NamedOutputPipe::Write(const BinaryQueue &buffer, size_t bufferSize)
     ScopedFree<void> flattened(malloc(bufferSize));
     buffer.Flatten(flattened.Get(), bufferSize);
 
     ScopedFree<void> flattened(malloc(bufferSize));
     buffer.Flatten(flattened.Get(), bufferSize);
 
-    ssize_t result = TEMP_FAILURE_RETRY(write(m_fifo, flattened.Get(), bufferSize));
+    ssize_t result =
+        TEMP_FAILURE_RETRY(write(m_fifo, flattened.Get(), bufferSize));
 
 
-    if (result > 0)
-    {
+    if (result > 0) {
         // Successfuly written some bytes
         return static_cast<size_t>(result);
         // Successfuly written some bytes
         return static_cast<size_t>(result);
-    }
-    else if (result == 0)
-    {
+    } else if (result == 0) {
         // This is abnormal result
         // This is abnormal result
-        ThrowMsg(CommonException::InternalError, "Invalid socket write result, 0 bytes written");
-    }
-    else
-    {
+        ThrowMsg(CommonException::InternalError,
+                 "Invalid socket write result, 0 bytes written");
+    } else {
         // Interpret error result
         // FIXME: Handle errno
         Throw(AbstractOutput::Exception::WriteFailed);
         // Interpret error result
         // FIXME: Handle errno
         Throw(AbstractOutput::Exception::WriteFailed);
index d0af48a..9453655 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of noncopyable
  */
  * @version     1.0
  * @brief       This file is the implementation file of noncopyable
  */
+#include <stddef.h>
 #include <dpl/noncopyable.h>
 
 #include <dpl/noncopyable.h>
 
-namespace DPL
-{
+namespace DPL {
 Noncopyable::Noncopyable()
 Noncopyable::Noncopyable()
-{
-}
+{}
 
 Noncopyable::~Noncopyable()
 
 Noncopyable::~Noncopyable()
-{
-}
+{}
 } // namespace DPL
 } // namespace DPL
index 5ac0c1e..f2d4a1a 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of once
  */
  * @version     1.0
  * @brief       This file is the implementation file of once
  */
+#include <stddef.h>
 #include <dpl/once.h>
 
 #include <dpl/once.h>
 
-namespace DPL
-{
+namespace DPL {
 void Once::Call(Delegate delegate)
 {
     // First chance test
 void Once::Call(Delegate delegate)
 {
     // First chance test
-    if (m_atomic == 1)
+    if (m_atomic == 1) {
         return;
         return;
+    }
 
     // Enter mutex
     Mutex::ScopedLock lock(&m_mutex);
 
     // Second chance test
 
     // Enter mutex
     Mutex::ScopedLock lock(&m_mutex);
 
     // Second chance test
-    if (m_atomic == 1)
+    if (m_atomic == 1) {
         return;
         return;
+    }
 
     // Initialization: call delegate
     delegate();
 
     // Initialization: call delegate
     delegate();
index 7807f7f..ef34758 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of read write mutex
  */
  * @version     1.0
  * @brief       This file is the implementation file of read write mutex
  */
+#include <stddef.h>
 #include <dpl/read_write_mutex.h>
 #include <dpl/assert.h>
 
 #include <dpl/read_write_mutex.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 ReadWriteMutex::ReadWriteMutex()
 {
 ReadWriteMutex::ReadWriteMutex()
 {
-    if (pthread_rwlock_init(&m_rwlock, NULL) != 0)
+    if (pthread_rwlock_init(&m_rwlock, NULL) != 0) {
         Throw(Exception::CreateFailed);
         Throw(Exception::CreateFailed);
+    }
 }
 
 ReadWriteMutex::~ReadWriteMutex()
 {
 }
 
 ReadWriteMutex::~ReadWriteMutex()
 {
-    if (pthread_rwlock_destroy(&m_rwlock) != 0)
+    if (pthread_rwlock_destroy(&m_rwlock) != 0) {
         Throw(Exception::DestroyFailed);
         Throw(Exception::DestroyFailed);
+    }
 }
 
 void ReadWriteMutex::ReadLock() const
 {
 }
 
 void ReadWriteMutex::ReadLock() const
 {
-    if (pthread_rwlock_rdlock(&m_rwlock) != 0)
+    if (pthread_rwlock_rdlock(&m_rwlock) != 0) {
         Throw(Exception::ReadLockFailed);
         Throw(Exception::ReadLockFailed);
+    }
 }
 
 void ReadWriteMutex::WriteLock() const
 {
 }
 
 void ReadWriteMutex::WriteLock() const
 {
-    if (pthread_rwlock_wrlock(&m_rwlock) != 0)
+    if (pthread_rwlock_wrlock(&m_rwlock) != 0) {
         Throw(Exception::WriteLockFailed);
         Throw(Exception::WriteLockFailed);
+    }
 }
 
 void ReadWriteMutex::Unlock() const
 {
 }
 
 void ReadWriteMutex::Unlock() const
 {
-    if (pthread_rwlock_unlock(&m_rwlock) != 0)
+    if (pthread_rwlock_unlock(&m_rwlock) != 0) {
         Throw(Exception::UnlockFailed);
         Throw(Exception::UnlockFailed);
+    }
 }
 
 }
 
-ReadWriteMutex::ScopedReadLock::ScopedReadLock(ReadWriteMutex *mutex)
-    m_mutex(mutex)
+ReadWriteMutex::ScopedReadLock::ScopedReadLock(ReadWriteMutex *mutex) :
+    m_mutex(mutex)
 {
     Assert(mutex != NULL);
     m_mutex->ReadLock();
 {
     Assert(mutex != NULL);
     m_mutex->ReadLock();
@@ -66,8 +71,8 @@ ReadWriteMutex::ScopedReadLock::~ScopedReadLock()
     m_mutex->Unlock();
 }
 
     m_mutex->Unlock();
 }
 
-ReadWriteMutex::ScopedWriteLock::ScopedWriteLock(ReadWriteMutex *mutex)
-    m_mutex(mutex)
+ReadWriteMutex::ScopedWriteLock::ScopedWriteLock(ReadWriteMutex *mutex) :
+    m_mutex(mutex)
 {
     Assert(mutex != NULL);
     m_mutex->WriteLock();
 {
     Assert(mutex != NULL);
     m_mutex->WriteLock();
index 19e9dea..234d25f 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of recursive mutex
  */
  * @version     1.0
  * @brief       This file is the implementation file of recursive mutex
  */
+#include <stddef.h>
 #include <dpl/recursive_mutex.h>
 #include <dpl/assert.h>
 
 #include <dpl/recursive_mutex.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 RecursiveMutex::RecursiveMutex()
 {
     pthread_mutexattr_t attr;
 RecursiveMutex::RecursiveMutex()
 {
     pthread_mutexattr_t attr;
@@ -31,30 +31,34 @@ RecursiveMutex::RecursiveMutex()
     pthread_mutexattr_init(&attr);
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 
     pthread_mutexattr_init(&attr);
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 
-    if (pthread_mutex_init(&m_mutex, &attr) != 0)
+    if (pthread_mutex_init(&m_mutex, &attr) != 0) {
         Throw(Exception::CreateFailed);
         Throw(Exception::CreateFailed);
+    }
 }
 
 RecursiveMutex::~RecursiveMutex()
 {
 }
 
 RecursiveMutex::~RecursiveMutex()
 {
-    if (pthread_mutex_destroy(&m_mutex) != 0)
+    if (pthread_mutex_destroy(&m_mutex) != 0) {
         Throw(Exception::DestroyFailed);
         Throw(Exception::DestroyFailed);
+    }
 }
 
 void RecursiveMutex::Lock() const
 {
 }
 
 void RecursiveMutex::Lock() const
 {
-    if (pthread_mutex_lock(&m_mutex) != 0)
+    if (pthread_mutex_lock(&m_mutex) != 0) {
         Throw(Exception::LockFailed);
         Throw(Exception::LockFailed);
+    }
 }
 
 void RecursiveMutex::Unlock() const
 {
 }
 
 void RecursiveMutex::Unlock() const
 {
-    if (pthread_mutex_unlock(&m_mutex) != 0)
+    if (pthread_mutex_unlock(&m_mutex) != 0) {
         Throw(Exception::UnlockFailed);
         Throw(Exception::UnlockFailed);
+    }
 }
 
 }
 
-RecursiveMutex::ScopedLock::ScopedLock(RecursiveMutex *mutex)
-    m_mutex(mutex)
+RecursiveMutex::ScopedLock::ScopedLock(RecursiveMutex *mutex) :
+    m_mutex(mutex)
 {
     Assert(mutex != NULL);
     m_mutex->Lock();
 {
     Assert(mutex != NULL);
     m_mutex->Lock();
index 82d53ff..387c009 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of semaphore
  */
  * @version     1.0
  * @brief       This file is the implementation file of semaphore
  */
+#include <stddef.h>
 #include <dpl/semaphore.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <dpl/semaphore.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <fcntl.h>
 #include <unistd.h>
 
 #include <fcntl.h>
 #include <unistd.h>
 
-namespace DPL
-{
+namespace DPL {
 void Semaphore::Remove(const std::string &fileName)
 {
     if (sem_unlink(fileName.c_str()) == -1) {
         int error = errno;
         LogPedantic("Failed to unlink semaphore. Errno: " << error);
         ThrowMsg(Exception::RemoveFailed,
 void Semaphore::Remove(const std::string &fileName)
 {
     if (sem_unlink(fileName.c_str()) == -1) {
         int error = errno;
         LogPedantic("Failed to unlink semaphore. Errno: " << error);
         ThrowMsg(Exception::RemoveFailed,
-                "Failed to unlink semaphore. Errno: " << error);
+                 "Failed to unlink semaphore. Errno: " << error);
     }
 }
 
     }
 }
 
@@ -54,7 +54,7 @@ Semaphore::Semaphore(size_t maxLockCount)
         LogPedantic("Failed to create semaphore. Errno: " << error);
 
         ThrowMsg(Exception::CreateFailed,
         LogPedantic("Failed to create semaphore. Errno: " << error);
 
         ThrowMsg(Exception::CreateFailed,
-            "Failed to create semaphore. Errno: " << error);
+                 "Failed to create semaphore. Errno: " << error);
     }
 
     m_type = Type_Unnamed;
     }
 
     m_type = Type_Unnamed;
@@ -78,50 +78,42 @@ Semaphore::Semaphore(const std::string &fileName,
 
     sem_t *semaphore;
 
 
     sem_t *semaphore;
 
-    do
-    {
-        if (allowCreate)
-        {
-            if (exclusiveCreate)
-            {
+    do {
+        if (allowCreate) {
+            if (exclusiveCreate) {
                 semaphore = sem_open(fileName.c_str(),
                                      O_CREAT | O_EXCL,
                                      permissions,
                                      static_cast<unsigned>(maxLockCount));
                 semaphore = sem_open(fileName.c_str(),
                                      O_CREAT | O_EXCL,
                                      permissions,
                                      static_cast<unsigned>(maxLockCount));
-            }
-            else
-            {
+            } else {
                 semaphore = sem_open(fileName.c_str(),
                                      O_CREAT,
                                      permissions,
                                      static_cast<unsigned>(maxLockCount));
             }
                 semaphore = sem_open(fileName.c_str(),
                                      O_CREAT,
                                      permissions,
                                      static_cast<unsigned>(maxLockCount));
             }
-        }
-        else
-        {
+        } else {
             semaphore = sem_open(fileName.c_str(), 0);
         }
             semaphore = sem_open(fileName.c_str(), 0);
         }
-    }
-    while (semaphore == SEM_FAILED && errno == EINTR);
+    } while (semaphore == SEM_FAILED && errno == EINTR);
 
 
-    if (semaphore == SEM_FAILED)
-    {
+    if (semaphore == SEM_FAILED) {
         int error = errno;
 
         LogPedantic("Failed to create semaphore '" << fileName
         int error = errno;
 
         LogPedantic("Failed to create semaphore '" << fileName
-                    << "'. Errno: " << error);
+                                                   << "'. Errno: " << error);
 
         ThrowMsg(Exception::CreateFailed,
                  "Failed to create semaphore '" << fileName
 
         ThrowMsg(Exception::CreateFailed,
                  "Failed to create semaphore '" << fileName
-                     << "'. Errno: " << error);
+                                                << "'. Errno: " << error);
     }
 
     m_semaphore.named.handle = semaphore;
 
     m_semaphore.named.name = strdup(fileName.c_str()); // May be NULL
 
     }
 
     m_semaphore.named.handle = semaphore;
 
     m_semaphore.named.name = strdup(fileName.c_str()); // May be NULL
 
-    if (m_semaphore.named.name == NULL)
+    if (m_semaphore.named.name == NULL) {
         LogPedantic("Out of memory while duplicating semaphore name");
         LogPedantic("Out of memory while duplicating semaphore name");
+    }
 
     m_semaphore.named.unlinkOnDestroy = unlinkOnDestroy;
 
 
     m_semaphore.named.unlinkOnDestroy = unlinkOnDestroy;
 
@@ -135,16 +127,15 @@ Semaphore::~Semaphore()
 
 sem_t *Semaphore::InternalGet() const
 {
 
 sem_t *Semaphore::InternalGet() const
 {
-    switch (m_type)
-    {
-        case Type_Unnamed:
-            return &m_semaphore.unnamed.handle;
+    switch (m_type) {
+    case Type_Unnamed:
+        return &m_semaphore.unnamed.handle;
 
 
-        case Type_Named:
-            return m_semaphore.named.handle;
+    case Type_Named:
+        return m_semaphore.named.handle;
 
 
-        default:
-            Assert(false && "Invalid type");
+    default:
+        Assert(false && "Invalid type");
     }
 
     return NULL;
     }
 
     return NULL;
@@ -152,75 +143,69 @@ sem_t *Semaphore::InternalGet() const
 
 void Semaphore::InternalDestroy()
 {
 
 void Semaphore::InternalDestroy()
 {
-    switch (m_type)
-    {
-        case Type_Unnamed:
-            if (sem_destroy(&m_semaphore.unnamed.handle) == -1)
-            {
-                int error = errno;
+    switch (m_type) {
+    case Type_Unnamed:
+        if (sem_destroy(&m_semaphore.unnamed.handle) == -1) {
+            int error = errno;
 
 
-                LogPedantic("Failed to destroy semaphore. Errno: " << error);
-            }
-            break;
+            LogPedantic("Failed to destroy semaphore. Errno: " << error);
+        }
+        break;
+
+    case Type_Named:
+        if (sem_close(m_semaphore.named.handle) == -1) {
+            int error = errno;
+
+            LogPedantic("Failed to close semaphore. Errno: " << error);
+        }
 
 
-        case Type_Named:
-            if (sem_close(m_semaphore.named.handle) == -1)
+        if (m_semaphore.named.name != NULL) {
+            // Unlink named semaphore
+            if (m_semaphore.named.unlinkOnDestroy &&
+                sem_unlink(m_semaphore.named.name) == -1)
             {
                 int error = errno;
 
             {
                 int error = errno;
 
-                LogPedantic("Failed to close semaphore. Errno: " << error);
+                LogPedantic("Failed to unlink semaphore. Errno: "
+                            << error);
             }
 
             }
 
-            if (m_semaphore.named.name != NULL)
-            {
-                // Unlink named semaphore
-                if (m_semaphore.named.unlinkOnDestroy &&
-                    sem_unlink(m_semaphore.named.name) == -1)
-                {
-                    int error = errno;
-
-                    LogPedantic("Failed to unlink semaphore. Errno: "
-                                << error);
-                }
-
-                // Free name
-                free(m_semaphore.named.name);
-            }
-            break;
+            // Free name
+            free(m_semaphore.named.name);
+        }
+        break;
 
 
-        default:
-            Assert(false && "Invalid type");
+    default:
+        Assert(false && "Invalid type");
     }
 }
 
 void Semaphore::Lock() const
 {
     }
 }
 
 void Semaphore::Lock() const
 {
-    if (TEMP_FAILURE_RETRY(sem_wait(InternalGet())) != 0)
-    {
+    if (TEMP_FAILURE_RETRY(sem_wait(InternalGet())) != 0) {
         int error = errno;
 
         LogPedantic("Failed to lock semaphore. Errno: " << error);
 
         ThrowMsg(Exception::LockFailed,
         int error = errno;
 
         LogPedantic("Failed to lock semaphore. Errno: " << error);
 
         ThrowMsg(Exception::LockFailed,
-            "Failed to lock semaphore. Errno: " << error);
+                 "Failed to lock semaphore. Errno: " << error);
     }
 }
 
 void Semaphore::Unlock() const
 {
     }
 }
 
 void Semaphore::Unlock() const
 {
-    if (sem_post(InternalGet()) != 0)
-    {
+    if (sem_post(InternalGet()) != 0) {
         int error = errno;
 
         LogPedantic("Failed to unlock semaphore. Errno: " << error);
 
         ThrowMsg(Exception::UnlockFailed,
         int error = errno;
 
         LogPedantic("Failed to unlock semaphore. Errno: " << error);
 
         ThrowMsg(Exception::UnlockFailed,
-            "Failed to unlock semaphore. Errno: " << error);
+                 "Failed to unlock semaphore. Errno: " << error);
     }
 }
 
     }
 }
 
-Semaphore::ScopedLock::ScopedLock(Semaphore *semaphore)
-    m_semaphore(semaphore)
+Semaphore::ScopedLock::ScopedLock(Semaphore *semaphore) :
+    m_semaphore(semaphore)
 {
     Assert(semaphore != NULL);
     m_semaphore->Lock();
 {
     Assert(semaphore != NULL);
     m_semaphore->Lock();
@@ -232,7 +217,7 @@ Semaphore::ScopedLock::~ScopedLock()
     {
         m_semaphore->Unlock();
     }
     {
         m_semaphore->Unlock();
     }
-    Catch (Semaphore::Exception::UnlockFailed)
+    Catch(Semaphore::Exception::UnlockFailed)
     {
         LogPedantic("Failed to leave semaphore scoped lock");
     }
     {
         LogPedantic("Failed to leave semaphore scoped lock");
     }
index b6e7da8..f8f05ff 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of data serialization.
  */
  * @version     1.0
  * @brief       This file is the implementation file of data serialization.
  */
+#include <stddef.h>
 #include <dpl/serialization.h>
 
 //
 #include <dpl/serialization.h>
 
 //
index cca8365..5f95836 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of single instance
  */
  * @version     1.0
  * @brief       This file is the implementation file of single instance
  */
+#include <stddef.h>
 #include <dpl/single_instance.h>
 #include <dpl/log/log.h>
 #include <unistd.h>
 #include <dpl/single_instance.h>
 #include <dpl/log/log.h>
 #include <unistd.h>
 #include <errno.h>
 #include <dpl/assert.h>
 
 #include <errno.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonumous
 {
 const char *LOCK_PREFIX_PATH = "/tmp/dpl_single_instance_";
 }
 namespace // anonumous
 {
 const char *LOCK_PREFIX_PATH = "/tmp/dpl_single_instance_";
 }
-SingleInstance::SingleInstance()
-    : m_locked(false),
-      m_fdLock(-1)
-{
-}
+SingleInstance::SingleInstance() :
+    m_locked(false),
+    m_fdLock(-1)
+{}
 
 SingleInstance::~SingleInstance()
 {
 
 SingleInstance::~SingleInstance()
 {
@@ -55,17 +54,20 @@ bool SingleInstance::TryLock(const std::string &lockName)
     lock.l_len = 1;
 
     // Open lock file
     lock.l_len = 1;
 
     // Open lock file
-    m_fdLock = TEMP_FAILURE_RETRY(open((std::string(LOCK_PREFIX_PATH) + lockName).c_str(), O_WRONLY | O_CREAT, 0666));
+    m_fdLock =
+        TEMP_FAILURE_RETRY(open((std::string(LOCK_PREFIX_PATH) +
+                                 lockName).c_str(),
+                                O_WRONLY | O_CREAT, 0666));
 
 
-    if (m_fdLock == -1)
+    if (m_fdLock == -1) {
         ThrowMsg(Exception::LockError, "Cannot open single instance lock file!");
         ThrowMsg(Exception::LockError, "Cannot open single instance lock file!");
+    }
 
     // Lock file
     int result = TEMP_FAILURE_RETRY(fcntl(m_fdLock, F_SETLK, &lock));
 
     // Was the instance successfuly locked ?
 
     // Lock file
     int result = TEMP_FAILURE_RETRY(fcntl(m_fdLock, F_SETLK, &lock));
 
     // Was the instance successfuly locked ?
-    if (result == 0)
-    {
+    if (result == 0) {
         LogPedantic("Instance locked: " << lockName);
 
         // It is locked now
         LogPedantic("Instance locked: " << lockName);
 
         // It is locked now
@@ -75,8 +77,7 @@ bool SingleInstance::TryLock(const std::string &lockName)
         return true;
     }
 
         return true;
     }
 
-    if (errno == EACCES || errno == EAGAIN)
-    {
+    if (errno == EACCES || errno == EAGAIN) {
         LogPedantic("Instance is already running: " << lockName);
         return false;
     }
         LogPedantic("Instance is already running: " << lockName);
         return false;
     }
@@ -87,8 +88,9 @@ bool SingleInstance::TryLock(const std::string &lockName)
 
 void SingleInstance::Release()
 {
 
 void SingleInstance::Release()
 {
-    if (!m_locked)
+    if (!m_locked) {
         return;
         return;
+    }
 
     LogPedantic("Unlocking single instance");
 
 
     LogPedantic("Unlocking single instance");
 
@@ -103,12 +105,16 @@ void SingleInstance::Release()
     int result = TEMP_FAILURE_RETRY(fcntl(m_fdLock, F_SETLK, &lock));
 
     // Was the instance successfuly unlocked ?
     int result = TEMP_FAILURE_RETRY(fcntl(m_fdLock, F_SETLK, &lock));
 
     // Was the instance successfuly unlocked ?
-    if (result == -1)
-        ThrowMsg(Exception::LockError, "Cannot unlock single instance lock file!");
+    if (result == -1) {
+        ThrowMsg(Exception::LockError,
+                 "Cannot unlock single instance lock file!");
+    }
 
     // Close lock file
 
     // Close lock file
-    if (TEMP_FAILURE_RETRY(close(m_fdLock)) == -1)
-        ThrowMsg(Exception::LockError, "Cannot close single instance lock file!");
+    if (TEMP_FAILURE_RETRY(close(m_fdLock)) == -1) {
+        ThrowMsg(Exception::LockError,
+                 "Cannot close single instance lock file!");
+    }
 
     m_fdLock = -1;
 
 
     m_fdLock = -1;
 
index a6680f1..a76e8ac 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of singleton
  */
  * @version     1.0
  * @brief       This file is the implementation file of singleton
  */
+#include <stddef.h>
 #include <dpl/singleton.h>
 
 //
 #include <dpl/singleton.h>
 
 //
index d945ebd..e81ae22 100644 (file)
@@ -19,6 +19,7 @@
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  */
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  */
+#include <stddef.h>
 #include <dpl/string.h>
 #include <dpl/char_traits.h>
 #include <dpl/errno_string.h>
 #include <dpl/string.h>
 #include <dpl/char_traits.h>
 #include <dpl/errno_string.h>
 #include <unicode/ustring.h>
 
 // TODO: Completely move to ICU
 #include <unicode/ustring.h>
 
 // TODO: Completely move to ICU
-namespace DPL
-{
+namespace DPL {
 namespace //anonymous
 {
 class ASCIIValidator
 {
     const std::string& m_TestedString;
 
 namespace //anonymous
 {
 class ASCIIValidator
 {
     const std::string& m_TestedString;
 
-public:
+  public:
     ASCIIValidator(const std::string& aTestedString);
 
     void operator()(char aCharacter) const;
 };
 
     ASCIIValidator(const std::string& aTestedString);
 
     void operator()(char aCharacter) const;
 };
 
-ASCIIValidator::ASCIIValidator(const std::string& aTestedString)
-    : m_TestedString(aTestedString)
-{
-}
+ASCIIValidator::ASCIIValidator(const std::string& aTestedString) :
+    m_TestedString(aTestedString)
+{}
 
 void ASCIIValidator::operator()(char aCharacter) const
 {
     // Check for ASCII data range
 
 void ASCIIValidator::operator()(char aCharacter) const
 {
     // Check for ASCII data range
-    if (aCharacter <= 0)
-    {
-        ThrowMsg(StringException::InvalidASCIICharacter,
-                 "invalid character code " << static_cast<int>(aCharacter)
-                 << " from string [" << m_TestedString
-                 << "] passed as ASCII");
+    if (aCharacter <= 0) {
+        ThrowMsg(
+            StringException::InvalidASCIICharacter,
+            "invalid character code " << static_cast<int>(aCharacter)
+                                      << " from string [" <<
+            m_TestedString
+                                      << "] passed as ASCII");
     }
 }
 
     }
 }
 
@@ -71,9 +71,9 @@ const size_t gc_IconvConvertError = static_cast<size_t>(-1);
 
 String FromUTF8String(const std::string& aIn)
 {
 
 String FromUTF8String(const std::string& aIn)
 {
-    if (aIn.empty())
-
+    if (aIn.empty()) {
         return String();
         return String();
+    }
 
     size_t inbytes = aIn.size();
 
 
     size_t inbytes = aIn.size();
 
@@ -84,7 +84,7 @@ String FromUTF8String(const std::string& aIn)
     // oldsize - letters in UTF-8 string
     // end - end character for UTF-32 (\0)
     // bom - Unicode header in front of string (0xfeff)
     // oldsize - letters in UTF-8 string
     // end - end character for UTF-32 (\0)
     // bom - Unicode header in front of string (0xfeff)
-    size_t outbytes = sizeof(wchar_t)*(inbytes + 2);
+    size_t outbytes = sizeof(wchar_t) * (inbytes + 2);
     std::vector<wchar_t> output(inbytes + 2, 0);
 
     size_t outbytesleft = outbytes;
     std::vector<wchar_t> output(inbytes + 2, 0);
 
     size_t outbytesleft = outbytes;
@@ -94,10 +94,9 @@ String FromUTF8String(const std::string& aIn)
     // but during conversion from UTF32 uses internaly wchar_t
     char* outbuf = reinterpret_cast<char*>(&output[0]);
 
     // but during conversion from UTF32 uses internaly wchar_t
     char* outbuf = reinterpret_cast<char*>(&output[0]);
 
-    iconv_t iconvHandle = iconv_open("UTF-32","UTF-8");
+    iconv_t iconvHandle = iconv_open("UTF-32", "UTF-8");
 
 
-    if (gc_IconvOperError == iconvHandle)
-    {
+    if (gc_IconvOperError == iconvHandle) {
         int error = errno;
 
         ThrowMsg(StringException::IconvInitErrorUTF8ToUTF32,
         int error = errno;
 
         ThrowMsg(StringException::IconvInitErrorUTF8ToUTF32,
@@ -105,16 +104,18 @@ String FromUTF8String(const std::string& aIn)
                  "error: " << GetErrnoString(error));
     }
 
                  "error: " << GetErrnoString(error));
     }
 
-    size_t iconvRet = iconv(iconvHandle, &inbuf, &inbytes, &outbuf, &outbytesleft);
+    size_t iconvRet = iconv(iconvHandle,
+                            &inbuf,
+                            &inbytes,
+                            &outbuf,
+                            &outbytesleft);
 
     iconv_close(iconvHandle);
 
 
     iconv_close(iconvHandle);
 
-    if (gc_IconvConvertError == iconvRet)
-    {
+    if (gc_IconvConvertError == iconvRet) {
         ThrowMsg(StringException::IconvConvertErrorUTF8ToUTF32,
                  "iconv failed for " << "UTF-32 <- UTF-8" << "error: "
         ThrowMsg(StringException::IconvConvertErrorUTF8ToUTF32,
                  "iconv failed for " << "UTF-32 <- UTF-8" << "error: "
-                            << GetErrnoString());
-        return String();
+                                     << GetErrnoString());
     }
 
     // Ignore BOM in front of UTF-32
     }
 
     // Ignore BOM in front of UTF-32
@@ -123,41 +124,41 @@ String FromUTF8String(const std::string& aIn)
 
 std::string ToUTF8String(const DPL::String& aIn)
 {
 
 std::string ToUTF8String(const DPL::String& aIn)
 {
-    if (aIn.empty())
-
+    if (aIn.empty()) {
         return std::string();
         return std::string();
+    }
 
     size_t inbytes = aIn.size() * sizeof(wchar_t);
     size_t outbytes = inbytes + sizeof(char);
 
     // wstring returns wchar_t but iconv expects char*
     // iconv internally is processing input as wchar_t
 
     size_t inbytes = aIn.size() * sizeof(wchar_t);
     size_t outbytes = inbytes + sizeof(char);
 
     // wstring returns wchar_t but iconv expects char*
     // iconv internally is processing input as wchar_t
-    char* inbuf =  reinterpret_cast<char*>(const_cast<wchar_t*>(aIn.c_str()));
+    char* inbuf = reinterpret_cast<char*>(const_cast<wchar_t*>(aIn.c_str()));
     std::vector<char> output(inbytes, 0);
     char* outbuf = &output[0];
 
     size_t outbytesleft = outbytes;
 
     std::vector<char> output(inbytes, 0);
     char* outbuf = &output[0];
 
     size_t outbytesleft = outbytes;
 
-    iconv_t iconvHandle = iconv_open("UTF-8","UTF-32");
+    iconv_t iconvHandle = iconv_open("UTF-8", "UTF-32");
 
 
-    if (gc_IconvOperError == iconvHandle)
-    {
+    if (gc_IconvOperError == iconvHandle) {
         ThrowMsg(StringException::IconvInitErrorUTF32ToUTF8,
                  "iconv_open failed for " << "UTF-8 <- UTF-32"
         ThrowMsg(StringException::IconvInitErrorUTF32ToUTF8,
                  "iconv_open failed for " << "UTF-8 <- UTF-32"
-                            << "error: " << GetErrnoString());
-        return std::string();
+                                          << "error: " << GetErrnoString());
     }
 
     }
 
-    size_t iconvRet = iconv(iconvHandle, &inbuf, &inbytes, &outbuf, &outbytesleft);
+    size_t iconvRet = iconv(iconvHandle,
+                            &inbuf,
+                            &inbytes,
+                            &outbuf,
+                            &outbytesleft);
 
     iconv_close(iconvHandle);
 
 
     iconv_close(iconvHandle);
 
-    if (gc_IconvConvertError == iconvRet)
-    {
+    if (gc_IconvConvertError == iconvRet) {
         ThrowMsg(StringException::IconvConvertErrorUTF32ToUTF8,
                  "iconv failed for " << "UTF-8 <- UTF-32"
         ThrowMsg(StringException::IconvConvertErrorUTF32ToUTF8,
                  "iconv failed for " << "UTF-8 <- UTF-32"
-                            << "error: " << GetErrnoString());
-        return std::string();
+                                     << "error: " << GetErrnoString());
     }
 
     return &output[0];
     }
 
     return &output[0];
@@ -198,9 +199,7 @@ static UChar *ConvertToICU(const String &inputString)
     {
         // What buffer size is ok ?
         LogPedantic("ICU: Output buffer size: " << size);
     {
         // What buffer size is ok ?
         LogPedantic("ICU: Output buffer size: " << size);
-    }
-    else
-    {
+    } else {
         ThrowMsg(StringException::ICUInvalidCharacterFound,
                  "ICU: Failed to retrieve output string size. Error: "
                  << error);
         ThrowMsg(StringException::ICUInvalidCharacterFound,
                  "ICU: Failed to retrieve output string size. Error: "
                  << error);
@@ -220,8 +219,7 @@ static UChar *ConvertToICU(const String &inputString)
                    -1,
                    &error);
 
                    -1,
                    &error);
 
-    if (!U_SUCCESS(error))
-    {
+    if (!U_SUCCESS(error)) {
         ThrowMsg(StringException::ICUInvalidCharacterFound,
                  "ICU: Failed to convert string. Error: " << error);
     }
         ThrowMsg(StringException::ICUInvalidCharacterFound,
                  "ICU: Failed to convert string. Error: " << error);
     }
@@ -238,12 +236,9 @@ int StringCompare(const String &left,
     ScopedArray<UChar> leftICU(ConvertToICU(left));
     ScopedArray<UChar> rightICU(ConvertToICU(right));
 
     ScopedArray<UChar> leftICU(ConvertToICU(left));
     ScopedArray<UChar> rightICU(ConvertToICU(right));
 
-    if (caseInsensitive)
-    {
+    if (caseInsensitive) {
         return static_cast<int>(u_strcasecmp(leftICU.Get(), rightICU.Get(), 0));
         return static_cast<int>(u_strcasecmp(leftICU.Get(), rightICU.Get(), 0));
-    }
-    else
-    {
+    } else {
         return static_cast<int>(u_strcmp(leftICU.Get(), rightICU.Get()));
     }
 }
         return static_cast<int>(u_strcmp(leftICU.Get(), rightICU.Get()));
     }
 }
index a8f18a4..6d4ff0d 100644 (file)
@@ -20,6 +20,7 @@
  * @version 1.0
  * @brief   Implementation file for abstaract task definition
  */
  * @version 1.0
  * @brief   Implementation file for abstaract task definition
  */
+#include <stddef.h>
 #include <dpl/task.h>
 
 //
 #include <dpl/task.h>
 
 //
index 89e0ff8..928f254 100644 (file)
  * @version 1.0
  * @brief   Implementation file for task list
  */
  * @version 1.0
  * @brief   Implementation file for task list
  */
+#include <stddef.h>
 #include <dpl/task_list.h>
 #include <dpl/assert.h>
 
 #include <dpl/task_list.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-TaskList::TaskList()
-    : m_switched(false),
-      m_running(false)
+namespace DPL {
+TaskList::TaskList() :
+    m_switched(false),
+    m_running(false)
 {
     m_currentTask = m_tasks.end();
 }
 
 TaskList::~TaskList()
 {
 {
     m_currentTask = m_tasks.end();
 }
 
 TaskList::~TaskList()
 {
-    for (Tasks::iterator i = m_tasks.begin(); i != m_tasks.end(); ++i)
+    for (Tasks::iterator i = m_tasks.begin(); i != m_tasks.end(); ++i) {
         delete *i;
         delete *i;
+    }
 }
 
 void TaskList::AddTask(Task *task)
 }
 
 void TaskList::AddTask(Task *task)
@@ -49,38 +50,40 @@ bool TaskList::NextStep()
 {
     m_running = true;
 
 {
     m_running = true;
 
-    Assert(m_currentTask != m_tasks.end() && "Task list is empty or all tasks done");
+    Assert(
+        m_currentTask != m_tasks.end() &&
+        "Task list is empty or all tasks done");
 
     m_switched = false;
 
     bool result = (*m_currentTask)->NextStep();
 
 
     m_switched = false;
 
     bool result = (*m_currentTask)->NextStep();
 
-    if (result || m_switched)
+    if (result || m_switched) {
         return true;
         return true;
+    }
 
     return ++m_currentTask != m_tasks.end();
 }
 
 bool TaskList::Abort()
 {
 
     return ++m_currentTask != m_tasks.end();
 }
 
 bool TaskList::Abort()
 {
-    m_tasks.erase(m_currentTask,m_tasks.end());
+    m_tasks.erase(m_currentTask, m_tasks.end());
     m_tasks.reverse();
     m_tasks.reverse();
-    for (Tasks::iterator i = m_tasks.begin(); i != m_tasks.end();)
-    {
+    for (Tasks::iterator i = m_tasks.begin(); i != m_tasks.end();) {
         //If given task does not have any "abortSteps", remove it from the list
         //If given task does not have any "abortSteps", remove it from the list
-        if(!(*i)->Abort())
-        {
+        if (!(*i)->Abort()) {
             delete *i;
             delete *i;
-            i=m_tasks.erase(i);
+            i = m_tasks.erase(i);
             continue;
         }
         ++i;
     }
 
             continue;
         }
         ++i;
     }
 
-    if(m_tasks.empty())
+    if (m_tasks.empty()) {
         return false;
         return false;
+    }
 
 
-    m_currentTask=m_tasks.begin();
+    m_currentTask = m_tasks.begin();
 
     return true;
 }
 
     return true;
 }
@@ -102,10 +105,10 @@ size_t TaskList::GetStepCount() const
 {
     size_t count = 0;
 
 {
     size_t count = 0;
 
-    for (Tasks::const_iterator i = m_tasks.begin(); i != m_tasks.end(); ++i)
+    for (Tasks::const_iterator i = m_tasks.begin(); i != m_tasks.end(); ++i) {
         count += (*i)->GetStepCount();
         count += (*i)->GetStepCount();
+    }
 
     return count;
 }
 
     return count;
 }
-
 } // namespace DPL
 } // namespace DPL
index ec7166a..0e75810 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of thread
  */
  * @version     1.0
  * @brief       This file is the implementation file of thread
  */
+#include <stddef.h>
 #include <dpl/thread.h>
 #include <dpl/log/log.h>
 #include <sys/time.h>
 #include <dpl/thread.h>
 #include <dpl/log/log.h>
 #include <sys/time.h>
@@ -26,6 +27,7 @@
 #include <dpl/assert.h>
 #include <errno.h>
 #include <time.h>
 #include <dpl/assert.h>
 #include <errno.h>
 #include <time.h>
+#include <string.h>
 
 namespace // anonymous
 {
 
 namespace // anonymous
 {
@@ -42,13 +44,13 @@ static const pthread_t g_mainThread = pthread_self();
 
 class ThreadSpecific
 {
 
 class ThreadSpecific
 {
-public:
+  public:
     pthread_key_t threadSpecific;
 
     pthread_key_t threadSpecific;
 
-    ThreadSpecific()
-        threadSpecific(0)
+    ThreadSpecific() :
+        threadSpecific(0)
     {
     {
-        threadSpecific=0;
+        threadSpecific = 0;
         pthread_key_create(&threadSpecific, NULL);
     }
 
         pthread_key_create(&threadSpecific, NULL);
     }
 
@@ -61,17 +63,15 @@ public:
 static ThreadSpecific g_threadSpecific;
 } // namespace anonymous
 
 static ThreadSpecific g_threadSpecific;
 } // namespace anonymous
 
-namespace DPL
-{
+namespace DPL {
 bool g_TLSforMainCreated = false;
 
 bool g_TLSforMainCreated = false;
 
-Thread::Thread()
-    : m_thread(0),
-      m_abandon(false),
-      m_running(false),
-      m_directInvoke(false)
-{
-}
+Thread::Thread() :
+    m_thread(0),
+    m_abandon(false),
+    m_running(false),
+    m_directInvoke(false)
+{}
 
 Thread::~Thread()
 {
 
 Thread::~Thread()
 {
@@ -83,22 +83,33 @@ Thread::~Thread()
 
     // Remove any remainig events
     // Thread proc is surely not running now
 
     // Remove any remainig events
     // Thread proc is surely not running now
-    for (InternalEventList::iterator iterator = m_eventList.begin(); iterator != m_eventList.end(); ++iterator)
+    for (InternalEventList::iterator iterator = m_eventList.begin();
+         iterator != m_eventList.end();
+         ++iterator)
+    {
         iterator->eventDeleteProc(iterator->event, iterator->userParam);
         iterator->eventDeleteProc(iterator->event, iterator->userParam);
+    }
 
     m_eventList.clear();
 }
 
 
     m_eventList.clear();
 }
 
+bool Thread::IsMainThread()
+{
+    return (pthread_equal(pthread_self(), g_mainThread));
+}
+
 Thread *Thread::GetCurrentThread()
 {
 Thread *Thread::GetCurrentThread()
 {
-    if (pthread_equal(pthread_self(), g_mainThread))
+    if (pthread_equal(pthread_self(), g_mainThread)) {
         return NULL;
         return NULL;
+    }
 
     void *threadSpecific = pthread_getspecific(g_threadSpecific.threadSpecific);
 
     // Is this a managed thread ?
 
     void *threadSpecific = pthread_getspecific(g_threadSpecific.threadSpecific);
 
     // Is this a managed thread ?
-    if (threadSpecific == NULL)
+    if (threadSpecific == NULL) {
         Throw(Exception::UnmanagedThread);
         Throw(Exception::UnmanagedThread);
+    }
 
     return static_cast<Thread *>(threadSpecific);
 }
 
     return static_cast<Thread *>(threadSpecific);
 }
@@ -112,7 +123,11 @@ void *Thread::StaticThreadEntry(void *param)
     Assert(This != NULL);
 
     // Set thread specific
     Assert(This != NULL);
 
     // Set thread specific
-    pthread_setspecific(g_threadSpecific.threadSpecific, This);
+    int result = pthread_setspecific(g_threadSpecific.threadSpecific, This);
+
+    if (result != 0) {
+        LogError("Failed to set threadSpecific. Error: " << strerror(result));
+    }
 
     // Enter thread proc
     // Do not allow exceptions to hit pthread core
 
     // Enter thread proc
     // Do not allow exceptions to hit pthread core
@@ -130,13 +145,10 @@ void *Thread::StaticThreadEntry(void *param)
         This->m_running = false;
 
         // Abandon thread
         This->m_running = false;
 
         // Abandon thread
-        if (This->m_abandon)
-        {
+        if (This->m_abandon) {
             LogPedantic("Thread was abandoned");
             pthread_detach(This->m_thread);
             LogPedantic("Thread was abandoned");
             pthread_detach(This->m_thread);
-        }
-        else
-        {
+        } else {
             LogPedantic("Thread is joinable");
         }
     }
             LogPedantic("Thread is joinable");
         }
     }
@@ -153,7 +165,7 @@ int Thread::ThreadEntry()
 void Thread::ProcessEvents()
 {
     LogPedantic("Processing events");
 void Thread::ProcessEvents()
 {
     LogPedantic("Processing events");
-    
+
     // Steal current event list
     InternalEventList stolenEvents;
 
     // Steal current event list
     InternalEventList stolenEvents;
 
@@ -167,7 +179,9 @@ void Thread::ProcessEvents()
     // Process event list
     LogPedantic("Stolen " << stolenEvents.size() << " internal events");
 
     // Process event list
     LogPedantic("Stolen " << stolenEvents.size() << " internal events");
 
-    for (InternalEventList::iterator iterator = stolenEvents.begin(); iterator != stolenEvents.end(); ++iterator)
+    for (InternalEventList::iterator iterator = stolenEvents.begin();
+         iterator != stolenEvents.end();
+         ++iterator)
     {
         // Dispatch immediate event
         iterator->eventDispatchProc(iterator->event, iterator->userParam);
     {
         // Dispatch immediate event
         iterator->eventDispatchProc(iterator->event, iterator->userParam);
@@ -187,16 +201,24 @@ void Thread::ProcessTimedEvents()
         unsigned long currentTimeMiliseconds = GetCurrentTimeMiliseconds();
 
         // Info
         unsigned long currentTimeMiliseconds = GetCurrentTimeMiliseconds();
 
         // Info
-        LogPedantic("Processing timed events. Time now: " << currentTimeMiliseconds << " ms");
+        LogPedantic(
+            "Processing timed events. Time now: " << currentTimeMiliseconds <<
+            " ms");
 
         // All timed events are sorted chronologically
         // Emit timed out events
         while (!m_timedEventVector.empty() &&
 
         // All timed events are sorted chronologically
         // Emit timed out events
         while (!m_timedEventVector.empty() &&
-               currentTimeMiliseconds >= m_timedEventVector.begin()->registerTimeMiliseconds + m_timedEventVector.begin()->dueTimeMiliseconds)
+               currentTimeMiliseconds >=
+               m_timedEventVector.begin()->registerTimeMiliseconds +
+               m_timedEventVector.begin()->dueTimeMiliseconds)
         {
             // Info
         {
             // Info
-            LogPedantic("Transforming timed event into immediate event. Absolute due time: " <<
-                        (m_timedEventVector.begin()->registerTimeMiliseconds + m_timedEventVector.begin()->dueTimeMiliseconds) << " ms");
+            LogPedantic(
+                "Transforming timed event into immediate event. Absolute due time: "
+                <<
+                (m_timedEventVector.begin()->registerTimeMiliseconds +
+                 m_timedEventVector.begin()->dueTimeMiliseconds) <<
+                " ms");
 
             // Emit immediate event
             PushEvent(m_timedEventVector.begin()->event,
 
             // Emit immediate event
             PushEvent(m_timedEventVector.begin()->event,
@@ -215,7 +237,8 @@ unsigned long Thread::GetCurrentTimeMiliseconds() const
 {
     timeval tv;
     gettimeofday(&tv, NULL);
 {
     timeval tv;
     gettimeofday(&tv, NULL);
-    return static_cast<unsigned long>(tv.tv_sec) * 1000 + static_cast<unsigned long>(tv.tv_usec) / 1000;
+    return static_cast<unsigned long>(tv.tv_sec) * 1000 +
+           static_cast<unsigned long>(tv.tv_usec) / 1000;
 }
 
 int Thread::Exec()
 }
 
 int Thread::Exec()
@@ -231,28 +254,34 @@ int Thread::Exec()
     handleList.push_back(std::make_pair(m_quitEvent.GetHandle(), WaitMode::Read));
 
     // index 1: Event occurred event handle
     handleList.push_back(std::make_pair(m_quitEvent.GetHandle(), WaitMode::Read));
 
     // index 1: Event occurred event handle
-    handleList.push_back(std::make_pair(m_eventInvoker.GetHandle(), WaitMode::Read));
+    handleList.push_back(std::make_pair(m_eventInvoker.GetHandle(),
+                                        WaitMode::Read));
 
     // index 2: Timed event occurred event handle
 
     // index 2: Timed event occurred event handle
-    handleList.push_back(std::make_pair(m_timedEventInvoker.GetHandle(), WaitMode::Read));
+    handleList.push_back(std::make_pair(m_timedEventInvoker.GetHandle(),
+                                        WaitMode::Read));
 
     // index 3: Waitable handle watch support invoker
 
     // index 3: Waitable handle watch support invoker
-    handleList.push_back(std::make_pair(WaitableHandleWatchSupport::WaitableInvokerHandle(), WaitMode::Read));
+    handleList.push_back(std::make_pair(WaitableHandleWatchSupport::
+                                            WaitableInvokerHandle(),
+                                        WaitMode::Read));
 
     //
     // Watch list might have been initialized before threaded started
     // Need to fill waitable event watch list in this case
     //
     {
 
     //
     // Watch list might have been initialized before threaded started
     // Need to fill waitable event watch list in this case
     //
     {
-        WaitableHandleListEx waitableHandleWatchHandles = WaitableHandleWatchSupport::WaitableWatcherHandles();
-        std::copy(waitableHandleWatchHandles.begin(), waitableHandleWatchHandles.end(), std::back_inserter(handleList));
+        WaitableHandleListEx waitableHandleWatchHandles =
+            WaitableHandleWatchSupport::WaitableWatcherHandles();
+        std::copy(
+            waitableHandleWatchHandles.begin(),
+            waitableHandleWatchHandles.end(), std::back_inserter(handleList));
     }
 
     // Quit flag
     bool quit = false;
 
     }
 
     // Quit flag
     bool quit = false;
 
-    while (!quit)
-    {
+    while (!quit) {
         // Retrieve minimum wait time, according to timed events list
         unsigned long minimumWaitTime;
 
         // Retrieve minimum wait time, according to timed events list
         unsigned long minimumWaitTime;
 
@@ -260,29 +289,34 @@ int Thread::Exec()
         {
             Mutex::ScopedLock lock(&m_timedEventMutex);
 
         {
             Mutex::ScopedLock lock(&m_timedEventMutex);
 
-            if (!m_timedEventVector.empty())
-            {
-                unsigned long currentTimeMiliseconds = GetCurrentTimeMiliseconds();
-                unsigned long destinationTimeMiliseconds = m_timedEventVector.begin()->registerTimeMiliseconds + m_timedEventVector.begin()->dueTimeMiliseconds;
+            if (!m_timedEventVector.empty()) {
+                unsigned long currentTimeMiliseconds =
+                    GetCurrentTimeMiliseconds();
+                unsigned long destinationTimeMiliseconds =
+                    m_timedEventVector.begin()->registerTimeMiliseconds +
+                    m_timedEventVector.begin()->dueTimeMiliseconds;
 
                 // Are we already late with timed event ?
 
                 // Are we already late with timed event ?
-                if (currentTimeMiliseconds > destinationTimeMiliseconds)
+                if (currentTimeMiliseconds > destinationTimeMiliseconds) {
                     minimumWaitTime = 0;
                     minimumWaitTime = 0;
-                else
-                    minimumWaitTime = destinationTimeMiliseconds - currentTimeMiliseconds;
-            }
-            else
+                } else {
+                    minimumWaitTime = destinationTimeMiliseconds -
+                        currentTimeMiliseconds;
+                }
+            } else {
                 minimumWaitTime = 0xFFFFFFFF; // Infinity
                 minimumWaitTime = 0xFFFFFFFF; // Infinity
+            }
         }
 
         // Info
         }
 
         // Info
-        LogPedantic("Thread loop minimum wait time: " << minimumWaitTime << " ms");
+        LogPedantic(
+            "Thread loop minimum wait time: " << minimumWaitTime << " ms");
 
         // Do thread waiting
 
         // Do thread waiting
-        WaitableHandleIndexList waitableHandleIndexList = WaitForMultipleHandles(handleList, minimumWaitTime);
+        WaitableHandleIndexList waitableHandleIndexList =
+            WaitForMultipleHandles(handleList, minimumWaitTime);
 
 
-        if (waitableHandleIndexList.empty())
-        {
+        if (waitableHandleIndexList.empty()) {
             // Timeout occurred. Process timed events.
             LogPedantic("Timed event list elapsed invoker");
             ProcessTimedEvents();
             // Timeout occurred. Process timed events.
             LogPedantic("Timed event list elapsed invoker");
             ProcessTimedEvents();
@@ -290,7 +324,8 @@ int Thread::Exec()
         }
 
         // Go through each index
         }
 
         // Go through each index
-        for (WaitableHandleIndexList::const_iterator waitableHandleIndexIterator = waitableHandleIndexList.begin();
+        for (WaitableHandleIndexList::const_iterator
+             waitableHandleIndexIterator = waitableHandleIndexList.begin();
              waitableHandleIndexIterator != waitableHandleIndexList.end();
              ++waitableHandleIndexIterator)
         {
              waitableHandleIndexIterator != waitableHandleIndexList.end();
              ++waitableHandleIndexIterator)
         {
@@ -298,106 +333,116 @@ int Thread::Exec()
 
             LogPedantic("Event loop triggered with index: " << index);
 
 
             LogPedantic("Event loop triggered with index: " << index);
 
-            switch (index)
-            {
-                case 0:
-                    // Quit waitable event handle
-                    quit = true;
-                    break;
+            switch (index) {
+            case 0:
+                // Quit waitable event handle
+                quit = true;
+                break;
 
 
-                case 1:
-                    // Event occurred event handle
-                    ProcessEvents();
+            case 1:
+                // Event occurred event handle
+                ProcessEvents();
 
 
-                    // Handle direct invoker
-                    if (m_directInvoke)
-                    {
-                        m_directInvoke = false;
+                // Handle direct invoker
+                if (m_directInvoke) {
+                    m_directInvoke = false;
 
 
-                        LogPedantic("Handling direct invoker");
+                    LogPedantic("Handling direct invoker");
 
 
-                        // Update list
-                        while (handleList.size() > MIN_HANDLE_LIST_SIZE)
-                            handleList.pop_back();
+                    // Update list
+                    while (handleList.size() > MIN_HANDLE_LIST_SIZE) {
+                        handleList.pop_back();
+                    }
 
 
-                        // Insert current waitable event handles instead
-                        {
-                            WaitableHandleListEx waitableHandleWatchHandles = WaitableHandleWatchSupport::WaitableWatcherHandles();
-                            std::copy(waitableHandleWatchHandles.begin(), waitableHandleWatchHandles.end(), std::back_inserter(handleList));
-                        }
+                    // Insert current waitable event handles instead
+                    {
+                        WaitableHandleListEx waitableHandleWatchHandles =
+                            WaitableHandleWatchSupport::WaitableWatcherHandles();
+                        std::copy(
+                            waitableHandleWatchHandles.begin(),
+                            waitableHandleWatchHandles.end(),
+                            std::back_inserter(handleList));
                     }
                     }
+                }
 
 
-                    // Done
-                    break;
+                // Done
+                break;
 
 
-                case 2:
-                    // Timed event list changed
-                    LogPedantic("Timed event list changed invoker");
-                    ProcessTimedEvents();
+            case 2:
+                // Timed event list changed
+                LogPedantic("Timed event list changed invoker");
+                ProcessTimedEvents();
 
 
-                    // Reset timed event invoker
-                    m_timedEventInvoker.Reset();
+                // Reset timed event invoker
+                m_timedEventInvoker.Reset();
 
 
-                    // Done
-                    break;
+                // Done
+                break;
 
 
-                case 3:
-                    // Waitable handle watch support invoker
-                    LogPedantic("Waitable handle watch invoker event occurred");
+            case 3:
+                // Waitable handle watch support invoker
+                LogPedantic("Waitable handle watch invoker event occurred");
 
 
-                    // First, remove all previous handles
-                    while (handleList.size() > MIN_HANDLE_LIST_SIZE)
-                        handleList.pop_back();
+                // First, remove all previous handles
+                while (handleList.size() > MIN_HANDLE_LIST_SIZE) {
+                    handleList.pop_back();
+                }
 
 
-                    // Insert current waitable event handles instead
-                    {
-                        WaitableHandleListEx waitableHandleWatchHandles = WaitableHandleWatchSupport::WaitableWatcherHandles();
-                        std::copy(waitableHandleWatchHandles.begin(), waitableHandleWatchHandles.end(), std::back_inserter(handleList));
-                    }
+                // Insert current waitable event handles instead
+                {
+                    WaitableHandleListEx waitableHandleWatchHandles =
+                        WaitableHandleWatchSupport::WaitableWatcherHandles();
+                    std::copy(
+                        waitableHandleWatchHandles.begin(),
+                        waitableHandleWatchHandles.end(),
+                        std::back_inserter(handleList));
+                }
 
 
-                    // Handle invoker in waitable watch support
-                    WaitableHandleWatchSupport::InvokerFinished();
+                // Handle invoker in waitable watch support
+                WaitableHandleWatchSupport::InvokerFinished();
 
 
-                    LogPedantic("Waitable handle watch invoker event handled");
+                LogPedantic("Waitable handle watch invoker event handled");
 
 
-                    // Done
-                    break;
+                // Done
+                break;
 
 
-                default:
-                    // Waitable event watch list
-                    LogPedantic("Waitable handle watch event occurred");
+            default:
+                // Waitable event watch list
+                LogPedantic("Waitable handle watch event occurred");
 
 
-                    // Handle event in waitable handle watch
-                    {
-                        std::pair<WaitableHandle, WaitMode::Type> handle = handleList[index];
-                        WaitableHandleWatchSupport::HandleWatcher(handle.first, handle.second);
+                // Handle event in waitable handle watch
+                {
+                    std::pair<WaitableHandle,
+                              WaitMode::Type> handle = handleList[index];
+                    WaitableHandleWatchSupport::HandleWatcher(handle.first,
+                                                              handle.second);
+                }
+
+                if (m_directInvoke) {
+                    m_directInvoke = false;
+
+                    LogPedantic("Handling direct invoker");
+
+                    // Update list
+                    while (handleList.size() > MIN_HANDLE_LIST_SIZE) {
+                        handleList.pop_back();
                     }
 
                     }
 
-                    if (m_directInvoke)
+                    // Insert current waitable event handles instead
                     {
                     {
-                        m_directInvoke = false;
-
-                        LogPedantic("Handling direct invoker");
-
-                        // Update list
-                        while (handleList.size() > MIN_HANDLE_LIST_SIZE)
-                            handleList.pop_back();
-
-                        // Insert current waitable event handles instead
-                        {
-                            WaitableHandleListEx waitableHandleWatchHandles = 
-                                    WaitableHandleWatchSupport::
-                                        WaitableWatcherHandles();
-                            std::copy(waitableHandleWatchHandles.begin(),
-                                      waitableHandleWatchHandles.end(),
-                                      std::back_inserter(handleList));
-                        }
+                        WaitableHandleListEx waitableHandleWatchHandles =
+                            WaitableHandleWatchSupport::
+                                WaitableWatcherHandles();
+                        std::copy(waitableHandleWatchHandles.begin(),
+                                  waitableHandleWatchHandles.end(),
+                                  std::back_inserter(handleList));
                     }
                     }
+                }
 
 
-                    LogPedantic("Waitable handle watch event handled");
+                LogPedantic("Waitable handle watch event handled");
 
 
-                    // Done
-                    break;
+                // Done
+                break;
             }
         }
     }
             }
         }
     }
@@ -414,12 +459,14 @@ void Thread::Run()
     {
         Mutex::ScopedLock lock(&m_stateMutex);
 
     {
         Mutex::ScopedLock lock(&m_stateMutex);
 
-        if (m_running)
+        if (m_running) {
             return;
             return;
+        }
 
         // Try to create new thread
 
         // Try to create new thread
-        if (pthread_create(&m_thread, NULL, &StaticThreadEntry, this) != 0)
+        if (pthread_create(&m_thread, NULL, &StaticThreadEntry, this) != 0) {
             Throw(Exception::RunFailed);
             Throw(Exception::RunFailed);
+        }
 
         // At default, we abandon thread
         m_abandon = true;
 
         // At default, we abandon thread
         m_abandon = true;
@@ -440,8 +487,9 @@ void Thread::Quit()
         Mutex::ScopedLock lock(&m_stateMutex);
 
         // Is thread running ?
         Mutex::ScopedLock lock(&m_stateMutex);
 
         // Is thread running ?
-        if (!m_running)
+        if (!m_running) {
             return;
             return;
+        }
 
         LogPedantic("Quitting thread...");
 
 
         LogPedantic("Quitting thread...");
 
@@ -459,19 +507,24 @@ void Thread::Quit()
     // Wait for joinable thread
     void *result;
 
     // Wait for joinable thread
     void *result;
 
-    if (pthread_join(joinableThread, &result) != 0)
+    if (pthread_join(joinableThread, &result) != 0) {
         Throw(Exception::QuitFailed);
         Throw(Exception::QuitFailed);
+    }
 
     LogPedantic("Thread quit");
 }
 
 
     LogPedantic("Thread quit");
 }
 
-void Thread::PushEvent(void *event, EventDispatchProc eventDispatchProc, EventDeleteProc eventDeleteProc, void *userParam)
+void Thread::PushEvent(void *event,
+                       EventDispatchProc eventDispatchProc,
+                       EventDeleteProc eventDeleteProc,
+                       void *userParam)
 {
     // Enter event list critical section
     Mutex::ScopedLock lock(&m_eventMutex);
 
     // Push new event
 {
     // Enter event list critical section
     Mutex::ScopedLock lock(&m_eventMutex);
 
     // Push new event
-    m_eventList.push_back(InternalEvent(event, userParam, eventDispatchProc, eventDeleteProc));
+    m_eventList.push_back(InternalEvent(event, userParam, eventDispatchProc,
+                                        eventDeleteProc));
 
     // Trigger invoker
     m_eventInvoker.Signal();
 
     // Trigger invoker
     m_eventInvoker.Signal();
@@ -479,7 +532,11 @@ void Thread::PushEvent(void *event, EventDispatchProc eventDispatchProc, EventDe
     LogPedantic("Event pushed and invoker signaled");
 }
 
     LogPedantic("Event pushed and invoker signaled");
 }
 
-void Thread::PushTimedEvent(void *event, double dueTimeSeconds, EventDispatchProc eventDispatchProc, EventDeleteProc eventDeleteProc, void *userParam)
+void Thread::PushTimedEvent(void *event,
+                            double dueTimeSeconds,
+                            EventDispatchProc eventDispatchProc,
+                            EventDeleteProc eventDeleteProc,
+                            void *userParam)
 {
     // Check for developer errors
     Assert(dueTimeSeconds >= 0.0);
 {
     // Check for developer errors
     Assert(dueTimeSeconds >= 0.0);
@@ -491,10 +548,15 @@ void Thread::PushTimedEvent(void *event, double dueTimeSeconds, EventDispatchPro
     unsigned long currentTimeMiliseconds = GetCurrentTimeMiliseconds();
 
     // Convert to miliseconds
     unsigned long currentTimeMiliseconds = GetCurrentTimeMiliseconds();
 
     // Convert to miliseconds
-    unsigned long dueTimeMiliseconds = static_cast<unsigned long>(1000.0 * dueTimeSeconds);
+    unsigned long dueTimeMiliseconds =
+        static_cast<unsigned long>(1000.0 * dueTimeSeconds);
 
     // Push new timed event
 
     // Push new timed event
-    m_timedEventVector.push_back(InternalTimedEvent(event, userParam, dueTimeMiliseconds, currentTimeMiliseconds, eventDispatchProc, eventDeleteProc));
+    m_timedEventVector.push_back(InternalTimedEvent(event, userParam,
+                                                    dueTimeMiliseconds,
+                                                    currentTimeMiliseconds,
+                                                    eventDispatchProc,
+                                                    eventDeleteProc));
 
     // Heapify timed events
     std::make_heap(m_timedEventVector.begin(), m_timedEventVector.end());
 
     // Heapify timed events
     std::make_heap(m_timedEventVector.begin(), m_timedEventVector.end());
@@ -502,7 +564,10 @@ void Thread::PushTimedEvent(void *event, double dueTimeSeconds, EventDispatchPro
     // Trigger invoker
     m_timedEventInvoker.Signal();
 
     // Trigger invoker
     m_timedEventInvoker.Signal();
 
-    LogPedantic("Timed event pushed and invoker signaled: due time: " << dueTimeMiliseconds << " ms, absolute due time: " << currentTimeMiliseconds + dueTimeMiliseconds << " ms");
+    LogPedantic(
+        "Timed event pushed and invoker signaled: due time: " <<
+        dueTimeMiliseconds << " ms, absolute due time: " <<
+        currentTimeMiliseconds + dueTimeMiliseconds << " ms");
 }
 
 Thread *Thread::GetInvokerThread()
 }
 
 Thread *Thread::GetInvokerThread()
@@ -519,7 +584,7 @@ void Thread::HandleDirectInvoker()
 
 void Thread::Sleep(uint64_t seconds)
 {
 
 void Thread::Sleep(uint64_t seconds)
 {
-   NanoSleep(seconds * NANOSECONDS_PER_SECOND);
+    NanoSleep(seconds * NANOSECONDS_PER_SECOND);
 }
 
 void Thread::MiliSleep(uint64_t miliseconds)
 }
 
 void Thread::MiliSleep(uint64_t miliseconds)
@@ -534,8 +599,7 @@ void Thread::MicroSleep(uint64_t microseconds)
 
 void Thread::NanoSleep(uint64_t nanoseconds)
 {
 
 void Thread::NanoSleep(uint64_t nanoseconds)
 {
-    timespec requestedTime =
-    {
+    timespec requestedTime = {
         static_cast<time_t>(
             nanoseconds / NANOSECONDS_PER_SECOND),
 
         static_cast<time_t>(
             nanoseconds / NANOSECONDS_PER_SECOND),
 
@@ -545,10 +609,10 @@ void Thread::NanoSleep(uint64_t nanoseconds)
 
     timespec remainingTime;
 
 
     timespec remainingTime;
 
-    for (;;)
-    {
-        if (nanosleep(&requestedTime, &remainingTime) == 0)
+    for (;;) {
+        if (nanosleep(&requestedTime, &remainingTime) == 0) {
             break;
             break;
+        }
 
         int error = errno;
         Assert(error == EINTR);
 
         int error = errno;
         Assert(error == EINTR);
index 8eeb106..fa94806 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       Generic type list template
  */
  * @version     1.0
  * @brief       Generic type list template
  */
+#include <stddef.h>
 #include <dpl/type_list.h>
 
 //
 #include <dpl/type_list.h>
 
 //
index b79b622..ffcb499 100644 (file)
@@ -19,6 +19,7 @@
  * @version 1.0
  * @brief   Implementation file for union cast
  */
  * @version 1.0
  * @brief   Implementation file for union cast
  */
+#include <stddef.h>
 #include <dpl/union_cast.h>
 
 //
 #include <dpl/union_cast.h>
 
 //
index 6bb021c..4808896 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of waitable event
  */
  * @version     1.0
  * @brief       This file is the implementation file of waitable event
  */
+#include <stddef.h>
 #include <dpl/waitable_event.h>
 #include <sys/select.h>
 #include <unistd.h>
 #include <dpl/waitable_event.h>
 #include <sys/select.h>
 #include <unistd.h>
 #include <errno.h>
 #include <errno.h>
 
 #include <errno.h>
 #include <errno.h>
 
-namespace DPL
-{
+namespace DPL {
 WaitableEvent::WaitableEvent()
 {
 WaitableEvent::WaitableEvent()
 {
-    if (pipe(m_pipe) == -1)
+    if (pipe(m_pipe) == -1) {
         Throw(Exception::CreateFailed);
         Throw(Exception::CreateFailed);
+    }
 
 
-    if (fcntl(m_pipe[0], F_SETFL, O_NONBLOCK | fcntl(m_pipe[0], F_GETFL)) == -1)
+    if (fcntl(m_pipe[0], F_SETFL, O_NONBLOCK |
+              fcntl(m_pipe[0], F_GETFL)) == -1)
+    {
         Throw(Exception::CreateFailed);
         Throw(Exception::CreateFailed);
+    }
 }
 
 WaitableEvent::~WaitableEvent()
 {
 }
 
 WaitableEvent::~WaitableEvent()
 {
-    if (TEMP_FAILURE_RETRY(close(m_pipe[0])) == -1)
+    if (TEMP_FAILURE_RETRY(close(m_pipe[0])) == -1) {
         Throw(Exception::DestroyFailed);
         Throw(Exception::DestroyFailed);
+    }
 
 
-    if (TEMP_FAILURE_RETRY(close(m_pipe[1])) == -1)
+    if (TEMP_FAILURE_RETRY(close(m_pipe[1])) == -1) {
         Throw(Exception::DestroyFailed);
         Throw(Exception::DestroyFailed);
+    }
 }
 
 WaitableHandle WaitableEvent::GetHandle() const
 }
 
 WaitableHandle WaitableEvent::GetHandle() const
@@ -55,15 +61,17 @@ void WaitableEvent::Signal() const
 {
     char data = 0;
 
 {
     char data = 0;
 
-    if (TEMP_FAILURE_RETRY(write(m_pipe[1], &data, 1)) != 1)
+    if (TEMP_FAILURE_RETRY(write(m_pipe[1], &data, 1)) != 1) {
         Throw(Exception::SignalFailed);
         Throw(Exception::SignalFailed);
+    }
 }
 
 void WaitableEvent::Reset() const
 {
     char data;
 
 }
 
 void WaitableEvent::Reset() const
 {
     char data;
 
-    if (TEMP_FAILURE_RETRY(read(m_pipe[0], &data, 1)) != 1)
+    if (TEMP_FAILURE_RETRY(read(m_pipe[0], &data, 1)) != 1) {
         Throw(Exception::ResetFailed);
         Throw(Exception::ResetFailed);
+    }
 }
 } // namespace DPL
 }
 } // namespace DPL
index faaea42..2894022 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of waitable handle
  */
  * @version     1.0
  * @brief       This file is the implementation file of waitable handle
  */
+#include <stddef.h>
 #include <dpl/waitable_event.h>
 #include <dpl/workaround.h>
 #include <dpl/log/log.h>
 #include <dpl/waitable_event.h>
 #include <dpl/workaround.h>
 #include <dpl/log/log.h>
@@ -28,8 +29,7 @@
 #include <errno.h>
 #include <dpl/assert.h>
 
 #include <errno.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 void CheckWaitableHandle(WaitableHandle handle)
 namespace // anonymous
 {
 void CheckWaitableHandle(WaitableHandle handle)
@@ -38,29 +38,35 @@ void CheckWaitableHandle(WaitableHandle handle)
     // Try to get descriptor flags
     int result = fcntl(handle, F_GETFL);
 
     // Try to get descriptor flags
     int result = fcntl(handle, F_GETFL);
 
-    if (result == -1 && errno == EBADF)
+    if (result == -1 && errno == EBADF) {
         Assert(0 && "CheckWaitableHandle: Invalid WaitableHandle! (EBADF)");
         Assert(0 && "CheckWaitableHandle: Invalid WaitableHandle! (EBADF)");
+    }
 
     Assert(result != -1 && "CheckWaitableHandle: Invalid WaitableHandle!");
 #endif // DPL_ENABLE_WAITABLE_HANDLE_BADF_CHECK
 }
 } // namespace anonymous
 
 
     Assert(result != -1 && "CheckWaitableHandle: Invalid WaitableHandle!");
 #endif // DPL_ENABLE_WAITABLE_HANDLE_BADF_CHECK
 }
 } // namespace anonymous
 
-WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle, unsigned long miliseconds)
+WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle,
+                                            unsigned long miliseconds)
 {
     WaitableHandleList waitHandles;
     waitHandles.push_back(handle);
     return WaitForMultipleHandles(waitHandles, miliseconds);
 }
 
 {
     WaitableHandleList waitHandles;
     waitHandles.push_back(handle);
     return WaitForMultipleHandles(waitHandles, miliseconds);
 }
 
-WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle, WaitMode::Type mode, unsigned long miliseconds)
+WaitableHandleIndexList WaitForSingleHandle(WaitableHandle handle,
+                                            WaitMode::Type mode,
+                                            unsigned long miliseconds)
 {
     WaitableHandleListEx waitHandles;
     waitHandles.push_back(std::make_pair(handle, mode));
     return WaitForMultipleHandles(waitHandles, miliseconds);
 }
 
 {
     WaitableHandleListEx waitHandles;
     waitHandles.push_back(std::make_pair(handle, mode));
     return WaitForMultipleHandles(waitHandles, miliseconds);
 }
 
-WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleList &waitableHandleList, unsigned long miliseconds)
+WaitableHandleIndexList WaitForMultipleHandles(
+    const WaitableHandleList &waitableHandleList,
+    unsigned long miliseconds)
 {
     WaitableHandleListEx handleList;
 
 {
     WaitableHandleListEx handleList;
 
@@ -76,7 +82,9 @@ WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleList &waitabl
     return WaitForMultipleHandles(handleList, miliseconds);
 }
 
     return WaitForMultipleHandles(handleList, miliseconds);
 }
 
-WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleListEx &waitableHandleListEx, unsigned long miliseconds)
+WaitableHandleIndexList WaitForMultipleHandles(
+    const WaitableHandleListEx &waitableHandleListEx,
+    unsigned long miliseconds)
 {
     fd_set readFds, writeFds, errorFds;
 
 {
     fd_set readFds, writeFds, errorFds;
 
@@ -88,24 +96,23 @@ WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleListEx &waita
     FD_ZERO(&errorFds);
 
     // Add read wait handles
     FD_ZERO(&errorFds);
 
     // Add read wait handles
-    for (WaitableHandleListEx::const_iterator iterator = waitableHandleListEx.begin();
+    for (WaitableHandleListEx::const_iterator iterator =
+             waitableHandleListEx.begin();
          iterator != waitableHandleListEx.end();
          ++iterator)
     {
          iterator != waitableHandleListEx.end();
          ++iterator)
     {
-        if (iterator->first > maxFd)
+        if (iterator->first > maxFd) {
             maxFd = iterator->first;
             maxFd = iterator->first;
+        }
 
         CheckWaitableHandle(iterator->first);
 
         // Handle errors along with read and write events
         FD_SET(iterator->first, &errorFds);
 
 
         CheckWaitableHandle(iterator->first);
 
         // Handle errors along with read and write events
         FD_SET(iterator->first, &errorFds);
 
-        if (iterator->second == WaitMode::Read)
-        {
+        if (iterator->second == WaitMode::Read) {
             FD_SET(iterator->first, &readFds);
             FD_SET(iterator->first, &readFds);
-        }
-        else if (iterator->second == WaitMode::Write)
-        {
+        } else if (iterator->second == WaitMode::Write) {
             FD_SET(iterator->first, &writeFds);
         }
     }
             FD_SET(iterator->first, &writeFds);
         }
     }
@@ -119,30 +126,32 @@ WaitableHandleIndexList WaitForMultipleHandles(const WaitableHandleListEx &waita
         effectiveTimeout = &timeout;
     }
 
         effectiveTimeout = &timeout;
     }
 
-    if (TEMP_FAILURE_RETRY(select(maxFd + 1, &readFds, &writeFds, &errorFds, effectiveTimeout)) == -1)
+    if (TEMP_FAILURE_RETRY(select(maxFd + 1, &readFds, &writeFds, &errorFds,
+                                  effectiveTimeout)) == -1)
+    {
         Throw(WaitFailed);
         Throw(WaitFailed);
+    }
 
     // Check results
     WaitableHandleIndexList indexes;
     size_t index = 0;
 
 
     // Check results
     WaitableHandleIndexList indexes;
     size_t index = 0;
 
-    for (WaitableHandleListEx::const_iterator iterator = waitableHandleListEx.begin();
+    for (WaitableHandleListEx::const_iterator iterator =
+             waitableHandleListEx.begin();
          iterator != waitableHandleListEx.end();
          ++iterator)
     {
         // Always return errors, no matter what type of listening is set
         if (FD_ISSET(iterator->first, &errorFds)) {
             indexes.push_back(index);
          iterator != waitableHandleListEx.end();
          ++iterator)
     {
         // Always return errors, no matter what type of listening is set
         if (FD_ISSET(iterator->first, &errorFds)) {
             indexes.push_back(index);
-        }
-        else if (iterator->second == WaitMode::Read)
-        {
-            if (FD_ISSET(iterator->first, &readFds))
+        } else if (iterator->second == WaitMode::Read) {
+            if (FD_ISSET(iterator->first, &readFds)) {
                 indexes.push_back(index);
                 indexes.push_back(index);
-        }
-        else if (iterator->second == WaitMode::Write)
-        {
-            if (FD_ISSET(iterator->first, &writeFds))
+            }
+        } else if (iterator->second == WaitMode::Write) {
+            if (FD_ISSET(iterator->first, &writeFds)) {
                 indexes.push_back(index);
                 indexes.push_back(index);
+            }
         }
         ++index;
     }
         }
         ++index;
     }
index 19c10e7..53f8b65 100644 (file)
  * @file        waitable_handle_watch_support.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        waitable_handle_watch_support.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of waitable handle watch support
+ * @brief       This file is the implementation file of waitable handle watch
+ * support
  */
  */
+#include <stddef.h>
 #include <dpl/waitable_handle_watch_support.h>
 #include <dpl/thread.h>
 #include <dpl/main.h>
 #include <dpl/waitable_handle_watch_support.h>
 #include <dpl/thread.h>
 #include <dpl/main.h>
 #include <algorithm>
 #include <dpl/assert.h>
 
 #include <algorithm>
 #include <dpl/assert.h>
 
-namespace DPL
-{
+namespace DPL {
 WaitableHandleWatchSupport::WaitableHandleWatchSupport()
 WaitableHandleWatchSupport::WaitableHandleWatchSupport()
-{
-}
+{}
 
 WaitableHandleWatchSupport::~WaitableHandleWatchSupport()
 {
     // Developer assertions
 
 WaitableHandleWatchSupport::~WaitableHandleWatchSupport()
 {
     // Developer assertions
-    if (!m_watchersMap.empty())
-    {
-        LogPedantic("### Leaked watchers map dump ###");
+    if (!m_watchersMap.empty()) {
+        LogWarning("### Leaked watchers map dump ###");
 
 
-        for (WaitableHandleWatchersMap::const_iterator iterator = m_watchersMap.begin();
+        for (WaitableHandleWatchersMap::const_iterator iterator =
+                 m_watchersMap.begin();
              iterator != m_watchersMap.end();
              ++iterator)
         {
              iterator != m_watchersMap.end();
              ++iterator)
         {
-            LogPedantic("###   Waitable handle: " << iterator->first);
+            LogWarning("###   Waitable handle: " << iterator->first);
 
 
-            LogPedantic("###     Read listeners: " << iterator->second.readListenersCount);
-            LogPedantic("###     Write listeners: " << iterator->second.writeListenersCount);
+            LogWarning(
+                "###     Read listeners: " <<
+                iterator->second.readListenersCount);
+            LogWarning(
+                "###     Write listeners: " <<
+                iterator->second.writeListenersCount);
 
 
-            for (WaitableHandleListenerList::const_iterator listenersIterator = iterator->second.listeners.begin();
+            for (WaitableHandleListenerList::const_iterator listenersIterator =
+                     iterator->second.listeners.begin();
                  listenersIterator != iterator->second.listeners.end();
                  ++listenersIterator)
             {
                  listenersIterator != iterator->second.listeners.end();
                  ++listenersIterator)
             {
-                LogPedantic("###       Mode: " << listenersIterator->mode << ". Listener: 0x" << std::hex << listenersIterator->listener);
+                LogWarning(
+                    "###       Mode: " << listenersIterator->mode <<
+                    ". Listener: 0x" << std::hex << listenersIterator->listener);
             }
         }
     }
             }
         }
     }
-
-    Assert(m_watchersMap.empty() == true);
 }
 
 WaitableHandle WaitableHandleWatchSupport::WaitableInvokerHandle() const
 }
 
 WaitableHandle WaitableHandleWatchSupport::WaitableInvokerHandle() const
@@ -73,18 +78,23 @@ WaitableHandleListEx WaitableHandleWatchSupport::WaitableWatcherHandles() const
 
         WaitableHandleListEx handleList;
 
 
         WaitableHandleListEx handleList;
 
-        for (WaitableHandleWatchersMap::const_iterator iterator = m_watchersMap.begin();
+        for (WaitableHandleWatchersMap::const_iterator iterator =
+                 m_watchersMap.begin();
              iterator != m_watchersMap.end();
              ++iterator)
         {
             // Register waitable event id for wait
             // Check if there are any read listeners and write listeners
             // and register for both if applicable
              iterator != m_watchersMap.end();
              ++iterator)
         {
             // Register waitable event id for wait
             // Check if there are any read listeners and write listeners
             // and register for both if applicable
-            if (iterator->second.readListenersCount > 0)
-                handleList.push_back(std::make_pair(iterator->first, WaitMode::Read));
+            if (iterator->second.readListenersCount > 0) {
+                handleList.push_back(std::make_pair(iterator->first,
+                                                    WaitMode::Read));
+            }
 
 
-            if (iterator->second.writeListenersCount > 0)
-                handleList.push_back(std::make_pair(iterator->first, WaitMode::Write));
+            if (iterator->second.writeListenersCount > 0) {
+                handleList.push_back(std::make_pair(iterator->first,
+                                                    WaitMode::Write));
+            }
         }
 
         return handleList;
         }
 
         return handleList;
@@ -102,13 +112,15 @@ void WaitableHandleWatchSupport::InvokerFinished()
     m_watchersInvokerCommit.Signal();
 }
 
     m_watchersInvokerCommit.Signal();
 }
 
-void WaitableHandleWatchSupport::HandleWatcher(WaitableHandle waitableHandle, WaitMode::Type mode)
+void WaitableHandleWatchSupport::HandleWatcher(WaitableHandle waitableHandle,
+                                               WaitMode::Type mode)
 {
     //
     // Waitable event occurred
     // Now call all listeners for that waitable event. It is possible
     // that some of listeners early disappeared. This is not a problem.
 {
     //
     // Waitable event occurred
     // Now call all listeners for that waitable event. It is possible
     // that some of listeners early disappeared. This is not a problem.
-    // Warning: Listeners and/or watcher may also disappear during dispatching handlers!
+    // Warning: Listeners and/or watcher may also disappear during dispatching
+    // handlers!
     //
     LogPedantic("Waitable event occurred");
 
     //
     LogPedantic("Waitable event occurred");
 
@@ -116,44 +128,58 @@ void WaitableHandleWatchSupport::HandleWatcher(WaitableHandle waitableHandle, Wa
     {
         RecursiveMutex::ScopedLock lock(&m_watchersMutex);
 
     {
         RecursiveMutex::ScopedLock lock(&m_watchersMutex);
 
-        // Notice: We must carefully call watchers here as they may disappear (zero listeners) or be created during each of handler call
-        //         All removed listeners are handled correctly. Adding additional listener to the same waitable handle
+        // Notice: We must carefully call watchers here as they may disappear
+        // (zero listeners) or be created during each of handler call
+        //         All removed listeners are handled correctly. Adding
+        // additional listener to the same waitable handle
         //         during handler dispatch sequence is _not_ supported.
         WaitableHandleWatchersMap trackedWatchers = m_watchersMap;
 
         //         during handler dispatch sequence is _not_ supported.
         WaitableHandleWatchersMap trackedWatchers = m_watchersMap;
 
-        for (WaitableHandleWatchersMap::const_iterator trackedWatchersIterator = trackedWatchers.begin();
+        for (WaitableHandleWatchersMap::const_iterator trackedWatchersIterator
+                 = trackedWatchers.begin();
              trackedWatchersIterator != trackedWatchers.end();
              ++trackedWatchersIterator)
         {
             // Check if this watcher still exists
             // If not, go to next tracked watcher
              trackedWatchersIterator != trackedWatchers.end();
              ++trackedWatchersIterator)
         {
             // Check if this watcher still exists
             // If not, go to next tracked watcher
-            if (m_watchersMap.find(trackedWatchersIterator->first) == m_watchersMap.end())
+            if (m_watchersMap.find(trackedWatchersIterator->first) ==
+                m_watchersMap.end())
             {
                 LogPedantic("Watcher disappeared during watcher handler");
                 continue;
             }
 
             // Is this is a waitable handle that we are searching for ?
             {
                 LogPedantic("Watcher disappeared during watcher handler");
                 continue;
             }
 
             // Is this is a waitable handle that we are searching for ?
-            if (waitableHandle != trackedWatchersIterator->first)
+            if (waitableHandle != trackedWatchersIterator->first) {
                 continue;
                 continue;
+            }
 
             // Track watcher listeners list
 
             // Track watcher listeners list
-            WaitableHandleListenerList trackedListeners = trackedWatchersIterator->second.listeners;
+            WaitableHandleListenerList trackedListeners =
+                trackedWatchersIterator->second.listeners;
+
+            LogPedantic(
+                "Calling waitable event listeners (" <<
+                trackedListeners.size() << ")...");
 
 
-            LogPedantic("Calling waitable event listeners (" << trackedListeners.size() << ")...");
+            // Notice: We must carefully call listeners here as they may
+            // disappear or be created during each of handler call
+            //         All removed listeners are handled correctly. Adding
+            // additional listener to the same waitable handle
+            //         during handler dispatch sequence is should be also
+            // handled, as an extremly case.
 
 
-            // Notice: We must carefully call listeners here as they may disappear or be created during each of handler call
-            //         All removed listeners are handled correctly. Adding additional listener to the same waitable handle
-            //         during handler dispatch sequence is should be also handled, as an extremly case.
             // Call all waitable event listeners who listen for that event
             // Call all waitable event listeners who listen for that event
-            for (WaitableHandleListenerList::const_iterator trackedListenersIterator = trackedListeners.begin();
+            for (WaitableHandleListenerList::const_iterator
+                 trackedListenersIterator = trackedListeners.begin();
                  trackedListenersIterator != trackedListeners.end();
                  ++trackedListenersIterator)
             {
                 // Check if this watcher still exists
                  trackedListenersIterator != trackedListeners.end();
                  ++trackedListenersIterator)
             {
                 // Check if this watcher still exists
-                // If not, there cannot be another one. Must exit now (after break, we actually exit)
-                if (m_watchersMap.find(trackedWatchersIterator->first) == m_watchersMap.end())
+                // If not, there cannot be another one. Must exit now (after
+                // break, we actually exit)
+                if (m_watchersMap.find(trackedWatchersIterator->first) ==
+                    m_watchersMap.end())
                 {
                     LogPedantic("Watcher disappeared during watcher handler");
                     break;
                 {
                     LogPedantic("Watcher disappeared during watcher handler");
                     break;
@@ -163,31 +189,39 @@ void WaitableHandleWatchSupport::HandleWatcher(WaitableHandle waitableHandle, Wa
                 // If not, go to next tracked watcher listener
                 bool listenerStillExists = false;
 
                 // If not, go to next tracked watcher listener
                 bool listenerStillExists = false;
 
-                for (WaitableHandleListenerList::const_iterator searchListenerIterator = trackedWatchersIterator->second.listeners.begin();
-                     searchListenerIterator != trackedWatchersIterator->second.listeners.end();
+                for (WaitableHandleListenerList::const_iterator
+                     searchListenerIterator =
+                         trackedWatchersIterator->second.listeners.begin();
+                     searchListenerIterator !=
+                     trackedWatchersIterator->second.listeners.end();
                      ++searchListenerIterator)
                 {
                      ++searchListenerIterator)
                 {
-                    if (searchListenerIterator->listener == trackedListenersIterator->listener &&
-                        searchListenerIterator->mode == trackedListenersIterator->mode)
+                    if (searchListenerIterator->listener ==
+                        trackedListenersIterator->listener &&
+                        searchListenerIterator->mode ==
+                        trackedListenersIterator->mode)
                     {
                         listenerStillExists = true;
                         break;
                     }
                 }
 
                     {
                         listenerStillExists = true;
                         break;
                     }
                 }
 
-                if (!listenerStillExists)
-                {
-                    LogPedantic("Watcher listener disappeared during watcher handler");
+                if (!listenerStillExists) {
+                    LogPedantic(
+                        "Watcher listener disappeared during watcher handler");
                     break;
                 }
 
                 // Is this is a listener mode that we are searching for ?
                     break;
                 }
 
                 // Is this is a listener mode that we are searching for ?
-                if (mode != trackedListenersIterator->mode)
+                if (mode != trackedListenersIterator->mode) {
                     continue;
                     continue;
+                }
 
                 // Call waitable event watch listener
                 LogPedantic("Before tracker listener call...");
 
                 // Call waitable event watch listener
                 LogPedantic("Before tracker listener call...");
-                trackedListenersIterator->listener->OnWaitableHandleEvent(trackedWatchersIterator->first, trackedListenersIterator->mode);
+                trackedListenersIterator->listener->OnWaitableHandleEvent(
+                    trackedWatchersIterator->first,
+                    trackedListenersIterator->mode);
                 LogPedantic("After tracker listener call...");
             }
 
                 LogPedantic("After tracker listener call...");
             }
 
@@ -202,47 +236,56 @@ void WaitableHandleWatchSupport::HandleWatcher(WaitableHandle waitableHandle, Wa
     }
 }
 
     }
 }
 
-void WaitableHandleWatchSupport::AddWaitableHandleWatch(WaitableHandleListener* listener, WaitableHandle waitableHandle, WaitMode::Type mode)
+void WaitableHandleWatchSupport::AddWaitableHandleWatch(
+    WaitableHandleListener* listener,
+    WaitableHandle waitableHandle,
+    WaitMode::Type mode)
 {
     // Enter waitable event list critical section
     RecursiveMutex::ScopedLock lock(&m_watchersMutex);
 
     // Find proper list to register into
 {
     // Enter waitable event list critical section
     RecursiveMutex::ScopedLock lock(&m_watchersMutex);
 
     // Find proper list to register into
-    WaitableHandleWatchersMap::iterator mapIterator = m_watchersMap.find(waitableHandle);
-
-    if (mapIterator != m_watchersMap.end())
-    {
-        // Assert if there is no such listener already that is listening in this mode
-        for (WaitableHandleListenerList::iterator listenersIterator = mapIterator->second.listeners.begin();
+    WaitableHandleWatchersMap::iterator mapIterator = m_watchersMap.find(
+            waitableHandle);
+
+    if (mapIterator != m_watchersMap.end()) {
+        // Assert if there is no such listener already that is listening in this
+        // mode
+        for (WaitableHandleListenerList::iterator listenersIterator =
+                 mapIterator->second.listeners.begin();
              listenersIterator != mapIterator->second.listeners.end();
              ++listenersIterator)
         {
             // Must not insert same listener-mode pair
              listenersIterator != mapIterator->second.listeners.end();
              ++listenersIterator)
         {
             // Must not insert same listener-mode pair
-            Assert(listenersIterator->listener != listener || listenersIterator->mode != mode);
+            Assert(
+                listenersIterator->listener != listener ||
+                listenersIterator->mode != mode);
         }
     }
 
     LogPedantic("Adding waitable handle watch: " << waitableHandle);
 
     // Push new waitable event watch
         }
     }
 
     LogPedantic("Adding waitable handle watch: " << waitableHandle);
 
     // Push new waitable event watch
-    if (mapIterator != m_watchersMap.end())
-        mapIterator->second.listeners.push_back(WaitableHandleWatcher(listener, mode));
-    else
-        m_watchersMap[waitableHandle].listeners.push_back(WaitableHandleWatcher(listener, mode));
+    if (mapIterator != m_watchersMap.end()) {
+        mapIterator->second.listeners.push_back(WaitableHandleWatcher(listener,
+                                                                      mode));
+    } else {
+        m_watchersMap[waitableHandle].listeners.push_back(WaitableHandleWatcher(
+                                                              listener, mode));
+    }
 
     // Update counters
 
     // Update counters
-    switch (mode)
-    {
-        case WaitMode::Read:
-            m_watchersMap[waitableHandle].readListenersCount++;
-            break;
+    switch (mode) {
+    case WaitMode::Read:
+        m_watchersMap[waitableHandle].readListenersCount++;
+        break;
 
 
-        case WaitMode::Write:
-            m_watchersMap[waitableHandle].writeListenersCount++;
-            break;
+    case WaitMode::Write:
+        m_watchersMap[waitableHandle].writeListenersCount++;
+        break;
 
 
-        default:
-            Assert(0);
+    default:
+        Assert(0);
     }
 
     // Trigger waitable event invoker to commit changes
     }
 
     // Trigger waitable event invoker to commit changes
@@ -251,25 +294,32 @@ void WaitableHandleWatchSupport::AddWaitableHandleWatch(WaitableHandleListener*
     LogPedantic("Waitable event watch added and invoker signaled");
 }
 
     LogPedantic("Waitable event watch added and invoker signaled");
 }
 
-void WaitableHandleWatchSupport::RemoveWaitableHandleWatch(WaitableHandleListener *listener, WaitableHandle waitableHandle, WaitMode::Type mode)
+void WaitableHandleWatchSupport::RemoveWaitableHandleWatch(
+    WaitableHandleListener *listener,
+    WaitableHandle waitableHandle,
+    WaitMode::Type mode)
 {
     // Enter waitable event list critical section
     RecursiveMutex::ScopedLock lock(&m_watchersMutex);
 
     // Find proper list with listener
 {
     // Enter waitable event list critical section
     RecursiveMutex::ScopedLock lock(&m_watchersMutex);
 
     // Find proper list with listener
-    WaitableHandleWatchersMap::iterator mapIterator = m_watchersMap.find(waitableHandle);
+    WaitableHandleWatchersMap::iterator mapIterator = m_watchersMap.find(
+            waitableHandle);
 
     Assert(mapIterator != m_watchersMap.end());
 
     // Assert if there is such listener and mode
 
     Assert(mapIterator != m_watchersMap.end());
 
     // Assert if there is such listener and mode
-    WaitableHandleListenerList::iterator listIterator = mapIterator->second.listeners.end();
+    WaitableHandleListenerList::iterator listIterator =
+        mapIterator->second.listeners.end();
 
 
-    for (WaitableHandleListenerList::iterator listenersIterator = mapIterator->second.listeners.begin();
+    for (WaitableHandleListenerList::iterator listenersIterator =
+             mapIterator->second.listeners.begin();
          listenersIterator != mapIterator->second.listeners.end();
          ++listenersIterator)
     {
         // Check same pair listener-mode
          listenersIterator != mapIterator->second.listeners.end();
          ++listenersIterator)
     {
         // Check same pair listener-mode
-        if (listenersIterator->listener == listener && listenersIterator->mode == mode)
+        if (listenersIterator->listener == listener &&
+            listenersIterator->mode == mode)
         {
             listIterator = listenersIterator;
             break;
         {
             listIterator = listenersIterator;
             break;
@@ -280,28 +330,28 @@ void WaitableHandleWatchSupport::RemoveWaitableHandleWatch(WaitableHandleListene
     Assert(listIterator != mapIterator->second.listeners.end());
 
     LogPedantic("Removing waitable handle watch: " << waitableHandle);
     Assert(listIterator != mapIterator->second.listeners.end());
 
     LogPedantic("Removing waitable handle watch: " << waitableHandle);
-  
+
     // Remove waitable event watch
     mapIterator->second.listeners.erase(listIterator);
 
     // Update counters
     // Remove waitable event watch
     mapIterator->second.listeners.erase(listIterator);
 
     // Update counters
-    switch (mode)
-    {
-        case WaitMode::Read:
-            mapIterator->second.readListenersCount--;
-            break;
+    switch (mode) {
+    case WaitMode::Read:
+        mapIterator->second.readListenersCount--;
+        break;
 
 
-        case WaitMode::Write:
-            mapIterator->second.writeListenersCount--;
-            break;
+    case WaitMode::Write:
+        mapIterator->second.writeListenersCount--;
+        break;
 
 
-        default:
-            Assert(0);
+    default:
+        Assert(0);
     }
 
     // If list is empty, remove it too
     }
 
     // If list is empty, remove it too
-    if (mapIterator->second.listeners.empty())
+    if (mapIterator->second.listeners.empty()) {
         m_watchersMap.erase(mapIterator);
         m_watchersMap.erase(mapIterator);
+    }
 
     // Trigger waitable event invoker to commit changes
     CommitInvoker();
 
     // Trigger waitable event invoker to commit changes
     CommitInvoker();
@@ -312,15 +362,12 @@ void WaitableHandleWatchSupport::RemoveWaitableHandleWatch(WaitableHandleListene
 void WaitableHandleWatchSupport::CommitInvoker()
 {
     // Check calling context and execute invoker
 void WaitableHandleWatchSupport::CommitInvoker()
 {
     // Check calling context and execute invoker
-    if (Thread::GetCurrentThread() == GetInvokerThread())
-    {
+    if (Thread::GetCurrentThread() == GetInvokerThread()) {
         LogPedantic("Calling direct invoker");
 
         // Direct invoker call
         HandleDirectInvoker();
         LogPedantic("Calling direct invoker");
 
         // Direct invoker call
         HandleDirectInvoker();
-    }
-    else
-    {
+    } else {
         LogPedantic("Calling indirect invoker");
 
         // Indirect invoker call
         LogPedantic("Calling indirect invoker");
 
         // Indirect invoker call
@@ -338,9 +385,10 @@ WaitableHandleWatchSupport *WaitableHandleWatchSupport::InheritedContext()
 {
     // In threaded context, return thread waitable handle watch implementation
     // In main loop, return main waitable handle watch implementation
 {
     // In threaded context, return thread waitable handle watch implementation
     // In main loop, return main waitable handle watch implementation
-    if (Thread::GetCurrentThread() != NULL)
+    if (Thread::GetCurrentThread() != NULL) {
         return Thread::GetCurrentThread();
         return Thread::GetCurrentThread();
-    else
+    } else {
         return &MainSingleton::Instance();
         return &MainSingleton::Instance();
+    }
 }
 } // namespace DPL
 }
 } // namespace DPL
index d862c01..4023ed8 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of zip input
  */
  * @version     1.0
  * @brief       This file is the implementation file of zip input
  */
+#include <stddef.h>
+#include <iomanip>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
 #include <dpl/zip_input.h>
 #include <dpl/zip_input.h>
-#include <dpl/file_input_mapping.h>
+#include <dpl/scoped_close.h>
 #include <dpl/binary_queue.h>
 #include <dpl/scoped_free.h>
 #include <dpl/binary_queue.h>
 #include <dpl/scoped_free.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
 #include <dpl/scoped_array.h>
 #include <dpl/foreach.h>
 #include <dpl/log/log.h>
 #include <minizip/framework_minizip.h>
 #include <new>
 
 #include <dpl/scoped_array.h>
 #include <dpl/foreach.h>
 #include <dpl/log/log.h>
 #include <minizip/framework_minizip.h>
 #include <new>
 
-namespace DPL
-{
+namespace DPL {
 namespace // anonymous
 {
 const size_t EXTRACT_BUFFER_SIZE = 4096;
 
 class ScopedUnzClose
 {
 namespace // anonymous
 {
 const size_t EXTRACT_BUFFER_SIZE = 4096;
 
 class ScopedUnzClose
 {
-private:
+  private:
     unzFile m_file;
 
     unzFile m_file;
 
-public:
-    ScopedUnzClose(unzFile file)
-        : m_file(file)
-    {
-    }
+  public:
+    ScopedUnzClose(unzFile file) :
+        m_file(file)
+    {}
 
     ~ScopedUnzClose()
     {
 
     ~ScopedUnzClose()
     {
-        if (!m_file)
+        if (!m_file) {
             return;
             return;
+        }
 
 
-        if (unzClose(m_file) != UNZ_OK)
+        if (unzClose(m_file) != UNZ_OK) {
             LogPedantic("Failed to close zip input file");
             LogPedantic("Failed to close zip input file");
+        }
     }
 
     unzFile Release()
     }
 
     unzFile Release()
@@ -80,54 +86,97 @@ public:
  *
  * About generalization:
  * To achieve the same results on abstract input device, there must be
  *
  * About generalization:
  * To achieve the same results on abstract input device, there must be
- * provided a mechanism to read data from random address without synchronization.
+ * provided a mechanism to read data from random address without
+ * synchronization.
  * In other words: stateless. As described above, stateless property can be
  * achieved via memory mapping.
  */
 class Device
 {
  * In other words: stateless. As described above, stateless property can be
  * achieved via memory mapping.
  */
 class Device
 {
-private:
-    DPL::ScopedPtr<FileInputMapping> m_fileMapping;
+  private:
+    int m_handle;
+    off64_t m_size; // file mapping size
+    unsigned char *m_address; // mapping base address
 
     struct File
     {
         off64_t offset;
         Device *device;
 
 
     struct File
     {
         off64_t offset;
         Device *device;
 
-        File(Device *d)
-            : offset(0),
-              device(d)
-        {
-        }
+        File(Device *d) :
+            offset(0),
+            device(d)
+        {}
     };
 
     };
 
-public:
+  public:
     Device(const std::string &fileName)
     {
     Device(const std::string &fileName)
     {
-        Try
-        {
-            LogPedantic("Creating file mapping");
-            m_fileMapping.Reset(new FileInputMapping(fileName));
+        LogPedantic("Creating file mapping");
+        // Open device and map it to user space
+        int file = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_RDONLY));
+
+        if (file == -1) {
+            int error = errno;
+            ThrowMsg(ZipInput::Exception::OpenFailed,
+                     "Failed to open file. errno = " << error);
         }
         }
-        Catch (FileInputMapping::Exception::Base)
-        {
-            LogPedantic("Failed to create file mapping");
 
 
-            ReThrowMsg(ZipInput::Exception::OpenFailed,
-                       "Failed to open zip file mapping");
+        // Scoped close on file
+        ScopedClose scopedClose(file);
+
+        // Calculate file size
+        off64_t size = lseek64(file, 0, SEEK_END);
+
+        if (size == static_cast<off64_t>(-1)) {
+            int error = errno;
+            ThrowMsg(ZipInput::Exception::OpenFailed,
+                     "Failed to seek file. errno = " << error);
+        }
+
+        // Map file to usespace
+        void *address = mmap(0, static_cast<size_t>(size),
+                             PROT_READ, MAP_SHARED, file, 0);
+
+        if (address == MAP_FAILED) {
+            int error = errno;
+            ThrowMsg(ZipInput::Exception::OpenFailed,
+                     "Failed to map file. errno = " << error);
+        }
+
+        // Release scoped close
+        m_handle = scopedClose.Release();
+
+        // Save mapped up address
+        m_size = size;
+        m_address = static_cast<unsigned char *>(address);
+
+        LogPedantic("Created file mapping: " << fileName <<
+                    " of size: " << m_size <<
+                    " at address: " << std::hex <<
+                    static_cast<void *>(m_address));
+    }
+
+    ~Device()
+    {
+        // Close mapping
+        if (munmap(m_address, static_cast<size_t>(m_size)) == -1) {
+            int error = errno;
+            LogPedantic("Failed to munmap file. errno = " << error);
         }
 
         }
 
-        LogPedantic("File mapping created");
+        // Close file descriptor
+        if (close(m_handle) == -1) {
+            int error = errno;
+            LogPedantic("Failed to close file. errno = " << error);
+        }
     }
 
     // zlib_filefunc64_def interface: files
     static voidpf ZCALLBACK open64_file(voidpf opaque,
     }
 
     // zlib_filefunc64_def interface: files
     static voidpf ZCALLBACK open64_file(voidpf opaque,
-                                        const void* filename,
-                                        int mode)
+                                        const void* /*filename*/,
+                                        int /*mode*/)
     {
     {
-        (void)filename;
-        (void)mode;
-
         Device *device = static_cast<Device *>(opaque);
 
         // Open file for master device
         Device *device = static_cast<Device *>(opaque);
 
         // Open file for master device
@@ -143,26 +192,26 @@ public:
         File *deviceFile = static_cast<File *>(pstream);
 
         // Check if offset is out of bounds
         File *deviceFile = static_cast<File *>(pstream);
 
         // Check if offset is out of bounds
-        if (deviceFile->offset >= device->m_fileMapping->GetSize())
-        {
+        if (deviceFile->offset >= device->m_size) {
             LogPedantic("Device: read offset out of bounds");
             return -1;
         }
 
             LogPedantic("Device: read offset out of bounds");
             return -1;
         }
 
-        off64_t bytesLeft = device->m_fileMapping->GetSize() -
-                            deviceFile->offset;
+        off64_t bytesLeft = device->m_size -
+            deviceFile->offset;
 
         off64_t bytesToRead;
 
         // Calculate bytes to read
 
         off64_t bytesToRead;
 
         // Calculate bytes to read
-        if (static_cast<off64_t>(size) > bytesLeft)
+        if (static_cast<off64_t>(size) > bytesLeft) {
             bytesToRead = bytesLeft;
             bytesToRead = bytesLeft;
-        else
+        } else {
             bytesToRead = static_cast<off64_t>(size);
             bytesToRead = static_cast<off64_t>(size);
+        }
 
         // Do copy
         memcpy(buf,
 
         // Do copy
         memcpy(buf,
-               device->m_fileMapping->GetAddress() + deviceFile->offset,
+               device->m_address + deviceFile->offset,
                static_cast<size_t>(bytesToRead));
 
         // Increment file offset
                static_cast<size_t>(bytesToRead));
 
         // Increment file offset
@@ -172,25 +221,18 @@ public:
         return static_cast<uLong>(bytesToRead);
     }
 
         return static_cast<uLong>(bytesToRead);
     }
 
-    static uLong ZCALLBACK write_file(voidpf opaque,
-                                      voidpf stream,
-                                      const void* buf,
-                                      uLong size)
+    static uLong ZCALLBACK write_file(voidpf /*opaque*/,
+                                      voidpf /*stream*/,
+                                      const void* /*buf*/,
+                                      uLong /*size*/)
     {
     {
-        (void)opaque;
-        (void)stream;
-        (void)buf;
-        (void)size;
-
         // Not supported by device
         LogPedantic("Unsupported function called!");
         return -1;
     }
 
         // Not supported by device
         LogPedantic("Unsupported function called!");
         return -1;
     }
 
-    static int ZCALLBACK close_file(voidpf opaque,
-                                    voidpf stream)
+    static int ZCALLBACK close_file(voidpf /*opaque*/, voidpf stream)
     {
     {
-        (void)opaque;
         File *deviceFile = static_cast<File *>(stream);
 
         // Delete file
         File *deviceFile = static_cast<File *>(stream);
 
         // Delete file
@@ -200,20 +242,14 @@ public:
         return 0;
     }
 
         return 0;
     }
 
-    static int ZCALLBACK testerror_file(voidpf opaque,
-                                        voidpf stream)
+    static int ZCALLBACK testerror_file(voidpf /*opaque*/, voidpf /*stream*/)
     {
     {
-        (void)opaque;
-        (void)stream;
-
         // No errors
         return 0;
     }
 
         // No errors
         return 0;
     }
 
-    static ZPOS64_T ZCALLBACK tell64_file(voidpf opaque,
-                                          voidpf stream)
+    static ZPOS64_T ZCALLBACK tell64_file(voidpf /*opaque*/, voidpf stream)
     {
     {
-        (void)opaque;
         File *deviceFile = static_cast<File *>(stream);
 
         return static_cast<ZPOS64_T>(deviceFile->offset);
         File *deviceFile = static_cast<File *>(stream);
 
         return static_cast<ZPOS64_T>(deviceFile->offset);
@@ -227,44 +263,43 @@ public:
         Device *device = static_cast<Device *>(opaque);
         File *deviceFile = static_cast<File *>(stream);
 
         Device *device = static_cast<Device *>(opaque);
         File *deviceFile = static_cast<File *>(stream);
 
-        switch (origin)
-        {
-            case ZLIB_FILEFUNC_SEEK_SET:
-                deviceFile->offset = static_cast<off64_t>(offset);
+        switch (origin) {
+        case ZLIB_FILEFUNC_SEEK_SET:
+            deviceFile->offset = static_cast<off64_t>(offset);
 
 
-                break;
+            break;
 
 
-            case ZLIB_FILEFUNC_SEEK_CUR:
-                deviceFile->offset += static_cast<off64_t>(offset);
+        case ZLIB_FILEFUNC_SEEK_CUR:
+            deviceFile->offset += static_cast<off64_t>(offset);
 
 
-                break;
+            break;
 
 
-            case ZLIB_FILEFUNC_SEEK_END:
-                deviceFile->offset =
-                    device->m_fileMapping->GetSize() -
-                    static_cast<off64_t>(offset);
+        case ZLIB_FILEFUNC_SEEK_END:
+            deviceFile->offset =
+                device->m_size -
+                static_cast<off64_t>(offset);
 
 
-                break;
+            break;
 
 
-            default:
-                return -1;
+        default:
+            return -1;
         }
 
         return 0;
     }
 };
 
         }
 
         return 0;
     }
 };
 
-ZipInput::ZipInput(const std::string &fileName)
-    m_device(NULL),
-      m_numberOfFiles(0),
-      m_globalComment(),
-      m_fileInfos()
+ZipInput::ZipInput(const std::string &fileName) :
+    m_device(NULL),
+    m_numberOfFiles(0),
+    m_globalComment(),
+    m_fileInfos()
 {
     LogPedantic("Zip input file: " << fileName);
 
     // Create master device
     LogPedantic("Creating master device");
 {
     LogPedantic("Zip input file: " << fileName);
 
     // Create master device
     LogPedantic("Creating master device");
-    ScopedPtr<Device> device(new Device(fileName));
+    std::unique_ptr<Device> device(new Device(fileName));
 
     // Open master file
     zlib_filefunc64_def interface;
 
     // Open master file
     zlib_filefunc64_def interface;
@@ -275,16 +310,15 @@ ZipInput::ZipInput(const std::string &fileName)
     interface.zseek64_file = &Device::seek64_file;
     interface.zclose_file = &Device::close_file;
     interface.zerror_file = &Device::testerror_file;
     interface.zseek64_file = &Device::seek64_file;
     interface.zclose_file = &Device::close_file;
     interface.zerror_file = &Device::testerror_file;
-    interface.opaque = device.Get();
+    interface.opaque = device.get();
 
     LogPedantic("Opening zip file");
     unzFile file = unzOpen2_64(NULL, &interface);
 
 
     LogPedantic("Opening zip file");
     unzFile file = unzOpen2_64(NULL, &interface);
 
-    if (file == NULL)
-    {
+    if (file == NULL) {
         LogPedantic("Failed to open zip file");
 
         LogPedantic("Failed to open zip file");
 
-         // Some errror occured
+        // Some errror occured
         ThrowMsg(Exception::OpenFailed,
                  "Failed to open zip file: " << fileName);
     }
         ThrowMsg(Exception::OpenFailed,
                  "Failed to open zip file: " << fileName);
     }
@@ -299,7 +333,7 @@ ZipInput::ZipInput(const std::string &fileName)
 
     // Release scoped unz close
     m_masterFile = scopedUnzClose.Release();
 
     // Release scoped unz close
     m_masterFile = scopedUnzClose.Release();
-    m_device = device.Release();
+    m_device = device.release();
 
     LogPedantic("Zip file opened");
 }
 
     LogPedantic("Zip file opened");
 }
@@ -307,8 +341,9 @@ ZipInput::ZipInput(const std::string &fileName)
 ZipInput::~ZipInput()
 {
     // Close zip
 ZipInput::~ZipInput()
 {
     // Close zip
-    if (unzClose(static_cast<unzFile>(m_masterFile)) != UNZ_OK)
+    if (unzClose(static_cast<unzFile>(m_masterFile)) != UNZ_OK) {
         LogPedantic("Failed to close zip input file");
         LogPedantic("Failed to close zip input file");
+    }
 
     // Close device
     delete m_device;
 
     // Close device
     delete m_device;
@@ -358,14 +393,12 @@ void ZipInput::ReadInfos(void *masterFile)
     // Read infos
     m_fileInfos.reserve(m_numberOfFiles);
 
     // Read infos
     m_fileInfos.reserve(m_numberOfFiles);
 
-    if (unzGoToFirstFile(static_cast<unzFile>(masterFile)) != UNZ_OK)
-    {
+    if (unzGoToFirstFile(static_cast<unzFile>(masterFile)) != UNZ_OK) {
         LogPedantic("Failed to go to first file");
         ThrowMsg(Exception::SeekFileFailed, "Failed to seek first file");
     }
 
         LogPedantic("Failed to go to first file");
         ThrowMsg(Exception::SeekFileFailed, "Failed to seek first file");
     }
 
-    for (size_t i = 0; i < m_numberOfFiles; ++i)
-    {
+    for (size_t i = 0; i < m_numberOfFiles; ++i) {
         unz_file_pos_s filePos;
 
         if (unzGetFilePos(static_cast<unzFile>(masterFile),
         unz_file_pos_s filePos;
 
         if (unzGetFilePos(static_cast<unzFile>(masterFile),
@@ -411,36 +444,18 @@ void ZipInput::ReadInfos(void *masterFile)
                 FileHandle(
                     static_cast<size_t>(filePos.pos_in_zip_directory),
                     static_cast<size_t>(filePos.num_of_file)
                 FileHandle(
                     static_cast<size_t>(filePos.pos_in_zip_directory),
                     static_cast<size_t>(filePos.num_of_file)
-                ),
+                    ),
                 std::string(fileName.Get()),
                 std::string(fileComment.Get()),
                 std::string(fileName.Get()),
                 std::string(fileComment.Get()),
-                static_cast<unsigned long>(fileInfo.version),
-                static_cast<unsigned long>(fileInfo.version_needed),
-                static_cast<unsigned long>(fileInfo.flag),
-                static_cast<unsigned long>(fileInfo.compression_method),
-                static_cast<unsigned long>(fileInfo.dosDate),
-                static_cast<unsigned long>(fileInfo.crc),
                 static_cast<off64_t>(fileInfo.compressed_size),
                 static_cast<off64_t>(fileInfo.compressed_size),
-                static_cast<off64_t>(fileInfo.uncompressed_size),
-                static_cast<unsigned long>(fileInfo.disk_num_start),
-                static_cast<unsigned long>(fileInfo.internal_fa),
-                static_cast<unsigned long>(fileInfo.external_fa),
-                FileDateTime(
-                    fileInfo.tmu_date.tm_sec,
-                    fileInfo.tmu_date.tm_min,
-                    fileInfo.tmu_date.tm_hour,
-                    fileInfo.tmu_date.tm_mday,
-                    fileInfo.tmu_date.tm_mon,
-                    fileInfo.tmu_date.tm_year
+                static_cast<off64_t>(fileInfo.uncompressed_size)
                 )
                 )
-            )
-        );
+            );
 
         // If this is not the last file, go to next one
 
         // If this is not the last file, go to next one
-        if (i != m_numberOfFiles - 1)
-        {
+        if (i != m_numberOfFiles - 1) {
             if (unzGoToNextFile(
             if (unzGoToNextFile(
-                    static_cast<unzFile>(masterFile))!= UNZ_OK)
+                    static_cast<unzFile>(masterFile)) != UNZ_OK)
             {
                 LogPedantic("Failed to go to next file");
 
             {
                 LogPedantic("Failed to go to next file");
 
@@ -476,17 +491,11 @@ ZipInput::size_type ZipInput::size() const
     return m_fileInfos.size();
 }
 
     return m_fileInfos.size();
 }
 
-ZipInput::File *ZipInput::OpenFile(FileHandle handle)
-{
-    return new File(m_device, handle);
-}
-
 ZipInput::File *ZipInput::OpenFile(const std::string &fileName)
 {
     FOREACH(iterator, m_fileInfos)
     {
 ZipInput::File *ZipInput::OpenFile(const std::string &fileName)
 {
     FOREACH(iterator, m_fileInfos)
     {
-        if (iterator->name == fileName)
-        {
+        if (iterator->name == fileName) {
             return new File(m_device, iterator->handle);
         }
     }
             return new File(m_device, iterator->handle);
         }
     }
@@ -511,11 +520,10 @@ ZipInput::File::File(class Device *device, FileHandle handle)
     LogPedantic("Opening zip file");
     unzFile file = unzOpen2_64(NULL, &interface);
 
     LogPedantic("Opening zip file");
     unzFile file = unzOpen2_64(NULL, &interface);
 
-    if (file == NULL)
-    {
+    if (file == NULL) {
         LogPedantic("Failed to open zip file");
 
         LogPedantic("Failed to open zip file");
 
-         // Some errror occured
+        // Some errror occured
         ThrowMsg(ZipInput::Exception::OpenFileFailed,
                  "Failed to open zip file");
     }
         ThrowMsg(ZipInput::Exception::OpenFileFailed,
                  "Failed to open zip file");
     }
@@ -524,27 +532,24 @@ ZipInput::File::File(class Device *device, FileHandle handle)
     ScopedUnzClose scopedUnzClose(file);
 
     // Look up file handle
     ScopedUnzClose scopedUnzClose(file);
 
     // Look up file handle
-    unz64_file_pos filePos =
-    {
+    unz64_file_pos filePos = {
         static_cast<ZPOS64_T>(handle.first),
         static_cast<ZPOS64_T>(handle.second)
     };
 
         static_cast<ZPOS64_T>(handle.first),
         static_cast<ZPOS64_T>(handle.second)
     };
 
-    if (unzGoToFilePos64(file, &filePos) != UNZ_OK)
-    {
+    if (unzGoToFilePos64(file, &filePos) != UNZ_OK) {
         LogPedantic("Failed to seek to zip file");
 
         LogPedantic("Failed to seek to zip file");
 
-         // Some errror occured
+        // Some errror occured
         ThrowMsg(ZipInput::Exception::OpenFileFailed,
                  "Failed to open zip file");
     }
 
     // Open current file for reading
         ThrowMsg(ZipInput::Exception::OpenFileFailed,
                  "Failed to open zip file");
     }
 
     // Open current file for reading
-    if (unzOpenCurrentFile(file) != UNZ_OK)
-    {
+    if (unzOpenCurrentFile(file) != UNZ_OK) {
         LogPedantic("Failed to open current zip file");
 
         LogPedantic("Failed to open current zip file");
 
-         // Some errror occured
+        // Some errror occured
         ThrowMsg(ZipInput::Exception::OpenFileFailed,
                  "Failed to open current zip file");
     }
         ThrowMsg(ZipInput::Exception::OpenFileFailed,
                  "Failed to open current zip file");
     }
@@ -558,30 +563,34 @@ ZipInput::File::File(class Device *device, FileHandle handle)
 ZipInput::File::~File()
 {
     // Close current file for reading
 ZipInput::File::~File()
 {
     // Close current file for reading
-    if (unzCloseCurrentFile(static_cast<unzFile>(m_file)) != UNZ_OK)
+    if (unzCloseCurrentFile(static_cast<unzFile>(m_file)) != UNZ_OK) {
         LogPedantic("Failed to close current zip input file");
         LogPedantic("Failed to close current zip input file");
+    }
 
     // Close zip file
 
     // Close zip file
-    if (unzClose(static_cast<unzFile>(m_file)) != UNZ_OK)
+    if (unzClose(static_cast<unzFile>(m_file)) != UNZ_OK) {
         LogPedantic("Failed to close zip input file");
         LogPedantic("Failed to close zip input file");
+    }
 }
 
 DPL::BinaryQueueAutoPtr ZipInput::File::Read(size_t size)
 {
     // Do not even try to unzip if requested zero bytes
 }
 
 DPL::BinaryQueueAutoPtr ZipInput::File::Read(size_t size)
 {
     // Do not even try to unzip if requested zero bytes
-    if (size == 0)
+    if (size == 0) {
         return DPL::BinaryQueueAutoPtr(new DPL::BinaryQueue());
         return DPL::BinaryQueueAutoPtr(new DPL::BinaryQueue());
+    }
 
     // Calc data to read
     size_t sizeToRead = size > EXTRACT_BUFFER_SIZE ?
 
     // Calc data to read
     size_t sizeToRead = size > EXTRACT_BUFFER_SIZE ?
-                        EXTRACT_BUFFER_SIZE :
-                        size;
+        EXTRACT_BUFFER_SIZE :
+        size;
 
     // Extract zip file data (one-copy)
     ScopedFree<void> rawBuffer(malloc(sizeToRead));
 
 
     // Extract zip file data (one-copy)
     ScopedFree<void> rawBuffer(malloc(sizeToRead));
 
-    if (!rawBuffer)
+    if (!rawBuffer) {
         throw std::bad_alloc();
         throw std::bad_alloc();
+    }
 
     // Do unpack
     int bytes = unzReadCurrentFile(static_cast<unzFile>(m_file),
 
     // Do unpack
     int bytes = unzReadCurrentFile(static_cast<unzFile>(m_file),
@@ -589,8 +598,7 @@ DPL::BinaryQueueAutoPtr ZipInput::File::Read(size_t size)
                                    sizeToRead);
 
     // Internal unzipper error
                                    sizeToRead);
 
     // Internal unzipper error
-    if (bytes < 0)
-    {
+    if (bytes < 0) {
         LogPedantic("Extract failed. Error: " << bytes);
 
         ThrowMsg(ZipInput::Exception::ReadFileFailed,
         LogPedantic("Extract failed. Error: " << bytes);
 
         ThrowMsg(ZipInput::Exception::ReadFileFailed,
diff --git a/modules/custom_handler_dao/CMakeLists.txt b/modules/custom_handler_dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1afddd5
--- /dev/null
@@ -0,0 +1,83 @@
+SET(TARGET_CUSTOM_HANDLER_DAO_DB "Sqlite3DbCustomHandler")
+
+ADD_CUSTOM_COMMAND(
+   OUTPUT ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h
+   COMMAND ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/gen_db_md5.sh
+   ARGS ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h
+        ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db
+   DEPENDS ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db
+        ${CMAKE_SOURCE_DIR}/modules/custom_handler_dao/orm/gen_db_md5.sh
+   COMMENT "Generating WRT custom handlers database checksum"
+   )
+
+ADD_CUSTOM_COMMAND( OUTPUT .wrt_custom_handler.db
+   COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db
+   COMMAND gcc -Wall -include ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h -I${PROJECT_SOURCE_DIR}/modules/db/include -I${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm -E ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_BINARY_DIR}/wrt_custom_handler_db.sql
+   COMMAND sqlite3 ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db ".read ${CMAKE_CURRENT_BINARY_DIR}/wrt_custom_handler_db.sql" || rm -f ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db
+   DEPENDS ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm/custom_handler_db
+   )
+
+ADD_CUSTOM_COMMAND( OUTPUT .wrt_custom_handler.db-journal
+   COMMAND touch
+   ARGS  ${CMAKE_CURRENT_BINARY_DIR}/.wrt_custom_handler.db-journal
+   )
+
+ADD_CUSTOM_TARGET(${TARGET_CUSTOM_HANDLER_DAO_DB} ALL DEPENDS .wrt_custom_handler.db .wrt_custom_handler.db-journal)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_custom_handler_db.sql DESTINATION share/wrt-engine/)
+
+###############################################################################
+
+INCLUDE(FindPkgConfig)
+
+PKG_CHECK_MODULES(CUSTOM_HANDLER_DAO_DEPS
+    glib-2.0
+    REQUIRED)
+
+SET(CUSTOM_HANDLER_DAO_INCLUDE_DIRS
+    ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/include
+    ${PROJECT_SOURCE_DIR}/modules/custom_handler_dao/orm
+    ${PROJECT_SOURCE_DIR}/modules/core/include
+    ${PROJECT_SOURCE_DIR}/modules/db/include
+    ${PROJECT_SOURCE_DIR}/modules/log/include
+)
+
+
+SET(CUSTOM_HANDLER_DAO_RO_SOURCES
+    dao/CustomHandlerDatabase.cpp
+    dao/custom_handler_dao_read_only.cpp
+)
+
+SET(CUSTOM_HANDLER_DAO_RW_SOURCES
+    dao/custom_handler_dao.cpp
+)
+
+
+INCLUDE_DIRECTORIES(${CUSTOM_HANDLER_DAO_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${CUSTOM_HANDLER_DAO_DEPS_INCLUDE_DIRS})
+
+ADD_LIBRARY(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} SHARED ${CUSTOM_HANDLER_DAO_RO_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h")
+TARGET_LINK_LIBRARIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} ${TARGET_CUSTOM_HANDLER_DAO_LIB})
+ADD_DEPENDENCIES(${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} ${TARGET_CUSTOM_HANDLER_DAO_DB})
+
+ADD_LIBRARY(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} SHARED ${CUSTOM_HANDLER_DAO_RW_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} PROPERTIES COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/modules/custom_handler_dao/database_checksum_custom_handler.h")
+TARGET_LINK_LIBRARIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} ${TARGET_CUSTOM_HANDLER_DAO_RO_LIB})
+ADD_DEPENDENCIES(${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} ${TARGET_CUSTOM_HANDLER_DAO_DB})
+
+INSTALL(TARGETS ${TARGET_CUSTOM_HANDLER_DAO_RO_LIB} DESTINATION lib)
+INSTALL(TARGETS ${TARGET_CUSTOM_HANDLER_DAO_RW_LIB} DESTINATION lib)
+
+INSTALL(FILES
+    include/wrt-commons/custom-handler-dao-ro/common_dao_types.h
+    include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h
+    include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h
+    DESTINATION include/dpl-efl/wrt-commons/custom-handler-dao-ro
+)
+
+INSTALL(FILES
+    include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h
+    DESTINATION include/dpl-efl/wrt-commons/custom-handler-dao-rw
+)
diff --git a/modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp b/modules/custom_handler_dao/dao/CustomHandlerDatabase.cpp
new file mode 100644 (file)
index 0000000..d6f70a8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+
+namespace CustomHandlerDB {
+namespace Interface {
+namespace {
+const char* CustomHandler_DB_DATABASE = "/opt/dbspace/.wrt_custom_handler.db";
+DPL::DB::SqlConnection::Flag::Type CustomHandler_DB_FLAGS =
+    DPL::DB::SqlConnection::Flag::UseLucene;
+}
+
+DPL::Mutex g_dbQueriesMutex;
+DPL::DB::ThreadDatabaseSupport g_dbInterface(CustomHandler_DB_DATABASE,
+                                             CustomHandler_DB_FLAGS);
+
+void attachDatabaseRO()
+{
+    g_dbInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RO);
+}
+
+void attachDatabaseRW()
+{
+    g_dbInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
+}
+
+void detachDatabase()
+{
+    g_dbInterface.DetachFromThread();
+}
+} //namespace Interface
+} //namespace CustomHandlerDB
diff --git a/modules/custom_handler_dao/dao/custom_handler_dao.cpp b/modules/custom_handler_dao/dao/custom_handler_dao.cpp
new file mode 100644 (file)
index 0000000..6d57771
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    custom_handler_dao.cpp
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief    This file contains the definition of custom handler dao class.
+ */
+
+#include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+#include <orm_generator_custom_handler.h>
+#include <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
+
+using namespace DPL::DB::ORM;
+using namespace DPL::DB::ORM::custom_handler;
+
+namespace CustomHandlerDB {
+namespace {
+template <typename T>
+void fillRow(T& row, const CustomHandler& handler, const DPL::String& pkgName)
+{
+    row.Set_app_id(pkgName);
+    row.Set_target(handler.target);
+    row.Set_base_url(handler.base_url);
+    row.Set_url(handler.url);
+    row.Set_title(handler.title);
+    row.Set_user_allowed(handler.user_decision);
+}
+} // namespace
+
+CustomHandlerDAO::CustomHandlerDAO(const DPL::String& pkgName) :
+    CustomHandlerDAOReadOnly(pkgName)
+{}
+
+CustomHandlerDAO::~CustomHandlerDAO()
+{}
+
+void CustomHandlerDAO::registerContentHandler(const CustomHandler& handler)
+{
+    LogDebug("Registering content handler " << handler.target << " " <<
+             handler.base_url);
+    Try {
+        if (handler.user_decision & Agreed) {
+            //need to disable all previous, agreed entries
+            CUSTOM_HANDLER_DB_SELECT(select, ContentHandlers);
+            select->Where(And(Equals<ContentHandlers::target>(handler.target),
+                              Or(Equals<ContentHandlers::user_allowed>(Agreed),
+                                 Equals<ContentHandlers::user_allowed>(
+                                     AgreedPermanently))
+                              ));
+            ContentHandlers::Select::RowList rows = select->GetRowList();
+            if (rows.size() > 1) {
+                //more than one activ content handler - not good. Remove all.
+                //this should never happen
+                LogError("Database data incoherent.");
+                CUSTOM_HANDLER_DB_DELETE(deleteContent, ContentHandlers);
+                deleteContent->Where(And(Equals<ContentHandlers::target>(
+                                             handler.target),
+                                         Or(Equals<ContentHandlers::
+                                                       user_allowed>(Agreed),
+                                            Equals<ContentHandlers::
+                                                       user_allowed>(
+                                                AgreedPermanently))));
+                deleteContent->Execute();
+                //all content handlers removed. New one can be inserted
+            } else if (!rows.empty()) {
+                //one active handler. Can be updaed
+                LogDebug("Activ content handler exist. Update");
+                CUSTOM_HANDLER_DB_UPDATE(update, ContentHandlers);
+                update->Where(And(Equals<ContentHandlers::target>(handler.
+                                                                      target),
+                                  Or(Equals<ContentHandlers::user_allowed>(
+                                         Agreed),
+                                     Equals<ContentHandlers::user_allowed>(
+                                         AgreedPermanently))
+                                  ));
+                ContentHandlers::Row rowToUpdate = rows.front();
+
+                if (handler.user_decision & DecisionSaved) {
+                    //do not ask about previous one
+                    rowToUpdate.Set_user_allowed(DeclinedPermanently);
+                } else {
+                    //ask for next time
+                    rowToUpdate.Set_user_allowed(Declined);
+                }
+                update->Values(rowToUpdate);
+                update->Execute();
+            }
+        }
+        LogDebug("Inserting new content handler");
+        ContentHandlers::Row row;
+        fillRow(row, handler, m_pkgName);
+        if (getContentHandler(handler.target, handler.url, handler.base_url)) {
+            LogDebug("Content handler exist. Update its state");
+            CUSTOM_HANDLER_DB_UPDATE(updateRow, ContentHandlers);
+            updateRow->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                                 And(Equals<ContentHandlers::target>(handler.
+                                                                         target),
+                                     And(Equals<ContentHandlers::url>(handler.
+                                                                          url),
+                                         Equals<ContentHandlers::base_url>(
+                                             handler.base_url)))));
+            updateRow->Values(row);
+            updateRow->Execute();
+            LogDebug("updated");
+            return;
+        }
+        CUSTOM_HANDLER_DB_INSERT(insert, ContentHandlers);
+        insert->Values(row);
+        insert->Execute();
+        LogDebug("insterted");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to register custom handler");
+    }
+}
+
+void CustomHandlerDAO::registerProtocolHandler(const CustomHandler& handler)
+{
+    LogDebug("Registering protocol handler " << handler.target << " " <<
+             handler.base_url);
+    Try {
+        if (handler.user_decision & Agreed) {
+            //need to disable all previous, agreed entries
+            CUSTOM_HANDLER_DB_SELECT(select, ProtocolHandlers);
+            select->Where(And(Equals<ProtocolHandlers::target>(handler.target),
+                              Or(Equals<ProtocolHandlers::user_allowed>(Agreed),
+                                 Equals<ProtocolHandlers::user_allowed>(
+                                     AgreedPermanently))
+                              ));
+            ProtocolHandlers::Select::RowList rows = select->GetRowList();
+            if (rows.size() > 1) {
+                //more than one activ protocol handler - not good. Remove all.
+                //this should never happen
+                LogError("Database data incoherent.");
+                CUSTOM_HANDLER_DB_DELETE(deleteProtocol, ProtocolHandlers);
+                deleteProtocol->Where(And(Equals<ProtocolHandlers::target>(
+                                              handler.target),
+                                          Or(Equals<ProtocolHandlers::
+                                                        user_allowed>(Agreed),
+                                             Equals<ProtocolHandlers::
+                                                        user_allowed>(
+                                                 AgreedPermanently))));
+                deleteProtocol->Execute();
+                //all protocol handlers removed. New one can be inserted
+            } else if (!rows.empty()) {
+                //one active handler. Can be updaed
+                CUSTOM_HANDLER_DB_UPDATE(update, ProtocolHandlers);
+                update->Where(And(Equals<ProtocolHandlers::target>(handler.
+                                                                       target),
+                                  Or(Equals<ProtocolHandlers::user_allowed>(
+                                         Agreed),
+                                     Equals<ProtocolHandlers::user_allowed>(
+                                         AgreedPermanently))
+                                  ));
+                ProtocolHandlers::Row rowToUpdate = rows.front();
+
+                if (handler.user_decision & DecisionSaved) {
+                    //do not ask about previous one
+                    rowToUpdate.Set_user_allowed(DeclinedPermanently);
+                } else {
+                    //ask for next time
+                    rowToUpdate.Set_user_allowed(Declined);
+                }
+                update->Values(rowToUpdate);
+                update->Execute();
+            }
+        }
+        LogDebug("Inserting new protocol handler");
+        ProtocolHandlers::Row row;
+        fillRow(row, handler, m_pkgName);
+        if (getProtocolHandler(handler.target, handler.url,
+                               handler.base_url))
+        {
+            LogDebug("Protocol handler exist. Update its state");
+            CUSTOM_HANDLER_DB_UPDATE(updateRow, ProtocolHandlers);
+            updateRow->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                                 And(Equals<ProtocolHandlers::target>(handler.
+                                                                          target),
+                                     And(Equals<ProtocolHandlers::url>(handler.
+                                                                           url),
+                                         Equals<ProtocolHandlers::base_url>(
+                                             handler.base_url)))));
+            updateRow->Values(row);
+            updateRow->Execute();
+            LogDebug("updated");
+            return;
+        }
+        CUSTOM_HANDLER_DB_INSERT(insert, ProtocolHandlers);
+        insert->Values(row);
+        insert->Execute();
+        LogDebug("insterted");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to register custom handler");
+    }
+}
+
+void CustomHandlerDAO::unregisterContentHandler(const DPL::String& target,
+                                                const DPL::String& url)
+{
+    LogDebug("Removing content handler " << target << " " << url);
+    Try {
+        CUSTOM_HANDLER_DB_DELETE(deleteFrom, ContentHandlers);
+        deleteFrom->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                              And(Equals<ContentHandlers::target>(target),
+                                  Equals<ContentHandlers::url>(url))));
+        deleteFrom->Execute();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to remove content handler");
+    }
+}
+
+void CustomHandlerDAO::unregisterProtocolHandler(const DPL::String& target,
+                                                 const DPL::String& url)
+{
+    LogDebug("Removing protocol handler " << target << " " << url);
+    Try {
+        CUSTOM_HANDLER_DB_DELETE(deleteFrom, ProtocolHandlers);
+        deleteFrom->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                              And(Equals<ProtocolHandlers::target>(target),
+                                  Equals<ProtocolHandlers::url>(url))));
+        deleteFrom->Execute();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to remove content handler");
+    }
+}
+
+void CustomHandlerDAO::unregisterContentHandler(const DPL::String& target,
+                                                const DPL::String& url,
+                                                const DPL::String& baseURL)
+{
+    LogDebug("Removing content handler " << target << " " << url);
+    Try {
+        CUSTOM_HANDLER_DB_DELETE(deleteFrom, ContentHandlers);
+        deleteFrom->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                              And(Equals<ContentHandlers::target>(target),
+                                  And(Equals<ContentHandlers::url>(url),
+                                      Equals<ContentHandlers::base_url>(baseURL)))));
+        deleteFrom->Execute();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to remove content handler");
+    }
+}
+
+void CustomHandlerDAO::unregisterProtocolHandler(const DPL::String& target,
+                                                 const DPL::String& url,
+                                                 const DPL::String& baseURL)
+{
+    LogDebug("Removing protocol handler " << target << " " << url);
+    Try {
+        CUSTOM_HANDLER_DB_DELETE(deleteFrom, ProtocolHandlers);
+        deleteFrom->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                              And(Equals<ProtocolHandlers::target>(target),
+                                  And(Equals<ProtocolHandlers::url>(url),
+                                      Equals<ProtocolHandlers::base_url>(
+                                          baseURL)))));
+        deleteFrom->Execute();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to remove content handler");
+    }
+}
+
+void CustomHandlerDAO::removeWidgetProtocolHandlers()
+{
+    LogDebug("ente");
+    Try {
+        CUSTOM_HANDLER_DB_DELETE(deleteProtocol, ProtocolHandlers);
+        deleteProtocol->Where(Equals<ProtocolHandlers::app_id>(m_pkgName));
+        deleteProtocol->Execute();
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to remove widget protoc");
+    }
+}
+
+void CustomHandlerDAO::removeWidgetContentHandlers()
+{
+    LogDebug("ente");
+    Try {
+        CUSTOM_HANDLER_DB_DELETE(deleteContent, ContentHandlers);
+        deleteContent->Where(Equals<ContentHandlers::app_id>(m_pkgName));
+        deleteContent->Execute();
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAO::Exception::DatabaseError,
+                   "Failed to remove widget entries");
+    }
+}
+} // namespace CustomHandlerDB
diff --git a/modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp b/modules/custom_handler_dao/dao/custom_handler_dao_read_only.cpp
new file mode 100644 (file)
index 0000000..ff43613
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of custom handler dao class.
+ *
+ * @file    custom_handler_dao_read_only.cpp
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of custom handler dao
+ */
+
+#include <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+
+#include <orm_generator_custom_handler.h>
+
+using namespace DPL::DB::ORM;
+using namespace DPL::DB::ORM::custom_handler;
+
+namespace CustomHandlerDB {
+namespace {
+template <typename T>
+CustomHandlerPtr getSingleHandler(std::list<T> row)
+{
+    CustomHandlerPtr handler;
+    if (!row.empty()) {
+        // There should be only one
+        if (row.size() > 1) {
+            ThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                     "More than one handler registered");
+        }
+
+        handler.reset(new CustomHandler());
+        handler->target = row.front().Get_target();
+        handler->base_url = row.front().Get_base_url();
+        handler->url = row.front().Get_url();
+        handler->title = row.front().Get_title();
+        handler->user_allowed = static_cast<bool>(row.front().Get_user_allowed());
+        handler->user_decision =
+            static_cast<HandlerState>(row.front().Get_user_allowed());
+    }
+    return handler;
+}
+} // namespace
+
+CustomHandlerDAOReadOnly::CustomHandlerDAOReadOnly(const DPL::String& pkgName)
+    :
+    m_pkgName(pkgName)
+{}
+
+CustomHandlerDAOReadOnly::~CustomHandlerDAOReadOnly()
+{}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getProtocolHandler(
+    const DPL::String& protocol,
+    const DPL::String& url)
+{
+    LogDebug("Getting protocol handler");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ProtocolHandlers);
+
+        select->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                          And(Equals<ProtocolHandlers::target>(protocol),
+                              Equals<ProtocolHandlers::url>(url))));
+
+        std::list<ProtocolHandlers::Row> list = select->GetRowList();
+        return getSingleHandler(list);
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get protocol handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getContentHandler(
+    const DPL::String& content,
+    const DPL::String& url)
+{
+    LogDebug("Getting content handler");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ContentHandlers);
+
+        select->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                          And(Equals<ContentHandlers::target>(content),
+                              Equals<ContentHandlers::url>(url))));
+
+        std::list<ContentHandlers::Row> list = select->GetRowList();
+        return getSingleHandler(list);
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get content handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getActivProtocolHandler(
+    const DPL::String& protocol)
+{
+    LogDebug("Getting active protocol handler");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ProtocolHandlers);
+
+        select->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                          Equals<ProtocolHandlers::target>(protocol)));
+
+        std::list<ProtocolHandlers::Row> list = select->GetRowList();
+        CustomHandlerPtr handler;
+
+        FOREACH(it, list) {
+            if (it->Get_user_allowed() & Agreed) {
+                handler.reset(new CustomHandler());
+                handler->base_url = it->Get_base_url();
+                handler->target = it->Get_target();
+                handler->title = it->Get_title();
+                handler->url = it->Get_url();
+                handler->user_allowed =
+                    static_cast<bool>(it->Get_user_allowed());
+                handler->user_decision =
+                    static_cast<HandlerState>(it->Get_user_allowed());
+            }
+        }
+        return handler;
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get protocol handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getProtocolHandler(
+    const DPL::String& protocol,
+    const DPL::String& url,
+    const DPL::String& baseURL)
+{
+    LogDebug("Check if protocol is registered");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ProtocolHandlers);
+
+        select->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                          And(Equals<ProtocolHandlers::target>(protocol),
+                              And(Equals<ProtocolHandlers::url>(url),
+                                  Equals<ProtocolHandlers::base_url>(baseURL)
+                                  )
+                              )
+                          )
+                      );
+
+        std::list<ProtocolHandlers::Row> list = select->GetRowList();
+        return getSingleHandler(list);
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get content handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getActivContentHandler(
+    const DPL::String& content)
+{
+    LogDebug("Getting active content handler");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ContentHandlers);
+
+        select->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                          Equals<ContentHandlers::target>(content)));
+
+        std::list<ContentHandlers::Row> list = select->GetRowList();
+        CustomHandlerPtr handler;
+
+        FOREACH(it, list) {
+            if (it->Get_user_allowed() & Agreed) {
+                handler.reset(new CustomHandler());
+                handler->base_url = it->Get_base_url();
+                handler->target = it->Get_target();
+                handler->title = it->Get_title();
+                handler->url = it->Get_url();
+                handler->user_allowed =
+                    static_cast<bool>(it->Get_user_allowed());
+                handler->user_decision =
+                    static_cast<HandlerState>(it->Get_user_allowed());
+            }
+        }
+        return handler;
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get protocol handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getContentHandler(
+    const DPL::String& content,
+    const DPL::String& url,
+    const DPL::String& baseURL)
+{
+    LogDebug("Check if content is registered");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ContentHandlers);
+
+        select->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                          And(Equals<ContentHandlers::target>(content),
+                              And(Equals<ContentHandlers::url>(url),
+                                  Equals<ContentHandlers::base_url>(baseURL)))));
+
+        std::list<ContentHandlers::Row> list = select->GetRowList();
+        return getSingleHandler(list);
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get content handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getAllowedProtocolHandler(
+    const DPL::String& protocol)
+{
+    LogDebug("Getting allowed protocol handler");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ProtocolHandlers);
+
+        select->Where(And(Equals<ProtocolHandlers::app_id>(m_pkgName),
+                          And(Equals<ProtocolHandlers::target>(protocol),
+                              Equals<ProtocolHandlers::user_allowed>(true))));
+
+        std::list<ProtocolHandlers::Row> list = select->GetRowList();
+        return getSingleHandler(list);
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get content handler");
+    }
+}
+
+CustomHandlerPtr CustomHandlerDAOReadOnly::getAllowedContentHandler(
+    const DPL::String& protocol)
+{
+    LogDebug("Getting allowed content handler");
+    Try {
+        CUSTOM_HANDLER_DB_SELECT(select, ContentHandlers)
+
+        select->Where(And(Equals<ContentHandlers::app_id>(m_pkgName),
+                          And(Equals<ContentHandlers::target>(protocol),
+                              Equals<ContentHandlers::user_allowed>(true))));
+
+        std::list<ContentHandlers::Row> list = select->GetRowList();
+        return getSingleHandler(list);
+    } Catch(DPL::DB::SqlConnection::Exception::Base) {
+        ReThrowMsg(CustomHandlerDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get content handler");
+    }
+}
+} // namespace CustomHandlerDB
diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h
new file mode 100644 (file)
index 0000000..4eabd55
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _CUSTOM_HANDLER_DATABASE_H_
+#define _CUSTOM_HANDLER_DATABASE_H_
+
+#include <dpl/thread.h>
+#include <dpl/mutex.h>
+#include <dpl/db/thread_database_support.h>
+
+namespace CustomHandlerDB {
+namespace Interface {
+void attachDatabaseRO();
+void attachDatabaseRW();
+void detachDatabase();
+
+extern DPL::Mutex g_dbQueriesMutex;
+extern DPL::DB::ThreadDatabaseSupport g_dbInterface;
+} // namespace Interface
+} // namespace CustomHandlerDB
+
+#define CUSTOM_HANDLER_DB_INTERNAL(tlsCommand, InternalType)                   \
+    static DPL::ThreadLocalVariable<InternalType> *tlsCommand##Ptr = NULL;   \
+    {                                                                          \
+        DPL::Mutex::ScopedLock lock(                                           \
+            &CustomHandlerDB::Interface::g_dbQueriesMutex);                \
+        if (!tlsCommand##Ptr) {                                              \
+            static DPL::ThreadLocalVariable<InternalType> tmp;                 \
+            tlsCommand##Ptr = &tmp;                                          \
+        }                                                                      \
+    }                                                                          \
+    DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand##Ptr;   \
+    if (tlsCommand.IsNull())                                                   \
+    {                                                                          \
+        tlsCommand = InternalType(&CustomHandlerDB::Interface::g_dbInterface); \
+    }
+
+#define CUSTOM_HANDLER_DB_SELECT(name, type) \
+    CUSTOM_HANDLER_DB_INTERNAL(name, type::Select)
+
+#define CUSTOM_HANDLER_DB_INSERT(name, type) \
+    CUSTOM_HANDLER_DB_INTERNAL(name, type::Insert)
+
+#define CUSTOM_HANDLER_DB_UPDATE(name, type) \
+    CUSTOM_HANDLER_DB_INTERNAL(name, type::Update)
+
+#define CUSTOM_HANDLER_DB_DELETE(name, type) \
+    CUSTOM_HANDLER_DB_INTERNAL(name, type::Delete)
+
+#endif /* _CUSTOM_HANDLER_DATABASE_H_ */
+
diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/common_dao_types.h
new file mode 100644 (file)
index 0000000..c798cea
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    common_dao_types.h
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief This file contains the declaration of
+ *           common data types for custom handler database.
+ */
+#ifndef SRC_MODULES_CUSTOM_HANDLERS_DAO_COMMON_DAO_TYPES_H_
+#define SRC_MODULES_CUSTOM_HANDLERS_DAO_COMMON_DAO_TYPES_H_
+
+#include <list>
+#include <memory>
+#include <dpl/string.h>
+
+namespace CustomHandlerDB {
+/**
+ * @brief Custom Handler struct
+ *
+ * Describes custom handler for protocol and content.
+ */
+enum HandlerState {
+    Agreed = 0x01,      //user agreed to use protocol only,
+                        //but want to ask in next occurence
+    Declined = 0x02,    //user declined to use protocol,
+                        //but want to ask in next occurence
+                        //in fact it is used when user wants to cover saved
+                        // agreed
+                        //decision by agreeing to another one without save.
+    DecisionSaved = 0x04, //user dont want to ask again
+    AgreedPermanently = Agreed | DecisionSaved,
+    DeclinedPermanently = Declined | DecisionSaved
+};
+
+struct CustomHandler
+{
+    DPL::String target;     // protocol/content ("mailto"/"application/x-soup")
+    DPL::String base_url;   // base url of registered page
+    DPL::String url;        // url used for protocol/content handling
+    DPL::String title;      // user friendly handler name
+    bool user_allowed;      // true if user has allowed the handler
+    HandlerState user_decision;
+};
+
+typedef std::shared_ptr<CustomHandler> CustomHandlerPtr;
+typedef std::list <CustomHandlerPtr> CustomHandlersList;
+} // namespace CustomHandlerDB
+
+#endif /* SRC_MODULES_CUSTOM_HANDLERS_DAO_COMMON_DAO_TYPES_H_ */
diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h
new file mode 100644 (file)
index 0000000..42a9936
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of custom handler dao class.
+ *
+ * @file    custom_handler_dao_read_only.h
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of custom handler dao
+ */
+
+#ifndef _CUSTOM_HANDLER_DAO_READ_ONLY_H_
+#define _CUSTOM_HANDLER_DAO_READ_ONLY_H_
+
+#include <dpl/string.h>
+#include <dpl/exception.h>
+#include "common_dao_types.h"
+
+namespace CustomHandlerDB {
+class CustomHandlerDAOReadOnly
+{
+  public:
+    /**
+     * CustomHandlerDAOReadOnly Exception classes
+     */
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
+    };
+
+  public:
+    explicit CustomHandlerDAOReadOnly(const DPL::String& pkgName);
+    virtual ~CustomHandlerDAOReadOnly();
+
+    /**
+     * Returns protocol handler
+     */
+    CustomHandlerPtr getProtocolHandler(const DPL::String& protocol,
+                                        const DPL::String& url);
+    CustomHandlerPtr getProtocolHandler(const DPL::String& protocol,
+                                        const DPL::String& url,
+                                        const DPL::String& baseURL);
+
+    /**
+     * Returns protocol handler that is agreed or agreed and saved and match
+     * tizenID
+     */
+    CustomHandlerPtr getActivProtocolHandler(const DPL::String& protocol);
+
+    /**
+     * Returns content handler
+     */
+    CustomHandlerPtr getContentHandler(const DPL::String& content,
+                                       const DPL::String& url);
+    CustomHandlerPtr getContentHandler(const DPL::String& protocol,
+                                       const DPL::String& url,
+                                       const DPL::String& baseURL);
+
+    /**
+     * Returns content handler that is agreed or agreed and saved and match
+     * tizenID
+     */
+    CustomHandlerPtr getActivContentHandler(const DPL::String& content);
+
+    /**
+     * Returns allowed handler for given protocol
+     */
+    CustomHandlerPtr getAllowedProtocolHandler(const DPL::String& protocol);
+
+    /**
+     * Returns allowed handler for given content
+     */
+    CustomHandlerPtr getAllowedContentHandler(const DPL::String& protocol);
+
+  protected:
+    DPL::String m_pkgName;
+};
+} // namespace CustomHandlerDB
+
+#endif // _CUSTOM_HANDLER_DAO_READ_ONLY_H_
+
diff --git a/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h b/modules/custom_handler_dao/include/wrt-commons/custom-handler-dao-rw/custom_handler_dao.h
new file mode 100644 (file)
index 0000000..9a478cb
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of custom handler dao class.
+ *
+ * @file    custom_handler_dao.h
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of custom handler dao
+ */
+#ifndef _CUSTOM_HANDLER_DAO_H_
+#define _CUSTOM_HANDLER_DAO_H_
+
+#include <wrt-commons/custom-handler-dao-ro/custom_handler_dao_read_only.h>
+
+namespace CustomHandlerDB {
+class CustomHandlerDAO : public CustomHandlerDAOReadOnly
+{
+  public:
+    explicit CustomHandlerDAO(const DPL::String& pkgName);
+    virtual ~CustomHandlerDAO();
+
+    /**
+     * Registers custom content handler
+     */
+    void registerContentHandler(const CustomHandler& handler);
+
+    /**
+     * Registers custom protocol handler
+     */
+    void registerProtocolHandler(const CustomHandler& handler);
+
+    /**
+     * Unregisters custom content handler
+     */
+    void unregisterContentHandler(const DPL::String& target,
+                                  const DPL::String& burl);
+    /**
+     * Unregisters custom protocol handler
+     */
+    void unregisterProtocolHandler(const DPL::String& target,
+                                   const DPL::String& url);
+
+    void unregisterContentHandler(const DPL::String& target,
+                                  const DPL::String& url,
+                                  const DPL::String& baseURL);
+
+    void unregisterProtocolHandler(const DPL::String& target,
+                                   const DPL::String& url,
+                                   const DPL::String& baseURL);
+
+    /**
+     * Removes all widget entries connected to given ID
+     */
+    void removeWidgetProtocolHandlers();
+    void removeWidgetContentHandlers();
+};
+} // namespace CustomHandlerDB
+
+#endif // _CUSTOM_HANDLER_DAO_H_
diff --git a/modules/custom_handler_dao/orm/custom_handler_db b/modules/custom_handler_dao/orm/custom_handler_db
new file mode 100644 (file)
index 0000000..848c84a
--- /dev/null
@@ -0,0 +1,34 @@
+SQL(
+    BEGIN TRANSACTION;
+)
+
+CREATE_TABLE(ProtocolHandlers)
+    COLUMN_NOT_NULL(app_id,            TEXT,)
+    COLUMN_NOT_NULL(target,            TEXT,)
+    COLUMN_NOT_NULL(base_url,       TEXT,)
+    COLUMN_NOT_NULL(url,               TEXT,)
+    COLUMN_NOT_NULL(title,          TEXT,)
+    COLUMN_NOT_NULL(user_allowed,   INT,)
+
+    TABLE_CONSTRAINTS(
+        PRIMARY KEY (app_id, target, base_url, url)
+    )
+CREATE_TABLE_END()
+
+CREATE_TABLE(ContentHandlers)
+    COLUMN_NOT_NULL(app_id,            TEXT,)
+    COLUMN_NOT_NULL(target,            TEXT,)
+    COLUMN_NOT_NULL(base_url,       TEXT,)
+    COLUMN_NOT_NULL(url,               TEXT,)
+    COLUMN_NOT_NULL(title,          TEXT,)
+    COLUMN_NOT_NULL(user_allowed,   INT,)
+
+    TABLE_CONSTRAINTS(
+        PRIMARY KEY (app_id, target, base_url, url)
+    )
+CREATE_TABLE_END()
+
+SQL(
+    COMMIT;
+)
+
diff --git a/modules/custom_handler_dao/orm/custom_handler_db_definitions b/modules/custom_handler_dao/orm/custom_handler_db_definitions
new file mode 100644 (file)
index 0000000..1bc2bcd
--- /dev/null
@@ -0,0 +1,6 @@
+DATABASE_START(custom_handler)
+
+#include "custom_handler_db"
+#include "version_db"
+
+DATABASE_END()
diff --git a/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h b/modules/custom_handler_dao/orm/custom_handler_db_sql_generator.h
new file mode 100644 (file)
index 0000000..9b007de
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        custom_handler_db_sql_generator.h
+ * @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version     1.0
+ * @brief       Macro definitions for generating the SQL
+ *                input file from database definition.
+ */
+
+//Do not include this file directly! It is used only for SQL code generation.
+#include <dpl/db/orm_macros.h>
+
+#include "custom_handler_db_definitions"
diff --git a/modules/custom_handler_dao/orm/gen_db_md5.sh b/modules/custom_handler_dao/orm/gen_db_md5.sh
new file mode 100755 (executable)
index 0000000..22c2530
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+CHECKSUM=`cat ${2} ${3} 2>/dev/null | md5sum 2>/dev/null | cut -d\  -f1 2>/dev/null`
+echo "#define DB_CHECKSUM DB_VERSION_${CHECKSUM}" > ${1}
+echo "#define DB_CHECKSUM_STR \"DB_VERSION_${CHECKSUM}\"" >> ${1}
+
diff --git a/modules/custom_handler_dao/orm/orm_generator_custom_handler.h b/modules/custom_handler_dao/orm/orm_generator_custom_handler.h
new file mode 100644 (file)
index 0000000..35c43a2
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _ORM_GENERATOR_CUSTOM_HANDLER_H_
+#define _ORM_GENERATOR_CUSTOM_HANDLER_H_
+
+#define ORM_GENERATOR_DATABASE_NAME custom_handler_db_definitions
+#include <dpl/db/orm_generator.h>
+#undef ORM_GENERATOR_DATABASE_NAME
+
+#endif // _ORM_GENERATOR_CUSTOM_HANDLER_H_
diff --git a/modules/custom_handler_dao/orm/version_db b/modules/custom_handler_dao/orm/version_db
new file mode 100644 (file)
index 0000000..7e20d8d
--- /dev/null
@@ -0,0 +1,5 @@
+SQL(
+    BEGIN TRANSACTION;
+    CREATE TABLE DB_CHECKSUM (version INT);
+    COMMIT;
+)
index 37d268c..2f63a0f 100644 (file)
  * @file        naive_synchronization_object.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        naive_synchronization_object.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of SQL naive synchronization object
+ * @brief       This file is the implementation file of SQL naive
+ * synchronization object
  */
 #ifndef DPL_NAIVE_SYNCHRONIZATION_OBJECT_H
 #define DPL_NAIVE_SYNCHRONIZATION_OBJECT_H
 
 #include <dpl/db/sql_connection.h>
 
  */
 #ifndef DPL_NAIVE_SYNCHRONIZATION_OBJECT_H
 #define DPL_NAIVE_SYNCHRONIZATION_OBJECT_H
 
 #include <dpl/db/sql_connection.h>
 
-namespace DPL
-{
-namespace DB
-{
-
+namespace DPL {
+namespace DB {
 /**
  * Naive synchronization object used to synchronize SQL connection
  * to the same database across different threads and processes
  */
 /**
  * Naive synchronization object used to synchronize SQL connection
  * to the same database across different threads and processes
  */
-class NaiveSynchronizationObject
-    public SqlConnection::SynchronizationObject
+class NaiveSynchronizationObject :
+    public SqlConnection::SynchronizationObject
 {
 {
-public:
+  public:
     // [SqlConnection::SynchronizationObject]
     virtual void Synchronize();
     virtual void NotifyAll();
 };
     // [SqlConnection::SynchronizationObject]
     virtual void Synchronize();
     virtual void NotifyAll();
 };
-
 } // namespace DB
 } // namespace DPL
 
 } // namespace DB
 } // namespace DPL
 
index f4df084..652e8e1 100644 (file)
 #include <string>
 #include <typeinfo>
 #include <utility>
 #include <string>
 #include <typeinfo>
 #include <utility>
+#include <set>
+#include <memory>
 
 #include <dpl/db/sql_connection.h>
 #include <dpl/db/orm_interface.h>
 #include <dpl/string.h>
 #include <dpl/optional.h>
 
 #include <dpl/db/sql_connection.h>
 #include <dpl/db/orm_interface.h>
 #include <dpl/string.h>
 #include <dpl/optional.h>
-#include <dpl/shared_ptr.h>
 #include <dpl/type_list.h>
 #include <dpl/assert.h>
 #include <dpl/type_list.h>
 #include <dpl/assert.h>
+#include <dpl/foreach.h>
 
 #ifndef DPL_ORM_H
 #define DPL_ORM_H
 
 #ifndef DPL_ORM_H
 #define DPL_ORM_H
@@ -48,6 +50,10 @@ namespace ORM {
         (void)_ignored_; \
     }
 
         (void)_ignored_; \
     }
 
+#define DECLARE_COLUMN_TYPE_LIST() typedef DPL::TypeListDecl<
+#define SELECTED_COLUMN(table_name, column_name) table_name::column_name,
+#define DECLARE_COLUMN_TYPE_LIST_END(name) DPL::TypeListGuard>::Type name;
+
 typedef size_t ColumnIndex;
 typedef size_t ArgumentIndex;
 typedef DPL::Optional<DPL::String> OptionalString;
 typedef size_t ColumnIndex;
 typedef size_t ArgumentIndex;
 typedef DPL::Optional<DPL::String> OptionalString;
@@ -60,6 +66,7 @@ namespace RelationTypes {
     extern const char And[];
     extern const char Or[];
     extern const char Is[];
     extern const char And[];
     extern const char Or[];
     extern const char Is[];
+    extern const char In[];
     //TODO define more relation types
 }
 
     //TODO define more relation types
 }
 
@@ -70,17 +77,49 @@ namespace DataCommandUtils {
     void BindArgument(DataCommand *command, ArgumentIndex index, const DPL::String& argument);
     void BindArgument(DataCommand *command, ArgumentIndex index, const OptionalString& argument);
 }
     void BindArgument(DataCommand *command, ArgumentIndex index, const DPL::String& argument);
     void BindArgument(DataCommand *command, ArgumentIndex index, const OptionalString& argument);
 }
-class Expression {
+class __attribute__ ((visibility("hidden"))) Expression {
 public:
     virtual ~Expression() {}
     virtual std::string GetString() const = 0;
     virtual ArgumentIndex BindTo(DataCommand *command, ArgumentIndex index) = 0;
 };
 
 public:
     virtual ~Expression() {}
     virtual std::string GetString() const = 0;
     virtual ArgumentIndex BindTo(DataCommand *command, ArgumentIndex index) = 0;
 };
 
-typedef DPL::SharedPtr<Expression> ExpressionPtr;
+typedef std::shared_ptr<Expression> ExpressionPtr;
+
+namespace OrderingUtils {
+
+template<typename CompoundType> inline std::string OrderByInternal()
+{
+    std::string order = OrderByInternal<typename CompoundType::Tail>();
+    if(!order.empty()) return CompoundType::Head::GetString() + ", " + order;
+    else return CompoundType::Head::GetString();
+}
+
+template<> inline std::string OrderByInternal<TypeListGuard>()
+{
+    return std::string();
+}
+
+}
+
+template<typename ColumnType>
+class __attribute__ ((visibility("hidden"))) OrderingExpression {
+protected:
+    static std::string GetSchemaAndName()
+    {
+        std::string statement;
+        statement += ColumnType::GetTableName();
+        statement += ".";
+        statement += ColumnType::GetColumnName();
+        statement += " ";
+        return statement;
+    }
+public:
+    virtual ~OrderingExpression() {}
+};
 
 template<const char* Operator, typename LeftExpression, typename RightExpression>
 
 template<const char* Operator, typename LeftExpression, typename RightExpression>
-class BinaryExpression : public Expression {
+class __attribute__ ((visibility("hidden"))) BinaryExpression : public Expression {
 protected:
     LeftExpression  m_leftExpression;
     RightExpression m_rightExpression;
 protected:
     LeftExpression  m_leftExpression;
     RightExpression m_rightExpression;
@@ -121,8 +160,16 @@ BinaryExpression<RelationTypes::And, LeftExpression, RightExpression>
             (leftExpression, rightExpression);
 }
 
             (leftExpression, rightExpression);
 }
 
+template<typename LeftExpression, typename RightExpression>
+BinaryExpression<RelationTypes::Or, LeftExpression, RightExpression>
+    Or(const LeftExpression& leftExpression, const RightExpression& rightExpression)
+{
+    return BinaryExpression<RelationTypes::Or, LeftExpression, RightExpression>
+            (leftExpression, rightExpression);
+}
+
 template<typename ArgumentType>
 template<typename ArgumentType>
-class ExpressionWithArgument : public Expression {
+class __attribute__ ((visibility("hidden"))) ExpressionWithArgument : public Expression {
 protected:
     ArgumentType argument;
 
 protected:
     ArgumentType argument;
 
@@ -136,9 +183,8 @@ public:
     }
 };
 
     }
 };
 
-
 template<typename ColumnData, const char* Relation>
 template<typename ColumnData, const char* Relation>
-class Compare : public ExpressionWithArgument<typename ColumnData::ColumnType> {
+class __attribute__ ((visibility("hidden"))) Compare : public ExpressionWithArgument<typename ColumnData::ColumnType> {
 public:
     explicit Compare(typename ColumnData::ColumnType column) :
         ExpressionWithArgument<typename ColumnData::ColumnType>(column)
 public:
     explicit Compare(typename ColumnData::ColumnType column) :
         ExpressionWithArgument<typename ColumnData::ColumnType>(column)
@@ -147,6 +193,8 @@ public:
     virtual std::string GetString() const
     {
         std::string statement;
     virtual std::string GetString() const
     {
         std::string statement;
+        statement += ColumnData::GetTableName();
+        statement += ".";
         statement += ColumnData::GetColumnName();
         statement += " ";
         statement += Relation;
         statement += ColumnData::GetColumnName();
         statement += " ";
         statement += Relation;
@@ -161,7 +209,7 @@ public:
 };
 #define ORM_DEFINE_COMPARE_EXPRESSION(name, relationType)                      \
     template<typename ColumnData>                                              \
 };
 #define ORM_DEFINE_COMPARE_EXPRESSION(name, relationType)                      \
     template<typename ColumnData>                                              \
-    class name : public Compare<ColumnData, RelationTypes::relationType> {     \
+    class __attribute__ ((visibility("hidden"))) name : public Compare<ColumnData, RelationTypes::relationType> {     \
     public:                                                                    \
         name(typename ColumnData::ColumnType column) :                         \
             Compare<ColumnData, RelationTypes::relationType>(column)           \
     public:                                                                    \
         name(typename ColumnData::ColumnType column) :                         \
             Compare<ColumnData, RelationTypes::relationType>(column)           \
@@ -171,12 +219,297 @@ public:
 ORM_DEFINE_COMPARE_EXPRESSION(Equals, Equal)
 ORM_DEFINE_COMPARE_EXPRESSION(Is, Is)
 
 ORM_DEFINE_COMPARE_EXPRESSION(Equals, Equal)
 ORM_DEFINE_COMPARE_EXPRESSION(Is, Is)
 
+#define ORM_DEFINE_ORDERING_EXPRESSION(name, value)                                     \
+    template<typename ColumnType>                                                       \
+    class __attribute__ ((visibility("hidden"))) name                                   \
+        : OrderingExpression<ColumnType> {                                              \
+    public:                                                                             \
+        static std::string GetString()                                                  \
+        {                                                                               \
+            std::string statement = OrderingExpression<ColumnType>::GetSchemaAndName(); \
+            statement += value;                                                         \
+            return statement;                                                           \
+        }                                                                               \
+    };
+
+ORM_DEFINE_ORDERING_EXPRESSION(OrderingAscending, "ASC")
+ORM_DEFINE_ORDERING_EXPRESSION(OrderingDescending, "DESC")
+
+template<typename ColumnData1, typename ColumnData2>
+class __attribute__ ((visibility("hidden"))) CompareBinaryColumn {
+private:
+    std::string m_relation;
+public:
+    CompareBinaryColumn(const char* Relation) :
+      m_relation(Relation)
+    {}
+
+    virtual ~CompareBinaryColumn() {}
+
+    virtual std::string GetString() const
+    {
+        std::string statement;
+        statement += ColumnData1::GetTableName();
+        statement += ".";
+        statement += ColumnData1::GetColumnName();
+        statement += " ";
+        statement += m_relation;
+        statement += " ";
+        statement += ColumnData2::GetTableName();
+        statement += ".";
+        statement += ColumnData2::GetColumnName();
+
+        return statement;
+    }
+};
+
+template<typename ColumnData1, typename ColumnData2>
+CompareBinaryColumn<ColumnData1, ColumnData2>
+    Equal()
+{
+    return CompareBinaryColumn<ColumnData1, ColumnData2>(RelationTypes::Equal);
+}
+
+template<typename ColumnData, const char* Relation>
+class __attribute__ ((visibility("hidden"))) NumerousArguments : public Expression {
+protected:
+    std::set<typename ColumnData::ColumnType> m_argumentList;
+public:
+    NumerousArguments(const std::set<typename ColumnData::ColumnType>& argumentList) : m_argumentList(argumentList) {}
+
+    virtual std::string GetString() const
+    {
+        std::string statement;
+        statement += ColumnData::GetColumnName();
+        statement += " ";
+        statement += Relation;
+        statement += " ( ";
+
+        int argumentCount = m_argumentList.size();
+        while(argumentCount)
+        {
+            statement += "?";
+            argumentCount--;
+            if (argumentCount)
+            {
+                statement += ", ";
+            }
+        }
+
+        statement += " )";
+
+        return statement;
+    }
+
+    virtual ArgumentIndex BindTo(DataCommand *command, ArgumentIndex index)
+    {
+        ArgumentIndex argumentIndex = index;
+        FOREACH(argumentIt, m_argumentList)
+        {
+            DataCommandUtils::BindArgument(command, argumentIndex, *argumentIt);
+            argumentIndex++;
+        }
+        return  argumentIndex + 1;
+    }
+
+    template<typename TableDefinition>
+    struct ValidForTable {
+        typedef typename TableDefinition::ColumnList::template Contains<ColumnData> Yes;
+    };
+};
+
+#define ORM_DEFINE_COMPARE_EXPRESSION_NUMEROUS_ARGUMENTS(name, relationType)                      \
+    template<typename ColumnData>                                              \
+    class __attribute__ ((visibility("hidden"))) name : public NumerousArguments<ColumnData, RelationTypes::relationType> {     \
+    public:                                                                    \
+        name(std::set<typename ColumnData::ColumnType> column) :                         \
+            NumerousArguments<ColumnData, RelationTypes::relationType>(column)           \
+        {}                                                                     \
+    };
+
+ORM_DEFINE_COMPARE_EXPRESSION_NUMEROUS_ARGUMENTS(In, In)
+
 template<typename ColumnType>
 ColumnType GetColumnFromCommand(ColumnIndex columnIndex, DataCommand *command);
 
 template<typename ColumnType>
 ColumnType GetColumnFromCommand(ColumnIndex columnIndex, DataCommand *command);
 
+class __attribute__ ((visibility("hidden"))) CustomColumnBase {
+public:
+    CustomColumnBase() {}
+    virtual ~CustomColumnBase() {}
+};
+
+template<typename ColumnType>
+class __attribute__ ((visibility("hidden"))) CustomColumn : public CustomColumnBase {
+private:
+    ColumnType m_columnData;
+
+public:
+    CustomColumn() {}
+    CustomColumn(ColumnType data)
+    {
+        m_columnData = data;
+    }
+
+    void SetColumnData(ColumnType data)
+    {
+        m_columnData = data;
+    }
+
+    ColumnType GetColumnData() const
+    {
+        return m_columnData;
+    }
+};
+
+template<typename ColumnList>
+class __attribute__ ((visibility("hidden"))) CustomRowUtil {
+public:
+    static void MakeColumnList(std::vector<CustomColumnBase*>& columnList)
+    {
+        typedef CustomColumn<typename ColumnList::Head::ColumnType> Type;
+        Type* pColumn = new Type();
+        columnList.push_back(pColumn);
+        CustomRowUtil<typename ColumnList::Tail>::MakeColumnList(columnList);
+    }
+
+    static void CopyColumnList(const std::vector<CustomColumnBase*>& srcList, std::vector<CustomColumnBase*>& dstList)
+    {
+        CopyColumnList(srcList, dstList, 0);
+    }
+
+    static ColumnIndex GetColumnIndex(const std::string& columnName)
+    {
+        return GetColumnIndex(columnName, 0);
+    }
+
+private:
+    static void CopyColumnList(const std::vector<CustomColumnBase*>& srcList, std::vector<CustomColumnBase*>& dstList, ColumnIndex index)
+    {
+        typedef CustomColumn<typename ColumnList::Head::ColumnType> Type;
+        Type* pColumn = new Type(((Type*)(srcList.at(index)))->GetColumnData());
+        dstList.push_back(pColumn);
+        CustomRowUtil<typename ColumnList::Tail>::CopyColumnList(srcList, dstList, index + 1);
+    }
+
+    static ColumnIndex GetColumnIndex(const std::string& columnName, ColumnIndex index)
+    {
+        if (ColumnList::Head::GetColumnName() == columnName)
+            return index;
+
+        return CustomRowUtil<typename ColumnList::Tail>::GetColumnIndex(columnName, index + 1);
+    }
+
+template<typename Other>
+friend class CustomRowUtil;
+};
+
+template<>
+class __attribute__ ((visibility("hidden"))) CustomRowUtil<DPL::TypeListGuard> {
+public:
+    static void MakeColumnList(std::vector<CustomColumnBase*>&) {}
+private:
+    static void CopyColumnList(const std::vector<CustomColumnBase*>&, std::vector<CustomColumnBase*>&, ColumnIndex) {}
+    static ColumnIndex GetColumnIndex(const std::string&, ColumnIndex) { return -1; }
+
+template<typename Other>
+friend class CustomRowUtil;
+};
+
+template<typename ColumnList>
+class __attribute__ ((visibility("hidden"))) CustomRow {
+private:
+    std::vector<CustomColumnBase*> m_columns;
+
+public:
+    CustomRow()
+    {
+        CustomRowUtil<ColumnList>::MakeColumnList(m_columns);
+    }
+
+    CustomRow(const CustomRow& r)
+    {
+        CustomRowUtil<ColumnList>::CopyColumnList(r.m_columns, m_columns);
+    }
+
+    virtual ~CustomRow()
+    {
+        while (!m_columns.empty())
+        {
+            CustomColumnBase* pCustomColumn = m_columns.back();
+            m_columns.pop_back();
+            if (pCustomColumn)
+                delete pCustomColumn;
+        }
+    }
+
+    template<typename ColumnType>
+    void SetColumnData(ColumnIndex columnIndex, ColumnType data)
+    {
+        typedef CustomColumn<ColumnType> Type;
+        Assert(columnIndex < m_columns.size());
+        Type* pColumn = dynamic_cast<Type*>(m_columns.at(columnIndex));
+        Assert(pColumn);
+        pColumn->SetColumnData(data);
+    }
+
+    template<typename ColumnData>
+    typename ColumnData::ColumnType GetColumnData()
+    {
+        typedef CustomColumn<typename ColumnData::ColumnType> Type;
+        ColumnIndex index = CustomRowUtil<ColumnList>::GetColumnIndex(ColumnData::GetColumnName());
+        Assert(index < m_columns.size());
+        Type* pColumn = dynamic_cast<Type*>(m_columns.at(index));
+        Assert(pColumn);
+        return pColumn->GetColumnData();
+    }
+};
+
+template<typename CustomRow, typename ColumnType>
+void SetColumnData(CustomRow& row, ColumnType columnData, ColumnIndex columnIndex)
+{
+    row.SetColumnData<ColumnType>(columnIndex, columnData);
+}
+
+template<typename ColumnList, typename CustomRow>
+class  __attribute__ ((visibility("hidden"))) FillCustomRowUtil {
+public:
+    static void FillCustomRow(CustomRow& row, DataCommand* command)
+    {
+        FillCustomRow(row, 0, command);
+    }
+
+private:
+    static void FillCustomRow(CustomRow& row, ColumnIndex columnIndex, DataCommand* command)
+    {
+        typename ColumnList::Head::ColumnType columnData;
+        columnData = GetColumnFromCommand<typename ColumnList::Head::ColumnType>(columnIndex, command);
+        SetColumnData<CustomRow, typename ColumnList::Head::ColumnType>(row, columnData, columnIndex);
+        FillCustomRowUtil<typename ColumnList::Tail, CustomRow>::FillCustomRow(row, columnIndex + 1, command);
+    }
+
+template<typename Other, typename OtherRow>
+friend class FillCustomRowUtil;
+};
+
+template<typename CustomRow>
+class  __attribute__ ((visibility("hidden"))) FillCustomRowUtil<DPL::TypeListGuard, CustomRow> {
+private:
+    static void FillCustomRow(CustomRow&, ColumnIndex, DataCommand *)
+    { /* do nothing, we're past the last element of column list */ }
+
+template<typename Other, typename OtherRow>
+friend class FillCustomRowUtil;
+};
+
 template<typename ColumnList, typename Row>
 template<typename ColumnList, typename Row>
-class FillRowUtil {
+class  __attribute__ ((visibility("hidden"))) FillRowUtil {
 public:
 public:
+    static void FillRow(Row& row, DataCommand *command)
+    {
+        FillRow(row, 0, command);
+    }
+
+private:
     static void FillRow(Row& row, ColumnIndex columnIndex, DataCommand *command)
     {
         typename ColumnList::Head::ColumnType rowField;
     static void FillRow(Row& row, ColumnIndex columnIndex, DataCommand *command)
     {
         typename ColumnList::Head::ColumnType rowField;
@@ -184,13 +517,51 @@ public:
         ColumnList::Head::SetRowField(row, rowField);
         FillRowUtil<typename ColumnList::Tail, Row>::FillRow(row, columnIndex + 1, command);
     }
         ColumnList::Head::SetRowField(row, rowField);
         FillRowUtil<typename ColumnList::Tail, Row>::FillRow(row, columnIndex + 1, command);
     }
+
+template<typename Other, typename OtherRow>
+friend class FillRowUtil;
 };
 
 template<typename Row>
 };
 
 template<typename Row>
-class FillRowUtil<DPL::TypeListGuard, Row> {
-public:
+class  __attribute__ ((visibility("hidden"))) FillRowUtil<DPL::TypeListGuard, Row> {
+private:
     static void FillRow(Row&, ColumnIndex, DataCommand *)
     { /* do nothing, we're past the last element of column list */ }
     static void FillRow(Row&, ColumnIndex, DataCommand *)
     { /* do nothing, we're past the last element of column list */ }
+
+template<typename Other, typename OtherRow>
+friend class FillRowUtil;
+};
+
+template<typename ColumnList>
+class  __attribute__ ((visibility("hidden"))) JoinUtil {
+public:
+    static std::string GetColumnNames()
+    {
+        std::string result;
+        result = ColumnList::Head::GetTableName();
+        result += ".";
+        result += ColumnList::Head::GetColumnName();
+        if (ColumnList::Tail::Size > 0)
+            result += ", ";
+
+        return result += JoinUtil<typename ColumnList::Tail>::GetColumnNames();
+    }
+
+    static std::string GetJoinTableName(const std::string& tableName)
+    {
+        std::string joinTableName = ColumnList::Head::GetTableName();
+        if (tableName.find(joinTableName) == std::string::npos)
+            return joinTableName;
+
+        return JoinUtil<typename ColumnList::Tail>::GetJoinTableName(tableName);
+    }
+};
+
+template<>
+class  __attribute__ ((visibility("hidden"))) JoinUtil<DPL::TypeListGuard> {
+public:
+    static std::string GetColumnNames() { return ""; }
+    static std::string GetJoinTableName(std::string) { return ""; }
 };
 
 class Exception {
 };
 
 class Exception {
@@ -202,7 +573,7 @@ public:
 };
 
 template<typename TableDefinition>
 };
 
 template<typename TableDefinition>
-class Query
+class  __attribute__ ((visibility("hidden"))) Query
 {
 protected:
     explicit Query(IOrmInterface* interface) :
 {
 protected:
     explicit Query(IOrmInterface* interface) :
@@ -226,7 +597,7 @@ protected:
 };
 
 template<typename TableDefinition>
 };
 
 template<typename TableDefinition>
-class QueryWithWhereClause : public Query<TableDefinition>
+class  __attribute__ ((visibility("hidden"))) QueryWithWhereClause : public Query<TableDefinition>
 {
 protected:
     ExpressionPtr m_whereExpression;
 {
 protected:
     ExpressionPtr m_whereExpression;
@@ -271,13 +642,13 @@ public:
                 str.str());
         }
         //TODO maybe don't make a copy here but just generate the string part of the query.
                 str.str());
         }
         //TODO maybe don't make a copy here but just generate the string part of the query.
-        m_whereExpression.Reset(new Expression(expression));
+        m_whereExpression.reset(new Expression(expression));
     }
 
 };
 
 template<typename TableDefinition>
     }
 
 };
 
 template<typename TableDefinition>
-class Delete : public QueryWithWhereClause<TableDefinition>
+class  __attribute__ ((visibility("hidden"))) Delete : public QueryWithWhereClause<TableDefinition>
 {
 protected:
     void Prepare()
 {
 protected:
     void Prepare()
@@ -317,8 +688,31 @@ public:
     }
 };
 
     }
 };
 
+namespace {
+class BindVisitor {
+private:
+    DataCommand *m_command;
+public:
+    ArgumentIndex m_bindArgumentIndex;
+
+    BindVisitor(DataCommand *command) :
+        m_command(command),
+        m_bindArgumentIndex(1)
+    {}
+
+    template<typename ColumnType>
+    void Visit(const char*, const ColumnType& value, bool isSet)
+    {
+        if ( isSet )
+        {
+            DataCommandUtils::BindArgument(m_command, m_bindArgumentIndex, value);
+            m_bindArgumentIndex++;
+        }
+    }
+};
+} //anonymous namespace
 template<typename TableDefinition>
 template<typename TableDefinition>
-class Insert : public Query<TableDefinition>
+class __attribute__ ((visibility("hidden"))) Insert : public Query<TableDefinition>
 {
 public:
     typedef typename TableDefinition::Row Row;
 {
 public:
     typedef typename TableDefinition::Row Row;
@@ -374,27 +768,6 @@ protected:
         }
     }
 
         }
     }
 
-    class BindVisitor {
-    private:
-        DataCommand *m_command;
-        ArgumentIndex m_bindArgumentIndex;
-    public:
-        BindVisitor(DataCommand *command) :
-            m_command(command),
-            m_bindArgumentIndex(1)
-        {}
-
-        template<typename ColumnType>
-        void Visit(const char*, const ColumnType& value, bool isSet)
-        {
-            if ( isSet )
-            {
-                DataCommandUtils::BindArgument(m_command, m_bindArgumentIndex, value);
-                m_bindArgumentIndex++;
-            }
-        }
-    };
-
     void Bind()
     {
         BindVisitor visitor(this->m_command);
     void Bind()
     {
         BindVisitor visitor(this->m_command);
@@ -439,7 +812,7 @@ public:
 };
 
 template<typename TableDefinition>
 };
 
 template<typename TableDefinition>
-class Select : public QueryWithWhereClause<TableDefinition>
+class __attribute__ ((visibility("hidden"))) Select : public QueryWithWhereClause<TableDefinition>
 {
 public:
     typedef typename TableDefinition::ColumnList       ColumnList;
 {
 public:
     typedef typename TableDefinition::ColumnList       ColumnList;
@@ -448,6 +821,7 @@ public:
     typedef std::list<Row>                             RowList;
 protected:
     DPL::Optional<std::string> m_orderBy;
     typedef std::list<Row>                             RowList;
 protected:
     DPL::Optional<std::string> m_orderBy;
+    std::string m_JoinClause;
     bool                       m_distinctResults;
 
     void Prepare(const char* selectColumnName)
     bool                       m_distinctResults;
 
     void Prepare(const char* selectColumnName)
@@ -461,6 +835,8 @@ protected:
             this->m_commandString += " FROM ";
             this->m_commandString += TableDefinition::GetName();
 
             this->m_commandString += " FROM ";
             this->m_commandString += TableDefinition::GetName();
 
+            this->m_commandString += m_JoinClause;
+
             QueryWithWhereClause<TableDefinition>::Prepare();
 
             if ( !m_orderBy.IsNull() )
             QueryWithWhereClause<TableDefinition>::Prepare();
 
             if ( !m_orderBy.IsNull() )
@@ -491,7 +867,15 @@ protected:
     Row GetRow()
     {
         Row row;
     Row GetRow()
     {
         Row row;
-        FillRowUtil<ColumnList, Row>::FillRow(row, 0, this->m_command);
+        FillRowUtil<ColumnList, Row>::FillRow(row, this->m_command);
+        return row;
+    }
+
+    template<typename ColumnList, typename CustomRow>
+    CustomRow GetCustomRow()
+    {
+        CustomRow row;
+        FillCustomRowUtil<ColumnList, CustomRow>::FillCustomRow(row, this->m_command);
         return row;
     }
 
         return row;
     }
 
@@ -508,11 +892,34 @@ public:
         m_distinctResults = true;
     }
 
         m_distinctResults = true;
     }
 
-    void OrderBy(const std::string& orderBy)
+    template<typename CompoundType>
+    void OrderBy(const CompoundType&)
+    {
+        m_orderBy = OrderingUtils::OrderByInternal<typename CompoundType::Type>();
+    }
+
+    void OrderBy(const std::string & orderBy) //backward compatibility
     {
         m_orderBy = orderBy;
     }
 
     {
         m_orderBy = orderBy;
     }
 
+    void OrderBy(const char * orderBy) //backward compatibility
+    {
+        m_orderBy = std::string(orderBy);
+    }
+
+    template<typename ColumnList, typename Expression>
+    void Join(const Expression& expression) {
+        std::string usedTableNames = TableDefinition::GetName();
+        if (!m_JoinClause.empty())
+            usedTableNames += m_JoinClause;
+
+        this->m_JoinClause += " JOIN ";
+        this->m_JoinClause += JoinUtil<ColumnList>::GetJoinTableName(usedTableNames);
+        this->m_JoinClause += " ON ";
+        this->m_JoinClause += expression.GetString();
+    }
+
     template<typename ColumnData>
     typename ColumnData::ColumnType GetSingleValue()
     {
     template<typename ColumnData>
     typename ColumnData::ColumnType GetSingleValue()
     {
@@ -569,10 +976,38 @@ public:
         this->m_command->Reset();
         return resultList;
     }
         this->m_command->Reset();
         return resultList;
     }
+
+    template<typename ColumnList, typename CustomRow>
+    CustomRow GetCustomSingleRow()
+    {
+        Prepare(JoinUtil<ColumnList>::GetColumnNames().c_str());
+        Bind();
+        this->m_command->Step();
+
+        CustomRow result = GetCustomRow<ColumnList, CustomRow>();
+
+        this->m_command->Reset();
+        return result;
+    }
+
+    template<typename ColumnList, typename CustomRow>
+    std::list<CustomRow> GetCustomRowList()
+    {
+        Prepare(JoinUtil<ColumnList>::GetColumnNames().c_str());
+        Bind();
+
+        std::list<CustomRow> resultList;
+
+        while (this->m_command->Step())
+            resultList.push_back(GetCustomRow<ColumnList, CustomRow>());
+
+        this->m_command->Reset();
+        return resultList;
+    }
 };
 
 template<typename TableDefinition>
 };
 
 template<typename TableDefinition>
-class Update : public QueryWithWhereClause<TableDefinition> {
+class __attribute__ ((visibility("hidden"))) Update : public QueryWithWhereClause<TableDefinition> {
 public:
     typedef typename TableDefinition::Row Row;
 
 public:
     typedef typename TableDefinition::Row Row;
 
@@ -633,29 +1068,6 @@ protected:
         }
     }
 
         }
     }
 
-    class BindVisitor {
-    private:
-        DataCommand *m_command;
-
-    public:
-        ArgumentIndex m_bindArgumentIndex;
-
-        BindVisitor(DataCommand *command) :
-            m_command(command),
-            m_bindArgumentIndex(1)
-        {}
-
-        template<typename ColumnType>
-        void Visit(const char*, const ColumnType& value, bool isSet)
-        {
-            if ( isSet )
-            {
-                DataCommandUtils::BindArgument(m_command, m_bindArgumentIndex, value);
-                m_bindArgumentIndex++;
-            }
-        }
-    };
-
     void Bind()
     {
         BindVisitor visitor(this->m_command);
     void Bind()
     {
         BindVisitor visitor(this->m_command);
index 61ff9ca..8bd9fdb 100644 (file)
@@ -70,8 +70,9 @@ namespace ORM {
 #define DECLARE_COLUMN(FIELD, TYPE) \
     struct FIELD { \
         typedef TYPE ColumnType; \
 #define DECLARE_COLUMN(FIELD, TYPE) \
     struct FIELD { \
         typedef TYPE ColumnType; \
+        static const char* GetTableName() { return GetName(); } \
         static const char* GetColumnName() { return STRINGIFY(FIELD); } \
         static const char* GetColumnName() { return STRINGIFY(FIELD); } \
-        static void SetRowField(Row& row, const TYPE& value) { row.Set_##FIELD(value);} \
+        static void SetRowField(Row& row, const TYPE& _value) { row.Set_##FIELD(_value);} \
     };
 
 #define INT         int
     };
 
 #define INT         int
@@ -81,8 +82,8 @@ namespace ORM {
 #define VARCHAR(x)  DPL::String
 #define TEXT        DPL::String
 
 #define VARCHAR(x)  DPL::String
 #define TEXT        DPL::String
 
-#define SQL(args...)
-#define TABLE_CONSTRAINTS(args...)
+#define SQL(...)
+#define TABLE_CONSTRAINTS(...)
 #define OPTIONAL(type) DPL::Optional< type >
 #define DATABASE_START(db_name)                                 \
     namespace db_name                                           \
 #define OPTIONAL(type) DPL::Optional< type >
 #define DATABASE_START(db_name)                                 \
     namespace db_name                                           \
@@ -123,8 +124,8 @@ namespace ORM {
         class RowBase;                                                          \
         inline std::ostream& operator<<(std::ostream& ostr, const RowBase& row); \
     }
         class RowBase;                                                          \
         inline std::ostream& operator<<(std::ostream& ostr, const RowBase& row); \
     }
-#define COLUMN_NOT_NULL(name, type, args...)
-#define COLUMN(name, type, args...)
+#define COLUMN_NOT_NULL(name, type, ...)
+#define COLUMN(name, type, ...)
 #define CREATE_TABLE_END()
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END()
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -141,11 +142,11 @@ namespace ORM {
 
 #define CREATE_TABLE(name) namespace name { class RowBase {                 \
    public: friend std::ostream& operator<<(std::ostream&, const RowBase&);
 
 #define CREATE_TABLE(name) namespace name { class RowBase {                 \
    public: friend std::ostream& operator<<(std::ostream&, const RowBase&);
-#define COLUMN_NOT_NULL(name, type, args...)                                \
+#define COLUMN_NOT_NULL(name, type, ...)                                \
         protected: type name; bool m_##name##_set;                          \
         protected: type name; bool m_##name##_set;                          \
-        public:  void Set_##name(const type& value) {                       \
+        public:  void Set_##name(const type& _value) {                       \
                      m_##name##_set = true;                                 \
                      m_##name##_set = true;                                 \
-                     this->name = value;                                     \
+                     this->name = _value;                                     \
         }                                                                   \
         public:  type Get_##name() const {                                  \
                      if ( !m_##name##_set ) {                               \
         }                                                                   \
         public:  type Get_##name() const {                                  \
                      if ( !m_##name##_set ) {                               \
@@ -155,11 +156,11 @@ namespace ORM {
                      return name;                                           \
         }
 
                      return name;                                           \
         }
 
-#define COLUMN(name, type, args...)                                         \
+#define COLUMN(name, type, ...)                                         \
         protected: OPTIONAL(type) name; bool m_##name##_set;                \
         protected: OPTIONAL(type) name; bool m_##name##_set;                \
-        public:  void Set_##name(const OPTIONAL(type)& value) {             \
+        public:  void Set_##name(const OPTIONAL(type)& _value) {             \
                      m_##name##_set = true;                                 \
                      m_##name##_set = true;                                 \
-                     this->name = value;                                     \
+                     this->name = _value;                                     \
         }                                                                   \
         public:  OPTIONAL(type) Get_##name() const {                        \
                      if ( !m_##name##_set ) {                               \
         }                                                                   \
         public:  OPTIONAL(type) Get_##name() const {                        \
                      if ( !m_##name##_set ) {                               \
@@ -180,8 +181,8 @@ namespace ORM {
 // RowBase ostream operator<<
 
 #define CREATE_TABLE(name) std::ostream& name::operator<<(std::ostream& ostr, const RowBase& row) { using ::operator<< ; ostr << STRINGIFY(name) << " (";
 // RowBase ostream operator<<
 
 #define CREATE_TABLE(name) std::ostream& name::operator<<(std::ostream& ostr, const RowBase& row) { using ::operator<< ; ostr << STRINGIFY(name) << " (";
-#define COLUMN_NOT_NULL(name, type, args...) ostr << " '" << row.name << "'" ;
-#define COLUMN(name, type, args...)          ostr << " '" << row.name << "'" ;
+#define COLUMN_NOT_NULL(name, type, ...) ostr << " '" << row.name << "'" ;
+#define COLUMN(name, type, ...)          ostr << " '" << row.name << "'" ;
 #define CREATE_TABLE_END() ostr << " )" ; return ostr; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() ostr << " )" ; return ostr; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -195,8 +196,8 @@ namespace ORM {
 
 #define CREATE_TABLE(name) namespace name { class RowBase2 : public RowBase { \
     public: bool operator==(const RowBase2& row) const { return true
 
 #define CREATE_TABLE(name) namespace name { class RowBase2 : public RowBase { \
     public: bool operator==(const RowBase2& row) const { return true
-#define COLUMN_NOT_NULL(name, type, args...) && (this->name == row.name)
-#define COLUMN(name, type, args...)          && (this->name == row.name)
+#define COLUMN_NOT_NULL(name, type, ...) && (this->name == row.name)
+#define COLUMN(name, type, ...)          && (this->name == row.name)
 #define CREATE_TABLE_END() ; } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() ; } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -210,8 +211,8 @@ namespace ORM {
 
 #define CREATE_TABLE(name) namespace name { class RowBase3 : public RowBase2 { \
     public: bool operator<(const RowBase3& row) const {
 
 #define CREATE_TABLE(name) namespace name { class RowBase3 : public RowBase2 { \
     public: bool operator<(const RowBase3& row) const {
-#define COLUMN_NOT_NULL(name, type, args...) if (this->name < row.name) { return true; } if (this->name > row.name) { return false; }
-#define COLUMN(name, type, args...)          if (this->name < row.name) { return true; } if (this->name > row.name) { return false; }
+#define COLUMN_NOT_NULL(name, type, ...) if (this->name < row.name) { return true; } if (this->name > row.name) { return false; }
+#define COLUMN(name, type, ...)          if (this->name < row.name) { return true; } if (this->name > row.name) { return false; }
 #define CREATE_TABLE_END() return false; } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() return false; } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -225,8 +226,8 @@ namespace ORM {
 
 #define CREATE_TABLE(name) namespace name { class RowBase4 : public RowBase3 { \
     public: bool IsSignatureMatching(const RowBase4& row) const { return true
 
 #define CREATE_TABLE(name) namespace name { class RowBase4 : public RowBase3 { \
     public: bool IsSignatureMatching(const RowBase4& row) const { return true
-#define COLUMN_NOT_NULL(name, type, args...) && (this->m_##name##_set == row.m_##name##_set)
-#define COLUMN(name, type, args...)          && (this->m_##name##_set == row.m_##name##_set)
+#define COLUMN_NOT_NULL(name, type, ...) && (this->m_##name##_set == row.m_##name##_set)
+#define COLUMN(name, type, ...)          && (this->m_##name##_set == row.m_##name##_set)
 #define CREATE_TABLE_END() ; } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() ; } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -240,8 +241,8 @@ namespace ORM {
 
 #define CREATE_TABLE(name) namespace name { class RowBase5 : public RowBase4 { \
     public: RowBase5() {
 
 #define CREATE_TABLE(name) namespace name { class RowBase5 : public RowBase4 { \
     public: RowBase5() {
-#define COLUMN_NOT_NULL(name, type, args...) m_##name##_set = false;
-#define COLUMN(name, type, args...)          m_##name##_set = false;
+#define COLUMN_NOT_NULL(name, type, ...) m_##name##_set = false;
+#define COLUMN(name, type, ...)          m_##name##_set = false;
 #define CREATE_TABLE_END() } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -256,8 +257,8 @@ namespace ORM {
 #define CREATE_TABLE(name) namespace name { class Row : public RowBase5 { \
     public: template<typename Visitor>                                    \
     void VisitColumns(Visitor& visitor) const {
 #define CREATE_TABLE(name) namespace name { class Row : public RowBase5 { \
     public: template<typename Visitor>                                    \
     void VisitColumns(Visitor& visitor) const {
-#define COLUMN_NOT_NULL(name, type, args...) visitor.Visit(STRINGIFY(name), this->name, this->m_##name##_set);
-#define COLUMN(name, type, args...)          visitor.Visit(STRINGIFY(name), this->name, this->m_##name##_set);
+#define COLUMN_NOT_NULL(name, type, ...) visitor.Visit(STRINGIFY(name), this->name, this->m_##name##_set);
+#define COLUMN(name, type, ...)          visitor.Visit(STRINGIFY(name), this->name, this->m_##name##_set);
 #define CREATE_TABLE_END() } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() } }; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -269,9 +270,10 @@ namespace ORM {
 
 // Field structure declarations
 
 
 // Field structure declarations
 
-#define CREATE_TABLE(name) namespace name {
-#define COLUMN_NOT_NULL(name, type, args...) DECLARE_COLUMN(name, type)
-#define COLUMN(name, type, args...) DECLARE_COLUMN(name, OPTIONAL(type))
+#define CREATE_TABLE(name) namespace name { \
+    static const char* GetName() { return STRINGIFY(name); }
+#define COLUMN_NOT_NULL(name, type, ...) DECLARE_COLUMN(name, type)
+#define COLUMN(name, type, ...) DECLARE_COLUMN(name, OPTIONAL(type))
 #define CREATE_TABLE_END() }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -284,8 +286,8 @@ namespace ORM {
 // ColumnList typedef
 
 #define CREATE_TABLE(name) namespace name { typedef DPL::TypeListDecl<
 // ColumnList typedef
 
 #define CREATE_TABLE(name) namespace name { typedef DPL::TypeListDecl<
-#define COLUMN_NOT_NULL(name, type, args...) name,
-#define COLUMN(name, type, args...) name,
+#define COLUMN_NOT_NULL(name, type, ...) name,
+#define COLUMN(name, type, ...) name,
 #define CREATE_TABLE_END() DPL::TypeListGuard>::Type ColumnList; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END() DPL::TypeListGuard>::Type ColumnList; }
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -326,8 +328,8 @@ namespace ORM {
         };                                                                  \
     }
 
         };                                                                  \
     }
 
-#define COLUMN_NOT_NULL(name, type, args...)
-#define COLUMN(name, type, args...)
+#define COLUMN_NOT_NULL(name, type, ...)
+#define COLUMN(name, type, ...)
 #define CREATE_TABLE_END()
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END()
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
@@ -346,8 +348,8 @@ namespace ORM {
         typedef Delete<TableDefinition> Delete; \
         typedef Update<TableDefinition> Update; \
     }
         typedef Delete<TableDefinition> Delete; \
         typedef Update<TableDefinition> Update; \
     }
-#define COLUMN_NOT_NULL(name, type, args...)
-#define COLUMN(name, type, args...)
+#define COLUMN_NOT_NULL(name, type, ...)
+#define COLUMN(name, type, ...)
 #define CREATE_TABLE_END()
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
 #define CREATE_TABLE_END()
 
 #include ORM_GENERATOR_DATABASE_NAME_LOCAL
index 74908fd..62ec073 100644 (file)
 #ifndef DPL_ORM_INTERFACE_H
 #define DPL_ORM_INTERFACE_H
 
 #ifndef DPL_ORM_INTERFACE_H
 #define DPL_ORM_INTERFACE_H
 
-namespace DPL
-{
-namespace DB
-{
-namespace ORM
-{
-
+namespace DPL {
+namespace DB {
+namespace ORM {
 class IOrmInterface
 {
   public:
     virtual ~IOrmInterface() {}
 class IOrmInterface
 {
   public:
     virtual ~IOrmInterface() {}
-    virtual DPL::DB::SqlConnection::DataCommand *AllocDataCommand(const std::string &statement) = 0;
-    virtual void FreeDataCommand(DPL::DB::SqlConnection::DataCommand *command) = 0;
+    virtual DPL::DB::SqlConnection::DataCommand *AllocDataCommand(
+        const std::string &statement) = 0;
+    virtual void FreeDataCommand(DPL::DB::SqlConnection::DataCommand *command)
+        = 0;
     virtual void TransactionBegin() = 0;
     virtual void TransactionCommit() = 0;
     virtual void TransactionRollback() = 0;
     virtual DPL::DB::SqlConnection::RowID GetLastInsertRowID() = 0;
 };
     virtual void TransactionBegin() = 0;
     virtual void TransactionCommit() = 0;
     virtual void TransactionRollback() = 0;
     virtual DPL::DB::SqlConnection::RowID GetLastInsertRowID() = 0;
 };
-
 }
 }
 }
 }
 }
 }
index 804f59a..a038523 100644 (file)
  * @file        orm_macros.h
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @version     1.0
  * @file        orm_macros.h
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @version     1.0
- * @brief       Macro definitions for generating the SQL input file from database definition.
+ * @brief       Macro definitions for generating the SQL input file from
+ * database definition.
  */
 
 //Do not include this file directly! It is used only for SQL code generation.
 
  */
 
 //Do not include this file directly! It is used only for SQL code generation.
 
-#define CREATE_TABLE(name) CREATE TABLE name (
-#define COLUMN(name, type, args...) name type args ,
-#define COLUMN_NOT_NULL(name, type, args...) name type args not null,
-#define SQL(args...) args
-#define TABLE_CONSTRAINTS(args...) args ,
+#define CREATE_TABLE(name) CREATE TABLE name(
+#define COLUMN(name, type, ...) name type __VA_ARGS__,
+#define COLUMN_NOT_NULL(name, type, ...) name type __VA_ARGS__ not null,
+#define SQL(...) __VA_ARGS__
+#define TABLE_CONSTRAINTS(...) __VA_ARGS__,
 #define CREATE_TABLE_END() CHECK(1) );
 #define DATABASE_START(db_name)
 #define DATABASE_END()
 #define CREATE_TABLE_END() CHECK(1) );
 #define DATABASE_START(db_name)
 #define DATABASE_END()
index 1d032ee..5a3b0c1 100644 (file)
@@ -25,7 +25,7 @@
 #include <dpl/noncopyable.h>
 #include <dpl/exception.h>
 #include <dpl/optional.h>
 #include <dpl/noncopyable.h>
 #include <dpl/exception.h>
 #include <dpl/optional.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
 #include <dpl/string.h>
 #include <dpl/log/log.h>
 #include <sqlite3.h>
 #include <dpl/string.h>
 #include <dpl/log/log.h>
 #include <sqlite3.h>
 #include <memory>
 #include <stdint.h>
 
 #include <memory>
 #include <stdint.h>
 
-namespace DPL
-{
-namespace DB
-{
-
+namespace DPL {
+namespace DB {
 /**
  * SQL connection class
  */
 class SqlConnection
 {
 /**
  * SQL connection class
  */
 class SqlConnection
 {
-public:
+  public:
     /**
      * SQL Exception classes
      */
     class Exception
     {
     /**
      * SQL Exception classes
      */
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, SyntaxError)
         DECLARE_EXCEPTION_TYPE(Base, ConnectionBroken)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, SyntaxError)
         DECLARE_EXCEPTION_TYPE(Base, ConnectionBroken)
@@ -64,10 +61,10 @@ public:
     /*
      * SQL processed data command
      */
     /*
      * SQL processed data command
      */
-    class DataCommand
-        private Noncopyable
+    class DataCommand :
+        private Noncopyable
     {
     {
-    private:
+      private:
         SqlConnection *m_masterConnection;
         sqlite3_stmt *m_stmt;
 
         SqlConnection *m_masterConnection;
         sqlite3_stmt *m_stmt;
 
@@ -78,7 +75,7 @@ public:
 
         friend class SqlConnection;
 
 
         friend class SqlConnection;
 
-    public:
+      public:
         virtual ~DataCommand();
 
         /**
         virtual ~DataCommand();
 
         /**
@@ -371,11 +368,23 @@ public:
     // Open flags
     class Flag
     {
     // Open flags
     class Flag
     {
-    public:
+      public:
         enum Type
         {
         enum Type
         {
-            None      = 1<<0,
-            UseLucene = 1<<1
+            None = 1 << 0,
+            UseLucene = 1 << 1
+        };
+
+        enum Option
+        {
+            RO = SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READONLY,
+            /**
+             * *TODO: please remove CREATE option from RW flag when all places
+             *      that need that switched do CRW
+             */
+            RW = SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE |
+                SQLITE_OPEN_CREATE,
+            CRW = RW | SQLITE_OPEN_CREATE
         };
     };
 
         };
     };
 
@@ -388,7 +397,7 @@ public:
      */
     class SynchronizationObject
     {
      */
     class SynchronizationObject
     {
-    public:
+      public:
         virtual ~SynchronizationObject() {}
 
         /**
         virtual ~SynchronizationObject() {}
 
         /**
@@ -402,7 +411,7 @@ public:
         virtual void NotifyAll() = 0;
     };
 
         virtual void NotifyAll() = 0;
     };
 
-protected:
+  protected:
     sqlite3 *m_connection;
 
     // Options
     sqlite3 *m_connection;
 
     // Options
@@ -412,16 +421,17 @@ protected:
     int m_dataCommandsCount;
 
     // Synchronization object
     int m_dataCommandsCount;
 
     // Synchronization object
-    ScopedPtr<SynchronizationObject> m_synchronizationObject;
+    std::unique_ptr<SynchronizationObject> m_synchronizationObject;
 
 
-    virtual void Connect(const std::string &address, Flag::Type = Flag::None);
+    virtual void Connect(const std::string &address,
+                         Flag::Type = Flag::None, Flag::Option = Flag::RO);
     virtual void Disconnect();
 
     void TurnOnForeignKeys();
 
     static SynchronizationObject *AllocDefaultSynchronizationObject();
 
     virtual void Disconnect();
 
     void TurnOnForeignKeys();
 
     static SynchronizationObject *AllocDefaultSynchronizationObject();
 
-public:
+  public:
     /**
      * Open SQL connection
      *
     /**
      * Open SQL connection
      *
@@ -436,6 +446,7 @@ public:
      */
     explicit SqlConnection(const std::string &address = std::string(),
                            Flag::Type flags = Flag::None,
      */
     explicit SqlConnection(const std::string &address = std::string(),
                            Flag::Type flags = Flag::None,
+                           Flag::Option options = Flag::RO,
                            SynchronizationObject *synchronizationObject =
                                AllocDefaultSynchronizationObject());
 
                            SynchronizationObject *synchronizationObject =
                                AllocDefaultSynchronizationObject());
 
@@ -475,7 +486,6 @@ public:
      */
     RowID GetLastInsertRowID() const;
 };
      */
     RowID GetLastInsertRowID() const;
 };
-
 } // namespace DB
 } // namespace DPL
 
 } // namespace DB
 } // namespace DPL
 
index 2f45f0f..52cfb33 100644 (file)
 #include <dpl/assert.h>
 #include <stdint.h>
 
 #include <dpl/assert.h>
 #include <stdint.h>
 
-namespace DPL
-{
-namespace DB
-{
-
+namespace DPL {
+namespace DB {
 /**
  * Thread database support
  *
 /**
  * Thread database support
  *
@@ -142,14 +139,14 @@ class ThreadDatabaseSupport :
                           DPL::DB::SqlConnection::Flag::Type flags) :
         m_address(address),
         m_flags(flags)
                           DPL::DB::SqlConnection::Flag::Type flags) :
         m_address(address),
         m_flags(flags)
-    {
-    }
+    {}
 
     virtual ~ThreadDatabaseSupport()
 
     virtual ~ThreadDatabaseSupport()
-    {
-    }
+    {}
 
 
-    void AttachToThread()
+    void AttachToThread(
+        DPL::DB::SqlConnection::Flag::Option options =
+            DPL::DB::SqlConnection::Flag::RO)
     {
         Linger() = false;
 
     {
         Linger() = false;
 
@@ -162,7 +159,8 @@ class ThreadDatabaseSupport :
         // Initialize SQL connection described in traits
         LogInfo("Attaching thread database connection: " << m_address);
 
         // Initialize SQL connection described in traits
         LogInfo("Attaching thread database connection: " << m_address);
 
-        Connection() = new DPL::DB::SqlConnection(m_address.c_str(), m_flags);
+        Connection() = new DPL::DB::SqlConnection(
+                m_address.c_str(), m_flags, options);
 
         RefCounter() = 0;
 
 
         RefCounter() = 0;
 
@@ -211,7 +209,7 @@ class ThreadDatabaseSupport :
     }
 
     DPL::DB::SqlConnection::DataCommand *AllocDataCommand(
     }
 
     DPL::DB::SqlConnection::DataCommand *AllocDataCommand(
-            const std::string &statement)
+        const std::string &statement)
     {
         // Calling thread must support thread database connections
         Assert(!Connection().IsNull());
     {
         // Calling thread must support thread database connections
         Assert(!Connection().IsNull());
@@ -296,7 +294,6 @@ class ThreadDatabaseSupport :
         return (*Connection())->CheckTableExist(name);
     }
 };
         return (*Connection())->CheckTableExist(name);
     }
 };
-
 }
 }
 
 }
 }
 
index 198a2b6..0fbc386 100644 (file)
  * @file        naive_synchronization_object.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        naive_synchronization_object.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of SQL naive synchronization object
+ * @brief       This file is the implementation file of SQL naive
+ * synchronization object
  */
  */
+#include <stddef.h>
 #include <dpl/db/naive_synchronization_object.h>
 #include <dpl/thread.h>
 
 #include <dpl/db/naive_synchronization_object.h>
 #include <dpl/thread.h>
 
-namespace DPL
-{
-namespace DB
-{
-
+namespace DPL {
+namespace DB {
 void NaiveSynchronizationObject::Synchronize()
 {
     // Sleep for about 10ms - 30ms
 void NaiveSynchronizationObject::Synchronize()
 {
     // Sleep for about 10ms - 30ms
@@ -37,6 +36,5 @@ void NaiveSynchronizationObject::NotifyAll()
 {
     // No need to inform about anything
 }
 {
     // No need to inform about anything
 }
-
 } // namespace DB
 } // namespace DPL
 } // namespace DB
 } // namespace DPL
index 5c7c821..c69415d 100644 (file)
  * @file        orm.cpp
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @version     1.0
  * @file        orm.cpp
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @version     1.0
- * @brief       Static definitions and function template specialziations of DPL-ORM.
+ * @brief       Static definitions and function template specialziations of
+ * DPL-ORM.
  */
  */
-
+#include <stddef.h>
 #include <dpl/db/orm.h>
 
 namespace DPL {
 namespace DB {
 namespace ORM {
 #include <dpl/db/orm.h>
 
 namespace DPL {
 namespace DB {
 namespace ORM {
-
 namespace RelationTypes {
 const char Equal[] = "=";
 const char LessThan[] = "<";
 const char And[] = "AND";
 const char Or[] = "OR";
 const char Is[] = "IS";
 namespace RelationTypes {
 const char Equal[] = "=";
 const char LessThan[] = "<";
 const char And[] = "AND";
 const char Or[] = "OR";
 const char Is[] = "IS";
+const char In[] = "IN";
 }
 
 template<>
 int GetColumnFromCommand<int>(ColumnIndex columnIndex,
 }
 
 template<>
 int GetColumnFromCommand<int>(ColumnIndex columnIndex,
-        DataCommand *command)
+                              DataCommand *command)
 {
     return command->GetColumnInteger(columnIndex);
 }
 
 template<>
 DPL::String GetColumnFromCommand<DPL::String>(ColumnIndex columnIndex,
 {
     return command->GetColumnInteger(columnIndex);
 }
 
 template<>
 DPL::String GetColumnFromCommand<DPL::String>(ColumnIndex columnIndex,
-        DataCommand *command)
+                                              DataCommand *command)
 {
     return DPL::FromUTF8String(command->GetColumnString(columnIndex));
 }
 
 template<>
 OptionalInteger GetColumnFromCommand<OptionalInteger>(ColumnIndex columnIndex,
 {
     return DPL::FromUTF8String(command->GetColumnString(columnIndex));
 }
 
 template<>
 OptionalInteger GetColumnFromCommand<OptionalInteger>(ColumnIndex columnIndex,
-        DataCommand *command)
+                                                      DataCommand *command)
 {
     return command->GetColumnOptionalInteger(columnIndex);
 }
 
 template<>
 OptionalString GetColumnFromCommand<OptionalString>(ColumnIndex columnIndex,
 {
     return command->GetColumnOptionalInteger(columnIndex);
 }
 
 template<>
 OptionalString GetColumnFromCommand<OptionalString>(ColumnIndex columnIndex,
-        DataCommand *command)
+                                                    DataCommand *command)
 {
     return command->GetColumnOptionalString(columnIndex);
 }
 
 template<>
 double GetColumnFromCommand<double>(ColumnIndex columnIndex,
 {
     return command->GetColumnOptionalString(columnIndex);
 }
 
 template<>
 double GetColumnFromCommand<double>(ColumnIndex columnIndex,
-        DataCommand *command)
+                                    DataCommand *command)
 {
     return command->GetColumnDouble(columnIndex);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
 {
     return command->GetColumnDouble(columnIndex);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
-        ArgumentIndex index,
-        int argument)
+                                    ArgumentIndex index,
+                                    int argument)
 {
     command->BindInteger(index, argument);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
 {
     command->BindInteger(index, argument);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
-        ArgumentIndex index,
-        const OptionalInteger& argument)
+                                    ArgumentIndex index,
+                                    const OptionalInteger& argument)
 {
     command->BindInteger(index, argument);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
 {
     command->BindInteger(index, argument);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
-        ArgumentIndex index,
-        const DPL::String& argument)
+                                    ArgumentIndex index,
+                                    const DPL::String& argument)
 {
     command->BindString(index, argument);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
 {
     command->BindString(index, argument);
 }
 
 void DataCommandUtils::BindArgument(DataCommand *command,
-        ArgumentIndex index,
-        const OptionalString& argument)
+                                    ArgumentIndex index,
+                                    const OptionalString& argument)
 {
     command->BindString(index, argument);
 }
 {
     command->BindString(index, argument);
 }
-
 }
 }
 }
 }
-}
\ No newline at end of file
+}
index 5a7fd4d..dab6116 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of SQL connection
  */
  * @version     1.0
  * @brief       This file is the implementation file of SQL connection
  */
+#include <stddef.h>
 #include <dpl/db/sql_connection.h>
 #include <dpl/db/naive_synchronization_object.h>
 #include <dpl/scoped_free.h>
 #include <dpl/db/sql_connection.h>
 #include <dpl/db/naive_synchronization_object.h>
 #include <dpl/scoped_free.h>
 #include <cstdio>
 #include <cstdarg>
 
 #include <cstdio>
 #include <cstdarg>
 
-namespace DPL
-{
-namespace DB
-{
-
+namespace DPL {
+namespace DB {
 namespace // anonymous
 {
 namespace // anonymous
 {
-class ScopedNotifyAll
-    public Noncopyable
+class ScopedNotifyAll :
+    public Noncopyable
 {
 {
-private:
+  private:
     SqlConnection::SynchronizationObject *m_synchronizationObject;
 
     SqlConnection::SynchronizationObject *m_synchronizationObject;
 
-public:
+  public:
     explicit ScopedNotifyAll(
     explicit ScopedNotifyAll(
-        SqlConnection::SynchronizationObject *synchronizationObject)
-        : m_synchronizationObject(synchronizationObject)
-    {
-    }
+        SqlConnection::SynchronizationObject *synchronizationObject) :
+        m_synchronizationObject(synchronizationObject)
+    {}
 
     ~ScopedNotifyAll()
     {
 
     ~ScopedNotifyAll()
     {
-        if (!m_synchronizationObject)
+        if (!m_synchronizationObject) {
             return;
             return;
+        }
 
         LogPedantic("Notifying after successful synchronize");
         m_synchronizationObject->NotifyAll();
 
         LogPedantic("Notifying after successful synchronize");
         m_synchronizationObject->NotifyAll();
@@ -61,33 +59,28 @@ public:
 } // namespace anonymous
 
 SqlConnection::DataCommand::DataCommand(SqlConnection *connection,
 } // namespace anonymous
 
 SqlConnection::DataCommand::DataCommand(SqlConnection *connection,
-                                        const char *buffer)
-    m_masterConnection(connection),
-      m_stmt(NULL)
+                                        const char *buffer) :
+    m_masterConnection(connection),
+    m_stmt(NULL)
 {
     Assert(connection != NULL);
 
     // Notify all after potentially synchronized database connection access
 {
     Assert(connection != NULL);
 
     // Notify all after potentially synchronized database connection access
-    ScopedNotifyAll notifyAll(connection->m_synchronizationObject.Get());
+    ScopedNotifyAll notifyAll(connection->m_synchronizationObject.get());
 
 
-    for (;;)
-    {
+    for (;;) {
         int ret = sqlite3_prepare_v2(connection->m_connection,
                                      buffer, strlen(buffer),
                                      &m_stmt, NULL);
 
         int ret = sqlite3_prepare_v2(connection->m_connection,
                                      buffer, strlen(buffer),
                                      &m_stmt, NULL);
 
-        if (ret == SQLITE_OK)
-        {
+        if (ret == SQLITE_OK) {
             LogPedantic("Data command prepared successfuly");
             break;
             LogPedantic("Data command prepared successfuly");
             break;
-        }
-        else if (ret == SQLITE_BUSY)
-        {
+        } else if (ret == SQLITE_BUSY) {
             LogPedantic("Collision occurred while preparing SQL command");
 
             // Synchronize if synchronization object is available
             LogPedantic("Collision occurred while preparing SQL command");
 
             // Synchronize if synchronization object is available
-            if (connection->m_synchronizationObject)
-            {
+            if (connection->m_synchronizationObject) {
                 LogPedantic("Performing synchronization");
                 connection->m_synchronizationObject->Synchronize();
                 continue;
                 LogPedantic("Performing synchronization");
                 connection->m_synchronizationObject->Synchronize();
                 continue;
@@ -116,8 +109,9 @@ SqlConnection::DataCommand::~DataCommand()
 {
     LogPedantic("SQL data command finalizing");
 
 {
     LogPedantic("SQL data command finalizing");
 
-    if (sqlite3_finalize(m_stmt) != SQLITE_OK)
+    if (sqlite3_finalize(m_stmt) != SQLITE_OK) {
         LogPedantic("Failed to finalize data command");
         LogPedantic("Failed to finalize data command");
+    }
 
     // Decrement stored data command count
     --m_masterConnection->m_dataCommandsCount;
 
     // Decrement stored data command count
     --m_masterConnection->m_dataCommandsCount;
@@ -125,10 +119,9 @@ SqlConnection::DataCommand::~DataCommand()
 
 void SqlConnection::DataCommand::CheckBindResult(int result)
 {
 
 void SqlConnection::DataCommand::CheckBindResult(int result)
 {
-    if (result != SQLITE_OK)
-    {
+    if (result != SQLITE_OK) {
         const char *error = sqlite3_errmsg(
         const char *error = sqlite3_errmsg(
-            m_masterConnection->m_connection);
+                m_masterConnection->m_connection);
 
         LogPedantic("Failed to bind SQL statement parameter");
         LogPedantic("    Error: " << error);
 
         LogPedantic("Failed to bind SQL statement parameter");
         LogPedantic("    Error: " << error);
@@ -217,8 +210,7 @@ void SqlConnection::DataCommand::BindString(
     SqlConnection::ArgumentIndex position,
     const char *value)
 {
     SqlConnection::ArgumentIndex position,
     const char *value)
 {
-    if (!value)
-    {
+    if (!value) {
         BindNull(position);
         return;
     }
         BindNull(position);
         return;
     }
@@ -243,109 +235,110 @@ void SqlConnection::DataCommand::BindInteger(
     SqlConnection::ArgumentIndex position,
     const Optional<int> &value)
 {
     SqlConnection::ArgumentIndex position,
     const Optional<int> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindInteger(position, *value);
         BindInteger(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindInt8(
     SqlConnection::ArgumentIndex position,
     const Optional<int8_t> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindInt8(
     SqlConnection::ArgumentIndex position,
     const Optional<int8_t> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindInt8(position, *value);
         BindInt8(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindInt16(
     SqlConnection::ArgumentIndex position,
     const Optional<int16_t> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindInt16(
     SqlConnection::ArgumentIndex position,
     const Optional<int16_t> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindInt16(position, *value);
         BindInt16(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindInt32(
     SqlConnection::ArgumentIndex position,
     const Optional<int32_t> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindInt32(
     SqlConnection::ArgumentIndex position,
     const Optional<int32_t> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindInt32(position, *value);
         BindInt32(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindInt64(
     SqlConnection::ArgumentIndex position,
     const Optional<int64_t> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindInt64(
     SqlConnection::ArgumentIndex position,
     const Optional<int64_t> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindInt64(position, *value);
         BindInt64(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindFloat(
     SqlConnection::ArgumentIndex position,
     const Optional<float> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindFloat(
     SqlConnection::ArgumentIndex position,
     const Optional<float> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindFloat(position, *value);
         BindFloat(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindDouble(
     SqlConnection::ArgumentIndex position,
     const Optional<double> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindDouble(
     SqlConnection::ArgumentIndex position,
     const Optional<double> &value)
 {
-    if (value.IsNull())
+    if (value.IsNull()) {
         BindNull(position);
         BindNull(position);
-    else
+    } else {
         BindDouble(position, *value);
         BindDouble(position, *value);
+    }
 }
 
 void SqlConnection::DataCommand::BindString(
     SqlConnection::ArgumentIndex position,
     const Optional<String> &value)
 {
 }
 
 void SqlConnection::DataCommand::BindString(
     SqlConnection::ArgumentIndex position,
     const Optional<String> &value)
 {
-    if (!!value)
+    if (!!value) {
         BindString(position, ToUTF8String(*value).c_str());
         BindString(position, ToUTF8String(*value).c_str());
-    else
+    } else {
         BindNull(position);
         BindNull(position);
+    }
 }
 
 bool SqlConnection::DataCommand::Step()
 {
     // Notify all after potentially synchronized database connection access
     ScopedNotifyAll notifyAll(
 }
 
 bool SqlConnection::DataCommand::Step()
 {
     // Notify all after potentially synchronized database connection access
     ScopedNotifyAll notifyAll(
-        m_masterConnection->m_synchronizationObject.Get());
+        m_masterConnection->m_synchronizationObject.get());
 
 
-    for (;;)
-    {
+    for (;;) {
         int ret = sqlite3_step(m_stmt);
 
         int ret = sqlite3_step(m_stmt);
 
-        if (ret == SQLITE_ROW)
-        {
+        if (ret == SQLITE_ROW) {
             LogPedantic("SQL data command step ROW");
             return true;
             LogPedantic("SQL data command step ROW");
             return true;
-        }
-        else if (ret == SQLITE_DONE)
-        {
+        } else if (ret == SQLITE_DONE) {
             LogPedantic("SQL data command step DONE");
             return false;
             LogPedantic("SQL data command step DONE");
             return false;
-        }
-        else if (ret == SQLITE_BUSY)
-        {
+        } else if (ret == SQLITE_BUSY) {
             LogPedantic("Collision occurred while executing SQL command");
 
             // Synchronize if synchronization object is available
             LogPedantic("Collision occurred while executing SQL command");
 
             // Synchronize if synchronization object is available
-            if (m_masterConnection->m_synchronizationObject)
-            {
+            if (m_masterConnection->m_synchronizationObject) {
                 LogPedantic("Performing synchronization");
 
                 m_masterConnection->
                 LogPedantic("Performing synchronization");
 
                 m_masterConnection->
@@ -385,8 +378,9 @@ void SqlConnection::DataCommand::Reset()
 void SqlConnection::DataCommand::CheckColumnIndex(
     SqlConnection::ColumnIndex column)
 {
 void SqlConnection::DataCommand::CheckColumnIndex(
     SqlConnection::ColumnIndex column)
 {
-    if (column < 0 || column >= sqlite3_column_count(m_stmt))
+    if (column < 0 || column >= sqlite3_column_count(m_stmt)) {
         ThrowMsg(Exception::InvalidColumn, "Column index is out of bounds");
         ThrowMsg(Exception::InvalidColumn, "Column index is out of bounds");
+    }
 }
 
 bool SqlConnection::DataCommand::IsColumnNull(
 }
 
 bool SqlConnection::DataCommand::IsColumnNull(
@@ -474,12 +468,13 @@ std::string SqlConnection::DataCommand::GetColumnString(
     CheckColumnIndex(column);
 
     const char *value = reinterpret_cast<const char *>(
     CheckColumnIndex(column);
 
     const char *value = reinterpret_cast<const char *>(
-        sqlite3_column_text(m_stmt, column));
+            sqlite3_column_text(m_stmt, column));
 
     LogPedantic("Value: " << (value ? value : "NULL"));
 
 
     LogPedantic("Value: " << (value ? value : "NULL"));
 
-    if (value == NULL)
+    if (value == NULL) {
         return std::string();
         return std::string();
+    }
 
     return std::string(value);
 }
 
     return std::string(value);
 }
@@ -490,8 +485,9 @@ Optional<int> SqlConnection::DataCommand::GetColumnOptionalInteger(
     LogPedantic("SQL data command get column optional integer: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional integer: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<int>::Null;
         return Optional<int>::Null;
+    }
     int value = sqlite3_column_int(m_stmt, column);
     LogPedantic("    Value: " << value);
     return Optional<int>(value);
     int value = sqlite3_column_int(m_stmt, column);
     LogPedantic("    Value: " << value);
     return Optional<int>(value);
@@ -503,8 +499,9 @@ Optional<int8_t> SqlConnection::DataCommand::GetColumnOptionalInt8(
     LogPedantic("SQL data command get column optional int8: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional int8: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<int8_t>::Null;
         return Optional<int8_t>::Null;
+    }
     int8_t value = static_cast<int8_t>(sqlite3_column_int(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int8_t>(value);
     int8_t value = static_cast<int8_t>(sqlite3_column_int(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int8_t>(value);
@@ -516,8 +513,9 @@ Optional<int16_t> SqlConnection::DataCommand::GetColumnOptionalInt16(
     LogPedantic("SQL data command get column optional int16: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional int16: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<int16_t>::Null;
         return Optional<int16_t>::Null;
+    }
     int16_t value = static_cast<int16_t>(sqlite3_column_int(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int16_t>(value);
     int16_t value = static_cast<int16_t>(sqlite3_column_int(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int16_t>(value);
@@ -529,8 +527,9 @@ Optional<int32_t> SqlConnection::DataCommand::GetColumnOptionalInt32(
     LogPedantic("SQL data command get column optional int32: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional int32: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<int32_t>::Null;
         return Optional<int32_t>::Null;
+    }
     int32_t value = static_cast<int32_t>(sqlite3_column_int(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int32_t>(value);
     int32_t value = static_cast<int32_t>(sqlite3_column_int(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int32_t>(value);
@@ -542,8 +541,9 @@ Optional<int64_t> SqlConnection::DataCommand::GetColumnOptionalInt64(
     LogPedantic("SQL data command get column optional int64: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional int64: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<int64_t>::Null;
         return Optional<int64_t>::Null;
+    }
     int64_t value = static_cast<int64_t>(sqlite3_column_int64(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int64_t>(value);
     int64_t value = static_cast<int64_t>(sqlite3_column_int64(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<int64_t>(value);
@@ -555,8 +555,9 @@ Optional<float> SqlConnection::DataCommand::GetColumnOptionalFloat(
     LogPedantic("SQL data command get column optional float: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional float: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<float>::Null;
         return Optional<float>::Null;
+    }
     float value = static_cast<float>(sqlite3_column_double(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<float>(value);
     float value = static_cast<float>(sqlite3_column_double(m_stmt, column));
     LogPedantic("    Value: " << value);
     return Optional<float>(value);
@@ -568,8 +569,9 @@ Optional<double> SqlConnection::DataCommand::GetColumnOptionalDouble(
     LogPedantic("SQL data command get column optional double: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional double: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<double>::Null;
         return Optional<double>::Null;
+    }
     double value = sqlite3_column_double(m_stmt, column);
     LogPedantic("    Value: " << value);
     return Optional<double>(value);
     double value = sqlite3_column_double(m_stmt, column);
     LogPedantic("    Value: " << value);
     return Optional<double>(value);
@@ -581,57 +583,51 @@ Optional<String> SqlConnection::DataCommand::GetColumnOptionalString(
     LogPedantic("SQL data command get column optional string: ["
                 << column << "]");
     CheckColumnIndex(column);
     LogPedantic("SQL data command get column optional string: ["
                 << column << "]");
     CheckColumnIndex(column);
-    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
+    if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL) {
         return Optional<String>::Null;
         return Optional<String>::Null;
+    }
     const char *value = reinterpret_cast<const char *>(
     const char *value = reinterpret_cast<const char *>(
-        sqlite3_column_text(m_stmt, column));
+            sqlite3_column_text(m_stmt, column));
     LogPedantic("Value: " << value);
     String s = FromUTF8String(value);
     return Optional<String>(s);
 }
 
     LogPedantic("Value: " << value);
     String s = FromUTF8String(value);
     return Optional<String>(s);
 }
 
-void SqlConnection::Connect(const std::string &address, Flag::Type flag)
+void SqlConnection::Connect(const std::string &address,
+                            Flag::Type type,
+                            Flag::Option flag)
 {
 {
-    if (m_connection != NULL)
-    {
+    if (m_connection != NULL) {
         LogPedantic("Already connected.");
         return;
     }
         LogPedantic("Already connected.");
         return;
     }
-
     LogPedantic("Connecting to DB: " << address << "...");
 
     // Connect to database
     int result;
     LogPedantic("Connecting to DB: " << address << "...");
 
     // Connect to database
     int result;
-
-    if (flag & Flag::UseLucene)
-    {
+    if (type & Flag::UseLucene) {
         result = db_util_open_with_options(
         result = db_util_open_with_options(
-            address.c_str(),
-            &m_connection,
-            SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
-            NULL);
+                address.c_str(),
+                &m_connection,
+                flag,
+                NULL);
 
         m_usingLucene = true;
         LogPedantic("Lucene index enabled");
 
         m_usingLucene = true;
         LogPedantic("Lucene index enabled");
-    }
-    else
-    {
+    } else {
         result = sqlite3_open_v2(
         result = sqlite3_open_v2(
-            address.c_str(),
-            &m_connection,
-            SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
-            NULL);
+                address.c_str(),
+                &m_connection,
+                flag,
+                NULL);
 
         m_usingLucene = false;
         LogPedantic("Lucene index disabled");
     }
 
 
         m_usingLucene = false;
         LogPedantic("Lucene index disabled");
     }
 
-    if (result == SQLITE_OK)
-    {
+    if (result == SQLITE_OK) {
         LogPedantic("Connected to DB");
         LogPedantic("Connected to DB");
-    }
-    else
-    {
+    } else {
         LogPedantic("Failed to connect to DB!");
         ThrowMsg(Exception::ConnectionBroken, address);
     }
         LogPedantic("Failed to connect to DB!");
         ThrowMsg(Exception::ConnectionBroken, address);
     }
@@ -642,8 +638,7 @@ void SqlConnection::Connect(const std::string &address, Flag::Type flag)
 
 void SqlConnection::Disconnect()
 {
 
 void SqlConnection::Disconnect()
 {
-    if (m_connection == NULL)
-    {
+    if (m_connection == NULL) {
         LogPedantic("Already disconnected.");
         return;
     }
         LogPedantic("Already disconnected.");
         return;
     }
@@ -657,17 +652,13 @@ void SqlConnection::Disconnect()
 
     int result;
 
 
     int result;
 
-    if (m_usingLucene)
-    {
+    if (m_usingLucene) {
         result = db_util_close(m_connection);
         result = db_util_close(m_connection);
-    }
-    else
-    {
+    } else {
         result = sqlite3_close(m_connection);
     }
 
         result = sqlite3_close(m_connection);
     }
 
-    if (result != SQLITE_OK)
-    {
+    if (result != SQLITE_OK) {
         const char *error = sqlite3_errmsg(m_connection);
         LogPedantic("SQL close failed");
         LogPedantic("    Error: " << error);
         const char *error = sqlite3_errmsg(m_connection);
         LogPedantic("SQL close failed");
         LogPedantic("    Error: " << error);
@@ -681,8 +672,7 @@ void SqlConnection::Disconnect()
 
 bool SqlConnection::CheckTableExist(const char *tableName)
 {
 
 bool SqlConnection::CheckTableExist(const char *tableName)
 {
-    if (m_connection == NULL)
-    {
+    if (m_connection == NULL) {
         LogPedantic("Cannot execute command. Not connected to DB!");
         return false;
     }
         LogPedantic("Cannot execute command. Not connected to DB!");
         return false;
     }
@@ -692,8 +682,7 @@ bool SqlConnection::CheckTableExist(const char *tableName)
 
     command->BindString(1, tableName);
 
 
     command->BindString(1, tableName);
 
-    if (!command->Step())
-    {
+    if (!command->Step()) {
         LogPedantic("No matching records in table");
         return false;
     }
         LogPedantic("No matching records in table");
         return false;
     }
@@ -703,19 +692,19 @@ bool SqlConnection::CheckTableExist(const char *tableName)
 
 SqlConnection::SqlConnection(const std::string &address,
                              Flag::Type flag,
 
 SqlConnection::SqlConnection(const std::string &address,
                              Flag::Type flag,
-                             SynchronizationObject *synchronizationObject)
-    : m_connection(NULL),
-      m_usingLucene(false),
-      m_dataCommandsCount(0),
-      m_synchronizationObject(synchronizationObject)
+                             Flag::Option option,
+                             SynchronizationObject *synchronizationObject) :
+    m_connection(NULL),
+    m_usingLucene(false),
+    m_dataCommandsCount(0),
+    m_synchronizationObject(synchronizationObject)
 {
     LogPedantic("Opening database connection to: " << address);
 
     // Connect to DB
 {
     LogPedantic("Opening database connection to: " << address);
 
     // Connect to DB
-    SqlConnection::Connect(address, flag);
+    SqlConnection::Connect(address, flag, option);
 
 
-    if (!m_synchronizationObject)
-    {
+    if (!m_synchronizationObject) {
         LogPedantic("No synchronization object defined");
     }
 }
         LogPedantic("No synchronization object defined");
     }
 }
@@ -729,7 +718,7 @@ SqlConnection::~SqlConnection()
     {
         SqlConnection::Disconnect();
     }
     {
         SqlConnection::Disconnect();
     }
-    Catch (Exception::Base)
+    Catch(Exception::Base)
     {
         LogPedantic("Failed to disconnect from database");
     }
     {
         LogPedantic("Failed to disconnect from database");
     }
@@ -737,26 +726,30 @@ SqlConnection::~SqlConnection()
 
 void SqlConnection::ExecCommand(const char *format, ...)
 {
 
 void SqlConnection::ExecCommand(const char *format, ...)
 {
-    if (m_connection == NULL)
-    {
+    if (m_connection == NULL) {
         LogPedantic("Cannot execute command. Not connected to DB!");
         return;
     }
 
         LogPedantic("Cannot execute command. Not connected to DB!");
         return;
     }
 
+    if (format == NULL) {
+        LogPedantic("Null query!");
+        ThrowMsg(Exception::SyntaxError, "Null statement");
+    }
+
     char *rawBuffer;
 
     va_list args;
     va_start(args, format);
 
     char *rawBuffer;
 
     va_list args;
     va_start(args, format);
 
-    if (vasprintf(&rawBuffer, format, args) == -1)
+    if (vasprintf(&rawBuffer, format, args) == -1) {
         rawBuffer = NULL;
         rawBuffer = NULL;
+    }
 
     va_end(args);
 
     ScopedFree<char> buffer(rawBuffer);
 
 
     va_end(args);
 
     ScopedFree<char> buffer(rawBuffer);
 
-    if (!buffer)
-    {
+    if (!buffer) {
         LogPedantic("Failed to allocate statement string");
         return;
     }
         LogPedantic("Failed to allocate statement string");
         return;
     }
@@ -764,10 +757,9 @@ void SqlConnection::ExecCommand(const char *format, ...)
     LogPedantic("Executing SQL command: " << buffer.Get());
 
     // Notify all after potentially synchronized database connection access
     LogPedantic("Executing SQL command: " << buffer.Get());
 
     // Notify all after potentially synchronized database connection access
-    ScopedNotifyAll notifyAll(m_synchronizationObject.Get());
+    ScopedNotifyAll notifyAll(m_synchronizationObject.get());
 
 
-    for (;;)
-    {
+    for (;;) {
         char *errorBuffer;
 
         int ret = sqlite3_exec(m_connection,
         char *errorBuffer;
 
         int ret = sqlite3_exec(m_connection,
@@ -779,22 +771,20 @@ void SqlConnection::ExecCommand(const char *format, ...)
         std::string errorMsg;
 
         // Take allocated error buffer
         std::string errorMsg;
 
         // Take allocated error buffer
-        if (errorBuffer != NULL)
-        {
+        if (errorBuffer != NULL) {
             errorMsg = errorBuffer;
             sqlite3_free(errorBuffer);
         }
 
             errorMsg = errorBuffer;
             sqlite3_free(errorBuffer);
         }
 
-        if (ret == SQLITE_OK)
+        if (ret == SQLITE_OK) {
             return;
             return;
+        }
 
 
-        if (ret == SQLITE_BUSY)
-        {
+        if (ret == SQLITE_BUSY) {
             LogPedantic("Collision occurred while executing SQL command");
 
             // Synchronize if synchronization object is available
             LogPedantic("Collision occurred while executing SQL command");
 
             // Synchronize if synchronization object is available
-            if (m_synchronizationObject)
-            {
+            if (m_synchronizationObject) {
                 LogPedantic("Performing synchronization");
                 m_synchronizationObject->Synchronize();
                 continue;
                 LogPedantic("Performing synchronization");
                 m_synchronizationObject->Synchronize();
                 continue;
@@ -813,8 +803,7 @@ SqlConnection::DataCommandAutoPtr SqlConnection::PrepareDataCommand(
     const char *format,
     ...)
 {
     const char *format,
     ...)
 {
-    if (m_connection == NULL)
-    {
+    if (m_connection == NULL) {
         LogPedantic("Cannot execute data command. Not connected to DB!");
         return DataCommandAutoPtr();
     }
         LogPedantic("Cannot execute data command. Not connected to DB!");
         return DataCommandAutoPtr();
     }
@@ -824,15 +813,15 @@ SqlConnection::DataCommandAutoPtr SqlConnection::PrepareDataCommand(
     va_list args;
     va_start(args, format);
 
     va_list args;
     va_start(args, format);
 
-    if (vasprintf(&rawBuffer, format, args) == -1)
+    if (vasprintf(&rawBuffer, format, args) == -1) {
         rawBuffer = NULL;
         rawBuffer = NULL;
+    }
 
     va_end(args);
 
     ScopedFree<char> buffer(rawBuffer);
 
 
     va_end(args);
 
     ScopedFree<char> buffer(rawBuffer);
 
-    if (!buffer)
-    {
+    if (!buffer) {
         LogPedantic("Failed to allocate statement string");
         return DataCommandAutoPtr();
     }
         LogPedantic("Failed to allocate statement string");
         return DataCommandAutoPtr();
     }
@@ -853,10 +842,9 @@ void SqlConnection::TurnOnForeignKeys()
 }
 
 SqlConnection::SynchronizationObject *
 }
 
 SqlConnection::SynchronizationObject *
-    SqlConnection::AllocDefaultSynchronizationObject()
+SqlConnection::AllocDefaultSynchronizationObject()
 {
     return new NaiveSynchronizationObject();
 }
 {
     return new NaiveSynchronizationObject();
 }
-
 } // namespace DB
 } // namespace DPL
 } // namespace DB
 } // namespace DPL
index 5b7865c..101640f 100644 (file)
@@ -19,5 +19,5 @@
  * @version 1.0
  * @brief   This file contains the definition of thread database support
  */
  * @version 1.0
  * @brief   This file contains the definition of thread database support
  */
-
+#include <stddef.h>
 #include <dpl/db/thread_database_support.h>
\ No newline at end of file
 #include <dpl/db/thread_database_support.h>
\ No newline at end of file
index 995c071..f2fefde 100644 (file)
@@ -40,6 +40,7 @@ SET(DPL_DBUS_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/dbus_server_serialization.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/dbus_signature.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/dispatcher.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/dbus_server_serialization.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/dbus_signature.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/dispatcher.h
+    ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/glib_util.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/exception.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/interface.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/method_proxy.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/exception.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/interface.h
     ${PROJECT_SOURCE_DIR}/modules/dbus/include/dpl/dbus/method_proxy.h
index 886038c..4a455ad 100644 (file)
 #include <memory>
 #include <vector>
 #include <string>
 #include <memory>
 #include <vector>
 #include <string>
-#include <gio/gio.h>
 #include <dpl/generic_event.h>
 #include <dpl/event/event_support.h>
 #include <dpl/dbus/object.h>
 #include <dpl/dbus/object_proxy.h>
 #include <dpl/generic_event.h>
 #include <dpl/event/event_support.h>
 #include <dpl/dbus/object.h>
 #include <dpl/dbus/object_proxy.h>
+#include <dpl/dbus/glib_util.h>
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
-namespace ConnectionEvents
-{
+namespace ConnectionEvents {
 /**
  * Emitted when service name is acquired.
  *
 /**
  * Emitted when service name is acquired.
  *
@@ -74,12 +72,12 @@ typedef std::shared_ptr<Connection> ConnectionPtr;
 typedef std::shared_ptr<ObjectProxy> ObjectProxyPtr;
 
 class Connection :
 typedef std::shared_ptr<ObjectProxy> ObjectProxyPtr;
 
 class Connection :
-        public DPL::Event::EventSupport<ConnectionEvents::ServiceNameAcquiredEvent>,
-        public DPL::Event::EventSupport<ConnectionEvents::ServiceNameLostEvent>,
-        public DPL::Event::EventSupport<ConnectionEvents::ConnectionBrokenEvent>,
-        public DPL::Event::EventSupport<ConnectionEvents::ConnectionInvalidEvent>
+    public DPL::Event::EventSupport<ConnectionEvents::ServiceNameAcquiredEvent>,
+    public DPL::Event::EventSupport<ConnectionEvents::ServiceNameLostEvent>,
+    public DPL::Event::EventSupport<ConnectionEvents::ConnectionBrokenEvent>,
+    public DPL::Event::EventSupport<ConnectionEvents::ConnectionInvalidEvent>
 {
 {
-public:
+  public:
     /**
      * Acquires connection to session bus.
      *
     /**
      * Acquires connection to session bus.
      *
@@ -165,18 +163,17 @@ public:
     ObjectProxyPtr createObjectProxy(const std::string& serviceName,
                                      const std::string& objectPath);
 
     ObjectProxyPtr createObjectProxy(const std::string& serviceName,
                                      const std::string& objectPath);
 
-private:
+  private:
     friend class Server;
 
     typedef std::map<std::string, guint> RegisteredServices;
 
     struct ObjectRegistration
     {
     friend class Server;
 
     typedef std::map<std::string, guint> RegisteredServices;
 
     struct ObjectRegistration
     {
-        ObjectRegistration(guint registrationId, const ObjectPtr& object)
-            : registrationId(registrationId),
-              object(object)
-        {
-        }
+        ObjectRegistration(guint _registrationId, const ObjectPtr& _object) :
+            registrationId(_registrationId),
+            object(_object)
+        {}
 
         guint registrationId;
         ObjectPtr object;
 
         guint registrationId;
         ObjectPtr object;
@@ -204,7 +201,6 @@ private:
 
     RegisteredObjects m_registeredObjects;
 };
 
     RegisteredObjects m_registeredObjects;
 };
-
 }
 }
 
 }
 }
 
index 6b86c57..061ec46 100644 (file)
@@ -32,7 +32,6 @@
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 /*
  * DBus::Client class is intended to act as simple DBus client. To call a method
  * on remote service "Service", on remote object "Object", interface
 /*
  * DBus::Client class is intended to act as simple DBus client. To call a method
  * on remote service "Service", on remote object "Object", interface
@@ -58,7 +57,6 @@ namespace DBus {
 
 class Client
 {
 
 class Client
 {
-
   public:
     class Exception
     {
   public:
     class Exception
     {
@@ -70,9 +68,9 @@ class Client
     Client(std::string serverPath,
            std::string serviceName,
            std::string interfaceName) :
     Client(std::string serverPath,
            std::string serviceName,
            std::string interfaceName) :
-            m_serviceName(serviceName),
-            m_serverPath(serverPath),
-            m_interfaceName(interfaceName)
+        m_serviceName(serviceName),
+        m_serverPath(serverPath),
+        m_interfaceName(interfaceName)
     {
         DBusError error;
 
     {
         DBusError error;
 
@@ -80,15 +78,15 @@ class Client
         m_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
         if (NULL == m_connection) {
             LogPedantic("Couldn't get DBUS connection. Error: " <<
         m_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
         if (NULL == m_connection) {
             LogPedantic("Couldn't get DBUS connection. Error: " <<
-                    error.message);
+                        error.message);
             dbus_error_free(&error);
             ThrowMsg(Exception::DBusClientException,
             dbus_error_free(&error);
             ThrowMsg(Exception::DBusClientException,
-                    "Couldn't get DBUS connection." );
+                     "Couldn't get DBUS connection.");
         }
     }
 
         }
     }
 
-    template<typename ...Args>
-    void call(const char* methodName, const Args&... args)
+    template<typename ... Args>
+    void call(const char* methodName, const Args& ... args)
     {
         DBusMessage* message = dbus_message_new_method_call(
                 m_serviceName.c_str(),
     {
         DBusMessage* message = dbus_message_new_method_call(
                 m_serviceName.c_str(),
@@ -97,14 +95,14 @@ class Client
                 methodName);
         DBusMessageIter argsIterator;
         dbus_message_iter_init_append(message, &argsIterator);
                 methodName);
         DBusMessageIter argsIterator;
         dbus_message_iter_init_append(message, &argsIterator);
-        call(message, &argsIterator, args...);
+        call(message, &argsIterator, args ...);
         dbus_message_unref(message);
     }
 
         dbus_message_unref(message);
     }
 
-    template<typename ...Args>
-    void call(std::string methodName, const Args&... args)
+    template<typename ... Args>
+    void call(std::string methodName, const Args& ... args)
     {
     {
-        call(methodName.c_str(), args...);
+        call(methodName.c_str(), args ...);
     }
 
     ~Client()
     }
 
     ~Client()
@@ -115,7 +113,7 @@ class Client
   private:
 
     DBusMessage* makeCall(
   private:
 
     DBusMessage* makeCall(
-            DBusMessage* message)
+        DBusMessage* message)
     {
         DBusError error;
         dbus_error_init(&error);
     {
         DBusError error;
         dbus_error_init(&error);
@@ -126,10 +124,10 @@ class Client
                 &error);
         if (NULL == ret) {
             LogPedantic("Error sending DBUS message: " <<
                 &error);
         if (NULL == ret) {
             LogPedantic("Error sending DBUS message: " <<
-                    error.message);
+                        error.message);
             dbus_error_free(&error);
             ThrowMsg(Exception::DBusClientException,
             dbus_error_free(&error);
             ThrowMsg(Exception::DBusClientException,
-                    "Error sending DBUS message." );
+                     "Error sending DBUS message.");
         }
         return ret;
     }
         }
         return ret;
     }
@@ -142,98 +140,97 @@ class Client
         } else {
             LogPedantic("Error getting DBUS response.");
             ThrowMsg(Exception::DBusClientException,
         } else {
             LogPedantic("Error getting DBUS response.");
             ThrowMsg(Exception::DBusClientException,
-                    "Error getting DBUS response." );
+                     "Error getting DBUS response.");
         }
     }
 
     template<typename T, typename ... Args>
     void call(
         }
     }
 
     template<typename T, typename ... Args>
     void call(
-            DBusMessage* message,
-            DBusMessageIter* argsIterator,
-            const T& invalue,
-            const Args&... args)
+        DBusMessage* message,
+        DBusMessageIter* argsIterator,
+        const T& invalue,
+        const Args& ... args)
     {
     {
-        if (!Serialization::serialize(argsIterator, invalue)){
+        if (!Serialization::serialize(argsIterator, invalue)) {
             LogPedantic("Error in serialization.");
             ThrowMsg(Exception::DBusClientException,
             LogPedantic("Error in serialization.");
             ThrowMsg(Exception::DBusClientException,
-                    "Error in serialization." );
+                     "Error in serialization.");
         }
         }
-        call(message, argsIterator, args...);
+        call(message, argsIterator, args ...);
     }
 
     template<typename T, typename ... Args>
     void call(
     }
 
     template<typename T, typename ... Args>
     void call(
-            DBusMessage* message,
-            DBusMessageIter* argsIterator,
-            const T* invalue,
-            const Args&... args)
+        DBusMessage* message,
+        DBusMessageIter* argsIterator,
+        const T* invalue,
+        const Args& ... args)
     {
     {
-        if (!Serialization::serialize(argsIterator, invalue)){
+        if (!Serialization::serialize(argsIterator, invalue)) {
             LogPedantic("Error in serialization.");
             ThrowMsg(Exception::DBusClientException,
             LogPedantic("Error in serialization.");
             ThrowMsg(Exception::DBusClientException,
-                    "Error in serialization." );
+                     "Error in serialization.");
         }
         }
-        call(message, argsIterator, args...);
+        call(message, argsIterator, args ...);
     }
 
     template<typename T, typename ... Args>
     void call(
     }
 
     template<typename T, typename ... Args>
     void call(
-            DBusMessage* message,
-            DBusMessageIter* argsIterator,
-            const T* invalue)
+        DBusMessage* message,
+        DBusMessageIter* argsIterator,
+        const T* invalue)
     {
     {
-        if (!Serialization::serialize(argsIterator, invalue)){
+        if (!Serialization::serialize(argsIterator, invalue)) {
             LogPedantic("Error in serialization.");
             ThrowMsg(Exception::DBusClientException,
             LogPedantic("Error in serialization.");
             ThrowMsg(Exception::DBusClientException,
-                    "Error in serialization." );
+                     "Error in serialization.");
         }
         call(message, argsIterator);
     }
 
     template<typename T, typename ... Args>
     void call(
         }
         call(message, argsIterator);
     }
 
     template<typename T, typename ... Args>
     void call(
-            DBusMessage* message,
-            DBusMessageIter* /*argsIterator*/,
-            T* out,
-            const Args&... args)
+        DBusMessage* message,
+        DBusMessageIter* /*argsIterator*/,
+        T* out,
+        const Args& ... args)
     {
         DBusMessage* ret = makeCall(message);
         if (ret != NULL) {
             DBusMessageIter responseIterator;
             dbus_message_iter_init(ret, &responseIterator);
     {
         DBusMessage* ret = makeCall(message);
         if (ret != NULL) {
             DBusMessageIter responseIterator;
             dbus_message_iter_init(ret, &responseIterator);
-            returnFromCall(&responseIterator, out, args...);
+            returnFromCall(&responseIterator, out, args ...);
             dbus_message_unref(ret);
         }
     }
 
     template<typename T, typename ... Args>
     void returnFromCall(
             dbus_message_unref(ret);
         }
     }
 
     template<typename T, typename ... Args>
     void returnFromCall(
-            DBusMessageIter* responseIterator,
-            T* out,
-            const Args&... args)
+        DBusMessageIter* responseIterator,
+        T* out,
+        const Args& ... args)
     {
     {
-        if (!Deserialization::deserialize(responseIterator, out)){
+        if (!Deserialization::deserialize(responseIterator, out)) {
             LogPedantic("Error in deserialization.");
             ThrowMsg(Exception::DBusClientException,
             LogPedantic("Error in deserialization.");
             ThrowMsg(Exception::DBusClientException,
-                    "Error in deserialization." );
+                     "Error in deserialization.");
         }
         }
-        returnFromCall(responseIterator, args...);
+        returnFromCall(responseIterator, args ...);
     }
 
     template<typename T>
     void returnFromCall(DBusMessageIter* responseIterator, T* out)
     {
     }
 
     template<typename T>
     void returnFromCall(DBusMessageIter* responseIterator, T* out)
     {
-        if (!Deserialization::deserialize(responseIterator, out)){
+        if (!Deserialization::deserialize(responseIterator, out)) {
             LogPedantic("Error in deserialization.");
             ThrowMsg(Exception::DBusClientException,
             LogPedantic("Error in deserialization.");
             ThrowMsg(Exception::DBusClientException,
-                    "Error in deserialization." );
+                     "Error in deserialization.");
         }
     }
 
     std::string m_serviceName, m_serverPath, m_interfaceName;
     DBusConnection* m_connection;
 };
         }
     }
 
     std::string m_serviceName, m_serverPath, m_interfaceName;
     DBusConnection* m_connection;
 };
-
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index 9f50f91..2a05db8 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 struct Deserialization
 {
 struct Deserialization
 {
-
     static bool deserializePrimitive(
     static bool deserializePrimitive(
-            DBusMessageIter* responseIterator,
-            void* arg,
-            int type)
+        DBusMessageIter* responseIterator,
+        void* arg,
+        int type)
     {
         if (dbus_message_iter_get_arg_type(responseIterator) != type) {
             return false;
     {
         if (dbus_message_iter_get_arg_type(responseIterator) != type) {
             return false;
@@ -54,7 +52,8 @@ struct Deserialization
     static bool deserialize(DBusMessageIter* responseIterator, T* arg)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
     static bool deserialize(DBusMessageIter* responseIterator, T* arg)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
-                != SimpleType<T>::value) {
+            != SimpleType<T>::value)
+        {
             return false;
         }
         dbus_message_iter_get_basic(responseIterator, arg);
             return false;
         }
         dbus_message_iter_get_basic(responseIterator, arg);
@@ -65,7 +64,7 @@ struct Deserialization
     static bool deserialize(DBusMessageIter* responseIterator, float* arg)
     {
         double d;
     static bool deserialize(DBusMessageIter* responseIterator, float* arg)
     {
         double d;
-        if (!deserialize(responseIterator, &d)){
+        if (!deserialize(responseIterator, &d)) {
             return false;
         }
         *arg = static_cast<float>(d);
             return false;
         }
         *arg = static_cast<float>(d);
@@ -74,11 +73,11 @@ struct Deserialization
 
     // std::string
     static bool deserialize(
 
     // std::string
     static bool deserialize(
-            DBusMessageIter* responseIterator,
-            std::string* arg)
+        DBusMessageIter* responseIterator,
+        std::string* arg)
     {
         char* str = NULL;
     {
         char* str = NULL;
-        if (!deserialize(responseIterator, &str)){
+        if (!deserialize(responseIterator, &str)) {
             return false;
         }
         *arg = std::string(str);
             return false;
         }
         *arg = std::string(str);
@@ -88,19 +87,21 @@ struct Deserialization
     // dbus array deserialization
     template<typename T>
     static bool deserializeContainer(
     // dbus array deserialization
     template<typename T>
     static bool deserializeContainer(
-            DBusMessageIter* responseIterator,
-            T* arg)
+        DBusMessageIter* responseIterator,
+        T* arg)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
-                != DBUS_TYPE_ARRAY) {
+            != DBUS_TYPE_ARRAY)
+        {
             return false;
         }
         DBusMessageIter subIterator;
         dbus_message_iter_recurse(responseIterator, &subIterator);
         while (dbus_message_iter_get_arg_type(&subIterator)
             return false;
         }
         DBusMessageIter subIterator;
         dbus_message_iter_recurse(responseIterator, &subIterator);
         while (dbus_message_iter_get_arg_type(&subIterator)
-                != DBUS_TYPE_INVALID) {
+               != DBUS_TYPE_INVALID)
+        {
             arg->push_back(typename T::value_type());
             arg->push_back(typename T::value_type());
-            if (!deserialize(&subIterator, &arg->back())){
+            if (!deserialize(&subIterator, &arg->back())) {
                 return false;
             }
             dbus_message_iter_next(&subIterator);
                 return false;
             }
             dbus_message_iter_next(&subIterator);
@@ -111,8 +112,8 @@ struct Deserialization
     // std::vector
     template<typename T>
     static bool deserialize(
     // std::vector
     template<typename T>
     static bool deserialize(
-            DBusMessageIter* responseIterator,
-            std::vector<T>* arg)
+        DBusMessageIter* responseIterator,
+        std::vector<T>* arg)
     {
         return deserializeContainer(responseIterator, arg);
     }
     {
         return deserializeContainer(responseIterator, arg);
     }
@@ -120,8 +121,8 @@ struct Deserialization
     // std::list
     template<typename T>
     static bool deserialize(
     // std::list
     template<typename T>
     static bool deserialize(
-            DBusMessageIter* responseIterator,
-            std::list<T>* arg)
+        DBusMessageIter* responseIterator,
+        std::list<T>* arg)
     {
         return deserializeContainer(responseIterator, arg);
     }
     {
         return deserializeContainer(responseIterator, arg);
     }
@@ -129,19 +130,21 @@ struct Deserialization
     // std::set
     template<typename T>
     static bool deserialize(
     // std::set
     template<typename T>
     static bool deserialize(
-            DBusMessageIter* responseIterator,
-            std::set<T>* arg)
+        DBusMessageIter* responseIterator,
+        std::set<T>* arg)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
-                != DBUS_TYPE_ARRAY) {
+            != DBUS_TYPE_ARRAY)
+        {
             return false;
         }
         DBusMessageIter subIterator;
         dbus_message_iter_recurse(responseIterator, &subIterator);
         while (dbus_message_iter_get_arg_type(&subIterator)
             return false;
         }
         DBusMessageIter subIterator;
         dbus_message_iter_recurse(responseIterator, &subIterator);
         while (dbus_message_iter_get_arg_type(&subIterator)
-                != DBUS_TYPE_INVALID) {
+               != DBUS_TYPE_INVALID)
+        {
             typename std::set<T>::value_type element;
             typename std::set<T>::value_type element;
-            if (!deserialize(&subIterator, &element)){
+            if (!deserialize(&subIterator, &element)) {
                 return false;
             }
             arg->insert(element);
                 return false;
             }
             arg->insert(element);
@@ -153,20 +156,21 @@ struct Deserialization
     // std::pair
     template<typename A, typename B>
     static bool deserialize(
     // std::pair
     template<typename A, typename B>
     static bool deserialize(
-            DBusMessageIter* argsIterator,
-            const std::pair<A, B>* arg)
+        DBusMessageIter* argsIterator,
+        const std::pair<A, B>* arg)
     {
         if (dbus_message_iter_get_arg_type(argsIterator)
     {
         if (dbus_message_iter_get_arg_type(argsIterator)
-                != DBUS_TYPE_DICT_ENTRY) {
+            != DBUS_TYPE_DICT_ENTRY)
+        {
             return false;
         }
         DBusMessageIter dictEntryIterator;
         dbus_message_iter_recurse(argsIterator, &dictEntryIterator);
             return false;
         }
         DBusMessageIter dictEntryIterator;
         dbus_message_iter_recurse(argsIterator, &dictEntryIterator);
-        if (!deserialize(dictEntryIterator, &arg->first)){
+        if (!deserialize(dictEntryIterator, &arg->first)) {
             return false;
         }
         dbus_message_iter_next(&dictEntryIterator);
             return false;
         }
         dbus_message_iter_next(&dictEntryIterator);
-        if (!deserialize(dictEntryIterator, &arg->second)){
+        if (!deserialize(dictEntryIterator, &arg->second)) {
             return false;
         }
         return true;
             return false;
         }
         return true;
@@ -175,19 +179,21 @@ struct Deserialization
     // std::map
     template<typename K, typename V>
     static bool deserialize(
     // std::map
     template<typename K, typename V>
     static bool deserialize(
-            DBusMessageIter* responseIterator,
-            const std::map<K, V>* arg)
+        DBusMessageIter* responseIterator,
+        const std::map<K, V>* arg)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
     {
         if (dbus_message_iter_get_arg_type(responseIterator)
-                != DBUS_TYPE_ARRAY) {
+            != DBUS_TYPE_ARRAY)
+        {
             return false;
         }
         DBusMessageIter subIterator;
         dbus_message_iter_recurse(responseIterator, &subIterator);
         while (dbus_message_iter_get_arg_type(&subIterator)
             return false;
         }
         DBusMessageIter subIterator;
         dbus_message_iter_recurse(responseIterator, &subIterator);
         while (dbus_message_iter_get_arg_type(&subIterator)
-                != DBUS_TYPE_INVALID) {
+               != DBUS_TYPE_INVALID)
+        {
             typename std::pair<K, V> element;
             typename std::pair<K, V> element;
-            if (!deserialize(&subIterator, &element)){
+            if (!deserialize(&subIterator, &element)) {
                 return false;
             }
             arg->insert(element);
                 return false;
             }
             arg->insert(element);
@@ -195,7 +201,6 @@ struct Deserialization
         }
         return true;
     }
         }
         return true;
     }
-
 };
 
 template<>
 };
 
 template<>
@@ -205,14 +210,14 @@ inline bool Deserialization::deserialize<bool>(
 {
     unsigned int value;
     if (dbus_message_iter_get_arg_type(responseIterator)
 {
     unsigned int value;
     if (dbus_message_iter_get_arg_type(responseIterator)
-        != SimpleType<bool>::value) {
+        != SimpleType<bool>::value)
+    {
         return false;
     }
     dbus_message_iter_get_basic(responseIterator, &value);
     *arg = static_cast<bool>(value);
     return true;
 }
         return false;
     }
     dbus_message_iter_get_basic(responseIterator, &value);
     *arg = static_cast<bool>(value);
     return true;
 }
-
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index d5e3591..ec1b06b 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 class InterfaceDispatcher : public DBus::Dispatcher
 {
 class InterfaceDispatcher : public DBus::Dispatcher
 {
-public:
-    explicit InterfaceDispatcher(const std::string& interfaceName):
+  public:
+    explicit InterfaceDispatcher(const std::string& interfaceName) :
         m_interfaceName(interfaceName)
         m_interfaceName(interfaceName)
-    {
-    }
+    {}
 
     virtual ~InterfaceDispatcher()
     {}
 
     virtual ~InterfaceDispatcher()
     {}
@@ -69,11 +67,11 @@ public:
                               GVariant* parameters,
                               GDBusMethodInvocation* invocation)
     {
                               GVariant* parameters,
                               GDBusMethodInvocation* invocation)
     {
-        if (g_strcmp0(interfaceName, m_interfaceName.c_str()) == 0){
+        if (g_strcmp0(interfaceName, m_interfaceName.c_str()) == 0) {
             onMethodCall(methodName, parameters, invocation);
         } else {
             LogPedantic("Called invalid interface: " << interfaceName <<
             onMethodCall(methodName, parameters, invocation);
         } else {
             LogPedantic("Called invalid interface: " << interfaceName <<
-                     " instead of: " << m_interfaceName);
+                        " instead of: " << m_interfaceName);
         }
     }
 
         }
     }
 
@@ -97,10 +95,10 @@ public:
         LogInfo("InterfaceDispatcher onPropertySet: " << propertyName);
         return false;
     }
         LogInfo("InterfaceDispatcher onPropertySet: " << propertyName);
         return false;
     }
-private:
-    std::string m_interfaceName,  m_xml;
-};
 
 
+  private:
+    std::string m_interfaceName, m_xml;
+};
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index 7bfa65b..c0fa338 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 struct Serialization
 {
 struct Serialization
 {
-
     // std::string
     static bool serialize(
     // std::string
     static bool serialize(
-            DBusMessageIter* argsIterator,
-            const std::string& str)
+        DBusMessageIter* argsIterator,
+        const std::string& str)
     {
         return serialize(argsIterator, str.c_str());
     }
     {
         return serialize(argsIterator, str.c_str());
     }
@@ -65,17 +63,19 @@ struct Serialization
     // dbus array serialization
     template<typename T>
     static bool serializeContainer(
     // dbus array serialization
     template<typename T>
     static bool serializeContainer(
-            DBusMessageIter* argsIterator,
-            const T& arg)
+        DBusMessageIter* argsIterator,
+        const T& arg)
     {
         typename T::const_iterator containerIt;
         DBusMessageIter subIterator;
         if (!dbus_message_iter_open_container(argsIterator, DBUS_TYPE_ARRAY,
     {
         typename T::const_iterator containerIt;
         DBusMessageIter subIterator;
         if (!dbus_message_iter_open_container(argsIterator, DBUS_TYPE_ARRAY,
-                Signature<typename T::value_type>::value(), &subIterator)) {
+                                              Signature<typename T::value_type>
+                                                  ::value(), &subIterator))
+        {
             return false;
         }
             return false;
         }
-        FOREACH(containerIt,arg) {
-            if (!serialize(&subIterator, *containerIt)){
+        FOREACH(containerIt, arg) {
+            if (!serialize(&subIterator, *containerIt)) {
                 return false;
             }
         }
                 return false;
             }
         }
@@ -85,8 +85,8 @@ struct Serialization
     // std::vector
     template<typename T>
     static bool serialize(
     // std::vector
     template<typename T>
     static bool serialize(
-            DBusMessageIter* argsIterator,
-            const std::vector<T> &arg)
+        DBusMessageIter* argsIterator,
+        const std::vector<T> &arg)
     {
         return serializeContainer(argsIterator, arg);
     }
     {
         return serializeContainer(argsIterator, arg);
     }
@@ -94,8 +94,8 @@ struct Serialization
     // std::list
     template<typename T>
     static bool serialize(
     // std::list
     template<typename T>
     static bool serialize(
-            DBusMessageIter* argsIterator,
-            const std::list<T> &arg)
+        DBusMessageIter* argsIterator,
+        const std::list<T> &arg)
     {
         return serializeContainer(argsIterator, arg);
     }
     {
         return serializeContainer(argsIterator, arg);
     }
@@ -103,8 +103,8 @@ struct Serialization
     // std::set
     template<typename T>
     static bool serialize(
     // std::set
     template<typename T>
     static bool serialize(
-            DBusMessageIter* argsIterator,
-            const std::set<T> &arg)
+        DBusMessageIter* argsIterator,
+        const std::set<T> &arg)
     {
         return serializeContainer(argsIterator, arg);
     }
     {
         return serializeContainer(argsIterator, arg);
     }
@@ -112,18 +112,20 @@ struct Serialization
     // std::pair
     template<typename A, typename B>
     static bool serialize(
     // std::pair
     template<typename A, typename B>
     static bool serialize(
-            DBusMessageIter* argsIterator,
-            const std::pair<A, B> &arg)
+        DBusMessageIter* argsIterator,
+        const std::pair<A, B> &arg)
     {
         DBusMessageIter dictEntryIterator;
         if (!dbus_message_iter_open_container(argsIterator,
     {
         DBusMessageIter dictEntryIterator;
         if (!dbus_message_iter_open_container(argsIterator,
-                DBUS_TYPE_DICT_ENTRY, NULL, &dictEntryIterator)) {
+                                              DBUS_TYPE_DICT_ENTRY, NULL,
+                                              &dictEntryIterator))
+        {
             return false;
         }
             return false;
         }
-        if (!serialize(dictEntryIterator, arg.first)){
+        if (!serialize(dictEntryIterator, arg.first)) {
             return false;
         }
             return false;
         }
-        if (!serialize(dictEntryIterator, arg.second)){
+        if (!serialize(dictEntryIterator, arg.second)) {
             return false;
         }
         return dbus_message_iter_close_container(argsIterator,
             return false;
         }
         return dbus_message_iter_close_container(argsIterator,
@@ -133,12 +135,11 @@ struct Serialization
     // std::map
     template<typename K, typename V>
     static bool serialize(
     // std::map
     template<typename K, typename V>
     static bool serialize(
-            DBusMessageIter* argsIterator,
-            const std::map<K, V> &arg)
+        DBusMessageIter* argsIterator,
+        const std::map<K, V> &arg)
     {
         return serializeContainer(argsIterator, arg);
     }
     {
         return serializeContainer(argsIterator, arg);
     }
-
 };
 
 // char* and all integer types + doubles
 };
 
 // char* and all integer types + doubles
@@ -151,7 +152,6 @@ inline bool Serialization::serialize<bool>(DBusMessageIter* argsIterator,
                                           SimpleType<bool>::value,
                                           &value);
 }
                                           SimpleType<bool>::value,
                                           &value);
 }
-
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index 5f3b28b..eb09d6d 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 struct ServerDeserialization {
 struct ServerDeserialization {
-
-    template<typename T, typename ...Args>
-    static bool deserialize(GVariant* g, T* arg1, Args... args)
+    template<typename T, typename ... Args>
+    static bool deserialize(GVariant* g, T* arg1, Args ... args)
     {
         Assert(NULL != g);
         Assert(NULL != arg1);
     {
         Assert(NULL != g);
         Assert(NULL != arg1);
@@ -48,7 +46,7 @@ struct ServerDeserialization {
             g_variant_iter_free(iterator);
             return false;
         }
             g_variant_iter_free(iterator);
             return false;
         }
-        if (!deserializeIterator(iterator, args...)) {
+        if (!deserializeIterator(iterator, args ...)) {
             g_variant_iter_free(iterator);
             return false;
         }
             g_variant_iter_free(iterator);
             return false;
         }
@@ -74,8 +72,8 @@ struct ServerDeserialization {
     }
 
     // deserialization from GVariant tuple iterator
     }
 
     // deserialization from GVariant tuple iterator
-    template<typename T, typename ...Args>
-    static bool deserializeIterator(GVariantIter* g, T* arg1, Args... args)
+    template<typename T, typename ... Args>
+    static bool deserializeIterator(GVariantIter* g, T* arg1, Args ... args)
     {
         Assert(NULL != g);
         Assert(NULL != arg1);
     {
         Assert(NULL != g);
         Assert(NULL != arg1);
@@ -86,7 +84,7 @@ struct ServerDeserialization {
         if (!deserializeElem(elem, arg1)) {
             return false;
         }
         if (!deserializeElem(elem, arg1)) {
             return false;
         }
-        if (!deserializeIterator(g, args...)) {
+        if (!deserializeIterator(g, args ...)) {
             return false;
         }
         return true;
             return false;
         }
         return true;
@@ -145,7 +143,7 @@ struct ServerDeserialization {
     }
 
     static bool deserializeElem(GVariant* parameters,
     }
 
     static bool deserializeElem(GVariant* parameters,
-                            std::vector<std::string>* outArray)
+                                std::vector<std::string>* outArray)
     {
         unsigned int i = 0;
         gsize length = 0;
     {
         unsigned int i = 0;
         gsize length = 0;
@@ -174,7 +172,6 @@ struct ServerDeserialization {
         return true;
     }
 };
         return true;
     }
 };
-
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index 8c299ef..9e47ca6 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 struct ServerSerialization {
 struct ServerSerialization {
-
-    template<typename ...Args>
-    static GVariant* serialize(Args... args)
+    template<typename ... Args>
+    static GVariant* serialize(Args ... args)
     {
         GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE_TUPLE);
         if (NULL == builder) {
     {
         GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE_TUPLE);
         if (NULL == builder) {
@@ -43,10 +41,10 @@ struct ServerSerialization {
     }
 
     // serialization on GVariantBuilder
     }
 
     // serialization on GVariantBuilder
-    template<typename T, typename ...Args>
+    template<typename T, typename ... Args>
     static void serializeBuilder(GVariantBuilder* builder,
                                  const T& arg,
     static void serializeBuilder(GVariantBuilder* builder,
                                  const T& arg,
-                                 Args... args)
+                                 Args ... args)
     {
         serializeElem(builder, arg);
         serializeBuilder(builder, args ...);
     {
         serializeElem(builder, arg);
         serializeBuilder(builder, args ...);
@@ -86,12 +84,11 @@ struct ServerSerialization {
     }
 
     static void serializeElem(GVariantBuilder* builder,
     }
 
     static void serializeElem(GVariantBuilder* builder,
-                                 const std::string& arg)
+                              const std::string& arg)
     {
         g_variant_builder_add_value(builder, g_variant_new_string(arg.c_str()));
     }
 };
     {
         g_variant_builder_add_value(builder, g_variant_new_string(arg.c_str()));
     }
 };
-
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index af0c2ef..bc99108 100644 (file)
@@ -28,7 +28,6 @@
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 template<typename T>
 struct SimpleType;
 
 template<typename T>
 struct SimpleType;
 
@@ -119,7 +118,7 @@ template<>
 struct SimpleType<unsigned char>
 {
     static const int value =
 struct SimpleType<unsigned char>
 {
     static const int value =
-            __UnsignedIntegerType<sizeof(unsigned char)>::value;
+        __UnsignedIntegerType<sizeof(unsigned char)>::value;
 };
 
 template<>
 };
 
 template<>
@@ -132,7 +131,7 @@ template<>
 struct SimpleType<unsigned short>
 {
     static const int value =
 struct SimpleType<unsigned short>
 {
     static const int value =
-            __UnsignedIntegerType<sizeof(unsigned short)>::value;
+        __UnsignedIntegerType<sizeof(unsigned short)>::value;
 };
 
 template<>
 };
 
 template<>
@@ -145,7 +144,7 @@ template<>
 struct SimpleType<unsigned int>
 {
     static const int value =
 struct SimpleType<unsigned int>
 {
     static const int value =
-            __UnsignedIntegerType<sizeof(unsigned int)>::value;
+        __UnsignedIntegerType<sizeof(unsigned int)>::value;
 };
 
 template<>
 };
 
 template<>
@@ -158,7 +157,7 @@ template<>
 struct SimpleType<unsigned long>
 {
     static const int value =
 struct SimpleType<unsigned long>
 {
     static const int value =
-            __UnsignedIntegerType<sizeof(unsigned long)>::value;
+        __UnsignedIntegerType<sizeof(unsigned long)>::value;
 };
 
 template<>
 };
 
 template<>
@@ -221,20 +220,17 @@ struct ArraySignature
 // std::vector
 template<typename T>
 struct Signature<std::vector<T> > : public ArraySignature<T>
 // std::vector
 template<typename T>
 struct Signature<std::vector<T> > : public ArraySignature<T>
-{
-};
+{};
 
 // std::list
 template<typename T>
 struct Signature<std::list<T> > : public ArraySignature<T>
 
 // std::list
 template<typename T>
 struct Signature<std::list<T> > : public ArraySignature<T>
-{
-};
+{};
 
 // std::set
 template<typename T>
 struct Signature<std::set<T> > : public ArraySignature<T>
 
 // std::set
 template<typename T>
 struct Signature<std::set<T> > : public ArraySignature<T>
-{
-};
+{};
 
 // std::pair
 template<typename K, typename V>
 
 // std::pair
 template<typename K, typename V>
@@ -244,8 +240,8 @@ struct Signature<std::pair<K, V> >
     {
         static const std::string signature = std::string(
                 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING)
     {
         static const std::string signature = std::string(
                 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING)
-                + Signature<K>::value() + Signature<V>::value()
-                + DBUS_DICT_ENTRY_END_CHAR_AS_STRING;
+            + Signature<K>::value() + Signature<V>::value()
+            + DBUS_DICT_ENTRY_END_CHAR_AS_STRING;
         return signature.c_str();
     }
 };
         return signature.c_str();
     }
 };
@@ -253,9 +249,7 @@ struct Signature<std::pair<K, V> >
 // std::map
 template<typename K, typename V>
 struct Signature<std::map<K, V> > : public ArraySignature<std::pair<K, V> >
 // std::map
 template<typename K, typename V>
 struct Signature<std::map<K, V> > : public ArraySignature<std::pair<K, V> >
-{
-};
-
+{};
 } // namespace DBus
 } // namespace DPL
 
 } // namespace DBus
 } // namespace DPL
 
index 68e4397..93e62e6 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 class Dispatcher
 {
 class Dispatcher
 {
-public:
-    virtual ~Dispatcher() =0;
+  public:
+    virtual ~Dispatcher() = 0;
 
     /**
      * Called on method invocation.
 
     /**
      * Called on method invocation.
@@ -52,7 +51,7 @@ public:
                               const gchar* interfaceName,
                               const gchar* methodName,
                               GVariant* parameters,
                               const gchar* interfaceName,
                               const gchar* methodName,
                               GVariant* parameters,
-                              GDBusMethodInvocation* invocation) =0;
+                              GDBusMethodInvocation* invocation) = 0;
 
     /**
      * Called on property get.
 
     /**
      * Called on property get.
@@ -94,7 +93,6 @@ public:
                                    GVariant* value,
                                    GError** error);
 };
                                    GVariant* value,
                                    GError** error);
 };
-
 }
 }
 
 }
 }
 
index fb21bf0..035d16f 100644 (file)
@@ -27,7 +27,6 @@
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 /**
  * Thrown when none of the following, more specific exception fit.
  */
 /**
  * Thrown when none of the following, more specific exception fit.
  */
@@ -42,7 +41,6 @@ DECLARE_EXCEPTION_TYPE(DBus::Exception, ConnectionClosedException)
  * Thrown when passing invalid argument(s).
  */
 DECLARE_EXCEPTION_TYPE(DBus::Exception, InvalidArgumentException)
  * Thrown when passing invalid argument(s).
  */
 DECLARE_EXCEPTION_TYPE(DBus::Exception, InvalidArgumentException)
-
 }
 }
 
 }
 }
 
diff --git a/modules/dbus/include/dpl/dbus/glib_util.h b/modules/dbus/include/dpl/dbus/glib_util.h
new file mode 100644 (file)
index 0000000..13206e3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        glib_util.h
+ * @author      Iwanek Tomasz (t.iwanek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the definitions of loop controlling utilities
+ */
+#ifndef GLIB_UTIL_H
+#define GLIB_UTIL_H
+
+//this header wraps glib headers which generates warnings
+
+#pragma GCC system_header
+#include <gio/gio.h>
+
+#endif // GLIB_UTIL_H
index 1bf1148..6248dab 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 class Interface;
 typedef std::shared_ptr<Interface> InterfacePtr;
 
 class Interface : private DPL::Noncopyable
 {
 class Interface;
 typedef std::shared_ptr<Interface> InterfacePtr;
 
 class Interface : private DPL::Noncopyable
 {
-public:
+  public:
     /**
      * Parses supplied XML string to produce DBus interface descriptions.
      *
     /**
      * Parses supplied XML string to produce DBus interface descriptions.
      *
@@ -46,9 +45,9 @@ public:
      * @throw DPL::DBus::Exception If error while parsing occurs.
      */
     static std::vector<InterfacePtr> fromXMLString(
      * @throw DPL::DBus::Exception If error while parsing occurs.
      */
     static std::vector<InterfacePtr> fromXMLString(
-            const std::string& xmlString);
+        const std::string& xmlString);
 
 
-public:
+  public:
     ~Interface();
 
     /**
     ~Interface();
 
     /**
@@ -73,7 +72,7 @@ public:
      */
     void setDispatcher(Dispatcher* dispatcher);
 
      */
     void setDispatcher(Dispatcher* dispatcher);
 
-private:
+  private:
     static void onMethodCallFunc(GDBusConnection *connection,
                                  const gchar *sender,
                                  const gchar *objectPath,
     static void onMethodCallFunc(GDBusConnection *connection,
                                  const gchar *sender,
                                  const gchar *objectPath,
@@ -108,7 +107,6 @@ private:
 
     Dispatcher* m_dispatcher;
 };
 
     Dispatcher* m_dispatcher;
 };
-
 }
 }
 
 }
 }
 
index 3d553cf..19c3b90 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 class ObjectProxy;
 
 /**
  * Represents a remote method.
  */
 class ObjectProxy;
 
 /**
  * Represents a remote method.
  */
-template<typename Result, typename ...Args>
+template<typename Result, typename ... Args>
 class MethodProxy
 {
 class MethodProxy
 {
-public:
+  public:
     ~MethodProxy()
     {
         g_object_unref(m_connection);
     ~MethodProxy()
     {
         g_object_unref(m_connection);
@@ -60,24 +59,24 @@ public:
      * @throw DBus::ConnectionClosedException If connection is closed.
      * @throw DBus::Exception If some other error occurs.
      */
      * @throw DBus::ConnectionClosedException If connection is closed.
      * @throw DBus::Exception If some other error occurs.
      */
-    Result operator()(const Args&... args)
+    Result operator()(const Args& ... args)
     {
     {
-        return invoke(args...);
+        return invoke(args ...);
     }
 
     }
 
-private:
+  private:
     friend class ObjectProxy;
 
     MethodProxy(GDBusConnection* connection,
                 const std::string& serviceName,
                 const std::string& objectPath,
                 const std::string& interfaceName,
     friend class ObjectProxy;
 
     MethodProxy(GDBusConnection* connection,
                 const std::string& serviceName,
                 const std::string& objectPath,
                 const std::string& interfaceName,
-                const std::string& methodName)
-        m_connection(connection),
-          m_serviceName(serviceName),
-          m_objectPath(objectPath),
-          m_interfaceName(interfaceName),
-          m_methodName(methodName)
+                const std::string& methodName) :
+        m_connection(connection),
+        m_serviceName(serviceName),
+        m_objectPath(objectPath),
+        m_interfaceName(interfaceName),
+        m_methodName(methodName)
     {
         Assert(m_connection && "Connection is not set.");
 
     {
         Assert(m_connection && "Connection is not set.");
 
@@ -91,9 +90,9 @@ private:
      */
     template<typename R = Result>
     typename std::enable_if<!std::is_void<R>::value, R>::type
      */
     template<typename R = Result>
     typename std::enable_if<!std::is_void<R>::value, R>::type
-    invoke(const Args&... args)
+    invoke(const Args& ... args)
     {
     {
-        GVariant* parameters = serialize(args...);
+        GVariant* parameters = serialize(args ...);
 
         GVariant* invokeResult = invokeSync(parameters);
 
 
         GVariant* invokeResult = invokeSync(parameters);
 
@@ -111,9 +110,9 @@ private:
      */
     template<typename R = Result>
     typename std::enable_if<std::is_void<R>::value>::type
      */
     template<typename R = Result>
     typename std::enable_if<std::is_void<R>::value>::type
-    invoke(const Args&... args)
+    invoke(const Args& ... args)
     {
     {
-        GVariant* parameters = serialize(args...);
+        GVariant* parameters = serialize(args ...);
 
         GVariant* invokeResult = invokeSync(parameters);
 
 
         GVariant* invokeResult = invokeSync(parameters);
 
@@ -124,10 +123,10 @@ private:
      * @remarks ArgsM... are the same as Args...; it has been made a template
      *          to make overloading/specialization possible.
      */
      * @remarks ArgsM... are the same as Args...; it has been made a template
      *          to make overloading/specialization possible.
      */
-    template<typename ...ArgsM>
-    GVariant* serialize(ArgsM&&... args)
+    template<typename ... ArgsM>
+    GVariant* serialize(ArgsM && ... args)
     {
     {
-        return ServerSerialization::serialize(std::forward<ArgsM>(args)...);
+        return ServerSerialization::serialize(std::forward<ArgsM>(args) ...);
     }
 
     /**
     }
 
     /**
@@ -151,7 +150,8 @@ private:
     {
         GError* error = NULL;
 
     {
         GError* error = NULL;
 
-        LogPedantic("Invoking method: " << m_interfaceName << "." << m_methodName);
+        LogPedantic(
+            "Invoking method: " << m_interfaceName << "." << m_methodName);
         GVariant* result = g_dbus_connection_call_sync(m_connection,
                                                        m_serviceName.c_str(),
                                                        m_objectPath.c_str(),
         GVariant* result = g_dbus_connection_call_sync(m_connection,
                                                        m_serviceName.c_str(),
                                                        m_objectPath.c_str(),
@@ -163,8 +163,7 @@ private:
                                                        DBUS_SYNC_CALL_TIMEOUT,
                                                        NULL,
                                                        &error);
                                                        DBUS_SYNC_CALL_TIMEOUT,
                                                        NULL,
                                                        &error);
-        if (NULL == result)
-        {
+        if (NULL == result) {
             std::ostringstream oss;
             oss << "Error while invoking: "
                 << m_interfaceName << "." << m_methodName
             std::ostringstream oss;
             oss << "Error while invoking: "
                 << m_interfaceName << "." << m_methodName
@@ -175,8 +174,7 @@ private:
 
             g_error_free(error);
 
 
             g_error_free(error);
 
-            switch (code)
-            {
+            switch (code) {
             case G_IO_ERROR_INVALID_ARGUMENT:
                 ThrowMsg(DBus::InvalidArgumentException, message);
             case G_IO_ERROR_CLOSED:
             case G_IO_ERROR_INVALID_ARGUMENT:
                 ThrowMsg(DBus::InvalidArgumentException, message);
             case G_IO_ERROR_CLOSED:
@@ -206,26 +204,24 @@ private:
 /**
  * Smart pointer for MethodProxy objects.
  */
 /**
  * Smart pointer for MethodProxy objects.
  */
-template<typename Result, typename ...Args>
+template<typename Result, typename ... Args>
 class MethodProxyPtr
 {
 class MethodProxyPtr
 {
-public:
-    explicit MethodProxyPtr(MethodProxy<Result, Args...>* method = NULL)
-        : m_method(method)
-    {
-    }
+  public:
+    explicit MethodProxyPtr(MethodProxy<Result, Args ...>* method = NULL) :
+        m_method(method)
+    {}
 
 
-    Result operator()(const Args&... args) const
+    Result operator()(const Args& ... args) const
     {
         Assert(NULL != m_method.get() && "Method not set.");
 
     {
         Assert(NULL != m_method.get() && "Method not set.");
 
-        return (*m_method)(args...);
+        return (*m_method)(args ...);
     }
 
     }
 
-private:
-    std::shared_ptr<MethodProxy<Result, Args...> > m_method;
+  private:
+    std::shared_ptr<MethodProxy<Result, Args ...> > m_method;
 };
 };
-
 }
 }
 
 }
 }
 
index 7731dfa..191464c 100644 (file)
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 class Object;
 typedef std::shared_ptr<Object> ObjectPtr;
 
 class Object
 {
 class Object;
 typedef std::shared_ptr<Object> ObjectPtr;
 
 class Object
 {
-public:
+  public:
     /**
      * Creates an object.
      *
     /**
      * Creates an object.
      *
@@ -61,13 +60,12 @@ public:
      */
     InterfacePtr getInterface() const;
 
      */
     InterfacePtr getInterface() const;
 
-private:
+  private:
     Object(const std::string& path, const InterfacePtr& interface);
 
     std::string m_path;
     InterfacePtr m_interface;
 };
     Object(const std::string& path, const InterfacePtr& interface);
 
     std::string m_path;
     InterfacePtr m_interface;
 };
-
 }
 }
 
 }
 }
 
index 3d727c0..17764f1 100644 (file)
@@ -30,7 +30,6 @@
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
 class Connection;
 
 /**
 class Connection;
 
 /**
@@ -38,7 +37,7 @@ class Connection;
  */
 class ObjectProxy
 {
  */
 class ObjectProxy
 {
-public:
+  public:
     ~ObjectProxy();
 
     /**
     ~ObjectProxy();
 
     /**
@@ -51,25 +50,24 @@ public:
      * @return Proxy to remote method.
      * @throw DBus::ConnectionClosedException If connection is closed.
      */
      * @return Proxy to remote method.
      * @throw DBus::ConnectionClosedException If connection is closed.
      */
-    template<typename Result, typename ...Args>
-    MethodProxyPtr<Result, Args...> createMethodProxy(
-            const std::string& interface,
-            const std::string& name)
+    template<typename Result, typename ... Args>
+    MethodProxyPtr<Result, Args ...> createMethodProxy(
+        const std::string& interface,
+        const std::string& name)
     {
     {
-        if (g_dbus_connection_is_closed(m_connection))
-        {
+        if (g_dbus_connection_is_closed(m_connection)) {
             ThrowMsg(DBus::ConnectionClosedException, "Connection closed.");
         }
 
             ThrowMsg(DBus::ConnectionClosedException, "Connection closed.");
         }
 
-        return MethodProxyPtr<Result, Args...>(
-                new MethodProxy<Result, Args...>(m_connection,
-                                                 m_serviceName,
-                                                 m_objectPath,
-                                                 interface,
-                                                 name));
+        return MethodProxyPtr<Result, Args ...>(
+                   new MethodProxy<Result, Args ...>(m_connection,
+                                                     m_serviceName,
+                                                     m_objectPath,
+                                                     interface,
+                                                     name));
     }
 
     }
 
-private:
+  private:
     friend class Connection;
 
     ObjectProxy(GDBusConnection* connection,
     friend class Connection;
 
     ObjectProxy(GDBusConnection* connection,
@@ -80,7 +78,6 @@ private:
     std::string m_serviceName;
     std::string m_objectPath;
 };
     std::string m_serviceName;
     std::string m_objectPath;
 };
-
 }
 }
 
 }
 }
 
index 39220ae..795a757 100644 (file)
 #include <dpl/event/event_support.h>
 #include <dpl/dbus/connection.h>
 
 #include <dpl/event/event_support.h>
 #include <dpl/dbus/connection.h>
 
-namespace DPL
-{
-namespace DBus
-{
-
-namespace ServerEvents
-{
+namespace DPL {
+namespace DBus {
+namespace ServerEvents {
 /**
  * Emitted when new connection is accepted.
  *
 /**
  * Emitted when new connection is accepted.
  *
@@ -57,7 +53,7 @@ typedef std::shared_ptr<Server> ServerPtr;
  */
 class Server : public DPL::Event::EventSupport<ServerEvents::NewConnectionEvent>
 {
  */
 class Server : public DPL::Event::EventSupport<ServerEvents::NewConnectionEvent>
 {
-public:
+  public:
     /**
      * Creates server.
      *
     /**
      * Creates server.
      *
@@ -78,17 +74,16 @@ public:
      */
     void stop();
 
      */
     void stop();
 
-protected:
+  protected:
     explicit Server(GDBusServer* server);
 
     explicit Server(GDBusServer* server);
 
-private:
+  private:
     static gboolean onNewConnection(GDBusServer* server,
                                     GDBusConnection* connection,
                                     gpointer data);
 
     GDBusServer* m_server;
 };
     static gboolean onNewConnection(GDBusServer* server,
                                     GDBusConnection* connection,
                                     gpointer data);
 
     GDBusServer* m_server;
 };
-
 }
 }
 
 }
 }
 
index e50faa8..52c0065 100644 (file)
  * @version 1.0
  * @brief
  */
  * @version 1.0
  * @brief
  */
-
+#include <stddef.h>
 #include <dpl/log/log.h>
 #include <dpl/dbus/connection.h>
 #include <dpl/dbus/exception.h>
 #include <dpl/dbus/object_proxy.h>
 
 #include <dpl/log/log.h>
 #include <dpl/dbus/connection.h>
 #include <dpl/dbus/exception.h>
 #include <dpl/dbus/object_proxy.h>
 
-namespace DPL
-{
-namespace DBus
-{
-
+namespace DPL {
+namespace DBus {
 ConnectionPtr Connection::sessionBus()
 {
     return connectTo(G_BUS_TYPE_SESSION);
 ConnectionPtr Connection::sessionBus()
 {
     return connectTo(G_BUS_TYPE_SESSION);
@@ -47,11 +44,9 @@ ConnectionPtr Connection::connectTo(GBusType busType)
     GDBusConnection* connection = g_bus_get_sync(busType,
                                                  NULL,
                                                  &error);
     GDBusConnection* connection = g_bus_get_sync(busType,
                                                  NULL,
                                                  &error);
-    if (NULL == connection)
-    {
+    if (NULL == connection) {
         std::string message;
         std::string message;
-        if (NULL != error)
-        {
+        if (NULL != error) {
             message = error->message;
             g_error_free(error);
         }
             message = error->message;
             g_error_free(error);
         }
@@ -69,16 +64,14 @@ ConnectionPtr Connection::connectTo(const std::string& address)
     GError* error = NULL;
 
     GDBusConnection* connection = g_dbus_connection_new_for_address_sync(
     GError* error = NULL;
 
     GDBusConnection* connection = g_dbus_connection_new_for_address_sync(
-                                          address.c_str(),
-                                          G_DBUS_CONNECTION_FLAGS_NONE,
-                                          NULL,
-                                          NULL,
-                                          &error);
-    if (NULL == connection)
-    {
+            address.c_str(),
+            G_DBUS_CONNECTION_FLAGS_NONE,
+            NULL,
+            NULL,
+            &error);
+    if (NULL == connection) {
         std::string message;
         std::string message;
-        if (NULL != error)
-        {
+        if (NULL != error) {
             message = error->message;
             g_error_free(error);
         }
             message = error->message;
             g_error_free(error);
         }
@@ -89,8 +82,8 @@ ConnectionPtr Connection::connectTo(const std::string& address)
     return ConnectionPtr(new Connection(connection));
 }
 
     return ConnectionPtr(new Connection(connection));
 }
 
-Connection::Connection(GDBusConnection* connection)
-    m_connection(connection)
+Connection::Connection(GDBusConnection* connection) :
+    m_connection(connection)
 {
     g_signal_connect(m_connection,
                      "closed",
 {
     g_signal_connect(m_connection,
                      "closed",
@@ -102,28 +95,28 @@ Connection::~Connection()
 {
     std::for_each(m_registeredServices.begin(),
                   m_registeredServices.end(),
 {
     std::for_each(m_registeredServices.begin(),
                   m_registeredServices.end(),
-                  [] (const RegisteredServices::value_type& value)
+                  [] (const RegisteredServices::value_type & value)
                   {
                       g_bus_unown_name(value.second);
                   });
 
     std::for_each(m_registeredObjects.begin(),
                   m_registeredObjects.end(),
                   {
                       g_bus_unown_name(value.second);
                   });
 
     std::for_each(m_registeredObjects.begin(),
                   m_registeredObjects.end(),
-                  [m_connection] (const RegisteredObjects::value_type& value)
+                  [this] (const RegisteredObjects::value_type & value)
                   {
                       g_dbus_connection_unregister_object(
                   {
                       g_dbus_connection_unregister_object(
-                              m_connection,
-                              value.second.registrationId);
+                          m_connection,
+                          value.second.registrationId);
                   });
 
                   });
 
-    if (!g_dbus_connection_is_closed(m_connection))
-    {
+    if (!g_dbus_connection_is_closed(m_connection)) {
         GError* error = NULL;
 
         GError* error = NULL;
 
-        if (FALSE == g_dbus_connection_flush_sync(m_connection, NULL, &error))
+        if (FALSE ==
+            g_dbus_connection_flush_sync(m_connection, NULL, &error))
         {
             LogPedantic("Could not flush the connection"
         {
             LogPedantic("Could not flush the connection"
-                     << " <" << error->message << ">");
+                        << " <" << error->message << ">");
             g_error_free(error);
         }
     }
             g_error_free(error);
         }
     }
@@ -140,8 +133,7 @@ void Connection::registerService(const std::string& serviceName)
                                                onServiceNameLost,
                                                this,
                                                NULL);
                                                onServiceNameLost,
                                                this,
                                                NULL);
-    if (0 >= regId)
-    {
+    if (0 >= regId) {
         ThrowMsg(DBus::Exception, "Error while registering service.");
     }
 
         ThrowMsg(DBus::Exception, "Error while registering service.");
     }
 
@@ -152,8 +144,7 @@ void Connection::registerService(const std::string& serviceName)
 void Connection::unregisterService(const std::string& serviceName)
 {
     auto it = m_registeredServices.find(serviceName);
 void Connection::unregisterService(const std::string& serviceName)
 {
     auto it = m_registeredServices.find(serviceName);
-    if (m_registeredServices.end() == it)
-    {
+    if (m_registeredServices.end() == it) {
         ThrowMsg(DBus::Exception, "Service not registered.");
     }
 
         ThrowMsg(DBus::Exception, "Service not registered.");
     }
 
@@ -167,45 +158,41 @@ void Connection::registerObject(const ObjectPtr& object)
     GError* error = NULL;
 
     guint regId = g_dbus_connection_register_object(
     GError* error = NULL;
 
     guint regId = g_dbus_connection_register_object(
-                          m_connection,
-                          object->getPath().c_str(),
-                          object->getInterface()->getInfo(),
-                          object->getInterface()->getVTable(),
-                          // TODO This is ugly, fix this!
-                          object->getInterface().get(),
-                          NULL,
-                          &error);
-    if (0 == regId)
-    {
+            m_connection,
+            object->getPath().c_str(),
+            object->getInterface()->getInfo(),
+            object->getInterface()->getVTable(),
+            // TODO This is ugly, fix this!
+            object->getInterface().get(),
+            NULL,
+            &error);
+    if (0 == regId) {
         std::string message;
         std::string message;
-        if (NULL != error)
-        {
+        if (NULL != error) {
             message = error->message;
             LogPedantic(error->message << " " << error->code);
             g_error_free(error);
         }
         ThrowMsg(DBus::Exception, "Error while registering an object: "
             message = error->message;
             LogPedantic(error->message << " " << error->code);
             g_error_free(error);
         }
         ThrowMsg(DBus::Exception, "Error while registering an object: "
-                                  << message);
+                 << message);
     }
 
     m_registeredObjects.insert(RegisteredObjects::value_type(
     }
 
     m_registeredObjects.insert(RegisteredObjects::value_type(
-                                       object->getPath(),
-                                       ObjectRegistration(regId, object)));
+                                   object->getPath(),
+                                   ObjectRegistration(regId, object)));
 }
 
 void Connection::unregisterObject(const std::string& objectPath)
 {
     auto it = m_registeredObjects.find(objectPath);
 }
 
 void Connection::unregisterObject(const std::string& objectPath)
 {
     auto it = m_registeredObjects.find(objectPath);
-    if (m_registeredObjects.end() == it)
-    {
+    if (m_registeredObjects.end() == it) {
         ThrowMsg(DBus::Exception, "Object not registered.");
     }
 
     gboolean result = g_dbus_connection_unregister_object(
         ThrowMsg(DBus::Exception, "Object not registered.");
     }
 
     gboolean result = g_dbus_connection_unregister_object(
-                              m_connection,
-                              it->second.registrationId);
-    if (FALSE == result)
-    {
+            m_connection,
+            it->second.registrationId);
+    if (FALSE == result) {
         ThrowMsg(DBus::Exception, "Unregistering object failed.");
     }
     m_registeredObjects.erase(it);
         ThrowMsg(DBus::Exception, "Unregistering object failed.");
     }
     m_registeredObjects.erase(it);
@@ -214,13 +201,12 @@ void Connection::unregisterObject(const std::string& objectPath)
 ObjectProxyPtr Connection::createObjectProxy(const std::string& serviceName,
                                              const std::string& objectPath)
 {
 ObjectProxyPtr Connection::createObjectProxy(const std::string& serviceName,
                                              const std::string& objectPath)
 {
-    if (g_dbus_connection_is_closed(m_connection))
-    {
+    if (g_dbus_connection_is_closed(m_connection)) {
         ThrowMsg(DBus::ConnectionClosedException, "Connection closed.");
     }
 
     return ObjectProxyPtr(
         ThrowMsg(DBus::ConnectionClosedException, "Connection closed.");
     }
 
     return ObjectProxyPtr(
-            new ObjectProxy(m_connection, serviceName, objectPath));
+               new ObjectProxy(m_connection, serviceName, objectPath));
 }
 
 void Connection::onServiceNameAcquired(GDBusConnection* /*connection*/,
 }
 
 void Connection::onServiceNameAcquired(GDBusConnection* /*connection*/,
@@ -234,8 +220,9 @@ void Connection::onServiceNameAcquired(GDBusConnection* /*connection*/,
     LogPedantic("Emitting service name acquired event: " << serviceName);
 
     ConnectionEvents::ServiceNameAcquiredEvent event(serviceName);
     LogPedantic("Emitting service name acquired event: " << serviceName);
 
     ConnectionEvents::ServiceNameAcquiredEvent event(serviceName);
-    self->DPL::Event::EventSupport<ConnectionEvents::ServiceNameAcquiredEvent>::
-            EmitEvent(event, DPL::Event::EmitMode::Queued);
+    self->DPL::Event::EventSupport<ConnectionEvents::ServiceNameAcquiredEvent>
+        ::
+        EmitEvent(event, DPL::Event::EmitMode::Queued);
 }
 
 void Connection::onServiceNameLost(GDBusConnection* /*connection*/,
 }
 
 void Connection::onServiceNameLost(GDBusConnection* /*connection*/,
@@ -250,7 +237,7 @@ void Connection::onServiceNameLost(GDBusConnection* /*connection*/,
 
     ConnectionEvents::ServiceNameLostEvent event(serviceName);
     self->DPL::Event::EventSupport<ConnectionEvents::ServiceNameLostEvent>::
 
     ConnectionEvents::ServiceNameLostEvent event(serviceName);
     self->DPL::Event::EventSupport<ConnectionEvents::ServiceNameLostEvent>::
-            EmitEvent(event, DPL::Event::EmitMode::Queued);
+        EmitEvent(event, DPL::Event::EmitMode::Queued);
 }
 
 void Connection::onConnectionClosed(GDBusConnection* /*connection*/,
 }
 
 void Connection::onConnectionClosed(GDBusConnection* /*connection*/,
@@ -262,32 +249,27 @@ void Connection::onConnectionClosed(GDBusConnection* /*connection*/,
 
     Connection* self = static_cast<Connection*>(data);
 
 
     Connection* self = static_cast<Connection*>(data);
 
-    if ((NULL == error) && (FALSE == peerVanished))
-    {
+    if ((NULL == error) && (FALSE == peerVanished)) {
         // Connection closed by this.
         // Connection closed by this.
-    }
-    else if (NULL != error)
-    {
+    } else if (NULL != error) {
         std::string message = error->message;
 
         g_error_free(error);
 
         std::string message = error->message;
 
         g_error_free(error);
 
-        if (TRUE == peerVanished)
-        {
+        if (TRUE == peerVanished) {
             // Connection closed by remote host.
             ConnectionEvents::ConnectionBrokenEvent event(message);
             // Connection closed by remote host.
             ConnectionEvents::ConnectionBrokenEvent event(message);
-            self->DPL::Event::EventSupport<ConnectionEvents::ConnectionBrokenEvent>::
-                    EmitEvent(event, DPL::Event::EmitMode::Queued);
-        }
-        else
-        {
+            self->DPL::Event::EventSupport<ConnectionEvents::
+                                               ConnectionBrokenEvent>::
+                EmitEvent(event, DPL::Event::EmitMode::Queued);
+        } else {
             // Invalid or malformed data on connection.
             ConnectionEvents::ConnectionInvalidEvent event(message);
             // Invalid or malformed data on connection.
             ConnectionEvents::ConnectionInvalidEvent event(message);
-            self->DPL::Event::EventSupport<ConnectionEvents::ConnectionInvalidEvent>::
-                    EmitEvent(event, DPL::Event::EmitMode::Queued);
+            self->DPL::Event::EventSupport<ConnectionEvents::
+                                               ConnectionInvalidEvent>::
+                EmitEvent(event, DPL::Event::EmitMode::Queued);
         }
     }
 }
         }
     }
 }
-
 }
 }
 }
 }
index ca1bbab..d83a22a 100644 (file)
  * @version 1.0
  * @brief
  */
  * @version 1.0
  * @brief
  */
-
+#include <stddef.h>
 #include <dpl/dbus/dispatcher.h>
 
 #include <dpl/dbus/dispatcher.h>
 
-namespace DPL
-{
-namespace DBus
-{
-
+namespace DPL {
+namespace DBus {
 Dispatcher::~Dispatcher() { }
 
 GVariant* Dispatcher::onPropertyGet(GDBusConnection* /*connection*/,
 Dispatcher::~Dispatcher() { }
 
 GVariant* Dispatcher::onPropertyGet(GDBusConnection* /*connection*/,
@@ -49,6 +46,5 @@ gboolean Dispatcher::onPropertySet(GDBusConnection* /*connection*/,
 {
     return false;
 }
 {
     return false;
 }
-
 }
 }
 }
 }
index 248ac6d..0df3a59 100644 (file)
@@ -19,6 +19,7 @@
  * @version 1.0
  * @brief
  */
  * @version 1.0
  * @brief
  */
+#include <stddef.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/exception.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/exception.h>
 
 namespace DPL {
 namespace DBus {
 
 namespace DPL {
 namespace DBus {
-
-const GDBusInterfaceVTable Interface::m_vTable =
-{
+const GDBusInterfaceVTable Interface::m_vTable = {
     Interface::onMethodCallFunc,
     Interface::onPropertyGetFunc,
     Interface::onPropertySetFunc,
     Interface::onMethodCallFunc,
     Interface::onPropertyGetFunc,
     Interface::onPropertySetFunc,
-    {0, 0, 0, 0, 0, 0, 0, 0}
+    { 0, 0, 0, 0, 0, 0, 0, 0 }
 };
 
 std::vector<InterfacePtr> Interface::fromXMLString(const std::string& xmlString)
 };
 
 std::vector<InterfacePtr> Interface::fromXMLString(const std::string& xmlString)
@@ -42,11 +41,9 @@ std::vector<InterfacePtr> Interface::fromXMLString(const std::string& xmlString)
 
     GDBusNodeInfo* nodeInfo = g_dbus_node_info_new_for_xml(xmlString.c_str(),
                                                            &error);
 
     GDBusNodeInfo* nodeInfo = g_dbus_node_info_new_for_xml(xmlString.c_str(),
                                                            &error);
-    if (NULL == nodeInfo)
-    {
+    if (NULL == nodeInfo) {
         std::string message;
         std::string message;
-        if (NULL != error)
-        {
+        if (NULL != error) {
             message = error->message;
             g_error_free(error);
         }
             message = error->message;
             g_error_free(error);
         }
@@ -57,8 +54,7 @@ std::vector<InterfacePtr> Interface::fromXMLString(const std::string& xmlString)
     std::vector<InterfacePtr> result;
 
     GDBusInterfaceInfo** interface = nodeInfo->interfaces;
     std::vector<InterfacePtr> result;
 
     GDBusInterfaceInfo** interface = nodeInfo->interfaces;
-    while (NULL != *interface)
-    {
+    while (NULL != *interface) {
         result.push_back(InterfacePtr(new Interface(*interface)));
         ++interface;
     }
         result.push_back(InterfacePtr(new Interface(*interface)));
         ++interface;
     }
@@ -68,8 +64,8 @@ std::vector<InterfacePtr> Interface::fromXMLString(const std::string& xmlString)
     return result;
 }
 
     return result;
 }
 
-Interface::Interface(GDBusInterfaceInfo* info)
-    m_info(info)
+Interface::Interface(GDBusInterfaceInfo* info) :
+    m_info(info)
 {
     g_dbus_interface_info_ref(m_info);
 }
 {
     g_dbus_interface_info_ref(m_info);
 }
@@ -108,10 +104,8 @@ void Interface::onMethodCallFunc(GDBusConnection *connection,
 
     // TODO Verify interface name.
 
 
     // TODO Verify interface name.
 
-    if (NULL != self->m_dispatcher)
-    {
-        try
-        {
+    if (NULL != self->m_dispatcher) {
+        try {
             self->m_dispatcher->onMethodCall(connection,
                                              sender,
                                              objectPath,
             self->m_dispatcher->onMethodCall(connection,
                                              sender,
                                              objectPath,
@@ -119,9 +113,7 @@ void Interface::onMethodCallFunc(GDBusConnection *connection,
                                              methodName,
                                              parameters,
                                              invocation);
                                              methodName,
                                              parameters,
                                              invocation);
-        }
-        catch (const DPL::Exception& /*ex*/)
-        {
+        } catch (const DPL::Exception& /*ex*/) {
             // TODO Support for errors.
         }
     }
             // TODO Support for errors.
         }
     }
@@ -140,10 +132,8 @@ GVariant* Interface::onPropertyGetFunc(GDBusConnection *connection,
 
     // TODO Verify interface name.
 
 
     // TODO Verify interface name.
 
-    if (NULL != self->m_dispatcher)
-    {
-        try
-        {
+    if (NULL != self->m_dispatcher) {
+        try {
             // TODO Check if NULL is returned, if so set error variable.
             return self->m_dispatcher->onPropertyGet(connection,
                                                      sender,
             // TODO Check if NULL is returned, if so set error variable.
             return self->m_dispatcher->onPropertyGet(connection,
                                                      sender,
@@ -151,9 +141,7 @@ GVariant* Interface::onPropertyGetFunc(GDBusConnection *connection,
                                                      interfaceName,
                                                      propertyName,
                                                      error);
                                                      interfaceName,
                                                      propertyName,
                                                      error);
-        }
-        catch (const DPL::Exception& /*ex*/)
-        {
+        } catch (const DPL::Exception& /*ex*/) {
             // TODO Support for errors.
         }
     }
             // TODO Support for errors.
         }
     }
@@ -177,10 +165,8 @@ gboolean Interface::onPropertySetFunc(GDBusConnection *connection,
 
     // TODO Verify interface name.
 
 
     // TODO Verify interface name.
 
-    if (NULL != self->m_dispatcher)
-    {
-        try
-        {
+    if (NULL != self->m_dispatcher) {
+        try {
             return self->m_dispatcher->onPropertySet(connection,
                                                      sender,
                                                      objectPath,
             return self->m_dispatcher->onPropertySet(connection,
                                                      sender,
                                                      objectPath,
@@ -188,9 +174,7 @@ gboolean Interface::onPropertySetFunc(GDBusConnection *connection,
                                                      propertyName,
                                                      value,
                                                      error);
                                                      propertyName,
                                                      value,
                                                      error);
-        }
-        catch (const DPL::Exception& /*ex*/)
-        {
+        } catch (const DPL::Exception& /*ex*/) {
             // TODO Support for errors.
         }
     }
             // TODO Support for errors.
         }
     }
@@ -199,6 +183,5 @@ gboolean Interface::onPropertySetFunc(GDBusConnection *connection,
 
     return false;
 }
 
     return false;
 }
-
 }
 }
 }
 }
index 1c46018..a66796d 100644 (file)
  * @version 1.0
  * @brief
  */
  * @version 1.0
  * @brief
  */
-
+#include <stddef.h>
 #include <dpl/dbus/object.h>
 
 namespace DPL {
 namespace DBus {
 #include <dpl/dbus/object.h>
 
 namespace DPL {
 namespace DBus {
-
 ObjectPtr Object::create(const std::string& path, const InterfacePtr& interface)
 {
     return ObjectPtr(new Object(path, interface));
 ObjectPtr Object::create(const std::string& path, const InterfacePtr& interface)
 {
     return ObjectPtr(new Object(path, interface));
@@ -40,11 +39,9 @@ InterfacePtr Object::getInterface() const
     return m_interface;
 }
 
     return m_interface;
 }
 
-Object::Object(const std::string& path, const InterfacePtr& interface)
-    : m_path(path),
-      m_interface(interface)
-{
-}
-
+Object::Object(const std::string& path, const InterfacePtr& interface) :
+    m_path(path),
+    m_interface(interface)
+{}
 }
 }
\ No newline at end of file
 }
 }
\ No newline at end of file
index 22275a1..9b15bb7 100644 (file)
  * @version 1.0
  * @brief
  */
  * @version 1.0
  * @brief
  */
-
+#include <stddef.h>
 #include <dpl/dbus/object_proxy.h>
 
 namespace DPL {
 namespace DBus {
 #include <dpl/dbus/object_proxy.h>
 
 namespace DPL {
 namespace DBus {
-
 ObjectProxy::ObjectProxy(GDBusConnection* connection,
                          const std::string& serviceName,
 ObjectProxy::ObjectProxy(GDBusConnection* connection,
                          const std::string& serviceName,
-                         const std::string& objectPath)
-    m_connection(connection),
-      m_serviceName(serviceName),
-      m_objectPath(objectPath)
+                         const std::string& objectPath) :
+    m_connection(connection),
+    m_serviceName(serviceName),
+    m_objectPath(objectPath)
 {
     g_object_ref(m_connection);
 }
 {
     g_object_ref(m_connection);
 }
@@ -39,6 +38,5 @@ ObjectProxy::~ObjectProxy()
 {
     g_object_unref(m_connection);
 }
 {
     g_object_unref(m_connection);
 }
-
 }
 }
\ No newline at end of file
 }
 }
\ No newline at end of file
index 08292f5..421090f 100644 (file)
  * @version 1.0
  * @brief
  */
  * @version 1.0
  * @brief
  */
-
+#include <stddef.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <dpl/dbus/server.h>
 
 namespace DPL {
 namespace DBus {
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <dpl/dbus/server.h>
 
 namespace DPL {
 namespace DBus {
-
 ServerPtr Server::create(const std::string& address)
 {
     GError* error = NULL;
 
     int flags = G_DBUS_SERVER_FLAGS_NONE |
 ServerPtr Server::create(const std::string& address)
 {
     GError* error = NULL;
 
     int flags = G_DBUS_SERVER_FLAGS_NONE |
-                G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS;
+        G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS;
 
     gchar* serverId = g_dbus_generate_guid();
 
     GDBusServer* server = g_dbus_server_new_sync(
 
     gchar* serverId = g_dbus_generate_guid();
 
     GDBusServer* server = g_dbus_server_new_sync(
-                                  address.c_str(),
-                                  static_cast<GDBusServerFlags>(flags),
-                                  serverId,
-                                  NULL,
-                                  NULL,
-                                  &error);
+            address.c_str(),
+            static_cast<GDBusServerFlags>(flags),
+            serverId,
+            NULL,
+            NULL,
+            &error);
     g_free(serverId);
 
     g_free(serverId);
 
-    if (NULL == server)
-    {
+    if (NULL == server) {
         std::string message;
         std::string message;
-        if (NULL != error)
-        {
+        if (NULL != error) {
             message = error->message;
             g_error_free(error);
         }
             message = error->message;
             g_error_free(error);
         }
@@ -60,15 +57,13 @@ ServerPtr Server::create(const std::string& address)
     return ServerPtr(new Server(server));
 }
 
     return ServerPtr(new Server(server));
 }
 
-Server::Server(GDBusServer* server)
-    : m_server(server)
-{
-}
+Server::Server(GDBusServer* server) :
+    m_server(server)
+{}
 
 Server::~Server()
 {
 
 Server::~Server()
 {
-    if (g_dbus_server_is_active(m_server))
-    {
+    if (g_dbus_server_is_active(m_server)) {
         stop();
     }
     g_object_unref(m_server);
         stop();
     }
     g_object_unref(m_server);
@@ -105,16 +100,15 @@ gboolean Server::onNewConnection(GDBusServer* /*server*/,
     Server* self = static_cast<Server*>(data);
 
     ServerEvents::NewConnectionEvent event(
     Server* self = static_cast<Server*>(data);
 
     ServerEvents::NewConnectionEvent event(
-            ConnectionPtr(new Connection(connection)));
+        ConnectionPtr(new Connection(connection)));
 
     LogInfo("Emitting new connection event");
     // TODO Blocking to allow object registration before any DBus messages are
     //      processed.
     self->DPL::Event::EventSupport<ServerEvents::NewConnectionEvent>::
 
     LogInfo("Emitting new connection event");
     // TODO Blocking to allow object registration before any DBus messages are
     //      processed.
     self->DPL::Event::EventSupport<ServerEvents::NewConnectionEvent>::
-            EmitEvent(event, DPL::Event::EmitMode::Blocking);
+        EmitEvent(event, DPL::Event::EmitMode::Blocking);
 
     return TRUE;
 }
 
     return TRUE;
 }
-
 }
 }
-}
\ No newline at end of file
+}
diff --git a/modules/encryption/config.cmake b/modules/encryption/config.cmake
new file mode 100644 (file)
index 0000000..5188ecb
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        config.cmake
+# @author      Soyoung Kim(sy037.kim@samsung.com)
+# @version     1.0
+# @brief
+#
+
+SET(DPL_ENCRYPTION_SOURCES
+    ${PROJECT_SOURCE_DIR}/modules/encryption/src/resource_encryption.cpp
+    ${PROJECT_SOURCE_DIR}/modules/encryption/src/resource_decryption.cpp
+    PARENT_SCOPE
+)
+
+
+SET(DPL_ENCRYPTION_HEADERS
+    ${PROJECT_SOURCE_DIR}/modules/encryption/include/dpl/encryption/resource_encryption.h
+    ${PROJECT_SOURCE_DIR}/modules/encryption/include/dpl/encryption/resource_decryption.h
+    PARENT_SCOPE
+)
+
+SET(DPL_ENCRYPTION_INCLUDE_DIR
+    ${PROJECT_SOURCE_DIR}/modules/encryption/include
+    PARENT_SCOPE
+)
diff --git a/modules/encryption/include/dpl/encryption/resource_decryption.h b/modules/encryption/include/dpl/encryption/resource_decryption.h
new file mode 100644 (file)
index 0000000..a6d7af0
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    resource_decryption.h
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Header file for resource decryption
+ */
+#ifndef RESOURCE_DECRYPTION_H
+#define RESOURCE_DECRYPTION_H
+
+#include <string.h>
+#include <string>
+#include <openssl/aes.h>
+#include <openssl/sha.h>
+#include <dpl/exception.h>
+
+extern char** calculate(char*pappId, int idLen, int keyLen);
+
+namespace WRTDecryptor {
+class ResourceDecryptor
+{
+  public:
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, GetDecKeyFailed)
+        DECLARE_EXCEPTION_TYPE(Base, EncryptionFailed)
+    };
+
+    ResourceDecryptor();
+    ResourceDecryptor(std::string userKey);
+    virtual ~ResourceDecryptor();
+
+    void SetDecryptionKey(std::string userKey);
+    void GetDecryptedChunk(unsigned char* inBuf,
+                           unsigned char* decBuf,
+                           size_t chunkSize);
+
+  private:
+    AES_KEY* GetDecryptionKey();
+    AES_KEY m_decKey;
+};
+} //namespace WRTDecryptor
+
+#endif /* RESOURCE_DECRYPTION_H */
diff --git a/modules/encryption/include/dpl/encryption/resource_encryption.h b/modules/encryption/include/dpl/encryption/resource_encryption.h
new file mode 100644 (file)
index 0000000..f2e4988
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    resource_encryption.h
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Header file for resource encryption
+ */
+#ifndef RESOURCE_ENCRYPTION_H
+#define RESOURCE_ENCRYPTION_H
+
+#include <string.h>
+#include <string>
+#include <openssl/aes.h>
+#include <openssl/sha.h>
+#include <dpl/exception.h>
+
+extern char** calculate(char*pappId, int idLen, int keyLen);
+
+namespace WRTEncryptor {
+class ResourceEncryptor
+{
+  public:
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateEncKeyFailed)
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDecKeyFailed)
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateEncKeyFileFailed)
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDecKeyFileFailed)
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, EncryptionFailed)
+    };
+
+    ResourceEncryptor();
+    virtual ~ResourceEncryptor();
+
+    int GetBlockSize(int inSize);
+    void CreateEncryptionKey(std::string userKey);
+    void EncryptChunk(unsigned char* inputBuf, unsigned char* encBuf, size_t
+                      chunkSize);
+
+  private:
+    AES_KEY GetEncryptionkey();
+    AES_KEY m_encKey;
+};
+} //namespace WRTEncryptor
+
+#endif /* RESOURCE_DECRYPTION_H */
diff --git a/modules/encryption/src/resource_decryption.cpp b/modules/encryption/src/resource_decryption.cpp
new file mode 100644 (file)
index 0000000..2ec612e
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    resource_decryption.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for resource decryption
+ */
+#include <stddef.h>
+#include <dpl/encryption/resource_decryption.h>
+
+#include <fcntl.h>
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/exception.h>
+
+namespace {
+#define BITS_SIZE 128
+#define KEY_SIZE 16
+}
+namespace WRTDecryptor {
+ResourceDecryptor::ResourceDecryptor()
+{
+    LogDebug("Started Decryption");
+}
+
+ResourceDecryptor::ResourceDecryptor(std::string userKey)
+{
+    LogDebug("Finished Decryption");
+    SetDecryptionKey(userKey);
+}
+
+ResourceDecryptor::~ResourceDecryptor()
+{}
+
+void ResourceDecryptor::SetDecryptionKey(std::string userKey)
+{
+    if (userKey.empty()) {
+        return;
+    }
+
+    char **duk = calculate(const_cast<char*>(userKey.c_str()),
+                           userKey.size(), KEY_SIZE);
+    unsigned char *key = reinterpret_cast<unsigned char*>(*duk);
+
+    if (0 > AES_set_decrypt_key(key, BITS_SIZE, &m_decKey)) {
+        ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
+                 "Failed to create decryption key");
+    }
+}
+
+AES_KEY* ResourceDecryptor::GetDecryptionKey()
+{
+    return &m_decKey;
+}
+
+void ResourceDecryptor::GetDecryptedChunk(unsigned char*
+                                          inBuf,
+                                          unsigned char* decBuf,
+                                          size_t inBufSize)
+{
+    Assert(decBuf);
+    if (decBuf == NULL) {
+        ThrowMsg(ResourceDecryptor::Exception::EncryptionFailed,
+                 "Failed to Get Decryption Chunk");
+    }
+    unsigned char ivec[16] = { 0, };
+
+    AES_cbc_encrypt(inBuf, decBuf, inBufSize, &m_decKey, ivec, AES_DECRYPT);
+    LogDebug("Success decryption");
+}
+} //namespace WRTDecryptor
diff --git a/modules/encryption/src/resource_encryption.cpp b/modules/encryption/src/resource_encryption.cpp
new file mode 100644 (file)
index 0000000..96e90b7
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    resource_encryption.cpp
+ * @author  Soyoung Kim (sy037.kim@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for resource encryption
+ */
+#include <stddef.h>
+#include <dpl/encryption/resource_encryption.h>
+
+#include <fcntl.h>
+#include <dpl/log/log.h>
+
+namespace {
+#define BITS_SIZE 128
+#define KEY_SIZE 16
+}
+namespace WRTEncryptor {
+ResourceEncryptor::ResourceEncryptor()
+{
+    LogDebug("Started Encrytion");
+}
+
+ResourceEncryptor::~ResourceEncryptor()
+{
+    LogDebug("Finished Encrytion");
+}
+
+int ResourceEncryptor::GetBlockSize(int inSize)
+{
+    if ((inSize % AES_BLOCK_SIZE) != 0) {
+        return (( inSize / AES_BLOCK_SIZE) + 1) * AES_BLOCK_SIZE;
+    }
+    return inSize;
+}
+
+void ResourceEncryptor::CreateEncryptionKey(std::string userKey)
+{
+    if (userKey.empty()) {
+        return;
+    }
+
+    char **duk = calculate(const_cast<char*>(userKey.c_str()),
+                           userKey.size(), KEY_SIZE);
+    unsigned char *key = reinterpret_cast<unsigned char*>(*duk);
+
+    if (0 > AES_set_encrypt_key(key, BITS_SIZE, &m_encKey)) {
+        ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFailed,
+                 "Failed to create encryption key");
+    }
+    LogDebug("Success to create ecryption and decryption key");
+}
+
+AES_KEY ResourceEncryptor::GetEncryptionkey()
+{
+    return m_encKey;
+}
+
+void ResourceEncryptor::EncryptChunk(unsigned char*
+                                     inputBuf,
+                                     unsigned char* encBuf,
+                                     size_t chunkSize)
+{
+    Assert(inputBuf);
+    Assert(encBuf);
+
+    unsigned char ivec[16] = { 0, };
+
+    AES_cbc_encrypt(inputBuf, encBuf, chunkSize, &m_encKey, ivec, AES_ENCRYPT);
+}
+} //namespace ResourceEnc
index 07831f0..313b6a8 100644 (file)
@@ -23,15 +23,12 @@ SET(DPL_EVENT_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/event/src/abstract_event_call.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/abstract_event_dispatcher.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/controller.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/abstract_event_call.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/abstract_event_dispatcher.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/controller.cpp
-    ${PROJECT_SOURCE_DIR}/modules/event/src/event_delivery.cpp
-    ${PROJECT_SOURCE_DIR}/modules/event/src/event_delivery_detail.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/event_listener.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/event_support.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/generic_event_call.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/main_event_dispatcher.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/thread_event_dispatcher.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/inter_context_delegate.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/event_listener.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/event_support.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/generic_event_call.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/main_event_dispatcher.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/thread_event_dispatcher.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/inter_context_delegate.cpp
-    ${PROJECT_SOURCE_DIR}/modules/event/src/nested_loop.cpp
     ${PROJECT_SOURCE_DIR}/modules/event/src/model.cpp
     PARENT_SCOPE
 )
     ${PROJECT_SOURCE_DIR}/modules/event/src/model.cpp
     PARENT_SCOPE
 )
@@ -40,16 +37,11 @@ SET(DPL_EVENT_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/abstract_event_call.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/abstract_event_dispatcher.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/controller.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/abstract_event_call.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/abstract_event_dispatcher.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/controller.h
-    ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_delivery_detail.h
-    ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_delivery.h
-    ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_delivery_injector.h
-    ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_delivery_messages.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_listener.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_support.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/generic_event_call.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/main_event_dispatcher.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/thread_event_dispatcher.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_listener.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/event_support.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/generic_event_call.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/main_event_dispatcher.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/thread_event_dispatcher.h
-    ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/nested_loop.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/inter_context_delegate.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/model.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/property.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/inter_context_delegate.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/model.h
     ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/property.h
index e199897..db1bea4 100644 (file)
 
 #include <dpl/noncopyable.h>
 
 
 #include <dpl/noncopyable.h>
 
-namespace DPL
+namespace DPL {
+namespace Event {
+class AbstractEventCall :
+    private Noncopyable
 {
 {
-namespace Event
-{
-
-
-class AbstractEventCall
-    : private Noncopyable
-{
-public:
+  public:
     /**
      * Constructor
      */
     /**
      * Constructor
      */
@@ -49,7 +45,6 @@ public:
      */
     virtual void Call() = 0;
 };
      */
     virtual void Call() = 0;
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index ddd76ad..f5caa56 100644 (file)
@@ -17,7 +17,8 @@
  * @file        abstract_event_dispatcher.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        abstract_event_dispatcher.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of abstract event dispatcher
+ * @brief       This file is the implementation file of abstract event
+ * dispatcher
  */
 #ifndef DPL_ABSTRACT_EVENT_DISPATCHER_H
 #define DPL_ABSTRACT_EVENT_DISPATCHER_H
  */
 #ifndef DPL_ABSTRACT_EVENT_DISPATCHER_H
 #define DPL_ABSTRACT_EVENT_DISPATCHER_H
 #include <dpl/event/abstract_event_call.h>
 #include <dpl/noncopyable.h>
 
 #include <dpl/event/abstract_event_call.h>
 #include <dpl/noncopyable.h>
 
-namespace DPL
+namespace DPL {
+namespace Event {
+class AbstractEventDispatcher :
+    private Noncopyable
 {
 {
-namespace Event
-{
-
-class AbstractEventDispatcher
-    : private Noncopyable
-{
-public:
+  public:
     /**
      * Constructor
      */
     /**
      * Constructor
      */
@@ -59,9 +57,9 @@ public:
      * @param[in] dueTime Due time for timed event in seconds
      * @return none
      */
      * @param[in] dueTime Due time for timed event in seconds
      * @return none
      */
-    virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall, double dueTime) = 0;
+    virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall,
+                                   double dueTime) = 0;
 };
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 1c5c75c..1b14632 100644 (file)
 #include <dpl/thread.h>
 #include <dpl/assert.h>
 
 #include <dpl/thread.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 template<typename EventType>
 template<typename EventType>
-class ControllerEventHandler
-    public EventListener<EventType>,
-      private EventSupport<EventType>
+class ControllerEventHandler :
+    public EventListener<EventType>,
+    private EventSupport<EventType>
 {
 {
-private:
+  private:
     bool m_touched;
 
     bool m_touched;
 
-public:
-    ControllerEventHandler()
-        m_touched(false)
+  public:
+    ControllerEventHandler() :
+        m_touched(false)
     {
         EventSupport<EventType>::AddListener(this);
     }
     {
         EventSupport<EventType>::AddListener(this);
     }
@@ -55,19 +52,25 @@ public:
 
     void PostEvent(const EventType &event)
     {
 
     void PostEvent(const EventType &event)
     {
-        Assert(m_touched && "Default context not inherited. Call Touch() to inherit one.");
+        Assert(
+            m_touched &&
+            "Default context not inherited. Call Touch() to inherit one.");
         EventSupport<EventType>::EmitEvent(event, EmitMode::Queued);
     }
 
     void PostTimedEvent(const EventType &event, double dueTime)
     {
         EventSupport<EventType>::EmitEvent(event, EmitMode::Queued);
     }
 
     void PostTimedEvent(const EventType &event, double dueTime)
     {
-        Assert(m_touched && "Default context not inherited. Call Touch() to inherit one.");
+        Assert(
+            m_touched &&
+            "Default context not inherited. Call Touch() to inherit one.");
         EventSupport<EventType>::EmitEvent(event, EmitMode::Deffered, dueTime);
     }
 
     void PostSyncEvent(const EventType &event)
     {
         EventSupport<EventType>::EmitEvent(event, EmitMode::Deffered, dueTime);
     }
 
     void PostSyncEvent(const EventType &event)
     {
-        Assert(m_touched && "Default context not inherited. Call Touch() to inherit one.");
+        Assert(
+            m_touched &&
+            "Default context not inherited. Call Touch() to inherit one.");
 
         // Check calling context
         EventSupport<EventType>::EmitEvent(event, EmitMode::Blocking);
 
         // Check calling context
         EventSupport<EventType>::EmitEvent(event, EmitMode::Blocking);
@@ -75,33 +78,36 @@ public:
 
     void SwitchToThread(Thread *thread)
     {
 
     void SwitchToThread(Thread *thread)
     {
-        Assert(m_touched && "Default context not inherited. Call Touch() to inherit one.");
+        Assert(
+            m_touched &&
+            "Default context not inherited. Call Touch() to inherit one.");
         EventSupport<EventType>::SwitchListenerToThread(this, thread);
     }
 
     void Touch()
     {
         m_touched = true;
         EventSupport<EventType>::SwitchListenerToThread(this, thread);
     }
 
     void Touch()
     {
         m_touched = true;
-        EventSupport<EventType>::SwitchListenerToThread(this, Thread::GetCurrentThread());
+        EventSupport<EventType>::SwitchListenerToThread(
+            this,
+            Thread::
+                GetCurrentThread());
     }
 };
 
 template<typename EventTypeList>
     }
 };
 
 template<typename EventTypeList>
-class Controller
-    public Controller<typename EventTypeList::Tail>,
-      public ControllerEventHandler<typename EventTypeList::Head>
+class Controller :
+    public Controller<typename EventTypeList::Tail>,
+    public ControllerEventHandler<typename EventTypeList::Head>
 {
 {
-public:
+  public:
     typedef typename EventTypeList::Head EventType;
 
     typedef typename EventTypeList::Head EventType;
 
-public:
+  public:
     Controller()
     Controller()
-    {
-    }
+    {}
 
     virtual ~Controller()
 
     virtual ~Controller()
-    {
-    }
+    {}
 
     virtual void SwitchToThread(Thread *thread)
     {
 
     virtual void SwitchToThread(Thread *thread)
     {
@@ -119,14 +125,12 @@ public:
 template<>
 class Controller<TypeListDecl<>::Type>
 {
 template<>
 class Controller<TypeListDecl<>::Type>
 {
-public:
+  public:
     Controller()
     Controller()
-    {
-    }
+    {}
 
     virtual ~Controller()
 
     virtual ~Controller()
-    {
-    }
+    {}
 
     virtual void SwitchToThread(Thread *thread)
     {
 
     virtual void SwitchToThread(Thread *thread)
     {
@@ -134,16 +138,23 @@ public:
     }
 
     virtual void Touch()
     }
 
     virtual void Touch()
-    {
-    }
+    {}
 };
 };
-
 }
 } // namespace DPL
 
 // Utilities
 }
 } // namespace DPL
 
 // Utilities
-#define CONTROLLER_POST_EVENT(Name, EventArg) Name##Singleton::Instance().DPL::Event::ControllerEventHandler<__typeof__ EventArg>::PostEvent(EventArg)
-#define CONTROLLER_POST_TIMED_EVENT(Name, EventArg, DueTime) Name##Singleton::Instance().DPL::Event::ControllerEventHandler<__typeof__ EventArg>::PostTimedEvent(EventArg, DueTime)
-#define CONTROLLER_POST_SYNC_EVENT(Name, EventArg) Name##Singleton::Instance().DPL::Event::ControllerEventHandler<__typeof__ EventArg>::PostSyncEvent(EventArg)
+#define CONTROLLER_POST_EVENT(Name, \
+                              EventArg) Name##Singleton::Instance().DPL::Event \
+        ::ControllerEventHandler< \
+        __typeof__ EventArg>::PostEvent(EventArg)
+#define CONTROLLER_POST_TIMED_EVENT(Name, EventArg, \
+                                    DueTime) Name##Singleton::Instance().DPL:: \
+        Event::ControllerEventHandler< \
+        __typeof__ EventArg>::PostTimedEvent(EventArg, DueTime)
+#define CONTROLLER_POST_SYNC_EVENT(Name, \
+                                   EventArg) Name##Singleton::Instance().DPL:: \
+        Event::ControllerEventHandler< \
+        __typeof__ EventArg>::PostSyncEvent(EventArg)
 
 #endif // DPL_CONTROLLER_H
 
 #endif // DPL_CONTROLLER_H
index bc7ecbf..27fdbec 100644 (file)
 
 #include <dpl/noncopyable.h>
 
 
 #include <dpl/noncopyable.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 template<typename EventType>
 template<typename EventType>
-class EventListener
-    private Noncopyable
+class EventListener :
+    private Noncopyable
 {
 {
-public:
+  public:
     EventListener()
     EventListener()
-    {
-    }
+    {}
 
     virtual ~EventListener()
 
     virtual ~EventListener()
-    {
-    }
+    {}
 
     virtual void OnEventReceived(const EventType &event) = 0;
 };
 
     virtual void OnEventReceived(const EventType &event) = 0;
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 3aaab81..f7a8d8f 100644 (file)
@@ -29,7 +29,7 @@
 #include <dpl/event/generic_event_call.h>
 #include <dpl/waitable_event.h>
 #include <dpl/fast_delegate.h>
 #include <dpl/event/generic_event_call.h>
 #include <dpl/waitable_event.h>
 #include <dpl/fast_delegate.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
 #include <dpl/exception.h>
 #include <dpl/thread.h>
 #include <dpl/assert.h>
 #include <dpl/exception.h>
 #include <dpl/thread.h>
 #include <dpl/assert.h>
 #include <map>
 #include <list>
 
 #include <map>
 #include <list>
 
-namespace DPL
-{
-namespace Event
-{
-namespace EmitMode
-{
+namespace DPL {
+namespace Event {
+namespace EmitMode {
 enum Type
 {
     Auto,     ///< If calling thread is the same as receiver's use
 enum Type
 {
     Auto,     ///< If calling thread is the same as receiver's use
@@ -62,10 +59,10 @@ enum Type
 } // namespace EmitMode
 
 template<typename EventType>
 } // namespace EmitMode
 
 template<typename EventType>
-class EventSupport
-    private Noncopyable
+class EventSupport :
+    private Noncopyable
 {
 {
-public:
+  public:
     typedef EventSupport<EventType> EventSupportType;
 
     typedef EventListener<EventType> EventListenerType;
     typedef EventSupport<EventType> EventSupportType;
 
     typedef EventListener<EventType> EventListenerType;
@@ -74,10 +71,10 @@ public:
     class EventSupportData; // Forward declaration
     typedef EventSupportData *EventSupportDataPtr;
 
     class EventSupportData; // Forward declaration
     typedef EventSupportData *EventSupportDataPtr;
 
-private:
+  private:
     typedef typename GenericEventCall<EventType, EventSupportDataPtr>::
         template Rebind<EventType, EventSupportDataPtr>::
     typedef typename GenericEventCall<EventType, EventSupportDataPtr>::
         template Rebind<EventType, EventSupportDataPtr>::
-            Other GenericEventCallType;
+        Other GenericEventCallType;
 
     // Event listener list
     typedef std::map<EventListenerType *, Thread *> EventListenerList;
 
     // Event listener list
     typedef std::map<EventListenerType *, Thread *> EventListenerList;
@@ -103,10 +100,10 @@ private:
     // Events list mutex
     Mutex m_eventListMutex;
 
     // Events list mutex
     Mutex m_eventListMutex;
 
-public:
+  public:
     class EventSupportData
     {
     class EventSupportData
     {
-    private:
+      private:
         typedef void (EventSupportType::*ReceiveAbstractEventCallMethod)(
             const EventType &event,
             EventListenerType *eventListener,
         typedef void (EventSupportType::*ReceiveAbstractEventCallMethod)(
             const EventType &event,
             EventListenerType *eventListener,
@@ -123,22 +120,20 @@ public:
 
         Mutex m_dataMutex;
 
 
         Mutex m_dataMutex;
 
-    public:
+      public:
         EventSupportData(EventSupportType *support,
                          ReceiveAbstractEventCallMethod method,
         EventSupportData(EventSupportType *support,
                          ReceiveAbstractEventCallMethod method,
-                         WaitableEvent *synchronization)
-            : m_eventSupport(support),
-              m_method(method),
-              m_synchronization(synchronization)
-        {
-        }
+                         WaitableEvent *synchronization) :
+            m_eventSupport(support),
+            m_method(method),
+            m_synchronization(synchronization)
+        {}
 
         ~EventSupportData()
         {
             Mutex::ScopedLock lock(&m_dataMutex);
 
 
         ~EventSupportData()
         {
             Mutex::ScopedLock lock(&m_dataMutex);
 
-            if (!m_eventSupport)
-            {
+            if (!m_eventSupport) {
                 LogPedantic("EventSupport for this call does not exist");
                 return;
             }
                 LogPedantic("EventSupport for this call does not exist");
                 return;
             }
@@ -160,15 +155,12 @@ public:
             {
                 Mutex::ScopedLock lock(&m_dataMutex);
 
             {
                 Mutex::ScopedLock lock(&m_dataMutex);
 
-                if (m_eventSupport != NULL)
-                {
+                if (m_eventSupport != NULL) {
                     (*m_eventSupport.*m_method)(event,
                                                 listener,
                                                 delegate,
                                                 m_synchronization);
                     (*m_eventSupport.*m_method)(event,
                                                 listener,
                                                 delegate,
                                                 m_synchronization);
-                }
-                else
-                {
+                } else {
                     LogPedantic("EventSupport for this call does not "
                                 "exist anymore. Ignored.");
                 }
                     LogPedantic("EventSupport for this call does not "
                                 "exist anymore. Ignored.");
                 }
@@ -190,7 +182,7 @@ public:
         }
     };
 
         }
     };
 
-private:
+  private:
     GenericEventCallType *RegisterEventCall(const EventType &event,
                                             EventListenerType *eventListener,
                                             DelegateType delegate,
     GenericEventCallType *RegisterEventCall(const EventType &event,
                                             EventListenerType *eventListener,
                                             DelegateType delegate,
@@ -241,7 +233,7 @@ private:
         }
         UNHANDLED_EXCEPTION_HANDLER_END
 
         }
         UNHANDLED_EXCEPTION_HANDLER_END
 
-        --m_guardedCallInProgress;
+        -- m_guardedCallInProgress;
 
         LogPedantic("Guarded event listener finished");
     }
 
         LogPedantic("Guarded event listener finished");
     }
@@ -260,7 +252,7 @@ private:
         }
         UNHANDLED_EXCEPTION_HANDLER_END
 
         }
         UNHANDLED_EXCEPTION_HANDLER_END
 
-        --m_guardedCallInProgress;
+        -- m_guardedCallInProgress;
 
         LogPedantic("Guarded delegate call finished");
     }
 
         LogPedantic("Guarded delegate call finished");
     }
@@ -275,44 +267,41 @@ private:
         Thread *targetThread;
 
         // Listener might have been removed, ensure that it still exits
         Thread *targetThread;
 
         // Listener might have been removed, ensure that it still exits
-        if (eventListener != NULL)
-        {
+        if (eventListener != NULL) {
             Mutex::ScopedLock lock(&m_listenerDelegateMutex);
 
             typename EventListenerList::iterator iterator =
                 m_eventListenerList.find(eventListener);
 
             Mutex::ScopedLock lock(&m_listenerDelegateMutex);
 
             typename EventListenerList::iterator iterator =
                 m_eventListenerList.find(eventListener);
 
-            if (iterator == m_eventListenerList.end())
-            {
+            if (iterator == m_eventListenerList.end()) {
                 LogPedantic("Abstract event call listener disappeared."
                             "Event ignored.");
 
                 // Even though, synchronize caller if needed
                 LogPedantic("Abstract event call listener disappeared."
                             "Event ignored.");
 
                 // Even though, synchronize caller if needed
-                if (synchronization != NULL)
+                if (synchronization != NULL) {
                     synchronization->Signal();
                     synchronization->Signal();
+                }
 
                 return;
             }
 
             // Get target thread id
             targetThread = iterator->second;
 
                 return;
             }
 
             // Get target thread id
             targetThread = iterator->second;
-        }
-        else
-        {
+        } else {
             // Delegate might have been removed, ensure that it still exits
             Mutex::ScopedLock lock(&m_listenerDelegateMutex);
 
             typename DelegateList::iterator iterator =
                 m_delegateList.find(delegate);
 
             // Delegate might have been removed, ensure that it still exits
             Mutex::ScopedLock lock(&m_listenerDelegateMutex);
 
             typename DelegateList::iterator iterator =
                 m_delegateList.find(delegate);
 
-            if (iterator == m_delegateList.end())
-            {
+            if (iterator == m_delegateList.end()) {
                 LogPedantic("Abstract event call delegate disappeared."
                             "Event ignored.");
 
                 // Even though, synchronize caller if needed
                 LogPedantic("Abstract event call delegate disappeared."
                             "Event ignored.");
 
                 // Even though, synchronize caller if needed
-                if (synchronization != NULL)
+                if (synchronization != NULL) {
                     synchronization->Signal();
                     synchronization->Signal();
+                }
 
                 return;
             }
 
                 return;
             }
@@ -322,22 +311,19 @@ private:
         }
 
         // Ensure that we are now in proper thread now
         }
 
         // Ensure that we are now in proper thread now
-        if (targetThread != Thread::GetCurrentThread())
-        {
+        if (targetThread != Thread::GetCurrentThread()) {
             LogPedantic("Detected event dispatching ping-pong scenario");
 
             // Retry if it was not synchronized
             LogPedantic("Detected event dispatching ping-pong scenario");
 
             // Retry if it was not synchronized
-            if (synchronization == NULL)
-            {
+            if (synchronization == NULL) {
                 // Cheat with event delivery
                 EmitEvent(event, EmitMode::Queued);
 
                 LogPedantic("Ping-Pong: Resent as queued event");
                 // Cheat with event delivery
                 EmitEvent(event, EmitMode::Queued);
 
                 LogPedantic("Ping-Pong: Resent as queued event");
-            }
-            else
-            {
+            } else {
                 // There is a problem
                 // There is a problem
-                // Developer did something nasty, and we will not clean up his mess
+                // Developer did something nasty, and we will not clean up his
+                // mess
                 synchronization->Signal();
 
                 LogPedantic("### Ping-Pong: Failed to deliver synchronized"
                 synchronization->Signal();
 
                 LogPedantic("### Ping-Pong: Failed to deliver synchronized"
@@ -348,46 +334,47 @@ private:
         }
 
         // Guard listener code for exceptions
         }
 
         // Guard listener code for exceptions
-        if (eventListener != NULL)
+        if (eventListener != NULL) {
             GuardedEventCall(event, eventListener);
             GuardedEventCall(event, eventListener);
-        else
+        } else {
             GuardedEventCall(event, delegate);
             GuardedEventCall(event, delegate);
+        }
 
         // Release caller if synchronizing
 
         // Release caller if synchronizing
-        if (synchronization != NULL)
+        if (synchronization != NULL) {
             synchronization->Signal();
             synchronization->Signal();
+        }
     }
 
     }
 
-protected:
+  protected:
     void EmitEvent(const EventType &event,
                    EmitMode::Type mode = EmitMode::Queued,
                    double dueTime = 0.0)
     {
         // Emit event, and retrieve later in current context to dispatch
     void EmitEvent(const EventType &event,
                    EmitMode::Type mode = EmitMode::Queued,
                    double dueTime = 0.0)
     {
         // Emit event, and retrieve later in current context to dispatch
-        ScopedPtr<Mutex::ScopedLock> lock(
+        std::unique_ptr<Mutex::ScopedLock> lock(
             new Mutex::ScopedLock(&m_listenerDelegateMutex));
 
         // Show some info
             new Mutex::ScopedLock(&m_listenerDelegateMutex));
 
         // Show some info
-        switch (mode)
-        {
-            case EmitMode::Auto:
-                LogPedantic("Emitting AUTO event...");
-                break;
+        switch (mode) {
+        case EmitMode::Auto:
+            LogPedantic("Emitting AUTO event...");
+            break;
 
 
-            case EmitMode::Queued:
-                LogPedantic("Emitting QUEUED event...");
-                break;
+        case EmitMode::Queued:
+            LogPedantic("Emitting QUEUED event...");
+            break;
 
 
-            case EmitMode::Blocking:
-                LogPedantic("Emitting BLOCKING event...");
-                break;
+        case EmitMode::Blocking:
+            LogPedantic("Emitting BLOCKING event...");
+            break;
 
 
-            case EmitMode::Deffered:
-                LogPedantic("Emitting DEFFERED event...");
-                break;
+        case EmitMode::Deffered:
+            LogPedantic("Emitting DEFFERED event...");
+            break;
 
 
-            default:
-                break;
+        default:
+            break;
         }
 
         // In some configurations there is a barrier
         }
 
         // In some configurations there is a barrier
@@ -399,14 +386,11 @@ protected:
             // Switch to proper dispatcher and emit event
             AbstractEventDispatcher *dispatcher = NULL;
 
             // Switch to proper dispatcher and emit event
             AbstractEventDispatcher *dispatcher = NULL;
 
-            if (iterator->second == NULL)
-            {
+            if (iterator->second == NULL) {
                 // Send to main thread
                 LogPedantic("Sending event to main dispatcher");
                 dispatcher = &GetMainEventDispatcherInstance();
                 // Send to main thread
                 LogPedantic("Sending event to main dispatcher");
                 dispatcher = &GetMainEventDispatcherInstance();
-            }
-            else
-            {
+            } else {
                 // Setup thread dispatcher, and send to proper thread
                 LogPedantic("Sending event to thread dispatcher");
                 m_threadEventDispatcher.SetThread(iterator->second);
                 // Setup thread dispatcher, and send to proper thread
                 LogPedantic("Sending event to thread dispatcher");
                 m_threadEventDispatcher.SetThread(iterator->second);
@@ -417,66 +401,59 @@ protected:
             WaitableEvent *synchronization;
 
             // TODO: Pool synchronization objects
             WaitableEvent *synchronization;
 
             // TODO: Pool synchronization objects
-            switch (mode)
-            {
-                case EmitMode::Auto:
-                    // Check thread
-                    if (iterator->second == Thread::GetCurrentThread())
-                    {
-                        // Guard listener code for exceptions
-                        GuardedEventCall(event, iterator->first);
-                    }
-                    else
-                    {
-                        // Handle non-synchronized event
-                        dispatcher->AddEventCall(
-                            RegisterEventCall(event, iterator->first,
-                                              DelegateType(), NULL));
-                    }
-                    break;
-
-                case EmitMode::Queued:
+            switch (mode) {
+            case EmitMode::Auto:
+                // Check thread
+                if (iterator->second == Thread::GetCurrentThread()) {
+                    // Guard listener code for exceptions
+                    GuardedEventCall(event, iterator->first);
+                } else {
                     // Handle non-synchronized event
                     dispatcher->AddEventCall(
                         RegisterEventCall(event, iterator->first,
                                           DelegateType(), NULL));
                     // Handle non-synchronized event
                     dispatcher->AddEventCall(
                         RegisterEventCall(event, iterator->first,
                                           DelegateType(), NULL));
+                }
+                break;
 
 
-                    break;
-
-                case EmitMode::Blocking:
-                    // Check thread
-                    if (iterator->second == Thread::GetCurrentThread())
-                    {
-                        // Guard listener code for exceptions
-                        GuardedEventCall(event, iterator->first);
-                    }
-                    else
-                    {
-                        // New synchronization object is needed
-                        synchronization = new WaitableEvent();
-
-                        // Handle synchronized event
-                        dispatcher->AddEventCall(
-                            RegisterEventCall(event, iterator->first,
-                                              DelegateType(), synchronization));
-
-                        // Add to barrier
-                        synchronizationBarrier.push_back(synchronization);
-                    }
-                    break;
-
-                case EmitMode::Deffered:
-                    // Handle deffered events
-                    Assert(dueTime >= 0.0 && "Due time must be non-negative");
-
-                    dispatcher->AddTimedEventCall(
+            case EmitMode::Queued:
+                // Handle non-synchronized event
+                dispatcher->AddEventCall(
+                    RegisterEventCall(event, iterator->first,
+                                      DelegateType(), NULL));
+
+                break;
+
+            case EmitMode::Blocking:
+                // Check thread
+                if (iterator->second == Thread::GetCurrentThread()) {
+                    // Guard listener code for exceptions
+                    GuardedEventCall(event, iterator->first);
+                } else {
+                    // New synchronization object is needed
+                    synchronization = new WaitableEvent();
+
+                    // Handle synchronized event
+                    dispatcher->AddEventCall(
                         RegisterEventCall(event, iterator->first,
                         RegisterEventCall(event, iterator->first,
-                                          DelegateType(), NULL), dueTime);
+                                          DelegateType(), synchronization));
+
+                    // Add to barrier
+                    synchronizationBarrier.push_back(synchronization);
+                }
+                break;
+
+            case EmitMode::Deffered:
+                // Handle deffered events
+                Assert(dueTime >= 0.0 && "Due time must be non-negative");
 
 
-                    break;
+                dispatcher->AddTimedEventCall(
+                    RegisterEventCall(event, iterator->first,
+                                      DelegateType(), NULL), dueTime);
+
+                break;
 
 
-                default:
-                    Assert("Invalid emit mode");
+            default:
+                Assert("Invalid emit mode");
             }
         }
 
             }
         }
 
@@ -488,14 +465,11 @@ protected:
             // Switch to proper dispatcher and emit event
             AbstractEventDispatcher *dispatcher = NULL;
 
             // Switch to proper dispatcher and emit event
             AbstractEventDispatcher *dispatcher = NULL;
 
-            if (iterator->second == NULL)
-            {
+            if (iterator->second == NULL) {
                 // Send to main thread
                 LogPedantic("Sending event to main dispatcher");
                 dispatcher = &GetMainEventDispatcherInstance();
                 // Send to main thread
                 LogPedantic("Sending event to main dispatcher");
                 dispatcher = &GetMainEventDispatcherInstance();
-            }
-            else
-            {
+            } else {
                 // Setup thread dispatcher, and send to proper thread
                 LogPedantic("Sending event to thread dispatcher");
                 m_threadEventDispatcher.SetThread(iterator->second);
                 // Setup thread dispatcher, and send to proper thread
                 LogPedantic("Sending event to thread dispatcher");
                 m_threadEventDispatcher.SetThread(iterator->second);
@@ -506,97 +480,88 @@ protected:
             WaitableEvent *synchronization;
 
             // TODO: Pool synchronization objects
             WaitableEvent *synchronization;
 
             // TODO: Pool synchronization objects
-            switch (mode)
-            {
-                case EmitMode::Auto:
-                    // Check thread
-                    if (iterator->second == Thread::GetCurrentThread())
-                    {
-                        // Guard listener code for exceptions
-                        GuardedEventCall(event, iterator->first);
-                    }
-                    else
-                    {
-                        // Handle non-synchronized event
-                        dispatcher->AddEventCall(
-                            RegisterEventCall(event,
-                                              NULL,
-                                              iterator->first,
-                                              NULL));
-                    }
-                    break;
-
-                case EmitMode::Queued:
+            switch (mode) {
+            case EmitMode::Auto:
+                // Check thread
+                if (iterator->second == Thread::GetCurrentThread()) {
+                    // Guard listener code for exceptions
+                    GuardedEventCall(event, iterator->first);
+                } else {
                     // Handle non-synchronized event
                     dispatcher->AddEventCall(
                         RegisterEventCall(event,
                                           NULL,
                                           iterator->first,
                                           NULL));
                     // Handle non-synchronized event
                     dispatcher->AddEventCall(
                         RegisterEventCall(event,
                                           NULL,
                                           iterator->first,
                                           NULL));
+                }
+                break;
+
+            case EmitMode::Queued:
+                // Handle non-synchronized event
+                dispatcher->AddEventCall(
+                    RegisterEventCall(event,
+                                      NULL,
+                                      iterator->first,
+                                      NULL));
 
 
-                    break;
-
-                case EmitMode::Blocking:
-                    // Check thread
-                    if (iterator->second == Thread::GetCurrentThread())
-                    {
-                        // Guard listener code for exceptions
-                        GuardedEventCall(event, iterator->first);
-                    }
-                    else
-                    {
-                        // New synchronization object is needed
-                        synchronization = new WaitableEvent();
-
-                        // Handle synchronized event
-                        dispatcher->AddEventCall(
-                            RegisterEventCall(event,
-                                              NULL,
-                                              iterator->first,
-                                              synchronization));
-
-                        // Add to barrier
-                        synchronizationBarrier.push_back(synchronization);
-                    }
-                    break;
-
-                case EmitMode::Deffered:
-                    // Handle deffered events
-                    Assert(dueTime >= 0.0 && "Due time must be non-negative");
-
-                    dispatcher->AddTimedEventCall(
+                break;
+
+            case EmitMode::Blocking:
+                // Check thread
+                if (iterator->second == Thread::GetCurrentThread()) {
+                    // Guard listener code for exceptions
+                    GuardedEventCall(event, iterator->first);
+                } else {
+                    // New synchronization object is needed
+                    synchronization = new WaitableEvent();
+
+                    // Handle synchronized event
+                    dispatcher->AddEventCall(
                         RegisterEventCall(event,
                                           NULL,
                                           iterator->first,
                         RegisterEventCall(event,
                                           NULL,
                                           iterator->first,
-                                          NULL), dueTime);
+                                          synchronization));
+
+                    // Add to barrier
+                    synchronizationBarrier.push_back(synchronization);
+                }
+                break;
+
+            case EmitMode::Deffered:
+                // Handle deffered events
+                Assert(dueTime >= 0.0 && "Due time must be non-negative");
+
+                dispatcher->AddTimedEventCall(
+                    RegisterEventCall(event,
+                                      NULL,
+                                      iterator->first,
+                                      NULL), dueTime);
 
 
-                    break;
+                break;
 
 
-                default:
-                    Assert("Invalid emit mode");
+            default:
+                Assert("Invalid emit mode");
             }
         }
 
         LogPedantic("Added event to dispatchers");
 
         // Leave listeners lock in case of blocking call
             }
         }
 
         LogPedantic("Added event to dispatchers");
 
         // Leave listeners lock in case of blocking call
-        if (!synchronizationBarrier.empty())
-        {
+        if (!synchronizationBarrier.empty()) {
             LogPedantic("Leaving lock due to existing barrier");
             LogPedantic("Leaving lock due to existing barrier");
-            lock.Reset();
+            lock.reset();
         }
 
         LogPedantic("Size of barrier: " << synchronizationBarrier.size());
 
         // Synchronize with barrier
         // TODO: Implement generic WaitForAllMultipleHandles call
         }
 
         LogPedantic("Size of barrier: " << synchronizationBarrier.size());
 
         // Synchronize with barrier
         // TODO: Implement generic WaitForAllMultipleHandles call
-        while (!synchronizationBarrier.empty())
-        {
+        while (!synchronizationBarrier.empty()) {
             // Get barrier waitable handles
             WaitableHandleList barrierHandles;
 
             FOREACH(iterator, synchronizationBarrier)
             // Get barrier waitable handles
             WaitableHandleList barrierHandles;
 
             FOREACH(iterator, synchronizationBarrier)
-                barrierHandles.push_back((*iterator)->GetHandle());
+            barrierHandles.push_back((*iterator)->GetHandle());
 
             // Await more events
             WaitableHandleIndexList indexList =
 
             // Await more events
             WaitableHandleIndexList indexList =
@@ -618,8 +583,9 @@ protected:
 
             FOREACH(iterator, synchronizationBarrier)
             {
 
             FOREACH(iterator, synchronizationBarrier)
             {
-                if (*iterator == NULL)
+                if (*iterator == NULL) {
                     continue;
                     continue;
+                }
 
                 clearedSynchronizationBarrier.push_back(*iterator);
             }
 
                 clearedSynchronizationBarrier.push_back(*iterator);
             }
@@ -633,11 +599,10 @@ protected:
         LogPedantic("Event emitted");
     }
 
         LogPedantic("Event emitted");
     }
 
-public:
-    EventSupport()
-        : m_guardedCallInProgress(false)
-    {
-    }
+  public:
+    EventSupport() :
+        m_guardedCallInProgress(false)
+    {}
 
     virtual ~EventSupport()
     {
 
     virtual ~EventSupport()
     {
@@ -773,15 +738,14 @@ public:
 
         // Switch all listeners and delegates
         FOREACH(iterator, m_eventListenerList)
 
         // Switch all listeners and delegates
         FOREACH(iterator, m_eventListenerList)
-            iterator->second = thread;
+        iterator->second = thread;
 
         FOREACH(iterator, m_delegateList)
 
         FOREACH(iterator, m_delegateList)
-            iterator->second = thread;
+        iterator->second = thread;
 
         LogPedantic("All listeners and delegates switched");
     }
 };
 
         LogPedantic("All listeners and delegates switched");
     }
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 7c0567c..77fea72 100644 (file)
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 template<typename EventType, typename SupportDataType>
 template<typename EventType, typename SupportDataType>
-class GenericEventCall
-    public AbstractEventCall
+class GenericEventCall :
+    public AbstractEventCall
 {
 {
-public:
+  public:
     typedef EventListener<EventType> EventListenerType;
     typedef FastDelegate1<const EventType &> DelegateType;
 
     typedef EventListener<EventType> EventListenerType;
     typedef FastDelegate1<const EventType &> DelegateType;
 
-protected:
+  protected:
     SupportDataType m_supportData;
     EventListenerType *m_eventListener;
     DelegateType m_delegate;
     EventType m_event;
 
     SupportDataType m_supportData;
     EventListenerType *m_eventListener;
     DelegateType m_delegate;
     EventType m_event;
 
-public:
+  public:
     template<typename OtherEventType, typename OtherSupportType>
     struct Rebind
     {
     template<typename OtherEventType, typename OtherSupportType>
     struct Rebind
     {
@@ -58,13 +55,12 @@ public:
     GenericEventCall(SupportDataType supportData,
                      EventListenerType *eventListener,
                      DelegateType delegate,
     GenericEventCall(SupportDataType supportData,
                      EventListenerType *eventListener,
                      DelegateType delegate,
-                     const EventType &event)
-        : m_supportData(supportData),
-          m_eventListener(eventListener),
-          m_delegate(delegate),
-          m_event(event)
-    {
-    }
+                     const EventType &event) :
+        m_supportData(supportData),
+        m_eventListener(eventListener),
+        m_delegate(delegate),
+        m_event(event)
+    {}
 
     virtual ~GenericEventCall()
     {
 
     virtual ~GenericEventCall()
     {
@@ -94,7 +90,6 @@ public:
         // from the event queue (not just marked "disabled")
     }
 };
         // from the event queue (not just marked "disabled")
     }
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 55af651..260a6a4 100644 (file)
@@ -31,8 +31,6 @@
 #include <dpl/event/thread_event_dispatcher.h>
 #include <dpl/event/main_event_dispatcher.h>
 #include <dpl/fast_delegate.h>
 #include <dpl/event/thread_event_dispatcher.h>
 #include <dpl/event/main_event_dispatcher.h>
 #include <dpl/fast_delegate.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/enable_shared_from_this.h>
 #include <dpl/generic_event.h>
 #include <dpl/foreach.h>
 #include <dpl/recursive_mutex.h>
 #include <dpl/generic_event.h>
 #include <dpl/foreach.h>
 #include <dpl/recursive_mutex.h>
@@ -43,6 +41,7 @@
 #include <dpl/apply.h>
 #include <tuple>
 #include <list>
 #include <dpl/apply.h>
 #include <tuple>
 #include <list>
+#include <memory>
 
 /*
  * - Created ICDelegate can be passed freely to other threads.
 
 /*
  * - Created ICDelegate can be passed freely to other threads.
 
 namespace DPL {
 namespace Event {
 
 namespace DPL {
 namespace Event {
-
 //forward declaration
 template <typename ... ArgTypesList>
 class ICDelegate;
 
 //forward declaration
 template <typename ... ArgTypesList>
 class ICDelegate;
 
-namespace ICD{
+namespace ICD {
 // This Type defines whether ICDelegate should be destroyed after the call, or
 // could be reused later.
 // This Type defines whether ICDelegate should be destroyed after the call, or
 // could be reused later.
-enum class Reuse{ Yes, No };
+enum class Reuse
+{
+    Yes, No
+};
 }
 
 namespace ICDPrivate {
 }
 
 namespace ICDPrivate {
@@ -88,7 +89,7 @@ namespace ICDPrivate {
 class ICDSharedDataBase
 {
   public:
 class ICDSharedDataBase
 {
   public:
-    typedef DPL::SharedPtr<ICDSharedDataBase> ICDSharedDataBasePtr;
+    typedef std::shared_ptr<ICDSharedDataBase> ICDSharedDataBasePtr;
     typedef std::list<ICDSharedDataBasePtr> ICDSharedDataBaseList;
 
     class ScopedLock : DPL::Noncopyable
     typedef std::list<ICDSharedDataBasePtr> ICDSharedDataBaseList;
 
     class ScopedLock : DPL::Noncopyable
@@ -96,19 +97,16 @@ class ICDSharedDataBase
       public:
         explicit ScopedLock(ICDSharedDataBasePtr helperBase) :
             m_scopedLock(&helperBase->m_mutex)
       public:
         explicit ScopedLock(ICDSharedDataBasePtr helperBase) :
             m_scopedLock(&helperBase->m_mutex)
-        {
-        }
+        {}
 
       private:
         DPL::RecursiveMutex::ScopedLock m_scopedLock;
     };
 
     ICDSharedDataBase() : m_disabled(false)
 
       private:
         DPL::RecursiveMutex::ScopedLock m_scopedLock;
     };
 
     ICDSharedDataBase() : m_disabled(false)
-    {
-    }
+    {}
     virtual ~ICDSharedDataBase()
     virtual ~ICDSharedDataBase()
-    {
-    }
+    {}
 
     bool isDisabled() const
     {
 
     bool isDisabled() const
     {
@@ -140,30 +138,28 @@ class DeleteICDSharedDataBaseEventCall : public DPL::Event::AbstractEventCall
 {
   public:
     DeleteICDSharedDataBaseEventCall(
 {
   public:
     DeleteICDSharedDataBaseEventCall(
-            ICDSharedDataBase::ICDSharedDataBasePtr helperBase) :
+        ICDSharedDataBase::ICDSharedDataBasePtr helperBase) :
         m_helperBase(helperBase)
         m_helperBase(helperBase)
-    {
-    }
+    {}
     virtual void Call()
     {
     virtual void Call()
     {
-        m_helperBase.Reset();
+        m_helperBase.reset();
     }
 
   private:
     ICDSharedDataBase::ICDSharedDataBasePtr m_helperBase;
 };
 
     }
 
   private:
     ICDSharedDataBase::ICDSharedDataBasePtr m_helperBase;
 };
 
-
 class ICDelegateSupportInterface
 {
   protected:
     virtual ~ICDelegateSupportInterface()
 class ICDelegateSupportInterface
 {
   protected:
     virtual ~ICDelegateSupportInterface()
-    {
-    }
+    {}
     virtual void unregisterICDSharedData(
     virtual void unregisterICDSharedData(
-            ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper) = 0;
+        ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper) = 0;
     virtual void registerICDSharedData(
     virtual void registerICDSharedData(
-            ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper) = 0;
+        ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper) = 0;
+
   private:
     template <typename ... ArgTypesList>
     friend class DPL::Event::ICDelegate;
   private:
     template <typename ... ArgTypesList>
     friend class DPL::Event::ICDelegate;
@@ -174,7 +170,7 @@ class ICDelegateSupportInterface
 template<typename ThisType, typename ... ArgTypesList>
 FastDelegate<void (ArgTypesList ...)>
 makeDelegate(ThisType* This,
 template<typename ThisType, typename ... ArgTypesList>
 FastDelegate<void (ArgTypesList ...)>
 makeDelegate(ThisType* This,
-        void (ThisType::*Func)(ArgTypesList ...))
+             void (ThisType::*Func)(ArgTypesList ...))
 {
     return FastDelegate<void (ArgTypesList ...)>(This, Func);
 }
 {
     return FastDelegate<void (ArgTypesList ...)>(This, Func);
 }
@@ -187,14 +183,13 @@ class ICDelegate
 {
   public:
     ICDelegate()
 {
   public:
     ICDelegate()
-    {
-    }
+    {}
     ICDelegate(ICDPrivate::ICDelegateSupportInterface* base,
                DPL::FastDelegate<void (ArgTypesList ...)> outerDelegate,
                ICD::Reuse reuse)
     {
         ICDSharedData* hlp = new ICDSharedData(base, outerDelegate, reuse);
     ICDelegate(ICDPrivate::ICDelegateSupportInterface* base,
                DPL::FastDelegate<void (ArgTypesList ...)> outerDelegate,
                ICD::Reuse reuse)
     {
         ICDSharedData* hlp = new ICDSharedData(base, outerDelegate, reuse);
-        m_helper.Reset(hlp);
+        m_helper.reset(hlp);
     }
 
     // Calling operator will pass all args passed to it to correct context and
     }
 
     // Calling operator will pass all args passed to it to correct context and
@@ -203,7 +198,7 @@ class ICDelegate
     {
         Assert(m_helper);
         ICDPrivate::ICDSharedDataBase::ScopedLock lock(
     {
         Assert(m_helper);
         ICDPrivate::ICDSharedDataBase::ScopedLock lock(
-            DPL::StaticPointerCast<ICDPrivate::ICDSharedDataBase>(m_helper));
+            std::static_pointer_cast<ICDPrivate::ICDSharedDataBase>(m_helper));
         m_helper->CallDelegate(args ...);
     }
 
         m_helper->CallDelegate(args ...);
     }
 
@@ -212,7 +207,7 @@ class ICDelegate
     {
         Assert(m_helper);
         ICDPrivate::ICDSharedDataBase::ScopedLock lock(
     {
         Assert(m_helper);
         ICDPrivate::ICDSharedDataBase::ScopedLock lock(
-            DPL::StaticPointerCast<ICDPrivate::ICDSharedDataBase>(m_helper));
+            std::static_pointer_cast<ICDPrivate::ICDSharedDataBase>(m_helper));
         m_helper->disable();
     }
 
         m_helper->disable();
     }
 
@@ -220,23 +215,22 @@ class ICDelegate
     ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr
     getRelatedICDSharedData() const
     {
     ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr
     getRelatedICDSharedData() const
     {
-        return DPL::StaticPointerCast<ICDPrivate::ICDSharedDataBase>(m_helper);
+        return std::static_pointer_cast<ICDPrivate::ICDSharedDataBase>(m_helper);
     }
 
   private:
     template<typename ThisType>
     friend class ICDelegateSupport;
     class ICDSharedData;
     }
 
   private:
     template<typename ThisType>
     friend class ICDelegateSupport;
     class ICDSharedData;
-    typedef DPL::SharedPtr<ICDSharedData> ICDSharedDataPtr;
+    typedef std::shared_ptr<ICDSharedData> ICDSharedDataPtr;
 
     struct PrivateEvent
     {
         PrivateEvent(ICDSharedDataPtr a_helper,
 
     struct PrivateEvent
     {
         PrivateEvent(ICDSharedDataPtr a_helper,
-                ArgTypesList ... arguments) :
+                     ArgTypesList ... arguments) :
             helper(a_helper),
             args(std::make_tuple(arguments ...))
             helper(a_helper),
             args(std::make_tuple(arguments ...))
-        {
-        }
+        {}
 
         ICDSharedDataPtr helper;
         std::tuple<ArgTypesList ...> args;
 
         ICDSharedDataPtr helper;
         std::tuple<ArgTypesList ...> args;
@@ -245,7 +239,7 @@ class ICDelegate
     typedef DPL::FastDelegate<void (const PrivateEvent&)>
     ICDSharedDataDelegateType;
     class ICDSharedData : private DPL::Event::EventSupport<PrivateEvent>,
     typedef DPL::FastDelegate<void (const PrivateEvent&)>
     ICDSharedDataDelegateType;
     class ICDSharedData : private DPL::Event::EventSupport<PrivateEvent>,
-        private DPL::EnableSharedFromThis<ICDSharedData>,
+        public std::enable_shared_from_this<ICDSharedData>,
         public ICDPrivate::ICDSharedDataBase
     {
       public:
         public ICDPrivate::ICDSharedDataBase
     {
       public:
@@ -268,10 +262,10 @@ class ICDelegate
         void CallDelegate(ArgTypesList ... args)
         {
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(
         void CallDelegate(ArgTypesList ... args)
         {
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(
-                DPL::StaticPointerCast<ICDPrivate::ICDSharedDataBase>(
-                    this->SharedFromThis()));
+                std::static_pointer_cast<ICDPrivate::ICDSharedDataBase>(
+                    this->shared_from_this()));
             if (!isDisabled()) {
             if (!isDisabled()) {
-                EmitEvent(PrivateEvent(this->SharedFromThis(),
+                EmitEvent(PrivateEvent(this->shared_from_this(),
                                        args ...));
             }
         }
                                        args ...));
             }
         }
@@ -279,8 +273,8 @@ class ICDelegate
         virtual void disable()
         {
             ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr ptr(
         virtual void disable()
         {
             ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr ptr(
-                DPL::StaticPointerCast<ICDSharedDataBase>(
-                    this->SharedFromThis()));
+                std::static_pointer_cast<ICDSharedDataBase>(
+                    this->shared_from_this()));
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(ptr);
             if (!isDisabled()) {
                 ICDPrivate::ICDSharedDataBase::disable();
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(ptr);
             if (!isDisabled()) {
                 ICDPrivate::ICDSharedDataBase::disable();
@@ -290,7 +284,7 @@ class ICDelegate
         }
 
       private:
         }
 
       private:
-        friend class DPL::SharedPtr<ICDSharedData>;
+        friend class std::shared_ptr<ICDSharedData>;
         ICDSharedDataDelegateType m_subDelegate;
         ICDPrivate::ICDelegateSupportInterface* m_base;
         DPL::FastDelegate<void (ArgTypesList ...)> m_outerDelegate;
         ICDSharedDataDelegateType m_subDelegate;
         ICDPrivate::ICDelegateSupportInterface* m_base;
         DPL::FastDelegate<void (ArgTypesList ...)> m_outerDelegate;
@@ -299,7 +293,7 @@ class ICDelegate
         void delegateForwarder(const PrivateEvent& event)
         {
             ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr ptr(
         void delegateForwarder(const PrivateEvent& event)
         {
             ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr ptr(
-                DPL::StaticPointerCast<ICDSharedDataBase>(event.helper));
+                std::static_pointer_cast<ICDSharedDataBase>(event.helper));
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(ptr);
 
             Assert(!m_outerDelegate.empty());
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(ptr);
 
             Assert(!m_outerDelegate.empty());
@@ -308,8 +302,9 @@ class ICDelegate
             } else {
                 DPL::Apply(m_outerDelegate, event.args);
 
             } else {
                 DPL::Apply(m_outerDelegate, event.args);
 
-                if(m_reuse == ICD::Reuse::Yes)
+                if (m_reuse == ICD::Reuse::Yes) {
                     return;
                     return;
+                }
 
                 disable();
                 deleteICDSharedDataBase(ptr);
 
                 disable();
                 deleteICDSharedDataBase(ptr);
@@ -318,12 +313,13 @@ class ICDelegate
     };
 
     // Schedules helper removal.
     };
 
     // Schedules helper removal.
-    static void deleteICDSharedDataBase(ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper)
+    static void deleteICDSharedDataBase(
+        ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper)
     {
         using namespace ICDPrivate;
         ICDSharedDataBase::ScopedLock lock(helper);
         DeleteICDSharedDataBaseEventCall* event =
     {
         using namespace ICDPrivate;
         ICDSharedDataBase::ScopedLock lock(helper);
         DeleteICDSharedDataBaseEventCall* event =
-          new DeleteICDSharedDataBaseEventCall(helper);
+            new DeleteICDSharedDataBaseEventCall(helper);
         if (DPL::Thread::GetCurrentThread() == NULL) {
             DPL::Event::GetMainEventDispatcherInstance().AddEventCall(event);
         } else {
         if (DPL::Thread::GetCurrentThread() == NULL) {
             DPL::Event::GetMainEventDispatcherInstance().AddEventCall(event);
         } else {
@@ -342,8 +338,8 @@ class ICDelegateSupport : public ICDPrivate::ICDelegateSupportInterface
   protected:
     template<typename ... ArgTypesList>
     ICDelegate<ArgTypesList ...> makeICDelegate(
   protected:
     template<typename ... ArgTypesList>
     ICDelegate<ArgTypesList ...> makeICDelegate(
-            void (ThisType::*Func)(ArgTypesList ...),
-            ICD::Reuse reuse = ICD::Reuse::No)
+        void (ThisType::*Func)(ArgTypesList ...),
+        ICD::Reuse reuse = ICD::Reuse::No)
     {
         ThisType* This = static_cast<ThisType*>(this);
         ICDelegate<ArgTypesList ...> icdelegate(
     {
         ThisType* This = static_cast<ThisType*>(this);
         ICDelegate<ArgTypesList ...> icdelegate(
@@ -355,8 +351,7 @@ class ICDelegateSupport : public ICDPrivate::ICDelegateSupportInterface
     }
 
     ICDelegateSupport()
     }
 
     ICDelegateSupport()
-    {
-    }
+    {}
 
     ~ICDelegateSupport()
     {
 
     ~ICDelegateSupport()
     {
@@ -364,7 +359,7 @@ class ICDelegateSupport : public ICDPrivate::ICDelegateSupportInterface
             m_ICDSharedDatas;
         FOREACH(helper, list) {
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(
             m_ICDSharedDatas;
         FOREACH(helper, list) {
             ICDPrivate::ICDSharedDataBase::ScopedLock lock(
-                DPL::StaticPointerCast<ICDPrivate::ICDSharedDataBase>(*helper));
+                std::static_pointer_cast<ICDPrivate::ICDSharedDataBase>(*helper));
             (*helper)->disable();
         }
         m_ICDSharedDatas.clear();
             (*helper)->disable();
         }
         m_ICDSharedDatas.clear();
@@ -372,13 +367,13 @@ class ICDelegateSupport : public ICDPrivate::ICDelegateSupportInterface
 
   private:
     virtual void unregisterICDSharedData(
 
   private:
     virtual void unregisterICDSharedData(
-            ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper)
+        ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper)
     {
         m_ICDSharedDatas.erase(helper->getIterator());
     }
 
     virtual void registerICDSharedData(
     {
         m_ICDSharedDatas.erase(helper->getIterator());
     }
 
     virtual void registerICDSharedData(
-            ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper)
+        ICDPrivate::ICDSharedDataBase::ICDSharedDataBasePtr helper)
     {
         helper->setIterator(
             m_ICDSharedDatas.insert(m_ICDSharedDatas.begin(),
     {
         helper->setIterator(
             m_ICDSharedDatas.insert(m_ICDSharedDatas.begin(),
@@ -388,7 +383,6 @@ class ICDelegateSupport : public ICDPrivate::ICDelegateSupportInterface
   private:
     ICDPrivate::ICDSharedDataBase::ICDSharedDataBaseList m_ICDSharedDatas;
 };
   private:
     ICDPrivate::ICDSharedDataBase::ICDSharedDataBaseList m_ICDSharedDatas;
 };
-
 }
 } //namespace
 
 }
 } //namespace
 
index 97145f6..db86b1f 100644 (file)
@@ -17,7 +17,8 @@
  * @file        main_event_dispatcher.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        main_event_dispatcher.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of main event dispatcher for EFL
+ * @brief       This file is the implementation file of main event dispatcher
+ * for EFL
  */
 #ifndef DPL_MAIN_EVENT_DISPATCHER_H
 #define DPL_MAIN_EVENT_DISPATCHER_H
  */
 #ifndef DPL_MAIN_EVENT_DISPATCHER_H
 #define DPL_MAIN_EVENT_DISPATCHER_H
 #include <dpl/framework_efl.h>
 #include <list>
 
 #include <dpl/framework_efl.h>
 #include <list>
 
-namespace DPL
+namespace DPL {
+namespace Event {
+class MainEventDispatcher :
+    public AbstractEventDispatcher
 {
 {
-namespace Event
-{
-
-class MainEventDispatcher
-    : public AbstractEventDispatcher
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, AddEventFailed)
         DECLARE_EXCEPTION_TYPE(Base, AddTimedEventFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
         DECLARE_EXCEPTION_TYPE(Base, AddEventFailed)
         DECLARE_EXCEPTION_TYPE(Base, AddTimedEventFailed)
     };
 
-protected:
+  protected:
     struct WrappedEventCall
     {
         AbstractEventCall *abstractEventCall;
     struct WrappedEventCall
     {
         AbstractEventCall *abstractEventCall;
@@ -58,12 +56,11 @@ protected:
 
         WrappedEventCall(AbstractEventCall *abstractEventCallArg,
                          bool timedArg,
 
         WrappedEventCall(AbstractEventCall *abstractEventCallArg,
                          bool timedArg,
-                         double dueTimeArg)
-            : abstractEventCall(abstractEventCallArg),
-              timed(timedArg),
-              dueTime(dueTimeArg)
-        {
-        }
+                         double dueTimeArg) :
+            abstractEventCall(abstractEventCallArg),
+            timed(timedArg),
+            dueTime(dueTimeArg)
+        {}
     };
 
     typedef std::list<WrappedEventCall> WrappedEventCallList;
     };
 
     typedef std::list<WrappedEventCall> WrappedEventCallList;
@@ -71,7 +68,7 @@ protected:
     // Cross thread send support
     WrappedEventCallList m_wrappedCrossEventCallList;
     Mutex m_crossEventCallMutex;
     // Cross thread send support
     WrappedEventCallList m_wrappedCrossEventCallList;
     Mutex m_crossEventCallMutex;
-    WaitableEvent m_crossEventCallInvoker;
+    WaitableEvent* m_crossEventCallInvoker;
 
     Ecore_Event_Handler *m_eventCallHandler;
     Ecore_Fd_Handler *m_crossEventCallHandler;
 
     Ecore_Event_Handler *m_eventCallHandler;
     Ecore_Fd_Handler *m_crossEventCallHandler;
@@ -85,35 +82,38 @@ protected:
         MainEventDispatcher *This;
 
         TimedEventStruct(AbstractEventCall *abstractEventCallArg,
         MainEventDispatcher *This;
 
         TimedEventStruct(AbstractEventCall *abstractEventCallArg,
-                         MainEventDispatcher *ThisArg)
-            : abstractEventCall(abstractEventCallArg),
-              This(ThisArg)
-        {
-        }
+                         MainEventDispatcher *ThisArg) :
+            abstractEventCall(abstractEventCallArg),
+            This(ThisArg)
+        {}
     };
 
     };
 
-    void InternalAddEvent(AbstractEventCall *abstractEventCall, bool timed, double dueTime);
+    void InternalAddEvent(AbstractEventCall *abstractEventCall,
+                          bool timed,
+                          double dueTime);
 
     static void StaticDeleteEvent(void *data, void *event);
     static Eina_Bool StaticDispatchEvent(void *data, int type, void *event);
     static Eina_Bool StaticDispatchTimedEvent(void *event);
 
     static void StaticDeleteEvent(void *data, void *event);
     static Eina_Bool StaticDispatchEvent(void *data, int type, void *event);
     static Eina_Bool StaticDispatchTimedEvent(void *event);
-    static Eina_Bool StaticDispatchCrossInvoker(void *data, Ecore_Fd_Handler *fd_handler);
+    static Eina_Bool StaticDispatchCrossInvoker(void *data,
+                                                Ecore_Fd_Handler *fd_handler);
 
     void DeleteEvent(AbstractEventCall *abstractEventCall);
     void DispatchEvent(AbstractEventCall *abstractEventCall);
     void DispatchTimedEvent(AbstractEventCall *abstractEventCall);
     void DispatchCrossInvoker();
 
 
     void DeleteEvent(AbstractEventCall *abstractEventCall);
     void DispatchEvent(AbstractEventCall *abstractEventCall);
     void DispatchTimedEvent(AbstractEventCall *abstractEventCall);
     void DispatchCrossInvoker();
 
-public:
+  public:
     explicit MainEventDispatcher();
     virtual ~MainEventDispatcher();
 
     virtual void AddEventCall(AbstractEventCall *abstractEventCall);
     explicit MainEventDispatcher();
     virtual ~MainEventDispatcher();
 
     virtual void AddEventCall(AbstractEventCall *abstractEventCall);
-    virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall, double dueTime);
+    virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall,
+                                   double dueTime);
+    virtual void ResetCrossEventCallHandler();
 };
 
 MainEventDispatcher& GetMainEventDispatcherInstance();
 };
 
 MainEventDispatcher& GetMainEventDispatcherInstance();
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 07c0340..b149eee 100644 (file)
 #include <dpl/read_write_mutex.h>
 #include <dpl/noncopyable.h>
 
 #include <dpl/read_write_mutex.h>
 #include <dpl/noncopyable.h>
 
-namespace DPL
+namespace DPL {
+namespace Event {
+class Model :
+    public Noncopyable
 {
 {
-namespace Event
-{
-
-class Model
-    : public Noncopyable
-{
-protected:
+  protected:
     mutable DPL::ReadWriteMutex m_mutex;
 
     template<typename Type, typename StorageMethod>
     mutable DPL::ReadWriteMutex m_mutex;
 
     template<typename Type, typename StorageMethod>
@@ -42,10 +39,9 @@ protected:
     template<typename Type, typename AccessType, typename StorageMethod>
     friend class Property;
 
     template<typename Type, typename AccessType, typename StorageMethod>
     friend class Property;
 
-public:
+  public:
     virtual ~Model() = 0;
 };
     virtual ~Model() = 0;
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 51473e8..2ed7e0e 100644 (file)
 #ifndef DPL_MODEL_BIND_TO_DAO_H_
 #define DPL_MODEL_BIND_TO_DAO_H_
 
 #ifndef DPL_MODEL_BIND_TO_DAO_H_
 #define DPL_MODEL_BIND_TO_DAO_H_
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 /**
  * @param ObjectType type of object used as delegate argument
  * @param RetType Type returned from the external function
 /**
  * @param ObjectType type of object used as delegate argument
  * @param RetType Type returned from the external function
@@ -70,7 +67,6 @@ struct BindToDAO
         return (extObject.*externalGetter)();
     }
 };
         return (extObject.*externalGetter)();
     }
 };
-
 }
 }
 
 }
 }
 
index 33da4df..cb88431 100644 (file)
 #include <dpl/fast_delegate.h>
 #include <dpl/once.h>
 
 #include <dpl/fast_delegate.h>
 #include <dpl/once.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 /**
  * Property is a class that encapsulates model's property fields.
  * Its main purpose is to automate things related to model's properties
 /**
  * Property is a class that encapsulates model's property fields.
  * Its main purpose is to automate things related to model's properties
@@ -205,15 +202,13 @@ struct PropertyStorageDynamicCached {}; ///< Use dynamic then cache
 struct PropertyReadOnly {};  ///< Read only, not setter available
 struct PropertyReadWrite {}; ///< Read and write
 
 struct PropertyReadOnly {};  ///< Read only, not setter available
 struct PropertyReadWrite {}; ///< Read and write
 
-
 template<typename Type>
 struct PropertyEvent
 {
 template<typename Type>
 struct PropertyEvent
 {
-    PropertyEvent(const Type &v, Model *s)
-        : value(v),
-          sender(s)
-    {
-    }
+    PropertyEvent(const Type &v, Model *s) :
+        value(v),
+        sender(s)
+    {}
 
     Type value;
     Model *sender;
 
     Type value;
     Model *sender;
@@ -222,36 +217,33 @@ struct PropertyEvent
 template<typename ReadDelegateType, typename WriteDelegateType>
 class PropertyStorageMethodDynamicBase
 {
 template<typename ReadDelegateType, typename WriteDelegateType>
 class PropertyStorageMethodDynamicBase
 {
-protected:
+  protected:
     ReadDelegateType m_readValue;
     WriteDelegateType m_writeValue;
 
     PropertyStorageMethodDynamicBase(ReadDelegateType readValue,
     ReadDelegateType m_readValue;
     WriteDelegateType m_writeValue;
 
     PropertyStorageMethodDynamicBase(ReadDelegateType readValue,
-                                     WriteDelegateType writeValue)
-        : m_readValue(readValue),
-          m_writeValue(writeValue)
-    {
-    }
+                                     WriteDelegateType writeValue) :
+        m_readValue(readValue),
+        m_writeValue(writeValue)
+    {}
 };
 
 template<typename Type>
 class PropertyStorageMethodCachedBase
 {
 };
 
 template<typename Type>
 class PropertyStorageMethodCachedBase
 {
-protected:
+  protected:
     mutable Type m_value;
 
     PropertyStorageMethodCachedBase()
     mutable Type m_value;
 
     PropertyStorageMethodCachedBase()
-    {
-    }
+    {}
 };
 
 class PropertyStorageMethodBase
 {
 };
 
 class PropertyStorageMethodBase
 {
-protected:
-    explicit PropertyStorageMethodBase(Model *model)
-        : m_model(model)
-    {
-    }
+  protected:
+    explicit PropertyStorageMethodBase(Model *model) :
+        m_model(model)
+    {}
 
     Model *m_model;
 };
 
     Model *m_model;
 };
@@ -268,17 +260,16 @@ template<typename Type,
 class PropertyStorageMethod<Type,
                             PropertyStorageCached,
                             ReadDelegateType,
 class PropertyStorageMethod<Type,
                             PropertyStorageCached,
                             ReadDelegateType,
-                            WriteDelegateType>
-    protected PropertyStorageMethodBase,
-      protected PropertyStorageMethodCachedBase<Type>
+                            WriteDelegateType>:
+    protected PropertyStorageMethodBase,
+    protected PropertyStorageMethodCachedBase<Type>
 {
 {
-public:
+  public:
     PropertyStorageMethod(Model *model,
                           ReadDelegateType /*readValue*/,
     PropertyStorageMethod(Model *model,
                           ReadDelegateType /*readValue*/,
-                          WriteDelegateType /*writeValue*/)
-        : PropertyStorageMethodBase(model)
-    {
-    }
+                          WriteDelegateType /*writeValue*/) :
+        PropertyStorageMethodBase(model)
+    {}
 
     Type Get() const
     {
 
     Type Get() const
     {
@@ -295,21 +286,20 @@ template<typename Type, typename ReadDelegateType, typename WriteDelegateType>
 class PropertyStorageMethod<Type,
                             PropertyStorageDynamic,
                             ReadDelegateType,
 class PropertyStorageMethod<Type,
                             PropertyStorageDynamic,
                             ReadDelegateType,
-                            WriteDelegateType>
-    protected PropertyStorageMethodBase,
-      protected PropertyStorageMethodDynamicBase<ReadDelegateType,
-                                                 WriteDelegateType>
+                            WriteDelegateType>:
+    protected PropertyStorageMethodBase,
+    protected PropertyStorageMethodDynamicBase<ReadDelegateType,
+                                               WriteDelegateType>
 {
 {
-public:
+  public:
     PropertyStorageMethod(Model *model,
                           ReadDelegateType readValue,
     PropertyStorageMethod(Model *model,
                           ReadDelegateType readValue,
-                          WriteDelegateType writeValue)
-        : PropertyStorageMethodBase(model),
-          PropertyStorageMethodDynamicBase<ReadDelegateType, WriteDelegateType>(
-              readValue,
-              writeValue)
-    {
-    }
+                          WriteDelegateType writeValue) :
+        PropertyStorageMethodBase(model),
+        PropertyStorageMethodDynamicBase<ReadDelegateType, WriteDelegateType>(
+            readValue,
+            writeValue)
+    {}
 
     Type Get() const
     {
 
     Type Get() const
     {
@@ -328,13 +318,13 @@ template<typename Type, typename ReadDelegateType, typename WriteDelegateType>
 class PropertyStorageMethod<Type,
                             PropertyStorageDynamicCached,
                             ReadDelegateType,
 class PropertyStorageMethod<Type,
                             PropertyStorageDynamicCached,
                             ReadDelegateType,
-                            WriteDelegateType>
-    protected PropertyStorageMethodBase,
-      protected PropertyStorageMethodDynamicBase<ReadDelegateType,
-                                                 WriteDelegateType>,
-      protected PropertyStorageMethodCachedBase<Type>
+                            WriteDelegateType>:
+    protected PropertyStorageMethodBase,
+    protected PropertyStorageMethodDynamicBase<ReadDelegateType,
+                                               WriteDelegateType>,
+    protected PropertyStorageMethodCachedBase<Type>
 {
 {
-private:
+  private:
     typedef PropertyStorageMethod<Type,
                                   PropertyStorageDynamicCached,
                                   ReadDelegateType,
     typedef PropertyStorageMethod<Type,
                                   PropertyStorageDynamicCached,
                                   ReadDelegateType,
@@ -347,21 +337,19 @@ private:
     }
 
     void OnceDisable() const
     }
 
     void OnceDisable() const
-    {
-    }
+    {}
 
 
-protected:
+  protected:
     mutable Once m_once;
 
     mutable Once m_once;
 
-public:
+  public:
     PropertyStorageMethod(Model *model,
                           ReadDelegateType readValue,
     PropertyStorageMethod(Model *model,
                           ReadDelegateType readValue,
-                          WriteDelegateType writeValue)
-        : PropertyStorageMethodBase(model),
-          PropertyStorageMethodDynamicBase<ReadDelegateType, WriteDelegateType>(
-              readValue, writeValue)
-    {
-    }
+                          WriteDelegateType writeValue) :
+        PropertyStorageMethodBase(model),
+        PropertyStorageMethodDynamicBase<ReadDelegateType, WriteDelegateType>(
+            readValue, writeValue)
+    {}
 
     Type Get() const
     {
 
     Type Get() const
     {
@@ -381,23 +369,23 @@ public:
 };
 
 template<typename Type, typename StorageMethod>
 };
 
 template<typename Type, typename StorageMethod>
-class PropertyBase
-    protected EventSupport<PropertyEvent<Type> >
+class PropertyBase :
+    protected EventSupport<PropertyEvent<Type> >
 {
 {
-public:
+  public:
     typedef typename EventSupport<PropertyEvent<Type> >::EventListenerType
     typedef typename EventSupport<PropertyEvent<Type> >::EventListenerType
-        EventListenerType;
+    EventListenerType;
 
     typedef typename EventSupport<PropertyEvent<Type> >::DelegateType
 
     typedef typename EventSupport<PropertyEvent<Type> >::DelegateType
-        DelegateType;
+    DelegateType;
 
 
-    typedef FastDelegate<Type (Model *)>
-        ReadDelegateType;
+    typedef FastDelegate<Type(Model *)>
+    ReadDelegateType;
 
     typedef FastDelegate<void (const Type &, Model *)>
 
     typedef FastDelegate<void (const Type &, Model *)>
-        WriteDelegateType;
+    WriteDelegateType;
 
 
-protected:
+  protected:
     PropertyStorageMethod<Type,
                           StorageMethod,
                           ReadDelegateType,
     PropertyStorageMethod<Type,
                           StorageMethod,
                           ReadDelegateType,
@@ -406,13 +394,12 @@ protected:
 
     PropertyBase(Model *model,
                  ReadDelegateType readValue,
 
     PropertyBase(Model *model,
                  ReadDelegateType readValue,
-                 WriteDelegateType writeValue)
-        : m_storage(model, readValue, writeValue),
-          m_model(model)
-    {
-    }
+                 WriteDelegateType writeValue) :
+        m_storage(model, readValue, writeValue),
+        m_model(model)
+    {}
 
 
-public:
+  public:
     virtual Type Get() const
     {
         ReadWriteMutex::ScopedReadLock lock(&m_model->m_mutex);
     virtual Type Get() const
     {
         ReadWriteMutex::ScopedReadLock lock(&m_model->m_mutex);
@@ -436,68 +423,66 @@ template<typename Type,
 class Property;
 
 template<typename Type, typename StorageMethod>
 class Property;
 
 template<typename Type, typename StorageMethod>
-class Property<Type, PropertyReadOnly, StorageMethod>
-    public PropertyBase<Type, StorageMethod>
+class Property<Type, PropertyReadOnly, StorageMethod>:
+    public PropertyBase<Type, StorageMethod>
 {
 {
-public:
+  public:
     typedef typename PropertyBase<Type, StorageMethod>::EventListenerType
     typedef typename PropertyBase<Type, StorageMethod>::EventListenerType
-        EventListenerType;
+    EventListenerType;
 
     typedef typename PropertyBase<Type, StorageMethod>::DelegateType
 
     typedef typename PropertyBase<Type, StorageMethod>::DelegateType
-        DelegateType;
+    DelegateType;
 
     typedef typename PropertyBase<Type, StorageMethod>::ReadDelegateType
 
     typedef typename PropertyBase<Type, StorageMethod>::ReadDelegateType
-        ReadDelegateType;
+    ReadDelegateType;
 
     typedef typename PropertyBase<Type, StorageMethod>::WriteDelegateType
 
     typedef typename PropertyBase<Type, StorageMethod>::WriteDelegateType
-        WriteDelegateType;
+    WriteDelegateType;
 
 
-public:
+  public:
     explicit Property(Model *model,
     explicit Property(Model *model,
-             ReadDelegateType readValue = NULL)
-        : PropertyBase<Type, StorageMethod>(model, readValue, NULL)
-    {
-    }
+                      ReadDelegateType readValue = NULL) :
+        PropertyBase<Type, StorageMethod>(model, readValue, NULL)
+    {}
 
     Property(Model *model,
              const Type &value,
 
     Property(Model *model,
              const Type &value,
-             ReadDelegateType readValue = NULL)
-        PropertyBase<Type, StorageMethod>(model, readValue, NULL)
+             ReadDelegateType readValue = NULL) :
+        PropertyBase<Type, StorageMethod>(model, readValue, NULL)
     {
         this->m_storage.Set(value);
     }
 };
 
 template<typename Type, typename StorageMethod>
     {
         this->m_storage.Set(value);
     }
 };
 
 template<typename Type, typename StorageMethod>
-class Property<Type, PropertyReadWrite, StorageMethod>
-    public PropertyBase<Type, StorageMethod>
+class Property<Type, PropertyReadWrite, StorageMethod>:
+    public PropertyBase<Type, StorageMethod>
 {
 {
-public:
+  public:
     typedef typename PropertyBase<Type, StorageMethod>::EventListenerType
     typedef typename PropertyBase<Type, StorageMethod>::EventListenerType
-        EventListenerType;
+    EventListenerType;
 
     typedef typename PropertyBase<Type, StorageMethod>::DelegateType
 
     typedef typename PropertyBase<Type, StorageMethod>::DelegateType
-        DelegateType;
+    DelegateType;
 
     typedef typename PropertyBase<Type, StorageMethod>::ReadDelegateType
 
     typedef typename PropertyBase<Type, StorageMethod>::ReadDelegateType
-        ReadDelegateType;
+    ReadDelegateType;
 
     typedef typename PropertyBase<Type, StorageMethod>::WriteDelegateType
 
     typedef typename PropertyBase<Type, StorageMethod>::WriteDelegateType
-        WriteDelegateType;
+    WriteDelegateType;
 
 
-public:
+  public:
     explicit Property(Model *model,
     explicit Property(Model *model,
-             ReadDelegateType readValue = NULL,
-             WriteDelegateType writeValue = NULL)
-        : PropertyBase<Type, StorageMethod>(model, readValue, writeValue)
-    {
-    }
+                      ReadDelegateType readValue = NULL,
+                      WriteDelegateType writeValue = NULL) :
+        PropertyBase<Type, StorageMethod>(model, readValue, writeValue)
+    {}
 
     Property(Model *model,
              const Type &value,
              ReadDelegateType readValue = NULL,
 
     Property(Model *model,
              const Type &value,
              ReadDelegateType readValue = NULL,
-             WriteDelegateType writeValue = NULL)
-        PropertyBase<Type, StorageMethod>(model, readValue, writeValue)
+             WriteDelegateType writeValue = NULL) :
+        PropertyBase<Type, StorageMethod>(model, readValue, writeValue)
     {
         this->m_storage.Set(value);
     }
     {
         this->m_storage.Set(value);
     }
@@ -506,16 +491,25 @@ public:
     {
         ReadWriteMutex::ScopedWriteLock lock(&this->m_model->m_mutex);
 
     {
         ReadWriteMutex::ScopedWriteLock lock(&this->m_model->m_mutex);
 
-        if (this->m_storage.Get() == value)
+        if (this->m_storage.Get() == value) {
             return;
             return;
+        }
 
         this->m_storage.Set(value);
 
 
         this->m_storage.Set(value);
 
-        EmitEvent(PropertyEvent<Type>(value, this->m_model),
-                  EmitMode::Auto);
+        this->EmitEvent(PropertyEvent<Type>(value, this->m_model),
+                        EmitMode::Auto);
     }
     }
-};
 
 
+    void SetWithoutLock(const Type &value)
+    {
+        if (this->m_storage.Get() == value) {
+            return;
+        }
+
+        this->m_storage.Set(value);
+    }
+};
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index e5e81a4..f3846a6 100644 (file)
 #include <dpl/event/abstract_event_call.h>
 #include <dpl/thread.h>
 
 #include <dpl/event/abstract_event_call.h>
 #include <dpl/thread.h>
 
-namespace DPL
+namespace DPL {
+namespace Event {
+class ThreadEventDispatcher :
+    public AbstractEventDispatcher
 {
 {
-namespace Event
-{
-
-class ThreadEventDispatcher
-    : public AbstractEventDispatcher
-{
-protected:
+  protected:
     Thread *m_thread;
 
     static void StaticEventDelete(void *event, void *userParam);
     Thread *m_thread;
 
     static void StaticEventDelete(void *event, void *userParam);
@@ -43,16 +40,16 @@ protected:
     void EventDelete(AbstractEventCall *abstractEventCall);
     void EventDispatch(AbstractEventCall *abstractEventCall);
 
     void EventDelete(AbstractEventCall *abstractEventCall);
     void EventDispatch(AbstractEventCall *abstractEventCall);
 
-public:
+  public:
     explicit ThreadEventDispatcher();
     virtual ~ThreadEventDispatcher();
 
     void SetThread(Thread *thread);
 
     virtual void AddEventCall(AbstractEventCall *abstractEventCall);
     explicit ThreadEventDispatcher();
     virtual ~ThreadEventDispatcher();
 
     void SetThread(Thread *thread);
 
     virtual void AddEventCall(AbstractEventCall *abstractEventCall);
-    virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall, double dueTime);
+    virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall,
+                                   double dueTime);
 };
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 093e5b5..748b6da 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of abstract event call
  */
  * @version     1.0
  * @brief       This file is the implementation file of abstract event call
  */
+#include <stddef.h>
 #include <dpl/event/abstract_event_call.h>
 
 #include <dpl/event/abstract_event_call.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 AbstractEventCall::AbstractEventCall()
 AbstractEventCall::AbstractEventCall()
-{
-}
+{}
 
 AbstractEventCall::~AbstractEventCall()
 
 AbstractEventCall::~AbstractEventCall()
-{
-}
-
+{}
 }
 } // namespace DPL
 }
 } // namespace DPL
index 043e452..7c385a4 100644 (file)
  * @file        abstract_event_dispatcher.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        abstract_event_dispatcher.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of abstract event dispatcher
+ * @brief       This file is the implementation file of abstract event
+ * dispatcher
  */
  */
+#include <stddef.h>
 #include <dpl/event/abstract_event_dispatcher.h>
 
 #include <dpl/event/abstract_event_dispatcher.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 AbstractEventDispatcher::AbstractEventDispatcher()
 AbstractEventDispatcher::AbstractEventDispatcher()
-{
-}
+{}
 
 AbstractEventDispatcher::~AbstractEventDispatcher()
 
 AbstractEventDispatcher::~AbstractEventDispatcher()
-{
-}
-
+{}
 }
 } // namespace DPL
 }
 } // namespace DPL
index abb126e..337a39f 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of MVC controller
  */
  * @version     1.0
  * @brief       This file is the implementation file of MVC controller
  */
+#include <stddef.h>
 #include <dpl/event/controller.h>
 
 //
 #include <dpl/event/controller.h>
 
 //
index a90973c..5d0d382 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of MVC event listener
  */
  * @version     1.0
  * @brief       This file is the implementation file of MVC event listener
  */
+#include <stddef.h>
 #include <dpl/event/event_listener.h>
 
 //
 #include <dpl/event/event_listener.h>
 
 //
index 641b311..d2e643c 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of MVC event support
  */
  * @version     1.0
  * @brief       This file is the implementation file of MVC event support
  */
+#include <stddef.h>
 #include <dpl/event/event_support.h>
 
 #include <dpl/event/event_support.h>
 
-namespace DPL
-{
-namespace Event
-{
-
+namespace DPL {
+namespace Event {
 namespace // anonymous
 {
 int dummyInitializerProc()
 namespace // anonymous
 {
 int dummyInitializerProc()
@@ -35,9 +33,7 @@ int dummyInitializerProc()
 }
 
 int g_dummyInitializer = dummyInitializerProc();
 }
 
 int g_dummyInitializer = dummyInitializerProc();
-
 } // namespace anonymous
 } // namespace anonymous
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 2ad49b8..d0d6886 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of generic event call
  */
  * @version     1.0
  * @brief       This file is the implementation file of generic event call
  */
+#include <stddef.h>
 #include <dpl/event/generic_event_call.h>
 
 //
 #include <dpl/event/generic_event_call.h>
 
 //
index e1dfc52..07e3885 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of ICDelegate functionality
  */
  * @version     1.0
  * @brief       This file is the implementation file of ICDelegate functionality
  */
+#include <stddef.h>
 #include <dpl/event/inter_context_delegate.h>
 
 //
 #include <dpl/event/inter_context_delegate.h>
 
 //
index dc2de85..c860398 100644 (file)
  * @file        main_event_dispatcher.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        main_event_dispatcher.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of main event dispatcher for EFL
+ * @brief       This file is the implementation file of main event dispatcher
+ * for EFL
  */
  */
+#include <stddef.h>
 #include <dpl/event/main_event_dispatcher.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/singleton_impl.h>
 
 #include <dpl/event/main_event_dispatcher.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/singleton_impl.h>
 
-namespace DPL
-{
-
+namespace DPL {
 IMPLEMENT_SINGLETON(Event::MainEventDispatcher)
 
 IMPLEMENT_SINGLETON(Event::MainEventDispatcher)
 
-namespace Event
-{
-
+namespace Event {
 typedef Singleton<Event::MainEventDispatcher> MainEventDispatcherSingleton;
 
 namespace // anonymous
 typedef Singleton<Event::MainEventDispatcher> MainEventDispatcherSingleton;
 
 namespace // anonymous
@@ -60,30 +58,48 @@ MainEventDispatcher::MainEventDispatcher()
     LogPedantic("ECORE event class registered: " << m_eventId);
 
     // Register event class handler
     LogPedantic("ECORE event class registered: " << m_eventId);
 
     // Register event class handler
-    if ((m_eventCallHandler = ecore_event_handler_add(m_eventId, &StaticDispatchEvent, this)) == NULL)
+    if ((m_eventCallHandler =
+             ecore_event_handler_add(m_eventId, &StaticDispatchEvent,
+                                     this)) == NULL)
+    {
         ThrowMsg(Exception::CreateFailed, "Failed to register event handler!");
         ThrowMsg(Exception::CreateFailed, "Failed to register event handler!");
+    }
 
 
-    // Register cross event handler
-    m_crossEventCallHandler = ecore_main_fd_handler_add(m_crossEventCallInvoker.GetHandle(), ECORE_FD_READ, &StaticDispatchCrossInvoker, this, NULL, NULL);
+    // Allocate WaitableEvent
+    m_crossEventCallInvoker = new WaitableEvent();
 
 
-    if (m_crossEventCallHandler == NULL)
-        ThrowMsg(Exception::CreateFailed, "Failed to register cross event handler!");
+    // Register cross event handler
+    m_crossEventCallHandler = ecore_main_fd_handler_add(
+            m_crossEventCallInvoker->GetHandle(),
+            ECORE_FD_READ,
+            &StaticDispatchCrossInvoker,
+            this,
+            NULL,
+            NULL);
+
+    if (m_crossEventCallHandler == NULL) {
+        ThrowMsg(Exception::CreateFailed,
+                 "Failed to register cross event handler!");
+    }
 
     LogPedantic("ECORE cross-event handler registered");
 }
 
 MainEventDispatcher::~MainEventDispatcher()
 {
 
     LogPedantic("ECORE cross-event handler registered");
 }
 
 MainEventDispatcher::~MainEventDispatcher()
 {
-    // Remove event class handler
-    ecore_event_handler_del(m_eventCallHandler);
-    m_eventCallHandler = NULL;
-
     // Remove cross event handler
     ecore_main_fd_handler_del(m_crossEventCallHandler);
     m_crossEventCallHandler = NULL;
     // Remove cross event handler
     ecore_main_fd_handler_del(m_crossEventCallHandler);
     m_crossEventCallHandler = NULL;
-
     LogPedantic("ECORE cross-event handler unregistered");
 
     LogPedantic("ECORE cross-event handler unregistered");
 
+    // Remove m_crossEventCallInvoker
+    delete m_crossEventCallInvoker;
+    m_crossEventCallInvoker = NULL;
+
+    // Remove event class handler
+    ecore_event_handler_del(m_eventCallHandler);
+    m_eventCallHandler = NULL;
+
     // Decrement ECORE init count
     // We do not need ecore routines any more
     ecore_shutdown();
     // Decrement ECORE init count
     // We do not need ecore routines any more
     ecore_shutdown();
@@ -93,46 +109,72 @@ MainEventDispatcher::~MainEventDispatcher()
     g_lateMainEventDispatcher = NULL;
 }
 
     g_lateMainEventDispatcher = NULL;
 }
 
+void MainEventDispatcher::ResetCrossEventCallHandler()
+{
+    // Remove cross event handler
+    ecore_main_fd_handler_del(m_crossEventCallHandler);
+    m_crossEventCallHandler = NULL;
+    LogPedantic("ECORE cross-event handler unregistered");
+
+    // Re-allocate WaitableEvent
+    delete m_crossEventCallInvoker;
+    m_crossEventCallInvoker = new WaitableEvent();
+
+    // Register cross event handler
+    m_crossEventCallHandler =
+        ecore_main_fd_handler_add(m_crossEventCallInvoker->GetHandle(),
+                                  ECORE_FD_READ,
+                                  &StaticDispatchCrossInvoker,
+                                  this,
+                                  NULL,
+                                  NULL);
+
+    if (m_crossEventCallHandler == NULL) {
+        ThrowMsg(Exception::CreateFailed,
+                 "Failed to register cross event handler!");
+    }
+
+    LogPedantic("ECORE cross-event handler re-registered");
+}
+
 void MainEventDispatcher::StaticDeleteEvent(void *data, void *event)
 {
     LogPedantic("Static ECORE delete event handler");
 
     MainEventDispatcher *This = static_cast<MainEventDispatcher *>(data);
 void MainEventDispatcher::StaticDeleteEvent(void *data, void *event)
 {
     LogPedantic("Static ECORE delete event handler");
 
     MainEventDispatcher *This = static_cast<MainEventDispatcher *>(data);
-    AbstractEventCall *abstractEventCall = static_cast<AbstractEventCall *>(event);
+    AbstractEventCall *abstractEventCall =
+        static_cast<AbstractEventCall *>(event);
 
     Assert(This != NULL);
     Assert(abstractEventCall != NULL);
 
     // Late EFL event handling
 
     Assert(This != NULL);
     Assert(abstractEventCall != NULL);
 
     // Late EFL event handling
-    if (g_lateMainEventDispatcher == NULL)
-    {
+    if (g_lateMainEventDispatcher == NULL) {
         LogPedantic("WARNING: Late EFL event delete!");
         delete abstractEventCall;
         LogPedantic("WARNING: Late EFL event delete!");
         delete abstractEventCall;
-    }
-    else
-    {
+    } else {
         This->DeleteEvent(abstractEventCall);
     }
 }
 
         This->DeleteEvent(abstractEventCall);
     }
 }
 
-Eina_Bool MainEventDispatcher::StaticDispatchEvent(void *data, int type, void *event)
+Eina_Bool MainEventDispatcher::StaticDispatchEvent(void *data,
+                                                   int type,
+                                                   void *event)
 {
     LogPedantic("Static ECORE dispatch event");
 
     MainEventDispatcher *This = static_cast<MainEventDispatcher *>(data);
 {
     LogPedantic("Static ECORE dispatch event");
 
     MainEventDispatcher *This = static_cast<MainEventDispatcher *>(data);
-    AbstractEventCall *abstractEventCall = static_cast<AbstractEventCall *>(event);
+    AbstractEventCall *abstractEventCall =
+        static_cast<AbstractEventCall *>(event);
     (void)type;
 
     Assert(This != NULL);
     Assert(abstractEventCall != NULL);
 
     // Late EFL event handling
     (void)type;
 
     Assert(This != NULL);
     Assert(abstractEventCall != NULL);
 
     // Late EFL event handling
-    if (g_lateMainEventDispatcher == NULL)
-    {
+    if (g_lateMainEventDispatcher == NULL) {
         LogPedantic("WARNING: Late EFL event dispatch!");
         LogPedantic("WARNING: Late EFL event dispatch!");
-    }
-    else
-    {
+    } else {
         This->DispatchEvent(abstractEventCall);
     }
 
         This->DispatchEvent(abstractEventCall);
     }
 
@@ -153,26 +195,27 @@ Eina_Bool MainEventDispatcher::StaticDispatchTimedEvent(void *data)
     Assert(abstractEventCall != NULL);
 
     // Late EFL event handling
     Assert(abstractEventCall != NULL);
 
     // Late EFL event handling
-    if (g_lateMainEventDispatcher == NULL)
-    {
+    if (g_lateMainEventDispatcher == NULL) {
         LogPedantic("WARNING: Late EFL timed event dispatch!");
         LogPedantic("WARNING: Late EFL timed event dispatch!");
-    }
-    else
-    {
+    } else {
         // Dispatch timed event
         This->DispatchEvent(abstractEventCall);
     }
 
     // And delete manually event, because ECORE does not
     // use delete handler for timers
         // Dispatch timed event
         This->DispatchEvent(abstractEventCall);
     }
 
     // And delete manually event, because ECORE does not
     // use delete handler for timers
-    StaticDeleteEvent(static_cast<void *>(This), static_cast<void *>(abstractEventCall));
+    StaticDeleteEvent(static_cast<void *>(This),
+                      static_cast<void *>(abstractEventCall));
 
     // Do not continue timed event handlers
     // This also releases ECORE timer
     return ECORE_CALLBACK_CANCEL;
 }
 
 
     // Do not continue timed event handlers
     // This also releases ECORE timer
     return ECORE_CALLBACK_CANCEL;
 }
 
-Eina_Bool MainEventDispatcher::StaticDispatchCrossInvoker(void *data, Ecore_Fd_Handler *fd_handler)
+Eina_Bool MainEventDispatcher::StaticDispatchCrossInvoker(
+    void *data,
+    Ecore_Fd_Handler *
+    fd_handler)
 {
     LogPedantic("Static ECORE dispatch cross invoker");
 
 {
     LogPedantic("Static ECORE dispatch cross invoker");
 
@@ -182,12 +225,9 @@ Eina_Bool MainEventDispatcher::StaticDispatchCrossInvoker(void *data, Ecore_Fd_H
     Assert(This != NULL);
 
     // Late EFL event handling
     Assert(This != NULL);
 
     // Late EFL event handling
-    if (g_lateMainEventDispatcher == NULL)
-    {
+    if (g_lateMainEventDispatcher == NULL) {
         LogPedantic("WARNING: Late EFL cross invoker dispatch!");
         LogPedantic("WARNING: Late EFL cross invoker dispatch!");
-    }
-    else
-    {
+    } else {
         This->DispatchCrossInvoker();
     }
 
         This->DispatchCrossInvoker();
     }
 
@@ -208,7 +248,8 @@ void MainEventDispatcher::DispatchEvent(AbstractEventCall *abstractEventCall)
     abstractEventCall->Call();
 }
 
     abstractEventCall->Call();
 }
 
-void MainEventDispatcher::DispatchTimedEvent(AbstractEventCall *abstractEventCall)
+void MainEventDispatcher::DispatchTimedEvent(
+    AbstractEventCall *abstractEventCall)
 {
     LogPedantic("ECORE dispatch timed event");
 
 {
     LogPedantic("ECORE dispatch timed event");
 
@@ -225,21 +266,27 @@ void MainEventDispatcher::DispatchCrossInvoker()
 
     // Critical section
     {
 
     // Critical section
     {
-        m_crossEventCallInvoker.Reset();
+        m_crossEventCallInvoker->Reset();
         Mutex::ScopedLock lock(&m_crossEventCallMutex);
         m_wrappedCrossEventCallList.swap(stolenCrossEvents);
     }
 
         Mutex::ScopedLock lock(&m_crossEventCallMutex);
         m_wrappedCrossEventCallList.swap(stolenCrossEvents);
     }
 
-    LogPedantic("Cross-thread event list stolen. Number of events: " << stolenCrossEvents.size());
+    LogPedantic(
+        "Cross-thread event list stolen. Number of events: " <<
+        stolenCrossEvents.size());
 
     // Repush all stolen events
     WrappedEventCallList::const_iterator eventIterator;
 
 
     // Repush all stolen events
     WrappedEventCallList::const_iterator eventIterator;
 
-    for (eventIterator = stolenCrossEvents.begin(); eventIterator != stolenCrossEvents.end(); ++eventIterator)
+    for (eventIterator = stolenCrossEvents.begin();
+         eventIterator != stolenCrossEvents.end();
+         ++eventIterator)
     {
         // Unwrap events
         LogPedantic("Dispatching event from invoker");
     {
         // Unwrap events
         LogPedantic("Dispatching event from invoker");
-        InternalAddEvent(eventIterator->abstractEventCall, eventIterator->timed, eventIterator->dueTime);
+        InternalAddEvent(eventIterator->abstractEventCall,
+                         eventIterator->timed,
+                         eventIterator->dueTime);
     }
 
     LogPedantic("Cross-thread events dispatched");
     }
 
     LogPedantic("Cross-thread events dispatched");
@@ -247,74 +294,78 @@ void MainEventDispatcher::DispatchCrossInvoker()
 
 void MainEventDispatcher::AddEventCall(AbstractEventCall *abstractEventCall)
 {
 
 void MainEventDispatcher::AddEventCall(AbstractEventCall *abstractEventCall)
 {
-    if (pthread_equal(pthread_self(), g_threadMain))
-    {
+    if (pthread_equal(pthread_self(), g_threadMain)) {
         LogPedantic("Main thread ECORE event push");
         InternalAddEvent(abstractEventCall, false, 0.0);
         LogPedantic("Main thread ECORE event push");
         InternalAddEvent(abstractEventCall, false, 0.0);
-    }
-    else
-    {
+    } else {
         LogPedantic("Cross-thread ECORE event push");
 
         // Push event to cross event list
         {
             Mutex::ScopedLock lock(&m_crossEventCallMutex);
         LogPedantic("Cross-thread ECORE event push");
 
         // Push event to cross event list
         {
             Mutex::ScopedLock lock(&m_crossEventCallMutex);
-            m_wrappedCrossEventCallList.push_back(WrappedEventCall(abstractEventCall, false, 0.0));
-            m_crossEventCallInvoker.Signal();
+            m_wrappedCrossEventCallList.push_back(WrappedEventCall(
+                                                      abstractEventCall, false,
+                                                      0.0));
+            m_crossEventCallInvoker->Signal();
         }
 
         LogPedantic("Event pushed to cross-thread event list");
     }
 }
 
         }
 
         LogPedantic("Event pushed to cross-thread event list");
     }
 }
 
-void MainEventDispatcher::AddTimedEventCall(AbstractEventCall *abstractEventCall, double dueTime)
+void MainEventDispatcher::AddTimedEventCall(
+    AbstractEventCall *abstractEventCall,
+    double dueTime)
 {
 {
-    if (pthread_equal(pthread_self(), g_threadMain))
-    {
+    if (pthread_equal(pthread_self(), g_threadMain)) {
         LogPedantic("Main thread timed ECORE event push");
         InternalAddEvent(abstractEventCall, true, dueTime);
         LogPedantic("Main thread timed ECORE event push");
         InternalAddEvent(abstractEventCall, true, dueTime);
-    }
-    else
-    {
+    } else {
         LogPedantic("Cross-thread timed ECORE event push");
 
         // Push event to cross event list
         {
             Mutex::ScopedLock lock(&m_crossEventCallMutex);
         LogPedantic("Cross-thread timed ECORE event push");
 
         // Push event to cross event list
         {
             Mutex::ScopedLock lock(&m_crossEventCallMutex);
-            m_wrappedCrossEventCallList.push_back(WrappedEventCall(abstractEventCall, true, dueTime));
-            m_crossEventCallInvoker.Signal();
+            m_wrappedCrossEventCallList.push_back(WrappedEventCall(
+                                                      abstractEventCall, true,
+                                                      dueTime));
+            m_crossEventCallInvoker->Signal();
         }
 
         LogPedantic("Event pushed to cross-thread event list");
     }
 }
 
         }
 
         LogPedantic("Event pushed to cross-thread event list");
     }
 }
 
-void MainEventDispatcher::InternalAddEvent(AbstractEventCall *abstractEventCall, bool timed, double dueTime)
+void MainEventDispatcher::InternalAddEvent(AbstractEventCall *abstractEventCall,
+                                           bool timed,
+                                           double dueTime)
 {
     LogPedantic("Adding base event");
 
 {
     LogPedantic("Adding base event");
 
-    if (timed == true)
-    {
+    if (timed == true) {
         // Push timed event onto ecore stack
         // Push timed event onto ecore stack
-        TimedEventStruct* eventData = new TimedEventStruct(abstractEventCall, this);
-        Ecore_Timer *timedEvent = ecore_timer_add(dueTime, &StaticDispatchTimedEvent, eventData);
+        TimedEventStruct* eventData = new TimedEventStruct(abstractEventCall,
+                                                           this);
+        Ecore_Timer *timedEvent = ecore_timer_add(dueTime,
+                                                  &StaticDispatchTimedEvent,
+                                                  eventData);
 
 
-        if (timedEvent == NULL)
-        {
+        if (timedEvent == NULL) {
             delete eventData;
             delete abstractEventCall;
             delete eventData;
             delete abstractEventCall;
-            ThrowMsg(Exception::AddTimedEventFailed, "Failed to add ECORE timed event");
+            ThrowMsg(Exception::AddTimedEventFailed,
+                     "Failed to add ECORE timed event");
         }
 
         LogPedantic("Timed wrapped event added");
         }
 
         LogPedantic("Timed wrapped event added");
-    }
-    else
-    {
+    } else {
         // Push immediate event onto ecore stack
         // Push immediate event onto ecore stack
-        Ecore_Event *event = ecore_event_add(m_eventId, abstractEventCall, &StaticDeleteEvent, this);
+        Ecore_Event *event = ecore_event_add(m_eventId,
+                                             abstractEventCall,
+                                             &StaticDeleteEvent,
+                                             this);
 
 
-        if (event == NULL)
-        {
+        if (event == NULL) {
             delete abstractEventCall;
             ThrowMsg(Exception::AddEventFailed, "Failed to add ECORE event");
         }
             delete abstractEventCall;
             ThrowMsg(Exception::AddEventFailed, "Failed to add ECORE event");
         }
@@ -327,6 +378,5 @@ MainEventDispatcher& GetMainEventDispatcherInstance()
 {
     return MainEventDispatcherSingleton::Instance();
 }
 {
     return MainEventDispatcherSingleton::Instance();
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index a2e951d..58e9a1b 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of model
  */
  * @version     1.0
  * @brief       This file is the implementation file of model
  */
+#include <stddef.h>
 #include <dpl/event/model.h>
 
 #include <dpl/event/model.h>
 
-namespace DPL
-{
-namespace Event
-{
+namespace DPL {
+namespace Event {
 Model::~Model()
 Model::~Model()
-{
-}
+{}
 }
 } // namespace DPL
 }
 } // namespace DPL
index fa155bc..7da99a2 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of thread event dispatcher
  */
  * @version     1.0
  * @brief       This file is the implementation file of thread event dispatcher
  */
+#include <stddef.h>
 #include <dpl/event/thread_event_dispatcher.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 
 #include <dpl/event/thread_event_dispatcher.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-namespace Event
-{
-
-ThreadEventDispatcher::ThreadEventDispatcher()
-    : m_thread(NULL)
-{
-}
+namespace DPL {
+namespace Event {
+ThreadEventDispatcher::ThreadEventDispatcher() :
+    m_thread(NULL)
+{}
 
 ThreadEventDispatcher::~ThreadEventDispatcher()
 
 ThreadEventDispatcher::~ThreadEventDispatcher()
-{
-}
+{}
 
 void ThreadEventDispatcher::SetThread(Thread *thread)
 {
 
 void ThreadEventDispatcher::SetThread(Thread *thread)
 {
@@ -44,8 +40,10 @@ void ThreadEventDispatcher::SetThread(Thread *thread)
 
 void ThreadEventDispatcher::StaticEventDelete(void *event, void *userParam)
 {
 
 void ThreadEventDispatcher::StaticEventDelete(void *event, void *userParam)
 {
-    AbstractEventCall *abstractEventCall = static_cast<AbstractEventCall *>(event);
-    ThreadEventDispatcher *This = static_cast<ThreadEventDispatcher *>(userParam);
+    AbstractEventCall *abstractEventCall =
+        static_cast<AbstractEventCall *>(event);
+    ThreadEventDispatcher *This =
+        static_cast<ThreadEventDispatcher *>(userParam);
 
     LogPedantic("Received static event delete from thread");
 
 
     LogPedantic("Received static event delete from thread");
 
@@ -57,8 +55,10 @@ void ThreadEventDispatcher::StaticEventDelete(void *event, void *userParam)
 
 void ThreadEventDispatcher::StaticEventDispatch(void *event, void *userParam)
 {
 
 void ThreadEventDispatcher::StaticEventDispatch(void *event, void *userParam)
 {
-    AbstractEventCall *abstractEventCall = static_cast<AbstractEventCall *>(event);
-    ThreadEventDispatcher *This = static_cast<ThreadEventDispatcher *>(userParam);
+    AbstractEventCall *abstractEventCall =
+        static_cast<AbstractEventCall *>(event);
+    ThreadEventDispatcher *This =
+        static_cast<ThreadEventDispatcher *>(userParam);
 
     LogPedantic("Received static event dispatch from thread");
 
 
     LogPedantic("Received static event dispatch from thread");
 
@@ -88,10 +88,15 @@ void ThreadEventDispatcher::AddEventCall(AbstractEventCall *abstractEventCall)
     LogPedantic("Adding event to thread event loop");
 
     // Call abstract event call in dedicated thread
     LogPedantic("Adding event to thread event loop");
 
     // Call abstract event call in dedicated thread
-    m_thread->PushEvent(abstractEventCall, &StaticEventDispatch, &StaticEventDelete, this);
+    m_thread->PushEvent(abstractEventCall,
+                        &StaticEventDispatch,
+                        &StaticEventDelete,
+                        this);
 }
 
 }
 
-void ThreadEventDispatcher::AddTimedEventCall(AbstractEventCall *abstractEventCall, double dueTime)
+void ThreadEventDispatcher::AddTimedEventCall(
+    AbstractEventCall *abstractEventCall,
+    double dueTime)
 {
     // Thread must be set prior to call
     Assert(m_thread != NULL);
 {
     // Thread must be set prior to call
     Assert(m_thread != NULL);
@@ -99,8 +104,11 @@ void ThreadEventDispatcher::AddTimedEventCall(AbstractEventCall *abstractEventCa
     LogPedantic("Adding timed event to thread event loop");
 
     // Call abstract event call in dedicated thread
     LogPedantic("Adding timed event to thread event loop");
 
     // Call abstract event call in dedicated thread
-    m_thread->PushTimedEvent(abstractEventCall, dueTime, &StaticEventDispatch, &StaticEventDelete, this);
+    m_thread->PushTimedEvent(abstractEventCall,
+                             dueTime,
+                             &StaticEventDispatch,
+                             &StaticEventDelete,
+                             this);
 }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index 5f52e6f..80f77c4 100644 (file)
@@ -20,8 +20,8 @@
 #
 
 SET(DPL_LOCALIZATION_SOURCES
 #
 
 SET(DPL_LOCALIZATION_SOURCES
-    ${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp
     ${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp
+    ${PROJECT_SOURCE_DIR}/modules/localization/src/LanguageTagsProvider.cpp
     PARENT_SCOPE
 )
 
     PARENT_SCOPE
 )
 
@@ -29,6 +29,7 @@ SET(DPL_LOCALIZATION_SOURCES
 SET(DPL_LOCALIZATION_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/localization/include/dpl/localization/localization_utils.h
     ${PROJECT_SOURCE_DIR}/modules/localization/include/dpl/localization/w3c_file_localization.h
 SET(DPL_LOCALIZATION_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/localization/include/dpl/localization/localization_utils.h
     ${PROJECT_SOURCE_DIR}/modules/localization/include/dpl/localization/w3c_file_localization.h
+    ${PROJECT_SOURCE_DIR}/modules/localization/include/LanguageTagsProvider.h
     PARENT_SCOPE
 )
 
     PARENT_SCOPE
 )
 
diff --git a/modules/localization/include/LanguageTagsProvider.h b/modules/localization/include/LanguageTagsProvider.h
new file mode 100644 (file)
index 0000000..529101f
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    LanguageTagsProvider.h
+ * @author  Marcin Kaminski (marcin.ka@samsung.com)
+ * @version 1.0
+ */
+
+#ifndef LANGUAGETAGSPROVIDER_H
+#define LANGUAGETAGSPROVIDER_H
+
+#include <dpl/optional.h>
+#include <dpl/string.h>
+#include <dpl/singleton.h>
+#include <list>
+
+typedef std::list<DPL::String> LanguageTags;
+
+class LanguageTagsProvider
+{
+  public:
+    /*
+     * Get list of currently set language tags
+     */
+    const LanguageTags getLanguageTags() const;
+
+    /*
+     * Set new language tags (other than based on system locales)
+     */
+    void setLanguageTags(const LanguageTags& taglist);
+
+    /*
+     * Set language tags from given locales.
+     * Supported format is: xx[-yy[-zz]][.encoding]
+     */
+    void setLanguageTagsFromLocales(const char* locales);
+
+    /*
+     * Set language tags based on system language settings
+     */
+    void resetLanguageTags();
+
+    /*
+     * Adds default widget locales to language tags if
+     * it doesn't exist within actual tags.
+     * Default locales i added:
+     * - at the beginning if less then 2 tags exists on list
+     * - just before empty ("") locales - pre-last position
+     * - at the end if last position is not empty locale
+     */
+    void addWidgetDefaultLocales(const DPL::String&);
+
+    /*
+     * Function converts language tag string (i.e. en-US)
+     * into locales string (en_US).
+     */
+    static DPL::String BCP47LanguageTagToLocale(const DPL::String&);
+
+    /*
+     * Function converts locales string (i.e. en_US.UTF-8) into language tag
+     * (i.e. en-US)
+     */
+    static DPL::String LocaleToBCP47LanguageTag(const DPL::String&);
+
+  private:
+    friend class DPL::Singleton<LanguageTagsProvider>;
+
+    LanguageTags m_languageTagsList;
+
+    LanguageTagsProvider();
+    virtual ~LanguageTagsProvider();
+
+    void loadSystemTags();
+    void createTagsFromLocales(const char* language);
+};
+
+typedef DPL::Singleton<LanguageTagsProvider> LanguageTagsProviderSingleton;
+
+#endif /* LANGUAGETAGSPROVIDER_H */
index 6779fd5..66a232d 100644 (file)
@@ -39,8 +39,7 @@ struct WidgetIcon
     WidgetIcon() :
         width(DPL::Optional<int>::Null),
         height(DPL::Optional<int>::Null)
     WidgetIcon() :
         width(DPL::Optional<int>::Null),
         height(DPL::Optional<int>::Null)
-    {
-    }
+    {}
 
     /*
      * a valid URI to an image file inside the widget package that represents an
 
     /*
      * a valid URI to an image file inside the widget package that represents an
@@ -73,18 +72,6 @@ struct WidgetStartFileInfo
 };
 
 typedef DPL::Optional<WidgetIcon> OptionalWidgetIcon;
 };
 
 typedef DPL::Optional<WidgetIcon> OptionalWidgetIcon;
-typedef std::list<DPL::String> LanguageTagsList;
 typedef DPL::Optional<WidgetStartFileInfo> OptionalWidgetStartFileInfo;
 
 typedef DPL::Optional<WidgetStartFileInfo> OptionalWidgetStartFileInfo;
 
-namespace LocalizationUtils {
-DPL::String BCP47LanguageTagToLocale(const DPL::String&);
-DPL::String LocaleToBCP47LanguageTag(const DPL::String&);
-
-void SetUserLanguageTags(const LanguageTagsList& tags);
-void SetSystemLanguageTags(const LanguageTagsList& tags);
-LanguageTagsList GetUserAgentLanguageTags();
-
-void Initialize();
-}
-
 #endif //LOCALIZATION_UTILS_H
 #endif //LOCALIZATION_UTILS_H
index d52bd6c..4f6aa1d 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef W3C_FILE_LOCALIZATION_H
 #define W3C_FILE_LOCALIZATION_H
 
 #ifndef W3C_FILE_LOCALIZATION_H
 #define W3C_FILE_LOCALIZATION_H
 
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/optional.h>
 #include <dpl/string.h>
 #include <list>
 #include <dpl/optional.h>
 #include <dpl/string.h>
 #include <list>
@@ -36,25 +36,51 @@ namespace W3CFileLocalization {
 typedef std::list<WidgetIcon> WidgetIconList;
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
 typedef std::list<WidgetIcon> WidgetIconList;
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags,
-        const DPL::String &url);
+    WrtDB::DbWidgetHandle widgetHandle,
+    const DPL::String &url);
+DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
+    const WrtDB::WidgetPkgName &pkgname,
+    const DPL::String &url);
+DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
+    WrtDB::WidgetDAOReadOnlyPtr dao,
+    const DPL::String &url);
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackage(
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackage(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags,
-        const DPL::String& file);
+    WrtDB::DbWidgetHandle widgetHandle,
+    const DPL::String& file);
+DPL::Optional<DPL::String> getFilePathInWidgetPackage(
+    const WrtDB::WidgetPkgName &pkgname,
+    const DPL::String& file);
+DPL::Optional<DPL::String> getFilePathInWidgetPackage(
+    WrtDB::WidgetDAOReadOnlyPtr dao,
+    const DPL::String& file);
+
+DPL::OptionalString getStartFile(WrtDB::DbWidgetHandle handle);
+DPL::OptionalString getStartFile(const WrtDB::WidgetPkgName & pkgname);
+DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao);
 
 
-DPL::OptionalString getStartFile(WrtDB::DbWidgetHandle widgetHandle);
 OptionalWidgetIcon getIcon(WrtDB::DbWidgetHandle widgetHandle);
 OptionalWidgetIcon getIcon(WrtDB::DbWidgetHandle widgetHandle);
+OptionalWidgetIcon getIcon(const WrtDB::WidgetPkgName & pkgname);
+OptionalWidgetIcon getIcon(WrtDB::WidgetDAOReadOnlyPtr dao);
+
 WidgetIconList getValidIconsList(
 WidgetIconList getValidIconsList(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags);
+    WrtDB::DbWidgetHandle widgetHandle);
+WidgetIconList getValidIconsList(
+    const WrtDB::WidgetPkgName &pkgname);
+WidgetIconList getValidIconsList(
+    WrtDB::WidgetDAOReadOnlyPtr dao);
 
 OptionalWidgetStartFileInfo getStartFileInfo(
 
 OptionalWidgetStartFileInfo getStartFileInfo(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &tagsList);
+    WrtDB::DbWidgetHandle widgetHandle);
+OptionalWidgetStartFileInfo getStartFileInfo(
+    const WrtDB::WidgetPkgName &pkgname);
+OptionalWidgetStartFileInfo getStartFileInfo(
+    WrtDB::WidgetDAOReadOnlyPtr dao);
+
 WrtDB::WidgetLocalizedInfo getLocalizedInfo(WrtDB::DbWidgetHandle widgetHandle);
 WrtDB::WidgetLocalizedInfo getLocalizedInfo(WrtDB::DbWidgetHandle widgetHandle);
+WrtDB::WidgetLocalizedInfo getLocalizedInfo(
+    const WrtDB::WidgetPkgName & pkgname);
+WrtDB::WidgetLocalizedInfo getLocalizedInfo(WrtDB::WidgetDAOReadOnlyPtr dao);
 }
 
 #endif //W3C_FILE_LOCALIZATION_H
 }
 
 #endif //W3C_FILE_LOCALIZATION_H
diff --git a/modules/localization/src/LanguageTagsProvider.cpp b/modules/localization/src/LanguageTagsProvider.cpp
new file mode 100644 (file)
index 0000000..fcf2077
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    LanguageTagsProvider.cpp
+ * @author  Marcin Kaminski (marcin.ka@samsung.com)
+ * @version 1.0
+ */
+#include <stddef.h>
+#include "LanguageTagsProvider.h"
+
+#include <dpl/log/log.h>
+#include <vconf.h>
+#include <algorithm>
+#include <iostream>
+#include <cassert>
+#include <dpl/singleton_impl.h>
+IMPLEMENT_SINGLETON(LanguageTagsProvider)
+
+/* ========== public ========== */
+const LanguageTags LanguageTagsProvider::getLanguageTags() const
+{
+    return m_languageTagsList;
+}
+
+void LanguageTagsProvider::setLanguageTags(const LanguageTags& taglist)
+{
+    m_languageTagsList = taglist;
+    /* If given list does not contain default value (empty string)
+     * than append it to the list.
+     * In case of empty list given as parameter only default value
+     * will exist on m_languageTagsList. */
+    DPL::String tofind = L"";
+    if (std::find(m_languageTagsList.begin(), m_languageTagsList.end(),
+                  tofind) == m_languageTagsList.end())
+    {
+        m_languageTagsList.push_back(L"");
+    }
+}
+
+void LanguageTagsProvider::setLanguageTagsFromLocales(const char* locales)
+{
+    LogDebug("Setting new language tags for locales " << locales);
+    this->createTagsFromLocales(locales);
+}
+
+void LanguageTagsProvider::resetLanguageTags()
+{
+    this->loadSystemTags();
+}
+
+void LanguageTagsProvider::addWidgetDefaultLocales(
+    const DPL::String& defaultLocale)
+{
+    if (defaultLocale.size() > 0 &&
+        std::find(m_languageTagsList.begin(), m_languageTagsList.end(),
+                  defaultLocale) == m_languageTagsList.end())
+    {
+        if (m_languageTagsList.size() < 2) {
+            m_languageTagsList.push_front(defaultLocale);
+        } else {
+            LanguageTags::iterator placeToInsert = m_languageTagsList.end();
+            --placeToInsert;
+            if (*placeToInsert != L"") {
+                ++placeToInsert;
+            }
+            m_languageTagsList.insert(placeToInsert, defaultLocale);
+        }
+    }
+}
+
+DPL::String LanguageTagsProvider::BCP47LanguageTagToLocale(
+    const DPL::String& inLanguageTag)
+{
+    DPL::String languageTag(inLanguageTag);
+    /* Replace all */
+    std::replace(languageTag.begin(), languageTag.end(), '-', '_');
+    return languageTag;
+}
+
+DPL::String LanguageTagsProvider::LocaleToBCP47LanguageTag(
+    const DPL::String& inLocaleString)
+{
+    /* Cut off codepage information from given string (if any exists)
+     * i.e. change en_US.UTF-8 into en_US */
+    DPL::String localeString = inLocaleString.substr(
+            0, inLocaleString.find_first_of(L"."));
+    /* Replace all '_' with '-' */
+    std::replace(localeString.begin(), localeString.end(), '_', '-');
+    return localeString;
+}
+
+/* ========== private ========== */
+LanguageTagsProvider::LanguageTagsProvider()
+{
+    LogDebug("Creating LanguageTagsProvider instance");
+    this->loadSystemTags();
+}
+
+LanguageTagsProvider::~LanguageTagsProvider()
+{}
+
+void LanguageTagsProvider::loadSystemTags()
+{
+    char* language = vconf_get_str(VCONFKEY_LANGSET);
+    if (!language) {
+        LogError("Failed to get language from vconf");
+    } else {
+        LogDebug("Language fetched from vconf: " << language);
+    }
+    createTagsFromLocales(language);
+    free(language);
+}
+
+void LanguageTagsProvider::createTagsFromLocales(const char* language)
+{
+    m_languageTagsList.clear();
+    if (!language) {
+        LogDebug("Setting default language tags");
+        /* If NULL language given than set default language tags
+         * and return. */
+        m_languageTagsList.push_back(L"");
+        return;
+    }
+
+    LogDebug("Setting tags for language: " << language);
+    DPL::String langdescr =
+        LocaleToBCP47LanguageTag(DPL::FromUTF8String(language));
+
+    size_t position;
+    if (langdescr.empty()) {
+        LogError("Empty language description while correct value needed");
+    } else {
+        /* Language tags list should not be cleared before this place to
+         * avoid losing current data when new data are invalid */
+        while (true) {
+            LogDebug("Processing language description: " << langdescr);
+            m_languageTagsList.push_back(langdescr);
+
+            position = langdescr.find_last_of(L"-");
+            if (position == DPL::String::npos) {
+                break;
+            }
+            langdescr = langdescr.substr(0, position);
+        }
+    }
+    /* Add empty tag for non-localized content */
+    m_languageTagsList.push_back(L"");
+}
index 9a63800..6298a5c 100644 (file)
 
 #include <dpl/localization/localization_utils.h>
 
 
 #include <dpl/localization/localization_utils.h>
 
-#include <appcore-efl.h>
-#include <vconf.h>
-#include <dpl/framework_efl.h>
-
 #include <dpl/foreach.h>
 #include <dpl/mutex.h>
 #include <dpl/foreach.h>
 #include <dpl/mutex.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-
-namespace {
-
-static int LanguageChanged(void *)
-{
-    char* lang = vconf_get_str(VCONFKEY_LANGSET);
-    if (!lang) {
-        LogError("Cannot get locale settings from vconf");
-        return 0;
-    }
-    LogDebug("Language set to: " << lang);
-
-    using namespace LocalizationUtils;
-
-    LanguageTagsList list;
-    list.push_back(DPL::FromUTF8String(lang));
-    SetSystemLanguageTags(list);
-
-    LogDebug("LanguageChanged to " << lang);
-
-    return 0;
-}
-}
 
 namespace LocalizationUtils {
 static LanguageTagsList m_systemLanguageTags;
 
 namespace LocalizationUtils {
 static LanguageTagsList m_systemLanguageTags;
-static LanguageTagsList m_userLanguageTags;
 static LanguageTagsList m_languageTags;
 static DPL::ReadWriteMutex m_readWriteMutex;
 
 template<typename StringType>
 void FindAndReplace(StringType& source,
 static LanguageTagsList m_languageTags;
 static DPL::ReadWriteMutex m_readWriteMutex;
 
 template<typename StringType>
 void FindAndReplace(StringType& source,
-        const StringType& find,
-        const StringType& replace)
+                    const StringType& find,
+                    const StringType& replace)
 {
     size_t pos = 0;
     while ((pos = source.find(find, pos)) != StringType::npos) {
 {
     size_t pos = 0;
     while ((pos = source.find(find, pos)) != StringType::npos) {
@@ -92,16 +63,14 @@ void UpdateUserAgentLanguageTags()
     // WARNING!!!!!  This function shall be called
     // only when mutex is locked in readWriteMode!
 
     // WARNING!!!!!  This function shall be called
     // only when mutex is locked in readWriteMode!
 
-    LanguageTagsList list = m_userLanguageTags;
-    list.insert(list.begin(),
-                m_systemLanguageTags.begin(),
-                m_systemLanguageTags.end());
     m_languageTags.clear();
 
     m_languageTags.clear();
 
-    FOREACH(i, list) {
+    FOREACH(i, m_systemLanguageTags) {
         DPL::String tag = LocaleToBCP47LanguageTag(*i);
         while (true) { //W3C Packaging 9. Step 5. 2. D
         DPL::String tag = LocaleToBCP47LanguageTag(*i);
         while (true) { //W3C Packaging 9. Step 5. 2. D
-            if (tag.empty()) { continue; }
+            if (tag.empty()) {
+                continue;
+            }
 
             LogDebug("Adding user locale '" << tag << "'");
             m_languageTags.push_back(tag);
 
             LogDebug("Adding user locale '" << tag << "'");
             m_languageTags.push_back(tag);
@@ -118,15 +87,6 @@ void UpdateUserAgentLanguageTags()
     m_languageTags.push_back(L"");
 }
 
     m_languageTags.push_back(L"");
 }
 
-void SetUserLanguageTags(const LanguageTagsList& tags)
-{
-    DPL::ReadWriteMutex::ScopedWriteLock lock(&m_readWriteMutex);
-    if (m_userLanguageTags != tags) {
-        m_userLanguageTags = tags;
-        UpdateUserAgentLanguageTags();
-    }
-}
-
 void SetSystemLanguageTags(const LanguageTagsList& tags)
 {
     DPL::ReadWriteMutex::ScopedWriteLock lock(&m_readWriteMutex);
 void SetSystemLanguageTags(const LanguageTagsList& tags)
 {
     DPL::ReadWriteMutex::ScopedWriteLock lock(&m_readWriteMutex);
@@ -141,15 +101,4 @@ LanguageTagsList GetUserAgentLanguageTags()
     DPL::ReadWriteMutex::ScopedReadLock lock(&m_readWriteMutex);
     return m_languageTags;
 }
     DPL::ReadWriteMutex::ScopedReadLock lock(&m_readWriteMutex);
     return m_languageTags;
 }
-
-void Initialize()
-{
-    appcore_set_event_callback(
-        APPCORE_EVENT_LANG_CHANGE,
-        &LanguageChanged,
-        NULL);
-
-    LanguageChanged(NULL); // updating language for the first time
-}
-
 }
 }
index bb41c5d..75a6bf2 100644 (file)
  * @author  Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version 1.0
  */
  * @author  Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @version 1.0
  */
-
+#include <stddef.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <assert.h>
 
 #include <dpl/localization/w3c_file_localization.h>
 
 
 #include <dpl/localization/w3c_file_localization.h>
 
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/localization/localization_utils.h>
 
 #include <dpl/log/log.h>
 #include <dpl/localization/localization_utils.h>
 
 #include <dpl/log/log.h>
 #include <dpl/optional.h>
 #include <dpl/foreach.h>
 
 #include <dpl/optional.h>
 #include <dpl/foreach.h>
 
+#include <LanguageTagsProvider.h>
+
 using namespace WrtDB;
 
 namespace {
 const DPL::String FILE_URI_BEGIN = L"file://";
 const DPL::String WIDGET_URI_BEGIN = L"widget://";
 using namespace WrtDB;
 
 namespace {
 const DPL::String FILE_URI_BEGIN = L"file://";
 const DPL::String WIDGET_URI_BEGIN = L"widget://";
+const DPL::String LOCALE_PREFIX = L"locales/";
 
 DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
 
 DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
-        const LanguageTagsList &tags,
-        const std::string& basePath,
-        std::string filePath)
+    const std::string& basePath,
+    std::string filePath)
 {
     LogDebug("Looking for file: " << filePath << "  in: " << basePath);
 {
     LogDebug("Looking for file: " << filePath << "  in: " << basePath);
-    using namespace LocalizationUtils;
+
+    const LanguageTags& ltags =
+        LanguageTagsProviderSingleton::Instance().getLanguageTags();
 
     //Check if string isn't empty
 
     //Check if string isn't empty
-    if (filePath.size() == 0) { return DPL::Optional<std::string>::Null; }
+    if (filePath.size() == 0) {
+        return DPL::Optional<std::string>::Null;
+    }
     //Removing preceding '/'
     //Removing preceding '/'
-    if (filePath[0] == '/') { filePath.erase(0, 1); }
+    if (filePath[0] == '/') {
+        filePath.erase(0, 1);
+    }
+    // In some cases (start file localization) url has unnecessary "/" at the
+    // end
+    if (filePath[filePath.size() - 1] == '/') {
+        filePath.erase(filePath.size() - 1, 1);
+    }
     //Check if string isn't empty
     //Check if string isn't empty
-    if (filePath.size() == 0) { return DPL::Optional<std::string>::Null; }
+    if (filePath.size() == 0) {
+        return DPL::Optional<std::string>::Null;
+    }
 
 
-    LogDebug("locales size = " << tags.size());
-    for (LanguageTagsList::const_iterator it = tags.begin();
-         it != tags.end();
-         ++it) {
+    LogDebug("locales size = " << ltags.size());
+    for (LanguageTags::const_iterator it = ltags.begin();
+         it != ltags.end();
+         ++it)
+    {
         LogDebug("Trying locale: " << *it);
         std::string path = basePath;
         if (path[path.size() - 1] == '/') {
         LogDebug("Trying locale: " << *it);
         std::string path = basePath;
         if (path[path.size() - 1] == '/') {
@@ -84,13 +101,11 @@ DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
 }
 
 DPL::Optional<DPL::String> GetFilePathInWidgetPackageInternal(
 }
 
 DPL::Optional<DPL::String> GetFilePathInWidgetPackageInternal(
-        const LanguageTagsList &languageTags,
-        const DPL::String& basePath,
-        const DPL::String& filePath)
+    const DPL::String& basePath,
+    const DPL::String& filePath)
 {
     DPL::Optional<std::string> path =
 {
     DPL::Optional<std::string> path =
-        GetFilePathInWidgetPackageInternal(languageTags,
-                                           DPL::ToUTF8String(basePath),
+        GetFilePathInWidgetPackageInternal(DPL::ToUTF8String(basePath),
                                            DPL::ToUTF8String(filePath));
     DPL::Optional<DPL::String> dplPath;
     if (!!path) {
                                            DPL::ToUTF8String(filePath));
     DPL::Optional<DPL::String> dplPath;
     if (!!path) {
@@ -102,29 +117,54 @@ DPL::Optional<DPL::String> GetFilePathInWidgetPackageInternal(
 
 namespace W3CFileLocalization {
 DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
 
 namespace W3CFileLocalization {
 DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
-        DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags,
-        const DPL::String &url)
+    DbWidgetHandle widgetHandle,
+    const DPL::String &url)
+{
+    return getFilePathInWidgetPackageFromUrl(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)),
+               url);
+}
+
+DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
+    const WrtDB::WidgetPkgName &pkgname,
+    const DPL::String &url)
+{
+    return getFilePathInWidgetPackageFromUrl(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)),
+               url);
+}
+
+DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
+    WrtDB::WidgetDAOReadOnlyPtr dao,
+    const DPL::String &url)
 {
     DPL::String req = url;
 {
     DPL::String req = url;
-    WidgetDAO dao(widgetHandle);
 
     if (req.find(WIDGET_URI_BEGIN) == 0) {
         req.erase(0, WIDGET_URI_BEGIN.length());
     } else if (req.find(FILE_URI_BEGIN) == 0) {
         req.erase(0, FILE_URI_BEGIN.length());
 
     if (req.find(WIDGET_URI_BEGIN) == 0) {
         req.erase(0, WIDGET_URI_BEGIN.length());
     } else if (req.find(FILE_URI_BEGIN) == 0) {
         req.erase(0, FILE_URI_BEGIN.length());
-        if (req.find(dao.getPath()) == 0) {
-            req.erase(0, dao.getPath().length());
+        if (req.find(dao->getPath()) == 0) {
+            req.erase(0, dao->getPath().length());
+        }
+        if (req.find(LOCALE_PREFIX) == 0) {
+            req.erase(0, LOCALE_PREFIX.length());
+            size_t position = req.find('/');
+            // should always be >0 as correct locales path is
+            // always locales/xx/ or locales/xx-XX/
+            if (position != std::string::npos && position > 0) {
+                req.erase(0, position + 1);
+            }
         }
     } else {
         LogDebug("Unknown path format, ignoring");
         return DPL::Optional<DPL::String>::Null;
     }
 
         }
     } else {
         LogDebug("Unknown path format, ignoring");
         return DPL::Optional<DPL::String>::Null;
     }
 
-    auto widgetPath = dao.getPath();
+    auto widgetPath = dao->getPath();
 
     DPL::Optional<DPL::String> found =
 
     DPL::Optional<DPL::String> found =
-        GetFilePathInWidgetPackageInternal(languageTags, widgetPath, req);
+        GetFilePathInWidgetPackageInternal(widgetPath, req);
 
     if (!found) {
         LogError("Path not found within current locale in current widget");
 
     if (!found) {
         LogError("Path not found within current locale in current widget");
@@ -137,25 +177,49 @@ DPL::Optional<DPL::String> getFilePathInWidgetPackageFromUrl(
 }
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackage(
 }
 
 DPL::Optional<DPL::String> getFilePathInWidgetPackage(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags,
-        const DPL::String& file)
+    WrtDB::DbWidgetHandle widgetHandle,
+    const DPL::String& file)
+{
+    return getFilePathInWidgetPackage(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)),
+               file);
+}
+
+DPL::Optional<DPL::String> getFilePathInWidgetPackage(
+    const WrtDB::WidgetPkgName &pkgname,
+    const DPL::String& file)
+{
+    return getFilePathInWidgetPackage(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)),
+               file);
+}
+
+DPL::Optional<DPL::String> getFilePathInWidgetPackage(
+    WrtDB::WidgetDAOReadOnlyPtr dao,
+    const DPL::String& file)
 {
 {
-    WidgetDAO dao(widgetHandle);
-    return GetFilePathInWidgetPackageInternal(languageTags, dao.getPath(), file);
+    return GetFilePathInWidgetPackageInternal(dao->getPath(), file);
 }
 
 }
 
-DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle widgetHandle)
+DPL::OptionalString getStartFile(const WrtDB::WidgetPkgName & pkgname)
 {
 {
-    using namespace LocalizationUtils;
+    return getStartFile(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)));
+}
 
 
-    WidgetDAO dao(widgetHandle);
+DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle handle)
+{
+    return getStartFile(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(handle)));
+}
 
 
-    WidgetDAO::LocalizedStartFileList locList = dao.getLocalizedStartFileList();
-    WidgetDAO::WidgetStartFileList list = dao.getStartFileList();
-    LanguageTagsList tagsList = LocalizationUtils::GetUserAgentLanguageTags();
+DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao)
+{
+    WidgetDAOReadOnly::LocalizedStartFileList locList =
+        dao->getLocalizedStartFileList();
+    WidgetDAOReadOnly::WidgetStartFileList list = dao->getStartFileList();
+    LanguageTags tagsList =
+        LanguageTagsProviderSingleton::Instance().getLanguageTags();
 
 
-    DPL::OptionalString defaultLoc = dao.getDefaultlocale();
+    DPL::OptionalString defaultLoc = dao->getDefaultlocale();
     if (!!defaultLoc) {
         tagsList.push_back(*defaultLoc);
     }
     if (!!defaultLoc) {
         tagsList.push_back(*defaultLoc);
     }
@@ -178,16 +242,25 @@ DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle widgetHandle)
     return DPL::OptionalString::Null;
 }
 
     return DPL::OptionalString::Null;
 }
 
-OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle)
+OptionalWidgetIcon getIcon(const WrtDB::WidgetPkgName & pkgname)
 {
 {
-    using namespace LocalizationUtils;
-    WidgetDAO dao(widgetHandle);
+    return getIcon(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)));
+}
 
 
-    WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
-    WidgetDAO::WidgetIconList list = dao.getIconList();
-    LanguageTagsList tagsList = LocalizationUtils::GetUserAgentLanguageTags();
+OptionalWidgetIcon getIcon(WrtDB::DbWidgetHandle widgetHandle)
+{
+    return getIcon(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)));
+}
 
 
-    DPL::OptionalString defaultLoc = dao.getDefaultlocale();
+OptionalWidgetIcon getIcon(WrtDB::WidgetDAOReadOnlyPtr dao)
+{
+    WidgetDAOReadOnly::WidgetLocalizedIconList locList =
+        dao->getLocalizedIconList();
+    WidgetDAOReadOnly::WidgetIconList list = dao->getIconList();
+    LanguageTags tagsList =
+        LanguageTagsProviderSingleton::Instance().getLanguageTags();
+
+    DPL::OptionalString defaultLoc = dao->getDefaultlocale();
     if (!!defaultLoc) {
         tagsList.push_back(*defaultLoc);
     }
     if (!!defaultLoc) {
         tagsList.push_back(*defaultLoc);
     }
@@ -214,21 +287,28 @@ OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle)
     return OptionalWidgetIcon::Null;
 }
 
     return OptionalWidgetIcon::Null;
 }
 
-WidgetIconList getValidIconsList(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagsList &languageTags)
+WidgetIconList getValidIconsList(WrtDB::DbWidgetHandle widgetHandle)
+{
+    return getValidIconsList(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)));
+}
+
+WidgetIconList getValidIconsList(const WrtDB::WidgetPkgName &pkgname)
+{
+    return getValidIconsList(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)));
+}
+
+WidgetIconList getValidIconsList(WrtDB::WidgetDAOReadOnlyPtr dao)
 {
 {
-    using namespace LocalizationUtils;
-    WidgetDAO dao(widgetHandle);
-    WidgetDAO::WidgetIconList list = dao.getIconList();
+    WidgetDAOReadOnly::WidgetIconList list = dao->getIconList();
 
     WidgetIconList outlist;
 
     FOREACH(it, list)
     {
         LogDebug(":" << it->iconSrc);
 
     WidgetIconList outlist;
 
     FOREACH(it, list)
     {
         LogDebug(":" << it->iconSrc);
-        if (!!getFilePathInWidgetPackage(widgetHandle,
-                                         languageTags,
+        if (!!getFilePathInWidgetPackage(dao->getHandle(),
                                          it->iconSrc))
         {
             WidgetIcon ret;
                                          it->iconSrc))
         {
             WidgetIcon ret;
@@ -241,18 +321,28 @@ WidgetIconList getValidIconsList(
     return outlist;
 }
 
     return outlist;
 }
 
+OptionalWidgetStartFileInfo getStartFileInfo(WrtDB::DbWidgetHandle widgetHandle)
+{
+    return getStartFileInfo(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(widgetHandle)));
+}
+
 OptionalWidgetStartFileInfo getStartFileInfo(
 OptionalWidgetStartFileInfo getStartFileInfo(
-        WrtDB::DbWidgetHandle widgetHandle,
-        const LanguageTagList &tagsList)
+    const WrtDB::WidgetPkgName &pkgname)
 {
 {
-    using namespace LocalizationUtils;
+    return getStartFileInfo(
+               WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)));
+}
 
 
+OptionalWidgetStartFileInfo getStartFileInfo(WrtDB::WidgetDAOReadOnlyPtr dao)
+{
     WidgetStartFileInfo info;
 
     WidgetStartFileInfo info;
 
-    WidgetDAO dao(widgetHandle);
-    WidgetDAO::LocalizedStartFileList locList =
-        dao.getLocalizedStartFileList();
-    WidgetDAO::WidgetStartFileList list = dao.getStartFileList();
+    WidgetDAOReadOnly::LocalizedStartFileList locList =
+        dao->getLocalizedStartFileList();
+    WidgetDAOReadOnly::WidgetStartFileList list = dao->getStartFileList();
+    const LanguageTags tagsList =
+        LanguageTagsProviderSingleton::Instance().getLanguageTags();
 
     FOREACH(tag, tagsList)
     {
 
     FOREACH(tag, tagsList)
     {
@@ -262,14 +352,15 @@ OptionalWidgetStartFileInfo getStartFileInfo(
                 FOREACH(it, list)
                 {
                     if (it->startFileId ==
                 FOREACH(it, list)
                 {
                     if (it->startFileId ==
-                        sFile->startFileId) {
+                        sFile->startFileId)
+                    {
                         info.file = it->src;
                         info.encoding = sFile->encoding;
                         info.type = sFile->type;
                         if (tag->empty()) {
                             info.localizedPath = it->src;
                         } else {
                         info.file = it->src;
                         info.encoding = sFile->encoding;
                         info.type = sFile->type;
                         if (tag->empty()) {
                             info.localizedPath = it->src;
                         } else {
-                            info.localizedPath = L"locales/" + *tag;
+                            info.localizedPath = L"locales/" + *tag + L"/";
                             info.localizedPath += it->src;
                         }
                         return info;
                             info.localizedPath += it->src;
                         }
                         return info;
@@ -284,10 +375,19 @@ OptionalWidgetStartFileInfo getStartFileInfo(
 
 WidgetLocalizedInfo getLocalizedInfo(const WrtDB::DbWidgetHandle handle)
 {
 
 WidgetLocalizedInfo getLocalizedInfo(const WrtDB::DbWidgetHandle handle)
 {
-    LanguageTagList languages =
-        LocalizationUtils::GetUserAgentLanguageTags();
-    WidgetDAO dao(handle);
-    DPL::OptionalString dl = dao.getDefaultlocale();
+    return getLocalizedInfo(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(handle)));
+}
+
+WidgetLocalizedInfo getLocalizedInfo(const WrtDB::WidgetPkgName & pkgname)
+{
+    return getLocalizedInfo(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(pkgname)));
+}
+
+WidgetLocalizedInfo getLocalizedInfo(WidgetDAOReadOnlyPtr dao)
+{
+    LanguageTags languages =
+        LanguageTagsProviderSingleton::Instance().getLanguageTags();
+    DPL::OptionalString dl = dao->getDefaultlocale();
     if (!!dl) {
         languages.push_back(*dl);
     }
     if (!!dl) {
         languages.push_back(*dl);
     }
@@ -295,7 +395,7 @@ WidgetLocalizedInfo getLocalizedInfo(const WrtDB::DbWidgetHandle handle)
     WidgetLocalizedInfo result;
     FOREACH(i, languages)
     {
     WidgetLocalizedInfo result;
     FOREACH(i, languages)
     {
-        WidgetLocalizedInfo languageResult = dao.getLocalizedInfo(*i);
+        WidgetLocalizedInfo languageResult = dao->getLocalizedInfo(*i);
 
 #define OVERWRITE_IF_NULL(FIELD) if (!result.FIELD) { \
         result.FIELD = languageResult.FIELD; \
 
 #define OVERWRITE_IF_NULL(FIELD) if (!result.FIELD) { \
         result.FIELD = languageResult.FIELD; \
index fdce9c0..62fa050 100644 (file)
 #ifndef DPL_ABSTRACT_LOG_PROVIDER_H
 #define DPL_ABSTRACT_LOG_PROVIDER_H
 
 #ifndef DPL_ABSTRACT_LOG_PROVIDER_H
 #define DPL_ABSTRACT_LOG_PROVIDER_H
 
-namespace DPL
-{
-namespace Log
-{
-
+namespace DPL {
+namespace Log {
 class AbstractLogProvider
 {
 class AbstractLogProvider
 {
-public:
+  public:
     virtual ~AbstractLogProvider() {}
 
     virtual ~AbstractLogProvider() {}
 
-    virtual void Debug(const char *message, const char *fileName, int line, const char *function) = 0;
-    virtual void Info(const char *message, const char *fileName, int line, const char *function) = 0;
-    virtual void Warning(const char *message, const char *fileName, int line, const char *function) = 0;
-    virtual void Error(const char *message, const char *fileName, int line, const char *function) = 0;
-    virtual void Pedantic(const char *message, const char *fileName, int line, const char *function) = 0;
+    virtual void Debug(const char *message,
+                       const char *fileName,
+                       int line,
+                       const char *function) = 0;
+    virtual void Info(const char *message,
+                      const char *fileName,
+                      int line,
+                      const char *function) = 0;
+    virtual void Warning(const char *message,
+                         const char *fileName,
+                         int line,
+                         const char *function) = 0;
+    virtual void Error(const char *message,
+                       const char *fileName,
+                       int line,
+                       const char *function) = 0;
+    virtual void Pedantic(const char *message,
+                          const char *fileName,
+                          int line,
+                          const char *function) = 0;
 
 
-protected:
+  protected:
     static const char *LocateSourceFileName(const char *filename);
 };
     static const char *LocateSourceFileName(const char *filename);
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 0b3edb5..1dd4c2d 100644 (file)
 #include <dpl/scoped_free.h>
 #include <string>
 
 #include <dpl/scoped_free.h>
 #include <string>
 
-namespace DPL
+namespace DPL {
+namespace Log {
+class DLOGLogProvider :
+    public AbstractLogProvider
 {
 {
-namespace Log
-{
-
-class DLOGLogProvider
-    : public AbstractLogProvider
-{
-private:
+  private:
     DPL::ScopedFree<char> m_tag;
 
     DPL::ScopedFree<char> m_tag;
 
-    static std::string FormatMessage(const char *message, const char *filename, int line, const char *function);
-public:
+    static std::string FormatMessage(const char *message,
+                                     const char *filename,
+                                     int line,
+                                     const char *function);
+
+  public:
     DLOGLogProvider();
     virtual ~DLOGLogProvider();
 
     DLOGLogProvider();
     virtual ~DLOGLogProvider();
 
-    virtual void Debug(const char *message, const char *fileName, int line, const char *function);
-    virtual void Info(const char *message, const char *fileName, int line, const char *function);
-    virtual void Warning(const char *message, const char *fileName, int line, const char *function);
-    virtual void Error(const char *message, const char *fileName, int line, const char *function);
-    virtual void Pedantic(const char *message, const char *fileName, int line, const char *function);
+    virtual void Debug(const char *message,
+                       const char *fileName,
+                       int line,
+                       const char *function);
+    virtual void Info(const char *message,
+                      const char *fileName,
+                      int line,
+                      const char *function);
+    virtual void Warning(const char *message,
+                         const char *fileName,
+                         int line,
+                         const char *function);
+    virtual void Error(const char *message,
+                       const char *fileName,
+                       int line,
+                       const char *function);
+    virtual void Pedantic(const char *message,
+                          const char *fileName,
+                          int line,
+                          const char *function);
 
     // Set global Tag according to DLOG
     void SetTag(const char *tag);
 };
 
     // Set global Tag according to DLOG
     void SetTag(const char *tag);
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index c9564bb..d4d95ed 100644 (file)
 #include <dpl/log/abstract_log_provider.h>
 #include <dpl/log/dlog_log_provider.h>
 #include <dpl/log/old_style_log_provider.h>
 #include <dpl/log/abstract_log_provider.h>
 #include <dpl/log/dlog_log_provider.h>
 #include <dpl/log/old_style_log_provider.h>
-#include <dpl/read_write_mutex.h>
 #include <sstream>
 #include <list>
 
 #include <sstream>
 #include <list>
 
-namespace DPL
-{
-namespace Log
-{
+namespace DPL {
+namespace Log {
 /**
  * DPL log system
  *
  * To switch logs into old style, export
  * DPL_USE_OLD_STYLE_LOGS before application start
  */
 /**
  * DPL log system
  *
  * To switch logs into old style, export
  * DPL_USE_OLD_STYLE_LOGS before application start
  */
-class LogSystem
-    private Noncopyable
+class LogSystem :
+    private Noncopyable
 {
 {
-private:
-    ReadWriteMutex m_spinLock;
-
+  private:
     typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
     AbstractLogProviderPtrList m_providers;
 
     typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
     AbstractLogProviderPtrList m_providers;
 
@@ -55,7 +50,7 @@ private:
 
     bool m_isLoggingEnabled;
 
 
     bool m_isLoggingEnabled;
 
-public:
+  public:
     bool IsLoggingEnabled() const;
     LogSystem();
     virtual ~LogSystem();
     bool IsLoggingEnabled() const;
     LogSystem();
     virtual ~LogSystem();
@@ -63,27 +58,42 @@ public:
     /**
      * Log debug message
      */
     /**
      * Log debug message
      */
-    void Debug(const char *message, const char *filename, int line, const char *function);
+    void Debug(const char *message,
+               const char *filename,
+               int line,
+               const char *function);
 
     /**
      * Log info message
      */
 
     /**
      * Log info message
      */
-    void Info(const char *message, const char *filename, int line, const char *function);
+    void Info(const char *message,
+              const char *filename,
+              int line,
+              const char *function);
 
     /**
      * Log warning message
      */
 
     /**
      * Log warning message
      */
-    void Warning(const char *message, const char *filename, int line, const char *function);
+    void Warning(const char *message,
+                 const char *filename,
+                 int line,
+                 const char *function);
 
     /**
      * Log error message
      */
 
     /**
      * Log error message
      */
-    void Error(const char *message, const char *filename, int line, const char *function);
+    void Error(const char *message,
+               const char *filename,
+               int line,
+               const char *function);
 
     /**
      * Log pedantic message
      */
 
     /**
      * Log pedantic message
      */
-    void Pedantic(const char *message, const char *filename, int line, const char *function);
+    void Pedantic(const char *message,
+                  const char *filename,
+                  int line,
+                  const char *function);
 
     /**
      * Set default's DLOG provider Tag
 
     /**
      * Set default's DLOG provider Tag
@@ -106,19 +116,22 @@ public:
 /*
  * Replacement low overhead null logging class
  */
 /*
  * Replacement low overhead null logging class
  */
-class NullStream {
+class NullStream
+{
   public:
     NullStream() {}
 
     template <typename T>
   public:
     NullStream() {}
 
     template <typename T>
-    NullStream& operator<<(const T&) { return *this; }
+    NullStream& operator<<(const T&)
+    {
+        return *this;
+    }
 };
 
 /**
  * Log system singleton
  */
 typedef Singleton<LogSystem> LogSystemSingleton;
 };
 
 /**
  * Log system singleton
  */
 typedef Singleton<LogSystem> LogSystemSingleton;
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
@@ -129,27 +142,26 @@ typedef Singleton<LogSystem> LogSystemSingleton;
 
 #ifdef DPL_LOGS_ENABLED
     #define DPL_MACRO_FOR_LOGGING(message, function)                           \
 
 #ifdef DPL_LOGS_ENABLED
     #define DPL_MACRO_FOR_LOGGING(message, function)                           \
-        do                                                                     \
-        {                                                                      \
-            if (DPL::Log::LogSystemSingleton::Instance().IsLoggingEnabled())   \
-            {                                                                  \
-                std::ostringstream platformLog;                                \
-                platformLog << message;                                        \
-                DPL::Log::LogSystemSingleton::Instance().function(             \
-                    platformLog.str().c_str(),                                 \
-                    __FILE__, __LINE__, __FUNCTION__);                         \
-            }                                                                  \
-        } while (0)
+    do                                                                     \
+    {                                                                      \
+        if (DPL::Log::LogSystemSingleton::Instance().IsLoggingEnabled())   \
+        {                                                                  \
+            std::ostringstream platformLog;                                \
+            platformLog << message;                                        \
+            DPL::Log::LogSystemSingleton::Instance().function(             \
+                platformLog.str().c_str(),                                 \
+                __FILE__, __LINE__, __FUNCTION__);                         \
+        }                                                                  \
+    } while (0)
 #else
 /* avoid warnings about unused variables */
     #define DPL_MACRO_FOR_LOGGING(message, function)                           \
 #else
 /* avoid warnings about unused variables */
     #define DPL_MACRO_FOR_LOGGING(message, function)                           \
-        do {                                                                   \
-            DPL::Log::NullStream ns;                                           \
-            ns << message;                                                     \
-        } while (0)
+    do {                                                                   \
+        DPL::Log::NullStream ns;                                           \
+        ns << message;                                                     \
+    } while (0)
 #endif
 
 #endif
 
-
 #define  LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug)
 #define  LogInfo(message) DPL_MACRO_FOR_LOGGING(message, Info)
 #define  LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
 #define  LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug)
 #define  LogInfo(message) DPL_MACRO_FOR_LOGGING(message, Info)
 #define  LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
index 3ff3d89..becdc93 100644 (file)
 #include <dpl/log/abstract_log_provider.h>
 #include <string>
 
 #include <dpl/log/abstract_log_provider.h>
 #include <string>
 
-namespace DPL
+namespace DPL {
+namespace Log {
+class OldStyleLogProvider :
+    public AbstractLogProvider
 {
 {
-namespace Log
-{
-class OldStyleLogProvider
-    : public AbstractLogProvider
-{
-private:
+  private:
     bool m_showDebug;
     bool m_showInfo;
     bool m_showWarning;
     bool m_showError;
     bool m_showPedantic;
 
     bool m_showDebug;
     bool m_showInfo;
     bool m_showWarning;
     bool m_showError;
     bool m_showPedantic;
 
-    static std::string FormatMessage(const char *message, const char *filename, int line, const char *function);
+    static std::string FormatMessage(const char *message,
+                                     const char *filename,
+                                     int line,
+                                     const char *function);
 
 
-public:
-    OldStyleLogProvider(bool showDebug, bool showInfo, bool showWarning, bool showError, bool showPedantic);
+  public:
+    OldStyleLogProvider(bool showDebug,
+                        bool showInfo,
+                        bool showWarning,
+                        bool showError,
+                        bool showPedantic);
     virtual ~OldStyleLogProvider() {}
 
     virtual ~OldStyleLogProvider() {}
 
-    virtual void Debug(const char *message, const char *fileName, int line, const char *function);
-    virtual void Info(const char *message, const char *fileName, int line, const char *function);
-    virtual void Warning(const char *message, const char *fileName, int line, const char *function);
-    virtual void Error(const char *message, const char *fileName, int line, const char *function);
-    virtual void Pedantic(const char *message, const char *fileName, int line, const char *function);
+    virtual void Debug(const char *message,
+                       const char *fileName,
+                       int line,
+                       const char *function);
+    virtual void Info(const char *message,
+                      const char *fileName,
+                      int line,
+                      const char *function);
+    virtual void Warning(const char *message,
+                         const char *fileName,
+                         int line,
+                         const char *function);
+    virtual void Error(const char *message,
+                       const char *fileName,
+                       int line,
+                       const char *function);
+    virtual void Pedantic(const char *message,
+                          const char *fileName,
+                          int line,
+                          const char *function);
 };
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index d16976c..a03f8a0 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of abstract log provider
  */
  * @version     1.0
  * @brief       This file is the implementation file of abstract log provider
  */
+#include <stddef.h>
 #include <dpl/log/abstract_log_provider.h>
 #include <cstring>
 
 #include <dpl/log/abstract_log_provider.h>
 #include <cstring>
 
-namespace DPL
-{
-namespace Log
-{
+namespace DPL {
+namespace Log {
 const char *AbstractLogProvider::LocateSourceFileName(const char *filename)
 {
     const char *ptr = strrchr(filename, '/');
 const char *AbstractLogProvider::LocateSourceFileName(const char *filename)
 {
     const char *ptr = strrchr(filename, '/');
index 448ae2c..943369f 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of DLOG log provider
  */
  * @version     1.0
  * @brief       This file is the implementation file of DLOG log provider
  */
+#include <stddef.h>
 #include <dpl/log/dlog_log_provider.h>
 #include <cstring>
 #include <sstream>
 #include <dlog.h>
 
 #include <dpl/log/dlog_log_provider.h>
 #include <cstring>
 #include <sstream>
 #include <dlog.h>
 
-namespace DPL
-{
-namespace Log
-{
-
-std::string DLOGLogProvider::FormatMessage(const char *message, const char *filename, int line, const char *function)
+namespace DPL {
+namespace Log {
+std::string DLOGLogProvider::FormatMessage(const char *message,
+                                           const char *filename,
+                                           int line,
+                                           const char *function)
 {
     std::ostringstream val;
 
     val << std::string("[") <<
 {
     std::ostringstream val;
 
     val << std::string("[") <<
-           LocateSourceFileName(filename) << std::string(":") << line <<
-           std::string("] ") << function << std::string("(): ") << message;
+    LocateSourceFileName(filename) << std::string(":") << line <<
+    std::string("] ") << function << std::string("(): ") << message;
 
     return val.str();
 }
 
 DLOGLogProvider::DLOGLogProvider()
 
     return val.str();
 }
 
 DLOGLogProvider::DLOGLogProvider()
-{
-}
+{}
 
 DLOGLogProvider::~DLOGLogProvider()
 
 DLOGLogProvider::~DLOGLogProvider()
-{
-}
+{}
 
 void DLOGLogProvider::SetTag(const char *tag)
 {
     m_tag.Reset(strdup(tag));
 }
 
 
 void DLOGLogProvider::SetTag(const char *tag)
 {
     m_tag.Reset(strdup(tag));
 }
 
-void DLOGLogProvider::Debug(const char *message, const char *filename, int line, const char *function)
+void DLOGLogProvider::Debug(const char *message,
+                            const char *filename,
+                            int line,
+                            const char *function)
 {
 {
-    LOG(LOG_DEBUG, m_tag.Get(), "%s" , FormatMessage(message, filename, line, function).c_str());
+    LOG(LOG_DEBUG, m_tag.Get(), "%s",
+        FormatMessage(message, filename, line, function).c_str());
 }
 
 }
 
-void DLOGLogProvider::Info(const char *message, const char *filename, int line, const char *function)
+void DLOGLogProvider::Info(const char *message,
+                           const char *filename,
+                           int line,
+                           const char *function)
 {
 {
-    LOG(LOG_INFO, m_tag.Get(), "%s" , FormatMessage(message, filename, line, function).c_str());
+    LOG(LOG_INFO, m_tag.Get(), "%s",
+        FormatMessage(message, filename, line, function).c_str());
 }
 
 }
 
-void DLOGLogProvider::Warning(const char *message, const char *filename, int line, const char *function)
+void DLOGLogProvider::Warning(const char *message,
+                              const char *filename,
+                              int line,
+                              const char *function)
 {
 {
-    LOG(LOG_WARN, m_tag.Get(), "%s" , FormatMessage(message, filename, line, function).c_str());
+    LOG(LOG_WARN, m_tag.Get(), "%s",
+        FormatMessage(message, filename, line, function).c_str());
 }
 
 }
 
-void DLOGLogProvider::Error(const char *message, const char *filename, int line, const char *function)
+void DLOGLogProvider::Error(const char *message,
+                            const char *filename,
+                            int line,
+                            const char *function)
 {
 {
-    LOG(LOG_ERROR, m_tag.Get(), "%s" , FormatMessage(message, filename, line, function).c_str());
+    LOG(LOG_ERROR, m_tag.Get(), "%s",
+        FormatMessage(message, filename, line, function).c_str());
 }
 
 }
 
-void DLOGLogProvider::Pedantic(const char *message, const char *filename, int line, const char *function)
+void DLOGLogProvider::Pedantic(const char *message,
+                               const char *filename,
+                               int line,
+                               const char *function)
 {
 {
-    LOG(LOG_DEBUG, "DPL", "%s",  FormatMessage(message, filename, line, function).c_str());
+    LOG(LOG_DEBUG, "DPL", "%s", FormatMessage(message,
+                                              filename,
+                                              line,
+                                              function).c_str());
 }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index b03ab61..7c0ebc2 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of log system
  */
  * @version     1.0
  * @brief       This file is the implementation file of log system
  */
+#include <stddef.h>
 #include <dpl/log/log.h>
 #include <dpl/singleton_impl.h>
 
 IMPLEMENT_SINGLETON(DPL::Log::LogSystem)
 
 #include <dpl/log/log.h>
 #include <dpl/singleton_impl.h>
 
 IMPLEMENT_SINGLETON(DPL::Log::LogSystem)
 
-namespace DPL
-{
-namespace Log
-{
+namespace DPL {
+namespace Log {
 namespace // anonymous
 {
 const char *OLD_STYLE_LOGS_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS";
 namespace // anonymous
 {
 const char *OLD_STYLE_LOGS_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS";
-const char *OLD_STYLE_PEDANTIC_LOGS_ENV_NAME = "DPL_USE_OLD_STYLE_PEDANTIC_LOGS";
+const char *OLD_STYLE_PEDANTIC_LOGS_ENV_NAME =
+    "DPL_USE_OLD_STYLE_PEDANTIC_LOGS";
 const char *OLD_STYLE_LOGS_MASK_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS_MASK";
 const char *DPL_LOG_OFF = "DPL_LOG_OFF";
 } // namespace anonymous
 
 const char *OLD_STYLE_LOGS_MASK_ENV_NAME = "DPL_USE_OLD_STYLE_LOGS_MASK";
 const char *DPL_LOG_OFF = "DPL_LOG_OFF";
 } // namespace anonymous
 
-
 bool LogSystem::IsLoggingEnabled() const
 {
     return m_isLoggingEnabled;
 }
 
 bool LogSystem::IsLoggingEnabled() const
 {
     return m_isLoggingEnabled;
 }
 
-LogSystem::LogSystem()
-    m_dlogProvider(NULL),
-      m_oldStyleProvider(NULL),
-      m_isLoggingEnabled(!getenv(DPL_LOG_OFF))
+LogSystem::LogSystem() :
+    m_dlogProvider(NULL),
+    m_oldStyleProvider(NULL),
+    m_isLoggingEnabled(!getenv(DPL_LOG_OFF))
 {
     bool oldStyleLogs = false;
     bool oldStyleDebugLogs = true;
 {
     bool oldStyleLogs = false;
     bool oldStyleDebugLogs = true;
@@ -57,62 +56,64 @@ LogSystem::LogSystem()
     // Check environment settings about pedantic logs
     const char *value = getenv(OLD_STYLE_LOGS_ENV_NAME);
 
     // Check environment settings about pedantic logs
     const char *value = getenv(OLD_STYLE_LOGS_ENV_NAME);
 
-    if (value != NULL && !strcmp(value, "1"))
+    if (value != NULL && !strcmp(value, "1")) {
         oldStyleLogs = true;
         oldStyleLogs = true;
+    }
 
     value = getenv(OLD_STYLE_PEDANTIC_LOGS_ENV_NAME);
 
 
     value = getenv(OLD_STYLE_PEDANTIC_LOGS_ENV_NAME);
 
-    if (value != NULL && !strcmp(value, "1"))
+    if (value != NULL && !strcmp(value, "1")) {
         oldStylePedanticLogs = true;
         oldStylePedanticLogs = true;
+    }
 
     value = getenv(OLD_STYLE_LOGS_MASK_ENV_NAME);
 
 
     value = getenv(OLD_STYLE_LOGS_MASK_ENV_NAME);
 
-    if (value != NULL)
-    {
+    if (value != NULL) {
         size_t len = strlen(value);
 
         size_t len = strlen(value);
 
-        if (len >= 1)
-        {
-            if (value[0] == '0')
+        if (len >= 1) {
+            if (value[0] == '0') {
                 oldStyleDebugLogs = false;
                 oldStyleDebugLogs = false;
-            else if (value[0] == '1')
+            } else if (value[0] == '1') {
                 oldStyleDebugLogs = true;
                 oldStyleDebugLogs = true;
+            }
         }
 
         }
 
-        if (len >= 2)
-        {
-            if (value[1] == '0')
+        if (len >= 2) {
+            if (value[1] == '0') {
                 oldStyleInfoLogs = false;
                 oldStyleInfoLogs = false;
-            else if (value[1] == '1')
+            } else if (value[1] == '1') {
                 oldStyleInfoLogs = true;
                 oldStyleInfoLogs = true;
+            }
         }
 
         }
 
-        if (len >= 3)
-        {
-            if (value[2] == '0')
+        if (len >= 3) {
+            if (value[2] == '0') {
                 oldStyleWarningLogs = false;
                 oldStyleWarningLogs = false;
-            else if (value[2] == '1')
+            } else if (value[2] == '1') {
                 oldStyleWarningLogs = true;
                 oldStyleWarningLogs = true;
+            }
         }
 
         }
 
-        if (len >= 4)
-        {
-            if (value[3] == '0')
+        if (len >= 4) {
+            if (value[3] == '0') {
                 oldStyleErrorLogs = false;
                 oldStyleErrorLogs = false;
-            else if (value[3] == '1')
+            } else if (value[3] == '1') {
                 oldStyleErrorLogs = true;
                 oldStyleErrorLogs = true;
+            }
         }
     }
 
     // Setup default DLOG and old style logging
         }
     }
 
     // Setup default DLOG and old style logging
-    if (oldStyleLogs)
-    {
+    if (oldStyleLogs) {
         // Old style
         // Old style
-        m_oldStyleProvider = new OldStyleLogProvider(oldStyleDebugLogs, oldStyleInfoLogs, oldStyleWarningLogs, oldStyleErrorLogs, oldStylePedanticLogs);
+        m_oldStyleProvider = new OldStyleLogProvider(oldStyleDebugLogs,
+                                                     oldStyleInfoLogs,
+                                                     oldStyleWarningLogs,
+                                                     oldStyleErrorLogs,
+                                                     oldStylePedanticLogs);
         AddProvider(m_oldStyleProvider);
         AddProvider(m_oldStyleProvider);
-    }
-    else
-    {
+    } else {
         // DLOG
         m_dlogProvider = new DLOGLogProvider();
         AddProvider(m_dlogProvider);
         // DLOG
         m_dlogProvider = new DLOGLogProvider();
         AddProvider(m_dlogProvider);
@@ -122,8 +123,12 @@ LogSystem::LogSystem()
 LogSystem::~LogSystem()
 {
     // Delete all providers
 LogSystem::~LogSystem()
 {
     // Delete all providers
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator)
+    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
+         iterator != m_providers.end();
+         ++iterator)
+    {
         delete *iterator;
         delete *iterator;
+    }
 
     m_providers.clear();
 
 
     m_providers.clear();
 
@@ -134,61 +139,84 @@ LogSystem::~LogSystem()
 
 void LogSystem::SetTag(const char* tag)
 {
 
 void LogSystem::SetTag(const char* tag)
 {
-    if (m_dlogProvider != NULL)
+    if (m_dlogProvider != NULL) {
         m_dlogProvider->SetTag(tag);
         m_dlogProvider->SetTag(tag);
+    }
 }
 
 void LogSystem::AddProvider(AbstractLogProvider *provider)
 {
 }
 
 void LogSystem::AddProvider(AbstractLogProvider *provider)
 {
-    ReadWriteMutex::ScopedWriteLock lock(&m_spinLock);
     m_providers.push_back(provider);
 }
 
 void LogSystem::RemoveProvider(AbstractLogProvider *provider)
 {
     m_providers.push_back(provider);
 }
 
 void LogSystem::RemoveProvider(AbstractLogProvider *provider)
 {
-    ReadWriteMutex::ScopedWriteLock lock(&m_spinLock);
     m_providers.remove(provider);
 }
 
     m_providers.remove(provider);
 }
 
-void LogSystem::Debug(const char *message, const char *filename, int line, const char *function)
+void LogSystem::Debug(const char *message,
+                      const char *filename,
+                      int line,
+                      const char *function)
 {
 {
-    ReadWriteMutex::ScopedReadLock lock(&m_spinLock);
-
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator)
+    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
+         iterator != m_providers.end();
+         ++iterator)
+    {
         (*iterator)->Debug(message, filename, line, function);
         (*iterator)->Debug(message, filename, line, function);
+    }
 }
 
 }
 
-void LogSystem::Info(const char *message, const char *filename, int line, const char *function)
+void LogSystem::Info(const char *message,
+                     const char *filename,
+                     int line,
+                     const char *function)
 {
 {
-    ReadWriteMutex::ScopedReadLock lock(&m_spinLock);
-
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator)
+    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
+         iterator != m_providers.end();
+         ++iterator)
+    {
         (*iterator)->Info(message, filename, line, function);
         (*iterator)->Info(message, filename, line, function);
+    }
 }
 
 }
 
-void LogSystem::Warning(const char *message, const char *filename, int line, const char *function)
+void LogSystem::Warning(const char *message,
+                        const char *filename,
+                        int line,
+                        const char *function)
 {
 {
-    ReadWriteMutex::ScopedReadLock lock(&m_spinLock);
-
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator)
+    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
+         iterator != m_providers.end();
+         ++iterator)
+    {
         (*iterator)->Warning(message, filename, line, function);
         (*iterator)->Warning(message, filename, line, function);
+    }
 }
 
 }
 
-void LogSystem::Error(const char *message, const char *filename, int line, const char *function)
+void LogSystem::Error(const char *message,
+                      const char *filename,
+                      int line,
+                      const char *function)
 {
 {
-    ReadWriteMutex::ScopedReadLock lock(&m_spinLock);
-
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator)
+    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
+         iterator != m_providers.end();
+         ++iterator)
+    {
         (*iterator)->Error(message, filename, line, function);
         (*iterator)->Error(message, filename, line, function);
+    }
 }
 
 }
 
-void LogSystem::Pedantic(const char *message, const char *filename, int line, const char *function)
+void LogSystem::Pedantic(const char *message,
+                         const char *filename,
+                         int line,
+                         const char *function)
 {
 {
-    ReadWriteMutex::ScopedReadLock lock(&m_spinLock);
-
-    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin(); iterator != m_providers.end(); ++iterator)
+    for (AbstractLogProviderPtrList::iterator iterator = m_providers.begin();
+         iterator != m_providers.end();
+         ++iterator)
+    {
         (*iterator)->Pedantic(message, filename, line, function);
         (*iterator)->Pedantic(message, filename, line, function);
+    }
 }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index 7c3b1fc..84433af 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of old style log provider
  */
  * @version     1.0
  * @brief       This file is the implementation file of old style log provider
  */
+#include <stddef.h>
 #include <dpl/log/old_style_log_provider.h>
 #include <dpl/colors.h>
 #include <cstdio>
 #include <cstring>
 #include <sstream>
 #include <sys/time.h>
 #include <dpl/log/old_style_log_provider.h>
 #include <dpl/colors.h>
 #include <cstdio>
 #include <cstring>
 #include <sstream>
 #include <sys/time.h>
+#include <unistd.h>
 
 
-namespace DPL
-{
-namespace Log
-{
+namespace DPL {
+namespace Log {
 namespace // anonymous
 {
 using namespace DPL::Colors::Text;
 namespace // anonymous
 {
 using namespace DPL::Colors::Text;
@@ -44,7 +44,6 @@ const char *WARNING_END = BOLD_GOLD_END;
 const char *PEDANTIC_BEGIN = PURPLE_BEGIN;
 const char *PEDANTIC_END = PURPLE_END;
 
 const char *PEDANTIC_BEGIN = PURPLE_BEGIN;
 const char *PEDANTIC_END = PURPLE_END;
 
-
 std::string GetFormattedTime()
 {
     timeval tv;
 std::string GetFormattedTime()
 {
     timeval tv;
@@ -54,62 +53,103 @@ std::string GetFormattedTime()
     localtime_r(&tv.tv_sec, &localNowTime);
 
     char format[64];
     localtime_r(&tv.tv_sec, &localNowTime);
 
     char format[64];
-    snprintf(format, sizeof(format), "%02i:%02i:%02i.%03i", localNowTime.tm_hour, localNowTime.tm_min, localNowTime.tm_sec, static_cast<int>(tv.tv_usec / 1000));
+    snprintf(format,
+             sizeof(format),
+             "%02i:%02i:%02i.%03i",
+             localNowTime.tm_hour,
+             localNowTime.tm_min,
+             localNowTime.tm_sec,
+             static_cast<int>(tv.tv_usec / 1000));
     return format;
 }
     return format;
 }
-
 } // namespace anonymous
 
 } // namespace anonymous
 
-std::string OldStyleLogProvider::FormatMessage(const char *message, const char *filename, int line, const char *function)
+std::string OldStyleLogProvider::FormatMessage(const char *message,
+                                               const char *filename,
+                                               int line,
+                                               const char *function)
 {
     std::ostringstream val;
 
     val << std::string("[") << GetFormattedTime() << std::string("] [") <<
 {
     std::ostringstream val;
 
     val << std::string("[") << GetFormattedTime() << std::string("] [") <<
-           static_cast<unsigned long>(pthread_self()) << "/" << static_cast<int>(getpid()) << std::string("] [") <<
-           LocateSourceFileName(filename) << std::string(":") << line <<
-           std::string("] ") << function << std::string("(): ") << message;
+    static_cast<unsigned long>(pthread_self()) << "/" <<
+    static_cast<int>(getpid()) << std::string("] [") <<
+    LocateSourceFileName(filename) << std::string(":") << line <<
+    std::string("] ") << function << std::string("(): ") << message;
 
     return val.str();
 }
 
 
     return val.str();
 }
 
-OldStyleLogProvider::OldStyleLogProvider(bool showDebug, bool showInfo, bool showWarning, bool showError, bool showPedantic)
-    : m_showDebug(showDebug),
-      m_showInfo(showInfo),
-      m_showWarning(showWarning),
-      m_showError(showError),
-      m_showPedantic(showPedantic)
+OldStyleLogProvider::OldStyleLogProvider(bool showDebug,
+                                         bool showInfo,
+                                         bool showWarning,
+                                         bool showError,
+                                         bool showPedantic) :
+    m_showDebug(showDebug),
+    m_showInfo(showInfo),
+    m_showWarning(showWarning),
+    m_showError(showError),
+    m_showPedantic(showPedantic)
+{}
+
+void OldStyleLogProvider::Debug(const char *message,
+                                const char *filename,
+                                int line,
+                                const char *function)
 {
 {
+    if (m_showDebug) {
+        fprintf(stdout, "%s%s%s\n", DEBUG_BEGIN,
+                FormatMessage(message, filename, line,
+                              function).c_str(), DEBUG_END);
+    }
 }
 
 }
 
-void OldStyleLogProvider::Debug(const char *message, const char *filename, int line, const char *function)
+void OldStyleLogProvider::Info(const char *message,
+                               const char *filename,
+                               int line,
+                               const char *function)
 {
 {
-    if (m_showDebug)
-        fprintf(stdout, "%s%s%s\n", DEBUG_BEGIN, FormatMessage(message, filename, line, function).c_str(), DEBUG_END);
+    if (m_showInfo) {
+        fprintf(stdout, "%s%s%s\n", INFO_BEGIN,
+                FormatMessage(message, filename, line,
+                              function).c_str(), INFO_END);
+    }
 }
 
 }
 
-void OldStyleLogProvider::Info(const char *message, const char *filename, int line, const char *function)
+void OldStyleLogProvider::Warning(const char *message,
+                                  const char *filename,
+                                  int line,
+                                  const char *function)
 {
 {
-    if (m_showInfo)
-        fprintf(stdout, "%s%s%s\n", INFO_BEGIN, FormatMessage(message, filename, line, function).c_str(), INFO_END);
+    if (m_showWarning) {
+        fprintf(stdout, "%s%s%s\n", WARNING_BEGIN,
+                FormatMessage(message, filename, line,
+                              function).c_str(), WARNING_END);
+    }
 }
 
 }
 
-void OldStyleLogProvider::Warning(const char *message, const char *filename, int line, const char *function)
+void OldStyleLogProvider::Error(const char *message,
+                                const char *filename,
+                                int line,
+                                const char *function)
 {
 {
-    if (m_showWarning)
-        fprintf(stdout, "%s%s%s\n", WARNING_BEGIN, FormatMessage(message, filename, line, function).c_str(), WARNING_END);
+    if (m_showError) {
+        fprintf(stdout, "%s%s%s\n", ERROR_BEGIN,
+                FormatMessage(message, filename, line,
+                              function).c_str(), ERROR_END);
+    }
 }
 
 }
 
-void OldStyleLogProvider::Error(const char *message, const char *filename, int line, const char *function)
+void OldStyleLogProvider::Pedantic(const char *message,
+                                   const char *filename,
+                                   int line,
+                                   const char *function)
 {
 {
-    if (m_showError)
-        fprintf(stdout, "%s%s%s\n", ERROR_BEGIN, FormatMessage(message, filename, line, function).c_str(), ERROR_END);
+    if (m_showPedantic) {
+        fprintf(stdout, "%s%s%s\n", PEDANTIC_BEGIN,
+                FormatMessage(message, filename, line,
+                              function).c_str(), PEDANTIC_END);
+    }
 }
 }
-
-void OldStyleLogProvider::Pedantic(const char *message, const char *filename, int line, const char *function)
-{
-    if (m_showPedantic)
-        fprintf(stdout, "%s%s%s\n", PEDANTIC_BEGIN, FormatMessage(message, filename, line, function).c_str(), PEDANTIC_END);
-}
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index 6f1fd63..7857c60 100644 (file)
 #include <memory>
 #include <string>
 
 #include <memory>
 #include <string>
 
-namespace DPL
-{
-namespace RPC
-{
-namespace AbstractRPCConnectionEvents
-{
+namespace DPL {
+namespace RPC {
+namespace AbstractRPCConnectionEvents {
 /**
  * Asynchronous call event
  */
 /**
  * Asynchronous call event
  */
@@ -51,21 +48,23 @@ DECLARE_GENERIC_EVENT_0(ConnectionClosedEvent)
 DECLARE_GENERIC_EVENT_0(ConnectionBrokenEvent)
 } // namespace AbstractRPCConnectionEvents
 
 DECLARE_GENERIC_EVENT_0(ConnectionBrokenEvent)
 } // namespace AbstractRPCConnectionEvents
 
-class AbstractRPCConnection
-    : public DPL::Event::EventSupport<AbstractRPCConnectionEvents::AsyncCallEvent>,
-      public DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionClosedEvent>,
-      public DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionBrokenEvent>
+class AbstractRPCConnection :
+    public DPL::Event::EventSupport<AbstractRPCConnectionEvents::AsyncCallEvent>,
+    public DPL::Event::EventSupport<AbstractRPCConnectionEvents::
+                                        ConnectionClosedEvent>,
+    public DPL::Event::EventSupport<AbstractRPCConnectionEvents::
+                                        ConnectionBrokenEvent>
 {
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, AsyncCallFailed)
         DECLARE_EXCEPTION_TYPE(Base, PingFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, AsyncCallFailed)
         DECLARE_EXCEPTION_TYPE(Base, PingFailed)
     };
 
-public:
+  public:
     virtual ~AbstractRPCConnection() {}
 
     /**
     virtual ~AbstractRPCConnection() {}
 
     /**
@@ -91,7 +90,6 @@ public:
  * or RPC server accepting connection
  */
 typedef void *AbstractRPCConnectionID;
  * or RPC server accepting connection
  */
 typedef void *AbstractRPCConnectionID;
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 38c1e97..c9e3b1f 100644 (file)
 #include <dpl/event/event_support.h>
 #include <dpl/generic_event.h>
 
 #include <dpl/event/event_support.h>
 #include <dpl/generic_event.h>
 
-namespace DPL
-{
-namespace RPC
-{
-namespace AbstractRPCConnectorEvents
-{
+namespace DPL {
+namespace RPC {
+namespace AbstractRPCConnectorEvents {
 /**
  * RPC connection established
  */
 /**
  * RPC connection established
  */
-DECLARE_GENERIC_EVENT_2(ConnectionEstablishedEvent, AbstractRPCConnectionID, AbstractRPCConnection *)
+DECLARE_GENERIC_EVENT_2(ConnectionEstablishedEvent,
+                        AbstractRPCConnectionID,
+                        AbstractRPCConnection *)
 } // namespace AbstractRPCClientEvents
 
 } // namespace AbstractRPCClientEvents
 
-class AbstractRPCConnector
-    : public DPL::Event::EventSupport<AbstractRPCConnectorEvents::ConnectionEstablishedEvent>
+class AbstractRPCConnector :
+    public DPL::Event::EventSupport<AbstractRPCConnectorEvents::
+                                        ConnectionEstablishedEvent>
 {
 {
-public:
+  public:
     /**
      * Destructor
      */
     virtual ~AbstractRPCConnector() {}
 };
     /**
      * Destructor
      */
     virtual ~AbstractRPCConnector() {}
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 1342859..7810ef9 100644 (file)
 #include <dpl/rpc/abstract_rpc_connection.h>
 #include <dpl/abstract_waitable_input_output.h>
 #include <dpl/socket/waitable_input_output_execution_context_support.h>
 #include <dpl/rpc/abstract_rpc_connection.h>
 #include <dpl/abstract_waitable_input_output.h>
 #include <dpl/socket/waitable_input_output_execution_context_support.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
 
 
-namespace DPL
+namespace DPL {
+namespace RPC {
+class GenericRPCConnection :
+    public AbstractRPCConnection,
+    private DPL::Socket::WaitableInputOutputExecutionContextSupport
 {
 {
-namespace RPC
-{
-
-class GenericRPCConnection
-    : public AbstractRPCConnection,
-      private DPL::Socket::WaitableInputOutputExecutionContextSupport
-{
-private:
+  private:
     // WaitableInputOutputExecutionContextSupport
     virtual void OnInputStreamRead();
     virtual void OnInputStreamClosed();
     virtual void OnInputStreamBroken();
 
     // WaitableInputOutputExecutionContextSupport
     virtual void OnInputStreamRead();
     virtual void OnInputStreamClosed();
     virtual void OnInputStreamBroken();
 
-    ScopedPtr<AbstractWaitableInputOutput> m_inputOutput;
+    std::unique_ptr<AbstractWaitableInputOutput> m_inputOutput;
 
 
-public:
+  public:
     /**
      * Costructor
      *
     /**
      * Costructor
      *
-     * Abstract waitable input/outobject is acquired by class and destroyed upon desctructor
+     * Abstract waitable input/outobject is acquired by class and destroyed upon
+     * desctructor
      */
     explicit GenericRPCConnection(AbstractWaitableInputOutput *inputOutput);
     virtual ~GenericRPCConnection();
      */
     explicit GenericRPCConnection(AbstractWaitableInputOutput *inputOutput);
     virtual ~GenericRPCConnection();
@@ -56,7 +54,6 @@ public:
     virtual void AsyncCall(const RPCFunction &function);
     virtual void Ping();
 };
     virtual void AsyncCall(const RPCFunction &function);
     virtual void Ping();
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 122dd0b..9629e61 100644 (file)
 #include <dpl/socket/abstract_socket.h>
 #include <set>
 
 #include <dpl/socket/abstract_socket.h>
 #include <set>
 
-namespace DPL
-{
-namespace RPC
-{
-
+namespace DPL {
+namespace RPC {
 template<typename SocketType>
 template<typename SocketType>
-class GenericSocketRPCClient
-    : public AbstractRPCConnector,
-      private DPL::Event::EventListener<DPL::Socket::AbstractSocketEvents::ConnectedEvent>
+class GenericSocketRPCClient :
+    public AbstractRPCConnector,
+    private DPL::Event::EventListener<DPL::Socket::AbstractSocketEvents::
+                                          ConnectedEvent>
 {
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
-protected:
+  protected:
     // Derived class implementations for connection managment
     // Derived class implementations for connection managment
-    virtual AbstractRPCConnection *OpenSpecificConnection(SocketType *socket) = 0;
+    virtual AbstractRPCConnection *OpenSpecificConnection(SocketType *socket) =
+        0;
 
 
-private:
+  private:
     typedef std::set<SocketType *> InternalConnectionSet;
     InternalConnectionSet m_internalConnectionSet;
 
     typedef std::set<SocketType *> InternalConnectionSet;
     InternalConnectionSet m_internalConnectionSet;
 
-    virtual void OnEventReceived(const DPL::Socket::AbstractSocketEvents::ConnectedEvent &event)
+    virtual void OnEventReceived(
+        const DPL::Socket::AbstractSocketEvents::ConnectedEvent &event)
     {
         // Retrieve socket sender
         SocketType *socket = static_cast<SocketType *>(event.GetSender());
     {
         // Retrieve socket sender
         SocketType *socket = static_cast<SocketType *>(event.GetSender());
@@ -62,10 +62,10 @@ private:
 
         // Is this connection still tracked ?
         // It might have disappeared on close
 
         // Is this connection still tracked ?
         // It might have disappeared on close
-        typename InternalConnectionSet::iterator iterator = m_internalConnectionSet.find(socket);
+        typename InternalConnectionSet::iterator iterator =
+            m_internalConnectionSet.find(socket);
 
 
-        if (iterator == m_internalConnectionSet.end())
-        {
+        if (iterator == m_internalConnectionSet.end()) {
             LogPedantic("RPC client connection socket disappeared");
             return;
         }
             LogPedantic("RPC client connection socket disappeared");
             return;
         }
@@ -74,22 +74,25 @@ private:
         AbstractRPCConnection *connection = OpenSpecificConnection(socket);
 
         // Remove internal connection
         AbstractRPCConnection *connection = OpenSpecificConnection(socket);
 
         // Remove internal connection
-        socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>::RemoveListener(this);
+        socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>
+            ::RemoveListener(this);
         m_internalConnectionSet.erase(iterator);
 
         // Retrieve ID once again
         m_internalConnectionSet.erase(iterator);
 
         // Retrieve ID once again
-        AbstractRPCConnectionID connectionID = static_cast<AbstractRPCConnectionID>(socket);
+        AbstractRPCConnectionID connectionID =
+            static_cast<AbstractRPCConnectionID>(socket);
 
         // Inform listeners
 
         // Inform listeners
-        DPL::Event::EventSupport<AbstractRPCConnectorEvents::ConnectionEstablishedEvent>::
+        DPL::Event::EventSupport<AbstractRPCConnectorEvents::
+                                     ConnectionEstablishedEvent>::
             EmitEvent(AbstractRPCConnectorEvents::ConnectionEstablishedEvent(
             EmitEvent(AbstractRPCConnectorEvents::ConnectionEstablishedEvent(
-                connectionID, connection, EventSender(this)), DPL::Event::EmitMode::Queued);
+                          connectionID, connection, EventSender(
+                              this)), DPL::Event::EmitMode::Queued);
     }
 
     }
 
-public:
+  public:
     explicit GenericSocketRPCClient()
     explicit GenericSocketRPCClient()
-    {
-    }
+    {}
 
     virtual ~GenericSocketRPCClient()
     {
 
     virtual ~GenericSocketRPCClient()
     {
@@ -105,7 +108,8 @@ public:
         SocketType *socket = new SocketType();
 
         // Add socket listeners
         SocketType *socket = new SocketType();
 
         // Add socket listeners
-        socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>::AddListener(this);
+        socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>
+            ::AddListener(this);
 
         Try
         {
 
         Try
         {
@@ -115,10 +119,11 @@ public:
             // Start connecting to server
             socket->Connect(Address(socketAddress));
         }
             // Start connecting to server
             socket->Connect(Address(socketAddress));
         }
-        Catch (DPL::Socket::AbstractSocket::Exception::Base)
+        Catch(DPL::Socket::AbstractSocket::Exception::Base)
         {
             // Remove back socket listener
         {
             // Remove back socket listener
-            socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>::RemoveListener(this);
+            socket->EventSupport<DPL::Socket::AbstractSocketEvents::
+                                     ConnectedEvent>::RemoveListener(this);
 
             // Log debug message
             LogPedantic("Cannot connect to: " << socketAddress.ToString());
 
             // Log debug message
             LogPedantic("Cannot connect to: " << socketAddress.ToString());
@@ -131,7 +136,9 @@ public:
         m_internalConnectionSet.insert(socket);
 
         // Debug info
         m_internalConnectionSet.insert(socket);
 
         // Debug info
-        LogPedantic("Client started on interface: " << socket->GetLocalAddress().ToString());
+        LogPedantic(
+            "Client started on interface: " <<
+            socket->GetLocalAddress().ToString());
 
         // Return unique identifier
         return static_cast<AbstractRPCConnectionID>(socket);
 
         // Return unique identifier
         return static_cast<AbstractRPCConnectionID>(socket);
@@ -145,16 +152,19 @@ public:
         SocketType *socket = static_cast<SocketType *>(connectionID);
 
         // Find corresponding internal connection
         SocketType *socket = static_cast<SocketType *>(connectionID);
 
         // Find corresponding internal connection
-        typename InternalConnectionSet::iterator iterator = m_internalConnectionSet.find(socket);
+        typename InternalConnectionSet::iterator iterator =
+            m_internalConnectionSet.find(socket);
 
 
-        if (iterator == m_internalConnectionSet.end())
+        if (iterator == m_internalConnectionSet.end()) {
             return;
             return;
+        }
 
         // Close socket
         socket->Close();
 
         // Remove internal socket
 
         // Close socket
         socket->Close();
 
         // Remove internal socket
-        socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>::RemoveListener(this);
+        socket->EventSupport<DPL::Socket::AbstractSocketEvents::ConnectedEvent>
+            ::RemoveListener(this);
         delete socket;
 
         m_internalConnectionSet.erase(iterator);
         delete socket;
 
         m_internalConnectionSet.erase(iterator);
@@ -165,11 +175,12 @@ public:
 
     void CloseAll()
     {
 
     void CloseAll()
     {
-        while (!m_internalConnectionSet.empty())
-            Close(static_cast<AbstractRPCConnectionID>(*m_internalConnectionSet.begin()));
+        while (!m_internalConnectionSet.empty()) {
+            Close(static_cast<AbstractRPCConnectionID>(*m_internalConnectionSet
+                                                           .begin()));
+        }
     }
 };
     }
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 12e53de..6c2d0ce 100644 (file)
 
 #include <dpl/rpc/generic_rpc_connection.h>
 
 
 #include <dpl/rpc/generic_rpc_connection.h>
 
-namespace DPL
-{
-namespace RPC
-{
-
+namespace DPL {
+namespace RPC {
 template<class SocketType>
 template<class SocketType>
-class GenericSocketRPCConnection
-    public GenericRPCConnection
+class GenericSocketRPCConnection :
+    public GenericRPCConnection
 {
 {
-protected:
+  protected:
     // Private construction with socket acquisition
     // Private construction with socket acquisition
-    GenericSocketRPCConnection(SocketType *socket)
-        : GenericRPCConnection(socket)
-    {
-    }
+    GenericSocketRPCConnection(SocketType *socket) :
+        GenericRPCConnection(socket)
+    {}
 };
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 87d6899..a4cae00 100644 (file)
 #include <dpl/socket/abstract_socket.h>
 #include <set>
 
 #include <dpl/socket/abstract_socket.h>
 #include <set>
 
-namespace DPL
-{
-namespace RPC
-{
-
+namespace DPL {
+namespace RPC {
 template<typename SocketType>
 template<typename SocketType>
-class GenericSocketRPCServer
-    : public AbstractRPCConnector,
-      private DPL::Event::EventListener<DPL::Socket::AbstractSocketEvents::AcceptEvent>
+class GenericSocketRPCServer :
+    public AbstractRPCConnector,
+    private DPL::Event::EventListener<DPL::Socket::AbstractSocketEvents::
+                                          AcceptEvent>
 {
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
-protected:
+  protected:
     // Derived class implementations for connection managment
     // Derived class implementations for connection managment
-    virtual AbstractRPCConnection *OpenSpecificConnection(SocketType *socket) = 0;
+    virtual AbstractRPCConnection *OpenSpecificConnection(SocketType *socket) =
+        0;
 
 
-private:
+  private:
     typedef std::set<SocketType *> InternalInterfaceSet;
     InternalInterfaceSet m_internalInterfacesSet;
 
     typedef std::set<SocketType *> InternalInterfaceSet;
     InternalInterfaceSet m_internalInterfacesSet;
 
-    virtual void OnEventReceived(const DPL::Socket::AbstractSocketEvents::AcceptEvent &event)
+    virtual void OnEventReceived(
+        const DPL::Socket::AbstractSocketEvents::AcceptEvent &event)
     {
         // Retrieve socket sender
         SocketType *server = static_cast<SocketType *>(event.GetSender());
 
         // Is this interface still tracked ?
         // It might have disappeared on close
     {
         // Retrieve socket sender
         SocketType *server = static_cast<SocketType *>(event.GetSender());
 
         // Is this interface still tracked ?
         // It might have disappeared on close
-        typename InternalInterfaceSet::iterator iterator = m_internalInterfacesSet.find(server);
+        typename InternalInterfaceSet::iterator iterator =
+            m_internalInterfacesSet.find(server);
 
 
-        if (iterator == m_internalInterfacesSet.end())
-        {
+        if (iterator == m_internalInterfacesSet.end()) {
             LogPedantic("RPC server interface socket disappeared");
             return;
         }
 
         // Accept incoming client
         SocketType *client = static_cast<SocketType *>(server->Accept());
             LogPedantic("RPC server interface socket disappeared");
             return;
         }
 
         // Accept incoming client
         SocketType *client = static_cast<SocketType *>(server->Accept());
-        if(client == NULL)
-        {
+        if (client == NULL) {
             LogPedantic("Spontaneous accept on socket occurred");
             return;
         }
 
             LogPedantic("Spontaneous accept on socket occurred");
             return;
         }
 
-        LogPedantic("Client connected to server: " << client->GetRemoteAddress().ToString());
+        LogPedantic(
+            "Client connected to server: " <<
+            client->GetRemoteAddress().ToString());
 
         // Open specific connection implementation
         AbstractRPCConnection *connection = OpenSpecificConnection(client);
 
         // Retrieve ID once again
 
         // Open specific connection implementation
         AbstractRPCConnection *connection = OpenSpecificConnection(client);
 
         // Retrieve ID once again
-        AbstractRPCConnectionID connectionID = static_cast<AbstractRPCConnectionID>(server);
+        AbstractRPCConnectionID connectionID =
+            static_cast<AbstractRPCConnectionID>(server);
 
         // Inform listeners
 
         // Inform listeners
-        DPL::Event::EventSupport<AbstractRPCConnectorEvents::ConnectionEstablishedEvent>::
+        DPL::Event::EventSupport<AbstractRPCConnectorEvents::
+                                     ConnectionEstablishedEvent>::
             EmitEvent(AbstractRPCConnectorEvents::ConnectionEstablishedEvent(
             EmitEvent(AbstractRPCConnectorEvents::ConnectionEstablishedEvent(
-                connectionID, connection, EventSender(this)), DPL::Event::EmitMode::Queued);
+                          connectionID, connection, EventSender(
+                              this)), DPL::Event::EmitMode::Queued);
     }
 
     }
 
-public:
+  public:
     explicit GenericSocketRPCServer()
     explicit GenericSocketRPCServer()
-    {
-    }
+    {}
 
     virtual ~GenericSocketRPCServer()
     {
 
     virtual ~GenericSocketRPCServer()
     {
@@ -109,7 +112,8 @@ public:
         SocketType *socket = new SocketType();
 
         // Add socket listener
         SocketType *socket = new SocketType();
 
         // Add socket listener
-        socket->EventSupport<DPL::Socket::AbstractSocketEvents::AcceptEvent>::AddListener(this);
+        socket->EventSupport<DPL::Socket::AbstractSocketEvents::AcceptEvent>::
+            AddListener(this);
 
         Try
         {
 
         Try
         {
@@ -122,10 +126,11 @@ public:
             // Start listening
             socket->Listen(8);
         }
             // Start listening
             socket->Listen(8);
         }
-        Catch (DPL::Socket::AbstractSocket::Exception::Base)
+        Catch(DPL::Socket::AbstractSocket::Exception::Base)
         {
             // Remove back socket listener
         {
             // Remove back socket listener
-            socket->EventSupport<DPL::Socket::AbstractSocketEvents::AcceptEvent>::RemoveListener(this);
+            socket->EventSupport<DPL::Socket::AbstractSocketEvents::AcceptEvent>
+                ::RemoveListener(this);
 
             // Log debug
             LogPedantic("Cannot start server: " << socketAddress.ToString());
 
             // Log debug
             LogPedantic("Cannot start server: " << socketAddress.ToString());
@@ -138,7 +143,9 @@ public:
         m_internalInterfacesSet.insert(socket);
 
         // Debug info
         m_internalInterfacesSet.insert(socket);
 
         // Debug info
-        LogPedantic("Server started on interface: " << socket->GetLocalAddress().ToString());
+        LogPedantic(
+            "Server started on interface: " <<
+            socket->GetLocalAddress().ToString());
 
         // Return unique identifier
         return static_cast<AbstractRPCConnectionID>(socket);
 
         // Return unique identifier
         return static_cast<AbstractRPCConnectionID>(socket);
@@ -152,16 +159,19 @@ public:
         SocketType *socket = static_cast<SocketType *>(connectionID);
 
         // Find corresponding internal connection
         SocketType *socket = static_cast<SocketType *>(connectionID);
 
         // Find corresponding internal connection
-        typename InternalInterfaceSet::iterator iterator = m_internalInterfacesSet.find(socket);
+        typename InternalInterfaceSet::iterator iterator =
+            m_internalInterfacesSet.find(socket);
 
 
-        if (iterator == m_internalInterfacesSet.end())
+        if (iterator == m_internalInterfacesSet.end()) {
             return;
             return;
+        }
 
         // Close socket
         socket->Close();
 
         // Remove socket listeners
 
         // Close socket
         socket->Close();
 
         // Remove socket listeners
-        socket->EventSupport<DPL::Socket::AbstractSocketEvents::AcceptEvent>::RemoveListener(this);
+        socket->EventSupport<DPL::Socket::AbstractSocketEvents::AcceptEvent>::
+            RemoveListener(this);
         delete socket;
 
         m_internalInterfacesSet.erase(iterator);
         delete socket;
 
         m_internalInterfacesSet.erase(iterator);
@@ -172,11 +182,12 @@ public:
 
     void CloseAll()
     {
 
     void CloseAll()
     {
-        while (!m_internalInterfacesSet.empty())
-            Close(static_cast<AbstractRPCConnectionID>(*m_internalInterfacesSet.begin()));
+        while (!m_internalInterfacesSet.empty()) {
+            Close(static_cast<AbstractRPCConnectionID>(*m_internalInterfacesSet
+                                                           .begin()));
+        }
     }
 };
     }
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 4a121ff..a01235f 100644 (file)
 #include <dpl/serialization.h>
 #include <string>
 
 #include <dpl/serialization.h>
 #include <string>
 
-namespace DPL
-{
-namespace RPC
-{
-
+namespace DPL {
+namespace RPC {
 class RPCFunction : public IStream
 {
 class RPCFunction : public IStream
 {
-protected:
+  protected:
     BinaryQueue m_buffer; ///< Serialized RPC function call as a binary queue
 
     BinaryQueue m_buffer; ///< Serialized RPC function call as a binary queue
 
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, ParseFailed)
     };
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, ParseFailed)
     };
@@ -51,8 +48,7 @@ public:
      * Constructor
      */
     RPCFunction()
      * Constructor
      */
     RPCFunction()
-    {
-    }
+    {}
 
     /**
      * Constructor
 
     /**
      * Constructor
@@ -68,15 +64,15 @@ public:
      * Destructor
      */
     virtual ~RPCFunction()
      * Destructor
      */
     virtual ~RPCFunction()
-    {
-    }
+    {}
 
     /**
      * Append argument to call
      *
      * @param[in] arg Template based argument to append
      * @return none
 
     /**
      * Append argument to call
      *
      * @param[in] arg Template based argument to append
      * @return none
-     * @warning Carefully add any pointers to buffer because of template nature of this method
+     * @warning Carefully add any pointers to buffer because of template nature
+     * of this method
      */
     template<typename Type>
     void AppendArg(const Type &arg)
      */
     template<typename Type>
     void AppendArg(const Type &arg)
@@ -116,7 +112,8 @@ public:
      * (same as they were pushed onto RPC function argument stack)
      *
      * @param[out] arg Reference to output template based argument
      * (same as they were pushed onto RPC function argument stack)
      *
      * @param[out] arg Reference to output template based argument
-     * @warning Carefully add any pointers to buffer because of template nature of this method
+     * @warning Carefully add any pointers to buffer because of template nature
+     * of this method
      * @return none
      */
     template<typename Type>
      * @return none
      */
     template<typename Type>
@@ -127,19 +124,21 @@ public:
             size_t argSize = sizeof(arg);
             m_buffer.FlattenConsume(&argSize, sizeof(argSize));
 
             size_t argSize = sizeof(arg);
             m_buffer.FlattenConsume(&argSize, sizeof(argSize));
 
-            if (argSize != sizeof(arg))
+            if (argSize != sizeof(arg)) {
                 ThrowMsg(Exception::ParseFailed, "Stream parse CRC failed");
                 ThrowMsg(Exception::ParseFailed, "Stream parse CRC failed");
+            }
 
             m_buffer.FlattenConsume(&arg, sizeof(arg));
         }
 
             m_buffer.FlattenConsume(&arg, sizeof(arg));
         }
-        Catch (BinaryQueue::Exception::OutOfData)
+        Catch(BinaryQueue::Exception::OutOfData)
         {
             ReThrowMsg(Exception::ParseFailed, "Unexpected end of stream");
         }
     }
 
     /**
         {
             ReThrowMsg(Exception::ParseFailed, "Unexpected end of stream");
         }
     }
 
     /**
-     * Consume @a std::string argument from call. Arguments are retrieved in non-reversed order
+     * Consume @a std::string argument from call. Arguments are retrieved in
+     * non-reversed order
      * (same as they were pushed onto RPC function argument stack)
      *
      * @param[out] arg Reference to output @a std::string argument
      * (same as they were pushed onto RPC function argument stack)
      *
      * @param[out] arg Reference to output @a std::string argument
@@ -155,14 +154,15 @@ public:
             m_buffer.FlattenConsume(str.Get(), size);
             arg = std::string(str.Get(), str.Get() + size);
         }
             m_buffer.FlattenConsume(str.Get(), size);
             arg = std::string(str.Get(), str.Get() + size);
         }
-        Catch (BinaryQueue::Exception::OutOfData)
+        Catch(BinaryQueue::Exception::OutOfData)
         {
             ReThrowMsg(Exception::ParseFailed, "Unexpected end of stream");
         }
     }
 
     /**
         {
             ReThrowMsg(Exception::ParseFailed, "Unexpected end of stream");
         }
     }
 
     /**
-     * Consume @a DPL::String argument from call. Arguments are converted to UTF-8 string
+     * Consume @a DPL::String argument from call. Arguments are converted to
+     * UTF-8 string
      *
      * @param[out] arg Reference to output @a DPL::String argument
      * @return none
      *
      * @param[out] arg Reference to output @a DPL::String argument
      * @return none
@@ -206,7 +206,6 @@ public:
         m_buffer.AppendCopy(bytes, num);
     }
 };
         m_buffer.AppendCopy(bytes, num);
     }
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 730a349..aba62ec 100644 (file)
 #include <dpl/socket/unix_socket.h>
 #include <string>
 
 #include <dpl/socket/unix_socket.h>
 #include <string>
 
-namespace DPL
+namespace DPL {
+namespace RPC {
+class UnixSocketRPCClient :
+    public GenericSocketRPCClient<DPL::Socket::UnixSocket>
 {
 {
-namespace RPC
-{
-
-class UnixSocketRPCClient
-    : public GenericSocketRPCClient<DPL::Socket::UnixSocket>
-{
-protected:
-    virtual AbstractRPCConnection *OpenSpecificConnection(DPL::Socket::UnixSocket *socket);
+  protected:
+    virtual AbstractRPCConnection *OpenSpecificConnection(
+        DPL::Socket::UnixSocket *socket);
 
 
-public:
+  public:
     AbstractRPCConnectionID Open(const std::string &fileName);
 };
     AbstractRPCConnectionID Open(const std::string &fileName);
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 5981596..9b00141 100644 (file)
 #include <dpl/rpc/generic_socket_rpc_connection.h>
 #include <dpl/socket/unix_socket.h>
 
 #include <dpl/rpc/generic_socket_rpc_connection.h>
 #include <dpl/socket/unix_socket.h>
 
-namespace DPL
+namespace DPL {
+namespace RPC {
+class UnixSocketRPCConnection :
+    public GenericSocketRPCConnection<DPL::Socket::UnixSocket>
 {
 {
-namespace RPC
-{
-
-class UnixSocketRPCConnection
-    : public GenericSocketRPCConnection<DPL::Socket::UnixSocket>
-{
-public:
+  public:
     // Socket acquisition
     UnixSocketRPCConnection(DPL::Socket::UnixSocket *socket);
 };
     // Socket acquisition
     UnixSocketRPCConnection(DPL::Socket::UnixSocket *socket);
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index a6d7335..de2b605 100644 (file)
 #include <dpl/socket/unix_socket.h>
 #include <string>
 
 #include <dpl/socket/unix_socket.h>
 #include <string>
 
-namespace DPL
+namespace DPL {
+namespace RPC {
+class UnixSocketRPCServer :
+    public GenericSocketRPCServer<DPL::Socket::UnixSocket>
 {
 {
-namespace RPC
-{
-
-class UnixSocketRPCServer
-    : public GenericSocketRPCServer<DPL::Socket::UnixSocket>
-{
-protected:
-    virtual AbstractRPCConnection *OpenSpecificConnection(DPL::Socket::UnixSocket *socket);
+  protected:
+    virtual AbstractRPCConnection *OpenSpecificConnection(
+        DPL::Socket::UnixSocket *socket);
 
 
-public:
+  public:
     AbstractRPCConnectionID Open(const std::string &fileName);
 };
     AbstractRPCConnectionID Open(const std::string &fileName);
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index b1b2140..e5455e2 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of abstract RPC connection
  */
  * @version     1.0
  * @brief       This file is the implementation file of abstract RPC connection
  */
+#include <stddef.h>
 #include <dpl/rpc/abstract_rpc_connection.h>
 
 //
 #include <dpl/rpc/abstract_rpc_connection.h>
 
 //
index 63527bc..2bd879e 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of abstract RPC connector
  */
  * @version     1.0
  * @brief       This file is the implementation file of abstract RPC connector
  */
+#include <stddef.h>
 #include <dpl/rpc/abstract_rpc_connector.h>
 
 //
 #include <dpl/rpc/abstract_rpc_connector.h>
 
 //
index f087494..6b16f28 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of generic RPC connection
  */
  * @version     1.0
  * @brief       This file is the implementation file of generic RPC connection
  */
+#include <stddef.h>
 #include <dpl/rpc/generic_rpc_connection.h>
 #include <dpl/scoped_array.h>
 #include <dpl/log/log.h>
 #include <dpl/aligned.h>
 #include <stdexcept>
 
 #include <dpl/rpc/generic_rpc_connection.h>
 #include <dpl/scoped_array.h>
 #include <dpl/log/log.h>
 #include <dpl/aligned.h>
 #include <stdexcept>
 
-namespace DPL
-{
-namespace RPC
-{
+namespace DPL {
+namespace RPC {
 namespace // anonymous
 {
 namespace // anonymous
 {
-namespace Protocol
-{
+namespace Protocol {
 // Packet definitions
 enum PacketType
 {
 // Packet definitions
 enum PacketType
 {
@@ -46,17 +44,17 @@ struct Header
     unsigned short type;
 } DPL_ALIGNED(1);
 
     unsigned short type;
 } DPL_ALIGNED(1);
 
-struct AsyncCall
-    public Header
+struct AsyncCall :
+    public Header
 {
     unsigned char data[1];
 } DPL_ALIGNED(1);
 {
     unsigned char data[1];
 } DPL_ALIGNED(1);
-
 } // namespace Protocol
 } // namespace anonymous
 
 } // namespace Protocol
 } // namespace anonymous
 
-GenericRPCConnection::GenericRPCConnection(AbstractWaitableInputOutput *inputOutput)
-    : m_inputOutput(inputOutput)
+GenericRPCConnection::GenericRPCConnection(
+    AbstractWaitableInputOutput *inputOutput) :
+    m_inputOutput(inputOutput)
 {
     LogPedantic("Opening generic RPC...");
     WaitableInputOutputExecutionContextSupport::Open(inputOutput);
 {
     LogPedantic("Opening generic RPC...");
     WaitableInputOutputExecutionContextSupport::Open(inputOutput);
@@ -91,7 +89,7 @@ void GenericRPCConnection::AsyncCall(const RPCFunction &function)
     {
         FeedOutput();
     }
     {
         FeedOutput();
     }
-    Catch (WaitableInputOutputExecutionContextSupport::Exception::NotOpened)
+    Catch(WaitableInputOutputExecutionContextSupport::Exception::NotOpened)
     {
         // Error occurred while feeding
         ReThrow(AbstractRPCConnection::Exception::AsyncCallFailed);
     {
         // Error occurred while feeding
         ReThrow(AbstractRPCConnection::Exception::AsyncCallFailed);
@@ -114,7 +112,7 @@ void GenericRPCConnection::Ping()
     {
         FeedOutput();
     }
     {
         FeedOutput();
     }
-    Catch (WaitableInputOutputExecutionContextSupport::Exception::NotOpened)
+    Catch(WaitableInputOutputExecutionContextSupport::Exception::NotOpened)
     {
         // Error occurred while feeding
         ReThrow(AbstractRPCConnection::Exception::PingFailed);
     {
         // Error occurred while feeding
         ReThrow(AbstractRPCConnection::Exception::PingFailed);
@@ -126,76 +124,82 @@ void GenericRPCConnection::OnInputStreamRead()
     LogPedantic("Interpreting " << m_inputStream.Size() << " bytes buffer");
 
     // Enough bytes to read at least one header ?
     LogPedantic("Interpreting " << m_inputStream.Size() << " bytes buffer");
 
     // Enough bytes to read at least one header ?
-    if (m_inputStream.Size() >= sizeof(Protocol::Header))
-    {
+    if (m_inputStream.Size() >= sizeof(Protocol::Header)) {
         // Begin consuming as much packets as it is possible
         // Begin consuming as much packets as it is possible
-        while (m_inputStream.Size() >= sizeof(Protocol::Header))
-        {
+        while (m_inputStream.Size() >= sizeof(Protocol::Header)) {
             Protocol::Header header;
             m_inputStream.Flatten(&header, sizeof(header));
 
             Protocol::Header header;
             m_inputStream.Flatten(&header, sizeof(header));
 
-            if (m_inputStream.Size() >= sizeof(Protocol::Header) + header.size)
+            if (m_inputStream.Size() >= sizeof(Protocol::Header) +
+                header.size)
             {
                 LogPedantic("Will parse packet of type: " << header.type);
 
                 // Allocate new packet (header + real packet data)
             {
                 LogPedantic("Will parse packet of type: " << header.type);
 
                 // Allocate new packet (header + real packet data)
-                void *binaryPacket = malloc(sizeof(Protocol::Header) + header.size);
+                void *binaryPacket = malloc(
+                        sizeof(Protocol::Header) + header.size);
 
 
-                if (binaryPacket == NULL)
+                if (binaryPacket == NULL) {
                     throw std::bad_alloc();
                     throw std::bad_alloc();
+                }
 
                 // Get it from stream
 
                 // Get it from stream
-                m_inputStream.FlattenConsume(binaryPacket, sizeof(Protocol::Header) + header.size);
+                m_inputStream.FlattenConsume(
+                    binaryPacket,
+                    sizeof(Protocol::Header) +
+                    header.size);
 
                 // Parse specific packet
 
                 // Parse specific packet
-                switch (header.type)
+                switch (header.type) {
+                case Protocol::PacketType_AsyncCall:
                 {
                 {
-                    case Protocol::PacketType_AsyncCall:
-                        {
-                            BinaryQueue call;
-
-                            // No need to delete packet data, we can use it
-                            call.AppendUnmanaged(binaryPacket, sizeof(Protocol::Header) + header.size, &BinaryQueue::BufferDeleterFree, NULL);
-
-                            // ...but just remove protocol header
-                            call.Consume(sizeof(Protocol::Header));
-
-                            LogPedantic("Async call of size: " << header.size << " parsed");
-
-                            // Call async call event listeners
-                            DPL::Event::EventSupport<AbstractRPCConnectionEvents::AsyncCallEvent>::
-                                EmitEvent(AbstractRPCConnectionEvents::AsyncCallEvent(
-                                    RPCFunction(call), EventSender(this)), DPL::Event::EmitMode::Queued);
-                        }
-                        break;
+                    BinaryQueue call;
+
+                    // No need to delete packet data, we can use it
+                    call.AppendUnmanaged(binaryPacket,
+                                         sizeof(Protocol::Header) + header.size,
+                                         &BinaryQueue::BufferDeleterFree,
+                                         NULL);
+
+                    // ...but just remove protocol header
+                    call.Consume(sizeof(Protocol::Header));
+
+                    LogPedantic(
+                        "Async call of size: " << header.size <<
+                        " parsed");
+
+                    // Call async call event listeners
+                    DPL::Event::EventSupport<AbstractRPCConnectionEvents::
+                                                 AsyncCallEvent>::
+                        EmitEvent(AbstractRPCConnectionEvents::AsyncCallEvent(
+                                      RPCFunction(call), EventSender(
+                                          this)), DPL::Event::EmitMode::Queued);
+                }
+                break;
 
 
-                    case Protocol::PacketType_PingPong:
-                        {
-                            // Reply with ping/pong
-                            Ping();
+                case Protocol::PacketType_PingPong:
+                {
+                    // Reply with ping/pong
+                    Ping();
 
 
-                            // Do not need packet data
-                            free(binaryPacket);
+                    // Do not need packet data
+                    free(binaryPacket);
 
 
-                            LogPedantic("Ping pong replied");
-                        }
-                        break;
+                    LogPedantic("Ping pong replied");
+                }
+                break;
 
 
-                    default:
-                        LogPedantic("Warning: Unknown packet type");
-                        free(binaryPacket);
-                        break;
+                default:
+                    LogPedantic("Warning: Unknown packet type");
+                    free(binaryPacket);
+                    break;
                 }
                 }
-            }
-            else
-            {
+            } else {
                 LogPedantic("Too few bytes to read packet");
                 break;
             }
         }
                 LogPedantic("Too few bytes to read packet");
                 break;
             }
         }
-    }
-    else
-    {
+    } else {
         LogPedantic("Too few bytes to read header");
     }
 }
         LogPedantic("Too few bytes to read header");
     }
 }
@@ -203,18 +207,19 @@ void GenericRPCConnection::OnInputStreamRead()
 void GenericRPCConnection::OnInputStreamClosed()
 {
     // Emit closed event
 void GenericRPCConnection::OnInputStreamClosed()
 {
     // Emit closed event
-    DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionClosedEvent>::
+    DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionClosedEvent>
+        ::
         EmitEvent(AbstractRPCConnectionEvents::ConnectionClosedEvent(
         EmitEvent(AbstractRPCConnectionEvents::ConnectionClosedEvent(
-            EventSender(this)), DPL::Event::EmitMode::Queued);
+                      EventSender(this)), DPL::Event::EmitMode::Queued);
 }
 
 void GenericRPCConnection::OnInputStreamBroken()
 {
     // Emit broken event
 }
 
 void GenericRPCConnection::OnInputStreamBroken()
 {
     // Emit broken event
-    DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionBrokenEvent>::
+    DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionBrokenEvent>
+        ::
         EmitEvent(AbstractRPCConnectionEvents::ConnectionBrokenEvent(
         EmitEvent(AbstractRPCConnectionEvents::ConnectionBrokenEvent(
-            EventSender(this)), DPL::Event::EmitMode::Queued);
+                      EventSender(this)), DPL::Event::EmitMode::Queued);
 }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index 3c09aac..51c1b97 100644 (file)
  * @file        generic_socket_rpc_client.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        generic_socket_rpc_client.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of generic socket RPC client
+ * @brief       This file is the implementation file of generic socket RPC
+ * client
  */
  */
+#include <stddef.h>
 #include <dpl/rpc/generic_socket_rpc_client.h>
 
 //
 #include <dpl/rpc/generic_socket_rpc_client.h>
 
 //
index 0786c62..2d84a4a 100644 (file)
  * @file        generic_socket_rpc_connection.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        generic_socket_rpc_connection.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of generic socket RPC connection
+ * @brief       This file is the implementation file of generic socket RPC
+ * connection
  */
  */
+#include <stddef.h>
 #include <dpl/rpc/generic_socket_rpc_connection.h>
 
 //
 #include <dpl/rpc/generic_socket_rpc_connection.h>
 
 //
index 2472c66..a0590f4 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of generic socket RPC
  */
  * @version     1.0
  * @brief       This file is the implementation file of generic socket RPC
  */
+#include <stddef.h>
 #include <dpl/rpc/generic_socket_rpc_server.h>
 
 //
 #include <dpl/rpc/generic_socket_rpc_server.h>
 
 //
index fb24741..8b105f2 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of unix socket RPC client
  */
  * @version     1.0
  * @brief       This file is the implementation file of unix socket RPC client
  */
+#include <stddef.h>
 #include <dpl/rpc/unix_socket_rpc_client.h>
 #include <dpl/rpc/unix_socket_rpc_connection.h>
 
 #include <dpl/rpc/unix_socket_rpc_client.h>
 #include <dpl/rpc/unix_socket_rpc_connection.h>
 
-namespace DPL
-{
-namespace RPC
-{
-AbstractRPCConnection *UnixSocketRPCClient::OpenSpecificConnection(DPL::Socket::UnixSocket *socket)
+namespace DPL {
+namespace RPC {
+AbstractRPCConnection *UnixSocketRPCClient::OpenSpecificConnection(
+    DPL::Socket::UnixSocket *socket)
 {
     // Allocate new UNIX/RPC connection object
     UnixSocketRPCConnection *connection = new UnixSocketRPCConnection(socket);
 {
     // Allocate new UNIX/RPC connection object
     UnixSocketRPCConnection *connection = new UnixSocketRPCConnection(socket);
@@ -37,7 +37,8 @@ AbstractRPCConnection *UnixSocketRPCClient::OpenSpecificConnection(DPL::Socket::
 
 AbstractRPCConnectionID UnixSocketRPCClient::Open(const std::string &fileName)
 {
 
 AbstractRPCConnectionID UnixSocketRPCClient::Open(const std::string &fileName)
 {
-    return GenericSocketRPCClient<DPL::Socket::UnixSocket>::Open(Address(fileName));
+    return GenericSocketRPCClient<DPL::Socket::UnixSocket>::Open(Address(
+                                                                     fileName));
 }
 }
 } // namespace DPL
 }
 }
 } // namespace DPL
index 28fea84..b21098d 100644 (file)
  * @file        unix_socket_rpc_connection.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        unix_socket_rpc_connection.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of unix socket RPC connection
+ * @brief       This file is the implementation file of unix socket RPC
+ * connection
  */
  */
+#include <stddef.h>
 #include <dpl/rpc/unix_socket_rpc_connection.h>
 
 #include <dpl/rpc/unix_socket_rpc_connection.h>
 
-namespace DPL
-{
-namespace RPC
-{
-UnixSocketRPCConnection::UnixSocketRPCConnection(DPL::Socket::UnixSocket *socket)
-    : GenericSocketRPCConnection<DPL::Socket::UnixSocket>(socket)
-{
-}
+namespace DPL {
+namespace RPC {
+UnixSocketRPCConnection::UnixSocketRPCConnection(
+    DPL::Socket::UnixSocket *socket) :
+    GenericSocketRPCConnection<DPL::Socket::UnixSocket>(socket)
+{}
 }
 } // namespace DPL
 }
 } // namespace DPL
index ea71eb7..e9dd9ab 100644 (file)
  * @version     1.0
  * @brief       This file is the implementation file of unix socket RPC server
  */
  * @version     1.0
  * @brief       This file is the implementation file of unix socket RPC server
  */
+#include <stddef.h>
 #include <dpl/rpc/unix_socket_rpc_server.h>
 #include <dpl/rpc/unix_socket_rpc_connection.h>
 
 #include <dpl/rpc/unix_socket_rpc_server.h>
 #include <dpl/rpc/unix_socket_rpc_connection.h>
 
-namespace DPL
-{
-namespace RPC
-{
-AbstractRPCConnection *UnixSocketRPCServer::OpenSpecificConnection(DPL::Socket::UnixSocket *socket)
+namespace DPL {
+namespace RPC {
+AbstractRPCConnection *UnixSocketRPCServer::OpenSpecificConnection(
+    DPL::Socket::UnixSocket *socket)
 {
     // Allocate new UNIX/RPC connection object
     UnixSocketRPCConnection *connection = new UnixSocketRPCConnection(socket);
 {
     // Allocate new UNIX/RPC connection object
     UnixSocketRPCConnection *connection = new UnixSocketRPCConnection(socket);
@@ -37,8 +37,8 @@ AbstractRPCConnection *UnixSocketRPCServer::OpenSpecificConnection(DPL::Socket::
 
 AbstractRPCConnectionID UnixSocketRPCServer::Open(const std::string &fileName)
 {
 
 AbstractRPCConnectionID UnixSocketRPCServer::Open(const std::string &fileName)
 {
-    return GenericSocketRPCServer<DPL::Socket::UnixSocket>::Open(Address(fileName));
+    return GenericSocketRPCServer<DPL::Socket::UnixSocket>::Open(Address(
+                                                                     fileName));
 }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
diff --git a/modules/security_origin_dao/CMakeLists.txt b/modules/security_origin_dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4e74cc3
--- /dev/null
@@ -0,0 +1,57 @@
+SET(TARGET_SECURITY_ORIGIN_DAO_DB "Sqlite3DbSecurityOrigin")
+
+ADD_CUSTOM_COMMAND( OUTPUT .security_origin.db
+   COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/.security_origin.db
+   COMMAND gcc -Wall -I${PROJECT_SOURCE_DIR}/modules/db/include -I${PROJECT_SOURCE_DIR}/modules/security_origin_dao/orm -E ${PROJECT_SOURCE_DIR}/modules/security_origin_dao/orm/security_origin_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_BINARY_DIR}/security_origin_db.sql
+   COMMAND sqlite3 ${CMAKE_CURRENT_BINARY_DIR}/.security_origin.db ".read ${CMAKE_CURRENT_BINARY_DIR}/security_origin_db.sql" || rm -f ${CMAKE_CURRENT_BINARY_DIR}/.security_origin.db
+   DEPENDS ${PROJECT_SOURCE_DIR}/modules/security_origin_dao/orm/security_origin_db_sql_generator.h ${PROJECT_SOURCE_DIR}/modules/security_origin_dao/orm/security_origin_db
+   )
+
+ADD_CUSTOM_COMMAND( OUTPUT .security_origin.db-journal
+   COMMAND touch
+   ARGS  ${CMAKE_CURRENT_BINARY_DIR}/.security_origin.db-journal
+   )
+
+ADD_CUSTOM_TARGET(${TARGET_SECURITY_ORIGIN_DAO_DB} ALL DEPENDS .security_origin.db .security_origin.db-journal)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/security_origin_db.sql DESTINATION share/wrt-engine/)
+
+###############################################################################
+
+INCLUDE(FindPkgConfig)
+
+PKG_CHECK_MODULES(SECURITY_ORIGIN_DAO_DEPS
+    glib-2.0
+    REQUIRED)
+
+SET(SECURITY_ORIGIN_DAO_INCLUDE_DIRS
+    ${PROJECT_SOURCE_DIR}/modules/security_origin_dao/include
+    ${PROJECT_SOURCE_DIR}/modules/security_origin_dao/orm
+    ${PROJECT_SOURCE_DIR}/modules/core/include
+    ${PROJECT_SOURCE_DIR}/modules/db/include
+    ${PROJECT_SOURCE_DIR}/modules/log/include
+    ${PROJECT_SOURCE_DIR}/modules/widget_dao/include
+)
+
+SET(SECURITY_ORIGIN_DAO_SOURCES
+    dao/security_origin_dao_types.cpp
+    dao/security_origin_database.cpp
+    dao/security_origin_dao.cpp
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${SECURITY_ORIGIN_DAO_DEPS_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES(${SECURITY_ORIGIN_DAO_INCLUDE_DIRS})
+
+ADD_LIBRARY(${TARGET_SECURITY_ORIGIN_DAO_LIB} SHARED ${SECURITY_ORIGIN_DAO_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_SECURITY_ORIGIN_DAO_LIB} PROPERTIES SOVERSION ${API_VERSION} VERSION ${VERSION})
+TARGET_LINK_LIBRARIES(${TARGET_SECURITY_ORIGIN_DAO_LIB} ${TARGET_DPL_EFL} ${TARGET_DPL_DB_EFL} ${TARGET_WRT_DAP_RO_LIB} ${SECURITY_ORIGIN_DAO_DEPS_LIBRARIES})
+ADD_DEPENDENCIES(${TARGET_SECURITY_ORIGIN_DAO_LIB} ${TARGET_SECURITY_ORIGIN_DAO_DB})
+
+INSTALL(TARGETS ${TARGET_SECURITY_ORIGIN_DAO_LIB} DESTINATION lib)
+
+INSTALL(FILES
+    include/wrt-commons/security-origin-dao/security_origin_dao_types.h
+    include/wrt-commons/security-origin-dao/security_origin_database.h
+    include/wrt-commons/security-origin-dao/security_origin_dao.h
+    DESTINATION include/dpl-efl/wrt-commons/security-origin-dao
+)
+
diff --git a/modules/security_origin_dao/dao/security_origin_dao.cpp b/modules/security_origin_dao/dao/security_origin_dao.cpp
new file mode 100644 (file)
index 0000000..07c816f
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    security_origin_dao.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief    This file contains the definition of security origin dao class.
+ */
+
+#include <wrt-commons/security-origin-dao/security_origin_database.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
+#include <orm_generator_security_origin.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+#include <dpl/wrt-dao-ro/widget_config.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <sys/stat.h>
+#include <fstream>
+
+using namespace DPL::DB::ORM;
+using namespace DPL::DB::ORM::security_origin;
+
+namespace SecurityOriginDB {
+#define SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN          Try
+
+#define SQL_CONNECTION_EXCEPTION_HANDLER_END(message)   \
+    Catch(DPL::DB::SqlConnection::Exception::Base) {       \
+        LogError(message);                              \
+        ReThrowMsg(SecurityOriginDAO::Exception::DatabaseError, \
+                   message);                            \
+    }
+
+namespace {
+DPL::DB::SqlConnection::Flag::Option SECURITY_ORIGIN_DB_OPTION =
+    DPL::DB::SqlConnection::Flag::RW;
+DPL::DB::SqlConnection::Flag::Type SECURITY_ORIGIN_DB_TYPE =
+    DPL::DB::SqlConnection::Flag::UseLucene;
+const char* const SECURITY_ORIGIN_DB_NAME = ".security_origin.db";
+const char* const SECURITY_ORIGIN_DB_SQL_PATH =
+    "/usr/share/wrt-engine/security_origin_db.sql";
+
+std::string createDatabasePath(const WrtDB::WidgetPkgName &pkgName)
+{
+    std::stringstream filename;
+
+    filename << WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(pkgName)
+             << "/"
+             << SECURITY_ORIGIN_DB_NAME;
+    return filename.str();
+}
+
+std::string createDatabasePath(int widgetHandle)
+{
+    using namespace DPL::DB::ORM;
+    using namespace WrtDB::WidgetConfig;
+    using namespace WrtDB::GlobalConfig;
+
+    WrtDB::TizenAppId appid;
+
+    Try
+    {
+        appid = WrtDB::WidgetDAOReadOnly::getTzAppId(widgetHandle);
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base) {
+        LogError("Failed to get database Path");
+    }
+    return createDatabasePath(appid);
+}
+
+void checkDatabase(std::string databasePath)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        if (databasePath.empty()) {
+            ThrowMsg(SecurityOriginDAO::Exception::DatabaseError,
+                     "Wrong database Path is passed");
+        }
+
+        struct stat buffer;
+        if (stat(databasePath.c_str(), &buffer) != 0) {
+            //Create fresh database
+            LogInfo("Creating database " << databasePath);
+
+            std::fstream file;
+            file.open(SECURITY_ORIGIN_DB_SQL_PATH, std::ios_base::in);
+            if (!file) {
+                ThrowMsg(SecurityOriginDAO::Exception::DatabaseError,
+                         "Fail to get database Path");
+            }
+
+            std::stringstream ssBuffer;
+            ssBuffer << file.rdbuf();
+
+            file.close();
+
+            DPL::DB::SqlConnection con(databasePath,
+                                       SECURITY_ORIGIN_DB_TYPE,
+                                       SECURITY_ORIGIN_DB_OPTION);
+            con.ExecCommand(ssBuffer.str().c_str());
+        }
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to get database Path")
+}
+}
+
+SecurityOriginDAO::SecurityOriginDAO(int handle) :
+    m_securityOriginDBPath(createDatabasePath(handle)),
+    m_securityOriginDBInterface(m_securityOriginDBPath, SECURITY_ORIGIN_DB_TYPE)
+{
+    checkDatabase(m_securityOriginDBPath);
+    m_securityOriginDBInterface.AttachToThread(SECURITY_ORIGIN_DB_OPTION);
+}
+
+SecurityOriginDAO::SecurityOriginDAO(const WrtDB::WidgetPkgName &pkgName) :
+    m_securityOriginDBPath(createDatabasePath(pkgName)),
+    m_securityOriginDBInterface(m_securityOriginDBPath, SECURITY_ORIGIN_DB_TYPE)
+{
+    checkDatabase(m_securityOriginDBPath);
+    m_securityOriginDBInterface.AttachToThread(SECURITY_ORIGIN_DB_OPTION);
+}
+
+SecurityOriginDAO::~SecurityOriginDAO()
+{
+    m_securityOriginDBInterface.DetachFromThread();
+}
+
+SecurityOriginDataList SecurityOriginDAO::getSecurityOriginDataList(void)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        SecurityOriginDataList list;
+        SECURITY_ORIGIN_DB_SELECT(select,
+                                  SecurityOriginInfo,
+                                  &m_securityOriginDBInterface);
+        typedef std::list<SecurityOriginInfo::Row> RowList;
+        RowList rowList = select->GetRowList();
+
+        FOREACH(it, rowList) {
+            Origin origin(it->Get_scheme(), it->Get_host(), it->Get_port());
+            list.push_back(
+                SecurityOriginDataPtr(
+                    new SecurityOriginData(
+                        static_cast<Feature>(it->Get_feature()), origin)));
+        }
+        return list;
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get data  list")
+}
+
+Result SecurityOriginDAO::getResult(
+    const SecurityOriginData &securityOriginData)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        SECURITY_ORIGIN_DB_SELECT(select,
+                                  SecurityOriginInfo,
+                                  &m_securityOriginDBInterface);
+        select->Where(
+            And(And(And(Equals<SecurityOriginInfo::feature>(securityOriginData.
+                                                                feature),
+                        Equals<SecurityOriginInfo::scheme>(securityOriginData.
+                                                               origin.scheme)),
+                    Equals<SecurityOriginInfo::host>(securityOriginData.origin.
+                                                         host)),
+                Equals<SecurityOriginInfo::port>(securityOriginData.origin.port)));
+        SecurityOriginInfo::Select::RowList rows = select->GetRowList();
+
+        if (rows.empty()) {
+            return RESULT_UNKNOWN;
+        }
+        SecurityOriginInfo::Row row = rows.front();
+        return static_cast<Result>(row.Get_result());
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END(
+        "Failed to get result for security origin")
+}
+
+void SecurityOriginDAO::setSecurityOriginData(
+    const SecurityOriginData &securityOriginData,
+    const Result result)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        ScopedTransaction transaction(&m_securityOriginDBInterface);
+        SecurityOriginInfo::Row row;
+        row.Set_feature(securityOriginData.feature);
+        row.Set_scheme(securityOriginData.origin.scheme);
+        row.Set_host(securityOriginData.origin.host);
+        row.Set_port(securityOriginData.origin.port);
+        row.Set_result(result);
+
+        if (true == hasResult(securityOriginData)) {
+            SECURITY_ORIGIN_DB_UPDATE(update,
+                                      SecurityOriginInfo,
+                                      &m_securityOriginDBInterface);
+            update->Values(row);
+            update->Execute();
+        } else {
+            SECURITY_ORIGIN_DB_INSERT(
+                insert,
+                SecurityOriginInfo,
+                &m_securityOriginDBInterface);
+            insert->Values(row);
+            insert->Execute();
+        }
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to set security origin data")
+}
+
+void SecurityOriginDAO::removeSecurityOriginData(
+    const SecurityOriginData &securityOriginData)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        ScopedTransaction transaction(&m_securityOriginDBInterface);
+
+        if (true == hasResult(securityOriginData)) {
+            SECURITY_ORIGIN_DB_DELETE(del,
+                                      SecurityOriginInfo,
+                                      &m_securityOriginDBInterface)
+            del->Where(
+                And(And(And(Equals<SecurityOriginInfo::feature>(
+                                securityOriginData.feature),
+                            Equals<SecurityOriginInfo::scheme>(
+                                securityOriginData.origin.scheme)),
+                        Equals<SecurityOriginInfo::host>(securityOriginData.
+                                                             origin.host)),
+                    Equals<SecurityOriginInfo::port>(securityOriginData.origin.
+                                                         port)));
+            del->Execute();
+            transaction.Commit();
+        }
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to set security origin data")
+}
+
+void SecurityOriginDAO::removeSecurityOriginData(const Result result)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        ScopedTransaction transaction(&m_securityOriginDBInterface);
+        SECURITY_ORIGIN_DB_DELETE(del,
+                                  SecurityOriginInfo,
+                                  &m_securityOriginDBInterface)
+        del->Where(Equals<SecurityOriginInfo::result>(result));
+        del->Execute();
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to remove data by result")
+}
+
+bool SecurityOriginDAO::hasResult(const SecurityOriginData &securityOriginData)
+{
+    Result res = getResult(securityOriginData);
+    return (res != RESULT_UNKNOWN);
+}
+
+#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
+} // namespace SecurityOriginDB
diff --git a/modules/security_origin_dao/dao/security_origin_dao_types.cpp b/modules/security_origin_dao/dao/security_origin_dao_types.cpp
new file mode 100644 (file)
index 0000000..601b277
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    security_origin_dao_types.cpp
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the implementation of
+ *             common data types for wrt_security_origin.db
+ */
+
+#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
+#include <dpl/log/log.h>
+
+namespace SecurityOriginDB {} // namespace SecurityOriginDB
\ No newline at end of file
diff --git a/modules/security_origin_dao/dao/security_origin_database.cpp b/modules/security_origin_dao/dao/security_origin_database.cpp
new file mode 100644 (file)
index 0000000..0564a18
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 <wrt-commons/security-origin-dao/security_origin_database.h>
+
+DPL::Mutex g_securityOriginDBQueriesMutex;
diff --git a/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h b/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao.h
new file mode 100644 (file)
index 0000000..f9ad12f
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    securoty_origin_dao.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of security origin dao
+ */
+#ifndef _SECURITY_ORIGIN_DAO_H_
+#define _SECURITY_ORIGIN_DAO_H_
+
+#include <dpl/db/thread_database_support.h>
+#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+
+namespace SecurityOriginDB {
+class SecurityOriginDAO
+{
+  public:
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
+        DECLARE_EXCEPTION_TYPE(Base, DataNotExist)
+    };
+
+    explicit SecurityOriginDAO(int handle) __attribute__((deprecated));
+    explicit SecurityOriginDAO(const WrtDB::WidgetPkgName &pkgName);
+    virtual ~SecurityOriginDAO();
+    SecurityOriginDataList getSecurityOriginDataList();
+    Result getResult(const SecurityOriginData &securityOriginData);
+    void setSecurityOriginData(const SecurityOriginData &securityOriginData,
+                               const Result result);
+    void removeSecurityOriginData(const SecurityOriginData &securityOriginData);
+    void removeSecurityOriginData(const Result result);
+
+  private:
+    std::string m_securityOriginDBPath;
+    DPL::DB::ThreadDatabaseSupport m_securityOriginDBInterface;
+    bool hasResult(const SecurityOriginData &securityOriginData);
+};
+
+typedef std::shared_ptr<SecurityOriginDAO> SecurityOriginDAOPtr;
+} // namespace SecurityOriginDB
+
+#endif // _SECURITY_ORIGIN_DAO_H_
diff --git a/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao_types.h b/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_dao_types.h
new file mode 100644 (file)
index 0000000..c517f05
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    security_origin_dao_types.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief This file contains the declaration of
+ *           common data types for security origin database.
+ */
+#ifndef _SECURITY_ORIGIN_DAO_TYPES_H_
+#define _SECURITY_ORIGIN_DAO_TYPES_H_
+
+#include <list>
+#include <memory>
+#include <dpl/string.h>
+
+namespace SecurityOriginDB {
+enum Feature
+{
+    FEATURE_START = 0,
+    FEATURE_GEOLOCATION = 0,
+    FEATURE_WEB_NOTIFICATION,
+    FEATURE_WEB_DATABASE,
+    FEATURE_FILE_SYSTEM_ACCESS,
+    FEATURE_END = FEATURE_FILE_SYSTEM_ACCESS
+};
+
+enum Result
+{
+    RESULT_UNKNOWN = 0,
+    RESULT_ALLOW_ONCE,
+    RESULT_DENY_ONCE,
+    RESULT_ALLOW_ALWAYS,
+    RESULT_DENY_ALWAYS
+};
+
+struct Origin
+{
+    DPL::String scheme;
+    DPL::String host;
+    unsigned int port;
+
+    Origin(const DPL::String& Scheme,
+           const DPL::String& Host,
+           const unsigned int Port) :
+        scheme(Scheme),
+        host(Host),
+        port(Port)
+    {}
+
+    bool operator== (const Origin& other) const
+    {
+        return (!DPL::StringCompare(scheme, other.scheme) &&
+                !DPL::StringCompare(host, other.host) &&
+                port == other.port);
+    }
+
+    bool operator!= (const Origin& other) const
+    {
+        return !(*this == other);
+    }
+};
+
+struct SecurityOriginData
+{
+    Feature feature;
+    Origin origin;
+
+    SecurityOriginData(const Feature features, const Origin& ori) :
+        feature(features),
+        origin(ori)
+    {}
+
+    bool operator== (const SecurityOriginData& other) const
+    {
+        return !(origin == other.origin) &&
+               !(feature == other.feature);
+    }
+
+    bool operator!= (const SecurityOriginData& other) const
+    {
+        return !(*this == other);
+    }
+};
+
+typedef std::shared_ptr<SecurityOriginData> SecurityOriginDataPtr;
+typedef std::list<SecurityOriginDataPtr> SecurityOriginDataList;
+} // namespace SecurityOriginDB
+
+#endif // _SECURITY_ORIGIN_DAO_TYPES_H_
diff --git a/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_database.h b/modules/security_origin_dao/include/wrt-commons/security-origin-dao/security_origin_database.h
new file mode 100644 (file)
index 0000000..d401620
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _SECURITY_ORIGIN_DATABASE_H_
+#define _SECURITY_ORIGIN_DATABASE_H_
+
+#include <dpl/thread.h>
+#include <dpl/mutex.h>
+
+extern DPL::Mutex g_securityOriginDBQueriesMutex;
+
+#define SECURITY_ORIGIN_DB_INTERNAL(tlsCommand, InternalType, interface)            \
+    static DPL::ThreadLocalVariable<InternalType> *tlsCommand##Ptr = NULL; \
+    {                                                                        \
+        DPL::Mutex::ScopedLock lock(&g_securityOriginDBQueriesMutex);              \
+        if (!tlsCommand##Ptr) {                                            \
+            static DPL::ThreadLocalVariable<InternalType> tmp;               \
+            tlsCommand##Ptr = &tmp;                                        \
+        }                                                                    \
+    }                                                                        \
+    DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand##Ptr; \
+    if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); }
+
+#define SECURITY_ORIGIN_DB_SELECT(name, type, interface) \
+    SECURITY_ORIGIN_DB_INTERNAL(name, type::Select, interface)
+
+#define SECURITY_ORIGIN_DB_INSERT(name, type, interface) \
+    SECURITY_ORIGIN_DB_INTERNAL(name, type::Insert, interface)
+
+#define SECURITY_ORIGIN_DB_UPDATE(name, type, interface) \
+    SECURITY_ORIGIN_DB_INTERNAL(name, type::Update, interface)
+
+#define SECURITY_ORIGIN_DB_DELETE(name, type, interface) \
+    SECURITY_ORIGIN_DB_INTERNAL(name, type::Delete, interface)
+
+#endif // _SECURITY_ORIGIN_DATABASE_H_
+
diff --git a/modules/security_origin_dao/orm/orm_generator_security_origin.h b/modules/security_origin_dao/orm/orm_generator_security_origin.h
new file mode 100644 (file)
index 0000000..84888de
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _ORM_GENERATOR_SECURITY_ORIGIN_H_
+#define _ORM_GENERATOR_SECURITY_ORIGIN_H_
+
+#define ORM_GENERATOR_DATABASE_NAME security_origin_db_definitions
+#include <dpl/db/orm_generator.h>
+#undef ORM_GENERATOR_DATABASE_NAME
+
+#endif // _ORM_GENERATOR_SECURITY_ORIGIN_H_
diff --git a/modules/security_origin_dao/orm/security_origin_db b/modules/security_origin_dao/orm/security_origin_db
new file mode 100644 (file)
index 0000000..cb45aa4
--- /dev/null
@@ -0,0 +1,12 @@
+SQL(BEGIN TRANSACTION;)
+
+CREATE_TABLE(SecurityOriginInfo)
+    COLUMN_NOT_NULL(feature, INT, )
+    COLUMN_NOT_NULL(scheme,  TEXT,DEFAULT '')
+    COLUMN_NOT_NULL(host,    TEXT,DEFAULT '')
+    COLUMN_NOT_NULL(port,    INT, DEFAULT 0)
+    COLUMN_NOT_NULL(result,  INT, DEFAULT 0)
+    TABLE_CONSTRAINTS(PRIMARY KEY(feature,scheme,host,port))
+CREATE_TABLE_END()
+
+SQL(COMMIT;)
diff --git a/modules/security_origin_dao/orm/security_origin_db_definitions b/modules/security_origin_dao/orm/security_origin_db_definitions
new file mode 100644 (file)
index 0000000..dc74f98
--- /dev/null
@@ -0,0 +1,5 @@
+DATABASE_START(security_origin)
+
+#include "security_origin_db"
+
+DATABASE_END()
diff --git a/modules/security_origin_dao/orm/security_origin_db_sql_generator.h b/modules/security_origin_dao/orm/security_origin_db_sql_generator.h
new file mode 100644 (file)
index 0000000..3bdbe6d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        security_origin_db_sql_generator.h
+ * @author      Jihoon Chung (jihoon.chung@samsung.com)
+ * @version     1.0
+ * @brief       Macro definitions for generating the SQL
+ *                input file from database definition.
+ */
+
+//Do not include this file directly! It is used only for SQL code generation.
+#include <dpl/db/orm_macros.h>
+
+#include "security_origin_db_definitions"
index 90a8fa6..0c06f99 100644 (file)
 #include <dpl/exception.h>
 #include <dpl/address.h>
 
 #include <dpl/exception.h>
 #include <dpl/address.h>
 
-namespace DPL
-{
-namespace Socket
-{
-namespace AbstractSocketEvents
-{
+namespace DPL {
+namespace Socket {
+namespace AbstractSocketEvents {
 // Successfuly connected to server socket
 DECLARE_GENERIC_EVENT_0(ConnectedEvent)
 
 // Successfuly connected to server socket
 DECLARE_GENERIC_EVENT_0(ConnectedEvent)
 
@@ -47,51 +44,144 @@ DECLARE_GENERIC_EVENT_0(ReadEvent)
 DECLARE_GENERIC_EVENT_0(WriteEvent)
 } // namespace AbstractSocketEvents
 
 DECLARE_GENERIC_EVENT_0(WriteEvent)
 } // namespace AbstractSocketEvents
 
-class AbstractSocket
-    public AbstractWaitableInputOutput,
-      public DPL::Event::EventSupport<AbstractSocketEvents::ConnectedEvent>,
-      public DPL::Event::EventSupport<AbstractSocketEvents::AcceptEvent>,
-      public DPL::Event::EventSupport<AbstractSocketEvents::ReadEvent>,
-      public DPL::Event::EventSupport<AbstractSocketEvents::WriteEvent>
+class AbstractSocket :
+    public AbstractWaitableInputOutput,
+    public DPL::Event::EventSupport<AbstractSocketEvents::ConnectedEvent>,
+    public DPL::Event::EventSupport<AbstractSocketEvents::AcceptEvent>,
+    public DPL::Event::EventSupport<AbstractSocketEvents::ReadEvent>,
+    public DPL::Event::EventSupport<AbstractSocketEvents::WriteEvent>
 {
 {
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
-        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)       ///< Base abstract socket exception
-
-        DECLARE_EXCEPTION_TYPE(Base, OpenFailed)           ///< Fatal error occurred during open socket descriptor. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, ConnectFailed)        ///< Fatal error occurred during connect. Socket state is inconsistent and it should be not used anymore.
-                                                           ///< Warning: This exception does not mean that socket did not succeed to connect, see CannotConnect
-                                                           ///< for this specific scenario
-
-        DECLARE_EXCEPTION_TYPE(Base, SetNonBlockingFailed) ///< Fatal error occurred during setting socket to non-blocking mode. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, BindFailed)           ///< Fatal error occurred during bind. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, AcceptFailed)         ///< Fatal error occurred during accept. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, ListenFailed)         ///< Fatal error occurred during listen. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, CloseFailed)          ///< Fatal error occurred during close. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, ReadFailed)           ///< Fatal error occurred during read. Socket state is inconsistent and it should be not used anymore.
-                                                           ///< Warning: This exception does not mean that connection was broken, see ConnectionBroken
-                                                           ///< for this specific scenario
-
-        DECLARE_EXCEPTION_TYPE(Base, WriteFailed)          ///< Fatal error occurred during write. Socket state is inconsistent and it should be not used anymore.
-                                                           ///< Warning: This exception does not mean that connection was broken, see ConnectionBroken
-                                                           ///< for this specific scenario
-
-        DECLARE_EXCEPTION_TYPE(Base, GetPeerNameFailed)    ///< Fatal error occurred during getpeername or getsockname. Socket state is inconsistent and it should be not used anymore.
-
-        DECLARE_EXCEPTION_TYPE(Base, CannotConnect)        ///< Cannot connect to remote socket. This is not fatal error, socket state is still consistent and it can be reconnected.
-
-        DECLARE_EXCEPTION_TYPE(Base, ConnectionBroken)     ///< Connection was broken. This is not fatal error, socket state is still consistent and it can be reconnected.
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)       ///< Base abstract
+                                                           // socket exception
+
+        DECLARE_EXCEPTION_TYPE(Base, OpenFailed)           ///< Fatal error
+                                                           // occurred during
+                                                           // open socket
+                                                           // descriptor. Socket
+                                                           // state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, ConnectFailed)        ///< Fatal error
+                                                           // occurred during
+                                                           // connect. Socket
+                                                           // state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+                                                           ///< Warning: This
+                                                           // exception does not
+                                                           // mean that socket
+                                                           // did not succeed to
+                                                           // connect, see
+                                                           // CannotConnect
+                                                           ///< for this
+                                                           // specific scenario
+
+        DECLARE_EXCEPTION_TYPE(Base, SetNonBlockingFailed) ///< Fatal error
+                                                           // occurred during
+                                                           // setting socket to
+                                                           // non-blocking mode.
+                                                           // Socket state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, BindFailed)           ///< Fatal error
+                                                           // occurred during
+                                                           // bind. Socket state
+                                                           // is inconsistent
+                                                           // and it should be
+                                                           // not used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, AcceptFailed)         ///< Fatal error
+                                                           // occurred during
+                                                           // accept. Socket
+                                                           // state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, ListenFailed)         ///< Fatal error
+                                                           // occurred during
+                                                           // listen. Socket
+                                                           // state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, CloseFailed)          ///< Fatal error
+                                                           // occurred during
+                                                           // close. Socket
+                                                           // state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, ReadFailed)           ///< Fatal error
+                                                           // occurred during
+                                                           // read. Socket state
+                                                           // is inconsistent
+                                                           // and it should be
+                                                           // not used anymore.
+                                                           ///< Warning: This
+                                                           // exception does not
+                                                           // mean that
+                                                           // connection was
+                                                           // broken, see
+                                                           // ConnectionBroken
+                                                           ///< for this
+                                                           // specific scenario
+
+        DECLARE_EXCEPTION_TYPE(Base, WriteFailed)          ///< Fatal error
+                                                           // occurred during
+                                                           // write. Socket
+                                                           // state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+                                                           ///< Warning: This
+                                                           // exception does not
+                                                           // mean that
+                                                           // connection was
+                                                           // broken, see
+                                                           // ConnectionBroken
+                                                           ///< for this
+                                                           // specific scenario
+
+        DECLARE_EXCEPTION_TYPE(Base, GetPeerNameFailed)    ///< Fatal error
+                                                           // occurred during
+                                                           // getpeername or
+                                                           // getsockname.
+                                                           // Socket state is
+                                                           // inconsistent and
+                                                           // it should be not
+                                                           // used anymore.
+
+        DECLARE_EXCEPTION_TYPE(Base, CannotConnect)        ///< Cannot connect
+                                                           // to remote socket.
+                                                           // This is not fatal
+                                                           // error, socket
+                                                           // state is still
+                                                           // consistent and it
+                                                           // can be
+                                                           // reconnected.
+
+        DECLARE_EXCEPTION_TYPE(Base, ConnectionBroken)     ///< Connection was
+                                                           // broken. This is
+                                                           // not fatal error,
+                                                           // socket state is
+                                                           // still consistent
+                                                           // and it can be
+                                                           // reconnected.
     };
 
     };
 
-public:
+  public:
     virtual ~AbstractSocket() {}
 
     // Connect to remote host
     virtual ~AbstractSocket() {}
 
     // Connect to remote host
@@ -119,7 +209,6 @@ public:
     // Remote socket address
     virtual Address GetRemoteAddress() const = 0;
 };
     // Remote socket address
     virtual Address GetRemoteAddress() const = 0;
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index f54d752..3ed9b86 100644 (file)
 #include <errno.h>
 #include <dpl/assert.h>
 
 #include <errno.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-namespace Socket
-{
+namespace DPL {
+namespace Socket {
 //
 // Generic abstract socket implementation
 // Execution context is inherited
 //
 template<typename SocketType>
 //
 // Generic abstract socket implementation
 // Execution context is inherited
 //
 template<typename SocketType>
-class GenericSocket
-    public AbstractSocket,
-      private WaitableHandleWatchSupport::WaitableHandleListener
+class GenericSocket :
+    public AbstractSocket,
+    private WaitableHandleWatchSupport::WaitableHandleListener
 {
 {
-protected:
+  protected:
     /**
      * Translate generic Address to specific socket kernel structure
      *
      * @warning Must be implemented in derived class
      */
     /**
      * Translate generic Address to specific socket kernel structure
      *
      * @warning Must be implemented in derived class
      */
-    virtual std::pair<sockaddr *, socklen_t> TranslateAddressGenericToSpecific(const Address &address) const = 0;
+    virtual std::pair<sockaddr *, socklen_t> TranslateAddressGenericToSpecific(
+        const Address &address) const = 0;
 
     /**
      * Translate specific socket kernel structure to generic Address
      *
      * @warning Must be implemented in derived class
      */
 
     /**
      * Translate specific socket kernel structure to generic Address
      *
      * @warning Must be implemented in derived class
      */
-    virtual Address TranslateAddressSpecificToGeneric(sockaddr *, socklen_t) const = 0;
+    virtual Address TranslateAddressSpecificToGeneric(sockaddr *,
+                                                      socklen_t) const = 0;
 
     /**
      * Get specific socket kernel structure size
 
     /**
      * Get specific socket kernel structure size
@@ -84,12 +84,13 @@ protected:
      */
     virtual int AllocSpecificDescriptor() const = 0;
 
      */
     virtual int AllocSpecificDescriptor() const = 0;
 
-private:
+  private:
     // Constants
     static const size_t DEFAULT_READ_BUFFER_SIZE = 4096;
 
     // Socket handle
     // Constants
     static const size_t DEFAULT_READ_BUFFER_SIZE = 4096;
 
     // Socket handle
-    int m_socket; // FIXME: Consider generalization to WaitableHandle upon leaving nix platform
+    int m_socket; // FIXME: Consider generalization to WaitableHandle upon
+                  // leaving nix platform
 
     // Internal state
     enum InternalState
 
     // Internal state
     enum InternalState
@@ -106,128 +107,143 @@ private:
     void SetNonBlocking()
     {
         // Set non-blocking mode
     void SetNonBlocking()
     {
         // Set non-blocking mode
-        if (fcntl(m_socket, F_SETFL, O_NONBLOCK | fcntl(m_socket, F_GETFL)) == -1)
+        if (fcntl(m_socket, F_SETFL, O_NONBLOCK |
+                  fcntl(m_socket, F_GETFL)) == -1)
+        {
             Throw(AbstractSocket::Exception::SetNonBlockingFailed);
             Throw(AbstractSocket::Exception::SetNonBlockingFailed);
+        }
     }
 
     // WaitableHandleWatchSupport::WaitableHandleListener
     }
 
     // WaitableHandleWatchSupport::WaitableHandleListener
-    virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle, WaitMode::Type mode)
+    virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle,
+                                       WaitMode::Type mode)
     {
         (void)waitableHandle;
         Assert(waitableHandle == m_socket);
 
     {
         (void)waitableHandle;
         Assert(waitableHandle == m_socket);
 
-        switch (m_internalState)
-        {
-            case InternalState_None:
-                break;
-
-            case InternalState_Prepare:
-                Assert(0 && "Invalid internal generic socket state!");
-                break;
+        switch (m_internalState) {
+        case InternalState_None:
+            break;
 
 
-            case InternalState_Listening:
-                Assert(mode == WaitMode::Read);
+        case InternalState_Prepare:
+            Assert(0 && "Invalid internal generic socket state!");
+            break;
 
 
-                // New client waiting for accept
-                DPL::Event::EventSupport<AbstractSocketEvents::AcceptEvent>::
-                    EmitEvent(AbstractSocketEvents::AcceptEvent(
-                        EventSender(this)), DPL::Event::EmitMode::Queued);
+        case InternalState_Listening:
+            Assert(mode == WaitMode::Read);
 
 
-                // Done
-                break;
+            // New client waiting for accept
+            DPL::Event::EventSupport<AbstractSocketEvents::AcceptEvent>::
+                EmitEvent(AbstractSocketEvents::AcceptEvent(
+                              EventSender(this)), DPL::Event::EmitMode::Queued);
 
 
-            case InternalState_Connecting:
-                Assert(mode == WaitMode::Write);
+            // Done
+            break;
 
 
-                // Connected to server
-                RemoveConnectWatch();
-                m_internalState = InternalState_Connected;
+        case InternalState_Connecting:
+            Assert(mode == WaitMode::Write);
 
 
-                // Add read watch
-                AddReadWatch();
-
-                // Emit event
-                DPL::Event::EventSupport<AbstractSocketEvents::ConnectedEvent>::
-                    EmitEvent(AbstractSocketEvents::ConnectedEvent(
-                        EventSender(this)), DPL::Event::EmitMode::Queued);
+            // Connected to server
+            RemoveConnectWatch();
+            m_internalState = InternalState_Connected;
 
 
-                // Done
-                break;
+            // Add read watch
+            AddReadWatch();
 
 
-            case InternalState_Connected:
-                if (mode == WaitMode::Read)
-                {
-                    // Emit ReadEvent
-                    DPL::Event::EventSupport<AbstractSocketEvents::ReadEvent>::
-                        EmitEvent(AbstractSocketEvents::ReadEvent(
-                            EventSender(this)), DPL::Event::EmitMode::Queued);
-                }
-                else if (mode == WaitMode::Write)
-                {
-                    // Emit WriteEvent
-                    DPL::Event::EventSupport<AbstractSocketEvents::WriteEvent>::
-                        EmitEvent(AbstractSocketEvents::WriteEvent(
-                            EventSender(this)), DPL::Event::EmitMode::Queued);
-                }
-                else
-                {
-                    Assert(0);
-                }
+            // Emit event
+            DPL::Event::EventSupport<AbstractSocketEvents::ConnectedEvent>::
+                EmitEvent(AbstractSocketEvents::ConnectedEvent(
+                              EventSender(this)), DPL::Event::EmitMode::Queued);
+
+            // Done
+            break;
+
+        case InternalState_Connected:
+            if (mode == WaitMode::Read) {
+                // Emit ReadEvent
+                DPL::Event::EventSupport<AbstractSocketEvents::ReadEvent>::
+                    EmitEvent(AbstractSocketEvents::ReadEvent(
+                                  EventSender(
+                                      this)), DPL::Event::EmitMode::Queued);
+            } else if (mode == WaitMode::Write) {
+                // Emit WriteEvent
+                DPL::Event::EventSupport<AbstractSocketEvents::WriteEvent>::
+                    EmitEvent(AbstractSocketEvents::WriteEvent(
+                                  EventSender(
+                                      this)), DPL::Event::EmitMode::Queued);
+            } else {
+                Assert(0);
+            }
 
 
-                break;
+            break;
 
 
-            default:
-                Assert(0);
-                break;
+        default:
+            Assert(0);
+            break;
         }
     }
 
     void AddAcceptWatch()
     {
         }
     }
 
     void AddAcceptWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(this, m_socket, WaitMode::Read);
+        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
+            this,
+            m_socket,
+            WaitMode::Read);
     }
 
     void RemoveAcceptWatch()
     {
     }
 
     void RemoveAcceptWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(this, m_socket, WaitMode::Read);
+        WaitableHandleWatchSupport::InheritedContext()->
+            RemoveWaitableHandleWatch(this, m_socket, WaitMode::Read);
     }
 
     void AddConnectWatch()
     {
     }
 
     void AddConnectWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(this, m_socket, WaitMode::Write);
+        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
+            this,
+            m_socket,
+            WaitMode::Write);
     }
 
     void RemoveConnectWatch()
     {
     }
 
     void RemoveConnectWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(this, m_socket, WaitMode::Write);
+        WaitableHandleWatchSupport::InheritedContext()->
+            RemoveWaitableHandleWatch(this, m_socket, WaitMode::Write);
     }
 
     void AddReadWatch()
     {
     }
 
     void AddReadWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(this, m_socket, WaitMode::Read);
+        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
+            this,
+            m_socket,
+            WaitMode::Read);
     }
 
     void RemoveReadWatch()
     {
     }
 
     void RemoveReadWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(this, m_socket, WaitMode::Read);
+        WaitableHandleWatchSupport::InheritedContext()->
+            RemoveWaitableHandleWatch(this, m_socket, WaitMode::Read);
     }
 
     void AddWriteWatch()
     {
     }
 
     void AddWriteWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(this, m_socket, WaitMode::Write);
+        WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
+            this,
+            m_socket,
+            WaitMode::Write);
     }
 
     void RemoveWriteWatch()
     {
     }
 
     void RemoveWriteWatch()
     {
-        WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(this, m_socket, WaitMode::Write);
+        WaitableHandleWatchSupport::InheritedContext()->
+            RemoveWaitableHandleWatch(this, m_socket, WaitMode::Write);
     }
 
     }
 
-public:
-    GenericSocket()
-        : m_socket(-1),
-          m_internalState(InternalState_None)
-    {
-    }
+  public:
+    GenericSocket() :
+        m_socket(-1),
+        m_internalState(InternalState_None)
+    {}
 
     virtual ~GenericSocket()
     {
 
     virtual ~GenericSocket()
     {
@@ -247,8 +263,10 @@ public:
 
     virtual void Open()
     {
 
     virtual void Open()
     {
-        if (m_internalState != InternalState_None)
-            ThrowMsg(AbstractSocket::Exception::OpenFailed, "Invalid socket state, should be 'None'");
+        if (m_internalState != InternalState_None) {
+            ThrowMsg(AbstractSocket::Exception::OpenFailed,
+                     "Invalid socket state, should be 'None'");
+        }
 
         LogPedantic("Opening socket...");
 
 
         LogPedantic("Opening socket...");
 
@@ -269,8 +287,10 @@ public:
 
     virtual void Connect(const Address &address)
     {
 
     virtual void Connect(const Address &address)
     {
-        if (m_internalState != InternalState_Prepare)
-            ThrowMsg(AbstractSocket::Exception::ConnectFailed, "Invalid socket state, should be 'Prepare'");
+        if (m_internalState != InternalState_Prepare) {
+            ThrowMsg(AbstractSocket::Exception::ConnectFailed,
+                     "Invalid socket state, should be 'Prepare'");
+        }
 
         LogPedantic("Connecting to: " << address.ToString());
 
 
         LogPedantic("Connecting to: " << address.ToString());
 
@@ -282,17 +302,19 @@ public:
             // Translate address to specific socket address struct
             socketAddress = TranslateAddressGenericToSpecific(address);
         }
             // Translate address to specific socket address struct
             socketAddress = TranslateAddressGenericToSpecific(address);
         }
-        Catch (Address::Exception::InvalidAddress)
+        Catch(Address::Exception::InvalidAddress)
         {
             // This address is invalid. Cannot connect.
         {
             // This address is invalid. Cannot connect.
-            ReThrowMsg(AbstractSocket::Exception::ConnectFailed, address.ToString());
+            ReThrowMsg(AbstractSocket::Exception::ConnectFailed,
+                       address.ToString());
         }
 
         // Do connect
         }
 
         // Do connect
-        int result = TEMP_FAILURE_RETRY(connect(m_socket, socketAddress.first, socketAddress.second));
+        int result =
+            TEMP_FAILURE_RETRY(connect(m_socket, socketAddress.first,
+                                       socketAddress.second));
 
 
-        if (result == 0)
-        {
+        if (result == 0) {
             // Immediate connect
             LogPedantic("Immediate connected to: " << address.ToString());
 
             // Immediate connect
             LogPedantic("Immediate connected to: " << address.ToString());
 
@@ -303,25 +325,22 @@ public:
             // Emit connected event
             DPL::Event::EventSupport<AbstractSocketEvents::ConnectedEvent>::
                 EmitEvent(AbstractSocketEvents::ConnectedEvent(
             // Emit connected event
             DPL::Event::EventSupport<AbstractSocketEvents::ConnectedEvent>::
                 EmitEvent(AbstractSocketEvents::ConnectedEvent(
-                    EventSender(this)), DPL::Event::EmitMode::Queued);
-        }
-        else
-        {
-            if (errno == EINTR || errno == EINPROGRESS)
-            {
-                LogPedantic("Asynchronous connect in progress: " << address.ToString());
+                              EventSender(this)), DPL::Event::EmitMode::Queued);
+        } else {
+            if (errno == EINTR || errno == EINPROGRESS) {
+                LogPedantic(
+                    "Asynchronous connect in progress: " << address.ToString());
 
                 // Connecting in progress
                 AddConnectWatch();
                 m_internalState = InternalState_Connecting;
 
                 // Connecting in progress
                 AddConnectWatch();
                 m_internalState = InternalState_Connecting;
-            }
-            else
-            {
+            } else {
                 // Free translation structure
                 free(socketAddress.first);
 
                 // Error occurred
                 // Free translation structure
                 free(socketAddress.first);
 
                 // Error occurred
-                ThrowMsg(AbstractSocket::Exception::ConnectFailed, address.ToString());
+                ThrowMsg(AbstractSocket::Exception::ConnectFailed,
+                         address.ToString());
             }
         }
 
             }
         }
 
@@ -331,40 +350,35 @@ public:
 
     virtual void Close()
     {
 
     virtual void Close()
     {
-        if (m_internalState == InternalState_None)
+        if (m_internalState == InternalState_None) {
             return;
             return;
+        }
 
         Assert(m_socket != -1);
 
 
         Assert(m_socket != -1);
 
-        if (m_internalState == InternalState_Listening)
-        {
+        if (m_internalState == InternalState_Listening) {
             // Remove watch in listening state
             LogPedantic("Removing accept watch");
             RemoveAcceptWatch();
             m_internalState = InternalState_None;
             // Remove watch in listening state
             LogPedantic("Removing accept watch");
             RemoveAcceptWatch();
             m_internalState = InternalState_None;
-        }
-        else if (m_internalState == InternalState_Connecting)
-        {
+        } else if (m_internalState == InternalState_Connecting) {
             // Remove watch in connecting state
             LogPedantic("Removing connect watch");
             RemoveConnectWatch();
             m_internalState = InternalState_None;
             // Remove watch in connecting state
             LogPedantic("Removing connect watch");
             RemoveConnectWatch();
             m_internalState = InternalState_None;
-        }
-        else if (m_internalState == InternalState_Connected)
-        {
+        } else if (m_internalState == InternalState_Connected) {
             // Remove watch in connected state
             LogPedantic("Removing read watch");
             RemoveReadWatch();
             m_internalState = InternalState_None;
             // Remove watch in connected state
             LogPedantic("Removing read watch");
             RemoveReadWatch();
             m_internalState = InternalState_None;
-        }
-        else
-        {
+        } else {
             // State must be just prepared only
             Assert(m_internalState == InternalState_Prepare);
         }
 
             // State must be just prepared only
             Assert(m_internalState == InternalState_Prepare);
         }
 
-        if (TEMP_FAILURE_RETRY(close(m_socket)) == -1)
+        if (TEMP_FAILURE_RETRY(close(m_socket)) == -1) {
             Throw(Exception::CloseFailed);
             Throw(Exception::CloseFailed);
+        }
 
         // Reset socket
         m_socket = -1;
 
         // Reset socket
         m_socket = -1;
@@ -377,35 +391,48 @@ public:
 
     virtual void Bind(const Address &address)
     {
 
     virtual void Bind(const Address &address)
     {
-        if (m_internalState != InternalState_Prepare)
-            ThrowMsg(AbstractSocket::Exception::BindFailed, "Invalid socket state, should be 'Prepare'");
+        if (m_internalState != InternalState_Prepare) {
+            ThrowMsg(AbstractSocket::Exception::BindFailed,
+                     "Invalid socket state, should be 'Prepare'");
+        }
 
 
-        LogPedantic("Binding to: " << address.GetAddress() << ":" << address.GetPort());
+        LogPedantic(
+            "Binding to: " << address.GetAddress() << ":" << address.GetPort());
 
         // Translate address to specific socket address struct
 
         // Translate address to specific socket address struct
-        std::pair<sockaddr *, socklen_t> socketAddress = TranslateAddressGenericToSpecific(address);
+        std::pair<sockaddr *,
+                  socklen_t> socketAddress = TranslateAddressGenericToSpecific(
+                address);
 
         // Do bind
 
         // Do bind
-        if (::bind(m_socket, socketAddress.first, socketAddress.second) == -1)
+        if (::bind(m_socket, socketAddress.first,
+                   socketAddress.second) == -1)
+        {
             ThrowMsg(AbstractSocket::Exception::BindFailed, address.ToString());
             ThrowMsg(AbstractSocket::Exception::BindFailed, address.ToString());
+        }
 
         // Free translation structure
         free(socketAddress.first);
 
         // Show info
 
         // Free translation structure
         free(socketAddress.first);
 
         // Show info
-        LogPedantic("Bound to address: " << address.GetAddress() << ":" << address.GetPort());
+        LogPedantic(
+            "Bound to address: " << address.GetAddress() << ":" <<
+            address.GetPort());
     }
 
     virtual void Listen(int backlog)
     {
     }
 
     virtual void Listen(int backlog)
     {
-        if (m_internalState != InternalState_Prepare)
-            ThrowMsg(AbstractSocket::Exception::ListenFailed, "Invalid socket state, should be 'None'");
+        if (m_internalState != InternalState_Prepare) {
+            ThrowMsg(AbstractSocket::Exception::ListenFailed,
+                     "Invalid socket state, should be 'None'");
+        }
 
         LogPedantic("Starting to listen...");
 
         // Do listen
 
         LogPedantic("Starting to listen...");
 
         // Do listen
-        if (listen(m_socket, backlog) != 0)
+        if (listen(m_socket, backlog) != 0) {
             Throw(AbstractSocket::Exception::ListenFailed);
             Throw(AbstractSocket::Exception::ListenFailed);
+        }
 
         // Begin read watch
         AddAcceptWatch();
 
         // Begin read watch
         AddAcceptWatch();
@@ -416,8 +443,10 @@ public:
 
     virtual AbstractSocket *Accept()
     {
 
     virtual AbstractSocket *Accept()
     {
-        if (m_internalState != InternalState_Listening)
-            ThrowMsg(AbstractSocket::Exception::AcceptFailed, "Invalid socket state, should be 'Listening'");
+        if (m_internalState != InternalState_Listening) {
+            ThrowMsg(AbstractSocket::Exception::AcceptFailed,
+                     "Invalid socket state, should be 'Listening'");
+        }
 
         LogPedantic("Accepting...");
 
 
         LogPedantic("Accepting...");
 
@@ -426,14 +455,15 @@ public:
         int client = TEMP_FAILURE_RETRY(accept(m_socket, NULL, &length));
 
         LogPedantic("Socket accept returned " << client);
         int client = TEMP_FAILURE_RETRY(accept(m_socket, NULL, &length));
 
         LogPedantic("Socket accept returned " << client);
-        if (client == -1)
-        {
+        if (client == -1) {
             // Check if there is any client waiting
             // Check if there is any client waiting
-            if (errno == EWOULDBLOCK || errno == EAGAIN)
+            if (errno == EWOULDBLOCK || errno == EAGAIN) {
                 return NULL;
                 return NULL;
+            }
             int err = errno;
             int err = errno;
-            if (errno == ENOENT)
+            if (errno == ENOENT) {
                 return NULL;
                 return NULL;
+            }
             LogPedantic("throwing error. errrno " << err);
             // Error occurred
             Throw(AbstractSocket::Exception::AcceptFailed);
             LogPedantic("throwing error. errrno " << err);
             // Error occurred
             Throw(AbstractSocket::Exception::AcceptFailed);
@@ -466,10 +496,16 @@ public:
         // FIXME: Additional internal state check
 
         socklen_t length = GetSpecificAddressSize();
         // FIXME: Additional internal state check
 
         socklen_t length = GetSpecificAddressSize();
-        ScopedFree<sockaddr> address(static_cast<sockaddr *>(calloc(static_cast<size_t>(length), 1)));
-
-        if (getsockname(m_socket, address.Get(), &length) == -1)
-            ThrowMsg(AbstractSocket::Exception::GetPeerNameFailed, "Failed to get local address");
+        ScopedFree<sockaddr> address(static_cast<sockaddr *>(calloc(
+                                                                 static_cast<
+                                                                     size_t>(
+                                                                     length),
+                                                                 1)));
+
+        if (getsockname(m_socket, address.Get(), &length) == -1) {
+            ThrowMsg(AbstractSocket::Exception::GetPeerNameFailed,
+                     "Failed to get local address");
+        }
 
         return TranslateAddressSpecificToGeneric(address.Get(), length);
     }
 
         return TranslateAddressSpecificToGeneric(address.Get(), length);
     }
@@ -479,55 +515,65 @@ public:
         // FIXME: Additional internal state check
 
         socklen_t length = GetSpecificAddressSize();
         // FIXME: Additional internal state check
 
         socklen_t length = GetSpecificAddressSize();
-        ScopedFree<sockaddr> address(static_cast<sockaddr *>(calloc(static_cast<size_t>(length), 1)));
-
-        if (getpeername(m_socket, address.Get(), &length) == -1)
-            ThrowMsg(AbstractSocket::Exception::GetPeerNameFailed, "Failed to get remote address");
+        ScopedFree<sockaddr> address(static_cast<sockaddr *>(calloc(
+                                                                 static_cast<
+                                                                     size_t>(
+                                                                     length),
+                                                                 1)));
+
+        if (getpeername(m_socket, address.Get(), &length) == -1) {
+            ThrowMsg(AbstractSocket::Exception::GetPeerNameFailed,
+                     "Failed to get remote address");
+        }
 
         return TranslateAddressSpecificToGeneric(address.Get(), length);
     }
 
     virtual BinaryQueueAutoPtr Read(size_t size)
     {
 
         return TranslateAddressSpecificToGeneric(address.Get(), length);
     }
 
     virtual BinaryQueueAutoPtr Read(size_t size)
     {
-        if (m_internalState != InternalState_Connected)
-            ThrowMsg(AbstractSocket::Exception::AcceptFailed, "Invalid socket state, should be 'Connected'");
+        if (m_internalState != InternalState_Connected) {
+            ThrowMsg(AbstractSocket::Exception::AcceptFailed,
+                     "Invalid socket state, should be 'Connected'");
+        }
 
         Try
         {
             // Adjust bytes to be read
 
         Try
         {
             // Adjust bytes to be read
-            size_t bytesToRead = size > DEFAULT_READ_BUFFER_SIZE ? DEFAULT_READ_BUFFER_SIZE : size;
+            size_t bytesToRead = size >
+                DEFAULT_READ_BUFFER_SIZE ? DEFAULT_READ_BUFFER_SIZE : size;
 
             // Malloc default read buffer size
 
             // Malloc default read buffer size
-            // It is unmanaged, so it can be then attached directly to binary queue
+            // It is unmanaged, so it can be then attached directly to binary
+            // queue
             void *buffer = malloc(bytesToRead);
 
             void *buffer = malloc(bytesToRead);
 
-            if (buffer == NULL)
+            if (buffer == NULL) {
                 throw std::bad_alloc();
                 throw std::bad_alloc();
+            }
 
             // Receive bytes from socket
 
             // Receive bytes from socket
-            ssize_t result = TEMP_FAILURE_RETRY(recv(m_socket, buffer, bytesToRead, 0));
+            ssize_t result =
+                TEMP_FAILURE_RETRY(recv(m_socket, buffer, bytesToRead, 0));
 
 
-            if (result > 0)
-            {
+            if (result > 0) {
                 // Succedded to read socket data
                 BinaryQueueAutoPtr binaryQueue(new BinaryQueue());
 
                 // Append unmanaged memory
                 // Succedded to read socket data
                 BinaryQueueAutoPtr binaryQueue(new BinaryQueue());
 
                 // Append unmanaged memory
-                binaryQueue->AppendUnmanaged(buffer, result, &BinaryQueue::BufferDeleterFree, NULL);
+                binaryQueue->AppendUnmanaged(buffer,
+                                             result,
+                                             &BinaryQueue::BufferDeleterFree,
+                                             NULL);
 
                 // Return buffer
                 return binaryQueue;
 
                 // Return buffer
                 return binaryQueue;
-            }
-            else if (result == 0)
-            {
+            } else if (result == 0) {
                 // Socket was gracefuly closed
                 free(buffer);
 
                 // Return empty buffer
                 return BinaryQueueAutoPtr(new BinaryQueue());
                 // Socket was gracefuly closed
                 free(buffer);
 
                 // Return empty buffer
                 return BinaryQueueAutoPtr(new BinaryQueue());
-            }
-            else
-            {
+            } else {
                 // Must first save errno value, because it may be altered
                 int lastErrno = errno;
 
                 // Must first save errno value, because it may be altered
                 int lastErrno = errno;
 
@@ -535,108 +581,132 @@ public:
                 free(buffer);
 
                 // Interpret error result
                 free(buffer);
 
                 // Interpret error result
-                switch (lastErrno)
-                {
-                    case EAGAIN: // = EWOULDBLOCK
-                        //
-                        // * The  socket's file descriptor is marked O_NONBLOCK and no data is waiting
-                        //   to be received; or MSG_OOB is set and no out-of-band data is available
-                        //   and either the socket's file descriptor is marked O_NONBLOCK or the socket
-                        //   does not support blocking to await out-of-band data.
-                        //
-                        // return null data buffer to indicate no data waiting
-                        //
-                        return BinaryQueueAutoPtr();
-
-                    case EBADF:
-                        //
-                        // * The socket argument is not a valid file descriptor.
-                        //
-                        // This is internal error
-                        //
-                        ThrowMsg(CommonException::InternalError, "Invalid socket descriptor");
-
-                    case ECONNRESET:
-                        //
-                        // * A connection was forcibly closed by a peer.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case EINTR:
-                        //
-                        // * The recv() function was interrupted by a signal that was caught, before any
-                        //   data was available.
-                        //
-                        // No interrupt here is expected, due to fact that we used TEMP_FAILURE_RETRY
-                        //
-                        ThrowMsg(CommonException::InternalError, "Unexpected interrupt occurred");
-
-                    case EINVAL:
-                        //
-                        // * The MSG_OOB flag is set and no out-of-band data is available.
-                        //
-                        // We did not specified OOB data. This is an error.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Unexpected OOB error occurred");
-
-                    case ENOTCONN:
-                        //
-                        // * A receive is attempted on a connection-mode socket that is not connected.
-                        //
-                        // FIXME: Is this proper exception here ?
-                        //
-                        ThrowMsg(CommonException::InternalError, "Socket is not connected");
-
-                    case ENOTSOCK:
-                        //
-                        // * The socket argument does not refer to a socket.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Handle is not a socket");
-
-                    case EOPNOTSUPP:
-                        //
-                        // * The specified flags are not supported for this socket type or protocol.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Socket flags not supported");
-
-                    case ETIMEDOUT:
-                        //
-                        // * The connection timed out during connection establishment, or due to a transmission timeout on active connection.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case EIO:
-                        //
-                        // * An I/O error occurred while reading from or writing to the file system.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case ENOBUFS:
-                        //
-                        // * Insufficient resources were available in the system to perform the operation.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Insufficient system resources");
-
-                    case ENOMEM:
-                        //
-                        // * Insufficient memory was available to fulfill the request.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Insufficient system memory");
-
-                    default:
-                        // Some kernel error occurred, should never happen
-                        ThrowMsg(CommonException::InternalError, "Unknown kernel read error returned");
-                        break;
+                switch (lastErrno) {
+                case EAGAIN:     // = EWOULDBLOCK
+                    //
+                    // * The  socket's file descriptor is marked O_NONBLOCK and
+                    // no data is waiting
+                    //   to be received; or MSG_OOB is set and no out-of-band
+                    // data is available
+                    //   and either the socket's file descriptor is marked
+                    // O_NONBLOCK or the socket
+                    //   does not support blocking to await out-of-band data.
+                    //
+                    // return null data buffer to indicate no data waiting
+                    //
+                    return BinaryQueueAutoPtr();
+
+                case EBADF:
+                    //
+                    // * The socket argument is not a valid file descriptor.
+                    //
+                    // This is internal error
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Invalid socket descriptor");
+
+                case ECONNRESET:
+                    //
+                    // * A connection was forcibly closed by a peer.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case EINTR:
+                    //
+                    // * The recv() function was interrupted by a signal that
+                    // was caught, before any
+                    //   data was available.
+                    //
+                    // No interrupt here is expected, due to fact that we used
+                    // TEMP_FAILURE_RETRY
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Unexpected interrupt occurred");
+
+                case EINVAL:
+                    //
+                    // * The MSG_OOB flag is set and no out-of-band data is
+                    // available.
+                    //
+                    // We did not specified OOB data. This is an error.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Unexpected OOB error occurred");
+
+                case ENOTCONN:
+                    //
+                    // * A receive is attempted on a connection-mode socket that
+                    // is not connected.
+                    //
+                    // FIXME: Is this proper exception here ?
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Socket is not connected");
+
+                case ENOTSOCK:
+                    //
+                    // * The socket argument does not refer to a socket.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Handle is not a socket");
+
+                case EOPNOTSUPP:
+                    //
+                    // * The specified flags are not supported for this socket
+                    // type or protocol.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Socket flags not supported");
+
+                case ETIMEDOUT:
+                    //
+                    // * The connection timed out during connection
+                    // establishment, or due to a transmission timeout on active
+                    // connection.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case EIO:
+                    //
+                    // * An I/O error occurred while reading from or writing to
+                    // the file system.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case ENOBUFS:
+                    //
+                    // * Insufficient resources were available in the system to
+                    // perform the operation.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Insufficient system resources");
+
+                case ENOMEM:
+                    //
+                    // * Insufficient memory was available to fulfill the
+                    // request.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Insufficient system memory");
+
+                default:
+                    // Some kernel error occurred, should never happen
+                    ThrowMsg(CommonException::InternalError,
+                             "Unknown kernel read error returned");
+                    break;
                 }
             }
         }
                 }
             }
         }
-        Catch (CommonException::InternalError)
+        Catch(CommonException::InternalError)
         {
             // If any internal error occurred, this is fatal for Write method
             // interpret this as WriteError exception and rethrow
         {
             // If any internal error occurred, this is fatal for Write method
             // interpret this as WriteError exception and rethrow
@@ -646,14 +716,17 @@ public:
 
     virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize)
     {
 
     virtual size_t Write(const BinaryQueue &buffer, size_t bufferSize)
     {
-        if (m_internalState != InternalState_Connected)
-            ThrowMsg(AbstractSocket::Exception::AcceptFailed, "Invalid socket state, should be 'Connected'");
+        if (m_internalState != InternalState_Connected) {
+            ThrowMsg(AbstractSocket::Exception::AcceptFailed,
+                     "Invalid socket state, should be 'Connected'");
+        }
 
         Try
         {
             // Adjust write size
 
         Try
         {
             // Adjust write size
-            if (bufferSize > buffer.Size())
+            if (bufferSize > buffer.Size()) {
                 bufferSize = buffer.Size();
                 bufferSize = buffer.Size();
+            }
 
             // FIXME: User write visitor to write !
             // WriteVisitor visitor
 
             // FIXME: User write visitor to write !
             // WriteVisitor visitor
@@ -663,149 +736,176 @@ public:
 
             // Linux: MSG_NOSIGNAL is supported, but it is not an ideal solution
             // FIXME: Should we setup signal PIPE ignoring for whole process ?
 
             // Linux: MSG_NOSIGNAL is supported, but it is not an ideal solution
             // FIXME: Should we setup signal PIPE ignoring for whole process ?
-            // In BSD, there is: setsockopt(c, SOL_SOCKET, SO_NOSIGPIPE, (void *)&on, sizeof(on))
-            ssize_t result = TEMP_FAILURE_RETRY(send(m_socket, flattened.Get(), bufferSize, MSG_NOSIGNAL));
+            // In BSD, there is: setsockopt(c, SOL_SOCKET, SO_NOSIGPIPE, (void
+            // *)&on, sizeof(on))
+            ssize_t result =
+                TEMP_FAILURE_RETRY(send(m_socket, flattened.Get(), bufferSize,
+                                        MSG_NOSIGNAL));
 
 
-            if (result > 0)
-            {
+            if (result > 0) {
                 // Successfuly written some bytes
                 return static_cast<size_t>(result);
                 // Successfuly written some bytes
                 return static_cast<size_t>(result);
-            }
-            else if (result == 0)
-            {
+            } else if (result == 0) {
                 // This is abnormal result
                 // This is abnormal result
-                ThrowMsg(CommonException::InternalError, "Invalid socket write result, 0 bytes written");
-            }
-            else if (result == -1)
-            {
+                ThrowMsg(CommonException::InternalError,
+                         "Invalid socket write result, 0 bytes written");
+            } else if (result == -1) {
                 // Interpret error result
                 // Interpret error result
-                switch (errno)
-                {
-                    case EAGAIN: // = EWOULDBLOCK
-                        //
-                        // * The socket's file descriptor is marked O_NONBLOCK and the requested operation would block.
-                        //
-                        // We should wait for writability
-                        //
-                        return 0;
-
-                    case EBADF:
-                        //
-                        // * The socket argument is not a valid file descriptor.
-                        //
-                        // This is internal error
-                        //
-                        ThrowMsg(CommonException::InternalError, "Invalid socket descriptor");
-
-                    case ECONNRESET:
-                        //
-                        // * A connection was forcibly closed by a peer.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case EDESTADDRREQ:
-                        //
-                        // * The socket is not connection-mode and no peer address is set.
-                        //
-                        // FIXME: Is this proper exception here ?
-                        //
-                        ThrowMsg(CommonException::InternalError, "Socket is not connected");
-
-                    case EINTR:
-                        //
-                        // * A signal interrupted send() before any data was transmitted.
-                        //
-                        // No interrupt here is expected, due to fact that we used TEMP_FAILURE_RETRY
-                        //
-                        ThrowMsg(CommonException::InternalError, "Unexpected interrupt occurred");
-
-                    case EMSGSIZE:
-                        //
-                        // * The message is too large to be sent all at once, as the socket requires.
-                        //
-                        // FIXME: Is this proper exception here ?
-                        //
-                        ThrowMsg(CommonException::InternalError, "Socket message is too big");
-
-                    case ENOTCONN:
-                        //
-                        // * The socket is not connected or otherwise has not had the peer pre-specified.
-                        //
-                        // FIXME: Is this proper exception here ?
-                        //
-                        ThrowMsg(CommonException::InternalError, "Socket is not connected");
-
-                    case ENOTSOCK:
-                        //
-                        // * The socket argument does not refer to a socket.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Handle is not a socket");
-
-                    case EOPNOTSUPP:
-                        //
-                        // * The socket argument is associated with a socket that does not support one or more of the values set in flags.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Socket flags not supported");
-
-                    case EPIPE:
-                        //
-                        // * The socket is shut down for writing, or the socket is connection-mode and
-                        //   is no longer connected. In the latter case, and if the socket is of type
-                        //   SOCK_STREAM, the SIGPIPE signal is  generated to the calling thread.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case EACCES:
-                        //
-                        // * The calling process does not have the appropriate privileges.
-                        //
-                        // Priviledges might have changed.
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case EIO:
-                        //
-                        // * An I/O error occurred while reading from or writing to the file system.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case ENETDOWN:
-                        //
-                        // * The local network interface used to reach the destination is down.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case ENETUNREACH:
-                        //
-                        // * No route to the network is present.
-                        //
-                        // In result, we can interpret this error as a broken connection
-                        //
-                        Throw(AbstractSocket::Exception::ConnectionBroken);
-
-                    case ENOBUFS:
-                        //
-                        // * Insufficient resources were available in the system to perform the operation.
-                        //
-                        ThrowMsg(CommonException::InternalError, "Insufficient system resources");
-
-                    default:
-                        // Some kernel error occurred, should never happen
-                        ThrowMsg(CommonException::InternalError, "Unknown kernel write error returned");
-                        break;
+                switch (errno) {
+                case EAGAIN:     // = EWOULDBLOCK
+                    //
+                    // * The socket's file descriptor is marked O_NONBLOCK and
+                    // the requested operation would block.
+                    //
+                    // We should wait for writability
+                    //
+                    return 0;
+
+                case EBADF:
+                    //
+                    // * The socket argument is not a valid file descriptor.
+                    //
+                    // This is internal error
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Invalid socket descriptor");
+
+                case ECONNRESET:
+                    //
+                    // * A connection was forcibly closed by a peer.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case EDESTADDRREQ:
+                    //
+                    // * The socket is not connection-mode and no peer address
+                    // is set.
+                    //
+                    // FIXME: Is this proper exception here ?
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Socket is not connected");
+
+                case EINTR:
+                    //
+                    // * A signal interrupted send() before any data was
+                    // transmitted.
+                    //
+                    // No interrupt here is expected, due to fact that we used
+                    // TEMP_FAILURE_RETRY
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Unexpected interrupt occurred");
+
+                case EMSGSIZE:
+                    //
+                    // * The message is too large to be sent all at once, as the
+                    // socket requires.
+                    //
+                    // FIXME: Is this proper exception here ?
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Socket message is too big");
+
+                case ENOTCONN:
+                    //
+                    // * The socket is not connected or otherwise has not had
+                    // the peer pre-specified.
+                    //
+                    // FIXME: Is this proper exception here ?
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Socket is not connected");
+
+                case ENOTSOCK:
+                    //
+                    // * The socket argument does not refer to a socket.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Handle is not a socket");
+
+                case EOPNOTSUPP:
+                    //
+                    // * The socket argument is associated with a socket that
+                    // does not support one or more of the values set in flags.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Socket flags not supported");
+
+                case EPIPE:
+                    //
+                    // * The socket is shut down for writing, or the socket is
+                    // connection-mode and
+                    //   is no longer connected. In the latter case, and if the
+                    // socket is of type
+                    //   SOCK_STREAM, the SIGPIPE signal is  generated to the
+                    // calling thread.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case EACCES:
+                    //
+                    // * The calling process does not have the appropriate
+                    // privileges.
+                    //
+                    // Priviledges might have changed.
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case EIO:
+                    //
+                    // * An I/O error occurred while reading from or writing to
+                    // the file system.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case ENETDOWN:
+                    //
+                    // * The local network interface used to reach the
+                    // destination is down.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case ENETUNREACH:
+                    //
+                    // * No route to the network is present.
+                    //
+                    // In result, we can interpret this error as a broken
+                    // connection
+                    //
+                    Throw(AbstractSocket::Exception::ConnectionBroken);
+
+                case ENOBUFS:
+                    //
+                    // * Insufficient resources were available in the system to
+                    // perform the operation.
+                    //
+                    ThrowMsg(CommonException::InternalError,
+                             "Insufficient system resources");
+
+                default:
+                    // Some kernel error occurred, should never happen
+                    ThrowMsg(CommonException::InternalError,
+                             "Unknown kernel write error returned");
+                    break;
                 }
             }
         }
                 }
             }
         }
-        Catch (CommonException::InternalError)
+        Catch(CommonException::InternalError)
         {
             // If any internal error occurred, this is fatal for Write method
             // interpret this as WriteError exception and rethrow
         {
             // If any internal error occurred, this is fatal for Write method
             // interpret this as WriteError exception and rethrow
@@ -828,7 +928,6 @@ public:
         return m_socket;
     }
 };
         return m_socket;
     }
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index 3d7b9fe..37614ce 100644 (file)
 #include <dpl/socket/generic_socket.h>
 #include <dpl/exception.h>
 
 #include <dpl/socket/generic_socket.h>
 #include <dpl/exception.h>
 
-namespace DPL
+namespace DPL {
+namespace Socket {
+class UnixSocket :
+    public GenericSocket<UnixSocket>
 {
 {
-namespace Socket
-{
-
-class UnixSocket
-    : public GenericSocket<UnixSocket>
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
     };
 
-protected:
-     /**
-      * Translate generic Address to specific socket kernel structure
-      */
-    virtual std::pair<sockaddr *, socklen_t> TranslateAddressGenericToSpecific(const Address &address) const;
+  protected:
+    /**
+     * Translate generic Address to specific socket kernel structure
+     */
+    virtual std::pair<sockaddr *, socklen_t> TranslateAddressGenericToSpecific(
+        const Address &address) const;
 
     /**
      * Translate specific socket kernel structure to generic Address
      */
 
     /**
      * Translate specific socket kernel structure to generic Address
      */
-    virtual Address TranslateAddressSpecificToGeneric(sockaddr *, socklen_t) const;
+    virtual Address TranslateAddressSpecificToGeneric(sockaddr *,
+                                                      socklen_t) const;
 
     /**
      * Get specific socket kernel structure size
 
     /**
      * Get specific socket kernel structure size
@@ -67,12 +66,11 @@ protected:
      */
     virtual int AllocSpecificDescriptor() const;
 
      */
     virtual int AllocSpecificDescriptor() const;
 
-public:
+  public:
     UnixSocket();
 
     virtual void Bind(const Address &address);
 };
     UnixSocket();
 
     virtual void Bind(const Address &address);
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index cfdbac2..f02df51 100644 (file)
@@ -17,7 +17,8 @@
  * @file        waitable_input_output_execution_context_support.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        waitable_input_output_execution_context_support.h
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the header file for waitable input-output execution context support
+ * @brief       This file is the header file for waitable input-output execution
+ * context support
  */
 #ifndef DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H
 #define DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H
  */
 #ifndef DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H
 #define DPL_WAITABLE_INPUT_OUTPUT_EXECUTION_CONTEXT_SUPPORT_H
 #include <dpl/waitable_handle_watch_support.h>
 #include <dpl/binary_queue.h>
 
 #include <dpl/waitable_handle_watch_support.h>
 #include <dpl/binary_queue.h>
 
-namespace DPL
+namespace DPL {
+namespace Socket {
+class WaitableInputOutputExecutionContextSupport :
+    private WaitableHandleWatchSupport::WaitableHandleListener
 {
 {
-namespace Socket
-{
-
-class WaitableInputOutputExecutionContextSupport
-    : private WaitableHandleWatchSupport::WaitableHandleListener
-{
-public:
+  public:
     class Exception
     {
     class Exception
     {
-    public:
+      public:
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, AlreadyOpened)
         DECLARE_EXCEPTION_TYPE(Base, NotOpened)
         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
         DECLARE_EXCEPTION_TYPE(Base, AlreadyOpened)
         DECLARE_EXCEPTION_TYPE(Base, NotOpened)
@@ -45,7 +43,7 @@ public:
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
         DECLARE_EXCEPTION_TYPE(Base, CloseFailed)
     };
 
-private:
+  private:
     bool m_opened;
     AbstractWaitableInputOutput *m_waitableInputOutput;
 
     bool m_opened;
     AbstractWaitableInputOutput *m_waitableInputOutput;
 
@@ -65,9 +63,10 @@ private:
 
     void CheckedRemoveReadWriteWatch();
 
 
     void CheckedRemoveReadWriteWatch();
 
-    virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle, WaitMode::Type mode);
+    virtual void OnWaitableHandleEvent(WaitableHandle waitableHandle,
+                                       WaitMode::Type mode);
 
 
-protected:
+  protected:
     // Incoming/Outgoing streams
     BinaryQueue m_inputStream;
     BinaryQueue m_outputStream;
     // Incoming/Outgoing streams
     BinaryQueue m_inputStream;
     BinaryQueue m_outputStream;
@@ -84,7 +83,7 @@ protected:
     void Open(AbstractWaitableInputOutput *waitableInputOutput);
     void Close();
 
     void Open(AbstractWaitableInputOutput *waitableInputOutput);
     void Close();
 
-public:
+  public:
     /**
      * Constructor
      */
     /**
      * Constructor
      */
@@ -95,7 +94,6 @@ public:
      */
     virtual ~WaitableInputOutputExecutionContextSupport();
 };
      */
     virtual ~WaitableInputOutputExecutionContextSupport();
 };
-
 }
 } // namespace DPL
 
 }
 } // namespace DPL
 
index a8e2237..aff2d74 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of generic socket
  */
  * @version     1.0
  * @brief       This file is the implementation file of generic socket
  */
+#include <stddef.h>
 #include <dpl/socket/generic_socket.h>
 
 //
 #include <dpl/socket/generic_socket.h>
 
 //
index f185da3..36bff51 100644 (file)
@@ -19,6 +19,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of unix socket
  */
  * @version     1.0
  * @brief       This file is the implementation file of unix socket
  */
+#include <stddef.h>
 #include <dpl/socket/unix_socket.h>
 #include <dpl/log/log.h>
 #include <dpl/exception.h>
 #include <dpl/socket/unix_socket.h>
 #include <dpl/log/log.h>
 #include <dpl/exception.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <string.h>
 
 
-namespace DPL
-{
-namespace Socket
-{
-
+namespace DPL {
+namespace Socket {
 UnixSocket::UnixSocket()
 UnixSocket::UnixSocket()
-{
-}
+{}
 
 int UnixSocket::AllocSpecificDescriptor() const
 {
 
 int UnixSocket::AllocSpecificDescriptor() const
 {
@@ -46,8 +44,9 @@ int UnixSocket::AllocSpecificDescriptor() const
     // Create new descriptor
     int newSocket = socket(AF_UNIX, SOCK_STREAM, 0);
 
     // Create new descriptor
     int newSocket = socket(AF_UNIX, SOCK_STREAM, 0);
 
-    if (newSocket == -1)
+    if (newSocket == -1) {
         Throw(Exception::CreateFailed);
         Throw(Exception::CreateFailed);
+    }
 
     LogPedantic("UNIX socket created");
 
 
     LogPedantic("UNIX socket created");
 
@@ -55,27 +54,36 @@ int UnixSocket::AllocSpecificDescriptor() const
     return newSocket;
 }
 
     return newSocket;
 }
 
-std::pair<sockaddr *, socklen_t> UnixSocket::TranslateAddressGenericToSpecific(const Address &address) const
+std::pair<sockaddr *, socklen_t> UnixSocket::TranslateAddressGenericToSpecific(
+    const Address &address) const
 {
     // Allocate new socket address structure
 {
     // Allocate new socket address structure
-    sockaddr_un *sockAddress = static_cast<sockaddr_un *>(malloc(sizeof(sockaddr_un)));
-    if (!sockAddress) throw std::bad_alloc();
+    sockaddr_un *sockAddress =
+        static_cast<sockaddr_un *>(malloc(sizeof(sockaddr_un)));
+    if (!sockAddress) {
+        throw std::bad_alloc();
+    }
 
     memset(sockAddress, 0, sizeof(sockaddr_un));
 
     // Copy address properties
     sockAddress->sun_family = AF_UNIX;
 
     memset(sockAddress, 0, sizeof(sockaddr_un));
 
     // Copy address properties
     sockAddress->sun_family = AF_UNIX;
-    strncpy(sockAddress->sun_path, address.GetAddress().c_str(), sizeof(sockAddress->sun_path) - 1);
-    sockAddress->sun_path[sizeof(sockAddress->sun_path) - 1] = '\0'; // Prevent buffer overflows
+    strncpy(sockAddress->sun_path, address.GetAddress().c_str(),
+            sizeof(sockAddress->sun_path) - 1);
+
+    //Prevent buffer overflows
+    sockAddress->sun_path[sizeof(sockAddress->sun_path) - 1] = '\0';
 
     // Set proper address length
     socklen_t sockAddressLength = SUN_LEN(sockAddress);
 
     // Return new translated address
 
     // Set proper address length
     socklen_t sockAddressLength = SUN_LEN(sockAddress);
 
     // Return new translated address
-    return std::make_pair(reinterpret_cast<sockaddr *>(sockAddress), sockAddressLength);
+    return std::make_pair(reinterpret_cast<sockaddr *>(sockAddress),
+                          sockAddressLength);
 }
 
 }
 
-Address UnixSocket::TranslateAddressSpecificToGeneric(sockaddr *address, socklen_t) const
+Address UnixSocket::TranslateAddressSpecificToGeneric(sockaddr *address,
+                                                      socklen_t) const
 {
     // FIXME: Constrain check ?
     sockaddr_un *unixAddress = reinterpret_cast<sockaddr_un *>(address);
 {
     // FIXME: Constrain check ?
     sockaddr_un *unixAddress = reinterpret_cast<sockaddr_un *>(address);
@@ -101,8 +109,11 @@ void UnixSocket::Bind(const Address &address)
     GenericSocket<UnixSocket>::Bind(address);
 
     // Always set proper permissions to the socket file
     GenericSocket<UnixSocket>::Bind(address);
 
     // Always set proper permissions to the socket file
-    chmod(address.GetAddress().c_str(), 0777);
+    if (chmod(address.GetAddress().c_str(), 0777) < 0) {
+        LogError(
+            "Error setting permissions to the socket file. Errno " <<
+            strerror(errno));
+    }
 }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
index 7411b49..35635b5 100644 (file)
  * @file        waitable_input_output_execution_context_support.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
  * @file        waitable_input_output_execution_context_support.cpp
  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
  * @version     1.0
- * @brief       This file is the implementation file of waitable input-output execution context support
+ * @brief       This file is the implementation file of waitable input-output
+ * execution context support
  */
  */
+#include <stddef.h>
 #include <dpl/socket/waitable_input_output_execution_context_support.h>
 #include <dpl/scoped_array.h>
 #include <dpl/socket/abstract_socket.h> // FIXME: Remove !!!
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 
 #include <dpl/socket/waitable_input_output_execution_context_support.h>
 #include <dpl/scoped_array.h>
 #include <dpl/socket/abstract_socket.h> // FIXME: Remove !!!
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 
-namespace DPL
-{
-namespace Socket
-{
-
+namespace DPL {
+namespace Socket {
 namespace // anonymous
 {
 const size_t DEFAULT_READ_SIZE = 2048;
 } // namespace anonymous
 
 namespace // anonymous
 {
 const size_t DEFAULT_READ_SIZE = 2048;
 } // namespace anonymous
 
-WaitableInputOutputExecutionContextSupport::WaitableInputOutputExecutionContextSupport()
-    : m_opened(false),
-      m_waitableInputOutput(NULL),
-      m_hasReadWatch(false),
-      m_hasWriteWatch(false)
-{
-}
+WaitableInputOutputExecutionContextSupport::
+    WaitableInputOutputExecutionContextSupport() :
+    m_opened(false),
+    m_waitableInputOutput(NULL),
+    m_hasReadWatch(false),
+    m_hasWriteWatch(false)
+{}
 
 
-WaitableInputOutputExecutionContextSupport::~WaitableInputOutputExecutionContextSupport()
+WaitableInputOutputExecutionContextSupport::~
+WaitableInputOutputExecutionContextSupport()
 {
     // Ensure support is closed
     Close();
 }
 
 {
     // Ensure support is closed
     Close();
 }
 
-void WaitableInputOutputExecutionContextSupport::Open(AbstractWaitableInputOutput *inputOutput)
+void WaitableInputOutputExecutionContextSupport::Open(
+    AbstractWaitableInputOutput *inputOutput)
 {
 {
-    if (m_opened)
+    if (m_opened) {
         Throw(Exception::AlreadyOpened);
         Throw(Exception::AlreadyOpened);
+    }
 
     LogPedantic("Opening waitable input-output execution context support...");
 
 
     LogPedantic("Opening waitable input-output execution context support...");
 
@@ -73,8 +75,9 @@ void WaitableInputOutputExecutionContextSupport::Open(AbstractWaitableInputOutpu
 
 void WaitableInputOutputExecutionContextSupport::Close()
 {
 
 void WaitableInputOutputExecutionContextSupport::Close()
 {
-    if (!m_opened)
+    if (!m_opened) {
         return;
         return;
+    }
 
     LogPedantic("Closing waitable input-output execution context support...");
 
 
     LogPedantic("Closing waitable input-output execution context support...");
 
@@ -89,28 +92,45 @@ void WaitableInputOutputExecutionContextSupport::Close()
 
 void WaitableInputOutputExecutionContextSupport::AddReadWatch()
 {
 
 void WaitableInputOutputExecutionContextSupport::AddReadWatch()
 {
-    WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(this, m_waitableInputOutput->WaitableReadHandle(), WaitMode::Read);
+    WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
+        this,
+        m_waitableInputOutput
+            ->WaitableReadHandle(),
+        WaitMode
+            ::Read);
 }
 
 void WaitableInputOutputExecutionContextSupport::RemoveReadWatch()
 {
 }
 
 void WaitableInputOutputExecutionContextSupport::RemoveReadWatch()
 {
-    WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(this, m_waitableInputOutput->WaitableReadHandle(), WaitMode::Read);
+    WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(
+        this,
+        m_waitableInputOutput->WaitableReadHandle(),
+        WaitMode::Read);
 }
 
 void WaitableInputOutputExecutionContextSupport::AddWriteWatch()
 {
 }
 
 void WaitableInputOutputExecutionContextSupport::AddWriteWatch()
 {
-    WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(this, m_waitableInputOutput->WaitableWriteHandle(), WaitMode::Write);
+    WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
+        this,
+        m_waitableInputOutput
+            ->WaitableWriteHandle(),
+        WaitMode
+            ::Write);
 }
 
 void WaitableInputOutputExecutionContextSupport::RemoveWriteWatch()
 {
 }
 
 void WaitableInputOutputExecutionContextSupport::RemoveWriteWatch()
 {
-    WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(this, m_waitableInputOutput->WaitableWriteHandle(), WaitMode::Write);
+    WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(
+        this,
+        m_waitableInputOutput->WaitableWriteHandle(),
+        WaitMode::Write);
 }
 
 void WaitableInputOutputExecutionContextSupport::CheckedRemoveReadWatch()
 {
 }
 
 void WaitableInputOutputExecutionContextSupport::CheckedRemoveReadWatch()
 {
-    if (!m_hasReadWatch)
+    if (!m_hasReadWatch) {
         return;
         return;
+    }
 
     RemoveReadWatch();
     m_hasReadWatch = false;
 
     RemoveReadWatch();
     m_hasReadWatch = false;
@@ -118,8 +138,9 @@ void WaitableInputOutputExecutionContextSupport::CheckedRemoveReadWatch()
 
 void WaitableInputOutputExecutionContextSupport::CheckedRemoveWriteWatch()
 {
 
 void WaitableInputOutputExecutionContextSupport::CheckedRemoveWriteWatch()
 {
-    if (!m_hasWriteWatch)
+    if (!m_hasWriteWatch) {
         return;
         return;
+    }
 
     RemoveWriteWatch();
     m_hasWriteWatch = false;
 
     RemoveWriteWatch();
     m_hasWriteWatch = false;
@@ -134,40 +155,40 @@ void WaitableInputOutputExecutionContextSupport::CheckedRemoveReadWriteWatch()
     CheckedRemoveWriteWatch();
 }
 
     CheckedRemoveWriteWatch();
 }
 
-void WaitableInputOutputExecutionContextSupport::OnWaitableHandleEvent(WaitableHandle waitableHandle, WaitMode::Type mode)
+void WaitableInputOutputExecutionContextSupport::OnWaitableHandleEvent(
+    WaitableHandle waitableHandle,
+    WaitMode::Type mode)
 {
     (void)waitableHandle;
 
 {
     (void)waitableHandle;
 
-    switch (mode)
-    {
-        case WaitMode::Read:
-            LogPedantic("Read event occurred");
+    switch (mode) {
+    case WaitMode::Read:
+        LogPedantic("Read event occurred");
 
 
-            // Read and parse bytes
-            ReadInput();
+        // Read and parse bytes
+        ReadInput();
 
 
-            // Done
-            break;
+        // Done
+        break;
 
 
-        case WaitMode::Write:
-            LogPedantic("Write event occurred");
+    case WaitMode::Write:
+        LogPedantic("Write event occurred");
 
 
-            // Push bytes and unregister from write event
-            FeedOutput();
+        // Push bytes and unregister from write event
+        FeedOutput();
 
 
-            // Unregister write watch only if no more data is available
-            if (m_outputStream.Empty())
-            {
-                Assert(m_hasWriteWatch == true);
-                CheckedRemoveWriteWatch();
-            }
+        // Unregister write watch only if no more data is available
+        if (m_outputStream.Empty()) {
+            Assert(m_hasWriteWatch == true);
+            CheckedRemoveWriteWatch();
+        }
 
 
-            // Done
-            break;
+        // Done
+        break;
 
 
-        default:
-            Assert(0);
-            break;
+    default:
+        Assert(0);
+        break;
     }
 }
 
     }
 }
 
@@ -177,17 +198,16 @@ void WaitableInputOutputExecutionContextSupport::ReadInput()
 
     Try
     {
 
     Try
     {
-        BinaryQueueAutoPtr inputBuffer = m_waitableInputOutput->Read(DEFAULT_READ_SIZE);
+        BinaryQueueAutoPtr inputBuffer = m_waitableInputOutput->Read(
+                DEFAULT_READ_SIZE);
 
 
-        if (inputBuffer.get() == NULL)
-        {
+        if (inputBuffer.get() == NULL) {
             // No data, should not occur
             LogPedantic("WARNING: Spontaneous ReadSocket occurred");
             return;
         }
 
             // No data, should not occur
             LogPedantic("WARNING: Spontaneous ReadSocket occurred");
             return;
         }
 
-        if (inputBuffer->Empty())
-        {
+        if (inputBuffer->Empty()) {
             // Connection was closed
             OnInputStreamClosed();
 
             // Connection was closed
             OnInputStreamClosed();
 
@@ -207,8 +227,9 @@ void WaitableInputOutputExecutionContextSupport::ReadInput()
         // Append all read data
         m_inputStream.AppendMoveFrom(*inputBuffer);
     }
         // Append all read data
         m_inputStream.AppendMoveFrom(*inputBuffer);
     }
-    Catch (AbstractSocket::Exception::ConnectionBroken) // FIXME: Inproper exception abstraction !!!
+    Catch(AbstractSocket::Exception::ConnectionBroken)
     {
     {
+        //FIXME: Inproper exception abstraction!!!
         // Some errors occurred while feeding abstract IO
         // Interpret connection broken errors, and pass futher other ones
         LogPedantic("Abstract IO connection was broken during read");
         // Some errors occurred while feeding abstract IO
         // Interpret connection broken errors, and pass futher other ones
         LogPedantic("Abstract IO connection was broken during read");
@@ -233,12 +254,14 @@ void WaitableInputOutputExecutionContextSupport::ReadInput()
 
 void WaitableInputOutputExecutionContextSupport::FeedOutput()
 {
 
 void WaitableInputOutputExecutionContextSupport::FeedOutput()
 {
-    if (!m_opened)
+    if (!m_opened) {
         Throw(Exception::NotOpened);
         Throw(Exception::NotOpened);
+    }
 
     // Anything to feed ?
 
     // Anything to feed ?
-    if (m_outputStream.Empty())
+    if (m_outputStream.Empty()) {
         return;
         return;
+    }
 
     // OK to feed output
     LogPedantic("Feeding output");
 
     // OK to feed output
     LogPedantic("Feeding output");
@@ -246,13 +269,13 @@ void WaitableInputOutputExecutionContextSupport::FeedOutput()
     Try
     {
         // Try to write some bytes
     Try
     {
         // Try to write some bytes
-        size_t bytes = m_waitableInputOutput->Write(m_outputStream, m_outputStream.Size());
+        size_t bytes = m_waitableInputOutput->Write(m_outputStream,
+                                                    m_outputStream.Size());
 
 
-        if (bytes < m_outputStream.Size())
-        {
-            // Start exhaustive output feeding if it is blocked and not already started
-            if (!m_hasWriteWatch)
-            {
+        if (bytes < m_outputStream.Size()) {
+            // Start exhaustive output feeding if it is blocked and not already
+            // started
+            if (!m_hasWriteWatch) {
                 AddWriteWatch();
                 m_hasWriteWatch = true;
 
                 AddWriteWatch();
                 m_hasWriteWatch = true;
 
@@ -263,7 +286,9 @@ void WaitableInputOutputExecutionContextSupport::FeedOutput()
         // Some bytes were written, consume them
         m_outputStream.Consume(bytes);
     }
         // Some bytes were written, consume them
         m_outputStream.Consume(bytes);
     }
-    Catch (AbstractSocket::Exception::ConnectionBroken) // FIXME: Inproper exception abstraction !!!
+    Catch(AbstractSocket::Exception::ConnectionBroken)  // FIXME: Inproper
+                                                        // exception abstraction
+                                                        // !!!
     {
         // Some errors occurred while feeding abstract IO
         // Interpret connection broken errors, and pass futher other ones
     {
         // Some errors occurred while feeding abstract IO
         // Interpret connection broken errors, and pass futher other ones
@@ -283,6 +308,5 @@ void WaitableInputOutputExecutionContextSupport::FeedOutput()
         return;
     }
 }
         return;
     }
 }
-
 }
 } // namespace DPL
 }
 } // namespace DPL
diff --git a/modules/support/config.cmake b/modules/support/config.cmake
new file mode 100644 (file)
index 0000000..e2865f6
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        config.cmake
+# @author      Lukasz Marek (l.marek@samsung.com)
+# @version     1.0
+# @brief
+#
+
+
+SET(DPL_WRT_ENGINE_HEADERS
+    ${PROJECT_SOURCE_DIR}/modules/support/wrt_plugin_export.h
+    PARENT_SCOPE
+)
diff --git a/modules/support/wrt_plugin_export.h b/modules/support/wrt_plugin_export.h
new file mode 100644 (file)
index 0000000..ae1e8e1
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    wrt_plugin_export.h
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief   Header file for plugin export API
+ */
+#ifndef WRT_PLUGIN_EXPORT_H
+#define WRT_PLUGIN_EXPORT_H
+
+#include <stddef.h>
+
+/**
+ * Widget handle type
+ */
+typedef int widget_handle_t;
+
+/**
+ * Parameter which should be used during policy evaluation.
+ */
+typedef struct ace_param_s
+{
+    const char *name;
+    const char *value;
+} ace_param_t;
+
+/**
+ * List of additional parameters which should be used during policy evaluation.
+ */
+typedef struct ace_param_list_s
+{
+    size_t count;
+    ace_param_t *param;
+} ace_param_list_t;
+
+/**
+ * Contains list of device capabilities. Each device capability may have
+ * associated list of function params.
+ */
+typedef struct ace_device_cap_s
+{
+    size_t devcapsCount;
+    const char**      dev_cap_names;
+    size_t paramsCount;
+    ace_param_list_t* params;
+} ace_device_cap_t;
+
+/**
+ * List of device capabilities which must be check.
+ */
+typedef struct ace_device_capabilities_s
+{
+    size_t count;
+    const char **device_cap;
+} ace_device_capabilities_t;
+
+/**
+ * List of api features that must be checked
+ */
+typedef struct ace_api_features_s
+{
+    size_t count;
+    const char **api_feature;
+} ace_api_features_t;
+
+/**
+ * Data from request will be used to evaluate policy file.
+ */
+typedef struct ace_request_s
+{
+    widget_handle_t widget_handle;
+    const char*                 feature_api;
+    const char*                 function_name;
+    ace_device_capabilities_t device_capabilities;
+    ace_param_list_t param_list;
+} ace_request_t;
+
+/**
+ * Data from request will be used to evaluate policy file.
+ */
+typedef struct ace_request_2_s
+{
+    widget_handle_t widget_handle;
+    ace_api_features_t api_features;
+    const char*                 function_name;
+    ace_device_cap_t device_capabilities;
+} ace_request_2_t;
+
+/**
+ * info returned by plugin_api_check_access
+ */
+#define PLUGIN_API_ACCESS_GRANTED 1
+#define PLUGIN_API_ACCESS_DENIED 0
+#define PLUGIN_API_ACCESS_ERROR -1
+
+typedef const void* java_script_context_t;
+
+typedef struct js_object_properties_s
+{
+    size_t count;
+    char** properties;
+} js_object_properties_t;
+
+typedef const void* js_class_template_t;
+typedef void* js_object_ref_t;
+typedef const void* js_value_ref_t;
+
+typedef js_class_template_t (*js_class_template_getter)(void);
+typedef void* (*js_class_constructor_cb_t)(js_class_template_t,
+                                           js_object_ref_t, size_t,
+                                           js_value_ref_t[],
+                                           js_value_ref_t*);
+
+typedef enum class_definition_type_e
+{
+    JS_CLASS,
+    JS_FUNCTION,
+    JS_INTERFACE
+} class_definition_type_t;
+
+typedef enum class_definition_iframe_behaviour_e
+{
+    //object should not be initalized in iframes
+    //it is default one
+    NONE,
+    //object should be copied as reference to each iframe
+    REFERENCE,
+    //object should be created for each iframe and NOT inform plugin
+    CREATE_INSTANCE
+} class_definition_iframe_behaviour_t;
+
+typedef enum class_definition_iframe_notice_e
+{
+    //it is default one
+    NONE_NOTICE,
+    ALWAYS_NOTICE
+} class_definition_iframe_notice_t;
+
+typedef enum class_definition_iframe_overlay_e
+{
+    IGNORED,
+    USE_OVERLAYED,
+    OVERLAYED_BEFORE_ORIGINAL
+} class_definition_iframe_overlay_t;
+
+typedef void* js_object_instance_t;
+//global_context - id
+typedef void (*iframe_loaded_cb)(java_script_context_t global_context,
+                                 js_object_instance_t iframe,
+                                 js_object_instance_t object);
+
+typedef void* (*js_function_impl)(void*);
+
+typedef struct class_definition_options_s
+{
+    class_definition_type_t type;
+    class_definition_iframe_behaviour_t iframe_option;
+    class_definition_iframe_notice_t iframe_notice;
+    class_definition_iframe_overlay_t iframe_overlay;
+    iframe_loaded_cb cb;
+    void * private_data;
+    js_function_impl function;
+} class_definition_options_t;
+
+/*
+ * list of device caps
+ */
+typedef struct devcaps_s
+{
+    char** deviceCaps;
+    size_t devCapsCount;
+} devcaps_t;
+
+/*
+ * mapping from a feature to corresponding list of device capabilities
+ */
+typedef struct feature_devcaps_s
+{
+    char* feature_name;
+    devcaps_t devCaps;
+} feature_devcaps_t;
+
+/*
+ * list of feature_devcaps_t structs
+ */
+typedef struct feature_mapping_s
+{
+    feature_devcaps_t* features;
+    size_t featuresCount;
+} feature_mapping_t;
+
+typedef feature_mapping_t* pfeature_mapping_t;
+
+typedef pfeature_mapping_t (*features_getter)(void);
+
+typedef const devcaps_t* (*devcaps_getter)(pfeature_mapping_t /*features*/,
+                                           const char* /*featureName*/);
+typedef void (*deinitializer)(pfeature_mapping_t /*features*/);
+
+typedef struct feature_mapping_interface_s
+{
+    features_getter featGetter;  /* returns a list of api features */
+    devcaps_getter dcGetter;     /*
+                                  * for a given api feature returns a list of
+                                  * corresponding device capabilities
+                                  */
+
+    deinitializer release;       /* as memory ownership of features is
+                                  * transfered to callee you have to call
+                                  * the release function ptr on features
+                                  */
+} feature_mapping_interface_t;
+
+/*
+ * This is a structure describing a JS entity template (a class, an interface
+ * or function), object name and it's parent class name (parent_name). JS
+ * entity will be bind to a parent class name (parent_name.js_entity_name).
+ * @param parent_name - parent name (ie Widget.Device)
+ * @param object_name - object name (DeviceStatus)
+ * @param interface_name - interface name (e.g. Widget)
+ * @param js_class_template_getter_fun - js_class_template required to create
+ *          JS object
+ * @param js_class_consturctor_cb - constructor to call to when instance of
+ *          certain interface is created
+ * @param private_data private data for object creator if required (usually
+ *          NULL)
+ */
+typedef struct js_entity_definition_s
+{
+    const char *parent_name;
+    const char *object_name;
+    const char *interface_name;
+    js_class_template_getter js_class_template_getter_fun;
+    js_class_constructor_cb_t js_class_constructor_cb;
+    //class options may be null - default
+    class_definition_options_t* class_options;
+} js_entity_definition_t;
+
+typedef const js_entity_definition_t *js_entity_definition_ptr_t;
+
+/**
+ * Plugin export names
+ */
+#define PLUGIN_WIDGET_START_PROC        on_widget_start
+#define PLUGIN_WIDGET_INIT_PROC         on_widget_init
+#define PLUGIN_WIDGET_STOP_PROC         on_widget_stop
+#define PLUGIN_FRAME_LOAD_PROC          on_frame_load
+#define PLUGIN_FRAME_UNLOAD_PROC        on_frame_unload
+#define PLUGIN_CLASS_MAP                class_map
+#define PLUGIN_GET_CLASS_PROC_MAP       get_widget_class_map
+
+#define PLUGIN_WIDGET_START_PROC_NAME   "on_widget_start"
+#define PLUGIN_WIDGET_INIT_PROC_NAME    "on_widget_init"
+#define PLUGIN_WIDGET_STOP_PROC_NAME    "on_widget_stop"
+#define PLUGIN_FRAME_LOAD_PROC_NAME     "on_frame_load"
+#define PLUGIN_FRAME_UNLOAD_PROC_NAME   "on_frame_unload"
+#define PLUGIN_CLASS_MAP_NAME           "class_map"
+#define PLUGIN_GET_CLASS_MAP_PROC_NAME  "get_widget_class_map"
+
+/**
+ * Plugin export typedefs
+ */
+typedef void (*on_widget_start_proc)(int widgetId);
+
+typedef void (*on_widget_init_proc)(feature_mapping_interface_t *interface);
+
+/**
+ * FIXME: Add documentation
+ */
+typedef void (*on_widget_stop_proc)(int widgetId);
+
+typedef void (*on_frame_load_proc)(java_script_context_t context);
+
+typedef void (*on_frame_unload_proc)(java_script_context_t context);
+
+typedef const js_entity_definition_t* (*get_widget_entity_map_proc)();
+
+#endif // WRT_PLUGIN_EXPORT_H
index 69d5341..d3485cf 100644 (file)
@@ -22,6 +22,7 @@
 SET(DPL_TEST_ENGINE_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_results_collector.cpp
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_runner.cpp
 SET(DPL_TEST_ENGINE_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_results_collector.cpp
     ${PROJECT_SOURCE_DIR}/modules/test/src/test_runner.cpp
+    ${PROJECT_SOURCE_DIR}/modules/test/src/test_runner_child.cpp
     PARENT_SCOPE
 )
 
     PARENT_SCOPE
 )
 
@@ -29,6 +30,7 @@ SET(DPL_TEST_ENGINE_SOURCES
 SET(DPL_TEST_ENGINE_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_results_collector.h
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner.h
 SET(DPL_TEST_ENGINE_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_results_collector.h
     ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner.h
+    ${PROJECT_SOURCE_DIR}/modules/test/include/dpl/test/test_runner_child.h
     PARENT_SCOPE
 )
 
     PARENT_SCOPE
 )
 
index 6c4e24b..73fe1bf 100644 (file)
 #ifndef DPL_TEST_RESULTS_COLLECTOR_H
 #define DPL_TEST_RESULTS_COLLECTOR_H
 
 #ifndef DPL_TEST_RESULTS_COLLECTOR_H
 #define DPL_TEST_RESULTS_COLLECTOR_H
 
-#include <dpl/shared_ptr.h>
 #include <dpl/noncopyable.h>
 #include <vector>
 #include <list>
 #include <map>
 #include <string>
 #include <dpl/noncopyable.h>
 #include <vector>
 #include <list>
 #include <map>
 #include <string>
+#include <memory>
 
 
-namespace DPL
-{
-namespace Test
-{
-
+namespace DPL {
+namespace Test {
 class TestResultsCollectorBase;
 class TestResultsCollectorBase;
-typedef DPL::SharedPtr<TestResultsCollectorBase>
-    TestResultsCollectorBasePtr;
+typedef std::shared_ptr<TestResultsCollectorBase>
+TestResultsCollectorBasePtr;
 
 
-class TestResultsCollectorBase
-    private DPL::Noncopyable
+class TestResultsCollectorBase :
+    private DPL::Noncopyable
 {
   public:
     typedef TestResultsCollectorBase* (*CollectorConstructorFunc)();
 {
   public:
     typedef TestResultsCollectorBase* (*CollectorConstructorFunc)();
@@ -52,39 +49,46 @@ class TestResultsCollectorBase
             NONE,
             FAILED,
             IGNORED,
             NONE,
             FAILED,
             IGNORED,
-            TODO,
             INTERNAL
         };
     };
 
     virtual ~TestResultsCollectorBase() {}
 
             INTERNAL
         };
     };
 
     virtual ~TestResultsCollectorBase() {}
 
-    virtual bool Configure() { return true; }
+    virtual bool Configure()
+    {
+        return true;
+    }
     virtual void Start() { }
     virtual void Finish() { }
     virtual void Start() { }
     virtual void Finish() { }
-    virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/) {}
+    virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/)
+    {}
 
     virtual void CollectTestsCasesList(const TestCaseIdList& /*list*/) {}
     virtual void CollectResult(const std::string& id,
                                const std::string& description,
                                const FailStatus::Type status = FailStatus::NONE,
                                const std::string& reason = "") = 0;
 
     virtual void CollectTestsCasesList(const TestCaseIdList& /*list*/) {}
     virtual void CollectResult(const std::string& id,
                                const std::string& description,
                                const FailStatus::Type status = FailStatus::NONE,
                                const std::string& reason = "") = 0;
-    virtual std::string CollectorSpecificHelp() const { return ""; }
+    virtual std::string CollectorSpecificHelp() const
+    {
+        return "";
+    }
     virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
     {
         return false;
     }
 
     static TestResultsCollectorBase* Create(const std::string& name);
     virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
     {
         return false;
     }
 
     static TestResultsCollectorBase* Create(const std::string& name);
-    static void RegisterCollectorConstructor(const std::string& name,
-                                             CollectorConstructorFunc constructor);
+    static void RegisterCollectorConstructor(
+        const std::string& name,
+        CollectorConstructorFunc
+        constructor);
     static std::vector<std::string> GetCollectorsNames();
 
   private:
     typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
     static ConstructorsMap m_constructorsMap;
 };
     static std::vector<std::string> GetCollectorsNames();
 
   private:
     typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
     static ConstructorsMap m_constructorsMap;
 };
-
 }
 }
 
 }
 }
 
index ab1a626..99a2cb5 100644 (file)
 #include <vector>
 #include <list>
 #include <set>
 #include <vector>
 #include <list>
 #include <set>
+#include <map>
 
 
-namespace DPL
-{
-namespace Test
-{
+namespace DPL {
+namespace Test {
 class TestRunner
 {
 class TestRunner
 {
-    TestResultsCollectorBasePtr m_collector;
-    std::string m_collectorName;
+    typedef std::map<std::string, TestResultsCollectorBasePtr>
+    TestResultsCollectors;
+    TestResultsCollectors m_collectors;
+
     std::string m_startTestId;
     std::string m_startTestId;
+    bool m_runIgnored;
+
+  public:
+    TestRunner() :
+        m_terminate(false)
+      , m_allowChildLogs(false)
+    {}
 
 
-public:
     typedef void (*TestCase)();
 
     typedef void (*TestCase)();
 
-private:
+  private:
     struct TestCaseStruct
     {
         std::string name;
     struct TestCaseStruct
     {
         std::string name;
@@ -62,11 +69,10 @@ private:
             return name == other.name;
         }
 
             return name == other.name;
         }
 
-        TestCaseStruct(const std::string &n, TestCase p)
-            : name(n),
-              proc(p)
-        {
-        }
+        TestCaseStruct(const std::string &n, TestCase p) :
+            name(n),
+            proc(p)
+        {}
     };
 
     typedef std::list<TestCaseStruct> TestCaseStructList;
     };
 
     typedef std::list<TestCaseStruct> TestCaseStructList;
@@ -81,26 +87,37 @@ private:
 
     DPL::Atomic m_totalAssertions;
 
 
     DPL::Atomic m_totalAssertions;
 
+    // Terminate without any logs.
+    // Some test requires to call fork function.
+    // Child process must not produce any logs and should die quietly.
+    bool m_terminate;
+    bool m_allowChildLogs;
+
     void Banner();
     void Banner();
-    void InvalidArgs();
+    void InvalidArgs(const std::string& message = "Invalid arguments!");
     void Usage();
 
     void Usage();
 
-    enum Status { FAILED, TODO, IGNORED, PASS };
+    enum Status { FAILED, IGNORED, PASS };
 
     Status RunTestCase(const TestCaseStruct& testCase);
 
     void RunTests();
 
 
     Status RunTestCase(const TestCaseStruct& testCase);
 
     void RunTests();
 
-public:
+    void CollectResult(const std::string& id,
+                       const std::string& description,
+                       const TestResultsCollectorBase::FailStatus::Type status
+                           = TestResultsCollectorBase::FailStatus::NONE,
+                       const std::string& reason = std::string());
+
+  public:
     class TestFailed
     {
     class TestFailed
     {
-    private:
+      private:
         std::string m_message;
 
         std::string m_message;
 
-    public:
+      public:
         TestFailed()
         TestFailed()
-        {
-        }
+        {}
 
         //! \brief Failed test message creator
         //!
 
         //! \brief Failed test message creator
         //!
@@ -108,28 +125,12 @@ public:
         //! \param[in] aFile source file name
         //! \param[in] aLine source file line
         //! \param[in] aMessage error message
         //! \param[in] aFile source file name
         //! \param[in] aLine source file line
         //! \param[in] aMessage error message
-        TestFailed(const char* aTest, const char* aFile, int aLine, const std::string &aMessage);
-
-        std::string GetMessage() const
-        {
-            return m_message;
-        }
-    };
+        TestFailed(const char* aTest,
+                   const char* aFile,
+                   int aLine,
+                   const std::string &aMessage);
 
 
-    class ToDo
-    {
-    private:
-        std::string m_message;
-
-    public:
-        ToDo()
-        {
-        }
-
-        ToDo(const std::string &message)
-            : m_message(message)
-        {
-        }
+        TestFailed(const std::string &message);
 
         std::string GetMessage() const
         {
 
         std::string GetMessage() const
         {
@@ -139,18 +140,16 @@ public:
 
     class Ignored
     {
 
     class Ignored
     {
-    private:
+      private:
         std::string m_message;
 
         std::string m_message;
 
-    public:
+      public:
         Ignored()
         Ignored()
-        {
-        }
+        {}
 
 
-        Ignored(const std::string &message)
-            : m_message(message)
-        {
-        }
+        Ignored(const std::string &message) :
+            m_message(message)
+        {}
 
         std::string GetMessage() const
         {
 
         std::string GetMessage() const
         {
@@ -166,20 +165,23 @@ public:
     int ExecTestRunner(int argc, char *argv[]);
     typedef std::vector<std::string> ArgsList;
     int ExecTestRunner(const ArgsList& args);
     int ExecTestRunner(int argc, char *argv[]);
     typedef std::vector<std::string> ArgsList;
     int ExecTestRunner(const ArgsList& args);
+    bool getRunIgnored() const;
+    // The runner will terminate as soon as possible (after current test).
+    void Terminate();
+    bool GetAllowChildLogs();
 };
 
 typedef DPL::Singleton<TestRunner> TestRunnerSingleton;
 };
 
 typedef DPL::Singleton<TestRunner> TestRunnerSingleton;
-
 }
 } // namespace DPL
 
 #define RUNNER_TEST_GROUP_INIT(GroupName)                                \
     static int Static##GroupName##Init()                                 \
     {                                                                    \
 }
 } // namespace DPL
 
 #define RUNNER_TEST_GROUP_INIT(GroupName)                                \
     static int Static##GroupName##Init()                                 \
     {                                                                    \
-        DPL::Test::TestRunnerSingleton::Instance().InitGroup(#GroupName);\
+        DPL::Test::TestRunnerSingleton::Instance().InitGroup(#GroupName); \
         return 0;                                                        \
     }                                                                    \
         return 0;                                                        \
     }                                                                    \
-    const int DPL_UNUSED  Static##GroupName##InitVar =                   \
+    const int DPL_UNUSED Static##GroupName##InitVar =                   \
         Static##GroupName##Init();
 
 #define RUNNER_TEST(Proc)                                                \
         Static##GroupName##Init();
 
 #define RUNNER_TEST(Proc)                                                \
@@ -189,30 +191,35 @@ typedef DPL::Singleton<TestRunner> TestRunnerSingleton;
         DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
         return 0;                                                        \
     }                                                                    \
         DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \
         return 0;                                                        \
     }                                                                    \
-    const int DPL_UNUSED  Static##Proc##InitVar = Static##Proc##Init();  \
+    const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init();  \
     void Proc()
 
 //! \brief Returns base name for path
 
 #define RUNNER_ASSERT_MSG(test, message)                                               \
     void Proc()
 
 //! \brief Returns base name for path
 
 #define RUNNER_ASSERT_MSG(test, message)                                               \
-do                                                                                     \
-{                                                                                      \
-    DPL::Test::TestRunnerSingleton::Instance().MarkAssertion();                        \
+    do                                                                                     \
+    {                                                                                      \
+        DPL::Test::TestRunnerSingleton::Instance().MarkAssertion();                        \
                                                                                        \
                                                                                        \
-    if (!(test))                                                                       \
-    {                                                                                  \
-        std::ostringstream assertMsg;                                                  \
-        assertMsg << message;                                                          \
-        throw DPL::Test::TestRunner::TestFailed(#test, __FILE__, __LINE__, assertMsg.str()); \
-    }                                                                                  \
-} while (0)
+        if (!(test))                                                                       \
+        {                                                                                  \
+            std::ostringstream assertMsg;                                                  \
+            assertMsg << message;                                                          \
+            throw DPL::Test::TestRunner::TestFailed(#test, \
+                                                    __FILE__, \
+                                                    __LINE__, \
+                                                    assertMsg.str()); \
+        }                                                                                  \
+    } while (0)
 
 #define RUNNER_ASSERT(test) RUNNER_ASSERT_MSG(test, "")
 
 #define RUNNER_FAIL RUNNER_ASSERT(false)
 
 
 #define RUNNER_ASSERT(test) RUNNER_ASSERT_MSG(test, "")
 
 #define RUNNER_FAIL RUNNER_ASSERT(false)
 
-#define RUNNER_TODO_MSG(message) do { std::ostringstream assertMsg; assertMsg << message; throw DPL::Test::TestRunner::ToDo(assertMsg.str()); } while (0)
-
-#define RUNNER_IGNORED_MSG(message) do { std::ostringstream assertMsg; assertMsg << message; throw DPL::Test::TestRunner::Ignored(assertMsg.str()); } while (0)
+#define RUNNER_IGNORED_MSG(message) do { std::ostringstream assertMsg; \
+                                         assertMsg << message; \
+                                         throw DPL::Test::TestRunner::Ignored( \
+                                                   assertMsg.str()); \
+} while (0)
 
 #endif // DPL_TEST_RUNNER_H
 
 #endif // DPL_TEST_RUNNER_H
diff --git a/modules/test/include/dpl/test/test_runner_child.h b/modules/test/include/dpl/test/test_runner_child.h
new file mode 100644 (file)
index 0000000..b20c371
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_runner_child.h
+ * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version     1.0
+ * @brief       This file is the header file of test runner
+ */
+#ifndef DPL_TEST_RUNNER_CHILD_H
+#define DPL_TEST_RUNNER_CHILD_H
+
+#include <dpl/test/test_runner.h>
+
+namespace DPL {
+namespace Test {
+void RunChildProc(TestRunner::TestCase procChild);
+} // namespace Test
+} // namespace DPL
+
+#define RUNNER_CHILD_TEST(Proc)                                                      \
+    void Proc();                                                                     \
+    void Proc##Child();                                                              \
+    static int Static##Proc##Init()                                                  \
+    {                                                                                \
+        DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc);       \
+        return 0;                                                                    \
+    }                                                                                \
+    const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init();               \
+    void Proc(){                                                                     \
+        DPL::Test::RunChildProc(&Proc##Child);                                       \
+    }                                                                                \
+    void Proc##Child()
+
+#endif // DPL_TEST_RUNNER_CHILD_H
index 07a6a69..482b132 100644 (file)
  * @version     1.0
  * @brief       Implementation file some concrete TestResulstsCollector
  */
  * @version     1.0
  * @brief       Implementation file some concrete TestResulstsCollector
  */
-
+#include <cstddef>
 #include <dpl/test/test_results_collector.h>
 #include <dpl/colors.h>
 #include <dpl/assert.h>
 #include <dpl/foreach.h>
 #include <dpl/scoped_fclose.h>
 #include <dpl/test/test_results_collector.h>
 #include <dpl/colors.h>
 #include <dpl/assert.h>
 #include <dpl/foreach.h>
 #include <dpl/scoped_fclose.h>
+#include <dpl/exception.h>
+#include <dpl/errno_string.h>
 
 #include <string>
 
 #include <string>
+#include <string.h>
 #include <cstdio>
 #include <cstdio>
+#include <fstream>
+#include <sstream>
+#include <cstdlib>
 
 
-namespace DPL
-{
-namespace Test
-{
+#define GREEN_RESULT_OK "[%s%s%s]\n", BOLD_GREEN_BEGIN, "   OK   ", \
+    BOLD_GREEN_END
 
 
-namespace
-{
+namespace DPL {
+namespace Test {
+namespace {
 const char *DEFAULT_HTML_FILE_NAME = "index.html";
 const char *DEFAULT_HTML_FILE_NAME = "index.html";
+const char *DEFAULT_TAP_FILE_NAME = "results.tap";
+const char *DEFAULT_XML_FILE_NAME = "results.xml";
+
+bool ParseCollectorFileArg(const std::string &arg, std::string &filename)
+{
+    const std::string argname = "--file=";
+    if (0 == arg.find(argname)) {
+        filename = arg.substr(argname.size());
+        return true;
+    }
+    return false;
+}
 
 class Statistic
 {
 
 class Statistic
 {
@@ -44,32 +61,46 @@ class Statistic
     Statistic() :
         m_failed(0),
         m_ignored(0),
     Statistic() :
         m_failed(0),
         m_ignored(0),
-        m_todo(0),
         m_passed(0),
         m_count(0)
         m_passed(0),
         m_count(0)
-    {
-    }
+    {}
 
     void AddTest(TestResultsCollectorBase::FailStatus::Type type)
     {
         ++m_count;
         switch (type) {
 
     void AddTest(TestResultsCollectorBase::FailStatus::Type type)
     {
         ++m_count;
         switch (type) {
-            case TestResultsCollectorBase::FailStatus::INTERNAL:
-            case TestResultsCollectorBase::FailStatus::FAILED:   ++m_failed; break;
-            case TestResultsCollectorBase::FailStatus::IGNORED:  ++m_ignored; break;
-            case TestResultsCollectorBase::FailStatus::TODO:     ++m_todo; break;
-            case TestResultsCollectorBase::FailStatus::NONE:     ++m_passed; break;
-            default:
-                Assert(false && "Bad FailStatus");
+        case TestResultsCollectorBase::FailStatus::INTERNAL:
+        case TestResultsCollectorBase::FailStatus::FAILED:   ++m_failed;
+            break;
+        case TestResultsCollectorBase::FailStatus::IGNORED:  ++m_ignored;
+            break;
+        case TestResultsCollectorBase::FailStatus::NONE:     ++m_passed;
+            break;
+        default:
+            Assert(false && "Bad FailStatus");
         }
     }
 
         }
     }
 
-    size_t GetTotal() const { return m_count; }
-    size_t GetPassed() const { return m_passed; }
-    size_t GetSuccesed() const { return m_passed; }
-    size_t GetFailed() const { return m_failed; }
-    size_t GetTODO() const { return m_todo; }
-    size_t GetIgnored() const { return m_ignored; }
+    std::size_t GetTotal() const
+    {
+        return m_count;
+    }
+    std::size_t GetPassed() const
+    {
+        return m_passed;
+    }
+    std::size_t GetSuccesed() const
+    {
+        return m_passed;
+    }
+    std::size_t GetFailed() const
+    {
+        return m_failed;
+    }
+    std::size_t GetIgnored() const
+    {
+        return m_ignored;
+    }
     float GetPassedOrIgnoredPercend() const
     {
         float passIgnoredPercent =
     float GetPassedOrIgnoredPercend() const
     {
         float passIgnoredPercent =
@@ -80,15 +111,14 @@ class Statistic
     }
 
   private:
     }
 
   private:
-    size_t m_failed;
-    size_t m_ignored;
-    size_t m_todo;
-    size_t m_passed;
-    size_t m_count;
+    std::size_t m_failed;
+    std::size_t m_ignored;
+    std::size_t m_passed;
+    std::size_t m_count;
 };
 
 };
 
-class ConsoleCollector
-    public TestResultsCollectorBase
+class ConsoleCollector :
+    public TestResultsCollectorBase
 {
   public:
     static TestResultsCollectorBase* Constructor();
 {
   public:
     static TestResultsCollectorBase* Constructor();
@@ -122,19 +152,21 @@ class ConsoleCollector
         std::string tmp = "'" + id + "' ...";
 
         printf("Running test case %-60s", tmp.c_str());
         std::string tmp = "'" + id + "' ...";
 
         printf("Running test case %-60s", tmp.c_str());
-        switch(status) {
-            case TestResultsCollectorBase::FailStatus::NONE:
-                printf("[%s%s%s]\n", BOLD_GREEN_BEGIN, "   OK   ", BOLD_GREEN_END); break;
-            case TestResultsCollectorBase::FailStatus::FAILED:
-                PrintfErrorMessage(  " FAILED ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::IGNORED:
-                PrintfIgnoredMessage("Ignored ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::TODO:
-                PrintfTODOMessage(   "  TODO  ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::INTERNAL:
-                PrintfErrorMessage(  "INTERNAL", reason, true); break;
-            default:
-                Assert(false && "Bad status");
+        switch (status) {
+        case TestResultsCollectorBase::FailStatus::NONE:
+            printf(GREEN_RESULT_OK);
+            break;
+        case TestResultsCollectorBase::FailStatus::FAILED:
+            PrintfErrorMessage(" FAILED ", reason, true);
+            break;
+        case TestResultsCollectorBase::FailStatus::IGNORED:
+            PrintfIgnoredMessage("Ignored ", reason, true);
+            break;
+        case TestResultsCollectorBase::FailStatus::INTERNAL:
+            PrintfErrorMessage("INTERNAL", reason, true);
+            break;
+        default:
+            Assert(false && "Bad status");
         }
         m_stats.AddTest(status);
         m_groupsStats[m_currentGroup].AddTest(status);
         }
         m_stats.AddTest(status);
         m_groupsStats[m_currentGroup].AddTest(status);
@@ -155,30 +187,9 @@ class ConsoleCollector
                    BOLD_YELLOW_END);
         } else {
             printf("[%s%s%s]\n",
                    BOLD_YELLOW_END);
         } else {
             printf("[%s%s%s]\n",
-                    BOLD_RED_BEGIN,
-                    type,
-                    BOLD_RED_END);
-        }
-    }
-
-    void PrintfTODOMessage(const char* type,
-                           const std::string& message,
-                           bool verbosity)
-    {
-        using namespace DPL::Colors::Text;
-        if (verbosity) {
-            printf("[%s%s%s] %s%s%s\n",
-                   BOLD_WHITE_BEGIN,
-                   type,
-                   BOLD_WHITE_END,
-                   BOLD_GOLD_BEGIN,
-                   message.c_str(),
-                   BOLD_GOLD_END);
-        } else {
-            printf("[%s%s%s]\n",
-                   BOLD_WHITE_BEGIN,
+                   BOLD_RED_BEGIN,
                    type,
                    type,
-                   BOLD_WHITE_END);
+                   BOLD_RED_END);
         }
     }
 
         }
     }
 
@@ -197,7 +208,7 @@ class ConsoleCollector
                    BOLD_GOLD_END);
         } else {
             printf("[%s%s%s]\n",
                    BOLD_GOLD_END);
         } else {
             printf("[%s%s%s]\n",
-                   CYAN_BEGIN ,
+                   CYAN_BEGIN,
                    type,
                    CYAN_END);
         }
                    type,
                    CYAN_END);
         }
@@ -206,14 +217,28 @@ class ConsoleCollector
     void PrintStats(const std::string& title, const Statistic& stats)
     {
         using namespace DPL::Colors::Text;
     void PrintStats(const std::string& title, const Statistic& stats)
     {
         using namespace DPL::Colors::Text;
-        printf("\n%sResults [%s]: %s\n", BOLD_GREEN_BEGIN, title.c_str(), BOLD_GREEN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Total tests:            ", stats.GetTotal(), CYAN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Succeeded or ignored:   ", stats.GetPassed() + stats.GetIgnored(), CYAN_END);
-        printf("  %s%s%3d%s\n", CYAN_BEGIN,     "Succeeded:            ", stats.GetPassed(), CYAN_END);
-        printf("  %s%s%3d%s\n", CYAN_BEGIN,     "Ignored:              ", stats.GetIgnored(), CYAN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Failed:                 ", stats.GetFailed(), CYAN_END);
-        printf("%s%s%3d%s\n", CYAN_BEGIN,     "Todo:                   ", stats.GetTODO(), CYAN_END);
-        printf("%s%s%3.0f%%%s\n", CYAN_BEGIN, "Succeeded or ignored %: ", stats.GetPassedOrIgnoredPercend(), CYAN_END);
+        printf("\n%sResults [%s]: %s\n", BOLD_GREEN_BEGIN,
+               title.c_str(), BOLD_GREEN_END);
+        printf("%s%s%3d%s\n",
+               CYAN_BEGIN,
+               "Total tests:            ",
+               stats.GetTotal(),
+               CYAN_END);
+        printf("  %s%s%3d%s\n",
+               CYAN_BEGIN,
+               "Succeeded:            ",
+               stats.GetPassed(),
+               CYAN_END);
+        printf("  %s%s%3d%s\n",
+               CYAN_BEGIN,
+               "Failed:               ",
+               stats.GetFailed(),
+               CYAN_END);
+        printf("  %s%s%3d%s\n",
+               CYAN_BEGIN,
+               "Ignored:              ",
+               stats.GetIgnored(),
+               CYAN_END);
     }
 
     Statistic m_stats;
     }
 
     Statistic m_stats;
@@ -221,15 +246,13 @@ class ConsoleCollector
     std::string m_currentGroup;
 };
 
     std::string m_currentGroup;
 };
 
-
 TestResultsCollectorBase* ConsoleCollector::Constructor()
 {
     return new ConsoleCollector();
 }
 
 TestResultsCollectorBase* ConsoleCollector::Constructor()
 {
     return new ConsoleCollector();
 }
 
-
-class HtmlCollector
-    : public TestResultsCollectorBase
+class HtmlCollector :
+    public TestResultsCollectorBase
 {
   public:
     static TestResultsCollectorBase* Constructor();
 {
   public:
     static TestResultsCollectorBase* Constructor();
@@ -239,13 +262,13 @@ class HtmlCollector
 
     virtual void CollectCurrentTestGroupName(const std::string& name)
     {
 
     virtual void CollectCurrentTestGroupName(const std::string& name)
     {
-        fprintf(m_fp.Get(),"<b>Starting group %s", name.c_str());
+        fprintf(m_fp.Get(), "<b>Starting group %s", name.c_str());
         m_currentGroup = name;
     }
 
     virtual bool Configure()
     {
         m_currentGroup = name;
     }
 
     virtual bool Configure()
     {
-        m_fp.Reset(fopen (m_filename.c_str(), "w"));
+        m_fp.Reset(fopen(m_filename.c_str(), "w"));
         if (!m_fp) {
             LogPedantic("Could not open file " << m_filename << " for writing");
             return false;
         if (!m_fp) {
             LogPedantic("Could not open file " << m_filename << " for writing");
             return false;
@@ -290,13 +313,7 @@ class HtmlCollector
 
     virtual bool ParseCollectorSpecificArg(const std::string& arg)
     {
 
     virtual bool ParseCollectorSpecificArg(const std::string& arg)
     {
-        const std::string argname = "--file=";
-        if (0 == arg.find(argname)) {
-            m_filename = arg.substr(argname.size());
-            return true;
-        } else {
-            return false;
-        }
+        return ParseCollectorFileArg(arg, m_filename);
     }
 
     virtual void CollectResult(const std::string& id,
     }
 
     virtual void CollectResult(const std::string& id,
@@ -308,19 +325,21 @@ class HtmlCollector
         std::string tmp = "'" + id + "' ...";
 
         fprintf(m_fp.Get(), "Running test case %-100s", tmp.c_str());
         std::string tmp = "'" + id + "' ...";
 
         fprintf(m_fp.Get(), "Running test case %-100s", tmp.c_str());
-        switch(status) {
-            case TestResultsCollectorBase::FailStatus::NONE:
-                fprintf(m_fp.Get(), "[%s%s%s]\n", BOLD_GREEN_BEGIN, "   OK   ", BOLD_GREEN_END); break;
-            case TestResultsCollectorBase::FailStatus::FAILED:
-                PrintfErrorMessage(  " FAILED ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::IGNORED:
-                PrintfIgnoredMessage("Ignored ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::TODO:
-                PrintfTODOMessage(   "  TODO  ", reason, true); break;
-            case TestResultsCollectorBase::FailStatus::INTERNAL:
-                PrintfErrorMessage(  "INTERNAL", reason, true); break;
-            default:
-                Assert(false && "Bad status");
+        switch (status) {
+        case TestResultsCollectorBase::FailStatus::NONE:
+            fprintf(m_fp.Get(), GREEN_RESULT_OK);
+            break;
+        case TestResultsCollectorBase::FailStatus::FAILED:
+            PrintfErrorMessage(" FAILED ", reason, true);
+            break;
+        case TestResultsCollectorBase::FailStatus::IGNORED:
+            PrintfIgnoredMessage("Ignored ", reason, true);
+            break;
+        case TestResultsCollectorBase::FailStatus::INTERNAL:
+            PrintfErrorMessage("INTERNAL", reason, true);
+            break;
+        default:
+            Assert(false && "Bad status");
         }
         m_groupsStats[m_currentGroup].AddTest(status);
         m_stats.AddTest(status);
         }
         m_groupsStats[m_currentGroup].AddTest(status);
         m_stats.AddTest(status);
@@ -349,29 +368,6 @@ class HtmlCollector
         }
     }
 
         }
     }
 
-    void PrintfTODOMessage(const char* type,
-                           const std::string& message,
-                           bool verbosity)
-    {
-        using namespace DPL::Colors::Html;
-        if (verbosity) {
-            fprintf(m_fp.Get(),
-                    "[%s%s%s] %s%s%s\n",
-                    BOLD_WHITE_BEGIN,
-                    type,
-                    BOLD_WHITE_END,
-                    BOLD_GOLD_BEGIN,
-                    message.c_str(),
-                    BOLD_GOLD_END);
-        } else {
-            fprintf(m_fp.Get(),
-                    "[%s%s%s]\n",
-                    BOLD_WHITE_BEGIN,
-                    type,
-                    BOLD_WHITE_END);
-        }
-    }
-
     void PrintfIgnoredMessage(const char* type,
                               const std::string& message,
                               bool verbosity)
     void PrintfIgnoredMessage(const char* type,
                               const std::string& message,
                               bool verbosity)
@@ -390,7 +386,7 @@ class HtmlCollector
         } else {
             fprintf(m_fp.Get(),
                     "[%s%s%s]\n",
         } else {
             fprintf(m_fp.Get(),
                     "[%s%s%s]\n",
-                    CYAN_BEGIN ,
+                    CYAN_BEGIN,
                     type,
                     CYAN_END);
         }
                     type,
                     CYAN_END);
         }
@@ -399,14 +395,21 @@ class HtmlCollector
     void PrintStats(const std::string& name, const Statistic& stats)
     {
         using namespace DPL::Colors::Html;
     void PrintStats(const std::string& name, const Statistic& stats)
     {
         using namespace DPL::Colors::Html;
-        fprintf(m_fp.Get(), "\n%sResults [%s]:%s\n", BOLD_GREEN_BEGIN, name.c_str(), BOLD_GREEN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Total tests:            ", stats.GetTotal(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Succeeded or ignored:   ", stats.GetPassed() + stats.GetIgnored(), CYAN_END);
-        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,     "Succeeded:            ", stats.GetPassed(), CYAN_END);
-        fprintf(m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,     "Ignored:              ", stats.GetIgnored(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Failed:                 ", stats.GetFailed(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,     "Todo:                   ", stats.GetTODO(), CYAN_END);
-        fprintf(m_fp.Get(), "%s%s%3.0f%%%s\n", CYAN_BEGIN, "Succeeded or ignored %: ", stats.GetPassedOrIgnoredPercend(), CYAN_END);
+        fprintf(
+            m_fp.Get(), "\n%sResults [%s]:%s\n", BOLD_GREEN_BEGIN,
+            name.c_str(), BOLD_GREEN_END);
+        fprintf(
+            m_fp.Get(), "%s%s%3d%s\n", CYAN_BEGIN,
+            "Total tests:            ", stats.GetTotal(), CYAN_END);
+        fprintf(
+            m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,
+            "Succeeded:            ", stats.GetPassed(), CYAN_END);
+        fprintf(
+            m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,
+            "Failed:               ", stats.GetFailed(), CYAN_END);
+        fprintf(
+            m_fp.Get(), "  %s%s%3d%s\n", CYAN_BEGIN,
+            "Ignored:              ", stats.GetIgnored(), CYAN_END);
     }
 
     std::string m_filename;
     }
 
     std::string m_filename;
@@ -421,8 +424,336 @@ TestResultsCollectorBase* HtmlCollector::Constructor()
     return new HtmlCollector();
 }
 
     return new HtmlCollector();
 }
 
-class CSVCollector
-    : public TestResultsCollectorBase
+class XmlCollector :
+    public TestResultsCollectorBase
+{
+  public:
+    static TestResultsCollectorBase* Constructor();
+
+  private:
+    XmlCollector() : m_filename(DEFAULT_XML_FILE_NAME) {}
+
+    virtual void CollectCurrentTestGroupName(const std::string& name)
+    {
+        std::size_t pos = GetCurrentGroupPosition();
+        if (std::string::npos != pos) {
+            GroupFinish(pos);
+            FlushOutput();
+            m_stats = Statistic();
+        }
+
+        pos = m_outputBuffer.find("</testsuites>");
+        if (std::string::npos == pos) {
+            ThrowMsg(DPL::Exception, "Could not find test suites closing tag");
+        }
+        GroupStart(pos, name);
+    }
+
+    void GroupStart(const std::size_t pos, const std::string& name)
+    {
+        std::stringstream groupHeader;
+        groupHeader << "\n\t<testsuite";
+        groupHeader << " name=\"" << EscapeSpecialCharacters(name) << "\"";
+        groupHeader << R"( tests="1")"; // include SegFault
+        groupHeader << R"( failures="1")"; // include SegFault
+        groupHeader << R"( skipped="0")";
+        groupHeader << ">";
+
+        groupHeader << "\n\t\t<testcase name=\"unknown\" status=\"FAILED\">";
+        groupHeader <<
+        "\n\t\t\t<failure type=\"FAILED\" message=\"segmentation fault\"/>";
+        groupHeader << "\n\t\t</testcase>";
+
+        groupHeader << "\n\t</testsuite>";
+
+        m_outputBuffer.insert(pos - 1, groupHeader.str());
+    }
+
+    virtual bool Configure()
+    {
+        m_fp.Reset(fopen(m_filename.c_str(), "w"));
+        if (!m_fp) {
+            LogPedantic("Could not open file " << m_filename << " for writing");
+            return false;
+        }
+        return true;
+    }
+
+    virtual std::string CollectorSpecificHelp() const
+    {
+        return "--file=<filename> - name of file for output\n"
+               "                    default - results.xml\n";
+    }
+
+    virtual void Start()
+    {
+        Assert(!!m_fp && "File handle must not be null");
+        m_outputBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
+        m_outputBuffer.append("<testsuites>\n</testsuites>");
+        FlushOutput();
+    }
+
+    virtual void Finish()
+    {
+        std::size_t pos = GetCurrentGroupPosition();
+        if (std::string::npos != pos) {
+            GroupFinish(pos);
+            FlushOutput();
+        }
+    }
+
+    virtual bool ParseCollectorSpecificArg(const std::string& arg)
+    {
+        return ParseCollectorFileArg(arg, m_filename);
+    }
+
+    virtual void CollectResult(const std::string& id,
+                               const std::string& /*description*/,
+                               const FailStatus::Type status = FailStatus::NONE,
+                               const std::string& reason = "")
+    {
+        m_resultBuffer.erase();
+        m_resultBuffer.append("\t\t<testcase name=\"");
+        m_resultBuffer.append(EscapeSpecialCharacters(id));
+        m_resultBuffer.append("\"");
+        switch (status) {
+        case TestResultsCollectorBase::FailStatus::NONE:
+            m_resultBuffer.append(" status=\"OK\"/>\n");
+            break;
+        case TestResultsCollectorBase::FailStatus::FAILED:
+            m_resultBuffer.append(" status=\"FAILED\">\n");
+            PrintfErrorMessage("FAILED", EscapeSpecialCharacters(reason), true);
+            m_resultBuffer.append("\t\t</testcase>\n");
+            break;
+        case TestResultsCollectorBase::FailStatus::IGNORED:
+            m_resultBuffer.append(" status=\"Ignored\">\n");
+            PrintfIgnoredMessage("Ignored", EscapeSpecialCharacters(
+                                     reason), true);
+            m_resultBuffer.append("\t\t</testcase>\n");
+            break;
+        case TestResultsCollectorBase::FailStatus::INTERNAL:
+            m_resultBuffer.append(" status=\"FAILED\">\n");
+            PrintfErrorMessage("INTERNAL", EscapeSpecialCharacters(
+                                   reason), true);
+            m_resultBuffer.append("\t\t</testcase>");
+            break;
+        default:
+            Assert(false && "Bad status");
+        }
+        std::size_t group_pos = GetCurrentGroupPosition();
+        if (std::string::npos == group_pos) {
+            ThrowMsg(DPL::Exception, "No current group set");
+        }
+
+        std::size_t last_case_pos = m_outputBuffer.find(
+                "<testcase name=\"unknown\"",
+                group_pos);
+        if (std::string::npos == last_case_pos) {
+            ThrowMsg(DPL::Exception, "Could not find SegFault test case");
+        }
+        m_outputBuffer.insert(last_case_pos - 2, m_resultBuffer);
+
+        m_stats.AddTest(status);
+
+        UpdateGroupHeader(group_pos,
+                          m_stats.GetTotal() + 1, // include SegFault
+                          m_stats.GetFailed() + 1, // include SegFault
+                          m_stats.GetIgnored());
+        FlushOutput();
+    }
+
+    std::size_t GetCurrentGroupPosition() const
+    {
+        return m_outputBuffer.rfind("<testsuite ");
+    }
+
+    void UpdateGroupHeader(const std::size_t groupPosition,
+                           const unsigned int tests,
+                           const unsigned int failures,
+                           const unsigned int skipped)
+    {
+        UpdateElementAttribute(groupPosition, "tests", UIntToString(tests));
+        UpdateElementAttribute(groupPosition, "failures", UIntToString(failures));
+        UpdateElementAttribute(groupPosition, "skipped", UIntToString(skipped));
+    }
+
+    void UpdateElementAttribute(const std::size_t elementPosition,
+                                const std::string& name,
+                                const std::string& value)
+    {
+        std::string pattern = name + "=\"";
+
+        std::size_t start = m_outputBuffer.find(pattern, elementPosition);
+        if (std::string::npos == start) {
+            ThrowMsg(DPL::Exception,
+                     "Could not find attribute " << name << " beginning");
+        }
+
+        std::size_t end = m_outputBuffer.find("\"", start + pattern.length());
+        if (std::string::npos == end) {
+            ThrowMsg(DPL::Exception,
+                     "Could not find attribute " << name << " end");
+        }
+
+        m_outputBuffer.replace(start + pattern.length(),
+                               end - start - pattern.length(),
+                               value);
+    }
+
+    std::string UIntToString(const unsigned int value)
+    {
+        std::stringstream result;
+        result << value;
+        return result.str();
+    }
+
+    void GroupFinish(const std::size_t groupPosition)
+    {
+        std::size_t segFaultStart =
+            m_outputBuffer.find("<testcase name=\"unknown\"", groupPosition);
+        if (std::string::npos == segFaultStart) {
+            ThrowMsg(DPL::Exception,
+                     "Could not find SegFault test case start position");
+        }
+        segFaultStart -= 2; // to erase tabs
+
+        std::string closeTag = "</testcase>";
+        std::size_t segFaultEnd = m_outputBuffer.find(closeTag, segFaultStart);
+        if (std::string::npos == segFaultEnd) {
+            ThrowMsg(DPL::Exception,
+                     "Could not find SegFault test case end position");
+        }
+        segFaultEnd += closeTag.length() + 1; // to erase new line
+
+        m_outputBuffer.erase(segFaultStart, segFaultEnd - segFaultStart);
+
+        UpdateGroupHeader(groupPosition,
+                          m_stats.GetTotal(),
+                          m_stats.GetFailed(),
+                          m_stats.GetIgnored());
+    }
+
+    void FlushOutput()
+    {
+        int fd = fileno(m_fp.Get());
+        if (-1 == fd) {
+            int error = errno;
+            ThrowMsg(DPL::Exception, DPL::GetErrnoString(error));
+        }
+
+        if (-1 == TEMP_FAILURE_RETRY(ftruncate(fd, 0L))) {
+            int error = errno;
+            ThrowMsg(DPL::Exception, DPL::GetErrnoString(error));
+        }
+
+        if (-1 == TEMP_FAILURE_RETRY(fseek(m_fp.Get(), 0L, SEEK_SET))) {
+            int error = errno;
+            ThrowMsg(DPL::Exception, DPL::GetErrnoString(error));
+        }
+
+        if (m_outputBuffer.size() !=
+            fwrite(m_outputBuffer.c_str(), 1, m_outputBuffer.size(),
+                   m_fp.Get()))
+        {
+            int error = errno;
+            ThrowMsg(DPL::Exception, DPL::GetErrnoString(error));
+        }
+
+        if (-1 == TEMP_FAILURE_RETRY(fflush(m_fp.Get()))) {
+            int error = errno;
+            ThrowMsg(DPL::Exception, DPL::GetErrnoString(error));
+        }
+    }
+
+    void PrintfErrorMessage(const char* type,
+                            const std::string& message,
+                            bool verbosity)
+    {
+        if (verbosity) {
+            m_resultBuffer.append("\t\t\t<failure type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\" message=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(message));
+            m_resultBuffer.append("\"/>\n");
+        } else {
+            m_resultBuffer.append("\t\t\t<failure type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\"/>\n");
+        }
+    }
+
+    void PrintfIgnoredMessage(const char* type,
+                              const std::string& message,
+                              bool verbosity)
+    {
+        if (verbosity) {
+            m_resultBuffer.append("\t\t\t<skipped type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\" message=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(message));
+            m_resultBuffer.append("\"/>\n");
+        } else {
+            m_resultBuffer.append("\t\t\t<skipped type=\"");
+            m_resultBuffer.append(EscapeSpecialCharacters(type));
+            m_resultBuffer.append("\"/>\n");
+        }
+    }
+
+    std::string EscapeSpecialCharacters(std::string s)
+    {
+        for (unsigned int i = 0; i < s.size();) {
+            switch (s[i]) {
+            case '"':
+                s.erase(i, 1);
+                s.insert(i, "&quot;");
+                i += 6;
+                break;
+
+            case '&':
+                s.erase(i, 1);
+                s.insert(i, "&amp;");
+                i += 5;
+                break;
+
+            case '<':
+                s.erase(i, 1);
+                s.insert(i, "&lt;");
+                i += 4;
+                break;
+
+            case '>':
+                s.erase(i, 1);
+                s.insert(i, "&gt;");
+                i += 4;
+                break;
+
+            case '\'':
+                s.erase(i, 1);
+                s.insert(i, "&#39;");
+                i += 5;
+                break;
+            default:
+                ++i;
+                break;
+            }
+        }
+        return s;
+    }
+
+    std::string m_filename;
+    ScopedFClose m_fp;
+    Statistic m_stats;
+    std::string m_outputBuffer;
+    std::string m_resultBuffer;
+};
+
+TestResultsCollectorBase* XmlCollector::Constructor()
+{
+    return new XmlCollector();
+}
+
+class CSVCollector :
+    public TestResultsCollectorBase
 {
   public:
     static TestResultsCollectorBase* Constructor();
 {
   public:
     static TestResultsCollectorBase* Constructor();
@@ -430,7 +761,8 @@ class CSVCollector
   private:
     CSVCollector() {}
 
   private:
     CSVCollector() {}
 
-    virtual void Start() {
+    virtual void Start()
+    {
         printf("GROUP;ID;RESULT;REASON\n");
     }
 
         printf("GROUP;ID;RESULT;REASON\n");
     }
 
@@ -445,14 +777,19 @@ class CSVCollector
                                const std::string& reason = "")
     {
         std::string statusMsg = "";
                                const std::string& reason = "")
     {
         std::string statusMsg = "";
-        switch(status) {
-            case TestResultsCollectorBase::FailStatus::NONE: statusMsg = "OK"; break;
-            case TestResultsCollectorBase::FailStatus::FAILED: statusMsg = "FAILED"; break;
-            case TestResultsCollectorBase::FailStatus::IGNORED: statusMsg = "IGNORED"; break;
-            case TestResultsCollectorBase::FailStatus::TODO:  statusMsg = "TODO"; break;
-            case TestResultsCollectorBase::FailStatus::INTERNAL: statusMsg = "FAILED"; break;
-            default:
-                Assert(false && "Bad status");
+        switch (status) {
+        case TestResultsCollectorBase::FailStatus::NONE: statusMsg = "OK";
+            break;
+        case TestResultsCollectorBase::FailStatus::FAILED: statusMsg = "FAILED";
+            break;
+        case TestResultsCollectorBase::FailStatus::IGNORED: statusMsg =
+            "IGNORED";
+            break;
+        case TestResultsCollectorBase::FailStatus::INTERNAL: statusMsg =
+            "FAILED";
+            break;
+        default:
+            Assert(false && "Bad status");
         }
         printf("%s;%s;%s;%s\n",
                m_currentGroup.c_str(),
         }
         printf("%s;%s;%s;%s\n",
                m_currentGroup.c_str(),
@@ -464,12 +801,115 @@ class CSVCollector
     std::string m_currentGroup;
 };
 
     std::string m_currentGroup;
 };
 
-
 TestResultsCollectorBase* CSVCollector::Constructor()
 {
     return new CSVCollector();
 }
 TestResultsCollectorBase* CSVCollector::Constructor()
 {
     return new CSVCollector();
 }
+}
+
+class TAPCollector :
+    public TestResultsCollectorBase
+{
+  public:
+    static TestResultsCollectorBase* Constructor();
+
+  private:
+    TAPCollector() : m_filename(DEFAULT_TAP_FILE_NAME)  {}
 
 
+    virtual bool Configure()
+    {
+        m_output.open(m_filename.c_str(), std::ios_base::trunc);
+        if (m_output.fail()) {
+            LogError("Can't open output file: " << m_filename);
+            return false;
+        }
+        return true;
+    }
+    virtual std::string CollectorSpecificHelp() const
+    {
+        std::string retVal = "--file=<filename> - name of file for output\n"
+                             "                    default - ";
+        retVal += DEFAULT_TAP_FILE_NAME;
+        retVal += "\n";
+        return retVal;
+    }
+
+    virtual void Start()
+    {
+        Assert(m_output.good() && "Output file must be opened.");
+        m_output << "TAP version 13" << std::endl;
+        m_testIndex = 0;
+    }
+
+    virtual void Finish()
+    {
+        m_output << "1.." << m_testIndex << std::endl;
+        m_output << m_collectedData.rdbuf();
+        m_output.close();
+    }
+
+    virtual bool ParseCollectorSpecificArg(const std::string& arg)
+    {
+        return ParseCollectorFileArg(arg, m_filename);
+    }
+
+    virtual void CollectResult(const std::string& id,
+                               const std::string& description,
+                               const FailStatus::Type status = FailStatus::NONE,
+                               const std::string& reason = "")
+    {
+        m_testIndex++;
+        switch (status) {
+        case TestResultsCollectorBase::FailStatus::NONE:
+            LogBasicTAP(true, id, description);
+            endTAPLine();
+            break;
+        case TestResultsCollectorBase::FailStatus::FAILED:
+            LogBasicTAP(false, id, description);
+            endTAPLine();
+            break;
+        case TestResultsCollectorBase::FailStatus::IGNORED:
+            LogBasicTAP(true, id, description);
+            m_collectedData << " # skip " << reason;
+            endTAPLine();
+            break;
+        case TestResultsCollectorBase::FailStatus::INTERNAL:
+            LogBasicTAP(true, id, description);
+            endTAPLine();
+            m_collectedData << "    ---" << std::endl;
+            m_collectedData << "    message: " << reason << std::endl;
+            m_collectedData << "    severity: Internal" << std::endl;
+            m_collectedData << "    ..." << std::endl;
+            break;
+        default:
+            Assert(false && "Bad status");
+        }
+    }
+
+    void LogBasicTAP(bool isOK, const std::string& id,
+                     const std::string& description)
+    {
+        if (!isOK) {
+            m_collectedData << "not ";
+        }
+        m_collectedData << "ok " << m_testIndex << " [" <<
+        id << "] " << description;
+    }
+
+    void endTAPLine()
+    {
+        m_collectedData << std::endl;
+    }
+
+    std::string m_filename;
+    std::stringstream m_collectedData;
+    std::ofstream m_output;
+    int m_testIndex;
+};
+
+TestResultsCollectorBase* TAPCollector::Constructor()
+{
+    return new TAPCollector();
 }
 
 void TestResultsCollectorBase::RegisterCollectorConstructor(
 }
 
 void TestResultsCollectorBase::RegisterCollectorConstructor(
@@ -484,10 +924,11 @@ TestResultsCollectorBase* TestResultsCollectorBase::Create(
     const std::string& name)
 {
     ConstructorsMap::iterator found = m_constructorsMap.find(name);
     const std::string& name)
 {
     ConstructorsMap::iterator found = m_constructorsMap.find(name);
-    if (found != m_constructorsMap.end())
+    if (found != m_constructorsMap.end()) {
         return found->second();
         return found->second();
-    else
+    } else {
         return NULL;
         return NULL;
+    }
 }
 
 std::vector<std::string> TestResultsCollectorBase::GetCollectorsNames()
 }
 
 std::vector<std::string> TestResultsCollectorBase::GetCollectorsNames()
@@ -500,10 +941,10 @@ std::vector<std::string> TestResultsCollectorBase::GetCollectorsNames()
     return list;
 }
 
     return list;
 }
 
-TestResultsCollectorBase::ConstructorsMap TestResultsCollectorBase::m_constructorsMap;
+TestResultsCollectorBase::ConstructorsMap TestResultsCollectorBase::
+    m_constructorsMap;
 
 
-namespace
-{
+namespace {
 static int RegisterCollectorConstructors();
 static const int RegisterHelperVariable = RegisterCollectorConstructors();
 int RegisterCollectorConstructors()
 static int RegisterCollectorConstructors();
 static const int RegisterHelperVariable = RegisterCollectorConstructors();
 int RegisterCollectorConstructors()
@@ -519,11 +960,16 @@ int RegisterCollectorConstructors()
     TestResultsCollectorBase::RegisterCollectorConstructor(
         "csv",
         &CSVCollector::Constructor);
     TestResultsCollectorBase::RegisterCollectorConstructor(
         "csv",
         &CSVCollector::Constructor);
+    TestResultsCollectorBase::RegisterCollectorConstructor(
+        "tap",
+        &TAPCollector::Constructor);
+    TestResultsCollectorBase::RegisterCollectorConstructor(
+        "xml",
+        &XmlCollector::Constructor);
 
     return 0;
 }
 
     return 0;
 }
-
 }
 }
-
 }
 }
 }
 }
+#undef GREEN_RESULT_OK
index 8097c23..126f1b0 100644 (file)
@@ -20,6 +20,7 @@
  * @version     1.0
  * @brief       This file is the implementation file of test runner
  */
  * @version     1.0
  * @brief       This file is the implementation file of test runner
  */
+#include <stddef.h>
 #include <dpl/test/test_runner.h>
 #include <dpl/test/test_results_collector.h>
 #include <dpl/exception.h>
 #include <dpl/test/test_runner.h>
 #include <dpl/test/test_results_collector.h>
 #include <dpl/exception.h>
 #include <memory.h>
 #include <libgen.h>
 #include <cstring>
 #include <memory.h>
 #include <libgen.h>
 #include <cstring>
+#include <cstdlib>
+#include <dpl/utils/wrt_global_settings.h>
 
 #include <dpl/singleton_impl.h>
 IMPLEMENT_SINGLETON(DPL::Test::TestRunner)
 
 
 #include <dpl/singleton_impl.h>
 IMPLEMENT_SINGLETON(DPL::Test::TestRunner)
 
-namespace DPL
-{
-namespace Test
-{
-
+namespace DPL {
+namespace Test {
 namespace // anonymous
 {
 namespace // anonymous
 {
-
 std::string BaseName(std::string aPath)
 {
     ScopedFree<char> path(strdup(aPath.c_str()));
 std::string BaseName(std::string aPath)
 {
     ScopedFree<char> path(strdup(aPath.c_str()));
-    if (NULL == path.Get())
-    {
-       throw std::bad_alloc();
+    if (NULL == path.Get()) {
+        throw std::bad_alloc();
     }
     char* baseName = basename(path.Get());
     std::string retValue = baseName;
     return retValue;
 }
     }
     char* baseName = basename(path.Get());
     std::string retValue = baseName;
     return retValue;
 }
-
 } // namespace anonymous
 
 //! \brief Failed test message creator
 } // namespace anonymous
 
 //! \brief Failed test message creator
@@ -77,6 +74,11 @@ TestRunner::TestFailed::TestFailed(const char* aTest,
     m_message = assertMsg.str();
 }
 
     m_message = assertMsg.str();
 }
 
+TestRunner::TestFailed::TestFailed(const std::string &message)
+{
+    m_message = message;
+}
+
 void TestRunner::RegisterTest(const char *testName, TestCase proc)
 {
     m_testGroups[m_currentGroup].push_back(TestCaseStruct(testName, proc));
 void TestRunner::RegisterTest(const char *testName, TestCase proc)
 {
     m_testGroups[m_currentGroup].push_back(TestCaseStruct(testName, proc));
@@ -87,77 +89,57 @@ void TestRunner::InitGroup(const char* name)
     m_currentGroup = name;
 }
 
     m_currentGroup = name;
 }
 
-
 TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
 {
 TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
 {
-    try
-    {
+    try {
         testCase.proc();
         testCase.proc();
-    }
-    catch (const TestFailed &e)
-    {
+    } catch (const TestFailed &e) {
         // Simple test failure
         // Simple test failure
-        m_collector->CollectResult(testCase.name,
-                                   "",
-                                   TestResultsCollectorBase::FailStatus::FAILED,
-                                   e.GetMessage());
+        CollectResult(testCase.name,
+                      "",
+                      TestResultsCollectorBase::FailStatus::FAILED,
+                      e.GetMessage());
         return FAILED;
         return FAILED;
-    }
-    catch (const Ignored &e)
-    {
-        // Simple test have to be implemented
-        m_collector->CollectResult(testCase.name,
-                                   "",
-                                   TestResultsCollectorBase::FailStatus::IGNORED,
-                                   e.GetMessage());
+    } catch (const Ignored &e) {
+        if (m_runIgnored) {
+            // Simple test have to be implemented
+            CollectResult(testCase.name,
+                          "",
+                          TestResultsCollectorBase::FailStatus::IGNORED,
+                          e.GetMessage());
+        }
 
         return IGNORED;
 
         return IGNORED;
-    }
-    catch (const ToDo &e)
-    {
-        // Simple test have to be implemented
-        m_collector->CollectResult(testCase.name,
-                                   "",
-                                   TestResultsCollectorBase::FailStatus::TODO,
-                                   e.GetMessage());
-
-        return TODO;
-    }
-    catch (const DPL::Exception &e)
-    {
+    } catch (const DPL::Exception &e) {
         // DPL exception failure
         // DPL exception failure
-        m_collector->CollectResult(testCase.name,
-                                   "",
-                                   TestResultsCollectorBase::FailStatus::INTERNAL,
-                                   "DPL exception:" +
-                                   e.GetMessage());
+        CollectResult(testCase.name,
+                      "",
+                      TestResultsCollectorBase::FailStatus::INTERNAL,
+                      "DPL exception:" + e.GetMessage());
 
         return FAILED;
 
         return FAILED;
-    }
-    catch (const std::exception &)
-    {
+    } catch (const std::exception &) {
         // std exception failure
         // std exception failure
-        m_collector->CollectResult(testCase.name,
-                                   "",
-                                   TestResultsCollectorBase::FailStatus::INTERNAL,
-                                   "std exception");
+        CollectResult(testCase.name,
+                      "",
+                      TestResultsCollectorBase::FailStatus::INTERNAL,
+                      "std exception");
 
         return FAILED;
 
         return FAILED;
-    }
-    catch (...)
-    {
+    } catch (...) {
         // Unknown exception failure
         // Unknown exception failure
-        m_collector->CollectResult(testCase.name,
-                                   "",
-                                   TestResultsCollectorBase::FailStatus::INTERNAL,
-                                   "unknown exception");
+        CollectResult(testCase.name,
+                      "",
+                      TestResultsCollectorBase::FailStatus::INTERNAL,
+                      "unknown exception");
 
         return FAILED;
     }
 
 
         return FAILED;
     }
 
-    m_collector->CollectResult(testCase.name,
-                               "",
-                               TestResultsCollectorBase::FailStatus::NONE);
+    CollectResult(testCase.name,
+                  "",
+                  TestResultsCollectorBase::FailStatus::NONE);
+
     // Everything OK
     return PASS;
 }
     // Everything OK
     return PASS;
 }
@@ -167,13 +149,25 @@ void TestRunner::RunTests()
     using namespace DPL::Colors::Text;
 
     Banner();
     using namespace DPL::Colors::Text;
 
     Banner();
-    m_collector->Start();
+    std::for_each(m_collectors.begin(),
+                  m_collectors.end(),
+                  [] (const TestResultsCollectors::value_type & collector)
+                  {
+                      collector.second->Start();
+                  });
 
     fprintf(stderr, "%s%s%s\n", GREEN_BEGIN, "Running tests...", GREEN_END);
     FOREACH(group, m_testGroups) {
         TestCaseStructList list = group->second;
         if (!list.empty()) {
 
     fprintf(stderr, "%s%s%s\n", GREEN_BEGIN, "Running tests...", GREEN_END);
     FOREACH(group, m_testGroups) {
         TestCaseStructList list = group->second;
         if (!list.empty()) {
-            m_collector->CollectCurrentTestGroupName(group->first);
+            std::for_each(
+                m_collectors.begin(),
+                m_collectors.end(),
+                [&group](const TestResultsCollectors::value_type & collector)
+                {
+                    collector.second->
+                        CollectCurrentTestGroupName(group->first);
+                });
             list.sort();
 
             for (TestCaseStructList::const_iterator iterator = list.begin();
             list.sort();
 
             for (TestCaseStructList::const_iterator iterator = list.begin();
@@ -181,21 +175,49 @@ void TestRunner::RunTests()
                  ++iterator)
             {
                 TestCaseStruct test = *iterator;
                  ++iterator)
             {
                 TestCaseStruct test = *iterator;
-                if (m_startTestId == test.name)
+                if (m_startTestId == test.name) {
                     m_startTestId = "";
                     m_startTestId = "";
+                }
 
                 if (m_startTestId.empty()) {
                     RunTestCase(test);
                 }
 
                 if (m_startTestId.empty()) {
                     RunTestCase(test);
                 }
+                if (m_terminate == true) {
+                    // Terminate quietly without any logs
+                    return;
+                }
             }
         }
     }
 
             }
         }
     }
 
-    m_collector->Finish();
+    std::for_each(m_collectors.begin(),
+                  m_collectors.end(),
+                  [] (const TestResultsCollectors::value_type & collector)
+                  {
+                      collector.second->Finish();
+                  });
+
     // Finished
     fprintf(stderr, "%s%s%s\n\n", GREEN_BEGIN, "Finished", GREEN_END);
 }
 
     // Finished
     fprintf(stderr, "%s%s%s\n\n", GREEN_BEGIN, "Finished", GREEN_END);
 }
 
+void TestRunner::CollectResult(
+    const std::string& id,
+    const std::string& description,
+    const TestResultsCollectorBase::FailStatus::Type status,
+    const std::string& reason)
+{
+    std::for_each(m_collectors.begin(),
+                  m_collectors.end(),
+                  [&](const TestResultsCollectors::value_type & collector)
+                  {
+                      collector.second->CollectResult(id,
+                                                      description,
+                                                      status,
+                                                      reason);
+                  });
+}
+
 void TestRunner::Banner()
 {
     using namespace DPL::Colors::Text;
 void TestRunner::Banner()
 {
     using namespace DPL::Colors::Text;
@@ -212,13 +234,13 @@ void TestRunner::Banner()
             GREEN_END);
 }
 
             GREEN_END);
 }
 
-void TestRunner::InvalidArgs()
+void TestRunner::InvalidArgs(const std::string& message)
 {
     using namespace DPL::Colors::Text;
     fprintf(stderr,
             "%s%s%s\n",
             BOLD_RED_BEGIN,
 {
     using namespace DPL::Colors::Text;
     fprintf(stderr,
             "%s%s%s\n",
             BOLD_RED_BEGIN,
-            "Invalid parameters!",
+            message.c_str(),
             BOLD_RED_END);
 }
 
             BOLD_RED_END);
 }
 
@@ -226,25 +248,42 @@ void TestRunner::Usage()
 {
     fprintf(stderr, "Usage: runner [options]\n\n");
     fprintf(stderr, "Output type:\n");
 {
     fprintf(stderr, "Usage: runner [options]\n\n");
     fprintf(stderr, "Output type:\n");
-    fprintf(stderr, "  --output=<output type>\n");
-    fprintf(stderr, "  possible output types:\n");
-    FOREACH (type, TestResultsCollectorBase::GetCollectorsNames()) {
-        fprintf(stderr, "  --output=%s\n", type->c_str());
+    fprintf(stderr, "  --output=<output type> --output=<output type> ...\n");
+    fprintf(stderr, "\n  possible output types:\n");
+    FOREACH(type, TestResultsCollectorBase::GetCollectorsNames()) {
+        fprintf(stderr, "    --output=%s\n", type->c_str());
     }
     }
+    fprintf(stderr, "\n  example:\n");
+    fprintf(stderr,
+            "    test-binary --output=text --output=xml --file=output.xml\n\n");
     fprintf(stderr, "Other parameters:\n");
     fprintf(stderr,
             "  --regexp='regexp'\t Only selected tests"
             " which names match regexp run\n\n");
     fprintf(stderr, "  --start=<test id>\tStart from concrete test id");
     fprintf(stderr, "  --group=<group name>\t Run tests only from one group\n");
     fprintf(stderr, "Other parameters:\n");
     fprintf(stderr,
             "  --regexp='regexp'\t Only selected tests"
             " which names match regexp run\n\n");
     fprintf(stderr, "  --start=<test id>\tStart from concrete test id");
     fprintf(stderr, "  --group=<group name>\t Run tests only from one group\n");
+    fprintf(stderr, "  --runignored\t Run also ignored tests\n");
     fprintf(stderr, "  --list\t Show a list of Test IDs\n");
     fprintf(stderr, "  --listgroups\t Show a list of Test Group names \n");
     fprintf(stderr, "  --list\t Show a list of Test IDs\n");
     fprintf(stderr, "  --listgroups\t Show a list of Test Group names \n");
-    fprintf(stderr, "  --listingroup=<group name>\t Show a list of Test IDS in one group\n");
+    fprintf(
+        stderr,
+        "  --listingroup=<group name>\t Show a list of Test IDS in one group\n");
+    fprintf(stderr, "  --allowchildlogs\t Allow to print logs from child process on screen.\n");
+    fprintf(stderr, "       When active child process will be able to print logs on stdout and stderr.\n");
+    fprintf(stderr, "       Both descriptors will be closed after test.\n");
     fprintf(stderr, "  --help\t This help\n\n");
     fprintf(stderr, "  --help\t This help\n\n");
-    if (m_collector) {
-        fprintf(stderr, "Output %s has specific args:\n", m_collectorName.c_str());
-        fprintf(stderr, "%s\n", m_collector->CollectorSpecificHelp().c_str());
-    }
+    std::for_each(m_collectors.begin(),
+                  m_collectors.end(),
+                  [] (const TestResultsCollectors::value_type & collector)
+                  {
+                      fprintf(stderr,
+                              "Output %s has specific args:\n",
+                              collector.first.c_str());
+                      fprintf(stderr,
+                              "%s\n",
+                              collector.second->
+                                  CollectorSpecificHelp().c_str());
+                  });
     fprintf(stderr, "For bug reporting, please write to:\n");
     fprintf(stderr, "<p.dobrowolsk@samsung.com>\n");
 }
     fprintf(stderr, "For bug reporting, please write to:\n");
     fprintf(stderr, "<p.dobrowolsk@samsung.com>\n");
 }
@@ -252,8 +291,7 @@ void TestRunner::Usage()
 int TestRunner::ExecTestRunner(int argc, char *argv[])
 {
     std::vector<std::string> args;
 int TestRunner::ExecTestRunner(int argc, char *argv[])
 {
     std::vector<std::string> args;
-    for (int i = 0; i < argc; ++i)
-    {
+    for (int i = 0; i < argc; ++i) {
         args.push_back(argv[i]);
     }
     return ExecTestRunner(args);
         args.push_back(argv[i]);
     }
     return ExecTestRunner(args);
@@ -266,10 +304,10 @@ void TestRunner::MarkAssertion()
 
 int TestRunner::ExecTestRunner(const ArgsList& value)
 {
 
 int TestRunner::ExecTestRunner(const ArgsList& value)
 {
+    m_runIgnored = false;
     ArgsList args = value;
     // Parse command line
     ArgsList args = value;
     // Parse command line
-    if (args.size() == 1)
-    {
+    if (args.size() == 1) {
         InvalidArgs();
         Usage();
         return -1;
         InvalidArgs();
         Usage();
         return -1;
@@ -279,6 +317,8 @@ int TestRunner::ExecTestRunner(const ArgsList& value)
 
     bool showHelp = false;
 
 
     bool showHelp = false;
 
+    TestResultsCollectorBasePtr currentCollector;
+
     // Parse each argument
     FOREACH(it, args)
     {
     // Parse each argument
     FOREACH(it, args)
     {
@@ -286,14 +326,20 @@ int TestRunner::ExecTestRunner(const ArgsList& value)
         const std::string regexp = "--regexp=";
         const std::string output = "--output=";
         const std::string groupId = "--group=";
         const std::string regexp = "--regexp=";
         const std::string output = "--output=";
         const std::string groupId = "--group=";
+        const std::string runIgnored = "--runignored";
         const std::string listCmd = "--list";
         const std::string startCmd = "--start=";
         const std::string listGroupsCmd = "--listgroups";
         const std::string listInGroup = "--listingroup=";
         const std::string listCmd = "--list";
         const std::string startCmd = "--start=";
         const std::string listGroupsCmd = "--listgroups";
         const std::string listInGroup = "--listingroup=";
+        const std::string allowChildLogs = "--allowchildlogs";
 
 
-        if (m_collector && m_collector->ParseCollectorSpecificArg(arg)) continue;
-        else if (arg.find(startCmd) == 0)
-        {
+        if (currentCollector) {
+            if (currentCollector->ParseCollectorSpecificArg(arg)) {
+                continue;
+            }
+        }
+
+        if (arg.find(startCmd) == 0) {
             arg.erase(0, startCmd.length());
             FOREACH(group, m_testGroups) {
                 FOREACH(tc, group->second) {
             arg.erase(0, startCmd.length());
             FOREACH(group, m_testGroups) {
                 FOREACH(tc, group->second) {
@@ -302,16 +348,18 @@ int TestRunner::ExecTestRunner(const ArgsList& value)
                         break;
                     }
                 }
                         break;
                     }
                 }
-                if (!m_startTestId.empty()) break;
+                if (!m_startTestId.empty()) {
+                    break;
+                }
+            }
+            if (!m_startTestId.empty()) {
+                continue;
             }
             }
-            if (!m_startTestId.empty()) continue;
             InvalidArgs();
             fprintf(stderr, "Start test id has not been found\n");
             Usage();
             return 0;
             InvalidArgs();
             fprintf(stderr, "Start test id has not been found\n");
             Usage();
             return 0;
-        }
-        else if (arg.find(groupId) == 0)
-        {
+        } else if (arg.find(groupId) == 0) {
             arg.erase(0, groupId.length());
             TestCaseGroupMap::iterator found = m_testGroups.find(arg);
             if (found != m_testGroups.end()) {
             arg.erase(0, groupId.length());
             TestCaseGroupMap::iterator found = m_testGroups.find(arg);
             if (found != m_testGroups.end()) {
@@ -325,63 +373,60 @@ int TestRunner::ExecTestRunner(const ArgsList& value)
                 Usage();
                 return -1;
             }
                 Usage();
                 return -1;
             }
-        }
-        else if (arg == listCmd)
-        {
+        } else if (arg == runIgnored) {
+            m_runIgnored = true;
+        } else if (arg == listCmd) {
             FOREACH(group, m_testGroups) {
                 FOREACH(test, group->second) {
                     printf("ID:%s:%s\n", group->first.c_str(), test->name.c_str());
                 }
             }
             return 0;
             FOREACH(group, m_testGroups) {
                 FOREACH(test, group->second) {
                     printf("ID:%s:%s\n", group->first.c_str(), test->name.c_str());
                 }
             }
             return 0;
-        }
-        else if (arg == listGroupsCmd)
-        {
+        } else if (arg == listGroupsCmd) {
             FOREACH(group, m_testGroups) {
                 printf("GR:%s\n", group->first.c_str());
             }
             return 0;
             FOREACH(group, m_testGroups) {
                 printf("GR:%s\n", group->first.c_str());
             }
             return 0;
-        }
-        else if (arg.find(listInGroup) == 0)
-        {
+        } else if (arg.find(listInGroup) == 0) {
             arg.erase(0, listInGroup.length());
             FOREACH(test, m_testGroups[arg]) {
                 printf("ID:%s\n", test->name.c_str());
             }
             return 0;
             arg.erase(0, listInGroup.length());
             FOREACH(test, m_testGroups[arg]) {
                 printf("ID:%s\n", test->name.c_str());
             }
             return 0;
-        }
-        else if (arg == "--help")
+        } else if (arg.find(allowChildLogs) == 0) {
+            arg.erase(0, allowChildLogs.length());
+            m_allowChildLogs = true;
+        } else if (arg == "--help") {
             showHelp = true;
             showHelp = true;
-        else if (arg.find(output) == 0)
-        {
+        } else if (arg.find(output) == 0) {
             arg.erase(0, output.length());
             arg.erase(0, output.length());
-            m_collector.Reset(TestResultsCollectorBase::Create(arg));
-            if (!m_collector) {
-                InvalidArgs();
+            if (m_collectors.find(arg) != m_collectors.end()) {
+                InvalidArgs(
+                    "Multiple outputs of the same type are not supported!");
                 Usage();
                 return -1;
                 Usage();
                 return -1;
-            } else {
-                m_collectorName = arg;
             }
             }
-        }
-        else if (arg.find(regexp) == 0)
-        {
+            currentCollector.reset(TestResultsCollectorBase::Create(arg));
+            if (!currentCollector) {
+                InvalidArgs("Unsupported output type!");
+                Usage();
+                return -1;
+            }
+            m_collectors[arg] = currentCollector;
+        } else if (arg.find(regexp) == 0) {
             arg.erase(0, regexp.length());
             arg.erase(0, regexp.length());
-            if (arg.length() == 0)
-            {
+            if (arg.length() == 0) {
                 InvalidArgs();
                 Usage();
                 return -1;
             }
 
                 InvalidArgs();
                 Usage();
                 return -1;
             }
 
-            if (arg[0] == '\'' && arg[arg.length() - 1] == '\'')
-            {
+            if (arg[0] == '\'' && arg[arg.length() - 1] == '\'') {
                 arg.erase(0);
                 arg.erase(arg.length() - 1);
             }
 
                 arg.erase(0);
                 arg.erase(arg.length() - 1);
             }
 
-            if (arg.length() == 0)
-            {
+            if (arg.length() == 0) {
                 InvalidArgs();
                 Usage();
                 return -1;
                 InvalidArgs();
                 Usage();
                 return -1;
@@ -392,35 +437,38 @@ int TestRunner::ExecTestRunner(const ArgsList& value)
                 TestCaseStructList newList;
                 FOREACH(iterator, group->second)
                 {
                 TestCaseStructList newList;
                 FOREACH(iterator, group->second)
                 {
-                    if (re.PartialMatch(iterator->name))
-                    {
+                    if (re.PartialMatch(iterator->name)) {
                         newList.push_back(*iterator);
                     }
                 }
                 group->second = newList;
             }
                         newList.push_back(*iterator);
                     }
                 }
                 group->second = newList;
             }
-        }
-        else
-        {
+        } else {
             InvalidArgs();
             Usage();
             return -1;
         }
     }
 
             InvalidArgs();
             Usage();
             return -1;
         }
     }
 
+    currentCollector.reset();
+
     // Show help
     // Show help
-    if (showHelp)
-    {
+    if (showHelp) {
         Usage();
         return 0;
     }
 
         Usage();
         return 0;
     }
 
-    if (!m_collector)
-        m_collector.Reset(TestResultsCollectorBase::Create("text"));
+    if (m_collectors.empty()) {
+        TestResultsCollectorBasePtr collector(
+            TestResultsCollectorBase::Create("text"));
+        m_collectors["text"] = collector;
+    }
 
 
-    if (!m_collector->Configure()) {
-        fprintf(stderr, "Could not configure selected output");
-        return 0;
+    for (auto it = m_collectors.begin(); it != m_collectors.end(); ++it) {
+        if (!it->second->Configure()) {
+            fprintf(stderr, "Could not configure selected output");
+            return 0;
+        }
     }
 
     // Run tests
     }
 
     // Run tests
@@ -429,5 +477,20 @@ int TestRunner::ExecTestRunner(const ArgsList& value)
     return 0;
 }
 
     return 0;
 }
 
+bool TestRunner::getRunIgnored() const
+{
+    return m_runIgnored;
+}
+
+void TestRunner::Terminate()
+{
+    m_terminate = true;
+}
+
+bool TestRunner::GetAllowChildLogs()
+{
+    return m_allowChildLogs;
+}
+
 }
 } // namespace DPL
 }
 } // namespace DPL
diff --git a/modules/test/src/test_runner_child.cpp b/modules/test/src/test_runner_child.cpp
new file mode 100644 (file)
index 0000000..bf773c6
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_runner_child.cpp
+ * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test runner
+ */
+#include <stddef.h>
+#include <dpl/test/test_runner.h>
+#include <dpl/test/test_runner_child.h>
+#include <dpl/test/test_results_collector.h>
+#include <dpl/binary_queue.h>
+#include <dpl/exception.h>
+#include <dpl/scoped_free.h>
+#include <dpl/foreach.h>
+#include <dpl/colors.h>
+#include <pcrecpp.h>
+#include <algorithm>
+#include <cstdio>
+#include <memory.h>
+#include <libgen.h>
+#include <cstring>
+#include <cstdlib>
+#include <ctime>
+#include <unistd.h>
+#include <poll.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <dpl/utils/wrt_global_settings.h>
+
+namespace {
+const int PIPE_CLOSED = -1;
+}
+
+namespace DPL {
+namespace Test {
+class PipeWrapper : DPL::Noncopyable
+{
+  public:
+    enum Usage {
+        READONLY,
+        WRITEONLY
+    };
+
+    enum Status {
+        SUCCESS,
+        TIMEOUT,
+        ERROR
+    };
+
+    PipeWrapper()
+    {
+        if (-1 == pipe(m_pipefd)) {
+            m_pipefd[0] = PIPE_CLOSED;
+            m_pipefd[1] = PIPE_CLOSED;
+        }
+    }
+
+    bool isReady()
+    {
+        return m_pipefd[0] != PIPE_CLOSED || m_pipefd[1] != PIPE_CLOSED;
+    }
+
+    void setUsage(Usage usage)
+    {
+        if (usage == READONLY) {
+            closeHelp(1);
+        }
+        if (usage == WRITEONLY) {
+            closeHelp(0);
+        }
+    }
+    ~PipeWrapper()
+    {
+        closeHelp(0);
+        closeHelp(1);
+    }
+
+    Status send(int code, std::string &message)
+    {
+        if (m_pipefd[1] == PIPE_CLOSED) {
+            return ERROR;
+        }
+
+        std::ostringstream output;
+        output << toBinaryString(code);
+        output << toBinaryString(static_cast<int>(message.size()));
+        output << message;
+
+        std::string binary = output.str();
+        int size = binary.size();
+
+        if ((writeHelp(&size,
+                       sizeof(int)) == ERROR) ||
+            (writeHelp(binary.c_str(), size) == ERROR))
+        {
+            return ERROR;
+        }
+        return SUCCESS;
+    }
+
+    Status receive(int &code, std::string &data, time_t deadline)
+    {
+        if (m_pipefd[0] == PIPE_CLOSED) {
+            return ERROR;
+        }
+
+        int size;
+        Status ret;
+
+        if ((ret = readHelp(&size, sizeof(int), deadline)) != SUCCESS) {
+            return ret;
+        }
+
+        std::vector<char> buffer;
+        buffer.resize(size);
+
+        if ((ret = readHelp(&buffer[0], size, deadline)) != SUCCESS) {
+            return ret;
+        }
+
+        try {
+            DPL::BinaryQueue queue;
+            queue.AppendCopy(&buffer[0], size);
+
+            queue.FlattenConsume(&code, sizeof(int));
+            queue.FlattenConsume(&size, sizeof(int));
+
+            buffer.resize(size);
+
+            queue.FlattenConsume(&buffer[0], size);
+            data.assign(buffer.begin(), buffer.end());
+        } catch (DPL::BinaryQueue::Exception::Base &e) {
+            return ERROR;
+        }
+        return SUCCESS;
+    }
+
+    void closeAll()
+    {
+        closeHelp(0);
+        closeHelp(1);
+    }
+
+  private:
+    std::string toBinaryString(int data)
+    {
+        char buffer[sizeof(int)];
+        memcpy(buffer, &data, sizeof(int));
+        return std::string(buffer, buffer + sizeof(int));
+    }
+
+    void closeHelp(int desc)
+    {
+        if (m_pipefd[desc] != PIPE_CLOSED) {
+            TEMP_FAILURE_RETRY(close(m_pipefd[desc]));
+            m_pipefd[desc] = PIPE_CLOSED;
+        }
+    }
+
+    Status writeHelp(const void *buffer, int size)
+    {
+        int ready = 0;
+        const char *p = static_cast<const char *>(buffer);
+        while (ready != size) {
+            int ret = write(m_pipefd[1], &p[ready], size - ready);
+
+            if (ret == -1 && (errno == EAGAIN || errno == EINTR)) {
+                continue;
+            }
+
+            if (ret == -1) {
+                closeHelp(1);
+                return ERROR;
+            }
+
+            ready += ret;
+        }
+        return SUCCESS;
+    }
+
+    Status readHelp(void *buf, int size, time_t deadline)
+    {
+        int ready = 0;
+        char *buffer = static_cast<char*>(buf);
+        while (ready != size) {
+            time_t wait = deadline - time(0);
+            wait = wait < 1 ? 1 : wait;
+            pollfd fds = { m_pipefd[0], POLLIN, 0 };
+
+            int pollReturn = poll(&fds, 1, wait * 1000);
+
+            if (pollReturn == 0) {
+                return TIMEOUT; // Timeout
+            }
+
+            if (pollReturn < -1) {
+                return ERROR;
+            }
+
+            int ret = read(m_pipefd[0], &buffer[ready], size - ready);
+
+            if (ret == -1 && (errno == EAGAIN || errno == EINTR)) {
+                continue;
+            }
+
+            if (ret == -1 || ret == 0) {
+                closeHelp(0);
+                return ERROR;
+            }
+
+            ready += ret;
+        }
+        return SUCCESS;
+    }
+
+    int m_pipefd[2];
+};
+
+void RunChildProc(TestRunner::TestCase procChild)
+{
+    PipeWrapper pipe;
+    if (!pipe.isReady()) {
+        throw TestRunner::TestFailed("Pipe creation failed");
+    }
+
+    pid_t pid = fork();
+
+    if (pid == -1) {
+        throw TestRunner::TestFailed("Child creation failed");
+    }
+
+    if (pid != 0) {
+        // parent code
+        pipe.setUsage(PipeWrapper::READONLY);
+
+        int code;
+        std::string message;
+
+        int pipeReturn = pipe.receive(code, message, time(0) + 10);
+
+        if (pipeReturn != PipeWrapper::SUCCESS) { // Timeout or reading error
+            pipe.closeAll();
+            kill(pid, SIGKILL);
+        }
+
+        int status;
+        waitpid(pid, &status, 0);
+
+        if (pipeReturn == PipeWrapper::TIMEOUT) {
+            throw TestRunner::TestFailed("Timeout");
+        }
+
+        if (pipeReturn == PipeWrapper::ERROR) {
+            throw TestRunner::TestFailed("Reading pipe error");
+        }
+
+        if (code == 0) {
+            throw TestRunner::TestFailed(message);
+        }
+    } else {
+        // child code
+
+        // End Runner after current test
+        TestRunnerSingleton::Instance().Terminate();
+
+        int code = 1;
+        std::string msg;
+
+        bool allowLogs = TestRunnerSingleton::Instance().GetAllowChildLogs();
+
+        close(0);            // stdin
+        if (!allowLogs) {
+            close(1);        // stdout
+            close(2);        // stderr
+        }
+
+        pipe.setUsage(PipeWrapper::WRITEONLY);
+
+        try {
+            procChild();
+        } catch (DPL::Test::TestRunner::TestFailed &e) {
+            msg = e.GetMessage();
+            code = 0;
+        } catch (...) { // Pokemon Catch... cache them all...
+            msg = "unhandled exeception";
+            code = 0;
+        }
+
+        if (allowLogs) {
+            close(1);   // stdout
+            close(2);   // stderr
+        }
+
+        pipe.send(code, msg);
+    }
+}
+} // namespace Test
+} // namespace DPL
index 96efba7..2b0beca 100644 (file)
 #
 
 SET(DPL_UTILS_SOURCES
 #
 
 SET(DPL_UTILS_SOURCES
-    ${PROJECT_SOURCE_DIR}/modules/utils/src/file_utils.cpp
+    ${PROJECT_SOURCE_DIR}/modules/utils/src/bash_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/folder_size.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/mime_type_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/warp_iri.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/widget_version.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/folder_size.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/mime_type_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/warp_iri.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/widget_version.cpp
-    ${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_global_settings_internal.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_global_settings.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_utility.cpp
     PARENT_SCOPE
     ${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_global_settings.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_utility.cpp
     PARENT_SCOPE
@@ -33,14 +32,13 @@ SET(DPL_UTILS_SOURCES
 
 
 SET(DPL_UTILS_HEADERS
 
 
 SET(DPL_UTILS_HEADERS
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/file_utils.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/folder_size.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/mime_type_utils.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/warp_iri.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/widget_version.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/wrt_global_settings.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/wrt_global_settings_internal.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/wrt_utility.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/bash_utils.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/folder_size.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/mime_type_utils.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/warp_iri.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/widget_version.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/wrt_global_settings.h
+    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/wrt_utility.h
     PARENT_SCOPE
 )
 
     PARENT_SCOPE
 )
 
diff --git a/modules/utils/include/dpl/utils/bash_utils.h b/modules/utils/include/dpl/utils/bash_utils.h
new file mode 100644 (file)
index 0000000..33a5f9d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    bash_utils.h
+ * @author  Iwanek Tomasz
+ * @version 1.0
+ */
+
+#ifndef BASH_UTILS_H
+#define BASH_UTILS_H
+
+#include <string>
+
+namespace BashUtils {
+/**
+ * Escapes bash special characters in string and return string in double quotes
+ * @param source string to be escaped
+ * @return escaped string
+ */
+std::string escape_arg(const std::string & source);
+}
+
+#endif // BASH_UTILS_H
diff --git a/modules/utils/include/dpl/utils/file_utils.h b/modules/utils/include/dpl/utils/file_utils.h
new file mode 100644 (file)
index 0000000..9fbad4e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    file_utils.h
+ * @author  Bartosz Janiak (b.janiak@samsung.com)
+ * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @version 1.0
+ */
+
+#ifndef FILEUTILS_H
+#define FILEUTILS_H
+
+#include <sys/types.h>
+#include <string>
+
+#include <dpl/string.h>
+#include <dpl/exception.h>
+
+namespace FileUtils {
+DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDirectoryException)
+DECLARE_EXCEPTION_TYPE(DPL::Exception, RemoveDirectoryException)
+
+bool FileExists(const DPL::String& absolutePath);
+bool DirectoryExists(const DPL::String& absolutePath);
+
+/**
+ * Creates specified path recursively.
+ * @param path Path to create (e.g. /tmp/dir1/dir2).
+ * @param mode Mode for the non-existing parts of the path (e.g. 0755).
+ * @throw DPL::CommonException::::InternalError If sth bad happens.
+ */
+void MakePath(const std::string& path, mode_t mode);
+
+/**
+ * Removes specified directory recursively.
+ * @param path Full path to directory to remove.
+ * @throw FileUtils::DirectoryRemoveException If an error occured.
+ */
+void RemoveDir(const std::string& path);
+} // namespace FileUtils
+
+#endif
diff --git a/modules/utils/include/dpl/utils/folder_size.h b/modules/utils/include/dpl/utils/folder_size.h
new file mode 100644 (file)
index 0000000..71a77bd
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        folder_size.h
+ * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
+ * @version     1.0
+ * @brief       Declaration for function calculating directory size
+ */
+
+#ifndef SRC_COMMON_FOLDER_SIZE_H_
+#define SRC_COMMON_FOLDER_SIZE_H_
+
+#include <string>
+
+#include <dpl/string.h>
+
+namespace Utils {
+size_t getFolderSize(const std::string& path);
+
+DPL::String fromFileSizeString(size_t fileSize);
+}
+
+#endif /* SRC_COMMON_FOLDER_SIZE_H_ */
diff --git a/modules/utils/include/dpl/utils/mime_type_utils.h b/modules/utils/include/dpl/utils/mime_type_utils.h
new file mode 100644 (file)
index 0000000..1d93385
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 MIME_TYPE_UTILS_H
+#define MIME_TYPE_UTILS_H
+
+#include <dpl/string.h>
+#include <dpl/optional_typedefs.h>
+
+class MimeTypeUtils
+{
+  public:
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, InvalidFileName)
+    };
+
+  private:
+    //TODO use hash_map if possible
+    static const std::set<DPL::String>& getMimeTypesSupportedForIcon();
+    static const std::set<DPL::String>& getMimeTypesSupportedForStartFile();
+
+    typedef std::map<DPL::String, DPL::String> FileIdentificationMap;
+
+    static DPL::String getFileNameFromPath(const DPL::String& path);
+    static const FileIdentificationMap& getFileIdentificationMap();
+    static DPL::String stripMimeParameters(const DPL::String& mimeType);
+
+  public:
+    typedef std::map<DPL::String, DPL::String> MimeAttributes;
+    static bool isValidIcon(const DPL::String& path);
+    static bool isValidStartFile(const DPL::String& path,
+                                 const DPL::OptionalString& providedMimeType);
+    static bool isMimeTypeSupportedForStartFile(const DPL::String& mimeType);
+    static bool isMimeTypeSupportedForIcon(const DPL::String& mimeType);
+    static MimeAttributes getMimeAttributes(const DPL::String& mimeType);
+    ///implements 9.1.10. (Rule for Identifying the Media Type of a File)
+    ///from W3C packaging specification
+    static DPL::String identifyFileMimeType(const DPL::String& path);
+};
+
+#endif  /* MIME_TYPE_UTILS_H */
+
diff --git a/modules/utils/include/dpl/utils/warp_iri.h b/modules/utils/include/dpl/utils/warp_iri.h
new file mode 100644 (file)
index 0000000..71773cb
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 _WARPIRI_H_
+#define _WARPIRI_H_
+
+#include <vector>
+
+#include <dpl/string.h>
+#include <dpl/log/log.h>
+
+class WarpIRI
+{
+    static const unsigned int UNKNOWN_PORT = 0;
+
+  public:
+    WarpIRI();
+
+    void set(const char *iri,
+             bool domain);
+    void set(const DPL::String &iristring,
+             bool domain);
+
+    /* It also checks port and schema */
+    bool isSubDomain(const WarpIRI &second) const;
+    bool isAccessDefinition() const;
+    bool getSubDomain() const;
+
+    static bool isIRISchemaIgnored(const char *iri);
+
+    bool operator ==(const WarpIRI &other) const
+    {
+        return m_domain == other.m_domain &&
+               m_host == other.m_host &&
+               m_schema == other.m_schema &&
+               m_port == other.m_port &&
+               m_isAccessDefinition == other.m_isAccessDefinition &&
+               m_isIRIValid == other.m_isIRIValid;
+    }
+
+  private:
+    unsigned int getPort(const DPL::String &schema) const;
+
+    bool m_domain;
+    std::vector<DPL::String> m_host;
+    DPL::String m_schema;
+    unsigned int m_port;
+    bool m_isAccessDefinition;
+    bool m_isIRIValid;
+};
+
+#endif // _WarpIRI_H_
diff --git a/modules/utils/include/dpl/utils/widget_version.h b/modules/utils/include/dpl/utils/widget_version.h
new file mode 100644 (file)
index 0000000..de3d3aa
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    widget_version.h
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief   Header file for widget version
+ */
+#ifndef WIDGET_VERSION_H
+#define WIDGET_VERSION_H
+
+#include <dpl/string.h>
+#include <dpl/optional.h>
+#include <ostream>
+
+/*
+ * Note: This class also support non-WAC compliant version numbers
+ *
+ * WAC Waikiki Beta Release Core Specification: Widget Runtime
+ * 10 Dec 2010
+ *
+ * WL-3370 The WRT MUST process widget packages as an update when received under
+ * the following conditions:
+ *
+ *  - the Widget Id matches the Widget Id of an installed widget
+ *  - the Widget version number is greater (as a compared string) than that of
+ * the installed widget, or no version
+ *    information was provided for the installed widget
+ *
+ * To ensure that a string comparison of widget versions can reliably determine
+ * which version is an updated widget,
+ * WAC will mandate a specific version string format for WAC widgets. All
+ * widgets coming through the WAC channel
+ * will be required to have version strings in this format. Side-loaded widgets
+ * may have any format and, in this
+ * case, there is no requirement that the WRT support version detection for
+ * update of these widgets.
+ *
+ * The widget version format is the rec-version-tag grammar as described in
+ * [Widget Packaging]:
+ *
+ *  rec-version-tag = 1*DIGIT "." 1*DIGIT [ "." 1*DIGIT] *[ 1*ALPHA / SP /
+ * 1*DIGIT ]
+ *
+ * Examples of rec-version-tag:
+ *
+ *    1.0
+ *    1.10.1 beta1
+ *    1.02.12 RC1
+ *
+ * WL-3371 The WRT MUST use the following widget version comparison algorithm to
+ * compare WAC widget version strings:
+ *
+ *  - prepare the version strings for comparison:
+ *     - all leading zeros are discarded
+ *     - the optional *[ 1*ALPHA / SP / 1*DIGIT ] part, if present, is discarded
+ *     - the resulting numbers are then in the format major.minor[.micro]
+ *  - Version A = Amajor.Aminor[.Amicro] is equal to Version B =
+ * Bmajor.Bminor[.Bmicro] if and only if:
+ *     - Amajor Bmajor
+ *     - Aminor Bminor
+ *     - both Amicro and Bmicro are present and Amicro == Bmicro; or both Amicro
+ * and Bmicro are absent.
+ *  - Version A = Amajor.Aminor[.Amicro] is greater than Version B =
+ * Bmajor.Bminor[.Bmicro] if and only if:
+ *     - Amajor > Bmajor; or
+ *     - Amajor Bmajor && Aminor > Bminor; or
+ *     - Amajor Bmajor && Aminor == Bminor && both Amicro and Bmicro are present
+ * and Amicro > Bmicro; or Bmicro is absent.
+ */
+class WidgetVersion
+{
+  private:
+    bool m_isWac;
+    DPL::String m_raw;
+
+    DPL::String m_major;
+    DPL::String m_minor;
+    DPL::Optional<DPL::String> m_micro;
+    DPL::Optional<DPL::String> m_optional;
+
+    void WacCertify(const DPL::String &major,
+                    const DPL::String &minor,
+                    const DPL::Optional<DPL::String> &micro,
+                    const DPL::Optional<DPL::String> &optional);
+
+  public:
+    explicit WidgetVersion(const DPL::String &str = DPL::String());
+    WidgetVersion(const DPL::String &major,
+                  const DPL::String &minor,
+                  const DPL::Optional<DPL::String> &micro,
+                  const DPL::Optional<DPL::String> &optional);
+
+    bool IsWac() const;
+    const DPL::String &Raw() const;
+
+    const DPL::String &Major() const;
+    const DPL::String &Minor() const;
+    const DPL::Optional<DPL::String> &Micro() const;
+    const DPL::Optional<DPL::String> &Optional() const;
+};
+
+bool operator<(const WidgetVersion &left,
+               const WidgetVersion &right);
+bool operator<=(const WidgetVersion &left,
+                const WidgetVersion &right);
+bool operator>(const WidgetVersion &left,
+               const WidgetVersion &right);
+bool operator>=(const WidgetVersion &left,
+                const WidgetVersion &right);
+bool operator==(const WidgetVersion &left,
+                const WidgetVersion &right);
+bool operator!=(const WidgetVersion &left,
+                const WidgetVersion &right);
+std::ostream & operator<<(std::ostream& stream,
+                          const WidgetVersion& version);
+
+#endif // WIDGET_VERSION_H
diff --git a/modules/utils/include/dpl/utils/wrt_global_settings.h b/modules/utils/include/dpl/utils/wrt_global_settings.h
new file mode 100644 (file)
index 0000000..14407ae
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    wrt_global_settings.h
+ * @version    0.6
+ * @author    Pawel Sikorski(p.sikorski@samsung.com)
+ * @brief     Header file for global predefined wrt setting
+ */
+
+#ifndef WRT_COMMON_GLOBAL_SETTINGS_H_
+#define WRT_COMMON_GLOBAL_SETTINGS_H_
+
+namespace GlobalSettings {
+// Methods for getting test mode environment flag
+bool TestModeEnabled();
+bool PopupsTestModeEnabled();
+bool WarpTestModeEnabled();
+bool RoamingTestModeEnabled();
+bool OCSPTestModeEnabled();
+bool CrlTestModeEnabled();
+bool MakeScreenTestModeEnabled();
+bool IsEmulator();
+}
+
+#endif /* WRT_COMMON_GLOBAL_SETTINGS_H_ */
diff --git a/modules/utils/include/dpl/utils/wrt_utility.h b/modules/utils/include/dpl/utils/wrt_utility.h
new file mode 100644 (file)
index 0000000..165e167
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        wrt_utility.h
+ * @version     0.8
+ * @author      Janusz Majnert <j.majnert@samsung.com>
+ * @brief       Common utility functions
+ */
+
+#ifndef _WRT_UTILITY_H_
+#define _WRT_UTILITY_H_
+
+#include <sys/stat.h>
+
+/**
+ * Joins two paths into one
+ *
+ * @param[out] joined  String for storing joined paths
+ * @param[in] parent   String containing the first part of path
+ * @param[in] child    String containing the second part of the path
+ *
+ * Data stored in joined before the function call will be replaced with joined
+ * paths.
+ */
+void WrtUtilJoinPaths(std::string &joined,
+                      const std::string &parent,
+                      const std::string &child);
+
+/**
+ * Creates directories specified by path
+ *
+ * @param[in]  path    Path to create
+ * @param[in]  mode    access flags, default to 0755
+ * @return    true on success, false on failure
+ *
+ * Function creates directory specified by path argument and all directories
+ * leading up to it, if they don't exist. Note that if yout wish to create
+ * several nested directories, you must make sure that the mode flag allows you
+ * to write and search the direcotries you create.
+ */
+bool WrtUtilMakeDir(const std::string &newpath, mode_t mode = 0755);
+
+/**
+ * This function removes the directory or file pointed to by path
+ *
+ * @param[in] path  Path to the file/directory to be deleted
+ *
+ * @return true on success, false otherwise
+ */
+bool WrtUtilRemove(const std::string &path);
+
+/**
+ * Checks if path exists and is a regular file
+ *
+ * @param[in] path   the string representing path to check
+ *
+ * @return true if regular file is accessible under path, false otherwise
+ */
+bool WrtUtilFileExists(const std::string &path);
+
+/**
+ * Checks if path exists and is a directory
+ *
+ * @param[in] path   the string representing path to check
+ *
+ * @return true if directory is accessible under path, false otherwise
+ */
+bool WrtUtilDirExists(const std::string &path);
+
+#endif //_WRT_UTILITY_H_
+
diff --git a/modules/utils/src/bash_utils.cpp b/modules/utils/src/bash_utils.cpp
new file mode 100644 (file)
index 0000000..1222eda
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    bash_utils.cpp
+ * @author  Iwanek Tomasz
+ * @version 1.0
+ */
+#include <stddef.h>
+#include <dpl/utils/bash_utils.h>
+#include <dpl/log/log.h>
+
+#include <string>
+
+namespace BashUtils {
+std::string escape_arg(const std::string & source)
+{
+    static const std::string special("!$`\\\"");
+    std::string ret = "\"";
+    for (std::string::const_iterator iter = source.begin();
+         iter != source.end();
+         ++iter)
+    {
+        if (special.find(*iter) != std::string::npos) {
+            ret += std::string("\\") + *iter;
+        } else {
+            ret += *iter;
+        }
+    }
+    return ret + "\"";
+}
+}
index 097fd4a..2510069 100644 (file)
@@ -19,7 +19,6 @@
  * @version 1.0
  */
 
  * @version 1.0
  */
 
-
 #include <sys/stat.h>
 #include <cerrno>
 #include <cstring>
 #include <sys/stat.h>
 #include <cerrno>
 #include <cstring>
 
 #include <dpl/exception.h>
 #include <dpl/errno_string.h>
 
 #include <dpl/exception.h>
 #include <dpl/errno_string.h>
-#include <file_utils.h>
+#include <dpl/utils/file_utils.h>
 
 #include <dpl/wrt-dao-ro/path_builder.h>
 
 namespace {
 int try_mkdir(const char* path,
 
 #include <dpl/wrt-dao-ro/path_builder.h>
 
 namespace {
 int try_mkdir(const char* path,
-        mode_t mode)
+              mode_t mode)
 {
     struct stat st;
     int err = 0;
 {
     struct stat st;
     int err = 0;
@@ -53,7 +52,7 @@ int try_mkdir(const char* path,
 }
 
 int mkpath(const char* path,
 }
 
 int mkpath(const char* path,
-        mode_t mode)
+           mode_t mode)
 {
     char* copy = ::strdup(path);
     if (NULL == copy) {
 {
     char* copy = ::strdup(path);
     if (NULL == copy) {
@@ -95,7 +94,8 @@ int RmDir(const char* path)
         errno = 0;
         if (NULL != (entry = ::readdir(dir))) {
             if (!::strncmp(entry->d_name, ".", 1) ||
         errno = 0;
         if (NULL != (entry = ::readdir(dir))) {
             if (!::strncmp(entry->d_name, ".", 1) ||
-                !::strncmp(entry->d_name, "..", 2)) {
+                !::strncmp(entry->d_name, "..", 2))
+            {
                 continue;
             }
             std::string fullPath = WrtDB::PathBuilder(path)
                 continue;
             }
             std::string fullPath = WrtDB::PathBuilder(path)
@@ -108,8 +108,7 @@ int RmDir(const char* path)
                 return -1;
             }
         }
                 return -1;
             }
         }
-    }
-    while (NULL != entry);
+    } while (NULL != entry);
 
     int error = errno;
     if (TEMP_FAILURE_RETRY(::closedir(dir)) != 0) {
 
     int error = errno;
     if (TEMP_FAILURE_RETRY(::closedir(dir)) != 0) {
@@ -142,10 +141,10 @@ bool FileExists(const DPL::String& absolutePath)
 }
 
 void MakePath(const std::string& path,
 }
 
 void MakePath(const std::string& path,
-        mode_t mode)
+              mode_t mode)
 {
     if (mkpath(path.c_str(), mode) == -1) {
 {
     if (mkpath(path.c_str(), mode) == -1) {
-        ThrowMsg(DPL::CommonException::InternalError, "Cannot make path");
+        ThrowMsg(CreateDirectoryException, "Cannot make path");
     }
 }
 
     }
 }
 
index 87646f7..522216a 100644 (file)
  * @version     1.0
  * @brief       Implementation for function calculating directory size
  */
  * @version     1.0
  * @brief       Implementation for function calculating directory size
  */
-
+#include <stddef.h>
 #include <string.h>
 #include <string.h>
-#include <dirent.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <fts.h>
 
 #include <sstream>
 #include <vector>
 
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
 
 #include <sstream>
 #include <vector>
 
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
-#include <folder_size.h>
+#include <dpl/utils/folder_size.h>
 
 namespace Utils {
 
 namespace Utils {
-namespace {
-
-size_t getObjectSize(const std::string& path)
-{
-    struct stat tmp;
-
-    if (stat(path.c_str(), &tmp) == -1) {
-        LogError("Failed to open file" << path);
-        return 0;
-    }
-    //it is not a file nor a directory
-    //not counting
-    if (!S_ISDIR(tmp.st_mode) && !S_ISREG(tmp.st_mode)) {
-        LogWarning("Not a regular file nor a directory: " << path);
-        return 0;
-    }
-    return tmp.st_size;
-}
-}
-
 size_t getFolderSize(const std::string& path)
 {
     size_t size = 0;
 size_t getFolderSize(const std::string& path)
 {
     size_t size = 0;
-
-    DIR *dir;
-    std::vector<std::string> localDirs;
-    if ((dir=opendir(path.c_str())) == NULL) {
-        LogError("Cannot open dir " << path);
+    FTS *fts;
+    FTSENT *ftsent;
+    char * const paths[] = { const_cast<char * const>(path.c_str()), NULL };
+
+    if ((fts = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) {
+        //ERROR
+        int error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: "
+                                       << strerror(error));
         return 0;
     }
         return 0;
     }
-    struct dirent* el;
-    while ((el = readdir(dir)) != 0) {
-        if (strcmp(el->d_name, ".") == 0 || strcmp(el->d_name, "..") == 0) {
-            continue;
-        }
-        struct stat tmp;
-        std::string local = path + el->d_name;
-        if (stat(local.c_str(), &tmp) == -1) {
-            LogError("Failed to open file " << local);
-            char* errstring = strerror(errno);
-            LogError("Reason: " << errstring);
-            continue;
-        }
 
 
-        size += getObjectSize(local);
-        if (S_ISDIR(tmp.st_mode)) {
-            localDirs.push_back(local + "/");
+    while ((ftsent = fts_read(fts)) != NULL) {
+        switch (ftsent->fts_info) {
+        case FTS_DP:
+        case FTS_DC:
+            //directory in postorder and directory causing a loop
+            break;
+        case FTS_F:
+        case FTS_D:
+        case FTS_NSOK:
+        case FTS_SL:
+        case FTS_SLNONE:
+        case FTS_DEFAULT:
+            //regular files and other objects that can be counted
+            size += ftsent->fts_statp->st_size;
+            break;
+        case FTS_NS:
+        case FTS_DOT:
+        case FTS_DNR:
+        case FTS_ERR:
+        default:
+            LogWarning(__PRETTY_FUNCTION__
+                       << ": traversal failed on file: "
+                       << ftsent->fts_path
+                       << " with error: "
+                       << strerror(ftsent->fts_errno));
+            return 0;
         }
     }
 
         }
     }
 
-    closedir(dir);
-
-    FOREACH (localDir, localDirs) {
-        size += getFolderSize(*localDir);
+    if (fts_close(fts) == -1) {
+        int error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
+                                       << strerror(error));
+        return 0;
     }
 
     return size;
 }
 
     }
 
     return size;
 }
 
-
-
-
-
 namespace {
 #define DECLARE_PREFIX_STRUCT(name)     \
 namespace {
 #define DECLARE_PREFIX_STRUCT(name)     \
-struct Prefix##name                     \
-{                                       \
-  static std::string get()              \
-  {                                     \
-        return std::string(#name);      \
-  }                                     \
-};                                      \
+    struct Prefix##name                     \
+    {                                       \
+        static std::string get()              \
+        {                                     \
+            return std::string(#name);      \
+        }                                     \
+    };                                      \
 
 DECLARE_PREFIX_STRUCT(B)
 DECLARE_PREFIX_STRUCT(KB)
 
 DECLARE_PREFIX_STRUCT(B)
 DECLARE_PREFIX_STRUCT(KB)
@@ -114,53 +105,51 @@ DECLARE_PREFIX_STRUCT(GB)
 
 #undef DECLARE_PREFIX_STRUCT
 
 
 #undef DECLARE_PREFIX_STRUCT
 
-
 const int stepSize = 1024;
 const int stepSize = 1024;
-template<typename... Rest>
+template<typename ... Rest>
 struct Pre;
 
 struct Pre;
 
-template<typename Postfix, typename... Rest>
-struct Pre<Postfix, Rest...>
+template<typename Postfix, typename ... Rest>
+struct Pre<Postfix, Rest ...>
 {
 {
-    static const double value = Pre<Rest...>::value * stepSize;
+    static const double value;
     static std::string printSize(double fileSize)
     {
     static std::string printSize(double fileSize)
     {
-        if(fileSize >= Pre<Rest...>::value) {
-            double now = fileSize / Pre<Rest...>::value;
+        if (fileSize >= Pre<Rest ...>::value) {
+            double now = fileSize / Pre<Rest ...>::value;
             std::ostringstream outputStream;
             outputStream.setf(std::ios::fixed, std::ios::floatfield);
             outputStream.precision(2);
             outputStream << now << Postfix::get();
             return outputStream.str();
         } else {
             std::ostringstream outputStream;
             outputStream.setf(std::ios::fixed, std::ios::floatfield);
             outputStream.precision(2);
             outputStream << now << Postfix::get();
             return outputStream.str();
         } else {
-            return Pre<Rest...>::printSize(fileSize);
+            return Pre<Rest ...>::printSize(fileSize);
         }
         }
-
     }
 };
 
 template<>
 struct Pre<>
 {
     }
 };
 
 template<>
 struct Pre<>
 {
-        static const double value;
-        static std::string printSize(double /*fileSize*/)
-        {
-                return "0B";
-        }
-
+    static const double value;
+    static std::string printSize(double /*fileSize*/)
+    {
+        return "0B";
+    }
 };
 };
+
 const double Pre<>::value = 1.0;
 const double Pre<>::value = 1.0;
+template<typename Postfix, typename ... Params> const double Pre<Postfix,
+                                                                 Params ...>::
+    value(Pre<>::value * stepSize);
 
 typedef Pre<PrefixGB, PrefixMB, PrefixKB, PrefixB> FolderSizeToStringType;
 } //anonymous namespace
 
 
 typedef Pre<PrefixGB, PrefixMB, PrefixKB, PrefixB> FolderSizeToStringType;
 } //anonymous namespace
 
-
 DPL::String fromFileSizeString(size_t fileSize)
 {
 DPL::String fromFileSizeString(size_t fileSize)
 {
-
     std::string output =
         FolderSizeToStringType::printSize(static_cast<double>(fileSize));
     return DPL::FromUTF8String(output);
 }
     std::string output =
         FolderSizeToStringType::printSize(static_cast<double>(fileSize));
     return DPL::FromUTF8String(output);
 }
-
 } // end of namespace Utils
 } // end of namespace Utils
index 988c1a3..1dbe832 100644 (file)
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
+#include <stddef.h>
 #include <set>
 #include <dpl/assert.h>
 #include <vector>
 
 #include <map>
 
 #include <set>
 #include <dpl/assert.h>
 #include <vector>
 
 #include <map>
 
-#include <mime_type_utils.h>
+#include <dpl/utils/mime_type_utils.h>
 
 const std::set<DPL::String>& MimeTypeUtils::getMimeTypesSupportedForIcon()
 {
 
 const std::set<DPL::String>& MimeTypeUtils::getMimeTypesSupportedForIcon()
 {
@@ -93,7 +94,7 @@ DPL::String MimeTypeUtils::stripMimeParameters(const DPL::String& mimeType)
 }
 
 MimeTypeUtils::MimeAttributes MimeTypeUtils::getMimeAttributes(
 }
 
 MimeTypeUtils::MimeAttributes MimeTypeUtils::getMimeAttributes(
-        const DPL::String& mimeType)
+    const DPL::String& mimeType)
 {
     MimeAttributes attributes;
     std::vector<DPL::String> tokens;
 {
     MimeAttributes attributes;
     std::vector<DPL::String> tokens;
@@ -109,8 +110,10 @@ bool MimeTypeUtils::isValidIcon(const DPL::String& path)
     return getMimeTypesSupportedForIcon().count(identifyFileMimeType(path)) > 0;
 }
 
     return getMimeTypesSupportedForIcon().count(identifyFileMimeType(path)) > 0;
 }
 
-bool MimeTypeUtils::isValidStartFile(const DPL::String& path,
-        const DPL::OptionalString& providedMimeType)
+bool MimeTypeUtils::isValidStartFile(
+    const DPL::String& path,
+    const DPL::OptionalString&
+    providedMimeType)
 {
     DPL::String mimeType = (!!providedMimeType) ? stripMimeParameters(
             *providedMimeType) : identifyFileMimeType(path);
 {
     DPL::String mimeType = (!!providedMimeType) ? stripMimeParameters(
             *providedMimeType) : identifyFileMimeType(path);
index a296ea5..9edf59f 100644 (file)
  * but there are some patent issue between  W3C WARP SPEC and APPLE.
  * so if you want to use this file, refer to the README file in root directory
  */
  * but there are some patent issue between  W3C WARP SPEC and APPLE.
  * so if you want to use this file, refer to the README file in root directory
  */
-
-#include <warp_iri.h>
+#include <stddef.h>
+#include <list>
+#include <set>
+#include <string>
+#include <dpl/utils/warp_iri.h>
 #include <dpl/string.h>
 #include <dpl/string.h>
+#include <dpl/auto_ptr.h>
 #include <dpl/foreach.h>
 #include <idna.h>
 #include <istream>
 #include <iri.h>
 #include <dpl/foreach.h>
 #include <idna.h>
 #include <istream>
 #include <iri.h>
-#include <ValidatorCommon.h>
+//#include <ValidatorCommon.h>
 
 namespace {
 // All schemes which are supported by external application should be ignored
 
 namespace {
 // All schemes which are supported by external application should be ignored
@@ -37,7 +41,7 @@ namespace {
 // hard drive. What's why we cannot check any iri with file schema.
 
 const char *IRI_IGNORED_SCHEME[] = { "file://", "widget://", "tel:", "sms:",
 // hard drive. What's why we cannot check any iri with file schema.
 
 const char *IRI_IGNORED_SCHEME[] = { "file://", "widget://", "tel:", "sms:",
-                                    "mmsto:", "mailto:", "data:", "blob:", 0 };
+                                     "mmsto:", "mailto:", "data:", "blob:", 0 };
 
 const DPL::String SCHEMA_HTTP = DPL::FromUTF8String("http");
 const DPL::String SCHEMA_HTTPS = DPL::FromUTF8String("https");
 
 const DPL::String SCHEMA_HTTP = DPL::FromUTF8String("http");
 const DPL::String SCHEMA_HTTPS = DPL::FromUTF8String("https");
@@ -46,20 +50,20 @@ const DPL::String SCHEMA_FTP = DPL::FromUTF8String("ftp");
 
 // This will create AutoPtr deleter for iri_struct.
 // Deleter must be in the same namespace as definition of AutoPtr.
 
 // This will create AutoPtr deleter for iri_struct.
 // Deleter must be in the same namespace as definition of AutoPtr.
-namespace ValidationCore {
-VC_DECLARE_DELETER(iri_struct, iri_destroy)
-}
+
+namespace DPL {
+DECLARE_DELETER(iri_struct, iri_destroy)
+} // namespace DPL
 
 WarpIRI::WarpIRI() :
     m_domain(false),
     m_port(UNKNOWN_PORT),
     m_isAccessDefinition(false),
     m_isIRIValid(false)
 
 WarpIRI::WarpIRI() :
     m_domain(false),
     m_port(UNKNOWN_PORT),
     m_isAccessDefinition(false),
     m_isIRIValid(false)
-{
-}
+{}
 
 void WarpIRI::set(const char *p_iri,
 
 void WarpIRI::set(const char *p_iri,
-        bool domain)
+                  bool domain)
 {
     if (!p_iri) {
         m_isAccessDefinition = m_isIRIValid = false;
 {
     if (!p_iri) {
         m_isAccessDefinition = m_isIRIValid = false;
@@ -75,7 +79,7 @@ void WarpIRI::set(const char *p_iri,
         return;
     }
 
         return;
     }
 
-    ValidationCore::AutoPtr<iri_struct> iri(iri_parse(p_iri));
+    DPL::AutoPtr<iri_struct> iri(iri_parse(p_iri));
 
     if (!iri.get()) {
         LogError("Error in iri_parse!");
 
     if (!iri.get()) {
         LogError("Error in iri_parse!");
@@ -142,7 +146,7 @@ void WarpIRI::set(const char *p_iri,
 }
 
 void WarpIRI::set(const DPL::String &iristring,
 }
 
 void WarpIRI::set(const DPL::String &iristring,
-        bool domain)
+                  bool domain)
 {
     set(DPL::ToUTF8String(iristring).c_str(), domain);
 }
 {
     set(DPL::ToUTF8String(iristring).c_str(), domain);
 }
@@ -162,9 +166,15 @@ unsigned int WarpIRI::getPort(const DPL::String &schema) const
 
 bool WarpIRI::isSubDomain(const WarpIRI &second) const
 {
 
 bool WarpIRI::isSubDomain(const WarpIRI &second) const
 {
-    if (!m_isAccessDefinition || !second.m_isIRIValid) { return false; }
-    if (m_schema != second.m_schema) { return false; }
-    if (m_port != second.m_port) { return false; }
+    if (!m_isAccessDefinition || !second.m_isIRIValid) {
+        return false;
+    }
+    if (m_schema != second.m_schema) {
+        return false;
+    }
+    if (m_port != second.m_port) {
+        return false;
+    }
 
     size_t size = m_host.size() < second.m_host.size() ?
         m_host.size() : second.m_host.size();
 
     size_t size = m_host.size() < second.m_host.size() ?
         m_host.size() : second.m_host.size();
@@ -190,10 +200,6 @@ bool WarpIRI::isAccessDefinition() const
     return m_isAccessDefinition;
 }
 
     return m_isAccessDefinition;
 }
 
-// KW bool WarpIRI::isIRIValid() const {
-// KW     return m_isIRIValid;
-// KW }
-
 bool WarpIRI::getSubDomain() const
 {
     return m_domain;
 bool WarpIRI::getSubDomain() const
 {
     return m_domain;
@@ -204,7 +210,8 @@ bool WarpIRI::isIRISchemaIgnored(const char *iri)
     for (int i = 0; IRI_IGNORED_SCHEME[i]; ++i) {
         if (0 ==
             strncmp(iri, IRI_IGNORED_SCHEME[i],
     for (int i = 0; IRI_IGNORED_SCHEME[i]; ++i) {
         if (0 ==
             strncmp(iri, IRI_IGNORED_SCHEME[i],
-                    strlen(IRI_IGNORED_SCHEME[i]))) {
+                    strlen(IRI_IGNORED_SCHEME[i])))
+        {
             return true;
         }
     }
             return true;
         }
     }
index 0bf91c1..cbaf5d1 100644 (file)
@@ -19,7 +19,8 @@
  * @version 1.0
  * @brief   Implementation file for widget version
  */
  * @version 1.0
  * @brief   Implementation file for widget version
  */
-#include <widget_version.h>
+#include <stddef.h>
+#include <dpl/utils/widget_version.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <ctype.h>
 #include <dpl/assert.h>
 #include <dpl/log/log.h>
 #include <ctype.h>
@@ -38,7 +39,8 @@ DPL::String::value_type LEADING_ZERO_CHAR = L'0';
 
 //
 // [ABNF]
 
 //
 // [ABNF]
-// Augmented BNF for Syntax Specifications: ABNF. RFC5234. D. Crocker and P. Overell. January 2008.
+// Augmented BNF for Syntax Specifications: ABNF. RFC5234. D. Crocker and P.
+// Overell. January 2008.
 //
 // ALPHA          =  %x41-5A / %x61-7A
 inline bool IsAlpha(int c)
 //
 // ALPHA          =  %x41-5A / %x61-7A
 inline bool IsAlpha(int c)
@@ -78,7 +80,7 @@ DPL::String RemoveLeadingZeroes(const DPL::String &str)
 
 // operator <
 bool NumberLessOperator(const DPL::String &left,
 
 // operator <
 bool NumberLessOperator(const DPL::String &left,
-        const DPL::String &right)
+                        const DPL::String &right)
 {
     // Assume: No leading zeroes
     if (left.size() < right.size()) {
 {
     // Assume: No leading zeroes
     if (left.size() < right.size()) {
@@ -160,7 +162,8 @@ WidgetVersion::WidgetVersion(const DPL::String &str) :
     LogDebug("Tokenized mandatory parts: " << parts.size());
 
     if (parts.size() != WAC_CERTIFY_MANDATORY_PART_LOW_COUNT &&
     LogDebug("Tokenized mandatory parts: " << parts.size());
 
     if (parts.size() != WAC_CERTIFY_MANDATORY_PART_LOW_COUNT &&
-        parts.size() != WAC_CERTIFY_MANDATORY_PART_HIGH_COUNT) {
+        parts.size() != WAC_CERTIFY_MANDATORY_PART_HIGH_COUNT)
+    {
         return;
     }
 
         return;
     }
 
@@ -180,9 +183,9 @@ WidgetVersion::WidgetVersion(const DPL::String &str) :
 }
 
 WidgetVersion::WidgetVersion(const DPL::String &major,
 }
 
 WidgetVersion::WidgetVersion(const DPL::String &major,
-        const DPL::String &minor,
-        const DPL::Optional<DPL::String> &micro,
-        const DPL::Optional<DPL::String> &optional) :
+                             const DPL::String &minor,
+                             const DPL::Optional<DPL::String> &micro,
+                             const DPL::Optional<DPL::String> &optional) :
     m_isWac(false)
 {
     // Create Raw version
     m_isWac(false)
 {
     // Create Raw version
@@ -205,9 +208,9 @@ WidgetVersion::WidgetVersion(const DPL::String &major,
 }
 
 void WidgetVersion::WacCertify(const DPL::String &major,
 }
 
 void WidgetVersion::WacCertify(const DPL::String &major,
-        const DPL::String &minor,
-        const DPL::Optional<DPL::String> &micro,
-        const DPL::Optional<DPL::String> &optional)
+                               const DPL::String &minor,
+                               const DPL::Optional<DPL::String> &micro,
+                               const DPL::Optional<DPL::String> &optional)
 {
     LogDebug("Certyfing...");
 
 {
     LogDebug("Certyfing...");
 
@@ -233,7 +236,8 @@ void WidgetVersion::WacCertify(const DPL::String &major,
     }
 
     if (!!optional &&
     }
 
     if (!!optional &&
-        (optional->empty() || !WacCertifyAlphaNumberStringSpace(*optional))) {
+        (optional->empty() || !WacCertifyAlphaNumberStringSpace(*optional)))
+    {
         LogDebug("Optional version not certified!");
         return;
     }
         LogDebug("Optional version not certified!");
         return;
     }
@@ -280,32 +284,49 @@ const DPL::Optional<DPL::String> &WidgetVersion::Optional() const
 }
 
 bool operator<(const WidgetVersion &left,
 }
 
 bool operator<(const WidgetVersion &left,
-        const WidgetVersion &right)
+               const WidgetVersion &right)
 {
     Assert(
         left.IsWac() && right.IsWac() &&
         "Only WAC version strings are comparable!");
 
     if (NumberLessOperator(RemoveLeadingZeroes(left.Major()),
 {
     Assert(
         left.IsWac() && right.IsWac() &&
         "Only WAC version strings are comparable!");
 
     if (NumberLessOperator(RemoveLeadingZeroes(left.Major()),
-                           RemoveLeadingZeroes(right.Major()))) { return true; }
+                           RemoveLeadingZeroes(right.Major())))
+    {
+        return true;
+    }
     if (NumberLessOperator(RemoveLeadingZeroes(right.Major()),
     if (NumberLessOperator(RemoveLeadingZeroes(right.Major()),
-                           RemoveLeadingZeroes(left.Major()))) { return false; }
+                           RemoveLeadingZeroes(left.Major())))
+    {
+        return false;
+    }
 
     if (NumberLessOperator(RemoveLeadingZeroes(left.Minor()),
 
     if (NumberLessOperator(RemoveLeadingZeroes(left.Minor()),
-                           RemoveLeadingZeroes(right.Minor()))) { return true; }
+                           RemoveLeadingZeroes(right.Minor())))
+    {
+        return true;
+    }
     if (NumberLessOperator(RemoveLeadingZeroes(right.Minor()),
     if (NumberLessOperator(RemoveLeadingZeroes(right.Minor()),
-                           RemoveLeadingZeroes(left.Minor()))) { return false; }
+                           RemoveLeadingZeroes(left.Minor())))
+    {
+        return false;
+    }
 
     if (!!left.Micro() && !!right.Micro() &&
         NumberLessOperator(RemoveLeadingZeroes(*left.Micro()),
 
     if (!!left.Micro() && !!right.Micro() &&
         NumberLessOperator(RemoveLeadingZeroes(*left.Micro()),
-                           RemoveLeadingZeroes(*right.Micro()))) { return true; }
-    if (!left.Micro() && !!right.Micro()) { return true; }
+                           RemoveLeadingZeroes(*right.Micro())))
+    {
+        return true;
+    }
+    if (!left.Micro() && !!right.Micro()) {
+        return true;
+    }
 
     return false;
 }
 
 bool operator<=(const WidgetVersion &left,
 
     return false;
 }
 
 bool operator<=(const WidgetVersion &left,
-        const WidgetVersion &right)
+                const WidgetVersion &right)
 {
     Assert(
         left.IsWac() && right.IsWac() &&
 {
     Assert(
         left.IsWac() && right.IsWac() &&
@@ -315,7 +336,7 @@ bool operator<=(const WidgetVersion &left,
 }
 
 bool operator>(const WidgetVersion &left,
 }
 
 bool operator>(const WidgetVersion &left,
-        const WidgetVersion &right)
+               const WidgetVersion &right)
 {
     Assert(
         left.IsWac() && right.IsWac() &&
 {
     Assert(
         left.IsWac() && right.IsWac() &&
@@ -325,7 +346,7 @@ bool operator>(const WidgetVersion &left,
 }
 
 bool operator>=(const WidgetVersion &left,
 }
 
 bool operator>=(const WidgetVersion &left,
-        const WidgetVersion &right)
+                const WidgetVersion &right)
 {
     Assert(
         left.IsWac() && right.IsWac() &&
 {
     Assert(
         left.IsWac() && right.IsWac() &&
@@ -335,26 +356,32 @@ bool operator>=(const WidgetVersion &left,
 }
 
 bool operator==(const WidgetVersion &left,
 }
 
 bool operator==(const WidgetVersion &left,
-        const WidgetVersion &right)
+                const WidgetVersion &right)
 {
     Assert(
         left.IsWac() && right.IsWac() &&
         "Only WAC version strings are comparable!");
 
 {
     Assert(
         left.IsWac() && right.IsWac() &&
         "Only WAC version strings are comparable!");
 
+    //Major are equal
+    //and
+    //Minor are equal
+    //and
+    //Both Micro exist and are equal
+    //or both Micro do not exist
     return RemoveLeadingZeroes(left.Major()) ==
     return RemoveLeadingZeroes(left.Major()) ==
-           RemoveLeadingZeroes(right.Major()) &&                                       // Major are equal
+           RemoveLeadingZeroes(right.Major()) &&
            RemoveLeadingZeroes(left.Minor()) ==
            RemoveLeadingZeroes(left.Minor()) ==
-           RemoveLeadingZeroes(right.Minor()) &&                                       // and Minor are equal
-           (                                                                           // and ...
+           RemoveLeadingZeroes(right.Minor()) &&
+           (
                (!!left.Micro() && !!right.Micro() &&
                 RemoveLeadingZeroes(*left.Micro()) ==
                (!!left.Micro() && !!right.Micro() &&
                 RemoveLeadingZeroes(*left.Micro()) ==
-                RemoveLeadingZeroes(*right.Micro())) ||                                                                              // Both Micro exist and are equal
-               (!left.Micro() && !right.Micro())                                                                                     // or both Micro do not exist
+                RemoveLeadingZeroes(*right.Micro())) ||
+               (!left.Micro() && !right.Micro())
            );
 }
 
 bool operator!=(const WidgetVersion &left,
            );
 }
 
 bool operator!=(const WidgetVersion &left,
-        const WidgetVersion &right)
+                const WidgetVersion &right)
 {
     Assert(
         left.IsWac() && right.IsWac() &&
 {
     Assert(
         left.IsWac() && right.IsWac() &&
@@ -364,7 +391,7 @@ bool operator!=(const WidgetVersion &left,
 }
 
 std::ostream & operator<<(std::ostream& stream,
 }
 
 std::ostream & operator<<(std::ostream& stream,
-        const WidgetVersion& version)
+                          const WidgetVersion& version)
 {
     stream << version.Raw();
     return stream;
 {
     stream << version.Raw();
     return stream;
index 8695e8a..adaac78 100644 (file)
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @brief       runtime
  */
  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
  * @brief       runtime
  */
-#include <dpl/assert.h>
-#include <dpl/log/log.h>
-#include <string.h>
-#include <stdlib.h>
-#include <wrt_global_settings_internal.h>
+#include <stddef.h>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <sstream>
+#include <sys/utsname.h>
+#include <dpl/utils/wrt_global_settings.h>
 
 
+namespace GlobalSettings {
 namespace {
 namespace {
-bool GetPopupsEnabledFlag()
-{
-    //TODO : env var. will be removed after UX guide for POWDER is enabled.
-    const char *env = getenv("WRT_POPUP_ENABLE");
-    if (env && 0 == strcmp(env, "1")) {
-        return true;
-    } else {
-        return false;
-    }
-}
+const int ROAMING_TEST = 0x00000001;
+const int POPUPS_TEST = 0x00000002;
+const int OCSP_TEST = 0x00000004;
+const int WARP_TEST = 0x00000008;
+const int CRL_TEST = 0x00000010;
+const int SCREEN_SHOT_TEST = 0x00000020;
+const int ALL_TEST = (ROAMING_TEST | POPUPS_TEST | OCSP_TEST | WARP_TEST
+                      | CRL_TEST | SCREEN_SHOT_TEST);
+const char* WRT_TEST_MODE = "WRT_TEST_MODE";
+const char* MACHINE_NAME_EMUL = "emulated"; // "arch_emulated"
+enum MachineType
+{
+    MACHINE_TYPE_TARGET,
+    MACHINE_TYPE_EMULATOR,
+    MACHINE_TYPE_UNKNOWN
+};
+
+struct Settings {
+    bool isEmulator;
+    int testModes;
 
 
-static bool initializeGlobalSettings();
+    Settings() :
+        isEmulator(false), testModes(0)
+    {}
+};
+
+Settings gSettings;
+
+bool initializeGlobalSettings();
+bool initHelper = initializeGlobalSettings();
+
+MachineType getMachineType()
+{
+    // get current machine name
+    struct utsname u;
+    if (0 == uname(&u)) {
+        if (0 == strlen(u.machine)) {
+            return MACHINE_TYPE_UNKNOWN;
+        } else {
+            // If current machine is emul,
+            // machine name include "<arch>_emulated"
+            std::string machine = u.machine;
+            // find "emulated" string in the u.machine
+            if (std::string::npos != machine.find(MACHINE_NAME_EMUL)) {
+                return MACHINE_TYPE_EMULATOR;
+            } else {
+                return MACHINE_TYPE_TARGET;
+            }
+        }
+    }
 
 
-static bool initHelper = initializeGlobalSettings();
+    return MACHINE_TYPE_UNKNOWN;
+}
 
 bool initializeGlobalSettings()
 {
     (void)initHelper;
 
 bool initializeGlobalSettings()
 {
     (void)initHelper;
-    LogDebug("Initializing globall settings");
-    GlobalSettings::IGlobalSettingsFunctions functions;
-    functions.getPopupsEnabledFlag = &GetPopupsEnabledFlag;
-    GlobalSettings::SetPredefinedGlobalSettings(functions);
+
+    // ignore environment variables if this flag is not set
+#ifdef GLOBAL_SETTINGS_CONTROL
+    char * envStr = getenv(WRT_TEST_MODE);
+    int testMode = 0;
+    if (NULL != envStr) {
+        std::string env = envStr;
+        if ("1" == env) {
+            testMode = ALL_TEST;
+        } else {
+            std::istringstream str(envStr);
+            while (std::getline(str, env, '|')) {
+                if ("popups" == env) {
+                    testMode |= POPUPS_TEST;
+                } else if ("roaming" == env) {
+                    testMode |= ROAMING_TEST;
+                } else if ("ocsp" == env) {
+                    testMode |= OCSP_TEST;
+                } else if ("warp" == env) {
+                    testMode |= WARP_TEST;
+                } else if ("crl" == env) {
+                    testMode |= CRL_TEST;
+                } else if ("screen" == env) {
+                    testMode |= SCREEN_SHOT_TEST;
+                }
+            }
+        }
+        gSettings.testModes = testMode;
+    }
+    // TODO other settings initialization
+
+#endif
+    gSettings.isEmulator = (MACHINE_TYPE_EMULATOR == getMachineType());
     return false;
 }
     return false;
 }
+} // namespace
+
+bool TestModeEnabled()
+{
+    return ((gSettings.testModes & ALL_TEST) == ALL_TEST);
+}
+
+bool PopupsTestModeEnabled()
+{
+    return (gSettings.testModes & POPUPS_TEST);
+}
+bool WarpTestModeEnabled()
+{
+    return (gSettings.testModes & WARP_TEST);
+}
+bool RoamingTestModeEnabled()
+{
+    return (gSettings.testModes & ROAMING_TEST);
+}
+bool OCSPTestModeEnabled()
+{
+    return (gSettings.testModes & OCSP_TEST);
+}
+bool CrlTestModeEnabled()
+{
+    return (gSettings.testModes & CRL_TEST);
+}
+bool MakeScreenTestModeEnabled()
+{
+    return (gSettings.testModes & SCREEN_SHOT_TEST);
+}
+
+bool IsEmulator()
+{
+    return gSettings.isEmulator;
 }
 }
+} // GlobalSettings
index f7ecd7d..44044f2 100644 (file)
  *    limitations under the License.
  */
 /**
  *    limitations under the License.
  */
 /**
- * @file       wrt_utility.cpp
- * @version    0.6
- * @author Wei Dong(d.wei@samsung.com)
- * @author Ma Quan(jason.ma@samsung.com)
- * @brief  This file implemented some common functions for widget manager
+ * @file        wrt_utility.cpp
+ * @version     0.8
+ * @author      Janusz Majnert <j.majnert@samsung.com>
+ * @brief       Implementation of some common utility functions
  */
  */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <stddef.h>
+#include <fts.h>
+#include <string>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
 #include <ctype.h>
 #include <ctype.h>
-#include <dirent.h>
-#include <fcntl.h>
 #include <unistd.h>
 #include <unistd.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <dpl/log/log.h>
 #include <dpl/log/log.h>
-#include <wrt_utility.h>
-
-using namespace std;
+#include <dpl/utils/wrt_utility.h>
 
 
-bool _WrtUtilSetAbsolutePath(char* absolutePath,
-        const char* parentPath,
-        const char* fileName)
+void WrtUtilJoinPaths(std::string &joined,
+                      const std::string &parent,
+                      const std::string &child)
 {
 {
-    int len;
-    if (NULL == absolutePath || NULL == parentPath || NULL == fileName) {
-        return false;
-    }
-    len = strlen(parentPath);
-    if (len > 0) {
-        // not check the valid of parentPath and fileName.
-        if (parentPath[len - 1] == '/') {
-            snprintf(absolutePath,
-                     MAX_WIDGET_PATH_LENGTH,
-                     "%s%s",
-                     parentPath,
-                     fileName);
-        } else {
-            snprintf(absolutePath,
-                     MAX_WIDGET_PATH_LENGTH,
-                     "%s/%s",
-                     parentPath,
-                     fileName);
+    size_t parent_len = parent.length();
+    joined = parent;
+    joined += child;
+    //In case someone used windows-style paths
+    std::replace(joined.begin(), joined.end(), '\\', '/');
+
+    if (parent_len != 0 && child.length() != 0) {
+        if (joined[parent_len - 1] != '/' && joined[parent_len] != '/') {
+            joined.insert(parent_len, "/");
+        } else if (joined[parent_len - 1] == '/' && joined[parent_len] ==
+                   '/')
+        {
+            joined.erase(parent_len, 1);
         }
         }
-    } else {
-        LogDebug("The parent path is null");
-        return false;
     }
     }
-
-    //some widget use Windows notation. We need to change '\' to '/'
-    for (int i = 0; absolutePath[i] != 0; ++i) {
-        if (absolutePath[i] == '\\') {
-            absolutePath[i] = '/';
-        }
-    }
-
-    return true;
 }
 
 }
 
-// KW bool _WrtUtilConvertStrToBool(char* value, bool *result)
-// KW {
-// KW     bool ret = false;
-// KW     if (NULL == value || NULL == result)
-// KW     {
-// KW         return ret;
-// KW     }
-// KW
-// KW     char* source = value;
-// KW     char* changed = (char*)malloc(strlen(value) + 1);
-// KW     if (NULL == changed)
-// KW     {
-// KW         return ret;
-// KW     }
-// KW     memset(changed, 0, strlen(value) + 1);
-// KW
-// KW     char* cur = changed;
-// KW     while(*source)
-// KW     {
-// KW         *cur++ = tolower(*source++);
-// KW     }
-// KW     if (!strcmp(changed,"false") || !strcmp(changed,"0"))
-// KW     {
-// KW         *result = false;
-// KW         ret = true;
-// KW     }
-// KW     else if(!strcmp(changed,"true") || !strcmp(changed,"1"))
-// KW     {
-// KW         *result = true;
-// KW         ret = true;
-// KW     }
-// KW     free(changed);
-// KW
-// KW     return ret;
-// KW }
-
-void _WrtUtilGetDirAndFileName(const char* fullPath,
-        char** dirName,
-        char** fileName)
+bool WrtUtilMakeDir(const std::string &newpath, mode_t mode)
 {
 {
-    int length = 0;
-    int index = 0;
-    if (NULL == fullPath || (NULL == dirName && NULL == fileName)) {
-        return;
-    }
+    size_t pos = 0;
+    int error;
 
 
-    length = strlen(fullPath);
-    for (index = length - 1; index >= 0; index--) {
-        if ('/' == fullPath[index]) {
-            if (index == length - 1) {
-                LogDebug(" Warning: The end of directroy is '/'! ");
-                if (dirName) {
-                    *dirName = (char*)malloc(sizeof(char) * (length + 1));
-                    if (*dirName != NULL) {
-                        memset(*dirName, 0, sizeof(char) * (length + 1));
-                        strncpy(*dirName, fullPath, length);
-                    }
-                }
-                return;
-            }
-            break;
-        }
-    }
-    if (index >= 0) {
-        if (dirName) {
-            int dirName_len = index + 2;
-
-            *dirName = (char*)malloc(sizeof(char) * dirName_len);
-            if (*dirName != NULL) {
-                memset(*dirName, 0, sizeof(char) * dirName_len);
-                strncpy(*dirName, fullPath, dirName_len - 1);
-            }
-        }
-
-        if (fileName) {
-            int fileName_len = length - index;
-
-            *fileName = (char*)malloc(sizeof(char) * fileName_len);
-            if (*fileName != NULL) {
-                memset(*fileName, 0, sizeof(char) * fileName_len);
-                strncpy(*fileName, &fullPath[index + 1], fileName_len - 1);
-            }
-        }
-    } else {
-        if (fileName) {
-            *fileName = (char*)malloc(sizeof(char) * (length + 1));
-            if (*fileName != NULL) {
-                memset(*fileName, 0, sizeof(char) * (length + 1));
-                strncpy(*fileName, fullPath, length);
-            }
-        }
-    }
-}
-
-// KW bool _WrtUtilStringCmp(const char* srcStr, const char* destStr)
-// KW {
-// KW     bool ret = false;
-// KW     char* strString = NULL;
-// KW     char* destString = NULL;
-// KW
-// KW     if (NULL == srcStr || NULL == destStr )
-// KW     {
-// KW         return ret;
-// KW     }
-// KW
-// KW     _WrtUtilStringToLower(srcStr, &strString);
-// KW     _WrtUtilStringToLower(destStr,&destString);
-// KW
-// KW     if(!strcmp(strString, destString))
-// KW     {
-// KW         ret = true;
-// KW     }
-// KW
-// KW     free(strString);
-// KW     free(destString);
-// KW
-// KW     return ret;
-// KW }
-
-// check it deeply later.
-bool _WrtMakeDir (const char *path,
-        long mode,
-        int flags)
-{
-    if (NULL == path) {
+    if (newpath.length() == 0) {
         return false;
     }
 
         return false;
     }
 
-    const int defaultMode = 0777;
-    if (!(flags & WRT_FILEUTILS_RECUR)) {
-        if (mkdir(path, defaultMode) < 0) {
-            LogDebug("Failed to make dir " << path);
-            return false;
-        }
-        if (mode != -1 && chmod(path, mode) < 0) {
-            LogDebug("Failed to chmod");
-            remove(path);
-            return false;
-        }
-    } else {
-        struct stat st;
-        if (stat(path, &st) < 0 && errno == ENOENT) {
-            bool ret;
-            char *buf = NULL;
-            char *parent = NULL;
-            //            mode_t mask;
-
-            //            mask = umask (0);
-            //            umask (mask);
+    std::string path = newpath;
 
 
-            buf = strdup(path);
-            parent = dirname(buf);
-            //ret = _WrtMakeDir(parent, (defaultMode & ~mask) | 0300, WRT_FILEUTILS_RECUR);
-            ret = _WrtMakeDir(parent, (defaultMode) | 0300, WRT_FILEUTILS_RECUR);
-            free(buf);
+    if (*(path.rbegin()) != '/') {
+        path += '/';
+    }
 
 
-            if ((!ret) || (!_WrtMakeDir(path, mode, 0))) {
-                LogDebug("Failed to _WrtMakeDir");
-                return false;
+    while ((pos = path.find('/', pos + 1)) != std::string::npos) {
+        if (mkdir(path.substr(0, pos).c_str(), mode) != 0) {
+            error = errno;
+            if (error == EEXIST) {
+                continue;
             }
             }
+            LogWarning(__PRETTY_FUNCTION__ << ": failed to create directory "
+                                           << path.substr(0, pos)
+                                           << ". Error: "
+                                           << strerror(error));
+            return false;
         }
     }
         }
     }
-
     return true;
 }
 
     return true;
 }
 
-bool _WrtUtilChangeDir(const char* path)
+bool WrtUtilRemove(const std::string &path)
 {
 {
-    if (NULL == path) {
+    FTS *fts;
+    FTSENT *ftsent;
+    bool rv = true;
+    int error = 0;
+    char * const paths[] = { const_cast<char * const>(path.c_str()), NULL };
+
+    if ((fts = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL) {
+        //ERROR
+        error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: "
+                                       << strerror(error));
         return false;
     }
         return false;
     }
-    if (-1 == chdir(path)) {
-        if (ENOENT == errno) {
-            if (!_WrtMakeDir(path, 0664, WRT_FILEUTILS_RECUR)) {
-                return false;
+
+    while ((ftsent = fts_read(fts)) != NULL) {
+        switch (ftsent->fts_info) {
+        case FTS_D:
+            //directory in preorder - do nothing
+            break;
+        case FTS_DP:
+            //directory in postorder - remove
+            if (rmdir(ftsent->fts_accpath) != 0) {
+                error = errno;
+                LogWarning(__PRETTY_FUNCTION__
+                           << ": rmdir failed with error: "
+                           << strerror(error));
+                rv = false;
             }
             }
-            if (-1 == chdir(path)) {
-                remove(path);
-                return false;
+            break;
+        case FTS_DC:
+        case FTS_F:
+        case FTS_NSOK:
+        case FTS_SL:
+        case FTS_SLNONE:
+        case FTS_DEFAULT:
+            //regular files and other objects that can safely be removed
+            if (unlink(ftsent->fts_accpath) != 0) {
+                error = errno;
+                LogWarning(__PRETTY_FUNCTION__
+                           << ": unlink failed with error: "
+                           << strerror(error));
+                rv = false;
             }
             }
-        } else {
-            return false;
+            break;
+        case FTS_NS:
+            LogWarning(__PRETTY_FUNCTION__
+                       << ": couldn't get stat info for file: "
+                       << ftsent->fts_path
+                       << ". The error was: "
+                       << strerror(ftsent->fts_errno));
+            rv = false;
+            break;
+        case FTS_DOT:
+        case FTS_DNR:
+        case FTS_ERR:
+        default:
+            LogWarning(__PRETTY_FUNCTION__
+                       << ": traversal failed with error: "
+                       << strerror(ftsent->fts_errno));
+            rv = false;
+            break;
         }
     }
 
         }
     }
 
-    return true;
+    if (fts_close(fts) == -1) {
+        error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
+                                       << strerror(error));
+        rv = false;
+    }
+    return rv;
 }
 
 }
 
-bool _WrtUtilRemoveDir(const char* path)
+bool WrtUtilFileExists(const std::string &path)
 {
 {
-    DIR* dir = NULL;
-    struct dirent* ptr = NULL;
-    char childPath[MAX_WIDGET_PATH_LENGTH + 1] = { 0 };
-    if (path == NULL) {
-        LogWarning("Path is null");
-        return false;
-    }
-    dir = opendir(path);
-    if (NULL != dir) {
-        while ((ptr = readdir(dir)) != NULL) {
-            if ((!strcmp(ptr->d_name, ".")) || (!strcmp(ptr->d_name, ".."))) {
-                continue;
-            }
-            int len = strlen(path);
-            if (path[len - 1] == '/') {
-                snprintf(childPath,
-                         MAX_WIDGET_PATH_LENGTH,
-                         "%s%s",
-                         path,
-                         ptr->d_name);
-            } else {
-                snprintf(childPath,
-                         MAX_WIDGET_PATH_LENGTH,
-                         "%s/%s",
-                         path,
-                         ptr->d_name);
-            }
-            if (ptr->d_type == DT_DIR) {
-                if (!_WrtUtilRemoveDir(childPath)) {
-                    closedir(dir);
-                    return false;
-                }
-            } else {
-                if (unlink(childPath) != 0) {
-                    closedir(dir);
-                    LogWarning("Failed to remove file " << childPath);
-                    return false;
-                }
-            }
-        }
-        closedir(dir);
-    } else if (errno == ENOTDIR) {
-        if (unlink(path) != 0) {
-            LogWarning("Failed to remove file " << path);
-            return false;
-        }
-        return true;
-    } else if (errno == ENOENT) { //not exist
-        LogWarning("Cannot remove non existent directory " << path);
-        return true;
+    struct stat tmp;
+    if (stat(path.c_str(), &tmp) == 0) {
+        return S_ISREG(tmp.st_mode);
     } else {
     } else {
-        LogWarning("Can't remove directory " << path);
         return false;
     }
         return false;
     }
-    if (rmdir(path) != 0) {
-        LogWarning("Removing directory failed :" << path << " errno: " << errno);
-        return false;
-    }
-
-    return true;
 }
 
 }
 
-bool
-_WrtUtilStringToLower(const char* str,
-        char** lowerStr)
+bool WrtUtilDirExists(const std::string &path)
 {
 {
-    if (!str || !lowerStr) {
-        return true;
-    }
-
-    char* cur = NULL;
-    int length = strlen(str);
-
-    *lowerStr = (char*)malloc(length + 1);
-
-    if (!(*lowerStr)) {
+    struct stat tmp;
+    if (stat(path.c_str(), &tmp) == 0) {
+        return S_ISDIR(tmp.st_mode);
+    } else {
         return false;
     }
         return false;
     }
-
-    memset(*lowerStr, 0, length + 1);
-    strncpy(*lowerStr, str, length);
-
-    cur = *lowerStr;
-
-    while (*str != '\0') {
-        *cur++ = tolower(*str++);
-        //cur++;
-    }
-
-    return true;
 }
 
 }
 
index 82403c9..cf1034f 100644 (file)
@@ -1,3 +1,5 @@
+SET(TARGET_WRT_DAO_DB "Sqlite3DbWRT")
+
 ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_BINARY_DIR}/modules/widget_dao/database_checksum.h
    COMMAND ${CMAKE_SOURCE_DIR}/modules/widget_dao/orm/gen_db_md5.sh
 ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_BINARY_DIR}/modules/widget_dao/database_checksum.h
    COMMAND ${CMAKE_SOURCE_DIR}/modules/widget_dao/orm/gen_db_md5.sh
@@ -22,7 +24,7 @@ ADD_CUSTOM_COMMAND( OUTPUT .wrt.db-journal
    ARGS  ${CMAKE_CURRENT_BINARY_DIR}/.wrt.db-journal
    )
  
    ARGS  ${CMAKE_CURRENT_BINARY_DIR}/.wrt.db-journal
    )
  
-ADD_CUSTOM_TARGET(Sqlite3DbWRT ALL DEPENDS .wrt.db .wrt.db-journal)
+ADD_CUSTOM_TARGET(${TARGET_WRT_DAO_DB} ALL DEPENDS .wrt.db .wrt.db-journal)
 
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_db.sql
     DESTINATION share/wrt-engine/
 
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_db.sql
     DESTINATION share/wrt-engine/
@@ -33,7 +35,6 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_db.sql
 INCLUDE(FindPkgConfig)
 
 PKG_CHECK_MODULES(WRT_DAO_DEPS
 INCLUDE(FindPkgConfig)
 
 PKG_CHECK_MODULES(WRT_DAO_DEPS
-    cert-svc
     ecore
     appcore-efl
     libxml-2.0
     ecore
     appcore-efl
     libxml-2.0
@@ -45,7 +46,6 @@ set(WRT_DAO_RO_SOURCES
     dao/common_dao_types.cpp
     dao/feature_dao_read_only.cpp
     dao/global_dao_read_only.cpp
     dao/common_dao_types.cpp
     dao/feature_dao_read_only.cpp
     dao/global_dao_read_only.cpp
-    dao/global_config.cpp
     dao/path_builder.cpp
     dao/plugin_dao_read_only.cpp
     dao/property_dao_read_only.cpp
     dao/path_builder.cpp
     dao/plugin_dao_read_only.cpp
     dao/property_dao_read_only.cpp
@@ -62,8 +62,6 @@ set(WRT_DAO_RW_SOURCES
     dao/widget_dao.cpp
 )
 
     dao/widget_dao.cpp
 )
 
-ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION")
-
 SET(WRT_DAO_INCLUDE_DIRS
     ${PROJECT_SOURCE_DIR}/modules/widget_dao/include
     ${PROJECT_SOURCE_DIR}/modules/event/include
 SET(WRT_DAO_INCLUDE_DIRS
     ${PROJECT_SOURCE_DIR}/modules/widget_dao/include
     ${PROJECT_SOURCE_DIR}/modules/event/include
@@ -71,16 +69,18 @@ SET(WRT_DAO_INCLUDE_DIRS
     ${PROJECT_SOURCE_DIR}/modules/core/include
     ${PROJECT_SOURCE_DIR}/modules/db/include
     ${PROJECT_SOURCE_DIR}/modules/log/include
     ${PROJECT_SOURCE_DIR}/modules/core/include
     ${PROJECT_SOURCE_DIR}/modules/db/include
     ${PROJECT_SOURCE_DIR}/modules/log/include
-    ${WRT_DAO_DEPS_INCLUDE_DIRS}
-    )
+    ${PROJECT_SOURCE_DIR}/modules/localization/include
+)
 
 INCLUDE_DIRECTORIES(${WRT_DAO_INCLUDE_DIRS})
 
 INCLUDE_DIRECTORIES(${WRT_DAO_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES(SYSTEM ${WRT_DAO_DEPS_INCLUDE_DIRS})
 
 ADD_LIBRARY(${TARGET_WRT_DAO_RO_LIB} SHARED
             ${WRT_DAO_RO_SOURCES}
 )
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RO_LIB} PROPERTIES
 
 ADD_LIBRARY(${TARGET_WRT_DAO_RO_LIB} SHARED
             ${WRT_DAO_RO_SOURCES}
 )
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RO_LIB} PROPERTIES
-    SOVERSION ${VERSION})
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION})
 
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RO_LIB} PROPERTIES
                       COMPILE_FLAGS -fPIC)
 
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RO_LIB} PROPERTIES
                       COMPILE_FLAGS -fPIC)
@@ -92,11 +92,13 @@ target_link_libraries(${TARGET_WRT_DAO_RO_LIB}
     ${TARGET_DPL_EFL}
     ${TARGET_DPL_DB_EFL}
     ${WRT_DAO_DEPS_LIBRARIES})
     ${TARGET_DPL_EFL}
     ${TARGET_DPL_DB_EFL}
     ${WRT_DAO_DEPS_LIBRARIES})
+ADD_DEPENDENCIES(${TARGET_WRT_DAO_RO_LIB} ${TARGET_WRT_DAO_DB})
 
 ADD_LIBRARY(${TARGET_WRT_DAO_RW_LIB} SHARED ${WRT_DAO_RW_SOURCES})
 
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RW_LIB} PROPERTIES
 
 ADD_LIBRARY(${TARGET_WRT_DAO_RW_LIB} SHARED ${WRT_DAO_RW_SOURCES})
 
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RW_LIB} PROPERTIES
-    SOVERSION ${VERSION})
+    SOVERSION ${API_VERSION} 
+ VERSION ${VERSION})
 
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RW_LIB} PROPERTIES COMPILE_FLAGS -fPIC)
 
 
 SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RW_LIB} PROPERTIES COMPILE_FLAGS -fPIC)
 
@@ -105,16 +107,13 @@ SET_TARGET_PROPERTIES(${TARGET_WRT_DAO_RW_LIB} PROPERTIES
 
 target_link_libraries(${TARGET_WRT_DAO_RW_LIB}
     ${TARGET_WRT_DAO_RO_LIB})
 
 target_link_libraries(${TARGET_WRT_DAO_RW_LIB}
     ${TARGET_WRT_DAO_RO_LIB})
+ADD_DEPENDENCIES(${TARGET_WRT_DAO_RW_LIB} ${TARGET_WRT_DAO_DB})
 
 INSTALL(TARGETS ${TARGET_WRT_DAO_RO_LIB}
 
 INSTALL(TARGETS ${TARGET_WRT_DAO_RO_LIB}
-    DESTINATION lib
-    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
-       )
+    DESTINATION lib)
 
 INSTALL(TARGETS ${TARGET_WRT_DAO_RW_LIB}
 
 INSTALL(TARGETS ${TARGET_WRT_DAO_RW_LIB}
-    DESTINATION lib
-    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
-       )
+    DESTINATION lib)
 
 INSTALL(FILES
     include/dpl/wrt-dao-ro/config_parser_data.h
 
 INSTALL(FILES
     include/dpl/wrt-dao-ro/config_parser_data.h
@@ -127,10 +126,12 @@ INSTALL(FILES
     include/dpl/wrt-dao-ro/plugin_dao_read_only.h
     include/dpl/wrt-dao-ro/property_dao_read_only.h
     include/dpl/wrt-dao-ro/widget_config.h
     include/dpl/wrt-dao-ro/plugin_dao_read_only.h
     include/dpl/wrt-dao-ro/property_dao_read_only.h
     include/dpl/wrt-dao-ro/widget_config.h
+    include/dpl/wrt-dao-ro/vconf_config.h
     include/dpl/wrt-dao-ro/widget_dao_read_only.h
     include/dpl/wrt-dao-ro/widget_dao_read_only.h
+    include/dpl/wrt-dao-ro/wrt_db_types.h
     include/dpl/wrt-dao-ro/WrtDatabase.h
     DESTINATION include/dpl-efl/dpl/wrt-dao-ro
     include/dpl/wrt-dao-ro/WrtDatabase.h
     DESTINATION include/dpl-efl/dpl/wrt-dao-ro
-       )
+    )
 
 INSTALL(FILES
     include/dpl/wrt-dao-rw/feature_dao.h
 
 INSTALL(FILES
     include/dpl/wrt-dao-rw/feature_dao.h
index f3fabe6..1cf6773 100644 (file)
@@ -13,7 +13,7 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 #include <dpl/db/thread_database_support.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 #include <dpl/db/thread_database_support.h>
@@ -23,7 +23,6 @@
 #include <dpl/wrt-dao-ro/global_config.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/global_config.h>
 
 namespace WrtDB {
-
 const char* WrtDatabase::Address()
 {
     using namespace WrtDB;
 const char* WrtDatabase::Address()
 {
     using namespace WrtDB;
@@ -36,12 +35,17 @@ DPL::DB::SqlConnection::Flag::Type WrtDatabase::Flags()
 }
 
 DPL::DB::ThreadDatabaseSupport WrtDatabase::m_interface(
 }
 
 DPL::DB::ThreadDatabaseSupport WrtDatabase::m_interface(
-        WrtDatabase::Address(),
-        WrtDatabase::Flags());
+    WrtDatabase::Address(),
+    WrtDatabase::Flags());
+
+void WrtDatabase::attachToThreadRO()
+{
+    m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RO);
+}
 
 
-void WrtDatabase::attachToThread()
+void WrtDatabase::attachToThreadRW()
 {
 {
-    m_interface.AttachToThread();
+    m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
 }
 
 void WrtDatabase::detachFromThread()
 }
 
 void WrtDatabase::detachFromThread()
@@ -58,5 +62,4 @@ bool WrtDatabase::CheckTableExist(const char *name)
 {
     return m_interface.CheckTableExist(name);
 }
 {
     return m_interface.CheckTableExist(name);
 }
-
 }
 }
index 94e1222..7c0b8c3 100644 (file)
  * @version 1.0
  * @brief   This file contains the implementation of common data types for wrtdb
  */
  * @version 1.0
  * @brief   This file contains the implementation of common data types for wrtdb
  */
-
-#include <dpl/wrt-dao-ro/common_dao_types.h>
-
-#include <dpl/log/log.h>
-
-namespace WrtDB {
-namespace Powder {
-
-Description::LevelEntry::LevelEntry(LevelEnum level) :
-    level(level)
-{
-}
-
-bool Description::LevelEntry::isContextValid(LevelEnum level,
-        const DPL::OptionalString& aContext) const
-{
-    if (!aContext) {
-        return level < level;
-    } else {
-        Context::const_iterator iter = context.find(*aContext);
-        if (iter != context.end()) {
-            return level < level;
-        } else {
-            return true;
-        }
-    }
-}
-
-bool Description::CategoryEntry::isCategoryValid(LevelEntry& aReason,
-        LevelEnum aLevel,
-        const DPL::OptionalString& aContext) const
-{
-    for (LevelsContainer::const_iterator iter = levels.begin();
-         iter != levels.end(); ++iter) {
-        if (!iter->isContextValid(aLevel, aContext)) {
-            aReason = *iter;
-            return false;
-        }
-    }
-    return true;
-}
-}
-
-namespace ChildProtection
-{
-
-PowderRules::CategoryRule::CategoryRule(const DPL::String& aCategory,
-        Powder::Description::LevelEnum aLevel,
-        const DPL::OptionalString& aContext) :
-    category(aCategory),
-    level(aLevel),
-    context(aContext)
-{
-}
-
-PowderRules::PowderResult::PowderResult(InvalidReason aReason,
-        const Powder::Description::LevelEntry& anInvalidDescription,
-        const CategoryRule& anInvalidRule) :
-    invalidDescription(anInvalidDescription),
-    invalidRule(anInvalidRule),
-    reason(aReason)
-{
-}
-
-//! Function checks if rule is fulfilled by description
-//! \param[in] rule checked rule
-//! \param[in] description
-//! \retval true rule is valid
-//! \retval false rule is invalid
-PowderRules::ResultPair PowderRules::isRuleValidForDescription(
-        const CategoryRule& aRule,
-        const Powder::Description& aDescription) const
-{
-    Powder::Description::CategoryEntries::const_iterator
-        iter = aDescription.categories.find(aRule.category);
-    if (iter != aDescription.categories.end()) {
-        Powder::Description::LevelEntry invalidDescription;
-        if (!iter->second.isCategoryValid(invalidDescription, aRule.level,
-                                          aRule.context)) {
-            LogWarning("Widget forbidden for children detected");
-            return std::make_pair(false,
-                                  PowderResult(PowderResult::InvalidRule,
-                                               invalidDescription,
-                                               aRule));
-        } else {
-            return std::make_pair(true, PowderResult());
-        }
-    } else {
-        return std::make_pair(true, PowderResult());
-    }
-}
-
-//! Function checks if age limit is fulfilled by description
-//! \param[in] description
-//! \retval true age is valid
-//! \retval false age is invalid
-PowderRules::ResultPair PowderRules::isAgeValidForDescription(
-        const Powder::Description& aDescription) const
-{
-    if (!ageLimit) {
-        return std::make_pair(true, PowderResult());
-    } else {
-        if (!!aDescription.ageRating) {
-            if (*aDescription.ageRating <= *ageLimit) {
-                return std::make_pair(true, PowderResult());
-            } else {
-                return std::make_pair(false,
-                                      PowderResult(PowderResult::InvalidAge));
-            }
-        } else {
-            if (!isAgeRatingRequired) {
-                return std::make_pair(true, PowderResult());
-            } else {
-                return std::make_pair(
-                           false,
-                           PowderResult(PowderResult::AgeRatingNotSet));
-            }
-        }
-    }
-}
-
-//! Function check if Widget description is valid for ChildProtection
-//! configuration
-//! \param description widget description
-//! \retval true widget is valid
-//! \retval false widget is invalid
-PowderRules::ResultPair PowderRules::isDescriptionValid(
-        const Powder::Description& aDescription) const
-{
-    ResultPair powderResult;
-    for (RulesContainer::const_iterator iter = rules.begin();
-         iter != rules.end(); ++iter) {
-        powderResult = isRuleValidForDescription(*iter, aDescription);
-        if (!powderResult.first) {
-            return powderResult;
-        }
-    }
-    return isAgeValidForDescription(aDescription);
-}
-
-}
-} // namespace WrtDB
+#include <stddef.h>
+namespace WrtDB {} // namespace WrtDB
index d2550cc..eccbe40 100644 (file)
  * @version     0.1
  * @brief
  */
  * @version     0.1
  * @brief
  */
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/log/log.h>
 #include <libxml/xmlreader.h>
 #include <libxml/xmlstring.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/log/log.h>
 #include <libxml/xmlreader.h>
 #include <libxml/xmlstring.h>
 
 namespace WrtDB {
+bool IsSpace(const xmlChar* str);
+bool CopyChar(xmlChar* out, xmlChar* in);
 
 bool IsSpace(const xmlChar* str)
 {
 
 bool IsSpace(const xmlChar* str)
 {
@@ -87,6 +90,8 @@ bool IsSpace(const xmlChar* str)
                 case 0xa9:
                 case 0xaf:
                     return true;
                 case 0xa9:
                 case 0xaf:
                     return true;
+                default:
+                    return false;
                 }
             case 0x81:
                 if (*(str + 2) == 0x9f) {
                 }
             case 0x81:
                 if (*(str + 2) == 0x9f) {
@@ -115,7 +120,7 @@ bool IsSpace(const xmlChar* str)
 }
 
 bool CopyChar(xmlChar* out,
 }
 
 bool CopyChar(xmlChar* out,
-        xmlChar* in)
+              xmlChar* in)
 {
     int size = xmlUTF8Size(in);
     switch (size) {
 {
     int size = xmlUTF8Size(in);
     switch (size) {
@@ -146,7 +151,7 @@ void NormalizeString(DPL::String& str)
     str = *opt;
 }
 
     str = *opt;
 }
 
-void NormalizeString (DPL::Optional<DPL::String>& txt)
+void NormalizeString (DPL::Optional<DPL::String>& txt, bool isTrimSpace)
 {
     if (!!txt) {
         std::string tmp = DPL::ToUTF8String(*txt);
 {
     if (!!txt) {
         std::string tmp = DPL::ToUTF8String(*txt);
@@ -176,7 +181,7 @@ void NormalizeString (DPL::Optional<DPL::String>& txt)
                 if (c[0] == 0x0) {
                     break;
                 }
                 if (c[0] == 0x0) {
                     break;
                 }
-                if (first) {
+                if (first && !isTrimSpace) {
                     xmlChar space[6] = { 0x20 };
                     CopyChar(s, space);
                     s += xmlUTF8Size(s);
                     xmlChar space[6] = { 0x20 };
                     CopyChar(s, space);
                     s += xmlUTF8Size(s);
@@ -193,6 +198,11 @@ void NormalizeString (DPL::Optional<DPL::String>& txt)
     }
 }
 
     }
 }
 
+void NormalizeAndTrimSpaceString(DPL::OptionalString& txt)
+{
+    NormalizeString(txt, true);
+}
+
 bool ConfigParserData::Param::operator==(const Param& other) const
 {
     return name == other.name && value == other.value;
 bool ConfigParserData::Param::operator==(const Param& other) const
 {
     return name == other.name && value == other.value;
@@ -293,6 +303,36 @@ bool ConfigParserData::Feature::operator<=(const Feature& other) const
     return paramsList <= other.paramsList;
 }
 
     return paramsList <= other.paramsList;
 }
 
+bool ConfigParserData::Privilege::operator==(const Privilege& other) const
+{
+    return name == other.name;
+}
+
+bool ConfigParserData::Privilege::operator!=(const Privilege& other) const
+{
+    return name != other.name;
+}
+
+bool ConfigParserData::Privilege::operator >(const Privilege& other) const
+{
+    return name > other.name;
+}
+
+bool ConfigParserData::Privilege::operator>=(const Privilege& other) const
+{
+    return name >= other.name;
+}
+
+bool ConfigParserData::Privilege::operator <(const Privilege& other) const
+{
+    return name < other.name;
+}
+
+bool ConfigParserData::Privilege::operator<=(const Privilege& other) const
+{
+    return name < other.name;
+}
+
 bool ConfigParserData::Icon::operator==(const Icon& other) const
 {
     return src == other.src;
 bool ConfigParserData::Icon::operator==(const Icon& other) const
 {
     return src == other.src;
@@ -377,13 +417,13 @@ bool ConfigParserData::AccessInfo::operator <(const AccessInfo& info) const
 bool ConfigParserData::Setting::operator==(const Setting& other) const
 {
     return m_name == other.m_name &&
 bool ConfigParserData::Setting::operator==(const Setting& other) const
 {
     return m_name == other.m_name &&
-        m_value == other.m_value;
+           m_value == other.m_value;
 }
 
 bool ConfigParserData::Setting::operator!=(const Setting& other) const
 {
     return m_name != other.m_name ||
 }
 
 bool ConfigParserData::Setting::operator!=(const Setting& other) const
 {
     return m_name != other.m_name ||
-        m_value != other.m_value;
+           m_value != other.m_value;
 }
 
 bool ConfigParserData::Setting::operator >(const Setting& other) const
 }
 
 bool ConfigParserData::Setting::operator >(const Setting& other) const
@@ -409,16 +449,36 @@ bool ConfigParserData::Setting::operator<=(const Setting& other) const
 bool ConfigParserData::ServiceInfo::operator== (const ServiceInfo& info) const
 {
     return m_src == info.m_src &&
 bool ConfigParserData::ServiceInfo::operator== (const ServiceInfo& info) const
 {
     return m_src == info.m_src &&
-    m_operation == info.m_operation &&
-    m_scheme == info.m_scheme &&
-    m_mime == info.m_mime;
+           m_operation == info.m_operation &&
+           m_scheme == info.m_scheme &&
+           m_mime == info.m_mime;
 }
 
 bool ConfigParserData::ServiceInfo::operator!= (const ServiceInfo& info) const
 {
     return m_src != info.m_src &&
 }
 
 bool ConfigParserData::ServiceInfo::operator!= (const ServiceInfo& info) const
 {
     return m_src != info.m_src &&
-    m_operation != info.m_operation &&
-    m_scheme != info.m_scheme &&
-    m_mime != info.m_mime;
+           m_operation != info.m_operation &&
+           m_scheme != info.m_scheme &&
+           m_mime != info.m_mime;
+}
+
+bool ConfigParserData::LiveboxInfo::operator==(const LiveboxInfo& other) const
+{
+    return m_liveboxId == other.m_liveboxId &&
+           m_autoLaunch == other.m_autoLaunch &&
+           m_updatePeriod == other.m_updatePeriod &&
+           m_primary == other.m_primary &&
+           m_label == other.m_label &&
+           m_icon == other.m_icon;
+}
+
+bool ConfigParserData::LiveboxInfo::operator!=(const LiveboxInfo& other) const
+{
+    return m_liveboxId != other.m_liveboxId &&
+           m_autoLaunch != other.m_autoLaunch &&
+           m_updatePeriod != other.m_updatePeriod &&
+           m_primary != other.m_primary &&
+           m_label != other.m_label &&
+           m_icon != other.m_icon;
 }
 } // namespace WrtDB
 }
 } // namespace WrtDB
index 60c7151..ba12c24 100644 (file)
@@ -22,7 +22,7 @@
  * @version 1.0
  * @brief   This file contains the definition of feature configuration.
  */
  * @version 1.0
  * @brief   This file contains the definition of feature configuration.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-rw/feature_dao.h>
 #include <dpl/foreach.h>
 #include <dpl/db/orm.h>
 #include <dpl/wrt-dao-rw/feature_dao.h>
 #include <dpl/foreach.h>
 #include <dpl/db/orm.h>
 
 namespace WrtDB {
 namespace FeatureDAO {
 
 namespace WrtDB {
 namespace FeatureDAO {
-
-const int STRANGE_FEATURE_PROPERTIES_ID = 0;
-
 FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
                               const DbPluginHandle pluginHandle)
 {
     Try
     {
         LogDebug("Registering Feature " << feature.m_name);
 FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
                               const DbPluginHandle pluginHandle)
 {
     Try
     {
         LogDebug("Registering Feature " << feature.m_name);
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         if (FeatureDAOReadOnly::isFeatureInstalled(feature.m_name)) {
             LogError(" >> Feature " << feature.m_name <<
 
         if (FeatureDAOReadOnly::isFeatureInstalled(feature.m_name)) {
             LogError(" >> Feature " << feature.m_name <<
@@ -66,7 +64,7 @@ FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
         }
 
         FeatureHandle featureHandle =
         }
 
         FeatureHandle featureHandle =
-                FeatureDAOReadOnly(feature.m_name).GetFeatureHandle();
+            FeatureDAOReadOnly(feature.m_name).GetFeatureHandle();
 
         //register device capabilities
         // Device Capabilities is unused in current version
 
         //register device capabilities
         // Device Capabilities is unused in current version
@@ -78,7 +76,9 @@ FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
                 LogInfo("    |    |--DeviceCap " << *itdev <<
                         " already installed!");
 
                 LogInfo("    |    |--DeviceCap " << *itdev <<
                         " already installed!");
 
-                WRT_DB_SELECT(select, DeviceCapabilities, &WrtDatabase::interface())
+                WRT_DB_SELECT(select,
+                              DeviceCapabilities,
+                              &WrtDatabase::interface())
 
                 select->Where(Equals<DeviceCapabilities::DeviceCapName>(
                                   DPL::FromUTF8String(*itdev)));
 
                 select->Where(Equals<DeviceCapabilities::DeviceCapName>(
                                   DPL::FromUTF8String(*itdev)));
@@ -91,16 +91,20 @@ FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
                 DeviceCapabilities::Row row;
                 row.Set_DeviceCapName(DPL::FromUTF8String(*itdev));
 
                 DeviceCapabilities::Row row;
                 row.Set_DeviceCapName(DPL::FromUTF8String(*itdev));
 
-                WRT_DB_INSERT(insert, DeviceCapabilities, &WrtDatabase::interface())
+                WRT_DB_INSERT(insert,
+                              DeviceCapabilities,
+                              &WrtDatabase::interface())
                 insert->Values(row);
                 insert->Values(row);
-                deviceCapID = insert->Execute();
+                deviceCapID = static_cast<int>(insert->Execute());
             }
 
             FeatureDeviceCapProxy::Row row;
             row.Set_FeatureUUID(featureHandle);
             row.Set_DeviceCapID(deviceCapID);
 
             }
 
             FeatureDeviceCapProxy::Row row;
             row.Set_FeatureUUID(featureHandle);
             row.Set_DeviceCapID(deviceCapID);
 
-            WRT_DB_INSERT(insert, FeatureDeviceCapProxy, &WrtDatabase::interface())
+            WRT_DB_INSERT(insert,
+                          FeatureDeviceCapProxy,
+                          &WrtDatabase::interface())
             insert->Values(row);
             insert->Execute();
         }
             insert->Values(row);
             insert->Execute();
         }
@@ -115,49 +119,46 @@ FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
     }
 }
 
     }
 }
 
-FeatureHandle RegisterStrangeFeature(const std::string& featureName)
+void UnregisterFeature(FeatureHandle featureHandle)
 {
     Try
     {
 {
     Try
     {
-        LogDebug("Registering Feature " << featureName);
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        LogDebug("Unregistering Feature " << featureHandle);
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
 
-        if (FeatureDAOReadOnly::isFeatureInstalled(featureName)) {
-            LogError(" >> Feature " << featureName <<
-                     " is already registered.");
-            transaction.Commit();
-            return -1;
+        if (FeatureDAOReadOnly::isFeatureInstalled(featureHandle)) {
+            LogError("Feature handle is invalid");
+            return;
         }
 
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
 
         }
 
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
 
-        //register feature
-        LogInfo("    |-- Registering feature " << featureName);
-
-        FeaturesList::Row row;
-        row.Set_FeatureName(DPL::FromUTF8String(featureName));
+        // Unregister DeviceCapabilities
+        FeatureDAOReadOnly::DeviceCapabilitiesList capabilitiesList =
+            FeatureDAOReadOnly(featureHandle).GetDeviceCapabilities();
 
 
-        // PluginPropertiesId '0' is not used as PluginPropertiesId for normal features(calendar, contact....).
-        // PluginPropertiesId for normal features start from '1'
-        row.Set_PluginPropertiesId(STRANGE_FEATURE_PROPERTIES_ID);
-
-        WRT_DB_INSERT(insert, FeaturesList, &WrtDatabase::interface())
-        insert->Values(row);
-        insert->Execute();
-
-        FeatureHandle featureHandle =
-            FeatureDAOReadOnly(featureName).GetFeatureHandle();
+        FOREACH(it, capabilitiesList) {
+            WRT_DB_DELETE(del, DeviceCapabilities, &WrtDatabase::interface())
+            del->Where(
+                Equals<DeviceCapabilities::DeviceCapName>(
+                    DPL::FromUTF8String(*it)));
+            del->Execute();
+        }
 
 
+        // Unregister Feature
+        WRT_DB_DELETE(del, FeaturesList, &WrtDatabase::interface())
+        del->Where(Equals<FeaturesList::FeatureUUID>(featureHandle));
+        del->Execute();
         transaction.Commit();
 
         transaction.Commit();
 
-        return featureHandle;
+        return;
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
-                   "Failure during Registering Feature");
+                   "Fail to unregister Feature");
     }
 }
     }
 }
-
 } // namespace FeatureDAO
 } // namespace WrtDB
 } // namespace FeatureDAO
 } // namespace WrtDB
index adf11e9..cab3fba 100644 (file)
@@ -19,7 +19,7 @@
  * @version 1.0
  * @brief   This file contains the implementation of feature dao read only
  */
  * @version 1.0
  * @brief   This file contains the implementation of feature dao read only
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
 #include <sstream>
 #include <dpl/log/log.h>
 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
 #include <sstream>
 #include <dpl/log/log.h>
@@ -30,7 +30,6 @@
 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
 
 namespace WrtDB {
-
 FeatureDAOReadOnly::FeatureDAOReadOnly(FeatureHandle featureHandle) :
     m_featureHandle(featureHandle)
 {
 FeatureDAOReadOnly::FeatureDAOReadOnly(FeatureHandle featureHandle) :
     m_featureHandle(featureHandle)
 {
@@ -63,39 +62,20 @@ FeatureDAOReadOnly::FeatureDAOReadOnly(const std::string &featureName)
 
 #define GET_PLUGIN_DATA(func)                                           \
     Try {                                                               \
 
 #define GET_PLUGIN_DATA(func)                                           \
     Try {                                                               \
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); \
-        LogDebug(# func << ". FeatureHandle: " << m_featureHandle);     \
+        DPL::DB::ORM::wrt::ScopedTransaction transaction( \
+            &WrtDatabase::interface()); \
+        LogDebug(#func << ". FeatureHandle: " << m_featureHandle);     \
         std::string ret = PluginDAOReadOnly(GetPluginHandle()).func();  \
         transaction.Commit();                                           \
         return ret;                                                     \
     }                                                                   \
     Catch(DPL::DB::SqlConnection::Exception::Base) {                        \
         std::ostringstream failure("Failure during ");                  \
         std::string ret = PluginDAOReadOnly(GetPluginHandle()).func();  \
         transaction.Commit();                                           \
         return ret;                                                     \
     }                                                                   \
     Catch(DPL::DB::SqlConnection::Exception::Base) {                        \
         std::ostringstream failure("Failure during ");                  \
-        failure << # func;                                              \
+        failure << #func;                                              \
         ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,        \
         ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,        \
-                failure.str());                                         \
+                   failure.str());                                         \
     }
 
     }
 
-std::string FeatureDAOReadOnly::GetInstallURI() const
-{
-    GET_PLUGIN_DATA(getInstallURI)
-}
-
-std::string FeatureDAOReadOnly::GetKeyCn() const
-{
-    GET_PLUGIN_DATA(getKeyCn)
-}
-
-std::string FeatureDAOReadOnly::GetRootKey() const
-{
-    GET_PLUGIN_DATA(getRootKey)
-}
-
-std::string FeatureDAOReadOnly::GetRootKeyFingerprint() const
-{
-    GET_PLUGIN_DATA(getRootKeyFingerprint)
-}
-
 std::string FeatureDAOReadOnly::GetLibraryPath() const
 {
     GET_PLUGIN_DATA(getLibraryPath)
 std::string FeatureDAOReadOnly::GetLibraryPath() const
 {
     GET_PLUGIN_DATA(getLibraryPath)
@@ -228,7 +208,7 @@ bool FeatureDAOReadOnly::isFeatureInstalled(FeatureHandle handle)
 }
 
 bool FeatureDAOReadOnly::isDeviceCapabilityInstalled(
 }
 
 bool FeatureDAOReadOnly::isDeviceCapabilityInstalled(
-        const std::string &deviceCapName)
+    const std::string &deviceCapName)
 {
     LogDebug("Check if DeviceCap is installed. Name: " << deviceCapName);
     Try {
 {
     LogDebug("Check if DeviceCap is installed. Name: " << deviceCapName);
     Try {
@@ -257,11 +237,14 @@ FeatureDAOReadOnly::GetDeviceCapabilities() const
 {
     Try {
         LogDebug("Get DeviceCap. FeatureHandle: " << m_featureHandle);
 {
     Try {
         LogDebug("Get DeviceCap. FeatureHandle: " << m_featureHandle);
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
 
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(selectDevCP, FeatureDeviceCapProxy, &WrtDatabase::interface())
+        WRT_DB_SELECT(selectDevCP,
+                      FeatureDeviceCapProxy,
+                      &WrtDatabase::interface())
         selectDevCP->Where(Equals<FeatureDeviceCapProxy::FeatureUUID>(
                                m_featureHandle));
 
         selectDevCP->Where(Equals<FeatureDeviceCapProxy::FeatureUUID>(
                                m_featureHandle));
 
@@ -271,7 +254,9 @@ FeatureDAOReadOnly::GetDeviceCapabilities() const
             selectDevCP->GetValueList<FeatureDeviceCapProxy::DeviceCapID>();
         FOREACH(devCId, deviceIDs)
         {
             selectDevCP->GetValueList<FeatureDeviceCapProxy::DeviceCapID>();
         FOREACH(devCId, deviceIDs)
         {
-            WRT_DB_SELECT(selectDevC, DeviceCapabilities, &WrtDatabase::interface())
+            WRT_DB_SELECT(selectDevC,
+                          DeviceCapabilities,
+                          &WrtDatabase::interface())
             selectDevC->Where(Equals<DeviceCapabilities::DeviceCapID>(*devCId));
 
             DPL::String devNames =
             selectDevC->Where(Equals<DeviceCapabilities::DeviceCapID>(*devCId));
 
             DPL::String devNames =
@@ -290,7 +275,7 @@ FeatureDAOReadOnly::GetDeviceCapabilities() const
 }
 
 FeatureHandleListPtr FeatureDAOReadOnly::GetFeatureHandleListForPlugin(
 }
 
 FeatureHandleListPtr FeatureDAOReadOnly::GetFeatureHandleListForPlugin(
-        DbPluginHandle pluginHandle)
+    DbPluginHandle pluginHandle)
 {
     LogDebug("Getting FeatureHandle list for pluginHandle: " << pluginHandle);
     Try {
 {
     LogDebug("Getting FeatureHandle list for pluginHandle: " << pluginHandle);
     Try {
@@ -314,9 +299,108 @@ FeatureHandleListPtr FeatureDAOReadOnly::GetFeatureHandleListForPlugin(
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(
-                FeatureDAOReadOnly::Exception::DatabaseError,
-                "Failure during getting FeatureHandle Set for plugin handle");
+            FeatureDAOReadOnly::Exception::DatabaseError,
+            "Failure during getting FeatureHandle Set for plugin handle");
+    }
+}
+
+FeatureDAOReadOnly::NameMap
+FeatureDAOReadOnly::GetNames()
+{
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, FeaturesList, &WrtDatabase::interface())
+
+        NameMap nameMap;
+
+        FeaturesList::Select::RowList rows = select->GetRowList();
+        FOREACH(rowIt, rows)
+        {
+            nameMap.insert(std::pair<FeatureHandle,
+                                     std::string>(rowIt->Get_FeatureUUID(),
+                                                  DPL::ToUTF8String(rowIt->
+                                                                        Get_FeatureName())));
+        }
+
+        return nameMap;
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+                   "Failure during getting GetNames");
     }
 }
 
     }
 }
 
+FeatureDAOReadOnly::DeviceCapabilitiesMap
+FeatureDAOReadOnly::GetDevCapWithFeatureHandle()
+{
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        DECLARE_COLUMN_TYPE_LIST()
+        SELECTED_COLUMN(FeatureDeviceCapProxy, FeatureUUID)
+        SELECTED_COLUMN(DeviceCapabilities, DeviceCapName)
+        DECLARE_COLUMN_TYPE_LIST_END(DevCapNameList)
+
+        WRT_DB_SELECT(select, FeatureDeviceCapProxy, &WrtDatabase::interface())
+        select->Join<DevCapNameList>(Equal<FeatureDeviceCapProxy::DeviceCapID,
+                                           DeviceCapabilities::DeviceCapID>());
+
+        DeviceCapabilitiesMap devCap;
+
+        std::list< CustomRow<DevCapNameList> > rowList =
+            select->GetCustomRowList< DevCapNameList, CustomRow<DevCapNameList> >();
+        FOREACH(rowIt, rowList)
+        {
+            FeatureHandle featureHandle =
+                (*rowIt).GetColumnData<FeatureDeviceCapProxy::FeatureUUID>();
+            std::string devName =
+                DPL::ToUTF8String((*rowIt).GetColumnData<DeviceCapabilities::
+                                                             DeviceCapName>());
+            devCap.insert(std::pair<FeatureHandle, std::string>(featureHandle,
+                                                                devName));
+        }
+
+        return devCap;
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+                   "Failure during getting DeviceCapabilities names");
+    }
+}
+
+FeatureDAOReadOnly::FeatureMap
+FeatureDAOReadOnly::GetFeatures(const std::list<std::string>& featureNames)
+{
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        std::set<typename FeaturesList::FeatureName::ColumnType> nameList;
+        FOREACH(nm, featureNames) {
+            nameList.insert(DPL::FromUTF8String(*nm));
+        }
+
+        WRT_DB_SELECT(select, FeaturesList, &WrtDatabase::interface())
+        select->Where(In<FeaturesList::FeatureName>(nameList));
+
+        FeatureMap featureMap;
+        FeatureData featureData;
+        FeaturesList::Select::RowList rows = select->GetRowList();
+        FOREACH(rowIt, rows) {
+            featureData.featureName = DPL::ToUTF8String(
+                    rowIt->Get_FeatureName());
+            featureData.pluginHandle = rowIt->Get_PluginPropertiesId();
+            featureMap.insert(std::pair<FeatureHandle, FeatureData>(
+                                  rowIt->Get_FeatureUUID(), featureData));
+        }
+
+        return featureMap;
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+                   "Failure during getting GetFeatures");
+    }
+}
 } // namespace WrtDB
 } // namespace WrtDB
index 6f1f406..0c22d90 100644 (file)
@@ -19,7 +19,7 @@
  * @version 1.0
  * @brief   This file contains the definition of global dao class.
  */
  * @version 1.0
  * @brief   This file contains the definition of global dao class.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-rw/global_dao.h>
 #include <dpl/log/log.h>
 #include <dpl/string.h>
 #include <dpl/wrt-dao-rw/global_dao.h>
 #include <dpl/log/log.h>
 #include <dpl/string.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
-
-void GlobalDAO::AddAdultBlackListElement(const DPL::String &url)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        if (IsElementOnAdultBlackList(url)) {
-            transaction.Commit();
-            return;
-        }
-
-        WRT_DB_INSERT(insert, ChildProtectionBlacklist, &WrtDatabase::interface())
-        ChildProtectionBlacklist::Row row;
-        row.Set_url(url);
-
-        insert->Values(row);
-        insert->Execute();
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to add element to AdultBlackList");
-    }
-}
-
-void GlobalDAO::RemoveAdultBlackListElement(const DPL::String &url)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_DELETE(deleteFrom, ChildProtectionBlacklist, &WrtDatabase::interface())
-
-        deleteFrom->Where(Equals<ChildProtectionBlacklist::url>(url));
-        deleteFrom->Execute();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to removed element from AdultBlackList");
-    }
-}
-
-void GlobalDAO::UpdateAdultBlackList(const DPL::String &oldUrl,
-                                     const DPL::String &newUrl)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        if (IsElementOnAdultBlackList(newUrl)) {
-            transaction.Commit();
-            return;
-        }
-        WRT_DB_UPDATE(update, ChildProtectionBlacklist, &WrtDatabase::interface())
-        ChildProtectionBlacklist::Row row;
-        row.Set_url(newUrl);
-
-        update->Where(Equals<ChildProtectionBlacklist::url>(oldUrl));
-        update->Values(row);
-        update->Execute();
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update an element in AdultBlackList");
-    }
-}
-
 void GlobalDAO::SetDeveloperMode(bool mode)
 {
     LogDebug("updating Developer mode to:" << mode);
 void GlobalDAO::SetDeveloperMode(bool mode)
 {
     LogDebug("updating Developer mode to:" << mode);
@@ -115,76 +48,6 @@ void GlobalDAO::SetDeveloperMode(bool mode)
     }
 }
 
     }
 }
 
-void GlobalDAO::AddDefferedWidgetPackageInstallation(const DPL::String &path)
-{
-    LogDebug("Adding widget package as defered. Path: " << path);
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        DefferedWidgetPackageInstallation::Row row;
-        row.Set_path(path);
-
-        WRT_DB_INSERT(insert, DefferedWidgetPackageInstallation, &WrtDatabase::interface())
-        insert->Values(row);
-        insert->Execute();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base){
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to add defered widget package");
-    }
-}
-
-void GlobalDAO::RemoveDefferedWidgetPackageInstallation(const DPL::String &path)
-{
-    LogDebug("Remove widget package from differed list. Path: " << path);
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_DELETE(del, DefferedWidgetPackageInstallation, &WrtDatabase::interface())
-        del->Where(Equals<DefferedWidgetPackageInstallation::path>(path));
-        del->Execute();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base){
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to remove defered widget package");
-    }
-}
-
-void GlobalDAO::SetParentalMode(bool parental_status)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        GlobalProperties::Row row;
-        row.Set_parental_mode(parental_status);
-        WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
-
-        update->Values(row);
-        update->Execute();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update Parental Mode");
-    }
-}
-
-void GlobalDAO::SetParentalAllowedAge(const DPL::OptionalInt& age)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-    Try {
-        typedef wrt::GlobalProperties::Row ParentalAllowedAgeRow;
-
-        ParentalAllowedAgeRow row;
-        row.Set_parental_allowed_age(age);
-        WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
-        update->Values(row);
-        update->Execute();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update Parental Mode");
-    }
-}
-
 void GlobalDAO::SetSecureByDefault(bool secure)
 {
     //If secure == true -> widget does not need to be signed
 void GlobalDAO::SetSecureByDefault(bool secure)
 {
     //If secure == true -> widget does not need to be signed
@@ -206,8 +69,9 @@ void GlobalDAO::SetSecureByDefault(bool secure)
 void GlobalDAO::setComplianceMode(bool mode)
 {
     LogDebug("Updating compliance mode to:" << mode);
 void GlobalDAO::setComplianceMode(bool mode)
 {
     LogDebug("Updating compliance mode to:" << mode);
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
         GlobalProperties::Row row;
         row.Set_compliance_mode(mode);
 
         GlobalProperties::Row row;
         row.Set_compliance_mode(mode);
 
@@ -215,7 +79,7 @@ void GlobalDAO::setComplianceMode(bool mode)
         update->Values(row);
         update->Execute();
     }
         update->Values(row);
         update->Execute();
     }
-    Catch (DPL::DB::SqlConnection::Exception::Base){
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
                    "Failed to update compliance mode");
     }
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
                    "Failed to update compliance mode");
     }
@@ -224,8 +88,9 @@ void GlobalDAO::setComplianceMode(bool mode)
 void GlobalDAO::setComplianceFakeImei(const std::string &imei)
 {
     LogDebug("Setting compliance fake IMEI: " << imei);
 void GlobalDAO::setComplianceFakeImei(const std::string &imei)
 {
     LogDebug("Setting compliance fake IMEI: " << imei);
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
         GlobalProperties::Row row;
         row.Set_compliance_fake_imei(DPL::FromASCIIString(imei));
 
         GlobalProperties::Row row;
         row.Set_compliance_fake_imei(DPL::FromASCIIString(imei));
 
@@ -233,7 +98,7 @@ void GlobalDAO::setComplianceFakeImei(const std::string &imei)
         update->Values(row);
         update->Execute();
     }
         update->Values(row);
         update->Execute();
     }
-    Catch (DPL::DB::SqlConnection::Exception::Base){
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
                    "Failed to update compliance fake IMEI");
     }
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
                    "Failed to update compliance fake IMEI");
     }
@@ -242,8 +107,9 @@ void GlobalDAO::setComplianceFakeImei(const std::string &imei)
 void GlobalDAO::setComplianceFakeMeid(const std::string &meid)
 {
     LogDebug("Setting compliance fake MEID: " << meid);
 void GlobalDAO::setComplianceFakeMeid(const std::string &meid)
 {
     LogDebug("Setting compliance fake MEID: " << meid);
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
         GlobalProperties::Row row;
         row.Set_compliance_fake_meid(DPL::FromASCIIString(meid));
 
         GlobalProperties::Row row;
         row.Set_compliance_fake_meid(DPL::FromASCIIString(meid));
 
@@ -251,111 +117,12 @@ void GlobalDAO::setComplianceFakeMeid(const std::string &meid)
         update->Values(row);
         update->Execute();
     }
         update->Values(row);
         update->Execute();
     }
-    Catch (DPL::DB::SqlConnection::Exception::Base){
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
                    "Failed to update compliance fake MEID");
     }
 }
 
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
                    "Failed to update compliance fake MEID");
     }
 }
 
-void GlobalDAO::AddCategoryRule(const ChildProtection::PowderRules::
-                                CategoryRule& powder)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        PowderRules::Row row;
-        row.Set_category(powder.category);
-        row.Set_level(powder.level);
-        row.Set_context(powder.context);
-
-        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
-        if (IsPowderRulePresent(powder)) {
-            transaction.Commit();
-            return;
-        }
-        WRT_DB_INSERT(insert, PowderRules, &WrtDatabase::interface())
-
-        insert->Values(row);
-        insert->Execute();
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to add POWDER rules");
-    }
-}
-
-void GlobalDAO::RemoveCategoryRule(const ChildProtection::PowderRules::
-                                   CategoryRule& powder)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        if (!powder.context.IsNull()) {
-            WRT_DB_DELETE(delWithContext, PowderRules, &WrtDatabase::interface())
-
-            delWithContext->Where(
-                And(Equals<PowderRules::category>(powder.category),
-                    And(Equals<PowderRules::level>(powder.level),
-                        Equals<PowderRules::context>(powder.context))));
-            delWithContext->Execute();
-        } else {
-            WRT_DB_DELETE(delWithoutContext, PowderRules, &WrtDatabase::interface())
-            delWithoutContext->Where(
-                And(Equals<PowderRules::category>(powder.category),
-                    And(Equals<PowderRules::level>(powder.level),
-                        Is<PowderRules::context>(powder.context))));
-            delWithoutContext->Execute();
-        }
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to remove POWDER rules");
-    }
-}
-
-void GlobalDAO::UpdateCategoryRule(
-        const ChildProtection::PowderRules::CategoryRule& oldRule,
-        const ChildProtection::PowderRules::CategoryRule& newRule)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        PowderRules::Row row;
-        row.Set_category(newRule.category);
-        row.Set_level(newRule.level);
-        row.Set_context(newRule.context);
-
-        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
-
-        if (IsPowderRulePresent(newRule)) {
-            transaction.Commit();
-            return;
-        }
-
-        if (!oldRule.context.IsNull()) {
-            WRT_DB_UPDATE(updateWithContext, PowderRules, &WrtDatabase::interface())
-            updateWithContext->Where(
-                And(Equals<PowderRules::category>(oldRule.category),
-                    And(Equals<PowderRules::level>(oldRule.level),
-                        Equals<PowderRules::context>(oldRule.context))));
-            updateWithContext->Values(row);
-            updateWithContext->Execute();
-        } else {
-            WRT_DB_UPDATE(updateWithoutContext, PowderRules, &WrtDatabase::interface())
-            updateWithoutContext->Where(
-                And(Equals<PowderRules::category>(oldRule.category),
-                    And(Equals<PowderRules::level>(oldRule.level),
-                        Is<PowderRules::context>(oldRule.context))));
-            updateWithoutContext->Values(row);
-            updateWithoutContext->Execute();
-        }
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Failed to update POWDER rules");
-    }
-}
-
 void GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NetworkAccessMode newMode)
 {
     LogDebug("updating home network data usage to:" << newMode);
 void GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NetworkAccessMode newMode)
 {
     LogDebug("updating home network data usage to:" << newMode);
@@ -394,41 +161,6 @@ void GlobalDAO::SetRoamingDataUsage(GlobalDAO::NetworkAccessMode newMode)
     }
 }
 
     }
 }
 
-void GlobalDAO::SetAutoSaveIdPasswd(const DPL::String &url,
-                                    const AutoSaveData &saveData)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        ScopedTransaction transaction(&WrtDatabase::interface());
-        AutoSaveIdPasswd::Row row;
-
-        row.Set_address(url);
-        row.Set_userId(saveData.userId);
-        row.Set_passwd(saveData.passwd);
-
-        DPL::Optional<GlobalDAO::AutoSaveData> savedData =
-            GetAutoSaveIdPasswd(url);
-
-        if (!savedData.IsNull()) {
-            WRT_DB_UPDATE(update, AutoSaveIdPasswd, &WrtDatabase::interface())
-
-            update->Where(Equals<AutoSaveIdPasswd::address>(url));
-            update->Values(row);
-            update->Execute();
-        } else {
-            WRT_DB_INSERT(insert, AutoSaveIdPasswd, &WrtDatabase::interface());
-            insert->Values(row);
-            insert->Execute();
-        }
-
-        transaction.Commit();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
-                   "Fail to register id, passwd for autosave");
-    }
-}
-
 void GlobalDAO::AddWhiteURI(const std::string &uri, bool subDomain)
 {
     LogDebug("Add White URI : " << uri);
 void GlobalDAO::AddWhiteURI(const std::string &uri, bool subDomain)
 {
     LogDebug("Add White URI : " << uri);
@@ -460,7 +192,8 @@ void GlobalDAO::RemoveWhiteURI(const std::string &uri)
         using namespace DPL::DB::ORM::wrt;
 
         WRT_DB_DELETE(deleteFrom, WidgetWhiteURIList, &WrtDatabase::interface())
         using namespace DPL::DB::ORM::wrt;
 
         WRT_DB_DELETE(deleteFrom, WidgetWhiteURIList, &WrtDatabase::interface())
-        deleteFrom->Where(Equals<WidgetWhiteURIList::uri>(DPL::FromASCIIString(uri)));
+        deleteFrom->Where(Equals<WidgetWhiteURIList::uri>(DPL::FromASCIIString(
+                                                              uri)));
         deleteFrom->Execute();
     } Catch(DPL::DB::SqlConnection::Exception::Base) {
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
         deleteFrom->Execute();
     } Catch(DPL::DB::SqlConnection::Exception::Base) {
         ReThrowMsg(GlobalDAO::Exception::DatabaseError,
@@ -468,4 +201,22 @@ void GlobalDAO::RemoveWhiteURI(const std::string &uri)
     }
 }
 
     }
 }
 
+void GlobalDAO::SetCookieSharingMode(bool mode)
+{
+    LogDebug("updating Cookie Sharing mode to:" << mode);
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        GlobalProperties::Row row;
+        row.Set_cookie_sharing_mode(mode);
+
+        WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
+        update->Values(row);
+        update->Execute();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(GlobalDAO::Exception::DatabaseError,
+                   "Failed to update Cookie Sharing Mode");
+    }
+}
 } // namespace WrtDB
 } // namespace WrtDB
index cb26a1e..d634523 100644 (file)
@@ -19,7 +19,7 @@
  * @version 1.0
  * @brief   This file contains the definition of global dao class.
  */
  * @version 1.0
  * @brief   This file contains the definition of global dao class.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
 
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
 
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
-
-ChildProtection::BlackList GlobalDAOReadOnly::GetAdultBlackList()
-{
-    LogDebug("Getting AdultBlackList");
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, ChildProtectionBlacklist, &WrtDatabase::interface())
-        std::list<DPL::String> list =
-            select->GetValueList<ChildProtectionBlacklist::url>();
-        ChildProtection::BlackList blacklist(list.begin(), list.end());
-        return blacklist;
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base){
-        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
-                   "Failed to get AdultBalckList");
-    }
-}
-
-bool GlobalDAOReadOnly::IsElementOnAdultBlackList(const DPL::String &url)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, ChildProtectionBlacklist, &WrtDatabase::interface())
-        select->Where(Equals<ChildProtectionBlacklist::url>(url));
-
-        return !select->GetRowList().empty();
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
-                   "Failure during checking if url is on pwoder black list");
-    }
-}
-
 bool GlobalDAOReadOnly::GetDeveloperMode()
 {
     LogDebug("Getting Developer mode");
 bool GlobalDAOReadOnly::GetDeveloperMode()
 {
     LogDebug("Getting Developer mode");
@@ -81,37 +47,6 @@ bool GlobalDAOReadOnly::GetDeveloperMode()
     }
 }
 
     }
 }
 
-WidgetPackageList GlobalDAOReadOnly::GetDefferedWidgetPackageInstallationList()
-{
-    LogDebug("Getting widget packages list defered for installation");
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, DefferedWidgetPackageInstallation, &WrtDatabase::interface())
-        return select->GetValueList<DefferedWidgetPackageInstallation::path>();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base){
-        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
-                   "Failed to get defered widget packages list");
-    }
-}
-
-bool GlobalDAOReadOnly::GetParentalMode()
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-    WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
-    return select->GetSingleValue<GlobalProperties::parental_mode>();
-}
-
-DPL::OptionalInt GlobalDAOReadOnly::GetParentalAllowedAge()
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-    WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
-    return select->GetSingleValue<GlobalProperties::parental_allowed_age>();
-}
-
 bool GlobalDAOReadOnly::GetSecureByDefault()
 {
     using namespace DPL::DB::ORM;
 bool GlobalDAOReadOnly::GetSecureByDefault()
 {
     using namespace DPL::DB::ORM;
@@ -123,12 +58,13 @@ bool GlobalDAOReadOnly::GetSecureByDefault()
 bool GlobalDAOReadOnly::getComplianceMode()
 {
     LogDebug("Getting compliance mode");
 bool GlobalDAOReadOnly::getComplianceMode()
 {
     LogDebug("Getting compliance mode");
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         return select->GetSingleValue<GlobalProperties::compliance_mode>();
     }
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         return select->GetSingleValue<GlobalProperties::compliance_mode>();
     }
-    Catch (DPL::DB::SqlConnection::Exception::Base){
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to get compliance mode");
     }
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to get compliance mode");
     }
@@ -137,8 +73,9 @@ bool GlobalDAOReadOnly::getComplianceMode()
 std::string GlobalDAOReadOnly::getComplianceFakeImei()
 {
     LogDebug("Getting compliance fake IMEI");
 std::string GlobalDAOReadOnly::getComplianceFakeImei()
 {
     LogDebug("Getting compliance fake IMEI");
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         DPL::Optional<DPL::String> result =
             select->GetSingleValue<GlobalProperties::compliance_fake_imei>();
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         DPL::Optional<DPL::String> result =
             select->GetSingleValue<GlobalProperties::compliance_fake_imei>();
@@ -147,7 +84,7 @@ std::string GlobalDAOReadOnly::getComplianceFakeImei()
         }
         return DPL::ToUTF8String(*result);
     }
         }
         return DPL::ToUTF8String(*result);
     }
-    Catch (DPL::DB::SqlConnection::Exception::Base){
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to get compliance fake IMEI");
     }
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to get compliance fake IMEI");
     }
@@ -156,8 +93,9 @@ std::string GlobalDAOReadOnly::getComplianceFakeImei()
 std::string GlobalDAOReadOnly::getComplianceFakeMeid()
 {
     LogDebug("Getting compliance fake MEID");
 std::string GlobalDAOReadOnly::getComplianceFakeMeid()
 {
     LogDebug("Getting compliance fake MEID");
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         DPL::Optional<DPL::String> result =
             select->GetSingleValue<GlobalProperties::compliance_fake_meid>();
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         DPL::Optional<DPL::String> result =
             select->GetSingleValue<GlobalProperties::compliance_fake_meid>();
@@ -166,7 +104,7 @@ std::string GlobalDAOReadOnly::getComplianceFakeMeid()
         }
         return DPL::ToUTF8String(*result);
     }
         }
         return DPL::ToUTF8String(*result);
     }
-    Catch (DPL::DB::SqlConnection::Exception::Base){
+    Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to get compliance fake MEID");
     }
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to get compliance fake MEID");
     }
@@ -179,73 +117,15 @@ bool GlobalDAOReadOnly::IsValidSubTag(const DPL::String& tag, int type)
     WRT_DB_SELECT(select, iana_records, &WrtDatabase::interface())
     select->Where(Equals<iana_records::SUBTAG>(tag));
     auto row = select->GetRowList();
     WRT_DB_SELECT(select, iana_records, &WrtDatabase::interface())
     select->Where(Equals<iana_records::SUBTAG>(tag));
     auto row = select->GetRowList();
-    if (row.size() == 0 || row.front().Get_TYPE() != type) {
+    if (row.empty() || row.front().Get_TYPE() != type) {
         return false;
     } else {
         return true;
     }
 }
 
         return false;
     } else {
         return true;
     }
 }
 
-
-bool GlobalDAOReadOnly::IsPowderRulePresent(
-        const ChildProtection::PowderRules::CategoryRule& powder)
-{
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-
-        if (!powder.context.IsNull()) {
-            WRT_DB_SELECT(selWithContext, PowderRules, &WrtDatabase::interface())
-
-            selWithContext->Where(
-                And(Equals<PowderRules::category>(powder.category),
-                    And(Equals<PowderRules::level>(powder.level),
-                        Equals<PowderRules::context>(powder.context))));
-            return !selWithContext->GetRowList().empty();
-        } else {
-            WRT_DB_SELECT(selWithoutContext, PowderRules, &WrtDatabase::interface())
-            selWithoutContext->Where(
-                And(Equals<PowderRules::category>(powder.category),
-                    And(Equals<PowderRules::level>(powder.level),
-                        Is<PowderRules::context>(powder.context))));
-            return !selWithoutContext->GetRowList().empty();
-        }
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
-                   "Failure during checking if rule is present");
-    }
-}
-
-ChildProtection::PowderRules GlobalDAOReadOnly::GetPowderRules()
-{
-    ChildProtection::PowderRules powder;
-    powder.ageLimit = GetParentalAllowedAge();
-
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        typedef std::list<PowderRules::Row> PowderRulesList;
-        WRT_DB_SELECT(select, PowderRules, &WrtDatabase::interface())
-
-        PowderRulesList list = select->GetRowList();
-        FOREACH(it, list) {
-            using namespace Powder;
-            powder.rules.push_back(
-                ChildProtection::PowderRules::CategoryRule(
-                    it->Get_category(),
-                    static_cast<Description::LevelEnum>(it->Get_level()),
-                    it->Get_context()));
-        }
-        return powder;
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
-                   "Failed to get POWDER rules");
-    }
-}
-
 GlobalDAOReadOnly::NetworkAccessMode
 GlobalDAOReadOnly::NetworkAccessMode
-        GlobalDAOReadOnly::GetHomeNetworkDataUsage()
+GlobalDAOReadOnly::GetHomeNetworkDataUsage()
 {
     LogDebug("Getting home network data usage");
     Try {
 {
     LogDebug("Getting home network data usage");
     Try {
@@ -253,8 +133,8 @@ GlobalDAOReadOnly::NetworkAccessMode
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         return static_cast<GlobalDAOReadOnly::NetworkAccessMode>(
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         return static_cast<GlobalDAOReadOnly::NetworkAccessMode>(
-            select->GetSingleValue<
-            GlobalProperties::home_network_data_usage>());
+                   select->GetSingleValue<
+                       GlobalProperties::home_network_data_usage>());
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
@@ -270,7 +150,7 @@ GlobalDAOReadOnly::NetworkAccessMode GlobalDAOReadOnly::GetRoamingDataUsage()
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         return static_cast<GlobalDAOReadOnly::NetworkAccessMode>(
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
         return static_cast<GlobalDAOReadOnly::NetworkAccessMode>(
-            select->GetSingleValue<GlobalProperties::roaming_data_usage>());
+                   select->GetSingleValue<GlobalProperties::roaming_data_usage>());
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
     }
     Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
@@ -303,12 +183,13 @@ DPL::String GlobalDAOReadOnly::GetUserAgentValue(const DPL::String &key)
 }
 
 DeviceCapabilitySet GlobalDAOReadOnly::GetDeviceCapability(
 }
 
 DeviceCapabilitySet GlobalDAOReadOnly::GetDeviceCapability(
-        const DPL::String &apifeature)
+    const DPL::String &apifeature)
 {
     // This could be done with one simply sql query but support for join is
     // needed in orm.
 {
     // This could be done with one simply sql query but support for join is
     // needed in orm.
-    Try{
-        using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt;
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
 
         int featureUUID;
         FeatureDeviceCapProxy::Select::RowList rows;
 
         int featureUUID;
         FeatureDeviceCapProxy::Select::RowList rows;
@@ -321,55 +202,33 @@ DeviceCapabilitySet GlobalDAOReadOnly::GetDeviceCapability(
         }
 
         {
         }
 
         {
-            WRT_DB_SELECT(select, FeatureDeviceCapProxy, &WrtDatabase::interface())
+            WRT_DB_SELECT(select,
+                          FeatureDeviceCapProxy,
+                          &WrtDatabase::interface())
             select->Where(Equals<FeatureDeviceCapProxy::FeatureUUID>(
             select->Where(Equals<FeatureDeviceCapProxy::FeatureUUID>(
-                featureUUID));
+                              featureUUID));
             rows = select->GetRowList();
         }
 
         FOREACH(it, rows){
             WRT_DB_SELECT(select, DeviceCapabilities, &WrtDatabase::interface())
             select->Where(Equals<DeviceCapabilities::DeviceCapID>(
             rows = select->GetRowList();
         }
 
         FOREACH(it, rows){
             WRT_DB_SELECT(select, DeviceCapabilities, &WrtDatabase::interface())
             select->Where(Equals<DeviceCapabilities::DeviceCapID>(
-                it->Get_DeviceCapID()));
+                              it->Get_DeviceCapID()));
             result.insert(select->
             result.insert(select->
-                          GetSingleValue<DeviceCapabilities::DeviceCapName>());
+                              GetSingleValue<DeviceCapabilities::DeviceCapName>());
         }
 
         return result;
         }
 
         return result;
-    }Catch(DPL::DB::SqlConnection::Exception::Base){
+    } Catch(DPL::DB::SqlConnection::Exception::Base){
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to update roaming network data usage");
     }
 }
 
         ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
                    "Failed to update roaming network data usage");
     }
 }
 
-DPL::Optional<GlobalDAOReadOnly::AutoSaveData>
-        GlobalDAOReadOnly::GetAutoSaveIdPasswd(const DPL::String &url)
-{
-    Try{
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, AutoSaveIdPasswd, &WrtDatabase::interface());
-        select->Where(Equals<AutoSaveIdPasswd::address>(url));
-        AutoSaveIdPasswd::Select::RowList rows = select->GetRowList();
-
-        if (rows.empty()) {
-            return DPL::Optional<GlobalDAOReadOnly::AutoSaveData>::Null;
-        }
-
-        GlobalDAOReadOnly::AutoSaveData saveData;
-        saveData.userId = rows.front().Get_userId();
-        saveData.passwd = rows.front().Get_passwd();
-        return saveData;
-    } Catch(DPL::DB::SqlConnection::Exception::Base) {
-        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
-                   "Failed to get autosave data string");
-    }
-}
-
 WidgetAccessInfoList GlobalDAOReadOnly::GetWhiteURIList()
 {
     LogDebug("Getting WhiteURIList.");
 WidgetAccessInfoList GlobalDAOReadOnly::GetWhiteURIList()
 {
     LogDebug("Getting WhiteURIList.");
-    Try{
+    Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetWhiteURIList, &WrtDatabase::interface())
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetWhiteURIList, &WrtDatabase::interface())
@@ -393,4 +252,18 @@ WidgetAccessInfoList GlobalDAOReadOnly::GetWhiteURIList()
     }
 }
 
     }
 }
 
+bool GlobalDAOReadOnly::GetCookieSharingMode()
+{
+    LogDebug("Getting Cookie Sharing mode");
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
+        return select->GetSingleValue<GlobalProperties::cookie_sharing_mode>();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
+                   "Failed to get Cookie Sharing mode");
+    }
+}
 } // namespace WrtDB
 } // namespace WrtDB
index 4d91bbf..ab55476 100644 (file)
@@ -19,6 +19,7 @@
  * @version 1.0
  * @brief   Implementation file for PathBuilde class.
  */
  * @version 1.0
  * @brief   Implementation file for PathBuilde class.
  */
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/path_builder.h>
 #include <sstream>
 
 #include <dpl/wrt-dao-ro/path_builder.h>
 #include <sstream>
 
@@ -31,13 +32,11 @@ class PathBuilderImpl : DPL::Noncopyable
 {
   public:
     PathBuilderImpl()
 {
   public:
     PathBuilderImpl()
-    {
-    }
+    {}
 
     explicit PathBuilderImpl(const std::string& path) :
         m_stream(path, std::ios_base::app)
 
     explicit PathBuilderImpl(const std::string& path) :
         m_stream(path, std::ios_base::app)
-    {
-    }
+    {}
 
     void Append(const std::string& path)
     {
 
     void Append(const std::string& path)
     {
@@ -79,13 +78,11 @@ class PathBuilderImpl : DPL::Noncopyable
 };
 
 PathBuilder::PathBuilder() : m_impl(new PathBuilderImpl())
 };
 
 PathBuilder::PathBuilder() : m_impl(new PathBuilderImpl())
-{
-}
+{}
 
 PathBuilder::PathBuilder(const std::string& path) :
     m_impl(new PathBuilderImpl(path))
 
 PathBuilder::PathBuilder(const std::string& path) :
     m_impl(new PathBuilderImpl(path))
-{
-}
+{}
 
 PathBuilder::~PathBuilder()
 {
 
 PathBuilder::~PathBuilder()
 {
@@ -125,5 +122,4 @@ std::string PathBuilder::GetFullPath() const
 {
     return m_impl->GetFullPath();
 }
 {
     return m_impl->GetFullPath();
 }
-
 } // namespace WrtDB
 } // namespace WrtDB
index 7941efb..cc8dcbf 100644 (file)
@@ -20,7 +20,7 @@
  * @version 1.0
  * @brief   This file contains the definition of plugin dao class.
  */
  * @version 1.0
  * @brief   This file contains the definition of plugin dao class.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-rw/plugin_dao.h>
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-rw/plugin_dao.h>
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
-
 PluginDAO::PluginDAO(DbPluginHandle pluginHandle) :
     PluginDAOReadOnly(pluginHandle)
 PluginDAO::PluginDAO(DbPluginHandle pluginHandle) :
     PluginDAOReadOnly(pluginHandle)
-{
-}
+{}
 
 PluginDAO::PluginDAO(const std::string &libraryName) :
     PluginDAOReadOnly(libraryName)
 
 PluginDAO::PluginDAO(const std::string &libraryName) :
     PluginDAOReadOnly(libraryName)
-{
-}
+{}
 
 DbPluginHandle PluginDAO::registerPlugin(const PluginMetafileData& metafile,
 
 DbPluginHandle PluginDAO::registerPlugin(const PluginMetafileData& metafile,
-                                       const std::string& pluginPath)
+                                         const std::string& pluginPath)
 {
     LogDebug("Registering plugin. Path: " << pluginPath);
 
     Try {
 {
     LogDebug("Registering plugin. Path: " << pluginPath);
 
     Try {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
         DbPluginHandle handle;
 
         if (isPluginInstalled(metafile.m_libraryName)) {
         DbPluginHandle handle;
 
         if (isPluginInstalled(metafile.m_libraryName)) {
@@ -67,18 +65,10 @@ DbPluginHandle PluginDAO::registerPlugin(const PluginMetafileData& metafile,
             row.Set_InstallationState(INSTALLATION_IN_PROGRESS);
             row.Set_PluginLibraryPath(
                 DPL::FromUTF8String(pluginPath));
             row.Set_InstallationState(INSTALLATION_IN_PROGRESS);
             row.Set_PluginLibraryPath(
                 DPL::FromUTF8String(pluginPath));
-            row.Set_InstallURI(
-                DPL::FromUTF8String(metafile.m_featuresInstallURI));
-            row.Set_KeyCN(
-                DPL::FromUTF8String(metafile.m_featuresKeyCN));
-            row.Set_RootKeyCN(
-                DPL::FromUTF8String(metafile.m_featuresRootCN));
-            row.Set_RootKeyFingerprint(
-                DPL::FromUTF8String(metafile.m_featuresRootFingerprint));
 
             WRT_DB_INSERT(insert, PluginProperties, &WrtDatabase::interface())
             insert->Values(row);
 
             WRT_DB_INSERT(insert, PluginProperties, &WrtDatabase::interface())
             insert->Values(row);
-            handle = insert->Execute();
+            handle = static_cast<WrtDB::DbWidgetHandle>(insert->Execute());
             LogDebug(" >> Plugin Registered. Handle: " << handle);
         }
         transaction.Commit();
             LogDebug(" >> Plugin Registered. Handle: " << handle);
         }
         transaction.Commit();
@@ -92,12 +82,13 @@ DbPluginHandle PluginDAO::registerPlugin(const PluginMetafileData& metafile,
 }
 
 void PluginDAO::registerPluginImplementedObject(const std::string& objectName,
 }
 
 void PluginDAO::registerPluginImplementedObject(const std::string& objectName,
-        DbPluginHandle pluginHandle)
+                                                DbPluginHandle pluginHandle)
 {
     LogDebug("Registering plugin object: " << objectName);
 
     Try {
 {
     LogDebug("Registering plugin object: " << objectName);
 
     Try {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         LogDebug("Register Object: " << objectName);
 
 
         LogDebug("Register Object: " << objectName);
 
@@ -123,12 +114,13 @@ void PluginDAO::registerPluginImplementedObject(const std::string& objectName,
 }
 
 void PluginDAO::registerPluginRequiredObject(const std::string& objectName,
 }
 
 void PluginDAO::registerPluginRequiredObject(const std::string& objectName,
-        DbPluginHandle pluginHandle)
+                                             DbPluginHandle pluginHandle)
 {
     LogDebug("Registering plugin object: " << objectName);
 
     Try {
 {
     LogDebug("Registering plugin object: " << objectName);
 
     Try {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         LogDebug("Register Object: " << objectName);
 
 
         LogDebug("Register Object: " << objectName);
 
@@ -154,13 +146,14 @@ void PluginDAO::registerPluginRequiredObject(const std::string& objectName,
 }
 
 void PluginDAO::registerPluginLibrariesDependencies(
 }
 
 void PluginDAO::registerPluginLibrariesDependencies(
-        DbPluginHandle pluginHandle,
-        const PluginHandleSetPtr& dependencies)
+    DbPluginHandle pluginHandle,
+    const PluginHandleSetPtr& dependencies)
 {
     LogDebug("Registering plugin library dependencies: " << pluginHandle);
 
     Try {
 {
     LogDebug("Registering plugin library dependencies: " << pluginHandle);
 
     Try {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
 
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
@@ -217,4 +210,34 @@ void PluginDAO::setPluginInstallationStatus(DbPluginHandle pluginHandle,
     }
 }
 
     }
 }
 
+void PluginDAO::unregisterPlugin(DbPluginHandle pluginHandle)
+{
+    LogDebug("unregisterPlugin plugin. Handle: " << pluginHandle);
+
+    Try {
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
+
+        if (!isPluginInstalled(pluginHandle)) {
+            LogInfo("PluginHandle is invalid. Handle: " << pluginHandle);
+            return;
+        } else {
+            using namespace DPL::DB::ORM;
+            using namespace DPL::DB::ORM::wrt;
+
+            WRT_DB_DELETE(del, PluginProperties, &WrtDatabase::interface())
+            del->Where(
+                Equals<PluginProperties::PluginPropertiesId>(pluginHandle));
+            del->Execute();
+
+            transaction.Commit();
+            LogDebug(" >> Plugin Unregistered. Handle: " << pluginHandle);
+        }
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base)
+    {
+        ReThrowMsg(PluginDAO::Exception::DatabaseError,
+                   "Failed in UnregisterPlugin");
+    }
+}
 } // namespace WrtDB
 } // namespace WrtDB
index edb376d..d5acba9 100644 (file)
@@ -19,7 +19,7 @@
  * @version 1.0
  * @brief   This file contains the implementation of plugin dao read only
  */
  * @version 1.0
  * @brief   This file contains the implementation of plugin dao read only
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
 
 #include <sstream>
 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
 
 #include <sstream>
@@ -31,9 +31,7 @@
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
-
 namespace {
 namespace {
-
 typedef DPL::DB::ORM::wrt::PluginProperties::Row PluginRow;
 
 PluginRow getPluginRow(DbPluginHandle pluginHandle)
 typedef DPL::DB::ORM::wrt::PluginProperties::Row PluginRow;
 
 PluginRow getPluginRow(DbPluginHandle pluginHandle)
@@ -101,7 +99,8 @@ PluginDAOReadOnly::PluginDAOReadOnly(const std::string &libraryName)
 void PluginDAOReadOnly::checkInstallationCompleted()
 {
     if (getInstallationStateForHandle(m_pluginHandle)
 void PluginDAOReadOnly::checkInstallationCompleted()
 {
     if (getInstallationStateForHandle(m_pluginHandle)
-        != PluginDAOReadOnly::INSTALLATION_COMPLETED) {
+        != PluginDAOReadOnly::INSTALLATION_COMPLETED)
+    {
         LogError("Plugin " << m_pluginHandle << " installation not completed");
         Throw(PluginDAOReadOnly::Exception::PluginInstallationNotCompleted);
     }
         LogError("Plugin " << m_pluginHandle << " installation not completed");
         Throw(PluginDAOReadOnly::Exception::PluginInstallationNotCompleted);
     }
@@ -160,7 +159,6 @@ DbPluginHandle PluginDAOReadOnly::getPluginHandle() const
     return m_pluginHandle;
 }
 
     return m_pluginHandle;
 }
 
-
 //"value" cannot be null, as in registerPlugin it is always set
 #define RETURN_STD_STRING(in, what)                 \
     std::string ret = "";                           \
 //"value" cannot be null, as in registerPlugin it is always set
 #define RETURN_STD_STRING(in, what)                 \
     std::string ret = "";                           \
@@ -185,34 +183,6 @@ std::string PluginDAOReadOnly::getLibraryName() const
     return ret;
 }
 
     return ret;
 }
 
-std::string PluginDAOReadOnly::getInstallURI() const
-{
-    LogDebug("Getting plugin install URI. Handle: " << m_pluginHandle);
-    PluginRow row = getPluginRow(m_pluginHandle);
-    RETURN_STD_STRING(row.Get_InstallURI(), "install URI")
-}
-
-std::string PluginDAOReadOnly::getKeyCn() const
-{
-    LogDebug("Getting plugin KeyCn. Handle: " << m_pluginHandle);
-    PluginRow row = getPluginRow(m_pluginHandle);
-    RETURN_STD_STRING(row.Get_KeyCN(), "keyCN")
-}
-
-std::string PluginDAOReadOnly::getRootKey() const
-{
-    LogDebug("Getting plugin rootKey. Handle: " << m_pluginHandle);
-    PluginRow row = getPluginRow(m_pluginHandle);
-    RETURN_STD_STRING(row.Get_RootKeyCN(), "rootKey")
-}
-
-std::string PluginDAOReadOnly::getRootKeyFingerprint() const
-{
-    LogDebug("Getting plugin rootKeyFingerprint. Handle: " << m_pluginHandle);
-    PluginRow row = getPluginRow(m_pluginHandle);
-    RETURN_STD_STRING(row.Get_RootKeyFingerprint(), "rootKeyFingerprint")
-}
-
 #undef RETURN_STD_STRING
 
 PluginHandleSetPtr PluginDAOReadOnly::getLibraryDependencies() const
 #undef RETURN_STD_STRING
 
 PluginHandleSetPtr PluginDAOReadOnly::getLibraryDependencies() const
@@ -245,7 +215,7 @@ PluginHandleSetPtr PluginDAOReadOnly::getLibraryDependencies() const
 }
 
 DbPluginHandle PluginDAOReadOnly::getPluginHandleForImplementedObject(
 }
 
 DbPluginHandle PluginDAOReadOnly::getPluginHandleForImplementedObject(
-        const std::string& objectName)
+    const std::string& objectName)
 {
     LogDebug("GetPluginHandle for object: " << objectName);
 
 {
     LogDebug("GetPluginHandle for object: " << objectName);
 
@@ -277,7 +247,7 @@ DbPluginHandle PluginDAOReadOnly::getPluginHandleForImplementedObject(
 }
 
 ImplementedObjectsList PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
 }
 
 ImplementedObjectsList PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
-        DbPluginHandle handle)
+    DbPluginHandle handle)
 {
     LogDebug("getImplementedObjects for pluginHandle: " << handle);
 
 {
     LogDebug("getImplementedObjects for pluginHandle: " << handle);
 
@@ -309,8 +279,9 @@ ImplementedObjectsList PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
     }
 }
 
     }
 }
 
-PluginObjectsDAO::ObjectsPtr PluginDAOReadOnly::getRequiredObjectsForPluginHandle(
-        DbPluginHandle handle)
+PluginObjectsDAO::ObjectsPtr PluginDAOReadOnly::
+    getRequiredObjectsForPluginHandle(
+    DbPluginHandle handle)
 {
     Try
     {
 {
     Try
     {
@@ -342,7 +313,7 @@ PluginObjectsDAO::ObjectsPtr PluginDAOReadOnly::getRequiredObjectsForPluginHandl
 }
 
 PluginHandleSetPtr PluginDAOReadOnly::getPluginHandleByStatus(
 }
 
 PluginHandleSetPtr PluginDAOReadOnly::getPluginHandleByStatus(
-        PluginInstallationState state)
+    PluginInstallationState state)
 {
     Try
     {
 {
     Try
     {
@@ -372,14 +343,16 @@ PluginHandleSetPtr PluginDAOReadOnly::getPluginHandleByStatus(
     }
 }
 
     }
 }
 
-PluginDAOReadOnly::PluginInstallationState PluginDAOReadOnly::getInstallationStatus() const
+PluginDAOReadOnly::PluginInstallationState PluginDAOReadOnly::
+    getInstallationStatus() const
 {
     PluginRow row = getPluginRow(m_pluginHandle);
     return ToState(row.Get_InstallationState());
 }
 
 {
     PluginRow row = getPluginRow(m_pluginHandle);
     return ToState(row.Get_InstallationState());
 }
 
-PluginDAOReadOnly::PluginInstallationState PluginDAOReadOnly::getInstallationStateForHandle(
-        DbPluginHandle handle)
+PluginDAOReadOnly::PluginInstallationState PluginDAOReadOnly::
+    getInstallationStateForHandle(
+    DbPluginHandle handle)
 {
     Try
     {
 {
     Try
     {
@@ -424,5 +397,4 @@ bool PluginDAOReadOnly::isPluginInstalled(DbPluginHandle pluginHandle)
                    "Failed in isPluginInstalled");
     }
 }
                    "Failed in isPluginInstalled");
     }
 }
-
 } // namespace WrtDB
 } // namespace WrtDB
index 95ba056..8b3dabb 100644 (file)
@@ -19,7 +19,7 @@
  * @version 1.0
  * @brief   This file contains the definition of property dao class.
  */
  * @version 1.0
  * @brief   This file contains the definition of property dao class.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-rw/property_dao.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/log/log.h>
 #include <dpl/wrt-dao-rw/property_dao.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/log/log.h>
 
 namespace WrtDB {
 namespace PropertyDAO {
 
 namespace WrtDB {
 namespace PropertyDAO {
-
-void RemoveProperty(DbWidgetHandle widgetHandle,
+void RemoveProperty(TizenAppId tzAppid,
                     const PropertyDAOReadOnly::WidgetPropertyKey &key)
 {
     //TODO below there are two queries.
     // First query asks if given property can be removed,
     // Second removes it. Maybe it should be combined two one.
 
                     const PropertyDAOReadOnly::WidgetPropertyKey &key)
 {
     //TODO below there are two queries.
     // First query asks if given property can be removed,
     // Second removes it. Maybe it should be combined two one.
 
-    LogDebug("Removing Property. Handle: " << widgetHandle << ", key: " << key);
+    LogDebug("Removing Property. appid: " << tzAppid << ", key: " << key);
     Try {
     Try {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         DPL::OptionalInt readonly = PropertyDAOReadOnly::CheckPropertyReadFlag(
 
         DPL::OptionalInt readonly = PropertyDAOReadOnly::CheckPropertyReadFlag(
-                widgetHandle,
+                tzAppid,
                 key);
         if (!readonly.IsNull() && *readonly == 1) {
             LogError("'" << key <<
                 key);
         if (!readonly.IsNull() && *readonly == 1) {
             LogError("'" << key <<
@@ -58,7 +58,7 @@ void RemoveProperty(DbWidgetHandle widgetHandle,
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_DELETE(del, WidgetPreference, &WrtDatabase::interface())
         del->Where(And(
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_DELETE(del, WidgetPreference, &WrtDatabase::interface())
         del->Where(And(
-                       Equals<WidgetPreference::app_id>(widgetHandle),
+                       Equals<WidgetPreference::tizen_appid>(tzAppid),
                        Equals<WidgetPreference::key_name>(key)));
         del->Execute();
 
                        Equals<WidgetPreference::key_name>(key)));
         del->Execute();
 
@@ -70,20 +70,31 @@ void RemoveProperty(DbWidgetHandle widgetHandle,
     }
 }
 
     }
 }
 
+//deprecated
 void SetProperty(DbWidgetHandle widgetHandle,
                  const PropertyDAOReadOnly::WidgetPropertyKey &key,
                  const PropertyDAOReadOnly::WidgetPropertyValue &value,
                  bool readOnly)
 {
 void SetProperty(DbWidgetHandle widgetHandle,
                  const PropertyDAOReadOnly::WidgetPropertyKey &key,
                  const PropertyDAOReadOnly::WidgetPropertyValue &value,
                  bool readOnly)
 {
-    LogDebug("Setting/updating Property. Handle: " << widgetHandle <<
+    SetProperty(WidgetDAOReadOnly::getTzAppId(
+                    widgetHandle), key, value, readOnly);
+}
+
+void SetProperty(TizenAppId tzAppid,
+                 const PropertyDAOReadOnly::WidgetPropertyKey &key,
+                 const PropertyDAOReadOnly::WidgetPropertyValue &value,
+                 bool readOnly)
+{
+    LogDebug("Setting/updating Property. appid: " << tzAppid <<
              ", key: " << key);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
              ", key: " << key);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
 
         DPL::OptionalInt readonly = PropertyDAOReadOnly::CheckPropertyReadFlag(
 
         DPL::OptionalInt readonly = PropertyDAOReadOnly::CheckPropertyReadFlag(
-                widgetHandle,
+                tzAppid,
                 key);
         if (!readonly.IsNull() && *readonly == 1) {
             LogError("'" << key <<
                 key);
         if (!readonly.IsNull() && *readonly == 1) {
             LogError("'" << key <<
@@ -94,7 +105,7 @@ void SetProperty(DbWidgetHandle widgetHandle,
 
         if (readonly.IsNull()) {
             WidgetPreference::Row row;
 
         if (readonly.IsNull()) {
             WidgetPreference::Row row;
-            row.Set_app_id(widgetHandle);
+            row.Set_tizen_appid(tzAppid);
             row.Set_key_name(key);
             row.Set_key_value(value);
             row.Set_readonly(readOnly ? 1 : 0);
             row.Set_key_name(key);
             row.Set_key_value(value);
             row.Set_readonly(readOnly ? 1 : 0);
@@ -108,7 +119,7 @@ void SetProperty(DbWidgetHandle widgetHandle,
 
             WRT_DB_UPDATE(update, WidgetPreference, &WrtDatabase::interface())
             update->Where(And(
 
             WRT_DB_UPDATE(update, WidgetPreference, &WrtDatabase::interface())
             update->Where(And(
-                              Equals<WidgetPreference::app_id>(widgetHandle),
+                              Equals<WidgetPreference::tizen_appid>(tzAppid),
                               Equals<WidgetPreference::key_name>(key)));
 
             update->Values(row);
                               Equals<WidgetPreference::key_name>(key)));
 
             update->Values(row);
@@ -122,10 +133,10 @@ void SetProperty(DbWidgetHandle widgetHandle,
     }
 }
 
     }
 }
 
-void RegisterProperties(DbWidgetHandle widgetHandle,
+void RegisterProperties(TizenAppId tzAppid,
                         const WidgetRegisterInfo &regInfo)
 {
                         const WidgetRegisterInfo &regInfo)
 {
-    LogDebug("Registering proferences for widget. Handle: " << widgetHandle);
+    LogDebug("Registering proferences for widget. appid: " << tzAppid);
 
     // Try-Catch in WidgetDAO
 
 
     // Try-Catch in WidgetDAO
 
@@ -137,7 +148,7 @@ void RegisterProperties(DbWidgetHandle widgetHandle,
     {
         { // Insert into table Widget Preferences
             WidgetPreference::Row row;
     {
         { // Insert into table Widget Preferences
             WidgetPreference::Row row;
-            row.Set_app_id(widgetHandle);
+            row.Set_tizen_appid(tzAppid);
             row.Set_key_name(it->name);
             row.Set_key_value(it->value);
             int readonly = true == it->readonly ? 1 : 0;
             row.Set_key_name(it->name);
             row.Set_key_value(it->value);
             int readonly = true == it->readonly ? 1 : 0;
@@ -149,6 +160,5 @@ void RegisterProperties(DbWidgetHandle widgetHandle,
         }
     }
 }
         }
     }
 }
-
 } // namespace PropertyDAO
 } // namespace WrtDB
 } // namespace PropertyDAO
 } // namespace WrtDB
index 74208af..c475f2a 100644 (file)
@@ -19,8 +19,9 @@
  *  Created on: Nov 16, 2011
  *      Author: Krzysztof Jackiewicz(k.jackiewicz@samsung.com)
  */
  *  Created on: Nov 16, 2011
  *      Author: Krzysztof Jackiewicz(k.jackiewicz@samsung.com)
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/webruntime_database.h>
 #include <dpl/log/log.h>
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/webruntime_database.h>
 
 namespace WrtDB {
 namespace PropertyDAOReadOnly {
 
 namespace WrtDB {
 namespace PropertyDAOReadOnly {
-
 namespace {
 namespace {
-
 typedef DPL::DB::ORM::wrt::WidgetPreference::key_name::ColumnType
 typedef DPL::DB::ORM::wrt::WidgetPreference::key_name::ColumnType
-    ORMWidgetPropertyKey;
+ORMWidgetPropertyKey;
 typedef DPL::DB::ORM::wrt::WidgetPreference::key_value::ColumnType
 typedef DPL::DB::ORM::wrt::WidgetPreference::key_value::ColumnType
-    ORMWidgetPropertyValue;
-typedef std::list<DPL::DB::ORM::wrt::WidgetPreference::Row> ORMWidgetPreferenceList;
+ORMWidgetPropertyValue;
+typedef std::list<DPL::DB::ORM::wrt::WidgetPreference::Row>
+ORMWidgetPreferenceList;
 typedef std::list<WidgetPropertyKey> ORMWidgetPropertyKeyList;
 
 typedef std::list<WidgetPropertyKey> ORMWidgetPropertyKeyList;
 
-
 void convertPropertyKey(const ORMWidgetPropertyKey& ormKey,
                         WidgetPropertyKey& key)
 {
 void convertPropertyKey(const ORMWidgetPropertyKey& ormKey,
                         WidgetPropertyKey& key)
 {
@@ -58,7 +57,7 @@ void convertWidgetPreferenceRow(const ORMWidgetPreferenceList& ormWidgetPrefRow,
     FOREACH(it, ormWidgetPrefRow) {
         WidgetPreferenceRow row;
 
     FOREACH(it, ormWidgetPrefRow) {
         WidgetPreferenceRow row;
 
-        row.app_id = it->Get_app_id();
+        row.tizen_appid = it->Get_tizen_appid();
         row.key_name = it->Get_key_name();
         row.key_value = it->Get_key_value();
         row.readonly = it->Get_readonly();
         row.key_name = it->Get_key_name();
         row.key_value = it->Get_key_value();
         row.readonly = it->Get_readonly();
@@ -74,19 +73,46 @@ void convertWidgetPropertyKeyList(const ORMWidgetPropertyKeyList& propKeyList,
         keyList.push_back(*it);
     }
 }
         keyList.push_back(*it);
     }
 }
+}
+
+//deprecated
+DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
+                                       const WidgetPropertyKey &key)
+{
+    return CheckPropertyReadFlag(WidgetDAOReadOnly::getTzAppId(widgetHandle),
+                                 key);
+}
 
 
+DPL::OptionalInt CheckPropertyReadFlag(TizenAppId tzAppid,
+                                       const WidgetPropertyKey &key)
+{
+    LogDebug("Checking Property flag. appid: " << tzAppid <<
+             ", key: " << key);
 
 
+    Try {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
+        select->Where(And(Equals<WidgetPreference::tizen_appid>(tzAppid),
+                          Equals<WidgetPreference::key_name>(key)));
+
+        return select->GetSingleValue<WidgetPreference::readonly>();
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base){
+        ReThrowMsg(Exception::DatabaseError,
+                   "Failure during checking readonly flag for property");
+    }
 }
 
 }
 
-WidgetPropertyKeyList GetPropertyKeyList(DbWidgetHandle widgetHandle)
+WidgetPropertyKeyList GetPropertyKeyList(TizenAppId tzAppid)
 {
 {
-    LogDebug("Get PropertyKey list. Handle: " << widgetHandle);
+    LogDebug("Get PropertyKey list. appid: " << tzAppid);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         ORMWidgetPropertyKeyList keyList;
         WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         ORMWidgetPropertyKeyList keyList;
         WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
-        select->Where(Equals<WidgetPreference::app_id>(widgetHandle));
+        select->Where(Equals<WidgetPreference::tizen_appid>(tzAppid));
         keyList = select->GetValueList<WidgetPreference::key_name>();
 
         WidgetPropertyKeyList retKeyList;
         keyList = select->GetValueList<WidgetPreference::key_name>();
 
         WidgetPropertyKeyList retKeyList;
@@ -100,14 +126,26 @@ WidgetPropertyKeyList GetPropertyKeyList(DbWidgetHandle widgetHandle)
     }
 }
 
     }
 }
 
+//deprecated
 WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle)
 {
 WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle)
 {
-    LogDebug("Get Property list. Handle: " << widgetHandle);
+    Try {
+        TizenAppId tzAppid = WidgetDAOReadOnly::getTzAppId(widgetHandle);
+        return GetPropertyList(tzAppid);
+    } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist){
+        WidgetPreferenceList empty;
+        return empty;
+    }
+}
+
+WidgetPreferenceList GetPropertyList(TizenAppId tzAppId)
+{
+    LogDebug("Get Property list. tizenAppId: " << tzAppId);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
-        select->Where(Equals<WidgetPreference::app_id>(widgetHandle));
+        select->Where(Equals<WidgetPreference::tizen_appid>(tzAppId));
 
         ORMWidgetPreferenceList ormPrefList = select->GetRowList();
         WidgetPreferenceList prefList;
 
         ORMWidgetPreferenceList ormPrefList = select->GetRowList();
         WidgetPreferenceList prefList;
@@ -121,20 +159,20 @@ WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle)
     }
 }
 
     }
 }
 
-WidgetPropertyValue GetPropertyValue(DbWidgetHandle widgetHandle,
+WidgetPropertyValue GetPropertyValue(TizenAppId tzAppid,
                                      const WidgetPropertyKey &key)
 {
                                      const WidgetPropertyKey &key)
 {
-    LogDebug("Get Property value. Handle: " << widgetHandle <<
+    LogDebug("Get Property value. appid: " << tzAppid <<
              ", key: " << key);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
              ", key: " << key);
     Try {
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
-        select->Where(And(Equals<WidgetPreference::app_id>(widgetHandle),
+        select->Where(And(Equals<WidgetPreference::tizen_appid>(tzAppid),
                           Equals<WidgetPreference::key_name>(key)));
 
         ORMWidgetPropertyValue ormPropValue =
                           Equals<WidgetPreference::key_name>(key)));
 
         ORMWidgetPropertyValue ormPropValue =
-                select->GetSingleValue<WidgetPreference::key_value>();
+            select->GetSingleValue<WidgetPreference::key_value>();
 
         WidgetPropertyValue propValue;
 
 
         WidgetPropertyValue propValue;
 
@@ -147,26 +185,5 @@ WidgetPropertyValue GetPropertyValue(DbWidgetHandle widgetHandle,
                    "Failure during getting property");
     }
 }
                    "Failure during getting property");
     }
 }
-
-DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
-                                  const WidgetPropertyKey &key)
-{
-    LogDebug("Checking Property flag. Handle: " << widgetHandle <<
-             ", key: " << key);
-    Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface())
-        select->Where(And(Equals<WidgetPreference::app_id>(widgetHandle),
-                          Equals<WidgetPreference::key_name>(key)));
-
-        return select->GetSingleValue<WidgetPreference::readonly>();
-    }
-    Catch(DPL::DB::SqlConnection::Exception::Base){
-        ReThrowMsg(Exception::DatabaseError,
-                   "Failure during checking readonly flag for property");
-    }
-}
-
 } // namespace PropertyDAOReadOnly
 } // namespace WrtDB
 } // namespace PropertyDAOReadOnly
 } // namespace WrtDB
index bc24fbe..5fbb7d7 100644 (file)
@@ -19,6 +19,7 @@
  * @version 1.0
  * @brief   This file contains the definition of webruntime database
  */
  * @version 1.0
  * @brief   This file contains the definition of webruntime database
  */
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/webruntime_database.h>
 
 DPL::Mutex g_wrtDbQueriesMutex;
 #include <dpl/wrt-dao-ro/webruntime_database.h>
 
 DPL::Mutex g_wrtDbQueriesMutex;
index be33379..6529fd0 100644 (file)
@@ -25,7 +25,7 @@
  * @version 1.0
  * @brief   This file contains the definition of Configuration.
  */
  * @version 1.0
  * @brief   This file contains the definition of Configuration.
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 
 #include <sstream>
 #include <dpl/wrt-dao-rw/widget_dao.h>
 
 #include <sstream>
@@ -37,7 +37,6 @@
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
-
 //TODO in current solution in each getter there exists a check
 //"IsWidgetInstalled". Maybe it should be verified, if it could be done
 //differently  (check in WidgetDAO constructor)
 //TODO in current solution in each getter there exists a check
 //"IsWidgetInstalled". Maybe it should be verified, if it could be done
 //differently  (check in WidgetDAO constructor)
@@ -51,129 +50,289 @@ namespace WrtDB {
                    message);                            \
     }
 
                    message);                            \
     }
 
-#define CHECK_WIDGET_EXISTENCE(macro_transaction, macro_handle)          \
-    if (!WidgetDAO::isWidgetInstalled(macro_handle))                      \
-    {                                                                    \
-        macro_transaction.Commit();                                      \
-        LogWarning("Cannot find widget. Handle: " << macro_handle);      \
-        ThrowMsg(WidgetDAO::Exception::WidgetNotExist,                   \
-                 "Cannot find widget. Handle: " << macro_handle);        \
-    }
+WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) :
+    WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID))
+{}
+
+WidgetDAO::WidgetDAO(DPL::String tzAppId) :
+    WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(tzAppId))
+{}
 
 
+WidgetDAO::WidgetDAO(DbWidgetHandle handle) :
+    WidgetDAOReadOnly(handle)
+{}
+
+WidgetDAO::~WidgetDAO()
+{}
 
 
-WidgetDAO::WidgetDAO(DbWidgetHandle widgetHandle) :
-    WidgetDAOReadOnly(widgetHandle)
+void WidgetDAO::setTizenAppId(const DPL::OptionalString& tzAppId)
 {
 {
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+
+        if (!isWidgetInstalled(getHandle())) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << getHandle());
+        }
+
+        wrt::WidgetInfo::Row row;
+        row.Set_tizen_appid(*tzAppId);
+
+        WRT_DB_UPDATE(update, wrt::WidgetInfo, &WrtDatabase::interface())
+        update->Where(
+            Equals<wrt::WidgetInfo::app_id>(getHandle()));
+
+        update->Values(row);
+        update->Execute();
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
 }
 
 }
 
-WidgetDAO::WidgetDAO(DPL::OptionalString widgetGUID) :
-    WidgetDAOReadOnly(WidgetDAOReadOnly::getHandle(widgetGUID))
+void WidgetDAO::setSecurityPopupUsage(const SettingsType value)
 {
 {
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(getHandle())) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << getHandle());
+        }
+
+        WidgetSecuritySettings::Row row;
+        row.Set_security_popup_usage(value);
+
+        WRT_DB_UPDATE(update, WidgetSecuritySettings, &WrtDatabase::interface())
+        update->Where(Equals<WidgetSecuritySettings::app_id>(getHandle()));
+        update->Values(row);
+        update->Execute();
+
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set security popup usage")
 }
 
 }
 
-WidgetDAO::~WidgetDAO()
+void WidgetDAO::setGeolocationUsage(const SettingsType value)
 {
 {
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(getHandle())) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << getHandle());
+        }
+
+        WidgetSecuritySettings::Row row;
+        row.Set_geolocation_usage(value);
+
+        WRT_DB_UPDATE(update, WidgetSecuritySettings, &WrtDatabase::interface())
+        update->Where(Equals<WidgetSecuritySettings::app_id>(getHandle()));
+        update->Values(row);
+        update->Execute();
+
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set geolocation usage")
 }
 
 }
 
-void WidgetDAO::removeProperty(
-        const PropertyDAOReadOnly::WidgetPropertyKey &key)
+void WidgetDAO::setWebNotificationUsage(const SettingsType value)
 {
 {
-    Try {
-        PropertyDAO::RemoveProperty(m_widgetHandle, key);
-    }
-    Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){
-        ReThrowMsg(WidgetDAO::Exception::DatabaseError,
-                   "Failure during removing property");
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(getHandle())) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << getHandle());
+        }
+
+        WidgetSecuritySettings::Row row;
+        row.Set_web_notification_usage(value);
+
+        WRT_DB_UPDATE(update, WidgetSecuritySettings, &WrtDatabase::interface())
+        update->Where(Equals<WidgetSecuritySettings::app_id>(getHandle()));
+        update->Values(row);
+        update->Execute();
+
+        transaction.Commit();
     }
     }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set web notification usage")
 }
 
 }
 
-void WidgetDAO::setProperty(
-        const PropertyDAOReadOnly::WidgetPropertyKey &key,
-        const PropertyDAOReadOnly::WidgetPropertyValue &value,
-        bool readOnly)
+void WidgetDAO::setWebDatabaseUsage(const SettingsType value)
 {
 {
-    Try {
-        PropertyDAO::SetProperty(m_widgetHandle, key, value, readOnly);
-    }
-    Catch(PropertyDAOReadOnly::Exception::ReadOnlyProperty){
-        ReThrowMsg(WidgetDAO::Exception::DatabaseError,
-                   "Failure during setting/updating property");
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(getHandle())) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << getHandle());
+        }
+
+        WidgetSecuritySettings::Row row;
+        row.Set_web_database_usage(value);
+
+        WRT_DB_UPDATE(update, WidgetSecuritySettings, &WrtDatabase::interface())
+        update->Where(Equals<WidgetSecuritySettings::app_id>(getHandle()));
+        update->Values(row);
+        update->Execute();
+
+        transaction.Commit();
     }
     }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set web database usage")
 }
 
 }
 
-void WidgetDAO::setPkgName(const DPL::OptionalString& pkgName)
+void WidgetDAO::setFileSystemUsage(const SettingsType value)
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
         using namespace DPL::DB::ORM;
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
         using namespace DPL::DB::ORM;
-        wrt::ScopedTransaction transaction(&WrtDatabase::interface());
-
-        isWidgetInstalled(getHandle());
+        using namespace DPL::DB::ORM::wrt;
 
 
-        wrt::WidgetInfo::Row row;
-        row.Set_pkgname(pkgName);
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(getHandle())) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << getHandle());
+        }
 
 
-        WRT_DB_UPDATE(update, wrt::WidgetInfo, &WrtDatabase::interface())
-        update->Where(
-            Equals<wrt::WidgetInfo::app_id>(getHandle()));
+        WidgetSecuritySettings::Row row;
+        row.Set_file_system_usage(value);
 
 
+        WRT_DB_UPDATE(update, WidgetSecuritySettings, &WrtDatabase::interface())
+        update->Where(Equals<WidgetSecuritySettings::app_id>(getHandle()));
         update->Values(row);
         update->Execute();
         update->Values(row);
         update->Execute();
+
         transaction.Commit();
     }
         transaction.Commit();
     }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to set filesystem usage")
 }
 
 }
 
-DbWidgetHandle WidgetDAO::registerWidget(const WidgetRegisterInfo &widgetRegInfo,
-                                       const IWacSecurity &wacSecurity,
-                                       const LanguageTagsList& languageTags)
+void WidgetDAO::registerWidget(
+    const TizenAppId & tzAppId,
+    const WidgetRegisterInfo &widgetRegInfo,
+    const IWacSecurity &wacSecurity)
 {
     LogDebug("Registering widget");
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     LogDebug("Registering widget");
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
+        registerWidgetInternal(tzAppId, widgetRegInfo, wacSecurity);
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
+}
+
+DbWidgetHandle WidgetDAO::registerWidget(
+    const WidgetRegisterInfo &pWidgetRegisterInfo,
+    const IWacSecurity &wacSecurity)
+{
+    //make it more precise due to very fast tests
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    srand(time(NULL) + tv.tv_usec);
+    DbWidgetHandle widgetHandle;
+    do {
+        widgetHandle = rand();
+    } while (isWidgetInstalled(widgetHandle));
+
+    registerWidget(*pWidgetRegisterInfo.configInfo.tizenAppId,
+                   pWidgetRegisterInfo,
+                   wacSecurity);
+    return widgetHandle;
+}
 
 
-        //Register into WidgetInfo has to be first
-        //as all other tables depend upon that
-        DbWidgetHandle widgetHandle =
-                registerWidgetInfo(widgetRegInfo, wacSecurity);
+TizenAppId WidgetDAO::registerWidgetGeneratePkgId(
+    const WidgetRegisterInfo &pWidgetRegisterInfo,
+    const IWacSecurity &wacSecurity)
+{
+    TizenAppId tzAppId = generatePkgId();
+    registerWidget(tzAppId, pWidgetRegisterInfo, wacSecurity);
+    return tzAppId;
+}
 
 
-        registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
+void WidgetDAO::registerWidgetInternal(
+    const TizenAppId & tzAppId,
+    const WidgetRegisterInfo &widgetRegInfo,
+    const IWacSecurity &wacSecurity,
+    const DPL::Optional<DbWidgetHandle> handle)
+{
+    //Register into WidgetInfo has to be first
+    //as all other tables depend upon that
+    DbWidgetHandle widgetHandle = registerWidgetInfo(tzAppId,
+                                                     widgetRegInfo,
+                                                     wacSecurity,
+                                                     handle);
 
 
-        registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo);
+    registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
 
 
-        registerWidgetUserAgentLocales(
-                widgetHandle, widgetRegInfo, languageTags);
+    registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo);
 
 
-        registerWidgetIcons(widgetHandle, widgetRegInfo);
+    registerWidgetIcons(widgetHandle, widgetRegInfo);
 
 
-        registerWidgetStartFile(widgetHandle, widgetRegInfo);
+    registerWidgetStartFile(widgetHandle, widgetRegInfo);
 
 
-        PropertyDAO::RegisterProperties(widgetHandle, widgetRegInfo);
+    PropertyDAO::RegisterProperties(tzAppId, widgetRegInfo);
 
 
-        registerWidgetFeatures(widgetHandle, widgetRegInfo);
+    registerWidgetFeatures(widgetHandle, widgetRegInfo);
 
 
-        registerWidgetWindowModes(widgetHandle, widgetRegInfo);
+    registerWidgetPrivilege(widgetHandle, widgetRegInfo);
 
 
-        registerWidgetWarpInfo(widgetHandle, widgetRegInfo);
+    registerWidgetWindowModes(widgetHandle, widgetRegInfo);
 
 
-        registerWidgetCertificates(widgetHandle, wacSecurity);
+    registerWidgetWarpInfo(widgetHandle, widgetRegInfo);
 
 
-        CertificateChainList list;
-        wacSecurity.getCertificateChainList(list);
-        registerLaunchCertificates(widgetHandle,list);
+    registerWidgetCertificates(widgetHandle, wacSecurity);
 
 
-        registerWidgetPowderData(widgetHandle, widgetRegInfo);
+    CertificateChainList list;
+    wacSecurity.getCertificateChainList(list, SIGNATURE_DISTRIBUTOR);
+    registerCertificatesChains(widgetHandle, SIGNATURE_DISTRIBUTOR, list);
 
 
-        registerWidgetSettings(widgetHandle, widgetRegInfo);
+    list.clear();
+    wacSecurity.getCertificateChainList(list, SIGNATURE_AUTHOR);
+    registerCertificatesChains(widgetHandle, SIGNATURE_AUTHOR, list);
 
 
-        registerAppService(widgetHandle, widgetRegInfo);
+    registerWidgetSettings(widgetHandle, widgetRegInfo);
 
 
-        transaction.Commit();
+    registerAppService(widgetHandle, widgetRegInfo);
+
+    registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
+
+    registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
 
 
-        return widgetHandle;
+    registerWidgetSecuritySettings(widgetHandle);
+}
+
+void WidgetDAO::registerOrUpdateWidget(
+    const TizenAppId & widgetName,
+    const WidgetRegisterInfo &widgetRegInfo,
+    const IWacSecurity &wacSecurity)
+{
+    LogDebug("Reregistering widget");
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
+
+        unregisterWidgetInternal(widgetName);
+        registerWidgetInternal(widgetName, widgetRegInfo, wacSecurity);
+        transaction.Commit();
     }
     }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
 }
 
 #define DO_INSERT(row, table)                              \
 }
 
 #define DO_INSERT(row, table)                              \
@@ -184,26 +343,30 @@ DbWidgetHandle WidgetDAO::registerWidget(const WidgetRegisterInfo &widgetRegInfo
     }
 
 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
     }
 
 void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                           const WidgetRegisterInfo &regInfo)
 {
     //Try and transaction not needed
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
 {
     //Try and transaction not needed
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
-
     WidgetExtendedInfo::Row row;
     row.Set_app_id(widgetHandle);
     //    row.Set_share_href    (DPL::FromUTF8String(regInfo.shareHref));
     row.Set_signature_type(regInfo.signatureType);
     WidgetExtendedInfo::Row row;
     row.Set_app_id(widgetHandle);
     //    row.Set_share_href    (DPL::FromUTF8String(regInfo.shareHref));
     row.Set_signature_type(regInfo.signatureType);
-    row.Set_factory_widget(regInfo.isFactoryWidget);
     row.Set_test_widget(regInfo.isTestWidget);
     row.Set_install_time(regInfo.installedTime);
     row.Set_test_widget(regInfo.isTestWidget);
     row.Set_install_time(regInfo.installedTime);
+    row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
+    row.Set_background_page(regInfo.configInfo.backgroundPage);
+    row.Set_installed_path(regInfo.widgetInstalledPath);
 
     DO_INSERT(row, WidgetExtendedInfo)
 }
 
 
     DO_INSERT(row, WidgetExtendedInfo)
 }
 
-DbWidgetHandle WidgetDAO::registerWidgetInfo(const WidgetRegisterInfo &regInfo,
-                                   const IWacSecurity &wacSecurity)
+DbWidgetHandle WidgetDAO::registerWidgetInfo(
+    const TizenAppId & tzAppId,
+    const WidgetRegisterInfo &regInfo,
+    const IWacSecurity &wacSecurity,
+    const DPL::Optional<DbWidgetHandle> handle)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
@@ -213,7 +376,19 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo(const WidgetRegisterInfo &regInfo,
     // Because of that, "Optional" is not used there
 
     WidgetInfo::Row row;
     // Because of that, "Optional" is not used there
 
     WidgetInfo::Row row;
-    row.Set_widget_type(regInfo.type.appType);
+    if (!!handle) {
+        row.Set_app_id(*handle);
+    }
+
+    if (regInfo.webAppType == APP_TYPE_UNKNOWN && regInfo.type !=
+        APP_TYPE_UNKNOWN)
+    {
+        // TODO : regInfo.type is temporary code for security.
+        //        This code will be removed.
+        row.Set_widget_type(regInfo.type.appType);
+    } else {
+        row.Set_widget_type(regInfo.webAppType.appType);
+    }
     row.Set_widget_id(widgetConfigurationInfo.widget_id);
     row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
     row.Set_widget_version(widgetConfigurationInfo.version);
     row.Set_widget_id(widgetConfigurationInfo.widget_id);
     row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
     row.Set_widget_version(widgetConfigurationInfo.version);
@@ -222,32 +397,45 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo(const WidgetRegisterInfo &regInfo,
     row.Set_author_name(widgetConfigurationInfo.authorName);
     row.Set_author_email(widgetConfigurationInfo.authorEmail);
     row.Set_author_href(widgetConfigurationInfo.authorHref);
     row.Set_author_name(widgetConfigurationInfo.authorName);
     row.Set_author_email(widgetConfigurationInfo.authorEmail);
     row.Set_author_href(widgetConfigurationInfo.authorHref);
+    row.Set_csp_policy(widgetConfigurationInfo.cspPolicy);
     row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
     row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
     row.Set_base_folder(DPL::FromUTF8String(regInfo.baseFolder));
     row.Set_webkit_plugins_required(widgetConfigurationInfo.flashNeeded);
-    row.Set_child_protection(1);
     row.Set_recognized(wacSecurity.isRecognized());
     row.Set_wac_signed(wacSecurity.isWacSigned());
     row.Set_distributor_signed(wacSecurity.isDistributorSigned());
     row.Set_recognized(wacSecurity.isRecognized());
     row.Set_wac_signed(wacSecurity.isWacSigned());
     row.Set_distributor_signed(wacSecurity.isDistributorSigned());
+    row.Set_tizen_appid(tzAppId);
+    row.Set_tizen_pkgid(regInfo.tzPkgid);
     {
         std::stringstream tmp;
     {
         std::stringstream tmp;
-        tmp << widgetConfigurationInfo.minVersionRequired;
+        tmp << regInfo.minVersion;
         row.Set_min_version(DPL::FromUTF8String(tmp.str()));
     }
     row.Set_back_supported(widgetConfigurationInfo.backSupported);
     row.Set_access_network(widgetConfigurationInfo.accessNetwork);
         row.Set_min_version(DPL::FromUTF8String(tmp.str()));
     }
     row.Set_back_supported(widgetConfigurationInfo.backSupported);
     row.Set_access_network(widgetConfigurationInfo.accessNetwork);
-    row.Set_pkgname(regInfo.pkgname);
+    row.Set_pkg_type(regInfo.packagingType.pkgType);
 
 
-    wrt::WidgetInfo::app_id::ColumnType appID;
+    Try
+    {
+        DO_INSERT(row, WidgetInfo);
+    }
+    Catch(DPL::DB::SqlConnection::Exception::Base)
     {
     {
-        WRT_DB_INSERT(insert, WidgetInfo, &WrtDatabase::interface())
-        insert->Values(row);
-        appID = insert->Execute();
+        ReThrowMsg(WidgetDAO::Exception::DatabaseError,
+                   "Failed to register widget info.");
+    }
+
+    if (!handle) {
+        //get autoincremented value of widgetHandle
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::tizen_appid>(tzAppId));
+        return select->GetSingleValue<WidgetInfo::app_id>();
+    } else {
+        return *handle;
     }
     }
-    return appID;
 }
 
 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                            const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
@@ -273,32 +461,12 @@ void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
     }
 }
 
     }
 }
 
-void WidgetDAO::registerWidgetUserAgentLocales(
-        DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &/*regInfo*/,
-        const LanguageTagsList& languageTags)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-
-
-    FOREACH(i, languageTags)
-    {
-        wrt::WidgetUserAgentLocales::Row row;
-        row.Set_app_id(widgetHandle);
-        row.Set_language_tag(*i);
-
-        DO_INSERT(row, wrt::WidgetUserAgentLocales)
-    }
-}
-
 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
 void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                    const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
-
     FOREACH(i, regInfo.localizationData.icons)
     {
         wrt::WidgetIcon::icon_id::ColumnType icon_id;
     FOREACH(i, regInfo.localizationData.icons)
     {
         wrt::WidgetIcon::icon_id::ColumnType icon_id;
@@ -311,7 +479,7 @@ void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
 
             WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
             insert->Values(row);
 
             WRT_DB_INSERT(insert, wrt::WidgetIcon, &WrtDatabase::interface())
             insert->Values(row);
-            icon_id = insert->Execute();
+            icon_id = static_cast<int>(insert->Execute());
         }
 
         FOREACH(j, i->availableLocales)
         }
 
         FOREACH(j, i->availableLocales)
@@ -320,36 +488,17 @@ void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
             row.Set_app_id(widgetHandle);
             row.Set_icon_id(icon_id);
             row.Set_widget_locale(*j);
             row.Set_app_id(widgetHandle);
             row.Set_icon_id(icon_id);
             row.Set_widget_locale(*j);
-            WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
-            select->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
-                              Equals<WidgetLocalizedIcon::widget_locale>(*j)));
-            WidgetLocalizedIcon::Select::RowList rows = select->GetRowList();
-
-            bool flag = !rows.empty();
-
-            if(flag == true)
-            {
-                // already default icon value of same locale exists
-                WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface())
-                update->Where(And(Equals<WidgetLocalizedIcon::app_id>(widgetHandle),
-                                  Equals<WidgetLocalizedIcon::widget_locale>(*j)));
-                update->Values(row);
-                update->Execute();
-            }else{
-                // any icon value of same locale doesn't exist
-                DO_INSERT(row, WidgetLocalizedIcon)
-            }
+            DO_INSERT(row, WidgetLocalizedIcon)
         }
     }
 }
 
 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
         }
     }
 }
 
 void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                        const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
-
     FOREACH(i, regInfo.localizationData.startFiles)
     {
         WidgetStartFile::start_file_id::ColumnType startFileID;
     FOREACH(i, regInfo.localizationData.startFiles)
     {
         WidgetStartFile::start_file_id::ColumnType startFileID;
@@ -360,7 +509,7 @@ void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
 
             WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
             insert->Values(row);
 
             WRT_DB_INSERT(insert, WidgetStartFile, &WrtDatabase::interface())
             insert->Values(row);
-            startFileID = insert->Execute();
+            startFileID = static_cast<int>(insert->Execute());
         }
 
         FOREACH(j, i->propertiesForLocales)
         }
 
         FOREACH(j, i->propertiesForLocales)
@@ -378,32 +527,30 @@ void WidgetDAO::registerWidgetStartFile(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                       const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
 {
     using namespace DPL::DB::ORM;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
-
     FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
     {
         wrt::WidgetFeature::Row widgetFeature;
         widgetFeature.Set_app_id(widgetHandle);
         widgetFeature.Set_name(pWidgetFeature->name);
         widgetFeature.Set_required(pWidgetFeature->required);
     FOREACH(pWidgetFeature, widgetConfigurationInfo.featuresList)
     {
         wrt::WidgetFeature::Row widgetFeature;
         widgetFeature.Set_app_id(widgetHandle);
         widgetFeature.Set_name(pWidgetFeature->name);
         widgetFeature.Set_required(pWidgetFeature->required);
+        widgetFeature.Set_rejected(false);
 
         wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
         {
             WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
             insert->Values(widgetFeature);
 
         wrt::WidgetFeature::widget_feature_id::ColumnType widgetFeatureID;
         {
             WRT_DB_INSERT(insert, wrt::WidgetFeature, &WrtDatabase::interface())
             insert->Values(widgetFeature);
-            widgetFeatureID = insert->Execute();
+            widgetFeatureID = static_cast<int>(insert->Execute());
         }
 
         // Insert into table FeatureParam
         wrt::FeatureParam::Row featureParam;
         featureParam.Set_widget_feature_id(widgetFeatureID);
 
         }
 
         // Insert into table FeatureParam
         wrt::FeatureParam::Row featureParam;
         featureParam.Set_widget_feature_id(widgetFeatureID);
 
-        ConfigParserData::ParamsList::const_iterator iter;
-
         FOREACH(iter, pWidgetFeature->paramsList)
         {
             featureParam.Set_name(iter->name);
         FOREACH(iter, pWidgetFeature->paramsList)
         {
             featureParam.Set_name(iter->name);
@@ -414,14 +561,55 @@ void WidgetDAO::registerWidgetFeatures(DbWidgetHandle widgetHandle,
     }
 }
 
     }
 }
 
+void WidgetDAO::registerWidgetPrivilege(DbWidgetHandle widgetHandle,
+                                        const WidgetRegisterInfo &regInfo)
+{
+    using namespace DPL::DB::ORM;
+    const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
+
+    FOREACH(it, widgetConfigurationInfo.privilegeList)
+    {
+        wrt::WidgetPrivilege::Row widgetPrivilege;
+        widgetPrivilege.Set_app_id(widgetHandle);
+        widgetPrivilege.Set_name(it->name);
+
+        DO_INSERT(widgetPrivilege, wrt::WidgetPrivilege)
+    }
+}
+
+void WidgetDAO::updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature)
+{
+    // This function could be merged with registerWidgetFeature but it requires
+    // desing change:
+    // 1. Check "ace step" in installer must be done before "update database
+    // step"
+    // And:
+    // ConfigurationParserData shouldn't be called "ParserData" any more.
+    using namespace DPL::DB::ORM;
+
+    wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+    WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
+    select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
+                      Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
+
+    auto row = select->GetSingleRow();
+    row.Set_rejected(widgetFeature.rejected);
+
+    WRT_DB_UPDATE(update, wrt::WidgetFeature, &WrtDatabase::interface())
+    update->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
+                      Equals<wrt::WidgetFeature::name>(widgetFeature.name)));
+    update->Values(row);
+    update->Execute();
+    transaction.Commit();
+}
+
 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
 void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                          const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
-
     FOREACH(i, widgetConfigurationInfo.windowModes)
     {
         wrt::WidgetWindowModes::Row windowMode;
     FOREACH(i, widgetConfigurationInfo.windowModes)
     {
         wrt::WidgetWindowModes::Row windowMode;
@@ -433,13 +621,12 @@ void WidgetDAO::registerWidgetWindowModes(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                       const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
     const ConfigParserData& widgetConfigurationInfo = regInfo.configInfo;
 
-
     FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
     {
         WidgetWARPInfo::Row row;
     FOREACH(AccIt, widgetConfigurationInfo.accessInfoSet)
     {
         WidgetWARPInfo::Row row;
@@ -453,12 +640,11 @@ void WidgetDAO::registerWidgetWarpInfo(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
-        const IWacSecurity &wacSecurity)
+                                           const IWacSecurity &wacSecurity)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 
-
     FOREACH(it, wacSecurity.getCertificateList())
     {
         WidgetCertificateFingerprint::Row row;
     FOREACH(it, wacSecurity.getCertificateList())
     {
         WidgetCertificateFingerprint::Row row;
@@ -474,46 +660,11 @@ void WidgetDAO::registerWidgetCertificates(DbWidgetHandle widgetHandle,
     }
 }
 
     }
 }
 
-void WidgetDAO::registerWidgetPowderData(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
-{
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-
-    using namespace Powder;
-
-    FOREACH(i, regInfo.powderDescription.categories)
-    {
-        const DPL::String& categoryName(i->first);
-        const Description::CategoryEntry& categoryEntry(i->second);
-        FOREACH(l, categoryEntry.levels)
-        {
-            PowderLevels::id::ColumnType powderID;
-            {
-                PowderLevels::Row row;
-                row.Set_app_id(widgetHandle);
-                row.Set_category(categoryName);
-                row.Set_level(l->level);
-
-                WRT_DB_INSERT(insert, PowderLevels, &WrtDatabase::interface())
-                insert->Values(row);
-                powderID = insert->Execute();
-            }
-
-            FOREACH(c, l->context)
-            {
-                PowderLevelContexts::Row row;
-                row.Set_levelId(powderID);
-                row.Set_context(*c);
-
-                DO_INSERT(row, PowderLevelContexts)
-            }
-        }
-    }
-}
-
-void WidgetDAO::registerLaunchCertificates(DbWidgetHandle widgetHandle,
-        const CertificateChainList &certificateChainList)
+void WidgetDAO::registerCertificatesChains(
+    DbWidgetHandle widgetHandle,
+    CertificateSource certificateSource,
+    const CertificateChainList &
+    certificateChainList)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
@@ -521,6 +672,7 @@ void WidgetDAO::registerLaunchCertificates(DbWidgetHandle widgetHandle,
     {
         WidgetCertificate::Row row;
         row.Set_app_id(widgetHandle);
     {
         WidgetCertificate::Row row;
         row.Set_app_id(widgetHandle);
+        row.Set_cert_source(certificateSource);
         row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
 
         DO_INSERT(row, WidgetCertificate);
         row.Set_encoded_chain(DPL::FromASCIIString(*certChain));
 
         DO_INSERT(row, WidgetCertificate);
@@ -528,7 +680,7 @@ void WidgetDAO::registerLaunchCertificates(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
 }
 
 void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
-        const WidgetRegisterInfo &regInfo)
+                                       const WidgetRegisterInfo &regInfo)
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
 {
     using namespace DPL::DB::ORM;
     using namespace DPL::DB::ORM::wrt;
@@ -537,12 +689,12 @@ void WidgetDAO::registerWidgetSettings(DbWidgetHandle widgetHandle,
 
     FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
     {
 
     FOREACH(pWidgetSetting, widgetConfigurationInfo.settingsList)
     {
-        SettginsList::Row row;
+        SettingsList::Row row;
         row.Set_appId(widgetHandle);
         row.Set_settingName(pWidgetSetting->m_name);
         row.Set_settingValue(pWidgetSetting->m_value);
 
         row.Set_appId(widgetHandle);
         row.Set_settingName(pWidgetSetting->m_name);
         row.Set_settingValue(pWidgetSetting->m_value);
 
-        DO_INSERT(row, SettginsList)
+        DO_INSERT(row, SettingsList)
     }
 }
 
     }
 }
 
@@ -566,35 +718,123 @@ void WidgetDAO::registerAppService(DbWidgetHandle widgetHandle,
     }
 }
 
     }
 }
 
-#undef DO_INSERT
+void WidgetDAO::registerEncryptedResouceInfo(DbWidgetHandle widgetHandle,
+                                             const WidgetRegisterInfo &regInfo)
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+
+    FOREACH(it, regInfo.encryptedFiles)
+    {
+        EncryptedResourceList::Row row;
+        row.Set_app_id(widgetHandle);
+        row.Set_resource(it->fileName);
+        row.Set_size(it->fileSize);
 
 
-void WidgetDAO::unregisterWidget(DbWidgetHandle widgetHandle)
+        DO_INSERT(row, EncryptedResourceList)
+    }
+}
+
+void WidgetDAO::registerExternalLocations(
+    DbWidgetHandle widgetHandle,
+    const ExternalLocationList &
+    externals)
 {
 {
-    LogDebug("Unregistering widget from DB. Handle: " << widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
         using namespace DPL::DB::ORM;
         using namespace DPL::DB::ORM::wrt;
-
-        CHECK_WIDGET_EXISTENCE(transaction, widgetHandle)
-
-        // Delete from table Widget Info
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
+        LogDebug("Inserting external files for widgetHandle: " << widgetHandle);
+        FOREACH(it, externals)
         {
         {
-            WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
-            del->Where(Equals<WidgetInfo::app_id>(widgetHandle));
-            del->Execute();
+            WidgetExternalLocations::Row row;
+            row.Set_app_id(widgetHandle);
+            row.Set_path(DPL::FromUTF8String(*it));
+
+            DO_INSERT(row, WidgetExternalLocations)
         }
         }
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files");
+}
+
+void WidgetDAO::registerWidgetSecuritySettings(DbWidgetHandle widgetHandle)
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+    WidgetSecuritySettings::Row row;
+    row.Set_app_id(widgetHandle);
+    row.Set_security_popup_usage(SETTINGS_TYPE_ON);
+    row.Set_geolocation_usage(SETTINGS_TYPE_ON);
+    row.Set_web_notification_usage(SETTINGS_TYPE_ON);
+    row.Set_web_database_usage(SETTINGS_TYPE_ON);
+    row.Set_file_system_usage(SETTINGS_TYPE_ON);
+
+    DO_INSERT(row, WidgetSecuritySettings)
+}
+
+void WidgetDAO::unregisterAllExternalLocations()
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+    LogDebug("Deleting external files for widgetHandle: " << m_widgetHandle);
+    WRT_DB_DELETE(del, WidgetExternalLocations, &WrtDatabase::interface());
+    del->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
+    del->Execute();
+}
+
+void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId)
+{
+    LogDebug("Unregistering widget from DB. tzAppId: " << tzAppId);
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        DPL::DB::ORM::wrt::ScopedTransaction transaction(
+            &WrtDatabase::interface());
+        unregisterWidgetInternal(tzAppId);
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
+}
+
+void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
+{
+    LogDebug("Unregistering widget from DB. Handle: " << handle);
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        ScopedTransaction transaction(&WrtDatabase::interface());
 
 
-        // Deleting in other tables is done via "delete cascade" in SQL
+        // Delete from table Widget Info
+        WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
+        del->Where(Equals<WidgetInfo::app_id>(handle));
+        del->Execute();
 
         transaction.Commit();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
 }
 
 
         transaction.Commit();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
 }
 
+void WidgetDAO::unregisterWidgetInternal(
+    const TizenAppId & tzAppId)
+{
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::wrt;
+
+    DbWidgetHandle handle = getHandle(tzAppId);
+
+    // Delete from table Widget Info
+    WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
+    del->Where(Equals<WidgetInfo::app_id>(handle));
+    del->Execute();
+
+    // Deleting in other tables is done via "delete cascade" in SQL
+}
+
+#undef DO_INSERT
+
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
-#undef CHECK_WIDGET_EXISTENCE
-
 } // namespace WrtDB
 } // namespace WrtDB
index d3c9377..f8fdf0b 100644 (file)
@@ -23,7 +23,7 @@
  * @version 1.0
  * @brief   This file contains the declaration of widget dao
  */
  * @version 1.0
  * @brief   This file contains the declaration of widget dao
  */
-
+#include <stddef.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
 #include <sstream>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
 #include <sstream>
@@ -35,9 +35,9 @@
 #include <dpl/wrt-dao-ro/widget_config.h>
 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
 #include <orm_generator_wrt.h>
 #include <dpl/wrt-dao-ro/widget_config.h>
 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
 #include <orm_generator_wrt.h>
+#include <LanguageTagsProvider.h>
 
 namespace WrtDB {
 
 namespace WrtDB {
-
 //TODO in current solution in each getter there exists a check
 //"IsWidgetInstalled". Maybe it should be verified, if it could be done
 //differently  (check in WidgetDAOReadOnly constructor)
 //TODO in current solution in each getter there exists a check
 //"IsWidgetInstalled". Maybe it should be verified, if it could be done
 //differently  (check in WidgetDAOReadOnly constructor)
@@ -60,20 +60,21 @@ namespace WrtDB {
                  "Cannot find widget. Handle: " << macro_handle);        \
     }
 
                  "Cannot find widget. Handle: " << macro_handle);        \
     }
 
-
 typedef DPL::DB::ORM::wrt::WidgetInfo::Row WidgetInfoRow;
 typedef DPL::DB::ORM::wrt::WidgetFeature::widget_feature_id::ColumnType
 typedef DPL::DB::ORM::wrt::WidgetInfo::Row WidgetInfoRow;
 typedef DPL::DB::ORM::wrt::WidgetFeature::widget_feature_id::ColumnType
-        WidgetFeatureId;
+WidgetFeatureId;
+typedef DPL::DB::ORM::wrt::WidgetSecuritySettings::Row
+WidgetSecuritySettingsRow;
 
 namespace {
 
 namespace {
+using namespace DPL::DB::ORM;
+using namespace DPL::DB::ORM::wrt;
 
 WidgetInfoRow getWidgetInfoRow(int widgetHandle)
 {
     LogDebug("Getting WidgetInfo row. Handle: " << widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 
 WidgetInfoRow getWidgetInfoRow(int widgetHandle)
 {
     LogDebug("Getting WidgetInfo row. Handle: " << widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetInfo::app_id>(widgetHandle));
 
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetInfo::app_id>(widgetHandle));
 
@@ -87,21 +88,88 @@ WidgetInfoRow getWidgetInfoRow(int widgetHandle)
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in GetWidgetInfoRow")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in GetWidgetInfoRow")
 }
 
-} // namespace
+WidgetSecuritySettingsRow getWidgetSecuritySettingsRow(int widgetHandle)
+{
+    LogDebug("Getting WidgetSecuritySettings row. Handle: " << widgetHandle);
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, WidgetSecuritySettings, &WrtDatabase::interface())
+        select->Where(Equals<WidgetSecuritySettings::app_id>(widgetHandle));
+
+        WidgetSecuritySettings::Select::RowList rows = select->GetRowList();
+        if (rows.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << widgetHandle);
+        }
+        return rows.front();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END(
+        "Failed in getWidgetSecuritySettingsRow")
+}
 
 
+const int MAX_TIZENID_LENGTH = 10;
 
 
-IWacSecurity::~IWacSecurity()
+TizenAppId getTizenAppIdByHandle(const DbWidgetHandle handle)
 {
 {
+    LogDebug("Getting TizenAppId by DbWidgetHandle: " << handle);
+
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::app_id>(handle));
+        WidgetInfo::Select::RowList rowList = select->GetRowList();
+
+        if (rowList.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Failed to get widget by handle");
+        }
+        TizenAppId tzAppid = rowList.front().Get_tizen_appid();
+
+        return tzAppid;
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
 }
 
 }
 
-WidgetDAOReadOnly::WidgetDAOReadOnly(DbWidgetHandle widgetHandle) :
-    m_widgetHandle(widgetHandle)
+TizenAppId getTizenAppIdByPkgId(const TizenPkgId tzPkgid)
 {
 {
+    LogDebug("Getting TizenAppId by pkgid : " << tzPkgid);
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::tizen_pkgid>(tzPkgid));
+        WidgetInfo::Select::RowList rowList = select->GetRowList();
+
+        if (rowList.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Failed to get widget by handle");
+        }
+        TizenAppId tzAppid = rowList.front().Get_tizen_appid();
+
+        return tzAppid;
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
 }
 }
+} // namespace
+
+IWacSecurity::~IWacSecurity()
+{}
+
+WidgetDAOReadOnly::WidgetDAOReadOnly(DbWidgetHandle widgetHandle) :
+    m_widgetHandle(widgetHandle)
+{}
+
+WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::OptionalString widgetGUID) :
+    m_widgetHandle(WidgetDAOReadOnly::getHandle(widgetGUID))
+{}
+
+WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::String tzAppid) :
+    m_widgetHandle(WidgetDAOReadOnly::getHandle(tzAppid))
+{}
 
 WidgetDAOReadOnly::~WidgetDAOReadOnly()
 
 WidgetDAOReadOnly::~WidgetDAOReadOnly()
-{
-}
+{}
 
 DbWidgetHandle WidgetDAOReadOnly::getHandle() const
 {
 
 DbWidgetHandle WidgetDAOReadOnly::getHandle() const
 {
@@ -114,95 +182,103 @@ DbWidgetHandle WidgetDAOReadOnly::getHandle(const WidgetGUID GUID)
 
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetInfo::widget_id>(GUID));
         WidgetInfo::Select::RowList rowList = select->GetRowList();
 
         if (rowList.empty()) {
             ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetInfo::widget_id>(GUID));
         WidgetInfo::Select::RowList rowList = select->GetRowList();
 
         if (rowList.empty()) {
             ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
-                 "Failed to get widget by guid");
+                     "Failed to get widget by guid");
         }
         return rowList.front().Get_app_id();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
         }
         return rowList.front().Get_app_id();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
-
-    ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
-                     "Failed to get widget by guid");
 }
 
 }
 
-DbWidgetHandle WidgetDAOReadOnly::getHandle(const DPL::String pkgName)
+DbWidgetHandle WidgetDAOReadOnly::getHandle(const DPL::String tzAppId)
 {
 {
-    LogDebug("Getting WidgetHandle by Package Name [" << pkgName << "]");
+    LogDebug("Getting WidgetHandle by tizen app id [" << tzAppId << "]");
 
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
-        select->Where(Equals<WidgetInfo::pkgname>(pkgName));
+        select->Where(Equals<WidgetInfo::tizen_appid>(tzAppId));
         WidgetInfo::Select::RowList rowList = select->GetRowList();
 
         if (rowList.empty()) {
             ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
         WidgetInfo::Select::RowList rowList = select->GetRowList();
 
         if (rowList.empty()) {
             ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
-                 "Failed to get widget by package name");
+                     "Failed to get widget by package name");
         }
         return rowList.front().Get_app_id();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
         }
         return rowList.front().Get_app_id();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
+}
 
 
-    ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
-                     "Failed to get widget by package name");
+WidgetPkgName WidgetDAOReadOnly::getPkgName() const
+{
+    return getTzAppId();
+}
+
+WidgetPkgName WidgetDAOReadOnly::getPkgName(const WidgetGUID GUID)
+{
+    return getTzAppId(GUID);
+}
+
+WidgetPkgName WidgetDAOReadOnly::getPkgName(const DbWidgetHandle handle)
+{
+    return getTzAppId(handle);
+}
+
+TizenAppId WidgetDAOReadOnly::getTzAppId() const
+{
+    return getTizenAppIdByHandle(m_widgetHandle);
+}
+
+TizenAppId WidgetDAOReadOnly::getTzAppId(const WidgetGUID GUID)
+{
+    return getTizenAppIdByHandle(getHandle(GUID));
+}
+
+TizenAppId WidgetDAOReadOnly::getTzAppId(const DbWidgetHandle handle)
+{
+    return getTizenAppIdByHandle(handle);
+}
+
+TizenAppId WidgetDAOReadOnly::getTzAppId(const TizenPkgId tzPkgid)
+{
+    return getTizenAppIdByPkgId(tzPkgid);
 }
 
 PropertyDAOReadOnly::WidgetPropertyKeyList
 WidgetDAOReadOnly::getPropertyKeyList() const
 {
 }
 
 PropertyDAOReadOnly::WidgetPropertyKeyList
 WidgetDAOReadOnly::getPropertyKeyList() const
 {
-    return PropertyDAOReadOnly::GetPropertyKeyList(m_widgetHandle);
+    return PropertyDAOReadOnly::GetPropertyKeyList(getTzAppId());
 }
 
 PropertyDAOReadOnly::WidgetPreferenceList
 WidgetDAOReadOnly::getPropertyList() const
 {
 }
 
 PropertyDAOReadOnly::WidgetPreferenceList
 WidgetDAOReadOnly::getPropertyList() const
 {
-    return PropertyDAOReadOnly::GetPropertyList(m_widgetHandle);
+    return PropertyDAOReadOnly::GetPropertyList(getTzAppId());
 }
 
 PropertyDAOReadOnly::WidgetPropertyValue WidgetDAOReadOnly::getPropertyValue(
 }
 
 PropertyDAOReadOnly::WidgetPropertyValue WidgetDAOReadOnly::getPropertyValue(
-        const PropertyDAOReadOnly::WidgetPropertyKey &key) const
+    const PropertyDAOReadOnly::WidgetPropertyKey &key) const
 {
 {
-    return PropertyDAOReadOnly::GetPropertyValue(m_widgetHandle, key);
+    return PropertyDAOReadOnly::GetPropertyValue(getTzAppId(), key);
 }
 
 DPL::OptionalInt WidgetDAOReadOnly::checkPropertyReadFlag(
 }
 
 DPL::OptionalInt WidgetDAOReadOnly::checkPropertyReadFlag(
-        const PropertyDAOReadOnly::WidgetPropertyKey &key) const
+    const PropertyDAOReadOnly::WidgetPropertyKey &key) const
 {
 {
-    return PropertyDAOReadOnly::CheckPropertyReadFlag(m_widgetHandle, key);
+    return PropertyDAOReadOnly::CheckPropertyReadFlag(getTzAppId(), key);
 }
 
 DPL::String WidgetDAOReadOnly::getPath() const
 {
 }
 
 DPL::String WidgetDAOReadOnly::getPath() const
 {
-    DPL::String path = DPL::FromUTF8String(
-            GlobalConfig::GetUserInstalledWidgetPath());
+    DPL::String path = *getWidgetInstalledPath();
     DPL::String srcPath = DPL::FromUTF8String(GlobalConfig::GetWidgetSrcPath());
 
     DPL::String srcPath = DPL::FromUTF8String(GlobalConfig::GetWidgetSrcPath());
 
-    bool isFactoryWidget = isFactory();
-
-    if (isFactoryWidget) {
-        WidgetGUID widgetGUID = getGUID();
-        if (!widgetGUID) {
-            Throw(WidgetDAOReadOnly::Exception::GUIDisNull);
-        }
-        path += L"/" + *widgetGUID + L"/";
-    } else {
-        // if the widget is a "downloaded widget",
-        // use unique package name.
-        DPL::OStringStream strAppId;
-        strAppId << m_widgetHandle;
-        DPL::OptionalString pkgname = getPkgname();
-        path += L"/" + *pkgname + L"/";
-        path += srcPath + L"/";
-    }
+    path += srcPath + L"/";
 
     return path;
 }
 
     return path;
 }
@@ -213,17 +289,15 @@ DPL::String WidgetDAOReadOnly::getFullPath() const
 }
 
 WidgetLocalizedInfo
 }
 
 WidgetLocalizedInfo
-        WidgetDAOReadOnly::getLocalizedInfo(const DPL::String& languageTag)
-        const
+WidgetDAOReadOnly::getLocalizedInfo(const DPL::String& languageTag)
+const
 {
     LogDebug("Getting Localized Info. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     LogDebug("Getting Localized Info. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        ScopedTransaction transaction(&WrtDatabase::interface());
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, LocalizedWidgetInfo, &WrtDatabase::interface())
         select->Where(
             And(Equals<LocalizedWidgetInfo::app_id>(m_widgetHandle),
         WRT_DB_SELECT(select, LocalizedWidgetInfo, &WrtDatabase::interface())
         select->Where(
             And(Equals<LocalizedWidgetInfo::app_id>(m_widgetHandle),
@@ -248,22 +322,21 @@ DbWidgetFeatureSet WidgetDAOReadOnly::getFeaturesList() const
     LogDebug("Getting FeaturesList. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     LogDebug("Getting FeaturesList. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        ScopedTransaction transaction(&WrtDatabase::interface());
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, DPL::DB::ORM::wrt::WidgetFeature, &WrtDatabase::interface())
-        select->Where(Equals<DPL::DB::ORM::wrt::WidgetFeature::app_id>(m_widgetHandle));
+        WRT_DB_SELECT(select, WidgetFeature, &WrtDatabase::interface())
+        select->Where(Equals<WidgetFeature::app_id>(m_widgetHandle));
 
         DbWidgetFeatureSet resultSet;
 
         DbWidgetFeatureSet resultSet;
-        typedef std::list<DPL::DB::ORM::wrt::WidgetFeature::Row> RowList;
+        typedef std::list<WidgetFeature::Row> RowList;
         RowList list = select->GetRowList();
 
         for (RowList::iterator i = list.begin(); i != list.end(); ++i) {
             DbWidgetFeature feature;
             feature.name = i->Get_name();
             feature.required = i->Get_required();
         RowList list = select->GetRowList();
 
         for (RowList::iterator i = list.begin(); i != list.end(); ++i) {
             DbWidgetFeature feature;
             feature.name = i->Get_name();
             feature.required = i->Get_required();
+            feature.rejected = i->Get_rejected();
             feature.params = getFeatureParams(i->Get_widget_feature_id());
             FeatureDAOReadOnly featureDao(DPL::ToUTF8String(i->Get_name()));
             feature.pluginId = featureDao.GetPluginHandle();
             feature.params = getFeatureParams(i->Get_widget_feature_id());
             FeatureDAOReadOnly featureDao(DPL::ToUTF8String(i->Get_name()));
             feature.pluginId = featureDao.GetPluginHandle();
@@ -281,18 +354,16 @@ WidgetParamMap WidgetDAOReadOnly::getFeatureParams(int id)
     LogDebug("Getting feature Params. featureId: " << widgetFeatureId);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     LogDebug("Getting feature Params. featureId: " << widgetFeatureId);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, DPL::DB::ORM::wrt::FeatureParam, &WrtDatabase::interface())
-        select->Where(Equals<DPL::DB::ORM::wrt::FeatureParam::widget_feature_id>(
+        WRT_DB_SELECT(select, FeatureParam, &WrtDatabase::interface())
+        select->Where(Equals<FeatureParam::widget_feature_id>(
                           widgetFeatureId));
 
         WidgetParamMap resultMap;
                           widgetFeatureId));
 
         WidgetParamMap resultMap;
-        typedef std::list<DPL::DB::ORM::wrt::FeatureParam::Row> RowList;
+        typedef std::list<FeatureParam::Row> RowList;
         RowList list = select->GetRowList();
 
         FOREACH(i, list)
         RowList list = select->GetRowList();
 
         FOREACH(i, list)
-            resultMap.insert(std::make_pair(i->Get_name(), i->Get_value()));
+        resultMap.insert(std::make_pair(i->Get_name(), i->Get_value()));
 
         return resultMap;
     }
 
         return resultMap;
     }
@@ -306,11 +377,9 @@ bool WidgetDAOReadOnly::hasFeature(const std::string& featureName) const
         m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
         m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        ScopedTransaction transaction(&WrtDatabase::interface());
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
         select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
                           Equals<wrt::WidgetFeature::name>(
         WRT_DB_SELECT(select, wrt::WidgetFeature, &WrtDatabase::interface())
         select->Where(And(Equals<wrt::WidgetFeature::app_id>(m_widgetHandle),
                           Equals<wrt::WidgetFeature::name>(
@@ -328,11 +397,9 @@ HostList WidgetDAOReadOnly::getAccessHostList() const
     LogDebug("Getting AccessHostList. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     LogDebug("Getting AccessHostList. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        ScopedTransaction transaction(&WrtDatabase::interface());
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetAccessHost, &WrtDatabase::interface())
         select->Where(Equals<WidgetAccessHost::app_id>(m_widgetHandle));
         std::list<WidgetAccessHost::host::ColumnType> values =
         WRT_DB_SELECT(select, WidgetAccessHost, &WrtDatabase::interface())
         select->Where(Equals<WidgetAccessHost::app_id>(m_widgetHandle));
         std::list<WidgetAccessHost::host::ColumnType> values =
@@ -359,21 +426,49 @@ DbWidgetHandleList WidgetDAOReadOnly::getHandleList()
     LogDebug("Getting DbWidgetHandle List");
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     LogDebug("Getting DbWidgetHandle List");
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         return select->GetValueList<WidgetInfo::app_id>();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get handle list")
 }
 
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         return select->GetValueList<WidgetInfo::app_id>();
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get handle list")
 }
 
+WidgetPkgNameList WidgetDAOReadOnly::getPkgnameList()
+{
+    LogDebug("Getting Pkgname List ");
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        return select->GetValueList<WidgetInfo::tizen_appid>();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get Pkgname list")
+}
+
+TizenAppIdList WidgetDAOReadOnly::getTizenAppidList()
+{
+    LogDebug("Getting Pkgname List ");
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        return select->GetValueList<WidgetInfo::tizen_appid>();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get Pkgname list")
+}
+
+DbWidgetDAOReadOnlyList WidgetDAOReadOnly::getWidgetList()
+{
+    LogDebug("Getting DbWidget List");
+    DbWidgetDAOReadOnlyList list;
+    FOREACH(iterator, getHandleList()) {
+        list.push_back(WidgetDAOReadOnlyPtr(new WidgetDAOReadOnly(*iterator)));
+    }
+    return list;
+}
+
 bool WidgetDAOReadOnly::isWidgetInstalled(DbWidgetHandle handle)
 {
     LogDebug("Checking if widget exist. Handle: " << handle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 bool WidgetDAOReadOnly::isWidgetInstalled(DbWidgetHandle handle)
 {
     LogDebug("Checking if widget exist. Handle: " << handle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetInfo::app_id>(handle));
 
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetInfo::app_id>(handle));
 
@@ -384,15 +479,13 @@ bool WidgetDAOReadOnly::isWidgetInstalled(DbWidgetHandle handle)
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to check if widget exist")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to check if widget exist")
 }
 
-bool WidgetDAOReadOnly::isWidgetInstalled(DPL::String pkgName)
+bool WidgetDAOReadOnly::isWidgetInstalled(const TizenAppId &tzAppId)
 {
 {
-    LogDebug("Checking if widget exist. package name " << pkgName);
+    LogDebug("Checking if widget exist. tizen app id" << tzAppId);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
         WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
-        select->Where(Equals<WidgetInfo::pkgname>(pkgName));
+        select->Where(Equals<WidgetInfo::tizen_appid>(tzAppId));
 
         WidgetInfo::Select::RowList rows = select->GetRowList();
 
 
         WidgetInfo::Select::RowList rows = select->GetRowList();
 
@@ -401,19 +494,39 @@ bool WidgetDAOReadOnly::isWidgetInstalled(DPL::String pkgName)
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to check if widget exist")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to check if widget exist")
 }
 
-CertificateChainList WidgetDAOReadOnly::getWidgetCertificate() const
+ExternalLocationList WidgetDAOReadOnly::getWidgetExternalLocations() const
+{
+    LogDebug("Getting WidgetExtranalFiles List");
+    ExternalLocationList result;
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetExternalLocations, &WrtDatabase::interface());
+        select->Where(Equals<WidgetExternalLocations::app_id>(m_widgetHandle));
+        WidgetExternalLocations::Select::RowList rows = select->GetRowList();
+        FOREACH(it, rows)
+        {
+            result.push_back(DPL::ToUTF8String(it->Get_path()));
+        }
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get handle list")
+    return result;
+}
+
+CertificateChainList WidgetDAOReadOnly::getWidgetCertificate(
+    CertificateSource source) const
 {
 {
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
     WRT_DB_SELECT(select, WidgetCertificate, &WrtDatabase::interface())
     WRT_DB_SELECT(select, WidgetCertificate, &WrtDatabase::interface())
-    select->Where(Equals<WidgetCertificate::app_id>(m_widgetHandle));
+    select->Where(
+        And(
+            Equals<WidgetCertificate::app_id>(m_widgetHandle),
+            Equals<WidgetCertificate::cert_source>(source)));
 
 
-    std::list<DPL::DB::ORM::wrt::WidgetCertificate::Row> chainList = select->GetRowList();
+    std::list<WidgetCertificate::Row> chainList = select->GetRowList();
 
     CertificateChainList result;
 
     FOREACH(iter, chainList)
 
     CertificateChainList result;
 
     FOREACH(iter, chainList)
-        result.push_back(DPL::ToUTF8String(iter->Get_encoded_chain()));
+    result.push_back(DPL::ToUTF8String(iter->Get_encoded_chain()));
     return result;
 }
 
     return result;
 }
 
@@ -445,10 +558,9 @@ WidgetGUID WidgetDAOReadOnly::getGUID() const
     return row.Get_widget_id();
 }
 
     return row.Get_widget_id();
 }
 
-DPL::OptionalString WidgetDAOReadOnly::getPkgname() const
+DPL::OptionalString WidgetDAOReadOnly::getTizenAppId() const
 {
 {
-    WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
-    return row.Get_pkgname();
+    return DPL::OptionalString(getTzAppId());
 }
 
 DPL::OptionalString WidgetDAOReadOnly::getDefaultlocale() const
 }
 
 DPL::OptionalString WidgetDAOReadOnly::getDefaultlocale() const
@@ -491,8 +603,6 @@ std::string WidgetDAOReadOnly::getShareHref() const
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
         WidgetExtendedInfo::Select::RowList rows = select->GetRowList();
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
         WidgetExtendedInfo::Select::RowList rows = select->GetRowList();
@@ -558,8 +668,6 @@ bool WidgetDAOReadOnly::isTrusted() const
 bool WidgetDAOReadOnly::isTestWidget() const
 {
     Try {
 bool WidgetDAOReadOnly::isTestWidget() const
 {
     Try {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
 
@@ -577,20 +685,27 @@ bool WidgetDAOReadOnly::isTestWidget() const
     }
 }
 
     }
 }
 
+DPL::OptionalString WidgetDAOReadOnly::getCspPolicy() const
+{
+    WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
+    return row.Get_csp_policy();
+}
+
 bool WidgetDAOReadOnly::getWebkitPluginsRequired() const
 {
     WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
     DPL::OptionalInt ret = row.Get_webkit_plugins_required();
 
 bool WidgetDAOReadOnly::getWebkitPluginsRequired() const
 {
     WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
     DPL::OptionalInt ret = row.Get_webkit_plugins_required();
 
-    if (ret.IsNull() || *ret == 0) { return false; } else { return true; }
+    if (ret.IsNull() || *ret == 0) {
+        return false;
+    } else { return true;
+    }
 }
 
 }
 
-bool WidgetDAOReadOnly::isFactory() const
+time_t WidgetDAOReadOnly::getInstallTime() const
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
 
@@ -600,21 +715,15 @@ bool WidgetDAOReadOnly::isFactory() const
                      "Cannot find widget. Handle: " << m_widgetHandle);
         }
 
                      "Cannot find widget. Handle: " << m_widgetHandle);
         }
 
-        DPL::OptionalInt ret = rows.front().Get_factory_widget();
-        if (ret.IsNull()) {
-            return false;
-        }
-        return static_cast<bool>(*ret);
+        return static_cast<time_t>(*rows.front().Get_install_time());
     }
     }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get isFactory")
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get widdget install time")
 }
 
 }
 
-time_t WidgetDAOReadOnly::getInstallTime() const
+DPL::OptionalString WidgetDAOReadOnly::getSplashImgSrc() const
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
 
@@ -624,29 +733,33 @@ time_t WidgetDAOReadOnly::getInstallTime() const
                      "Cannot find widget. Handle: " << m_widgetHandle);
         }
 
                      "Cannot find widget. Handle: " << m_widgetHandle);
         }
 
-        return static_cast<time_t>(*rows.front().Get_install_time());
+        DPL::OptionalString value = rows.front().Get_splash_img_src();
+        if (value.IsNull()) {
+            return DPL::OptionalString::Null;
+        }
+
+        return DPL::OptionalString(getPath() + *value);
     }
     }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get widdget install time")
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get splash image path")
 }
 
 }
 
-WidgetDAOReadOnly::WidgetLocalizedIconList WidgetDAOReadOnly::getLocalizedIconList() const
+WidgetDAOReadOnly::WidgetLocalizedIconList WidgetDAOReadOnly::
+    getLocalizedIconList() const
 {
     //TODO check widget existance??
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance??
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
         select->Where(Equals<WidgetLocalizedIcon::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
         select->Where(Equals<WidgetLocalizedIcon::app_id>(m_widgetHandle));
 
-        std::list<DPL::DB::ORM::wrt::WidgetLocalizedIcon::Row> list =
-                select->GetRowList();
+        std::list<WidgetLocalizedIcon::Row> list =
+            select->GetRowList();
         WidgetLocalizedIconList ret;
         WidgetLocalizedIconList ret;
-        FOREACH(it,list)
+        FOREACH(it, list)
         {
         {
-            WidgetLocalizedIconRow icon = {it->Get_app_id(),
-                                           it->Get_icon_id(),
-                                           it->Get_widget_locale()};
+            WidgetLocalizedIconRow icon = { it->Get_app_id(),
+                                            it->Get_icon_id(),
+                                            it->Get_widget_locale() };
             ret.push_back(icon);
         }
         return ret;
             ret.push_back(icon);
         }
         return ret;
@@ -659,21 +772,21 @@ WidgetDAOReadOnly::WidgetIconList WidgetDAOReadOnly::getIconList() const
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, wrt::WidgetIcon, &WrtDatabase::interface())
         select->Where(Equals<wrt::WidgetIcon::app_id>(m_widgetHandle));
         WRT_DB_SELECT(select, wrt::WidgetIcon, &WrtDatabase::interface())
         select->Where(Equals<wrt::WidgetIcon::app_id>(m_widgetHandle));
+        select->OrderBy(DPL::TypeListDecl<OrderingAscending<wrt::WidgetIcon::
+                                                                icon_id> >());
 
 
-        std::list<DPL::DB::ORM::wrt::WidgetIcon::Row> list =
-                select->GetRowList();
+        std::list<WidgetIcon::Row> list =
+            select->GetRowList();
         WidgetIconList ret;
         WidgetIconList ret;
-        FOREACH(it,list)
+        FOREACH(it, list)
         {
         {
-            WidgetIconRow icon = {it->Get_icon_id(),
-                                  it->Get_app_id(),
-                                  it->Get_icon_src(),
-                                  it->Get_icon_width(),
-                                  it->Get_icon_height()};
+            WidgetIconRow icon = { it->Get_icon_id(),
+                                   it->Get_app_id(),
+                                   it->Get_icon_src(),
+                                   it->Get_icon_width(),
+                                   it->Get_icon_height() };
             ret.push_back(icon);
         }
         return ret;
             ret.push_back(icon);
         }
         return ret;
@@ -681,28 +794,27 @@ WidgetDAOReadOnly::WidgetIconList WidgetDAOReadOnly::getIconList() const
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get icon data")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get icon data")
 }
 
-WidgetDAOReadOnly::LocalizedStartFileList WidgetDAOReadOnly::getLocalizedStartFileList() const
+WidgetDAOReadOnly::LocalizedStartFileList WidgetDAOReadOnly::
+    getLocalizedStartFileList() const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetLocalizedStartFile, &WrtDatabase::interface())
         select->Where(Equals<WidgetLocalizedStartFile::app_id>(
                           m_widgetHandle));
         select->OrderBy("start_file_id ASC");
 
         WRT_DB_SELECT(select, WidgetLocalizedStartFile, &WrtDatabase::interface())
         select->Where(Equals<WidgetLocalizedStartFile::app_id>(
                           m_widgetHandle));
         select->OrderBy("start_file_id ASC");
 
-        std::list<DPL::DB::ORM::wrt::WidgetLocalizedStartFile::Row> list =
-                select->GetRowList();
+        std::list<WidgetLocalizedStartFile::Row> list =
+            select->GetRowList();
         LocalizedStartFileList ret;
         LocalizedStartFileList ret;
-        FOREACH(it,list)
+        FOREACH(it, list)
         {
         {
-            WidgetLocalizedStartFileRow file = {it->Get_start_file_id(),
-                                                it->Get_app_id(),
-                                                it->Get_widget_locale(),
-                                                it->Get_type(),
-                                                it->Get_encoding()};
+            WidgetLocalizedStartFileRow file = { it->Get_start_file_id(),
+                                                 it->Get_app_id(),
+                                                 it->Get_widget_locale(),
+                                                 it->Get_type(),
+                                                 it->Get_encoding() };
             ret.push_back(file);
         }
         return ret;
             ret.push_back(file);
         }
         return ret;
@@ -710,25 +822,24 @@ WidgetDAOReadOnly::LocalizedStartFileList WidgetDAOReadOnly::getLocalizedStartFi
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get start file list data")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get start file list data")
 }
 
-WidgetDAOReadOnly::WidgetStartFileList WidgetDAOReadOnly::getStartFileList() const
+WidgetDAOReadOnly::WidgetStartFileList WidgetDAOReadOnly::getStartFileList()
+const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetStartFile, &WrtDatabase::interface())
         select->Where(Equals<WidgetStartFile::app_id>(m_widgetHandle));
         select->OrderBy("start_file_id ASC");
 
         WRT_DB_SELECT(select, WidgetStartFile, &WrtDatabase::interface())
         select->Where(Equals<WidgetStartFile::app_id>(m_widgetHandle));
         select->OrderBy("start_file_id ASC");
 
-        std::list<DPL::DB::ORM::wrt::WidgetStartFile::Row> list =
-                select->GetRowList();
+        std::list<WidgetStartFile::Row> list =
+            select->GetRowList();
         WidgetStartFileList ret;
         WidgetStartFileList ret;
-        FOREACH(it,list)
+        FOREACH(it, list)
         {
         {
-            WidgetStartFileRow file = {it->Get_start_file_id(),
-                                       it->Get_app_id(),
-                                       it->Get_src()};
+            WidgetStartFileRow file = { it->Get_start_file_id(),
+                                        it->Get_app_id(),
+                                        it->Get_src() };
             ret.push_back(file);
         }
         return ret;
             ret.push_back(file);
         }
         return ret;
@@ -741,8 +852,6 @@ WindowModeList WidgetDAOReadOnly::getWindowModes() const
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetWindowModes, &WrtDatabase::interface())
         select->Where(Equals<WidgetWindowModes::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, WidgetWindowModes, &WrtDatabase::interface())
         select->Where(Equals<WidgetWindowModes::app_id>(m_widgetHandle));
 
@@ -767,19 +876,14 @@ std::string WidgetDAOReadOnly::getBaseFolder() const
     return baseFolder;
 }
 
     return baseFolder;
 }
 
-bool WidgetDAOReadOnly::isDeletable() const
-{
-    return !WidgetDAOReadOnly::isFactory();
-}
-
 WidgetCertificateDataList WidgetDAOReadOnly::getCertificateDataList() const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 WidgetCertificateDataList WidgetDAOReadOnly::getCertificateDataList() const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, WidgetCertificateFingerprint, &WrtDatabase::interface())
+        WRT_DB_SELECT(select,
+                      WidgetCertificateFingerprint,
+                      &WrtDatabase::interface())
         select->Where(Equals<WidgetCertificateFingerprint::app_id>(
                           m_widgetHandle));
         select->OrderBy("chainid");
         select->Where(Equals<WidgetCertificateFingerprint::app_id>(
                           m_widgetHandle));
         select->OrderBy("chainid");
@@ -814,19 +918,20 @@ WidgetCertificateDataList WidgetDAOReadOnly::getCertificateDataList() const
 }
 
 FingerPrintList WidgetDAOReadOnly::getKeyFingerprints(
 }
 
 FingerPrintList WidgetDAOReadOnly::getKeyFingerprints(
-        WidgetCertificateData::Owner owner,
-        WidgetCertificateData::Type type) const
+    WidgetCertificateData::Owner owner,
+    WidgetCertificateData::Type type) const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, WidgetCertificateFingerprint, &WrtDatabase::interface())
+        WRT_DB_SELECT(select,
+                      WidgetCertificateFingerprint,
+                      &WrtDatabase::interface())
         select->Where(And(And(
         select->Where(And(And(
-            Equals<WidgetCertificateFingerprint::app_id>(m_widgetHandle),
-            Equals<WidgetCertificateFingerprint::owner>(owner)),
-            Equals<WidgetCertificateFingerprint::type>(type)));
+                              Equals<WidgetCertificateFingerprint::app_id>(
+                                  m_widgetHandle),
+                              Equals<WidgetCertificateFingerprint::owner>(owner)),
+                          Equals<WidgetCertificateFingerprint::type>(type)));
 
         WidgetCertificateFingerprint::Select::RowList rows =
             select->GetRowList();
 
         WidgetCertificateFingerprint::Select::RowList rows =
             select->GetRowList();
@@ -834,10 +939,14 @@ FingerPrintList WidgetDAOReadOnly::getKeyFingerprints(
         FingerPrintList keys;
         FOREACH(it, rows)
         {
         FingerPrintList keys;
         FOREACH(it, rows)
         {
-            DPL::Optional<DPL::String> md5 = it->Get_md5_fingerprint();
-            keys.push_back(md5.IsNull() ? "" : DPL::ToUTF8String(*md5));
             DPL::Optional<DPL::String> sha1 = it->Get_sha1_fingerprint();
             DPL::Optional<DPL::String> sha1 = it->Get_sha1_fingerprint();
-            keys.push_back(sha1.IsNull() ? "" : DPL::ToUTF8String(*sha1));
+            if (!sha1.IsNull()) {
+                keys.push_back(DPL::ToUTF8String(*sha1));
+            }
+            DPL::Optional<DPL::String> md5 = it->Get_md5_fingerprint();
+            if (!md5.IsNull()) {
+                keys.push_back(DPL::ToUTF8String(*md5));
+            }
         }
         return keys;
     }
         }
         return keys;
     }
@@ -845,19 +954,20 @@ FingerPrintList WidgetDAOReadOnly::getKeyFingerprints(
 }
 
 WidgetCertificateCNList WidgetDAOReadOnly::getKeyCommonNameList(
 }
 
 WidgetCertificateCNList WidgetDAOReadOnly::getKeyCommonNameList(
-        WidgetCertificateData::Owner owner,
-        WidgetCertificateData::Type type) const
+    WidgetCertificateData::Owner owner,
+    WidgetCertificateData::Type type) const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, WidgetCertificateFingerprint, &WrtDatabase::interface())
+        WRT_DB_SELECT(select,
+                      WidgetCertificateFingerprint,
+                      &WrtDatabase::interface())
         select->Where(And(And(
         select->Where(And(And(
-            Equals<WidgetCertificateFingerprint::app_id>(m_widgetHandle),
-            Equals<WidgetCertificateFingerprint::owner>(owner)),
-            Equals<WidgetCertificateFingerprint::type>(type)));
+                              Equals<WidgetCertificateFingerprint::app_id>(
+                                  m_widgetHandle),
+                              Equals<WidgetCertificateFingerprint::owner>(owner)),
+                          Equals<WidgetCertificateFingerprint::type>(type)));
 
         WidgetCertificateFingerprint::Select::RowList rows =
             select->GetRowList();
 
         WidgetCertificateFingerprint::Select::RowList rows =
             select->GetRowList();
@@ -874,35 +984,31 @@ WidgetCertificateCNList WidgetDAOReadOnly::getKeyCommonNameList(
 }
 
 ResourceAttributeList WidgetDAOReadOnly::getResourceAttribute(
 }
 
 ResourceAttributeList WidgetDAOReadOnly::getResourceAttribute(
-        const std::string &resourceId) const
+    const std::string &resourceId) const
 {
 {
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
-    WRT_DB_SELECT(select, DPL::DB::ORM::wrt::WidgetFeature, &WrtDatabase::interface())
-    select->Where(And(Equals<DPL::DB::ORM::wrt::WidgetFeature::app_id>(m_widgetHandle),
-                      Equals<DPL::DB::ORM::wrt::WidgetFeature::name>(
+    WRT_DB_SELECT(select, WidgetFeature, &WrtDatabase::interface())
+    select->Where(And(Equals<WidgetFeature::app_id>(m_widgetHandle),
+                      Equals<WidgetFeature::name>(
                           DPL::FromUTF8String(resourceId))));
 
                           DPL::FromUTF8String(resourceId))));
 
-    std::list<DPL::DB::ORM::wrt::WidgetFeature::Row> list = select->GetRowList();
+    std::list<WidgetFeature::Row> list = select->GetRowList();
     ResourceAttributeList result;
     if (!list.empty()) {
         int widgetFeatureId = list.begin()->Get_widget_feature_id();
         WidgetParamMap map = getFeatureParams(widgetFeatureId);
 
         FOREACH(i, map)
     ResourceAttributeList result;
     if (!list.empty()) {
         int widgetFeatureId = list.begin()->Get_widget_feature_id();
         WidgetParamMap map = getFeatureParams(widgetFeatureId);
 
         FOREACH(i, map)
-            result.push_back(DPL::ToUTF8String(i->first));
+        result.push_back(DPL::ToUTF8String(i->first));
     }
     return result;
 }
 
 void WidgetDAOReadOnly::getWidgetAccessInfo(
     }
     return result;
 }
 
 void WidgetDAOReadOnly::getWidgetAccessInfo(
-        WidgetAccessInfoList& outAccessInfoList) const
+    WidgetAccessInfoList& outAccessInfoList) const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, WidgetWARPInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetWARPInfo::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, WidgetWARPInfo, &WrtDatabase::interface())
         select->Where(Equals<WidgetWARPInfo::app_id>(m_widgetHandle));
 
@@ -926,13 +1032,11 @@ void WidgetDAOReadOnly::getWidgetAccessInfo(
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get accessinfo list")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get accessinfo list")
 }
 
-LanguageTagList WidgetDAOReadOnly::getLanguageTags() const
+LanguageTags WidgetDAOReadOnly::getLanguageTags() const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, LocalizedWidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<LocalizedWidgetInfo::app_id>(m_widgetHandle));
         return select->GetValueList<LocalizedWidgetInfo::widget_locale>();
         WRT_DB_SELECT(select, LocalizedWidgetInfo, &WrtDatabase::interface())
         select->Where(Equals<LocalizedWidgetInfo::app_id>(m_widgetHandle));
         return select->GetValueList<LocalizedWidgetInfo::widget_locale>();
@@ -940,11 +1044,9 @@ LanguageTagList WidgetDAOReadOnly::getLanguageTags() const
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get language tags")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get language tags")
 }
 
-LanguageTagList WidgetDAOReadOnly::getIconLanguageTags() const
+LanguageTags WidgetDAOReadOnly::getIconLanguageTags() const
 {
     //TODO check widget existance
 {
     //TODO check widget existance
-    using namespace DPL::DB::ORM;
-    using namespace DPL::DB::ORM::wrt;
     WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
     select->Where(Equals<WidgetLocalizedIcon::app_id>(m_widgetHandle));
     select->Distinct();
     WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface())
     select->Where(Equals<WidgetLocalizedIcon::app_id>(m_widgetHandle));
     select->Distinct();
@@ -956,9 +1058,9 @@ std::string WidgetDAOReadOnly::getCookieDatabasePath() const
     using namespace WrtDB::WidgetConfig;
     std::ostringstream path;
 
     using namespace WrtDB::WidgetConfig;
     std::ostringstream path;
 
-    DPL::OptionalString pkgname = getPkgname();
+    TizenAppId tzAppId = getTzAppId();
 
 
-    path << GetWidgetPersistentStoragePath(*pkgname);
+    path << GetWidgetPersistentStoragePath(tzAppId);
     path << "/";
     path << GlobalConfig::GetCookieDatabaseFile();
 
     path << "/";
     path << GlobalConfig::GetCookieDatabaseFile();
 
@@ -968,77 +1070,23 @@ std::string WidgetDAOReadOnly::getCookieDatabasePath() const
 std::string WidgetDAOReadOnly::getPrivateLocalStoragePath() const
 {
     std::ostringstream path;
 std::string WidgetDAOReadOnly::getPrivateLocalStoragePath() const
 {
     std::ostringstream path;
-    DPL::OptionalString pkgname = getPkgname();
-    path << WidgetConfig::GetWidgetWebLocalStoragePath(*pkgname);
+    TizenAppId tzAppId = getTzAppId();
+    path << WidgetConfig::GetWidgetWebLocalStoragePath(tzAppId);
     path << "/";
 
     path << "/";
 
-    if (isFactory()) {
-        WidgetGUID widgetGUID = getGUID();
-        if (!widgetGUID) {
-            Throw(WidgetDAOReadOnly::Exception::GUIDisNull);
-        }
-        path << DPL::ToUTF8String(*widgetGUID);
-    }
-
     return path.str();
 }
 
     return path.str();
 }
 
-ChildProtection::Record WidgetDAOReadOnly::getChildProtection() const
-{
-    WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
-    return ChildProtection::Record(row.Get_child_protection());
-}
-
-Powder::Description WidgetDAOReadOnly::getPowderDescription() const
-{
-    //TODO check widget existance
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        using namespace Powder;
-        Description description;
-
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, PowderLevels, &WrtDatabase::interface())
-        select->Where(Equals<PowderLevels::app_id>(m_widgetHandle));
-        typedef std::list<PowderLevels::Row> RowList;
-        RowList list = select->GetRowList();
-
-        FOREACH(it, list)
-        {
-            Description::CategoryEntry& categoryEntry =
-                description.categories[it->Get_category()];
-            Description::LevelEntry levelEntry(
-                (Description::LevelEnum)it->Get_level());
-
-            WRT_DB_SELECT(selectContexts, PowderLevelContexts, &WrtDatabase::interface())
-            selectContexts->Where(Equals<PowderLevelContexts::levelId>(
-                                      it->Get_id()));
-            typedef std::list<PowderLevelContexts::Row> ContextsRowList;
-            ContextsRowList contextsList = selectContexts->GetRowList();
-
-            FOREACH(c, contextsList)
-            levelEntry.context.insert(c->Get_context());
-
-            categoryEntry.levels.push_back(levelEntry);
-        }
-        return description;
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get powder description")
-}
-
 void WidgetDAOReadOnly::getWidgetSettings(
 void WidgetDAOReadOnly::getWidgetSettings(
-        WidgetSettings& outWidgetSettings) const
+    WidgetSettings& outWidgetSettings) const
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     //TODO check widget existance
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        WRT_DB_SELECT(select, SettginsList, &WrtDatabase::interface())
-        select->Where(Equals<SettginsList::appId>(m_widgetHandle));
+        WRT_DB_SELECT(select, SettingsList, &WrtDatabase::interface())
+        select->Where(Equals<SettingsList::appId>(m_widgetHandle));
 
 
-        SettginsList::Select::RowList rows = select->GetRowList();
+        SettingsList::Select::RowList rows = select->GetRowList();
 
         FOREACH(it, rows)
         {
 
         FOREACH(it, rows)
         {
@@ -1053,16 +1101,14 @@ void WidgetDAOReadOnly::getWidgetSettings(
 }
 
 void WidgetDAOReadOnly::getAppServiceList(
 }
 
 void WidgetDAOReadOnly::getAppServiceList(
-        WidgetApplicationServiceList& outAppServiceList) const
+    WidgetApplicationServiceList& outAppServiceList) const
 {
     LogDebug("Getting getAppServiceList. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
 {
     LogDebug("Getting getAppServiceList. Handle: " << m_widgetHandle);
     SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
     {
-        DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
+        ScopedTransaction transaction(&WrtDatabase::interface());
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
         CHECK_WIDGET_EXISTENCE(transaction, m_widgetHandle)
 
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
         WRT_DB_SELECT(select, ApplicationServiceInfo, &WrtDatabase::interface())
         select->Where(Equals<ApplicationServiceInfo::app_id>(m_widgetHandle));
 
         WRT_DB_SELECT(select, ApplicationServiceInfo, &WrtDatabase::interface())
         select->Where(Equals<ApplicationServiceInfo::app_id>(m_widgetHandle));
 
@@ -1087,8 +1133,131 @@ void WidgetDAOReadOnly::getAppServiceList(
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get access host list")
 }
 
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get access host list")
 }
 
+PackagingType WidgetDAOReadOnly::getPackagingType() const
+{
+    WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
+    DPL::OptionalInt result = row.Get_pkg_type();
+    return PackagingType(static_cast<PkgType>(*result));
+}
+
+void WidgetDAOReadOnly::getEncryptedFileList(EncryptedFileList& filesList)
+const
+{
+    //TODO check widget existance
+    WRT_DB_SELECT(select, EncryptedResourceList, &WrtDatabase::interface())
+    select->Where(Equals<EncryptedResourceList::app_id>(m_widgetHandle));
+
+    typedef std::list<EncryptedResourceList::Row> RowList;
+    RowList list = select->GetRowList();
+
+    FOREACH(it, list) {
+        EncryptedFileInfo info;
+        info.fileName = it->Get_resource();
+        info.fileSize = it->Get_size();
+        filesList.insert(info);
+    }
+}
+
+DPL::OptionalString WidgetDAOReadOnly::getBackgroundPage() const
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
+
+        WidgetExtendedInfo::Select::RowList rows = select->GetRowList();
+        if (rows.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << m_widgetHandle);
+        }
+
+        return rows.front().Get_background_page();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get background page")
+}
+
+TizenPkgId WidgetDAOReadOnly::generatePkgId()
+{
+    std::string allowed("0123456789"
+                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                        "abcdefghijklmnopqrstuvwxyz");
+    TizenPkgId pkgId;
+    pkgId.resize(MAX_TIZENID_LENGTH);
+    do {
+        for (int i = 0; i < MAX_TIZENID_LENGTH; ++i) {
+            pkgId[i] = allowed[rand() % allowed.length()];
+        }
+    } while (isWidgetInstalled(pkgId));
+    return pkgId;
+}
+
+SettingsType WidgetDAOReadOnly::getSecurityPopupUsage(void) const
+{
+    WidgetSecuritySettingsRow row =
+        getWidgetSecuritySettingsRow(m_widgetHandle);
+    DPL::OptionalInt result = row.Get_security_popup_usage();
+    return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getGeolocationUsage(void) const
+{
+    WidgetSecuritySettingsRow row =
+        getWidgetSecuritySettingsRow(m_widgetHandle);
+    DPL::OptionalInt result = row.Get_geolocation_usage();
+    return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getWebNotificationUsage(void) const
+{
+    WidgetSecuritySettingsRow row =
+        getWidgetSecuritySettingsRow(m_widgetHandle);
+    DPL::OptionalInt result = row.Get_web_notification_usage();
+    return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getWebDatabaseUsage(void) const
+{
+    WidgetSecuritySettingsRow row =
+        getWidgetSecuritySettingsRow(m_widgetHandle);
+    DPL::OptionalInt result = row.Get_web_database_usage();
+    return static_cast<SettingsType>(*result);
+}
+
+SettingsType WidgetDAOReadOnly::getFileSystemUsage(void) const
+{
+    WidgetSecuritySettingsRow row =
+        getWidgetSecuritySettingsRow(m_widgetHandle);
+    DPL::OptionalInt result = row.Get_file_system_usage();
+    return static_cast<SettingsType>(*result);
+}
+
+DPL::OptionalString WidgetDAOReadOnly::getWidgetInstalledPath() const
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+        WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
+
+        WidgetExtendedInfo::Select::RowList rows = select->GetRowList();
+        if (rows.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. Handle: " << m_widgetHandle);
+        }
+
+        return rows.front().Get_installed_path();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get widdget installed path")
+}
+
+TizenPkgId WidgetDAOReadOnly::getTizenPkgId() const
+{
+    WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
+    return row.Get_tizen_pkgid();
+}
+
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
 #undef CHECK_WIDGET_EXISTENCE
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
 #undef SQL_CONNECTION_EXCEPTION_HANDLER_END
 #undef CHECK_WIDGET_EXISTENCE
-
 } // namespace WrtDB
 } // namespace WrtDB
index 86a0980..8caa49f 100644 (file)
  *    limitations under the License.
  */
 #ifndef WRT_SRC_CONFIGURATION_WRTDATABASE_H_
  *    limitations under the License.
  */
 #ifndef WRT_SRC_CONFIGURATION_WRTDATABASE_H_
-#define        WRT_SRC_CONFIGURATION_WRTDATABASE_H_
+#define WRT_SRC_CONFIGURATION_WRTDATABASE_H_
 
 #include <dpl/db/thread_database_support.h>
 
 namespace WrtDB {
 
 #include <dpl/db/thread_database_support.h>
 
 namespace WrtDB {
-
 class WrtDatabase
 {
   public:
     static const char *Address();
     static DPL::DB::SqlConnection::Flag::Type Flags();
 class WrtDatabase
 {
   public:
     static const char *Address();
     static DPL::DB::SqlConnection::Flag::Type Flags();
-    static void attachToThread();
+    static void attachToThreadRO();
+    static void attachToThreadRW();
     static void detachFromThread();
     static DPL::DB::ThreadDatabaseSupport& interface();
     static bool CheckTableExist(const char *name);
     static void detachFromThread();
     static DPL::DB::ThreadDatabaseSupport& interface();
     static bool CheckTableExist(const char *name);
@@ -33,7 +33,6 @@ class WrtDatabase
   private:
     static DPL::DB::ThreadDatabaseSupport m_interface;
 };
   private:
     static DPL::DB::ThreadDatabaseSupport m_interface;
 };
-
 }
 
 #endif /* WRTDATABASE_H */
 }
 
 #endif /* WRTDATABASE_H */
index 6913766..ff30556 100644 (file)
  * @brief   This file contains the declaration of common data types for wrtdb
  */
 
  * @brief   This file contains the declaration of common data types for wrtdb
  */
 
-#ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_
-#define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_
+#ifndef WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_
+#define WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_
 
 #include <set>
 #include <string>
 #include <map>
 #include <vector>
 #include <list>
 
 #include <set>
 #include <string>
 #include <map>
 #include <vector>
 #include <list>
+#include <memory>
 #include <dpl/optional_typedefs.h>
 #include <dpl/optional_typedefs.h>
-#include <dpl/shared_ptr.h>
 
 namespace WrtDB {
 
 namespace WrtDB {
-namespace Powder {
-
-typedef std::set<DPL::String> StringSet;
-//! Widget description
-struct Description
-{
-    //!Content level
-    typedef enum
-    {
-        Level0 = 0,
-        Level1,
-        Level2,
-        Level3,
-        Level4,
-        Level5,
-        LevelUnknown
-    } LevelEnum;
-    struct LevelEntry
-    {
-        LevelEnum level; //!< content level
-
-        typedef StringSet Context;
-
-        //! POWDER context
-        //! xa    This material appears in an artistic context
-        //! xb    This material appears in an educational context
-        //! xc    This material appears in a medical context
-        //! xd    This material appears in a sports context
-        //! xe    This material appears in a violent context
-        Context context;
-        explicit LevelEntry(LevelEnum level = LevelUnknown);
-        //! Function checks if context is valid
-        //! \param[in] level POWDER content level
-        //! \param[in] context POWDER context
-        bool isContextValid(LevelEnum level,
-                const DPL::OptionalString& context) const;
-    };
-
-    struct CategoryEntry
-    {
-        //! Levels entries for POWDER description
-        typedef std::vector <LevelEntry> LevelsContainer;
-        LevelsContainer levels;
-        //! Function checks if context is valid
-        //! \param[out] reason set if context invalid
-        //! \param[in] level POWDER content level
-        //! \param[in] context POWDER context
-        bool isCategoryValid(LevelEntry& reason,
-                LevelEnum level,
-                const DPL::OptionalString& context) const;
-    };
-
-    //! POWDER Category -> Category entry map for Widget
-    //!
-    //! nu    Nudity
-    //! se    Sex
-    //! vi    Violence
-    //! la    Potentially offensive language
-    //! dr    Drug use
-    //! ga    Gambling
-    //! ha    Hate or harmful activities
-    //! ug    Use of user-generated content
-    typedef std::map<DPL::String, CategoryEntry> CategoryEntries;
-
-    CategoryEntries categories;
-
-    //! Age rating for widget
-    //! If Null not set
-    DPL::OptionalInt ageRating;
-};
-} // namespace Powder
-
-namespace ChildProtection {
-
-//! Blacklist with forbidden URLs
-//! It should be stored in WidgetDAO
-typedef std::vector<DPL::String> BlackList;
-
-//! Widget Child protection record
-//! Record should be stored in WingetDAO
-struct Record
-{
-    //! Child protection enabled
-    bool enabled;
-    explicit Record(bool enabled) :
-        enabled(enabled)
-    {
-    }
-};
-
-//! Powder processing
-struct PowderRules
-{
-    //! Rule set by parent about forbidden category
-    //! Powder category
-    //! nu    Nudity
-    //! se    Sex
-    //! vi    Violence
-    //! la    Potentially offensive language
-    //! dr    Drug use
-    //! ga    Gambling
-    //! ha    Hate or harmful activities
-    //! ug    Use of user-generated content
-    //! Powder context
-    //! xa    This material appears in an artistic conteaxt
-    //! xb    This material appears in an educational context
-    //! xc    This material appears in a medical context
-    //! xd    This material appears in a sports context
-    //! xe    This material appears in a violent context
-    struct CategoryRule
-    {
-        DPL::String category;
-        Powder::Description::LevelEnum level;
-        DPL::OptionalString context;
-        explicit CategoryRule(const DPL::String& category = DPL::String(),
-                Powder::Description::LevelEnum level =
-                    Powder::Description::LevelUnknown,
-                const DPL::OptionalString& context = DPL::OptionalString());
-    };
-
-    struct PowderResult
-    {
-        //! Reasoning outcome: part of POWDER description used to invalidate
-        Powder::Description::LevelEntry invalidDescription;
-        //! Reasoning outcome: rule set by parent not full filed by description
-        CategoryRule invalidRule;
-
-        //! Reasoning outcome: type of invalidity
-        enum InvalidReason
-        {
-            InvalidRule, //!< One of rules was not fulfilled
-            InvalidAge, //!< Age is invalid
-            AgeRatingNotSet, //!< Age rating for widget is not set
-            Valid //!< Description valid
-        };
-        InvalidReason reason;
-        explicit PowderResult(InvalidReason reason = Valid,
-                const Powder::Description::LevelEntry& invalidDescription =
-                    Powder::Description::LevelEntry(),
-                const CategoryRule& invalidRule = CategoryRule());
-    };
-
-    typedef std::pair<bool, PowderResult> ResultPair;
-
-    //! Function checks if rule is fulfilled by description
-    //! \param[in] rule checked rule
-    //! \param[in] description
-    //! \retval true rule is valid
-    //! \retval false rule is invalid
-    ResultPair isRuleValidForDescription(const CategoryRule& rule,
-            const Powder::Description& description) const;
-    //! Function checks if age limit is fulfilled by description
-    //! \param[in] description
-    //! \retval true age is valid
-    //! \retval false age is invalid
-    ResultPair isAgeValidForDescription(
-            const Powder::Description& description) const;
-
-    //! It is the maximum age rating valid for child
-    //! Uniform age is stored in WidgetDAO
-    DPL::OptionalInt ageLimit;
-
-    //! Set to true if age rating is required
-    //! If ageLimit is not set value is ignored
-    bool isAgeRatingRequired;
-
-    //! Set of rules configured by parent
-    //! Rules are stored in WidgetDAO and are uniform for all widgets
-    typedef std::vector<CategoryRule> RulesContainer;
-    RulesContainer rules;
-
-    //! Function check if Widget description is valid for ChildProtection
-    //! configuration
-    //! \param description widget description
-    //! \retval true widget is valid
-    //! \retval false widget is invalid
-    ResultPair isDescriptionValid(const Powder::Description& description)
-    const;
-
-    PowderRules() :
-        isAgeRatingRequired(false)
-    {
-    }
-};
-} // namespace ChildProtection
-
 class PluginMetafileData
 {
   public:
 class PluginMetafileData
 {
   public:
@@ -237,15 +51,9 @@ class PluginMetafileData
   public:
 
     PluginMetafileData()
   public:
 
     PluginMetafileData()
-    {
-    }
+    {}
 
     std::string m_libraryName;
 
     std::string m_libraryName;
-    std::string m_featuresInstallURI;
-    std::string m_featuresKeyCN;
-    std::string m_featuresRootCN;
-    std::string m_featuresRootFingerprint;
-
     FeatureContainer m_featureContainer;
 };
 
     FeatureContainer m_featureContainer;
 };
 
@@ -253,7 +61,7 @@ class PluginObjectsDAO
 {
   public:
     typedef std::set<std::string> Objects;
 {
   public:
     typedef std::set<std::string> Objects;
-    typedef DPL::SharedPtr<Objects> ObjectsPtr;
+    typedef std::shared_ptr<Objects> ObjectsPtr;
 
   public:
     explicit PluginObjectsDAO() {}
 
   public:
     explicit PluginObjectsDAO() {}
@@ -271,6 +79,16 @@ class PluginObjectsDAO
  * FindWidgetModel routine.
  */
 typedef int DbWidgetHandle;
  * FindWidgetModel routine.
  */
 typedef int DbWidgetHandle;
+typedef DPL::String TizenPkgId;
+typedef DPL::String TizenAppId;
+typedef DPL::String WidgetPkgName;
+
+/**
+ * Value of invalid widget handle
+ */
+enum {
+    INVALID_WIDGET_HANDLE = -1
+};
 
 /**
  * @brief Structure to hold the information of widget's size
 
 /**
  * @brief Structure to hold the information of widget's size
@@ -281,11 +99,10 @@ struct DbWidgetSize
     DPL::OptionalInt height;
 
     DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null,
     DPL::OptionalInt height;
 
     DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null,
-            DPL::OptionalInt h = DPL::OptionalInt::Null) :
+                 DPL::OptionalInt h = DPL::OptionalInt::Null) :
         width(w),
         height(h)
         width(w),
         height(h)
-    {
-    }
+    {}
 };
 
 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
 };
 
 inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
@@ -315,10 +132,33 @@ struct WidgetAccessInfo
     }
 };
 
     }
 };
 
+struct EncryptedFileInfo
+{
+    DPL::String fileName;
+    int fileSize;
+
+    bool operator==(const EncryptedFileInfo& info) const
+    {
+        return fileName == info.fileName;
+    }
+
+    bool operator==(const DPL::String& file) const
+    {
+        return fileName == file;
+    }
+
+    bool operator< (const EncryptedFileInfo& info) const
+    {
+        return fileName < info.fileName;
+    }
+};
+
 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
 
 typedef std::list<DPL::String> WindowModeList;
 
 typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
 
 typedef std::list<DPL::String> WindowModeList;
 
+typedef std::set<EncryptedFileInfo> EncryptedFileList;
+
 /**
  * @brief Widget configuration parameter key
  */
 /**
  * @brief Widget configuration parameter key
  */
@@ -360,24 +200,24 @@ struct DbWidgetFeature
 {
     DPL::String name;        /// Feature name
     bool required;           /// Whether feature is required
 {
     DPL::String name;        /// Feature name
     bool required;           /// Whether feature is required
-    DbPluginHandle pluginId;            /// Plugin id that implement this feature
+    bool rejected;           /// Api feature was rejected by ace
+    DbPluginHandle pluginId; /// Plugin id that implement this feature
     WidgetParamMap params;   /// Widget's params
 
     DbWidgetFeature() :
         required(false),
         pluginId(INVALID_PLUGIN_HANDLE)
     WidgetParamMap params;   /// Widget's params
 
     DbWidgetFeature() :
         required(false),
         pluginId(INVALID_PLUGIN_HANDLE)
-    {
-    }
+    {}
 };
 
 inline bool operator < (const DbWidgetFeature &objA,
 };
 
 inline bool operator < (const DbWidgetFeature &objA,
-        const DbWidgetFeature &objB)
+                        const DbWidgetFeature &objB)
 {
     return objA.name.compare(objB.name) < 0;
 }
 
 inline bool operator==(const DbWidgetFeature &featureA,
 {
     return objA.name.compare(objB.name) < 0;
 }
 
 inline bool operator==(const DbWidgetFeature &featureA,
-        const DbWidgetFeature &featureB)
+                       const DbWidgetFeature &featureB)
 {
     return featureA.name == featureB.name &&
            featureA.required == featureB.required &&
 {
     return featureA.name == featureB.name &&
            featureA.required == featureB.required &&
@@ -394,6 +234,20 @@ typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
  */
 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
 
  */
 typedef std::list<DbWidgetHandle> DbWidgetHandleList;
 
+typedef std::list<WidgetPkgName> WidgetPkgNameList; //TODO: this cannot be null
+                                                    // -> appropriate changes in
+                                                    // db schema needed
+typedef std::list<TizenAppId> TizenAppIdList; //TODO: this cannot be null ->
+                                              // appropriate changes in db
+                                              // schema needed
+
+class WidgetDAOReadOnly; //forward declaration
+typedef std::shared_ptr<WidgetDAOReadOnly> WidgetDAOReadOnlyPtr;
+/**
+ * @brief Default container with WidgetDAOReadOnly
+ */
+typedef std::list<WidgetDAOReadOnlyPtr> DbWidgetDAOReadOnlyList;
+
 /**
  * @brief Widget specific type
  *
 /**
  * @brief Widget specific type
  *
@@ -402,34 +256,34 @@ typedef std::list<DbWidgetHandle> DbWidgetHandleList;
 enum AppType
 {
     APP_TYPE_UNKNOWN = 0, // unknown
 enum AppType
 {
     APP_TYPE_UNKNOWN = 0, // unknown
-    APP_TYPE_WAC10, // WAC 1.0
     APP_TYPE_WAC20, // WAC 2.0
     APP_TYPE_WAC20, // WAC 2.0
-    APP_TYPE_TIZENWEBAPP, // Tizen webapp
+    APP_TYPE_TIZENWEBAPP // Tizen webapp
 };
 
 class WidgetType
 {
   public:
 };
 
 class WidgetType
 {
   public:
-    WidgetType()
-    :appType(APP_TYPE_UNKNOWN)
-    {
-    }
-    WidgetType(const AppType type)
-    :appType(type)
-    {
-    }
+    WidgetType() :
+        appType(APP_TYPE_UNKNOWN)
+    {}
+    WidgetType(const AppType type) :
+        appType(type)
+    {}
     bool operator== (const AppType& other) const
     {
         return appType == other;
     }
     bool operator== (const AppType& other) const
     {
         return appType == other;
     }
+    bool operator!= (const AppType& other) const
+    {
+        return appType != other;
+    }
     std::string getApptypeToString()
     {
         switch (appType) {
 #define X(x) case x: return #x;
     std::string getApptypeToString()
     {
         switch (appType) {
 #define X(x) case x: return #x;
-        X(APP_TYPE_UNKNOWN)
-        X(APP_TYPE_WAC10)
-        X(APP_TYPE_WAC20)
-        X(APP_TYPE_TIZENWEBAPP)
+            X(APP_TYPE_UNKNOWN)
+            X(APP_TYPE_WAC20)
+            X(APP_TYPE_TIZENWEBAPP)
 #undef X
         default:
             return "UNKNOWN";
 #undef X
         default:
             return "UNKNOWN";
@@ -439,6 +293,62 @@ class WidgetType
     AppType appType;
 };
 
     AppType appType;
 };
 
+/**
+ * @brief Package specific type
+ *
+ * Package type describes belowed in Tizen webapp, C++ service App
+ */
+enum PkgType
+{
+    PKG_TYPE_UNKNOWN = 0, // unknown
+    PKG_TYPE_NOMAL_WEB_APP,
+    PKG_TYPE_DIRECTORY_WEB_APP,
+    PKG_TYPE_HOSTED_WEB_APP,    // request from browser
+    PKG_TYPE_HYBRID_WEB_APP // Tizen webapp with C++ service app
+};
+
+class PackagingType
+{
+  public:
+    PackagingType() :
+        pkgType(PKG_TYPE_UNKNOWN)
+    {}
+    PackagingType(const PkgType type) :
+        pkgType(type)
+    {}
+    bool operator== (const PkgType& other) const
+    {
+        return pkgType == other;
+    }
+    bool operator!= (const PkgType& other) const
+    {
+        return pkgType != other;
+    }
+    std::string getPkgtypeToString()
+    {
+        switch (pkgType) {
+#define X(x) case x: return #x;
+            X(PKG_TYPE_UNKNOWN)
+            X(PKG_TYPE_NOMAL_WEB_APP)
+            X(PKG_TYPE_DIRECTORY_WEB_APP)
+            X(PKG_TYPE_HOSTED_WEB_APP)
+            X(PKG_TYPE_HYBRID_WEB_APP)
+#undef X
+        default:
+            return "UNKNOWN";
+        }
+    }
+
+    PkgType pkgType;
+};
+
+enum SettingsType
+{
+    SETTINGS_TYPE_UNKNOWN = 0,
+    SETTINGS_TYPE_ON,
+    SETTINGS_TYPE_ALWAYS_ASK,
+    SETTINGS_TYPE_OFF
+};
 } // namespace WrtDB
 
 struct WidgetSetting
 } // namespace WrtDB
 
 struct WidgetSetting
@@ -449,12 +359,12 @@ struct WidgetSetting
     bool operator ==(const WidgetSetting& info) const
     {
         return (info.settingName == settingName &&
     bool operator ==(const WidgetSetting& info) const
     {
         return (info.settingName == settingName &&
-               info.settingValue == settingValue);
+                info.settingValue == settingValue);
     }
     bool operator !=(const WidgetSetting& info) const
     {
         return (info.settingName != settingName ||
     }
     bool operator !=(const WidgetSetting& info) const
     {
         return (info.settingName != settingName ||
-               info.settingValue != settingValue);
+                info.settingValue != settingValue);
     }
 };
 
     }
 };
 
@@ -477,11 +387,12 @@ struct WidgetApplicationService
     bool operator== (const WidgetApplicationService& other) const
     {
         return src == other.src &&
     bool operator== (const WidgetApplicationService& other) const
     {
         return src == other.src &&
-        operation == other.operation &&
-        scheme == other.scheme &&
-        mime == other.mime;
+               operation == other.operation &&
+               scheme == other.scheme &&
+               mime == other.mime;
     }
 };
 
 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
     }
 };
 
 typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
-#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */
+
+#endif /* WRT_WIDGET_DAO_COMMON_DAO_TYPES_H_ */
index a2d92ef..c6ae0bd 100644 (file)
 #include <ctype.h>
 
 namespace WrtDB {
 #include <ctype.h>
 
 namespace WrtDB {
-
-void NormalizeString(DPL::OptionalString& txt);
+void NormalizeString(DPL::OptionalString& txt, bool isTrimSpace = false);
 void NormalizeString(DPL::String& str);
 DPL::String GetSingleAttributeValue(const DPL::String value);
 void NormalizeString(DPL::String& str);
 DPL::String GetSingleAttributeValue(const DPL::String value);
+void NormalizeAndTrimSpaceString(DPL::OptionalString& txt);
 
 class WidgetConfigurationManager;
 
 
 class WidgetConfigurationManager;
 
@@ -43,9 +43,8 @@ class ConfigParserData
   public:
     struct Param
     {
   public:
     struct Param
     {
-        Param(const DPL::String& name) : name(name)
-        {
-        }
+        Param(const DPL::String& _name) : name(_name)
+        {}
         DPL::String name;
         DPL::String value;
         bool operator==(const Param&) const;
         DPL::String name;
         DPL::String value;
         bool operator==(const Param&) const;
@@ -59,11 +58,10 @@ class ConfigParserData
 
     struct Feature
     {
 
     struct Feature
     {
-        Feature(const DPL::String& name,
-                bool required = true) : name(name),
-            required(required)
-        {
-        }
+        Feature(const DPL::String& _name,
+                bool _required = true) : name(_name),
+            required(_required)
+        {}
         DPL::String name;
         bool required;
         ParamsList paramsList;
         DPL::String name;
         bool required;
         ParamsList paramsList;
@@ -77,11 +75,25 @@ class ConfigParserData
     };
     typedef std::set<Feature> FeaturesList;
 
     };
     typedef std::set<Feature> FeaturesList;
 
+    struct Privilege
+    {
+        Privilege(const DPL::String& _name) : name(_name)
+        {}
+        DPL::String name;
+
+        bool operator==(const Privilege&) const;
+        bool operator!=(const Privilege&) const;
+        bool operator >(const Privilege&) const;
+        bool operator>=(const Privilege&) const;
+        bool operator <(const Privilege&) const;
+        bool operator<=(const Privilege&) const;
+    };
+    typedef std::set<Privilege> PrivilegeList;
+
     struct Icon
     {
     struct Icon
     {
-        Icon(const DPL::String& src) : src(src)
-        {
-        }
+        Icon(const DPL::String& _src) : src(_src)
+        {}
         DPL::String src;
         DPL::OptionalInt width;
         DPL::OptionalInt height;
         DPL::String src;
         DPL::OptionalInt width;
         DPL::OptionalInt height;
@@ -109,13 +121,12 @@ class ConfigParserData
 
     struct Preference
     {
 
     struct Preference
     {
-        Preference(const DPL::String& name,
-                bool readonly = false) :
-            name(name),
+        Preference(const DPL::String& _name,
+                   bool _readonly = false) :
+            name(_name),
             value(),
             value(),
-            readonly(readonly)
-        {
-        }
+            readonly(_readonly)
+        {}
         DPL::String name;
         DPL::OptionalString value;
         bool readonly;
         DPL::String name;
         DPL::OptionalString value;
         bool readonly;
@@ -132,10 +143,9 @@ class ConfigParserData
     struct AccessInfo
     {
         AccessInfo(const DPL::String& strIRI,
     struct AccessInfo
     {
         AccessInfo(const DPL::String& strIRI,
-                bool bSubdomainAccess) : m_strIRI(strIRI),
+                   bool bSubdomainAccess) : m_strIRI(strIRI),
             m_bSubDomainAccess(bSubdomainAccess)
             m_bSubDomainAccess(bSubdomainAccess)
-        {
-        }
+        {}
 
         bool operator==(const AccessInfo&) const;
         bool operator!=(const AccessInfo&) const;
 
         bool operator==(const AccessInfo&) const;
         bool operator!=(const AccessInfo&) const;
@@ -150,10 +160,9 @@ class ConfigParserData
     {
         Setting(const DPL::String& name,
                 const DPL::String& value) :
     {
         Setting(const DPL::String& name,
                 const DPL::String& value) :
-                m_name(name),
-                m_value(value)
-        {
-        }
+            m_name(name),
+            m_value(value)
+        {}
         DPL::String m_name;
         DPL::String m_value;
 
         DPL::String m_name;
         DPL::String m_value;
 
@@ -167,6 +176,9 @@ class ConfigParserData
 
     typedef std::set<Setting> SettingsList;
 
 
     typedef std::set<Setting> SettingsList;
 
+    /* ServiceInfo will be removed.
+     * ServiceInfo will be changed AppControl
+     */
     struct ServiceInfo
     {
         ServiceInfo(
     struct ServiceInfo
     {
         ServiceInfo(
@@ -178,8 +190,7 @@ class ConfigParserData
             m_operation(operation),
             m_scheme(scheme),
             m_mime(mime)
             m_operation(operation),
             m_scheme(scheme),
             m_mime(mime)
-        {
-        }
+        {}
         DPL::String m_src;
         DPL::String m_operation;
         DPL::String m_scheme;
         DPL::String m_src;
         DPL::String m_operation;
         DPL::String m_scheme;
@@ -188,7 +199,64 @@ class ConfigParserData
         bool operator==(const ServiceInfo&) const;
         bool operator!=(const ServiceInfo&) const;
     };
         bool operator==(const ServiceInfo&) const;
         bool operator!=(const ServiceInfo&) const;
     };
-    typedef std::list<ServiceInfo> ServiceInfoList;
+
+    struct AppControlInfo
+    {
+        AppControlInfo(
+            const DPL::String& operation) :
+            m_operation(operation)
+        {}
+        DPL::String m_src;
+        DPL::String m_operation;
+        std::set <DPL::String> m_uriList;
+        std::set <DPL::String> m_mimeList;
+
+        bool operator==(const AppControlInfo&) const;
+        bool operator!=(const AppControlInfo&) const;
+    };
+
+    typedef std::list<ServiceInfo> ServiceInfoList; // It will be removed.
+    typedef std::list<AppControlInfo> AppControlInfoList;
+
+    typedef std::list<std::pair<DPL::String, DPL::String> > BoxSizeList;
+
+    struct LiveboxInfo
+    {
+        LiveboxInfo() { }
+
+        struct BoxContent
+        {
+            DPL::String m_boxSrc;
+            DPL::String m_boxMouseEvent;
+            BoxSizeList m_boxSize;
+            DPL::String m_pdSrc;
+            DPL::String m_pdWidth;
+            DPL::String m_pdHeight;
+        };
+        typedef BoxContent BoxContentInfo;
+
+        DPL::String m_label;
+        DPL::String m_icon;
+        DPL::String m_liveboxId;
+        DPL::String m_primary;
+        DPL::String m_type;
+        DPL::String m_autoLaunch;
+        DPL::String m_updatePeriod;
+        BoxContentInfo m_boxInfo;
+
+        bool operator==(const LiveboxInfo&) const;
+        bool operator!=(const LiveboxInfo&) const;
+        bool operator >(const LiveboxInfo&) const;
+        bool operator>=(const LiveboxInfo&) const;
+        bool operator <(const LiveboxInfo&) const;
+        bool operator<=(const LiveboxInfo&) const;
+    };
+    typedef std::list<DPL::Optional<LiveboxInfo> > LiveboxList;
+    LiveboxList m_livebox;
+
+    typedef std::list<DPL::OptionalString> DependsPkgList;
+
+    typedef std::set<DPL::String> CategoryList;
 
     StringsList nameSpaces;
 
 
     StringsList nameSpaces;
 
@@ -199,6 +267,7 @@ class ConfigParserData
     DPL::OptionalString authorEmail;
 
     FeaturesList featuresList;
     DPL::OptionalString authorEmail;
 
     FeaturesList featuresList;
+    PrivilegeList privilegeList;
 
     SettingsList settingsList;
 
 
     SettingsList settingsList;
 
@@ -217,9 +286,7 @@ class ConfigParserData
 
     bool flashNeeded;
 
 
     bool flashNeeded;
 
-    DPL::OptionalFloat minVersionRequired;
-    DPL::OptionalInt minVersionRequiredFound;
-    StringsList powderDescriptionLinks;
+    DPL::OptionalString minVersionRequired;
 
     bool backSupported;
     bool accessNetwork;
 
     bool backSupported;
     bool accessNetwork;
@@ -231,22 +298,36 @@ class ConfigParserData
     DPL::OptionalString startFileContentType;
     IconsList iconsList;
 
     DPL::OptionalString startFileContentType;
     IconsList iconsList;
 
-    // pakcage name determined by operator for TIZEN webapp
-    DPL::OptionalString pkgname;
+    // tizen id / required platform min version for TIZEN webapp
+    DPL::OptionalString tizenId;
+    DPL::OptionalString tizenMinVersionRequired;
+    DPL::OptionalString tizenPkgId;
+    DPL::OptionalString tizenAppId;
+
+    //csp polic for widget
+    DPL::OptionalString cspPolicy;
+
     //Application service model list
     //Application service model list
-    ServiceInfoList appServiceList;
+    ServiceInfoList appServiceList; //It will be removed.
+    AppControlInfoList appControlList;
+
+    // For link shared directory
+    DependsPkgList dependsPkgList;
+    // Splash image path
+    DPL::OptionalString splashImgSrc;
+    // Background page filename
+    DPL::OptionalString backgroundPage;
+    // For category
+    CategoryList categoryList;
 
     ConfigParserData() :
         flashNeeded(false),
 
     ConfigParserData() :
         flashNeeded(false),
-        minVersionRequired(1.0),
-        minVersionRequiredFound(),
+        minVersionRequired(),
         backSupported(false),
         accessNetwork(false),
         startFileEncountered(false)
         backSupported(false),
         accessNetwork(false),
         startFileEncountered(false)
-    {
-    }
+    {}
 };
 };
-
 } // namespace WrtDB
 
 #endif  //CONFIG_PARSER_DATA_H_
 } // namespace WrtDB
 
 #endif  //CONFIG_PARSER_DATA_H_
index 9bd8945..14aec55 100644 (file)
@@ -32,7 +32,6 @@
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/WrtDatabase.h>
 
 namespace WrtDB {
-
 class FeatureDAOReadOnly
 {
   public:
 class FeatureDAOReadOnly
 {
   public:
@@ -48,6 +47,9 @@ class FeatureDAOReadOnly
     };
 
     typedef std::set<std::string> DeviceCapabilitiesList;
     };
 
     typedef std::set<std::string> DeviceCapabilitiesList;
+    typedef std::multimap<FeatureHandle, std::string> DeviceCapabilitiesMap;
+    typedef std::map<FeatureHandle, std::string> NameMap;
+    typedef std::map<FeatureHandle, FeatureData> FeatureMap;
 
     static bool isDeviceCapabilityInstalled(const std::string &deviceCapName);
 
 
     static bool isDeviceCapabilityInstalled(const std::string &deviceCapName);
 
@@ -55,27 +57,27 @@ class FeatureDAOReadOnly
     FeatureDAOReadOnly(const std::string &featureName);
 
     static FeatureHandleListPtr GetFeatureHandleListForPlugin(
     FeatureDAOReadOnly(const std::string &featureName);
 
     static FeatureHandleListPtr GetFeatureHandleListForPlugin(
-            DbPluginHandle pluginHandle);
+        DbPluginHandle pluginHandle);
 
     static bool isFeatureInstalled(const std::string &featureName);
     static bool isFeatureInstalled(FeatureHandle handle);
     static FeatureHandleList GetHandleList();
 
     std::string             GetName() const;
 
     static bool isFeatureInstalled(const std::string &featureName);
     static bool isFeatureInstalled(FeatureHandle handle);
     static FeatureHandleList GetHandleList();
 
     std::string             GetName() const;
-    std::string             GetInstallURI() const;
-    std::string             GetKeyCn() const;
-    std::string             GetRootKey() const;
-    std::string             GetRootKeyFingerprint() const;
     FeatureHandle           GetFeatureHandle() const;
     std::string             GetLibraryPath() const;
     std::string             GetLibraryName() const;
     DeviceCapabilitiesList  GetDeviceCapabilities() const;
     DbPluginHandle          GetPluginHandle() const;
 
     FeatureHandle           GetFeatureHandle() const;
     std::string             GetLibraryPath() const;
     std::string             GetLibraryName() const;
     DeviceCapabilitiesList  GetDeviceCapabilities() const;
     DbPluginHandle          GetPluginHandle() const;
 
+    static NameMap                 GetNames();
+    static DeviceCapabilitiesMap   GetDevCapWithFeatureHandle();
+
+    static FeatureMap GetFeatures(const std::list<std::string>& featureNames);
+
   protected:
     FeatureHandle m_featureHandle;
 };
   protected:
     FeatureHandle m_featureHandle;
 };
-
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_FEATURE_DAO_READ_ONLY_H_ */
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_FEATURE_DAO_READ_ONLY_H_ */
index 13b959c..8698d4a 100644 (file)
 
 #include <dpl/event/model.h>
 #include <dpl/event/property.h>
 
 #include <dpl/event/model.h>
 #include <dpl/event/property.h>
-#include <dpl/shared_ptr.h>
+#include <memory>
 #include <string>
 #include <list>
 #include <set>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
 #include <string>
 #include <list>
 #include <set>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
-
 typedef int FeatureHandle;
 typedef std::list<FeatureHandle> FeatureHandleList;
 typedef int FeatureHandle;
 typedef std::list<FeatureHandle> FeatureHandleList;
-typedef DPL::SharedPtr<FeatureHandleList> FeatureHandleListPtr;
+typedef std::shared_ptr<FeatureHandleList> FeatureHandleListPtr;
 
 typedef int FeatureSetHandle;
 typedef std::list<FeatureSetHandle> FeatureSetHandleList;
 
 
 typedef int FeatureSetHandle;
 typedef std::list<FeatureSetHandle> FeatureSetHandleList;
 
+typedef struct {
+    std::string featureName;
+    DbPluginHandle pluginHandle;
+} FeatureData;
+
 class FeatureModel : public DPL::Event::Model
 {
   public:
 class FeatureModel : public DPL::Event::Model
 {
   public:
@@ -53,12 +57,19 @@ class FeatureModel : public DPL::Event::Model
         Name(this),
         DeviceCapabilities(this),
         PHandle(this, -1)
         Name(this),
         DeviceCapabilities(this),
         PHandle(this, -1)
+    {}
+
+    void SetData(const std::string& name,
+                 const std::set<std::string>& deviceCapabilities,
+                 const DbPluginHandle& pluginHandle)
     {
     {
+        Name.SetWithoutLock(name);
+        DeviceCapabilities.SetWithoutLock(deviceCapabilities);
+        PHandle.SetWithoutLock(pluginHandle);
     }
 };
 
     }
 };
 
-typedef DPL::SharedPtr<FeatureModel> FeatureModelPtr;
-
+typedef std::shared_ptr<FeatureModel> FeatureModelPtr;
 } // namespace WrtDB
 
 #endif // FEATURE_MODEL_H
 } // namespace WrtDB
 
 #endif // FEATURE_MODEL_H
index bda207b..67dcca6 100644 (file)
@@ -53,19 +53,27 @@ inline const char* GetDevicePluginPath()
 }
 
 /**
 }
 
 /**
- * WRT factory widgets that are loaded by default
+ * WRT widgets that are downloaded and installed by user
+ */
+inline const char* GetUserInstalledWidgetPath()
+{
+    return "/opt/usr/apps";
+}
+
+/**
+ * WRT widgets that are preloaded
  */
  */
-inline const char* GetFactoryInstalledWidgetPath()
+inline const char* GetUserPreloadedWidgetPath()
 {
 {
-    return "/opt/apps/widget/system";
+    return "/usr/apps";
 }
 
 /**
  * WRT widgets that are downloaded and installed by user
  */
 }
 
 /**
  * WRT widgets that are downloaded and installed by user
  */
-inline const char* GetUserInstalledWidgetPath()
+inline const char* GetWidgetUserDataPath()
 {
 {
-    return "/opt/apps";
+    return "/opt/usr/apps";
 }
 
 /**
 }
 
 /**
@@ -73,7 +81,7 @@ inline const char* GetUserInstalledWidgetPath()
  */
 inline const char* GetWidgetSrcPath()
 {
  */
 inline const char* GetWidgetSrcPath()
 {
-    return "res/src";
+    return "/res/wgt";
 }
 
 /**
 }
 
 /**
@@ -81,7 +89,7 @@ inline const char* GetWidgetSrcPath()
  */
 inline const char* GetPublicVirtualRootPath()
 {
  */
 inline const char* GetPublicVirtualRootPath()
 {
-    return "/opt/apps/widget/data/Public";
+    return "/opt/share/widget/data/Public";
 }
 
 /**
 }
 
 /**
@@ -97,7 +105,7 @@ inline const char* GetWidgetLocalStoragePath()
  */
 inline const char* GetTestsDataPath()
 {
  */
 inline const char* GetTestsDataPath()
 {
-    return "/opt/apps/widget/tests";
+    return "/opt/share/widget/tests";
 }
 
 /**
 }
 
 /**
@@ -105,7 +113,7 @@ inline const char* GetTestsDataPath()
  */
 inline const char* GetUserWidgetExecPath()
 {
  */
 inline const char* GetUserWidgetExecPath()
 {
-    return "bin";
+    return "/bin";
 }
 
 /**
 }
 
 /**
@@ -116,6 +124,13 @@ inline const char* GetWidgetPrivateStoragePath()
     return "data";
 }
 
     return "data";
 }
 
+/**
+ * widgets share directory path
+ */
+inline const char* GetWidgetSharePath()
+{
+    return "share";
+}
 
 /**
  * widgets desktop files path
 
 /**
  * widgets desktop files path
@@ -138,7 +153,7 @@ inline const char* GetWrtClientExec()
  */
 inline const char* GetUserWidgetDesktopIconPath()
 {
  */
 inline const char* GetUserWidgetDesktopIconPath()
 {
-    return "res/icons/default/small";
+    return "/opt/share/icons/default/small";
 }
 
 /**
 }
 
 /**
@@ -149,14 +164,6 @@ inline const char* GetUserWidgetDefaultIconFile()
     return "/usr/share/wrt-engine/wrt_widget_default_icon.png";
 }
 
     return "/usr/share/wrt-engine/wrt_widget_default_icon.png";
 }
 
-/**
- * WRT downloaded widgets
- */
-// KW inline const char* GetDownloadedWidgetPath()
-// KW {
-// KW     return "/opt/apps/widget/test-widgets";
-// KW }
-
 inline const char* GetSignatureXmlSchema()
 {
     //TODO please rename, this filename is not descriptive enough
 inline const char* GetSignatureXmlSchema()
 {
     //TODO please rename, this filename is not descriptive enough
@@ -193,13 +200,29 @@ inline const char* GetPluginMetafileName()
 }
 
 /**
 }
 
 /**
+ * Plugin .so prefix
+ */
+inline const char* GetPluginPrefix()
+{
+    return "libwrt-plugins-";
+}
+
+/**
+ * Plugin .so suffix
+ */
+inline const char* GetPluginSuffix()
+{
+    return ".so";
+}
+
+/**
  * WRT device plugins installation required
  * File which indicate that new plugins
  * are available and should be installed
  */
 inline const char* GetPluginInstallInitializerName()
 {
  * WRT device plugins installation required
  * File which indicate that new plugins
  * are available and should be installed
  */
 inline const char* GetPluginInstallInitializerName()
 {
-    return "/opt/apps/widget/plugin-installation-required";
+    return "/opt/share/widget/plugin-installation-required";
 }
 
 /**
 }
 
 /**
@@ -218,10 +241,8 @@ inline const char* GetFingerprintListSchema()
 
 inline const char* GetVCoreDatabaseFilePath()
 {
 
 inline const char* GetVCoreDatabaseFilePath()
 {
-    return "/opt/dbspace/.vcore.db";
+    return "/opt/dbspace/.cert_svc_vcore.db";
 }
 }
-bool IsOCSPEnabled();
-bool IsCRLEnabled();
 
 /**
  * widgets cookie database file name
 
 /**
  * widgets cookie database file name
@@ -243,6 +264,61 @@ inline const char* GetTmpDirPath()
 {
     return "/tmp";
 }
 {
     return "/tmp";
 }
+
+inline const char* GetWACVersion()
+{
+    return "2.0";
+}
+
+inline const char* GetTizenVersion()
+{
+    return "1.0";
+}
+
+inline const char* GetShareDirectoryPath()
+{
+    return "/opt/share";
+}
+
+inline const char* GetTempInstallInfoPath()
+{
+    return "/opt/share/widget/temp_info";
+}
+
+inline const char* GetVconfKeyPrefixPath()
+{
+    return "file/private";
+}
+
+inline const char* GetVconfKeyPopupUsagePath()
+{
+    return "/popup_usage";
+}
+
+inline const char* GetVconfKeyGeolocationUsagePath()
+{
+    return "/geolocation_usage";
+}
+
+inline const char* GetVconfKeyWebNotificationUsagePath()
+{
+    return "/web_notification_usage";
+}
+
+inline const char* GetVconfKeyWebDatabaseUsagePath()
+{
+    return "/web_database_usage";
+}
+
+inline const char* GetVconfKeyFilesystemUsagePath()
+{
+    return "/filesystem_usage";
+}
+
+inline const char* GetVconfKeyMemorySavingModePath()
+{
+    return "/memory_saving_mode";
+}
 } // namespace GlobalConfig
 } // namespace WrtDB
 
 } // namespace GlobalConfig
 } // namespace WrtDB
 
index 2feafca..f5eab4e 100644 (file)
@@ -33,7 +33,6 @@
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
-
 typedef std::list<DPL::String> WidgetPackageList;
 typedef std::set<DPL::String> DeviceCapabilitySet;
 
 typedef std::list<DPL::String> WidgetPackageList;
 typedef std::set<DPL::String> DeviceCapabilitySet;
 
@@ -55,43 +54,9 @@ class GlobalDAOReadOnly
     };
 
   public:
     };
 
   public:
-    /**
-     * Retrieve Parental mode status
-     *
-     * @return true for Parental Mode on, false for Parental Mode off
-     */
-    static bool GetParentalMode();
-
-    /**
-     * Retrieve Parental mode maximal allowed age
-     *
-     * @return NULL if allowed age not set, else pointer value is allowed age
-     */
-    static DPL::OptionalInt GetParentalAllowedAge();
-    /**
-     * Retrieve Parental mode maximal allowed age
-     *
-     * @return NULL if allowed age not set, else pointer value is allowed age
-     */
 
     static bool IsValidSubTag(const DPL::String& tag, int type);
 
 
     static bool IsValidSubTag(const DPL::String& tag, int type);
 
-    static bool IsPowderRulePresent(
-            const ChildProtection::PowderRules::CategoryRule& rule);
-
-    static ChildProtection::PowderRules GetPowderRules();
-
-    static ChildProtection::BlackList GetAdultBlackList();
-
-    static bool IsElementOnAdultBlackList(const DPL::String &url);
-
-    /**
-     * Retrieve list of deffered widget packages to be installed
-     *
-     * @return Widget package list
-     */
-    static WidgetPackageList GetDefferedWidgetPackageInstallationList();
-
     static bool GetDeveloperMode();
 
     static bool GetSecureByDefault();
     static bool GetDeveloperMode();
 
     static bool GetSecureByDefault();
@@ -104,6 +69,8 @@ class GlobalDAOReadOnly
 
     static WidgetAccessInfoList GetWhiteURIList();
 
 
     static WidgetAccessInfoList GetWhiteURIList();
 
+    static bool GetCookieSharingMode();
+
     enum NetworkAccessMode
     {
         NEVER_CONNECT,
     enum NetworkAccessMode
     {
         NEVER_CONNECT,
@@ -131,27 +98,12 @@ class GlobalDAOReadOnly
      * This method returns set of device capabilities used by apifeature.
      */
     static DeviceCapabilitySet GetDeviceCapability(
      * This method returns set of device capabilities used by apifeature.
      */
     static DeviceCapabilitySet GetDeviceCapability(
-            const DPL::String &apifeature);
-
-
-    /**
-     * This method gets Autofill for Webkit
-     */
-    struct AutoSaveData
-    {
-        DPL::String userId;
-        DPL::String passwd;
-    };
-
-    static DPL::Optional<AutoSaveData> GetAutoSaveIdPasswd(
-            const DPL::String &url);
+        const DPL::String &apifeature);
 
   protected:
     GlobalDAOReadOnly()
 
   protected:
     GlobalDAOReadOnly()
-    {
-    }
+    {}
 };
 };
-
 } // namespace WrtDB
 
 #endif // WRT_SRC_CONFIGURATION_GLOBAL_DAO_READ_ONLY_H_
 } // namespace WrtDB
 
 #endif // WRT_SRC_CONFIGURATION_GLOBAL_DAO_READ_ONLY_H_
index 18fcca3..4ea6a4f 100644 (file)
@@ -26,7 +26,6 @@
 #include <dpl/noncopyable.h>
 
 namespace WrtDB {
 #include <dpl/noncopyable.h>
 
 namespace WrtDB {
-
 class PathBuilderImpl;
 
 class PathBuilder : private DPL::Noncopyable
 class PathBuilderImpl;
 
 class PathBuilder : private DPL::Noncopyable
@@ -51,7 +50,6 @@ class PathBuilder : private DPL::Noncopyable
   private:
     PathBuilderImpl* m_impl;
 };
   private:
     PathBuilderImpl* m_impl;
 };
-
 } // namespace WrtDB
 
 #endif
 } // namespace WrtDB
 
 #endif
index 2341316..eb9c030 100644 (file)
  * @brief   This file contains the declaration of plugin dao read only
  */
 
  * @brief   This file contains the declaration of plugin dao read only
  */
 
-
 #ifndef WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
 #define WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
 
 #include <string>
 #include <list>
 #ifndef WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
 #define WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_
 
 #include <string>
 #include <list>
+#include <memory>
 #include <dpl/exception.h>
 #include <dpl/exception.h>
-#include <dpl/shared_ptr.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
-
 typedef std::list<DbPluginHandle> PluginHandleList;
 typedef std::set<DbPluginHandle> PluginHandleSet;
 typedef std::list<std::string> ImplementedObjectsList;
 typedef std::list<DbPluginHandle> PluginHandleList;
 typedef std::set<DbPluginHandle> PluginHandleSet;
 typedef std::list<std::string> ImplementedObjectsList;
-typedef DPL::SharedPtr<PluginHandleSet> PluginHandleSetPtr;
+typedef std::shared_ptr<PluginHandleSet> PluginHandleSetPtr;
 
 //TODO make it friend to FeatureDAO or inherit
 class PluginDAOReadOnly
 
 //TODO make it friend to FeatureDAO or inherit
 class PluginDAOReadOnly
@@ -86,28 +84,24 @@ class PluginDAOReadOnly
     static bool isPluginInstalled(DbPluginHandle pluginHandle);
 
     static PluginHandleSetPtr getPluginHandleByStatus(
     static bool isPluginInstalled(DbPluginHandle pluginHandle);
 
     static PluginHandleSetPtr getPluginHandleByStatus(
-            PluginInstallationState state);
+        PluginInstallationState state);
 
     static DbPluginHandle getPluginHandleForImplementedObject(
 
     static DbPluginHandle getPluginHandleForImplementedObject(
-            const std::string& objectName);
+        const std::string& objectName);
 
     static ImplementedObjectsList getImplementedObjectsForPluginHandle(
 
     static ImplementedObjectsList getImplementedObjectsForPluginHandle(
-            DbPluginHandle handle);
+        DbPluginHandle handle);
 
     static PluginObjectsDAO::ObjectsPtr getRequiredObjectsForPluginHandle(
 
     static PluginObjectsDAO::ObjectsPtr getRequiredObjectsForPluginHandle(
-            DbPluginHandle handle);
+        DbPluginHandle handle);
 
     static PluginInstallationState getInstallationStateForHandle(
 
     static PluginInstallationState getInstallationStateForHandle(
-            DbPluginHandle handle);
+        DbPluginHandle handle);
 
     DbPluginHandle getPluginHandle() const;
     PluginInstallationState getInstallationStatus() const;
     std::string  getLibraryPath() const;
     std::string  getLibraryName() const;
 
     DbPluginHandle getPluginHandle() const;
     PluginInstallationState getInstallationStatus() const;
     std::string  getLibraryPath() const;
     std::string  getLibraryName() const;
-    std::string  getInstallURI() const;
-    std::string  getKeyCn() const;
-    std::string  getRootKey() const;
-    std::string  getRootKeyFingerprint() const;
     PluginHandleSetPtr getLibraryDependencies() const;
 
   private:
     PluginHandleSetPtr getLibraryDependencies() const;
 
   private:
@@ -115,7 +109,6 @@ class PluginDAOReadOnly
 
     void checkInstallationCompleted();
 };
 
     void checkInstallationCompleted();
 };
-
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_ */
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_PLUGIN_DAO_READ_ONLY_H_ */
index 50b3dab..d7ff799 100644 (file)
 
 namespace WrtDB {
 namespace PropertyDAOReadOnly {
 
 namespace WrtDB {
 namespace PropertyDAOReadOnly {
-
 typedef DPL::String WidgetPropertyKey;
 typedef DPL::OptionalString WidgetPropertyValue;
 
 typedef std::list<WidgetPropertyKey> WidgetPropertyKeyList;
 
 struct WidgetPreferenceRow {
 typedef DPL::String WidgetPropertyKey;
 typedef DPL::OptionalString WidgetPropertyValue;
 
 typedef std::list<WidgetPropertyKey> WidgetPropertyKeyList;
 
 struct WidgetPreferenceRow {
-    int                 app_id;
-    WidgetPropertyKey   key_name;
+    TizenAppId tizen_appid;
+    WidgetPropertyKey key_name;
     WidgetPropertyValue key_value;
     WidgetPropertyValue key_value;
-    DPL::OptionalInt    readonly;
+    DPL::OptionalInt readonly;
 };
 
 typedef std::list<WidgetPreferenceRow> WidgetPreferenceList;
 };
 
 typedef std::list<WidgetPreferenceRow> WidgetPreferenceList;
@@ -57,24 +56,36 @@ class Exception
     DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
 };
 
     DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
 };
 
+//deprecated
 /* This method checks read only flag for given property
  */
 DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
 /* This method checks read only flag for given property
  */
 DPL::OptionalInt CheckPropertyReadFlag(DbWidgetHandle widgetHandle,
-                                  const WidgetPropertyKey &key);
+                                       const WidgetPropertyKey &key)
+__attribute__((deprecated));
+
+/* This method checks read only flag for given property
+ */
+DPL::OptionalInt CheckPropertyReadFlag(TizenAppId tzAppid,
+                                       const WidgetPropertyKey &key);
 
 /* This method gets widget property key list
  */
 
 /* This method gets widget property key list
  */
-WidgetPropertyKeyList GetPropertyKeyList(DbWidgetHandle widgetHandle);
+WidgetPropertyKeyList GetPropertyKeyList(TizenAppId tzAppid);
 
 
+//deprecated
 /* This method gets widget property list
  */
 /* This method gets widget property list
  */
-WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle);
+WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle)
+__attribute__((deprecated));
+
+/* This method gets widget property list
+ */
+WidgetPreferenceList GetPropertyList(TizenAppId tzAppid);
 
 /* This method get widget property value
  */
 
 /* This method get widget property value
  */
-WidgetPropertyValue GetPropertyValue(DbWidgetHandle widgetHandle,
+WidgetPropertyValue GetPropertyValue(TizenAppId tzAppid,
                                      const WidgetPropertyKey &key);
                                      const WidgetPropertyKey &key);
-
 } // PropertyDAOReadOnly
 } // namespace WrtDB
 
 } // PropertyDAOReadOnly
 } // namespace WrtDB
 
diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h b/modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h
new file mode 100644 (file)
index 0000000..5f23262
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    vconf_config.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for vconf key config.
+ */
+#ifndef SRC_DOMAIN_VCONF_CONFIG_H
+#define SRC_DOMAIN_VCONF_CONFIG_H
+
+#include <string>
+#include <dpl/string.h>
+
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/path_builder.h>
+
+namespace WrtDB {
+namespace VconfConfig {
+inline std::string GetVconfKeyRootPath(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyPopupUsage(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .Concat(GlobalConfig::GetVconfKeyPopupUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyGeolocationUsage(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .Concat(GlobalConfig::GetVconfKeyGeolocationUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyWebNotificationUsage(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .Concat(GlobalConfig::GetVconfKeyWebNotificationUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyWebDatabaseUsage(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .Concat(GlobalConfig::GetVconfKeyWebDatabaseUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyFilesystemUsage(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .Concat(GlobalConfig::GetVconfKeyFilesystemUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyMemorySavingMode(DPL::String tzPkgId)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
+               .Concat(GlobalConfig::GetVconfKeyMemorySavingModePath())
+               .GetFullPath();
+}
+} // namespace VconfConfig
+} // namespace WrtDB
+
+#endif
index 96afd44..67c88a9 100644 (file)
 extern DPL::Mutex g_wrtDbQueriesMutex;
 
 #define WRT_DB_INTERNAL(tlsCommand, InternalType, interface)                 \
 extern DPL::Mutex g_wrtDbQueriesMutex;
 
 #define WRT_DB_INTERNAL(tlsCommand, InternalType, interface)                 \
-    static DPL::ThreadLocalVariable<InternalType> *tlsCommand ## Ptr = NULL; \
+    static DPL::ThreadLocalVariable<InternalType> *tlsCommand##Ptr = NULL; \
     {                                                                        \
         DPL::Mutex::ScopedLock lock(&g_wrtDbQueriesMutex);                   \
     {                                                                        \
         DPL::Mutex::ScopedLock lock(&g_wrtDbQueriesMutex);                   \
-        if (!tlsCommand ## Ptr) {                                            \
+        if (!tlsCommand##Ptr) {                                            \
             static DPL::ThreadLocalVariable<InternalType> tmp;               \
             static DPL::ThreadLocalVariable<InternalType> tmp;               \
-            tlsCommand ## Ptr = &tmp;                                        \
+            tlsCommand##Ptr = &tmp;                                        \
         }                                                                    \
     }                                                                        \
         }                                                                    \
     }                                                                        \
-    DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand ## Ptr; \
+    DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand##Ptr; \
     if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); }
 
     if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); }
 
-#define WRT_DB_SELECT(name, type, interface) WRT_DB_INTERNAL(name, type::Select, interface)
+#define WRT_DB_SELECT(name, type, interface) WRT_DB_INTERNAL(name, \
+                                                             type::Select, \
+                                                             interface)
 
 
-#define WRT_DB_INSERT(name, type, interface) WRT_DB_INTERNAL(name, type::Insert, interface)
+#define WRT_DB_INSERT(name, type, interface) WRT_DB_INTERNAL(name, \
+                                                             type::Insert, \
+                                                             interface)
 
 
-#define WRT_DB_UPDATE(name, type, interface) WRT_DB_INTERNAL(name, type::Update, interface)
+#define WRT_DB_UPDATE(name, type, interface) WRT_DB_INTERNAL(name, \
+                                                             type::Update, \
+                                                             interface)
 
 
-#define WRT_DB_DELETE(name, type, interface) WRT_DB_INTERNAL(name, type::Delete, interface)
+#define WRT_DB_DELETE(name, type, interface) WRT_DB_INTERNAL(name, \
+                                                             type::Delete, \
+                                                             interface)
 
 #endif // WRT_ENGINE_SRC_CONFIGURATION_WEBRUNTIME_DATABASE_H
 
 #endif // WRT_ENGINE_SRC_CONFIGURATION_WEBRUNTIME_DATABASE_H
index bd1ee00..1144bdc 100644 (file)
 
 namespace WrtDB {
 namespace WidgetConfig {
 
 namespace WrtDB {
 namespace WidgetConfig {
-
-inline std::string GetWidgetBasePath(DPL::String pkgName)
+inline std::string GetWidgetBasePath(DPL::String tzPkgId)
 {
     return PathBuilder()
 {
     return PathBuilder()
-               .Append(GlobalConfig::GetUserInstalledWidgetPath())
-               .Append(DPL::ToUTF8String(pkgName))
+               .Append(GlobalConfig::GetWidgetUserDataPath())
+               .Append(DPL::ToUTF8String(tzPkgId))
                .GetFullPath();
 }
 
                .GetFullPath();
 }
 
-inline std::string GetWidgetWebLocalStoragePath(DPL::String pkgName)
+inline std::string GetWidgetWebLocalStoragePath(DPL::String tzPkgId)
 {
 {
-    return PathBuilder(GetWidgetBasePath(pkgName))
+    return PathBuilder(GetWidgetBasePath(tzPkgId))
                .Append(GlobalConfig::GetWidgetLocalStoragePath())
                .GetFullPath();
 }
 
                .Append(GlobalConfig::GetWidgetLocalStoragePath())
                .GetFullPath();
 }
 
-inline std::string GetWidgetPersistentStoragePath(DPL::String pkgName)
+inline std::string GetWidgetPersistentStoragePath(DPL::String tzPkgId)
 {
 {
-    return PathBuilder(GetWidgetBasePath(pkgName))
+    return PathBuilder(GetWidgetBasePath(tzPkgId))
                .Append(GlobalConfig::GetWidgetPrivateStoragePath())
                .GetFullPath();
 }
 
                .Append(GlobalConfig::GetWidgetPrivateStoragePath())
                .GetFullPath();
 }
 
-inline std::string GetWidgetTemporaryStoragePath(DPL::String pkgName)
+inline std::string GetWidgetTemporaryStoragePath(DPL::String tzPkgId)
 {
     return PathBuilder()
                .Append(GlobalConfig::GetTmpDirPath())
 {
     return PathBuilder()
                .Append(GlobalConfig::GetTmpDirPath())
-               .Append(DPL::ToUTF8String(pkgName))
+               .Append(DPL::ToUTF8String(tzPkgId))
                .GetFullPath();
 }
 
                .GetFullPath();
 }
 
-inline std::string GetWidgetDesktopFilePath(DPL::String pkgName)
+inline std::string GetWidgetDesktopFilePath(DPL::String tzPkgId)
 {
     return PathBuilder()
                .Append(GlobalConfig::GetUserWidgetDesktopPath())
 {
     return PathBuilder()
                .Append(GlobalConfig::GetUserWidgetDesktopPath())
-               .Append(DPL::ToUTF8String(pkgName))
+               .Append(DPL::ToUTF8String(tzPkgId))
                .Concat(".desktop")
                .GetFullPath();
 }
                .Concat(".desktop")
                .GetFullPath();
 }
index 9dbd580..a7cd866 100644 (file)
@@ -39,7 +39,6 @@
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/common_dao_types.h>
 
 namespace WrtDB {
-
 /**
  * Widget's signature enum.
  * This enumerates signature type of widget.
 /**
  * Widget's signature enum.
  * This enumerates signature type of widget.
@@ -51,6 +50,11 @@ enum WidgetSignatureType
     SIGNATURE_TYPE_UNIDENTIFIED
 };
 
     SIGNATURE_TYPE_UNIDENTIFIED
 };
 
+enum CertificateSource {
+    SIGNATURE_DISTRIBUTOR = 0,
+    SIGNATURE_AUTHOR = 1
+};
+
 typedef std::list<DPL::String> StringList;
 
 struct WidgetLocalizedInfo
 typedef std::list<DPL::String> StringList;
 
 struct WidgetLocalizedInfo
@@ -85,12 +89,13 @@ struct WidgetCertificateData
     // Common name field in certificate
     DPL::String strCommonName;
 
     // Common name field in certificate
     DPL::String strCommonName;
 
-    bool operator== (const WidgetCertificateData& certData) const {
+    bool operator== (const WidgetCertificateData& certData) const
+    {
         return certData.chainId == chainId &&
         return certData.chainId == chainId &&
-           certData.owner == owner &&
-           certData.strCommonName == strCommonName &&
-           certData.strMD5Fingerprint == strMD5Fingerprint &&
-           certData.strSHA1Fingerprint == strSHA1Fingerprint;
+               certData.owner == owner &&
+               certData.strCommonName == strCommonName &&
+               certData.strMD5Fingerprint == strMD5Fingerprint &&
+               certData.strSHA1Fingerprint == strSHA1Fingerprint;
     }
 };
 
     }
 };
 
@@ -98,6 +103,7 @@ typedef std::list<WidgetCertificateData> WidgetCertificateDataList;
 
 typedef DPL::String Locale;
 typedef std::set<Locale> LocaleSet;
 
 typedef DPL::String Locale;
 typedef std::set<Locale> LocaleSet;
+typedef std::list<std::string> ExternalLocationList;
 
 /**
  * WidgetRegisterInfo
 
 /**
  * WidgetRegisterInfo
@@ -109,11 +115,10 @@ struct WidgetRegisterInfo
     struct LocalizedIcon : public ConfigParserData::Icon
     {
         LocalizedIcon(const ConfigParserData::Icon& icon,
     struct LocalizedIcon : public ConfigParserData::Icon
     {
         LocalizedIcon(const ConfigParserData::Icon& icon,
-                const LocaleSet& _availableLocales) :
+                      const LocaleSet& _availableLocales) :
             ConfigParserData::Icon(icon),
             availableLocales(_availableLocales)
             ConfigParserData::Icon(icon),
             availableLocales(_availableLocales)
-        {
-        }
+        {}
 
         LocaleSet availableLocales;
     };
 
         LocaleSet availableLocales;
     };
@@ -150,27 +155,35 @@ struct WidgetRegisterInfo
 
     //Constructor
     WidgetRegisterInfo() :
 
     //Constructor
     WidgetRegisterInfo() :
-        type(APP_TYPE_UNKNOWN),
+        webAppType(APP_TYPE_UNKNOWN),
         signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
         signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
-        isFactoryWidget(0),
         isTestWidget(0),
         isTestWidget(0),
-        configInfo()
-    {
-    }
+        configInfo(),
+        packagingType(PKG_TYPE_UNKNOWN)
+    {}
 
 
-    WidgetType type;
+    WidgetType webAppType;
+    WidgetType type; // TODO : This type will be removed.
     DPL::OptionalString guid;
     DPL::OptionalString version;
     DPL::OptionalString guid;
     DPL::OptionalString version;
+    DPL::OptionalString minVersion;
     std::string shareHref;
     std::string baseFolder;
     WidgetSignatureType signatureType;
     std::string shareHref;
     std::string baseFolder;
     WidgetSignatureType signatureType;
-    int isFactoryWidget;
     int isTestWidget;
     ConfigParserData configInfo;
     int isTestWidget;
     ConfigParserData configInfo;
-    Powder::Description powderDescription;
     LocalizationData localizationData;
     LocalizationData localizationData;
+
     DPL::OptionalString pkgname;
     DPL::OptionalString pkgname;
+    WidgetPkgName pkgName;
+    TizenPkgId tzPkgid;
+    TizenAppId tzAppid;
+
     time_t installedTime;
     time_t installedTime;
+    PackagingType packagingType;
+    EncryptedFileList encryptedFiles;
+    ExternalLocationList externalLocations;
+    DPL::OptionalString widgetInstalledPath;
 };
 
 typedef std::list<std::string> CertificateChainList;
 };
 
 typedef std::list<std::string> CertificateChainList;
@@ -187,7 +200,8 @@ class IWacSecurity
 
     virtual bool isWacSigned() const = 0;
 
 
     virtual bool isWacSigned() const = 0;
 
-    virtual void getCertificateChainList(CertificateChainList& list) const = 0;
+    virtual void getCertificateChainList(CertificateChainList& list,
+                                         CertificateSource source) const = 0;
 };
 
 /**
 };
 
 /**
@@ -277,13 +291,14 @@ class WidgetDAOReadOnly
     };
     typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
 
     };
     typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
 
-
     /**
      * This is a constructor.
      *
      * @param[in] widgetHandle application id of widget.
      */
     WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
     /**
      * This is a constructor.
      *
      * @param[in] widgetHandle application id of widget.
      */
     WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
+    WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
+    WidgetDAOReadOnly(DPL::String tzAppid);
 
     /**
      * Destructor
 
     /**
      * Destructor
@@ -295,13 +310,41 @@ class WidgetDAOReadOnly
      *
      * @return widget handle(m_widgetHandle).
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      *
      * @return widget handle(m_widgetHandle).
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
-     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     * DB table.
      */
     DbWidgetHandle getHandle() const;
     static DbWidgetHandle getHandle(const WidgetGUID GUID);
     static DbWidgetHandle getHandle(const DPL::String pkgName);
 
     /**
      */
     DbWidgetHandle getHandle() const;
     static DbWidgetHandle getHandle(const WidgetGUID GUID);
     static DbWidgetHandle getHandle(const DPL::String pkgName);
 
     /**
+     * Returns tizenAppId for the specified widget
+     *
+     * @return tzAppid;
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     * DB table.
+     */
+
+    TizenAppId getTzAppId() const;
+    static TizenAppId getTzAppId(const WidgetGUID GUID);
+    static TizenAppId getTzAppId(const DbWidgetHandle handle);
+    static TizenAppId getTzAppId(const TizenPkgId tzPkgid);
+
+    /**
+     * Returns WidgetPkgName for the specified widget
+     *
+     * @return pkgName;
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     * DB table.
+     */
+
+    WidgetPkgName getPkgName() const;
+    static WidgetPkgName getPkgName(const WidgetGUID GUID);
+    static WidgetPkgName getPkgName(const DbWidgetHandle handle);
+
+    /**
      * This method returns the root directory of widget resource.
      *
      * @return path name of root directory.
      * This method returns the root directory of widget resource.
      *
      * @return path name of root directory.
@@ -331,7 +374,7 @@ class WidgetDAOReadOnly
      * @return WidgetType
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
      * @return WidgetType
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
-                                                records in DB table.
+     *                                          records in DB table.
      */
     WidgetType getWidgetType() const;
 
      */
     WidgetType getWidgetType() const;
 
@@ -346,13 +389,14 @@ class WidgetDAOReadOnly
     WidgetGUID getGUID() const;
 
     /**
     WidgetGUID getGUID() const;
 
     /**
-     * This method returns the Package name of the widget.
+     * This method returns the App id of the widget.
      *
      *
-     * @return pkgname
+     * @return appid
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
-     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     * DB table.
      */
      */
-    DPL::OptionalString getPkgname() const;
+    DPL::OptionalString getTizenAppId() const;
 
     /**
      * This method returns the defaultlocale for the widget.
 
     /**
      * This method returns the defaultlocale for the widget.
@@ -456,6 +500,13 @@ class WidgetDAOReadOnly
     DPL::OptionalString getVersion() const;
 
     /**
     DPL::OptionalString getVersion() const;
 
     /**
+     * This method is used as a getter for csp policy of widget. It should be
+     * provided in configuration file.
+     * @return global csp policy for widget
+     */
+    DPL::OptionalString getCspPolicy() const;
+
+    /**
      * This method returns list filed with Common Name entries from certificate.
      *
      * @return Common Name of Distribuotor End Entity certificate.
      * This method returns list filed with Common Name entries from certificate.
      *
      * @return Common Name of Distribuotor End Entity certificate.
@@ -464,8 +515,8 @@ class WidgetDAOReadOnly
      *  DB table.
      */
     WidgetCertificateCNList getKeyCommonNameList(
      *  DB table.
      */
     WidgetCertificateCNList getKeyCommonNameList(
-            WidgetCertificateData::Owner owner,
-            WidgetCertificateData::Type type) const;
+        WidgetCertificateData::Owner owner,
+        WidgetCertificateData::Type type) const;
 
     /**
      * given a certificate owner (author / distributor) and type of certificate
 
     /**
      * given a certificate owner (author / distributor) and type of certificate
@@ -473,8 +524,8 @@ class WidgetDAOReadOnly
      * function returns list of matching fingerprints
      */
     FingerPrintList getKeyFingerprints(
      * function returns list of matching fingerprints
      */
     FingerPrintList getKeyFingerprints(
-            WidgetCertificateData::Owner owner,
-            WidgetCertificateData::Type type) const;
+        WidgetCertificateData::Owner owner,
+        WidgetCertificateData::Type type) const;
 
     /*
      *  This method gets certificate data list for a widget from database.
 
     /*
      *  This method gets certificate data list for a widget from database.
@@ -533,7 +584,7 @@ class WidgetDAOReadOnly
     bool getWebkitPluginsRequired() const;
 
     /**
     bool getWebkitPluginsRequired() const;
 
     /**
-     * This method returns a list of all the installed widgets.
+     * This method returns a list of all the installed widgets' app id.
      *
      * @return list of installed widgets' app id.
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      *
      * @return list of installed widgets' app id.
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
@@ -542,7 +593,24 @@ class WidgetDAOReadOnly
      */
     static DbWidgetHandleList getHandleList();
 
      */
     static DbWidgetHandleList getHandleList();
 
-   /**
+    /**
+     * This method returns list of pkgname of installed packages
+     * @return list of pkgname of installed packages
+     */
+    static TizenAppIdList getTizenAppidList();
+    static WidgetPkgNameList getPkgnameList();
+
+    /**
+     * This method returns a list of all the installed widgets.
+     *
+     * @return list of installed widgets.
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     *  DB table.
+     */
+    static DbWidgetDAOReadOnlyList getWidgetList();
+
+    /**
      * This method removes a widget's information from EmDB.
      *
      * @see RegisterWidget()
      * This method removes a widget's information from EmDB.
      *
      * @see RegisterWidget()
@@ -615,14 +683,6 @@ class WidgetDAOReadOnly
     std::string getShareHref() const;
 
     /**
     std::string getShareHref() const;
 
     /**
-     * This method checks whether specified widget is a factory widget.
-     *
-     * @param[in] widgetHandle    widget's app id
-     * @return true if yes, false if no.
-     */
-    bool isFactory() const;
-
-    /**
      * This method get widget installed time
      *
      * @return time_t : return widget's install time
      * This method get widget installed time
      *
      * @return time_t : return widget's install time
@@ -639,25 +699,15 @@ class WidgetDAOReadOnly
      */
     std::string getBaseFolder() const;
 
      */
     std::string getBaseFolder() const;
 
-    /**
-     * This method gets deletable property of widget.
-     *
-     * @return true: can be deleted; false: can not be deleted
-     * @exception WRT_CONF_ERR_GCONF_FAILURE
-     * @exception WRT_CONF_ERR_EMDB_FAILURE
-     * @exception WRT_CONF_ERR_EMDB_NO_RECORD
-     */
-    bool isDeletable() const;
-
     /* This method gets the parameter list for resource.
      */
     ResourceAttributeList getResourceAttribute(
     /* This method gets the parameter list for resource.
      */
     ResourceAttributeList getResourceAttribute(
-            const std::string &resourceId) const;
+        const std::string &resourceId) const;
 
     /* This method checks read only flag for given property
      */
     DPL::OptionalInt checkPropertyReadFlag(
 
     /* This method checks read only flag for given property
      */
     DPL::OptionalInt checkPropertyReadFlag(
-            const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
+        const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
 
     /* This method gets widget property key list
      */
 
     /* This method gets widget property key list
      */
@@ -670,7 +720,7 @@ class WidgetDAOReadOnly
     /* This method get widget property value
      */
     PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
     /* This method get widget property value
      */
     PropertyDAOReadOnly::WidgetPropertyValue getPropertyValue(
-            const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
+        const PropertyDAOReadOnly::WidgetPropertyKey &key) const;
 
     LanguageTagList getLanguageTags() const;
     LanguageTagList getIconLanguageTags() const;
 
     LanguageTagList getLanguageTags() const;
     LanguageTagList getIconLanguageTags() const;
@@ -680,16 +730,25 @@ class WidgetDAOReadOnly
     // Local storage
     std::string getPrivateLocalStoragePath() const;
 
     // Local storage
     std::string getPrivateLocalStoragePath() const;
 
-    ChildProtection::Record getChildProtection() const;
-
-    Powder::Description getPowderDescription() const;
-
     bool getBackSupported() const;
 
     static bool isWidgetInstalled(DbWidgetHandle handle);
     bool getBackSupported() const;
 
     static bool isWidgetInstalled(DbWidgetHandle handle);
-    static bool isWidgetInstalled(DPL::String pkgName);
+    static bool isWidgetInstalled(const TizenAppId & tzAppId);
+
+    /* This method get path of the splash image.
+     *
+     * @return path of the widget's splash image
+     */
+    DPL::OptionalString getSplashImgSrc() const;
 
 
-    CertificateChainList getWidgetCertificate() const;
+    ExternalLocationList getWidgetExternalLocations() const;
+
+    /*
+     * Default value is required to keep compatibility with
+     * wrt-installer and wrt.
+     */
+    CertificateChainList getWidgetCertificate(
+        CertificateSource source = SIGNATURE_DISTRIBUTOR) const;
 
     void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
 
 
     void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
 
@@ -700,9 +759,71 @@ class WidgetDAOReadOnly
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      */
     void getAppServiceList(
      * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
      */
     void getAppServiceList(
-            WidgetApplicationServiceList& outAppServiceList) const;
-};
+        WidgetApplicationServiceList& outAppServiceList) const;
+
+    /**
+     * This method returns the type of the package.
+     *
+     * @return PackagingType
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching
+     *                                          records in DB table.
+     */
+    PackagingType getPackagingType() const;
+
+    void getEncryptedFileList(EncryptedFileList& filesList) const;
 
 
+    /**
+     * This method returns widget's background page filename.
+     *
+     * @return Name of file containing background page
+     */
+    DPL::OptionalString getBackgroundPage() const;
+
+    /**
+     * @brief generateTizenId generates new package id
+     *
+     * If widget do not supplies it's own tizen package id, this method can be
+     * used,
+     * although it should be removed in future.
+     *
+     * @return new tizen package id
+     */
+    static TizenPkgId generatePkgId();
+    static TizenPkgId generateTizenId()
+    {
+        return generatePkgId();
+    }
+
+    /**
+     * @brief This method return each value for security setting
+     *
+     * @return SettingsType
+     *         SETTINGS_TYPE_UNKNOWN     : unknow value
+     *         SETTINGS_TYPE_ON                : enable
+     *         SETTINGS_TYPE_ALWAYS_ASK : ask by popup
+     *         SETTINGS_TYPE_OFF               : disable
+     */
+    SettingsType getSecurityPopupUsage() const;
+    SettingsType getGeolocationUsage() const;
+    SettingsType getWebNotificationUsage() const;
+    SettingsType getWebDatabaseUsage() const;
+    SettingsType getFileSystemUsage() const;
+
+    /**
+     * This method returns widget's installed path
+     *
+     * @return path of widget installed
+     */
+    DPL::OptionalString getWidgetInstalledPath() const;
+
+    /**
+     * This method returns tizen package id
+     *
+     * @return tizen package id
+     */
+    TizenPkgId getTizenPkgId() const;
+};
 } // namespace WrtDB
 
 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
 } // namespace WrtDB
 
 #endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h b/modules/widget_dao/include/dpl/wrt-dao-ro/wrt_db_types.h
new file mode 100644 (file)
index 0000000..1702433
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    wrt_db_types.h
+ * @author  Krzysztof Jackiewicz
+ * @version 1.0
+ * @brief   This file contains the declaration of common data types for wrtdb
+ */
+#ifndef _WRT_DB_TYPES_H_
+#define _WRT_DB_TYPES_H_
+
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+
+typedef WrtDB::DbWidgetHandle WidgetHandle;
+typedef WrtDB::DbWidgetHandleList WidgetHandleList;
+typedef WrtDB::DbWidgetDAOReadOnlyList WidgetDAOReadOnlyList;
+
+typedef WrtDB::DbWidgetFeature WidgetFeature;
+typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet;
+
+typedef WrtDB::DbWidgetSize WidgetSize;
+typedef WrtDB::DbPluginHandle PluginHandle;
+
+#endif
index 94b5cb7..6ee312a 100644 (file)
 
 namespace WrtDB {
 namespace FeatureDAO {
 
 namespace WrtDB {
 namespace FeatureDAO {
-    FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
-                                  const DbPluginHandle pluginHandle);
-
-    FeatureHandle RegisterStrangeFeature(const std::string& featureName);
+FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
+                              const DbPluginHandle pluginHandle);
+void UnregisterFeature(FeatureHandle featureHandle);
 } // namespace FeatureDB
 } // namespace WrtDB
 
 } // namespace FeatureDB
 } // namespace WrtDB
 
index 51c9f38..21b66fe 100644 (file)
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
 
 namespace WrtDB {
-
 class GlobalDAO : public GlobalDAOReadOnly
 {
   public:
 class GlobalDAO : public GlobalDAOReadOnly
 {
   public:
-    /**
-     * Set new Parental mode status
-     */
-    static void SetParentalMode(bool parental_status);
-
-    /**
-     * Retrieve Parental mode maximal allowed age
-     *
-     * @return NULL if allowed age not set, else pointer value is allowed age
-     */
-    static void SetParentalAllowedAge(const DPL::OptionalInt& age);
-
-    static void AddCategoryRule(
-            const ChildProtection::PowderRules::CategoryRule& powder);
-
-    static void RemoveCategoryRule(
-            const ChildProtection::PowderRules::CategoryRule& powder);
-
-    static void UpdateCategoryRule(
-            const ChildProtection::PowderRules::CategoryRule& oldRule,
-            const ChildProtection::PowderRules::CategoryRule& newRule);
-
-    static void AddAdultBlackListElement(const DPL::String &url);
-
-    static void RemoveAdultBlackListElement(const DPL::String &url);
-
-    static void UpdateAdultBlackList(const DPL::String &oldUrl,
-                                     const DPL::String &newUrl);
-
-    /**
-     * Add deffered widget packages to be installed
-     */
-    static void AddDefferedWidgetPackageInstallation(const DPL::String &path);
-
-    /**
-     * Remove deffered widget packages to be installed
-     */
-    static void RemoveDefferedWidgetPackageInstallation(const DPL::String &arg);
-
     static void SetDeveloperMode(bool mode);
 
     static void SetSecureByDefault(bool secureByDefault);
     static void SetDeveloperMode(bool mode);
 
     static void SetSecureByDefault(bool secureByDefault);
@@ -95,19 +55,12 @@ class GlobalDAO : public GlobalDAOReadOnly
      */
     static void SetRoamingDataUsage(NetworkAccessMode newMode);
 
      */
     static void SetRoamingDataUsage(NetworkAccessMode newMode);
 
-    /**
-     * This method sets Autofill for Webkit
-     */
-    static void SetAutoSaveIdPasswd(
-            const DPL::String &url, const AutoSaveData &saveData);
-
+    static void SetCookieSharingMode(bool mode);
 
   private:
     GlobalDAO()
 
   private:
     GlobalDAO()
-    {
-    }
+    {}
 };
 };
-
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_GLOBAL_DAO_H_ */
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_GLOBAL_DAO_H_ */
index e8a86d3..0b53eef 100644 (file)
@@ -28,7 +28,6 @@
 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
 
 namespace WrtDB {
-
 class PluginDAO : public PluginDAOReadOnly
 {
   public:
 class PluginDAO : public PluginDAOReadOnly
 {
   public:
@@ -36,26 +35,27 @@ class PluginDAO : public PluginDAOReadOnly
     PluginDAO(const std::string &libraryName);
 
     static DbPluginHandle registerPlugin(
     PluginDAO(const std::string &libraryName);
 
     static DbPluginHandle registerPlugin(
-            const PluginMetafileData& metafile,
-            const std::string& pluginPath);
+        const PluginMetafileData& metafile,
+        const std::string& pluginPath);
 
     static void registerPluginImplementedObject(
 
     static void registerPluginImplementedObject(
-            const std::string& objectName,
-            DbPluginHandle pluginHandle);
+        const std::string& objectName,
+        DbPluginHandle pluginHandle);
 
     static void registerPluginRequiredObject(
 
     static void registerPluginRequiredObject(
-            const std::string& objectName,
-            DbPluginHandle pluginHandle);
+        const std::string& objectName,
+        DbPluginHandle pluginHandle);
 
     static void registerPluginLibrariesDependencies(
 
     static void registerPluginLibrariesDependencies(
-            DbPluginHandle plugin,
-            const PluginHandleSetPtr& dependencies);
+        DbPluginHandle plugin,
+        const PluginHandleSetPtr& dependencies);
 
     static void setPluginInstallationStatus(
 
     static void setPluginInstallationStatus(
-            DbPluginHandle,
-            PluginInstallationState);
-};
+        DbPluginHandle,
+        PluginInstallationState);
 
 
+    static void unregisterPlugin(DbPluginHandle pluginHandle);
+};
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_PLUGIN_DAO_H_ */
 } // namespace WrtDB
 
 #endif /* WRT_SRC_CONFIGURATION_PLUGIN_DAO_H_ */
index d75dc59..faecc0d 100644 (file)
 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
 
 namespace WrtDB {
 #include <dpl/wrt-dao-ro/property_dao_read_only.h>
 
 namespace WrtDB {
-
 struct WidgetRegisterInfo; //forward declaration
 
 namespace PropertyDAO {
 struct WidgetRegisterInfo; //forward declaration
 
 namespace PropertyDAO {
-
-void RemoveProperty(DbWidgetHandle widgetHandle,
+void RemoveProperty(TizenAppId tzAppid,
                     const PropertyDAOReadOnly::WidgetPropertyKey &key);
 
                     const PropertyDAOReadOnly::WidgetPropertyKey &key);
 
+//deprecated
 /* This method sets widget property
  */
 void SetProperty(DbWidgetHandle widgetHandle,
                  const PropertyDAOReadOnly::WidgetPropertyKey &key,
                  const PropertyDAOReadOnly::WidgetPropertyValue &value,
 /* This method sets widget property
  */
 void SetProperty(DbWidgetHandle widgetHandle,
                  const PropertyDAOReadOnly::WidgetPropertyKey &key,
                  const PropertyDAOReadOnly::WidgetPropertyValue &value,
+                 bool readOnly = false)
+__attribute__((deprecated));
+
+/* This method sets widget property
+ */
+void SetProperty(TizenAppId tzAppid,
+                 const PropertyDAOReadOnly::WidgetPropertyKey &key,
+                 const PropertyDAOReadOnly::WidgetPropertyValue &value,
                  bool readOnly = false);
 
 /* This method registers properties for widget.
  * Properties unregistering is done via "delete cascade" mechanism in SQL
  */
                  bool readOnly = false);
 
 /* This method registers properties for widget.
  * Properties unregistering is done via "delete cascade" mechanism in SQL
  */
-void RegisterProperties(DbWidgetHandle widgetHandle,
+void RegisterProperties(TizenAppId tzAppid,
                         const WidgetRegisterInfo &regInfo);
                         const WidgetRegisterInfo &regInfo);
-
 } // namespace PropertyDAO
 } // namespace WrtDB
 
 } // namespace PropertyDAO
 } // namespace WrtDB
 
index 1b8b507..5f059db 100644 (file)
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <list>
 #include <string>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 #include <list>
 #include <string>
+#include <sys/time.h>
+#include <ctime>
+#include <cstdlib>
 #include <dpl/exception.h>
 #include <dpl/db/orm.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/wrt-dao-rw/property_dao.h>
 
 namespace WrtDB {
 #include <dpl/exception.h>
 #include <dpl/db/orm.h>
 #include <dpl/wrt-dao-ro/config_parser_data.h>
 #include <dpl/wrt-dao-rw/property_dao.h>
 
 namespace WrtDB {
-
 class WidgetDAO : public WidgetDAOReadOnly
 {
   public:
     typedef std::list<DPL::String> LanguageTagsList;
 
 class WidgetDAO : public WidgetDAOReadOnly
 {
   public:
     typedef std::list<DPL::String> LanguageTagsList;
 
-    /**
-     * This is a constructor.
-     *
-     * @param[in] widgetHandle application id of widget.
-     * @param[in] widgetGUID application guid of widget.
-     */
-    WidgetDAO(DbWidgetHandle widgetHandle);
+    WidgetDAO(DbWidgetHandle handle);
     WidgetDAO(DPL::OptionalString widgetGUID);
     WidgetDAO(DPL::OptionalString widgetGUID);
+    WidgetDAO(DPL::String tzAppId);
 
     /**
      * Destructor
 
     /**
      * Destructor
@@ -56,91 +53,175 @@ class WidgetDAO : public WidgetDAOReadOnly
     virtual ~WidgetDAO();
 
     /**
     virtual ~WidgetDAO();
 
     /**
-     * This method registers the widget information to the DB when it is installed.
+     * This method registers the widget information in the DB when it is
+     * installed.
      *
      * @see WidgetRegisterInfo
      * @see UnRegisterWidget()
      *
      * @see WidgetRegisterInfo
      * @see UnRegisterWidget()
-     * @param[in] pWidgetRegisterInfo    Specified the widget's information needed to be registered.
-     * @return widget's app id issued by app manager; 0 represents a failure during register.
+     * @param[in] TizenAppId Widget app id that will be registered.
+     * @param[in] pWidgetRegisterInfo    Specified the widget's information
+     * needed to be registered.
+     * @param[in] wacSecurity   Widget's security certificates.
      */
      */
+    static void registerWidget(
+        const TizenAppId& tzAppId,
+        const WidgetRegisterInfo &widgetRegInfo,
+        const IWacSecurity &wacSecurity);
+
     static DbWidgetHandle registerWidget(
     static DbWidgetHandle registerWidget(
-            const WidgetRegisterInfo &pWidgetRegisterInfo,
-            const IWacSecurity &wacSecurity,
-            const LanguageTagsList& languageTags);
+        const WidgetRegisterInfo &pWidgetRegisterInfo,
+        const IWacSecurity &wacSecurity) __attribute__((deprecated));
+
+    /**
+     * @brief registerWidgetGenerateTizenId Registers widget with auto-generated
+     * tizen id
+     *
+     * This function is disadviced and should be used only in tests.
+     * Function is not thread-safe.
+     *
+     * @param pWidgetRegisterInfo registeration information
+     * @param wacSecurity Widget's security certificates.
+     * @return tzAppId generated
+     */
+    static TizenAppId registerWidgetGeneratePkgId(
+        const WidgetRegisterInfo &pWidgetRegisterInfo,
+        const IWacSecurity &wacSecurity);
+
+    /**
+     * This method re-registers the widget information to the DB when it is
+     * installed.
+     *
+     * It performs unregistration and new registration of widget in db in one
+     * transaction.
+     *
+     * @see WidgetRegisterInfo
+     * @param[in] tzAppId  Widget tizen app id that will be registered.
+     * @param[in] pWidgetRegisterInfo    Specified the widget's information
+     * needed to be registered.
+     * @param[in] wacSecurity   Widget's security certificates.
+     */
+    static void registerOrUpdateWidget(
+        const TizenAppId & tzAppId,
+        const WidgetRegisterInfo &widgetRegInfo,
+        const IWacSecurity &wacSecurity);
 
     /**
      * This method removes a widget's information from EmDB.
      *
      * @see RegisterWidget()
 
     /**
      * This method removes a widget's information from EmDB.
      *
      * @see RegisterWidget()
-     * @param[in] widgetHandle    widget's app id
-     * @return true if succeed, false if fail.
+     * @param[in] tzAppId widgets name to be unregistered
      */
      */
-    static void unregisterWidget(DbWidgetHandle widgetHandle);
+    static void unregisterWidget(const TizenAppId & tzAppId);
+
+    static void unregisterWidget(WrtDB::DbWidgetHandle handle) __attribute__((
+                                                                                 deprecated));
 
     /* This method removes widget property
      */
     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
 
 
     /* This method removes widget property
      */
     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);
 
+    /**
+     * @brief registerExternalLocations Removes rows from
+     * WidgetExternalLocations
+     */
+    void unregisterAllExternalLocations();
+
     /* This method sets widget property
      */
     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
     /* This method sets widget property
      */
     void setProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key,
-            const PropertyDAOReadOnly::WidgetPropertyValue &value,
-            bool readOnly = false);
+                     const PropertyDAOReadOnly::WidgetPropertyValue &value,
+                     bool readOnly = false);
+
+    /* set tzAppId
+     */
+    void setTizenAppId(const DPL::OptionalString& tzAppId);
+
+    /* This function will update of api-feature status.
+     * If status is true (feature rejected) plugin connected with this
+     * api feature mustn't be loaded durign widget launch.
+     */
+    void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
 
 
-    /* set PkgName
+    /*
+     * This method change security settings value
      */
      */
-    void setPkgName(const DPL::OptionalString& pkgName);
+    void setSecurityPopupUsage(const SettingsType value);
+    void setGeolocationUsage(const SettingsType value);
+    void setWebNotificationUsage(const SettingsType value);
+    void setWebDatabaseUsage(const SettingsType value);
+    void setFileSystemUsage(const SettingsType value);
 
   private:
     //Methods used during widget registering
     static DbWidgetHandle registerWidgetInfo(
 
   private:
     //Methods used during widget registering
     static DbWidgetHandle registerWidgetInfo(
-            const WidgetRegisterInfo &regInfo,
-            const IWacSecurity &wacSecurity);
+        const TizenAppId & widgetName,
+        const WidgetRegisterInfo &regInfo,
+        const IWacSecurity &wacSecurity,
+        const DPL::Optional<DbWidgetHandle> handle =
+            DPL::Optional<DbWidgetHandle>());
     static void registerWidgetExtendedInfo(
     static void registerWidgetExtendedInfo(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetLocalizedInfo(
     static void registerWidgetLocalizedInfo(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
-    static void registerWidgetUserAgentLocales(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &rInf,
-            const LanguageTagsList& languageTags);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetIcons(
     static void registerWidgetIcons(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetStartFile(
     static void registerWidgetStartFile(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetPreferences(
     static void registerWidgetPreferences(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetFeatures(
     static void registerWidgetFeatures(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
+    static void registerWidgetPrivilege(
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetWindowModes(
     static void registerWidgetWindowModes(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetWarpInfo(
     static void registerWidgetWarpInfo(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerWidgetCertificates(
     static void registerWidgetCertificates(
-            DbWidgetHandle widgetHandle,
-            const IWacSecurity &wacSecurity);
-    static void registerWidgetPowderData(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
-    static void registerLaunchCertificates(
-            DbWidgetHandle widgetHandle,
-            const CertificateChainList &list);
+        DbWidgetHandle widgetHandle,
+        const IWacSecurity &wacSecurity);
+    static void registerCertificatesChains(
+        DbWidgetHandle widgetHandle,
+        CertificateSource certificateSource,
+        const CertificateChainList &list);
     static void registerWidgetSettings(
     static void registerWidgetSettings(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
     static void registerAppService(
     static void registerAppService(
-            DbWidgetHandle widgetHandle,
-            const WidgetRegisterInfo &regInfo);
-};
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
+    static void registerEncryptedResouceInfo(
+        DbWidgetHandle widgetHandle,
+        const WidgetRegisterInfo &regInfo);
+    /**
+     * @brief registerExternalLocations Inserts new rows to
+     * WidgetExternalLocations
+     * @param externals list of files
+     */
+    static void registerExternalLocations(
+        DbWidgetHandle widgetHandle,
+        const ExternalLocationList &
+        externals);
+    static void registerWidgetSecuritySettings(DbWidgetHandle widgetHandle);
 
 
+    static void registerWidgetInternal(
+        const TizenAppId & tzAppId,
+        const WidgetRegisterInfo &widgetRegInfo,
+        const IWacSecurity &wacSecurity,
+        const DPL::Optional<DbWidgetHandle> handle =
+            DPL::Optional<DbWidgetHandle>());
+    static void unregisterWidgetInternal(
+        const TizenAppId & tzAppId);
+};
 } // namespace WrtDB
 
 #endif // WIDGET_DAO_H
 } // namespace WrtDB
 
 #endif // WIDGET_DAO_H
old mode 100644 (file)
new mode 100755 (executable)
index dc0f27f..9a41d5b
@@ -5,14 +5,13 @@ SQL(
 /*TODO: secure_by_default should be 0 by default*/
 CREATE_TABLE(GlobalProperties)
     COLUMN_NOT_NULL(developer_mode,          INT,          DEFAULT 0)
 /*TODO: secure_by_default should be 0 by default*/
 CREATE_TABLE(GlobalProperties)
     COLUMN_NOT_NULL(developer_mode,          INT,          DEFAULT 0)
-    COLUMN_NOT_NULL(parental_mode,           INT,          DEFAULT 0)
-    COLUMN(parental_allowed_age,             INT,          DEFAULT NULL)
     COLUMN_NOT_NULL(secure_by_default,       INT,          DEFAULT 1)
     COLUMN_NOT_NULL(home_network_data_usage, TINYINT,      DEFAULT 1)
     COLUMN_NOT_NULL(roaming_data_usage,      TINYINT,      DEFAULT 1)
     COLUMN_NOT_NULL(compliance_mode,         TINYINT,      DEFAULT 0)
     COLUMN_NOT_NULL(compliance_fake_imei,    VARCHAR(256), DEFAULT '')
     COLUMN_NOT_NULL(compliance_fake_meid,    VARCHAR(256), DEFAULT '')
     COLUMN_NOT_NULL(secure_by_default,       INT,          DEFAULT 1)
     COLUMN_NOT_NULL(home_network_data_usage, TINYINT,      DEFAULT 1)
     COLUMN_NOT_NULL(roaming_data_usage,      TINYINT,      DEFAULT 1)
     COLUMN_NOT_NULL(compliance_mode,         TINYINT,      DEFAULT 0)
     COLUMN_NOT_NULL(compliance_fake_imei,    VARCHAR(256), DEFAULT '')
     COLUMN_NOT_NULL(compliance_fake_meid,    VARCHAR(256), DEFAULT '')
+    COLUMN_NOT_NULL(cookie_sharing_mode,          INT,          DEFAULT 0)
 CREATE_TABLE_END()
 
 SQL(
 CREATE_TABLE_END()
 
 SQL(
@@ -32,7 +31,7 @@ CREATE_TABLE(WidgetInfo)
     COLUMN(base_folder,             VARCHAR(256),  DEFAULT '')
     COLUMN(webkit_plugins_required, TINYINT,       DEFAULT 0)
     COLUMN(security_domain,         INT,           DEFAULT 0)
     COLUMN(base_folder,             VARCHAR(256),  DEFAULT '')
     COLUMN(webkit_plugins_required, TINYINT,       DEFAULT 0)
     COLUMN(security_domain,         INT,           DEFAULT 0)
-    COLUMN_NOT_NULL(child_protection,INT,          DEFAULT 0)
+    COLUMN(csp_policy,              TEXT,          DEFAULT '')
     COLUMN(recognized,              INT,           DEFAULT 0)
     COLUMN(wac_signed,              INT,           DEFAULT 0)
     COLUMN(distributor_signed,      INT,           DEFAULT 0)
     COLUMN(recognized,              INT,           DEFAULT 0)
     COLUMN(wac_signed,              INT,           DEFAULT 0)
     COLUMN(distributor_signed,      INT,           DEFAULT 0)
@@ -40,11 +39,18 @@ CREATE_TABLE(WidgetInfo)
     COLUMN_NOT_NULL(back_supported, TINYINT,       DEFAULT 0)
     COLUMN(access_network,          TINYINT,       DEFAULT 0)
     COLUMN(defaultlocale,           VARCHAR(256),  DEFAULT 0)
     COLUMN_NOT_NULL(back_supported, TINYINT,       DEFAULT 0)
     COLUMN(access_network,          TINYINT,       DEFAULT 0)
     COLUMN(defaultlocale,           VARCHAR(256),  DEFAULT 0)
-    COLUMN(pkgname,             VARCHAR(256),  DEFAULT 0)
+    COLUMN_NOT_NULL(tizen_pkgid,    VARCHAR(256),  DEFAULT '')
+    COLUMN_NOT_NULL(tizen_appid,    VARCHAR(256),  DEFAULT 0 UNIQUE)
+    COLUMN(pkg_type,                INT,  DEFAULT 0)
 CREATE_TABLE_END()
 
 CREATE_TABLE_END()
 
+SQL(
+    CREATE INDEX IF NOT EXISTS WidgetInfo_AppidIndex ON WidgetInfo(tizen_appid);
+)
+
 CREATE_TABLE(WidgetCertificate)
     COLUMN_NOT_NULL(app_id,                 INT,)
 CREATE_TABLE(WidgetCertificate)
     COLUMN_NOT_NULL(app_id,                 INT,)
+    COLUMN_NOT_NULL(cert_source,            INT,    CHECK(cert_source between 0 and 1))
     COLUMN_NOT_NULL(encoded_chain,          VARCHAR(16000),)
     TABLE_CONSTRAINTS(
         FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
     COLUMN_NOT_NULL(encoded_chain,          VARCHAR(16000),)
     TABLE_CONSTRAINTS(
         FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
@@ -59,15 +65,6 @@ CREATE_TABLE(WidgetWindowModes)
     )
 CREATE_TABLE_END()
 
     )
 CREATE_TABLE_END()
 
-CREATE_TABLE(WidgetUserAgentLocales)
-    COLUMN_NOT_NULL(id,             INTEGER,        PRIMARY KEY AUTOINCREMENT)
-    COLUMN_NOT_NULL(app_id,         INT,)
-    COLUMN_NOT_NULL(language_tag,   TEXT,)
-    TABLE_CONSTRAINTS(
-        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
-    )
-CREATE_TABLE_END()
-
 CREATE_TABLE(LocalizedWidgetInfo)
     COLUMN_NOT_NULL(app_id,         INT,)
     COLUMN_NOT_NULL(widget_locale,  TEXT,)
 CREATE_TABLE(LocalizedWidgetInfo)
     COLUMN_NOT_NULL(app_id,         INT,)
     COLUMN_NOT_NULL(widget_locale,  TEXT,)
@@ -91,24 +88,26 @@ CREATE_TABLE(WidgetExtendedInfo)
     COLUMN(option_state,        INT,            DEFAULT 0)
     COLUMN(share_href,          VARCHAR(256),   DEFAULT '')
     COLUMN(signature_type,      INT,            DEFAULT 0)
     COLUMN(option_state,        INT,            DEFAULT 0)
     COLUMN(share_href,          VARCHAR(256),   DEFAULT '')
     COLUMN(signature_type,      INT,            DEFAULT 0)
-    COLUMN(factory_widget,      INT,            DEFAULT 0)
     COLUMN(updated,             INT,            DEFAULT 0)
     COLUMN(update_policy,       INT,            DEFAULT 0)
     COLUMN_NOT_NULL(test_widget, INT, CHECK(test_widget between 0 and 1) DEFAULT 0)
     COLUMN(updated,             INT,            DEFAULT 0)
     COLUMN(update_policy,       INT,            DEFAULT 0)
     COLUMN_NOT_NULL(test_widget, INT, CHECK(test_widget between 0 and 1) DEFAULT 0)
+    COLUMN(splash_img_src,      VARCHAR(256),   DEFAULT '')
+    COLUMN(background_page,      VARCHAR(256),   DEFAULT '')
+    COLUMN(installed_path,      VARCHAR(512),   DEFAULT '')
     TABLE_CONSTRAINTS(
         FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
     )
 CREATE_TABLE_END()
 
 CREATE_TABLE(WidgetPreference)
     TABLE_CONSTRAINTS(
         FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
     )
 CREATE_TABLE_END()
 
 CREATE_TABLE(WidgetPreference)
-    COLUMN_NOT_NULL(app_id,     INT,)
+    COLUMN_NOT_NULL(tizen_appid,    VARCHAR(256),  DEFAULT 0)
     COLUMN_NOT_NULL(key_name,   VARCHAR(256),)
     COLUMN(key_value,           VARCHAR(8000),  DEFAULT '')
     COLUMN(readonly,            INT,            DEFAULT 0)
 
     TABLE_CONSTRAINTS(
     COLUMN_NOT_NULL(key_name,   VARCHAR(256),)
     COLUMN(key_value,           VARCHAR(8000),  DEFAULT '')
     COLUMN(readonly,            INT,            DEFAULT 0)
 
     TABLE_CONSTRAINTS(
-        PRIMARY KEY(app_id, key_name),
-        FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+        PRIMARY KEY(tizen_appid, key_name),
+        FOREIGN KEY(tizen_appid) REFERENCES WidgetInfo (tizen_appid) ON DELETE CASCADE
     )
 CREATE_TABLE_END()
 
     )
 CREATE_TABLE_END()
 
@@ -117,6 +116,7 @@ CREATE_TABLE(WidgetFeature)
     COLUMN_NOT_NULL(app_id,             INT,)
     COLUMN_NOT_NULL(name,               VARCHAR(256),)
     COLUMN_NOT_NULL(required,           INT,)
     COLUMN_NOT_NULL(app_id,             INT,)
     COLUMN_NOT_NULL(name,               VARCHAR(256),)
     COLUMN_NOT_NULL(required,           INT,)
+    COLUMN_NOT_NULL(rejected,           INT,)
     TABLE_CONSTRAINTS(
         FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
     )
     TABLE_CONSTRAINTS(
         FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
     )
@@ -126,12 +126,20 @@ CREATE_TABLE(FeatureParam)
     COLUMN_NOT_NULL(widget_feature_id,  INTEGER,)
     COLUMN_NOT_NULL(name,         TEXT,)
     COLUMN_NOT_NULL(value,        TEXT,)
     COLUMN_NOT_NULL(widget_feature_id,  INTEGER,)
     COLUMN_NOT_NULL(name,         TEXT,)
     COLUMN_NOT_NULL(value,        TEXT,)
-
     TABLE_CONSTRAINTS(
         FOREIGN KEY (widget_feature_id) REFERENCES WidgetFeature (widget_feature_id) ON DELETE CASCADE
     )
 CREATE_TABLE_END()
 
     TABLE_CONSTRAINTS(
         FOREIGN KEY (widget_feature_id) REFERENCES WidgetFeature (widget_feature_id) ON DELETE CASCADE
     )
 CREATE_TABLE_END()
 
+CREATE_TABLE(WidgetPrivilege)
+    COLUMN_NOT_NULL(widget_privilege_id, INTEGER,        primary key autoincrement)
+    COLUMN_NOT_NULL(app_id,              INT,)
+    COLUMN_NOT_NULL(name,                VARCHAR(256),)
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+    )
+CREATE_TABLE_END()
+
 CREATE_TABLE(WidgetIcon)
     COLUMN_NOT_NULL(icon_id,        INTEGER,   primary key autoincrement)
     COLUMN_NOT_NULL(app_id,         INT,)
 CREATE_TABLE(WidgetIcon)
     COLUMN_NOT_NULL(icon_id,        INTEGER,   primary key autoincrement)
     COLUMN_NOT_NULL(app_id,         INT,)
@@ -174,6 +182,15 @@ CREATE_TABLE(WidgetLocalizedStartFile)
     )
 CREATE_TABLE_END()
 
     )
 CREATE_TABLE_END()
 
+CREATE_TABLE(WidgetExternalLocations)
+    COLUMN_NOT_NULL(app_id,         INT,)
+    COLUMN_NOT_NULL(path,  TEXT,)
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE,
+        PRIMARY KEY(app_id, path)
+    )
+CREATE_TABLE_END()
+
 CREATE_TABLE(WidgetAccessHost)
     COLUMN_NOT_NULL(app_id,     INT,)
     COLUMN_NOT_NULL(host,       VARCHAR(256),)
 CREATE_TABLE(WidgetAccessHost)
     COLUMN_NOT_NULL(app_id,     INT,)
     COLUMN_NOT_NULL(host,       VARCHAR(256),)
@@ -209,10 +226,26 @@ CREATE_TABLE(WidgetWARPInfo)
     )
 CREATE_TABLE_END()
 
     )
 CREATE_TABLE_END()
 
+CREATE_TABLE(WidgetSecuritySettings)
+    COLUMN_NOT_NULL(app_id,                 INT,)
+    COLUMN_NOT_NULL(security_popup_usage,   INT, DEFAULT 1)
+    COLUMN_NOT_NULL(geolocation_usage,      INT, DEFAULT 1)
+    COLUMN_NOT_NULL(web_notification_usage, INT, DEFAULT 1)
+    COLUMN_NOT_NULL(web_database_usage,     INT, DEFAULT 1)
+    COLUMN_NOT_NULL(file_system_usage,      INT, DEFAULT 1)
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+    )
+CREATE_TABLE_END()
+
 CREATE_TABLE(FeaturesList)
     COLUMN_NOT_NULL(FeatureUUID,            INTEGER,    primary key autoincrement)
     COLUMN_NOT_NULL(FeatureName,            TEXT,       unique)
     COLUMN_NOT_NULL(PluginPropertiesId,     INT,)
 CREATE_TABLE(FeaturesList)
     COLUMN_NOT_NULL(FeatureUUID,            INTEGER,    primary key autoincrement)
     COLUMN_NOT_NULL(FeatureName,            TEXT,       unique)
     COLUMN_NOT_NULL(PluginPropertiesId,     INT,)
+
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE
+    )
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginProperties)
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginProperties)
@@ -220,25 +253,33 @@ CREATE_TABLE(PluginProperties)
     COLUMN_NOT_NULL(InstallationState,      INTEGER,    DEFAULT 0)
     COLUMN_NOT_NULL(PluginLibraryName,      TEXT,       unique)
     COLUMN(PluginLibraryPath,               TEXT,)
     COLUMN_NOT_NULL(InstallationState,      INTEGER,    DEFAULT 0)
     COLUMN_NOT_NULL(PluginLibraryName,      TEXT,       unique)
     COLUMN(PluginLibraryPath,               TEXT,)
-    COLUMN(InstallURI,                      TEXT,)
-    COLUMN(KeyCN,                           TEXT,)
-    COLUMN(RootKeyCN,                       TEXT,)
-    COLUMN(RootKeyFingerprint,              TEXT,)
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginDependencies)
     COLUMN_NOT_NULL(PluginPropertiesId,              INTEGER,    not null)
     COLUMN_NOT_NULL(RequiredPluginPropertiesId,      INTEGER,    not null)
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginDependencies)
     COLUMN_NOT_NULL(PluginPropertiesId,              INTEGER,    not null)
     COLUMN_NOT_NULL(RequiredPluginPropertiesId,      INTEGER,    not null)
+
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE
+    )
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginImplementedObjects)
     COLUMN_NOT_NULL(PluginObject,           TEXT,       unique)
     COLUMN_NOT_NULL(PluginPropertiesId,     INTEGER,    not null)
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginImplementedObjects)
     COLUMN_NOT_NULL(PluginObject,           TEXT,       unique)
     COLUMN_NOT_NULL(PluginPropertiesId,     INTEGER,    not null)
+
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE
+    )
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginRequiredObjects)
     COLUMN_NOT_NULL(PluginPropertiesId,     INTEGER,    not null)
     COLUMN_NOT_NULL(PluginObject,           TEXT,       not null)
 CREATE_TABLE_END()
 
 CREATE_TABLE(PluginRequiredObjects)
     COLUMN_NOT_NULL(PluginPropertiesId,     INTEGER,    not null)
     COLUMN_NOT_NULL(PluginObject,           TEXT,       not null)
+
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (PluginPropertiesId) REFERENCES PluginProperties (PluginPropertiesId) ON DELETE CASCADE
+    )
 CREATE_TABLE_END()
 
 CREATE_TABLE(DeviceCapabilities)
 CREATE_TABLE_END()
 
 CREATE_TABLE(DeviceCapabilities)
@@ -251,44 +292,13 @@ CREATE_TABLE(FeatureDeviceCapProxy)
     COLUMN_NOT_NULL(FeatureUUID,            INT,        not null)
     COLUMN_NOT_NULL(DeviceCapID,            INT,        not null)
 
     COLUMN_NOT_NULL(FeatureUUID,            INT,        not null)
     COLUMN_NOT_NULL(DeviceCapID,            INT,        not null)
 
-    TABLE_CONSTRAINTS(PRIMARY KEY(FeatureUUID,DeviceCapID))
-CREATE_TABLE_END()
-
-CREATE_TABLE(PowderLevels)
-    COLUMN_NOT_NULL(app_id,       INT,       )
-    COLUMN_NOT_NULL(id,           INTEGER,   primary key autoincrement)
-    COLUMN_NOT_NULL(category,     TEXT,      )
-    COLUMN_NOT_NULL(level,        INTEGER,   )
-    TABLE_CONSTRAINTS(
-        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
-    )
-CREATE_TABLE_END()
-
-CREATE_TABLE(PowderLevelContexts)
-    COLUMN_NOT_NULL(levelId,      INTEGER,   )
-    COLUMN_NOT_NULL(context,      TEXT,      )
-
     TABLE_CONSTRAINTS(
     TABLE_CONSTRAINTS(
-        FOREIGN KEY (levelId) REFERENCES PowderLevels (id) ON DELETE CASCADE
+        FOREIGN KEY (FeatureUUID) REFERENCES FeaturesList (FeatureUUID) ON DELETE CASCADE
+        FOREIGN KEY (DeviceCapID) REFERENCES DeviceCapabilities (DeviceCapID) ON DELETE CASCADE
+        PRIMARY KEY(FeatureUUID,DeviceCapID)
     )
 CREATE_TABLE_END()
 
     )
 CREATE_TABLE_END()
 
-CREATE_TABLE(ChildProtectionBlacklist)
-    COLUMN_NOT_NULL(url,        TEXT,       unique)
-CREATE_TABLE_END()
-
-CREATE_TABLE(PowderRules)
-    COLUMN_NOT_NULL(id,           INTEGER,   primary key autoincrement)
-    COLUMN_NOT_NULL(category,     TEXT,      )
-    COLUMN_NOT_NULL(level,        INTEGER,   )
-    COLUMN(context,               TEXT,      )
-    TABLE_CONSTRAINTS(unique(category,context))
-CREATE_TABLE_END()
-
-CREATE_TABLE(DefferedWidgetPackageInstallation)
-    COLUMN_NOT_NULL(path,        TEXT,       unique)
-CREATE_TABLE_END()
-
 CREATE_TABLE(OCSPResponseStorage)
     COLUMN_NOT_NULL(cert_chain,        TEXT,       primary key)
     COLUMN(end_entity_check,           INT,)
 CREATE_TABLE(OCSPResponseStorage)
     COLUMN_NOT_NULL(cert_chain,        TEXT,       primary key)
     COLUMN(end_entity_check,           INT,)
@@ -302,13 +312,7 @@ CREATE_TABLE(CRLResponseStorage)
     COLUMN(next_update_time,           BIGINT,)
 CREATE_TABLE_END()
 
     COLUMN(next_update_time,           BIGINT,)
 CREATE_TABLE_END()
 
-CREATE_TABLE(AutoSaveIdPasswd)
-    COLUMN_NOT_NULL(address,    VARCHAR(256), unique)
-    COLUMN_NOT_NULL(userId,     VARCHAR(128),)
-    COLUMN_NOT_NULL(passwd,     VARCHAR(128),)
-CREATE_TABLE_END()
-
-CREATE_TABLE(SettginsList)
+CREATE_TABLE(SettingsList)
     COLUMN_NOT_NULL(appId,         INT,)
     COLUMN_NOT_NULL(settingName,               TEXT,   )
     COLUMN_NOT_NULL(settingValue,        TEXT,   )
     COLUMN_NOT_NULL(appId,         INT,)
     COLUMN_NOT_NULL(settingName,               TEXT,   )
     COLUMN_NOT_NULL(settingValue,        TEXT,   )
@@ -335,6 +339,16 @@ CREATE_TABLE(WidgetWhiteURIList)
     COLUMN_NOT_NULL(subdomain_access,    INT,        CHECK(subdomain_access between 0 and 1))
 CREATE_TABLE_END()
 
     COLUMN_NOT_NULL(subdomain_access,    INT,        CHECK(subdomain_access between 0 and 1))
 CREATE_TABLE_END()
 
+CREATE_TABLE(EncryptedResourceList)
+    COLUMN_NOT_NULL(app_id,         INT,)
+    COLUMN_NOT_NULL(resource,       TEXT,)
+    COLUMN_NOT_NULL(size,           INT,)
+
+    TABLE_CONSTRAINTS(
+        FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
+    )
+CREATE_TABLE_END()
+
 SQL(
     INSERT INTO WidgetWhiteURIList VALUES("http://samsung.com", 1);
     INSERT INTO WidgetWhiteURIList VALUES("http://orange.fr", 1);
 SQL(
     INSERT INTO WidgetWhiteURIList VALUES("http://samsung.com", 1);
     INSERT INTO WidgetWhiteURIList VALUES("http://orange.fr", 1);
@@ -350,10 +364,37 @@ CREATE_TABLE(UserAgents)
 CREATE_TABLE_END()
 
 SQL(
 CREATE_TABLE_END()
 
 SQL(
+    INSERT INTO UserAgents VALUES("Galaxy S", "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; GT-I9000 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+    INSERT INTO UserAgents VALUES("Galaxy S II", "Mozilla/5.0 (Linux; U; Android 2.3.5; en-gb; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+    INSERT INTO UserAgents VALUES("Galaxy S III", "Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
+    INSERT INTO UserAgents VALUES("SLP Galaxy", "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; GT-I9500 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
     INSERT INTO UserAgents VALUES("Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0");
     INSERT INTO UserAgents VALUES("Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0");
-    INSERT INTO UserAgents VALUES("Chrome 16", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110706 Firefox/5.0");
+    INSERT INTO UserAgents VALUES("Galaxy Nexus", "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; Galaxy Nexus Build/IML74K) AppleWebKit/535.7 (KHTML, like Gecko) Mobile Safari/535.7");
+    INSERT INTO UserAgents VALUES("Samsung", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-I9200/1.0; U; Linux/SLP/2.0; ko-kr) AppleWebKit/534.4 (KHTML, like Gecko) Dolfin/2.0 Mobile");
+    INSERT INTO UserAgents VALUES("Samsung Dolfin", "SAMSUNG-GT-S8500/S8500XXJD2 SHP/VPP/R5 Dolfin/2.0 Nextreaming SMM-MMS/1.2.0 profile/MIDP-2.1 configuration/CLDC-1.1");
+    INSERT INTO UserAgents VALUES("Apple iPhone 3", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16");
+    INSERT INTO UserAgents VALUES("Apple iPhone 4", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5");
+    INSERT INTO UserAgents VALUES("Apple iOS 5", "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3");
+    INSERT INTO UserAgents VALUES("Android 2.3 (Nexus One)", "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Nexus One Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+    INSERT INTO UserAgents VALUES("Opera Mobi", "Opera/9.80 (Windows NT 6.1; U; Edition IBIS; en) Presto/2.6.30 Version/10.63");
+    INSERT INTO UserAgents VALUES("Samsung Bada", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/1.0; U; Bada/1.0; en-us) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WVGA SMM-MMS/1.2.0 OPN-B");
+    INSERT INTO UserAgents VALUES("Orange TV 3.2 iPhone", "Mozilla/5.0 (OrangeTVPlayer4iPhone/iPhone2,1; U; CPU iPhone OS 4_3 like Mac OS X; fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F136 Safari/525.20 OrangeAppliTVHTTPLS/3.2.16");
+    INSERT INTO UserAgents VALUES("Orange TV 3.2 iPad", "Mozilla/5.0 (OrangeTVPlayer4iPhone/iPad1,1; U; CPU iPhone OS 4_3 like Mac OS X; fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F136 Safari/525.20 iPad=SIMENABLED OrangeAppliTVHTTPLS/3.2.16");
+    INSERT INTO UserAgents VALUES("Orange TV 3.3 iOS", "OrangeTVPlayer4iPhone/_iOS_3.3.3_Apple_iPhone2,1_4.1_OrangeAppliTVHTTPLS/3.3.3");
+    INSERT INTO UserAgents VALUES("Chrome Browser for android", "Mozilla/5.0 (Linux; U; Android 4.0.1; ko-kr; Galaxy Nexus Build/ITL41F) AppleWebKit/535.7 (KHTML, like Gecko) CrMo/16.0.912.75 Mobile Safari/535.7");
+    INSERT INTO UserAgents VALUES("MANGO(Nokia 800C)", "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; Nokia; 800C)");
+    INSERT INTO UserAgents VALUES("Orange TV 3.2 Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; fr-fr; GT-I8800) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0 OrangeAppliTV/3.2.0");
+    INSERT INTO UserAgents VALUES("System user agent", "");
+    INSERT INTO UserAgents VALUES("Samsung Bada 2.0", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/1.0; U; Bada/2.0; en-us) AppleWebKit/534.20 (KHTML, like Gecko) Mobile WVGA SMM-MMS/1.2.0 OPN-B Dolfin/3.0");
+    INSERT INTO UserAgents VALUES("Samsung Desktop", "Mozilla/5.0 (U; Linux/SLP/2.0; ko-kr) AppleWebKit/533.1 (KHTML, like Gecko)");
+    INSERT INTO UserAgents VALUES("Firefox 5", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");
+    INSERT INTO UserAgents VALUES("Firefox 5 Fennec(Mobile)", "Mozilla/5.0 (Android; Linux armv7l; rv:5.0) Gecko/20110615 Firefox/5.0 Fennec/5.0");
+    INSERT INTO UserAgents VALUES("Safari 5.0", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7");
+    INSERT INTO UserAgents VALUES("Google Chrome 18.0", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.16 (KHTML, like Gecko) Chrome/18.0.1003.1 Safari/535.16");
+    INSERT INTO UserAgents VALUES("Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
+    INSERT INTO UserAgents VALUES("Galaxy Tab 10.1", "Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; GT-P7100 Build/HRI83) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13");
+    INSERT INTO UserAgents VALUES("iPad 2", "Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5");
 )
 )
-
-SQL(
+    SQL(
     COMMIT;
 )
     COMMIT;
 )
index a4d7da8..1b69679 100644 (file)
@@ -17,7 +17,8 @@
  * @file        wrt_db_sql_generator.h
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @version     1.0
  * @file        wrt_db_sql_generator.h
  * @author      Bartosz Janiak (b.janiak@samsung.com)
  * @version     1.0
- * @brief       Macro definitions for generating the SQL input file from database definition.
+ * @brief       Macro definitions for generating the SQL input file from
+ * database definition.
  */
 
 //Do not include this file directly! It is used only for SQL code generation.
  */
 
 //Do not include this file directly! It is used only for SQL code generation.
diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec
new file mode 100644 (file)
index 0000000..a5a3dd2
--- /dev/null
@@ -0,0 +1,155 @@
+#git:framework/web/wrt-commons wrt-commons 0.2.98
+Name:       wrt-commons
+Summary:    Wrt common library
+Version:    0.2.98
+Release:    1
+Group:      Development/Libraries
+License:    Apache License, Version 2.0
+URL:        N/A
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(ecore)
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(libssl)
+BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(zlib)
+BuildRequires:  pkgconfig(libpcrecpp)
+BuildRequires:  pkgconfig(icu-i18n)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(libiri)
+BuildRequires:  pkgconfig(libidn)
+
+%description
+Wrt common library
+
+%package devel
+Summary:    Wrt common library development headers
+Group:      Development/Libraries
+Requires:   %{name} = %{version}
+
+%description devel
+Wrt common library development headers
+
+%prep
+%setup -q
+
+%define with_tests 0
+%if "%{WITH_TESTS}" == "ON" || "%{WITH_TESTS}" == "Y" || "%{WITH_TESTS}" == "YES" || "%{WITH_TESTS}" == "TRUE" || "%{WITH_TESTS}" == "1"
+    %define with_tests 1
+%endif
+
+%build
+
+%ifarch %{ix86}
+cp build/encryption/libs/libcal.i586.a build/encryption/libs/libcal.a
+%else
+cp build/encryption/libs/libcal.arm.a build/encryption/libs/libcal.a
+%endif
+
+export LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed"
+
+cmake . -DVERSION=%{version} \
+        -DDPL_LOG="OFF"      \
+        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+        %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
+make %{?jobs:-j%jobs}
+
+%install
+mkdir -p %{buildroot}/usr/share/license
+cp %{name} %{buildroot}/usr/share/license/
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%post
+mkdir -p /opt/share/widget/system
+mkdir -p /opt/share/widget/user
+mkdir -p /opt/share/widget/exec
+mkdir -p /opt/share/widget/data/Public
+mkdir -p /usr/lib/wrt-plugins
+
+if [ -z ${2} ]; then
+    echo "This is new install of wrt-commons"
+    echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+    /usr/bin/wrt_commons_reset_db.sh
+else
+    # Find out old and new version of databases
+    WRT_OLD_DB_VERSION=`sqlite3 /opt/dbspace/.wrt.db ".tables" | grep "DB_VERSION_"`
+    WRT_NEW_DB_VERSION=`cat /usr/share/wrt-engine/wrt_db.sql | tr '[:blank:]' '\n' | grep DB_VERSION_`
+    echo "OLD wrt database version ${WRT_OLD_DB_VERSION}"
+    echo "NEW wrt database version ${WRT_NEW_DB_VERSION}"
+
+    if [ ${WRT_OLD_DB_VERSION} -a ${WRT_NEW_DB_VERSION} ]
+    then
+        if [ ${WRT_NEW_DB_VERSION} = ${WRT_OLD_DB_VERSION} ]
+        then
+            echo "Equal database detected so db installation ignored"
+        else
+            echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+            /usr/bin/wrt_commons_reset_db.sh
+        fi
+    else
+        echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+        /usr/bin/wrt_commons_reset_db.sh
+    fi
+fi
+
+mkdir -p /usr/etc/ace
+mkdir -p /usr/apps/org.tizen.policy
+
+# DBUS services fix
+# WARNING: THIS IS TEMPORARY SOLUTION, AS THIS SHOULD NOT BE OUR
+# RESPONSIBILITY!!! WE HAVE TO CONTACT TO DBUS MAINAINERS
+
+if [ -f /var/lib/dbus/machine-id ]; then
+    echo "machine-id exists"
+else
+    if [ -f /usr/var/lib/dbus/machine-id ]; then
+        echo "machine-id exists"
+    else
+        echo "Creating machine-id"
+        mkdir -p /usr/var/lib/dbus/
+        dbus-uuidgen > /usr/var/lib/dbus/machine-id
+        dbus-uuidgen --ensure=/usr/var/lib/dbus/machine-id
+    fi
+    mkdir -p /var/lib/dbus/
+    cp /usr/var/lib/dbus/machine-id /var/lib/dbus/
+fi
+
+# Set Smack label for db files
+chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db
+chsmack -a 'wrt-commons::db_wrt' /opt/dbspace/.wrt.db-journal
+chsmack -a 'wrt-commons::db_wrt_autosave' /opt/dbspace/.wrt_autosave.db
+chsmack -a 'wrt-commons::db_wrt_autosave' /opt/dbspace/.wrt_autosave.db-journal
+chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/dbspace/.wrt_custom_handler.db
+chsmack -a 'wrt-commons::db_wrt_custom_handler' /opt/dbspace/.wrt_custom_handler.db-journal
+
+echo "[WRT] wrt-commons postinst done ..."
+
+%files
+%manifest wrt-commons.manifest
+%{_libdir}/*.so
+%{_libdir}/*.so.*
+%{_datadir}/wrt-engine/*
+%{_datadir}/license/%{name}
+%attr(755,root,root) %{_bindir}/wrt_commons_create_clean_db.sh
+%attr(755,root,root) %{_bindir}/wrt_commons_reset_db.sh
+%if %{with_tests}
+    %attr(755,root,root) %{_bindir}/dpl-tests-*
+    %attr(755,root,root) %{_bindir}/dpl-dbus-test-service
+    %attr(755,root,root) %{_bindir}/wrt-tests-*
+    %attr(755,root,root) %{_bindir}/wrt_dao_tests_prepare_db.sh
+    %{_datadir}/dbus-1/services/org.tizen.DBusTestService.service
+    /opt/share/wrt/wrt-commons/tests/*
+%endif
+
+%files devel
+%{_includedir}/dpl-efl/*
+%{_libdir}/pkgconfig/*.pc
index 8453ccb..40112fe 100644 (file)
@@ -1,38 +1,18 @@
-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT 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        CMakeLists.txt
-# @author      Lukasz Marek (l.marek@samsung.com)
-# @version     1.0
-# @brief
-#
+# Suppress all warnings; TODO: inhibit only specific warnings per target (TURNED OFF)
+#SET(CMAKE_CXX_FLAGS_BACKUP ${CMAKE_CXX_FLAGS})
+#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
 
 
-SET(DPL_TEST_INCLUDE_DIR
-    ${DPL_CORE_INCLUDE_DIR}
-    ${DPL_EVENT_INCLUDE_DIR}
-    ${DPL_DBUS_INCLUDE_DIR}
-    ${DPL_DB_INCLUDE_DIR}
-    ${DPL_RPC_INCLUDE_DIR}
-    ${DPL_SOCKET_INCLUDE_DIR}
-    ${DPL_TEST_ENGINE_INCLUDE_DIR}
-    ${DPL_LOG_INCLUDE_DIR}
+INCLUDE(CMakeUtils.txt)
+
+SET(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+SET(TESTS_COMMON_DIR "${TESTS_DIR}/common")
+
+WRT_ADD_INTERNAL_DEPENDENCIES(
+  ${TARGET_DPL_TEST_ENGINE_EFL}
 )
 
 )
 
-ADD_SUBDIRECTORY(core)
-ADD_SUBDIRECTORY(dbus)
-ADD_SUBDIRECTORY(db)
-ADD_SUBDIRECTORY(event)
-ADD_SUBDIRECTORY(ace)
-ADD_SUBDIRECTORY(vcore)
-ADD_SUBDIRECTORY(localization)
+ADD_SUBDIRECTORY(dao)
+ADD_SUBDIRECTORY(dpl)
+
+# Rollback CXX flags
+#SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_BACKUP})
\ No newline at end of file
diff --git a/tests/CMakeUtils.txt b/tests/CMakeUtils.txt
new file mode 100644 (file)
index 0000000..ea9cfb3
--- /dev/null
@@ -0,0 +1,178 @@
+# @file        CMakeUtils.txt
+# @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+# @author      Pawel Sikorski (p.sikorski@samsung.com)
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Discovers target's INCLUDE_DIRECTORIES and LINK_DIRECTORIES.
+# This is done by retrieving the directory target was built in and
+# fetching appropriate properties of that directory.
+FUNCTION(WRT_INTROSPECT_TARGET PREFIX TARGET_NAME)
+  GET_TARGET_PROPERTY(LOCATION ${TARGET_NAME} LOCATION)
+  IF(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+    MESSAGE(FATAL_ERROR "Target '${TARGET_NAME}' introspection failed")
+  ELSE(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+    STRING(FIND ${LOCATION} "/" LAST_SLASH_POSITION REVERSE)
+    STRING(SUBSTRING ${LOCATION} 0 ${LAST_SLASH_POSITION} LOCATION)
+
+    GET_DIRECTORY_PROPERTY(INCLUDE_DIRS DIRECTORY ${LOCATION} INCLUDE_DIRECTORIES)
+    SET("${PREFIX}_INCLUDE_DIRS" ${INCLUDE_DIRS} PARENT_SCOPE)
+
+    GET_DIRECTORY_PROPERTY(LIBRARY_DIRS DIRECTORY ${LOCATION} LINK_DIRECTORIES)
+    SET("${PREFIX}_LIBRARY_DIRS" ${LIBRARY_DIRS} PARENT_SCOPE)
+  ENDIF(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+ENDFUNCTION(WRT_INTROSPECT_TARGET)
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to tests.
+# Anything added with this functions is used by all targets that are built with
+# WRT_TEST_BUILD function.
+
+#
+# Appends directories to global property TESTS_INCLUDE_DIRS which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command INCLUDE_DIRECTORIES() (for all targets).
+FUNCTION(WRT_INCLUDE_DIRECTORIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_INCLUDE_DIRS ${ARGV})
+ENDFUNCTION(WRT_INCLUDE_DIRECTORIES)
+
+#
+# Appends directories to global property TESTS_LIBRARY_DIRS which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command LINK_DIRECTORIES() (for all targets).
+FUNCTION(WRT_LINK_DIRECTORIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARY_DIRS ${ARGV})
+ENDFUNCTION(WRT_LINK_DIRECTORIES)
+
+#
+# Appends directories to global property TESTS_LIBRARIES which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command TARGET_LINK_LIBRARIES() (for all targets).
+FUNCTION(WRT_TARGET_LINK_LIBRARIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARIES ${ARGV})
+ENDFUNCTION(WRT_TARGET_LINK_LIBRARIES)
+
+#
+# Convenience method that fills TESTS_INCLUDE_DIRS, TESTS_LIBRARY_DIRS
+# and TESTS_LIBRARIES with values discovered from introspecting supplied
+# targets.
+# Function takes arbitrary number of targets.
+FUNCTION(WRT_ADD_INTERNAL_DEPENDENCIES)
+  FOREACH(DEPENDENCY ${ARGV})
+    WRT_INTROSPECT_TARGET(prefix ${DEPENDENCY})
+    WRT_INCLUDE_DIRECTORIES(${prefix_INCLUDE_DIRS})
+    WRT_LINK_DIRECTORIES(${prefix_LIBRARY_DIRS})
+    WRT_TARGET_LINK_LIBRARIES(${DEPENDENCY})
+  ENDFOREACH(DEPENDENCY)
+ENDFUNCTION(WRT_ADD_INTERNAL_DEPENDENCIES)
+
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to specific
+# tests. Properties names are based on the test target name.
+# Anything added with this functions is used only by the specified target that
+# is built with WRT_TEST_BUILD function.
+
+#
+# Appends directories to global property ${TARGET_NAME}_INCLUDE_DIRS
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command INCLUDE_DIRECTORIES() (for specified target).
+FUNCTION(WRT_TEST_INCLUDE_DIRECTORIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_INCLUDE_DIRS ${ARGN})
+ENDFUNCTION(WRT_TEST_INCLUDE_DIRECTORIES)
+
+#
+# Appends directories to global property ${TARGET_NAME}_LIBRARY_DIRS
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command LINK_DIRECTORIES() (for specified target).
+FUNCTION(WRT_TEST_LINK_DIRECTORIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_LIBRARY_DIRS ${ARGN})
+ENDFUNCTION(WRT_TEST_LINK_DIRECTORIES)
+
+#
+# Appends directories to global property ${TARGET_NAME}_LIBRARIES
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command TARGET_LINK_LIBRARIES() (for specified target).
+FUNCTION(WRT_TEST_TARGET_LINK_LIBRARIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_LIBRARIES ${ARGN})
+ENDFUNCTION(WRT_TEST_TARGET_LINK_LIBRARIES)
+
+#
+# Convenience method that fills ${TARGET_NAME}_INCLUDE_DIRS,
+# ${TARGET_NAME}_LIBRARY_DIRS and ${TARGET_NAME}_LIBRARIES with
+# values discovered from introspecting supplied targets.
+# Function takes arbitrary number of targets.
+FUNCTION(WRT_TEST_ADD_INTERNAL_DEPENDENCIES TARGET_NAME)
+  FOREACH(DEPENDENCY ${ARGN})
+    WRT_INTROSPECT_TARGET(prefix ${DEPENDENCY})
+    WRT_TEST_INCLUDE_DIRECTORIES(${TARGET_NAME} ${prefix_INCLUDE_DIRS})
+    WRT_TEST_LINK_DIRECTORIES(${TARGET_NAME} ${prefix_LIBRARY_DIRS})
+    WRT_TEST_TARGET_LINK_LIBRARIES(${TARGET_NAME} ${DEPENDENCY})
+  ENDFOREACH(DEPENDENCY)
+ENDFUNCTION(WRT_TEST_ADD_INTERNAL_DEPENDENCIES)
+
+# Functions used to build test targets (proper sources, includes, libs are
+# added automatically)
+FUNCTION(WRT_TEST_BUILD TARGET_NAME)
+    SET(SOURCES "${ARGN}")
+    ADD_EXECUTABLE("${TARGET_NAME}" ${SOURCES})
+
+    # get include dirs global property
+    GET_PROPERTY(INCLUDE_DIRS GLOBAL PROPERTY TESTS_INCLUDE_DIRS)
+    GET_PROPERTY(TEST_INCLUDE_DIRS GLOBAL PROPERTY ${TARGET_NAME}_INCLUDE_DIRS)
+    INCLUDE_DIRECTORIES(
+        ${INCLUDE_DIRS}
+        ${TEST_INCLUDE_DIRS}
+    )
+
+    # get library dirs global property
+    GET_PROPERTY(LIBRARY_DIRS GLOBAL PROPERTY TESTS_LIBRARY_DIRS)
+    GET_PROPERTY(TEST_LIBRARY_DIRS GLOBAL PROPERTY ${TARGET_NAME}_LIBRARY_DIRS)
+    LINK_DIRECTORIES(
+        ${LIBRARY_DIRS}
+        ${TEST_LIBRARY_DIRS}
+    )
+
+    # get link libraries global property
+    GET_PROPERTY(LINK_LIBRARIES GLOBAL PROPERTY TESTS_LIBRARIES)
+    GET_PROPERTY(TEST_LIBRARIES GLOBAL PROPERTY ${TARGET_NAME}_LIBRARIES)
+    TARGET_LINK_LIBRARIES("${TARGET_NAME}"
+        ${LINK_LIBRARIES}
+        ${TEST_LIBRARIES}
+    )
+ENDFUNCTION(WRT_TEST_BUILD)
+
+FUNCTION(WRT_TEST_INSTALL)
+    SET_TARGET_PROPERTIES(${ARGV} PROPERTIES
+        BUILD_WITH_INSTALL_RPATH ON
+        INSTALL_RPATH_USE_LINK_PATH ON
+    )
+    INSTALL(TARGETS ${ARGV}
+        DESTINATION bin
+        PERMISSIONS OWNER_READ
+                    OWNER_WRITE
+                    OWNER_EXECUTE
+                    GROUP_READ
+                    GROUP_EXECUTE
+                    WORLD_READ
+                    WORLD_EXECUTE
+    )
+ENDFUNCTION(WRT_TEST_INSTALL)
+
+# Takes arbitrary number of arguments and concatenates them using ':' character.
+# Rationale:
+#   CMake list when converted to a string is joined with ';' character. However,
+#   GCC takes strings with multiple elements separated with ':' (e.g. list of
+#   paths). Used typically when generating DB schemas with ORM mechanism.
+FUNCTION(WRT_CONVERT_TO_GCC_LIST OUTPUT_VARIABLE)
+    FOREACH(ITEM ${ARGN})
+        LIST(APPEND ITEMS ${ITEM})
+    ENDFOREACH(ITEM)
+    STRING(REPLACE ";" ":" OUTPUT "${ITEMS}")
+    SET("${OUTPUT_VARIABLE}" "${OUTPUT}" PARENT_SCOPE)
+ENDFUNCTION(WRT_CONVERT_TO_GCC_LIST)
diff --git a/tests/common/include/glib_interface.h b/tests/common/include/glib_interface.h
new file mode 100644 (file)
index 0000000..5629f99
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        glib_interface.h
+ * @author      Iwanek Tomasz (t.iwanek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the definitions of loop controlling utilities
+ */
+
+#ifndef GLIB_INTERFACE_H
+#define GLIB_INTERFACE_H
+
+//this header wraps glib headers which generates warnings
+
+#pragma GCC system_header
+#include <glib.h>
+#include <glib-object.h>
+
+#endif // GLIB_INTERFACE_H
diff --git a/tests/common/include/loop_control.h b/tests/common/include/loop_control.h
new file mode 100644 (file)
index 0000000..b58fb5c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        loop_control.cpp
+ * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
+ * @version     1.0
+ * @brief       This file is the definitions of loop controlling utilities
+ */
+
+#ifndef LOOP_CONTROL_H_
+#define LOOP_CONTROL_H_
+
+namespace LoopControl {
+void init_loop(int argc, char *argv[]);
+void wait_for_wrt_init();
+void finish_wait_for_wrt_init();
+void quit_loop();
+
+void wrt_start_loop();
+void wrt_end_loop();
+
+void *abstract_window();
+}
+
+#endif /* LOOP_CONTROL_H_ */
diff --git a/tests/common/src/loop_control.cpp b/tests/common/src/loop_control.cpp
new file mode 100644 (file)
index 0000000..4855288
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        loop_control.cpp
+ * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
+ * @version     1.0
+ * @brief       This is implementation of EFL version of loop control
+ */
+
+#include <glib_interface.h>
+#include <loop_control.h>
+#include <dpl/log/log.h>
+
+#include <dpl/framework_efl.h>
+
+namespace LoopControl {
+void init_loop(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+    g_type_init();
+    g_thread_init(NULL);
+
+    LogInfo("Starting");
+    elm_init(argc, argv);
+}
+
+void wait_for_wrt_init()
+{
+    ecore_main_loop_begin();
+}
+
+void finish_wait_for_wrt_init()
+{
+    ecore_main_loop_quit();
+}
+
+void quit_loop()
+{
+    elm_shutdown();
+}
+
+void wrt_start_loop()
+{
+    ecore_main_loop_begin();
+}
+
+void wrt_end_loop()
+{
+    ecore_main_loop_quit();
+}
+
+void *abstract_window()
+{
+    return elm_win_add(NULL, "hello", ELM_WIN_BASIC);
+}
+} //end of LoopControl namespace
diff --git a/tests/dao/CMakeLists.txt b/tests/dao/CMakeLists.txt
new file mode 100644 (file)
index 0000000..350431c
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Pawel Sikorski (p.sikorski@samsung.com)
+# @version     1.0
+# @brief
+#
+
+# common part
+FILE(GLOB DAO_TESTS_SOURCES "${PROJECT_SOURCE_DIR}/tests/dao/*DAO.cpp")
+
+# target wrt-tests-dao
+SET(TARGET_DAO_TEST "wrt-tests-dao")
+WRT_TEST_INCLUDE_DIRECTORIES(${TARGET_DAO_TEST} ${PROJECT_SOURCE_DIR}/modules/support/)
+WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_DAO_TEST} ${TARGET_WRT_DAO_RW_LIB} ${TARGET_CUSTOM_HANDLER_DAO_RW_LIB})
+WRT_TEST_BUILD(${TARGET_DAO_TEST} ${DAO_TESTS_SOURCES} tests_dao.cpp)
+WRT_TEST_INSTALL(${TARGET_DAO_TEST})
+
+
+# common installed files
+INSTALL(PROGRAMS
+    ${PROJECT_SOURCE_DIR}/tests/dao/wrt_dao_tests_prepare_db.sh
+    DESTINATION bin
+    )
diff --git a/tests/dao/README b/tests/dao/README
new file mode 100644 (file)
index 0000000..6c60a17
--- /dev/null
@@ -0,0 +1,11 @@
+Wrt DAO
+System tests. Tests database access layer: widgets information database, global configuration, plugins.
+Binary file: wrt-tests-dao. Uses our test framework. Allows to use different types of output. Text output shows results on console - green passed.
+To run:
+1. Install wrt-extra on target
+2. Run wrt-tests-dao --output=text
+
+Automatic: YES
+Included in Daily Build: YES (http://build01.sprc.samsung.pl/browse/LINUXNGWAP-INT)
+Included in Gerrit Builds: YES (http://build01.sprc.samsung.pl/browse/LINUXNGWAP-GERRIT)
+Number of test cases: 45
\ No newline at end of file
diff --git a/tests/dao/TestCases_CustomHandlerDAO.cpp b/tests/dao/TestCases_CustomHandlerDAO.cpp
new file mode 100644 (file)
index 0000000..97a4c9a
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   TestCases_CustomHandlerDAO.cpp
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for custom handler dao class.
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
+#include <wrt-commons/custom-handler-dao-ro/common_dao_types.h>
+
+using namespace CustomHandlerDB;
+
+RUNNER_TEST_GROUP_INIT(DAO)
+
+namespace {
+const DPL::String P_TARGET(L"p_target");
+const DPL::String P_BASE_URL(L"p_base_url");
+const DPL::String P_URL(L"p_url");
+const DPL::String P_TITLE(L"p_title");
+
+const DPL::String C_TARGET(L"c_target");
+const DPL::String C_BASE_URL(L"c_base_url");
+const DPL::String C_URL(L"c_url");
+const DPL::String C_TITLE(L"c_title");
+
+void checkHandlersExistence(CustomHandlerDAOReadOnly& dao,
+                            bool protocol,
+                            bool content)
+{
+    CustomHandlerDB::CustomHandlerPtr handler;
+    handler = dao.getProtocolHandler(P_TARGET, P_URL);
+    RUNNER_ASSERT_MSG((!!handler) == protocol, "Protocol handler check");
+    handler = dao.getContentHandler(C_TARGET, C_URL);
+    RUNNER_ASSERT_MSG((!!handler) == content, "Content handler check");
+}
+} // namespace
+
+RUNNER_TEST(custom_handler_empty_db_read)
+{
+    CustomHandlerDAOReadOnly dao(DPL::String(L"test"));
+}
+
+RUNNER_TEST(custom_handlers)
+{
+    CustomHandlerDAOReadOnly dao_ro(L"test");
+    CustomHandlerDAO dao_rw(L"test");
+
+    CustomHandlerDB::CustomHandlerPtr handler;
+    CustomHandlerDB::CustomHandler p_handler;
+    p_handler.target = P_TARGET;
+    p_handler.base_url = P_BASE_URL;
+    p_handler.url = P_URL;
+    p_handler.title = P_TITLE;
+    p_handler.user_decision = Agreed;
+
+    // initial check
+    checkHandlersExistence(dao_ro, false, false);
+
+    // Protocol handler registration
+    dao_rw.registerProtocolHandler(p_handler);
+    checkHandlersExistence(dao_ro, true, false);
+
+    handler = dao_ro.getProtocolHandler(P_TARGET, P_URL);
+    RUNNER_ASSERT(handler);
+    RUNNER_ASSERT(handler->target == P_TARGET);
+    RUNNER_ASSERT(handler->base_url == P_BASE_URL);
+    RUNNER_ASSERT(handler->url == P_URL);
+    RUNNER_ASSERT(handler->title == P_TITLE);
+    RUNNER_ASSERT(handler->user_decision == Agreed);
+
+    // Content handler registration
+    CustomHandlerDB::CustomHandler c_handler;
+    c_handler.target = C_TARGET;
+    c_handler.base_url = C_BASE_URL;
+    c_handler.url = C_URL;
+    c_handler.title = C_TITLE;
+    c_handler.user_decision = DeclinedPermanently;
+
+    dao_rw.registerContentHandler(c_handler);
+    checkHandlersExistence(dao_ro, true, true);
+    handler = dao_ro.getContentHandler(C_TARGET, C_URL);
+
+    RUNNER_ASSERT(handler);
+    RUNNER_ASSERT(handler->target == C_TARGET);
+    RUNNER_ASSERT(handler->base_url == C_BASE_URL);
+    RUNNER_ASSERT(handler->url == C_URL);
+    RUNNER_ASSERT(handler->title == C_TITLE);
+    RUNNER_ASSERT(handler->user_decision == DeclinedPermanently);
+
+    // Handler unregistration
+    dao_rw.unregisterProtocolHandler(P_TARGET, P_URL);
+    checkHandlersExistence(dao_ro, false, true);
+
+    // Nonexistent unregistration
+    dao_rw.unregisterContentHandler(L"blah", L"blah");
+    checkHandlersExistence(dao_ro, false, true);
+
+    // Cleanup
+    dao_rw.unregisterContentHandler(C_TARGET, C_URL);
+    checkHandlersExistence(dao_ro, false, false);
+}
diff --git a/tests/dao/TestCases_FeatureDAO.cpp b/tests/dao/TestCases_FeatureDAO.cpp
new file mode 100644 (file)
index 0000000..4f03a5a
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   TestCases_FeatureDAO.cpp
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for feature dao class.
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-rw/feature_dao.h>
+#include <dpl/wrt-dao-rw/plugin_dao.h>
+#include <dpl/wrt-dao-ro/wrt_db_types.h>
+
+using namespace WrtDB;
+
+#define RUNNER_ASSERT_WHAT_EQUALS(in, test)                   \
+    { std::string tmp(in);                                     \
+      RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
+
+RUNNER_TEST_GROUP_INIT(DAO)
+
+/*
+ * Name: feature_dao_test_register_features
+ * Description: Checks if plugin registeration performs features registration
+ * Expected: registrartion should succeed
+ */
+RUNNER_TEST(feature_dao_test_register_features)
+{
+    PluginHandle plHandle;
+    {
+        std::string libraryPath("nfp1 lib_path");
+        std::string libraryName("nfp1");
+
+        PluginMetafileData pluginData;
+        pluginData.m_libraryName = libraryName;
+
+        plHandle = PluginDAO::registerPlugin(pluginData, libraryPath);
+        RUNNER_ASSERT(PluginDAO::isPluginInstalled(libraryName) == true);
+
+        FeatureHandleList old = FeatureDAOReadOnly::GetHandleList();
+        PluginMetafileData::Feature f;
+        f.m_name = std::string("new_f1");
+
+        FeatureHandle handle = FeatureDAO::RegisterFeature(f, plHandle);
+        RUNNER_ASSERT_MSG(handle != -1, "Already registered");
+        RUNNER_ASSERT_MSG(old.size() < FeatureDAOReadOnly::GetHandleList().size(),
+                          "New feature should be saved");
+
+        FeatureDAOReadOnly dao(handle);
+
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetName(), "new_f1");
+        plHandle = dao.GetPluginHandle();
+    }
+
+    {
+        FeatureHandleList old = FeatureDAOReadOnly::GetHandleList();
+
+        PluginMetafileData::Feature f;
+        f.m_name = std::string("new_f2");
+
+        FeatureHandle handle = FeatureDAO::RegisterFeature(f, plHandle);
+        RUNNER_ASSERT_MSG(handle != -1, "Already registered");
+        RUNNER_ASSERT_MSG(old.size() < FeatureDAOReadOnly::GetHandleList().size(),
+                          "New feature should be saved");
+
+        FeatureDAOReadOnly dao(handle);
+
+        RUNNER_ASSERT_MSG(plHandle == dao.GetPluginHandle(),
+                          "New plugin registered (should be old used)");
+    }
+}
+
+/*
+ * Name: feature_dao_test_get_feature_properties
+ * Description: Checks properties of inserted features
+ * Expected: properties of features should match values inserted to database
+ * directly
+ */
+RUNNER_TEST(feature_dao_test_get_feature_properties)
+{
+    {
+        FeatureDAOReadOnly dao("feature1");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetName(), "feature1");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetLibraryName(), "plugin1");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetLibraryPath(), "");
+    }
+
+    {
+        FeatureDAOReadOnly dao("feature2");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetName(), "feature2");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetLibraryName(), "p4");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetLibraryPath(), "path_to_p4");
+    }
+
+    {
+        FeatureDAOReadOnly dao("feature3");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetName(), "feature3");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetLibraryName(), "p4");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetLibraryPath(), "path_to_p4");
+    }
+}
+
+/*
+ * Name: feature_dao_test_feature_constructor_name
+ * Description: -
+ * Expected: -
+ *
+ * TODO: test
+ */
+RUNNER_TEST(feature_dao_test_feature_constructor_name)
+{
+    std::list<const char *> preinstalled;
+    preinstalled.push_back("feature1");
+    preinstalled.push_back("feature2");
+    preinstalled.push_back("feature3");
+    preinstalled.push_back("feature4");
+
+    FOREACH(it, preinstalled)
+    {
+        FeatureDAOReadOnly dao(*it);
+        RUNNER_ASSERT_WHAT_EQUALS(dao.GetName(), *it);
+    }
+
+    //TODO check exception that may occur (feature does not exist)
+}
+
+/*
+ * Name: feature_dao_test_feature_handle_list
+ * Description: Checks if list of installed features is returend correctly
+ * Expected: list size should be at last equal number of preinserted features
+ */
+RUNNER_TEST(feature_dao_test_feature_handle_list)
+{
+    FeatureHandleList handles = FeatureDAOReadOnly::GetHandleList();
+    RUNNER_ASSERT(handles.size() >= 4);
+}
+
+/*
+ * Name: feature_dao_test_is_feature_installed
+ * Description: Checks if installed features are showed correctly.
+ * Expected: correct installed features should be present
+ */
+RUNNER_TEST(feature_dao_test_is_feature_installed)
+{
+    //installed
+    {
+        std::list<const char *> preinstalled;
+        preinstalled.push_back("feature1");
+        preinstalled.push_back("feature2");
+        preinstalled.push_back("feature3");
+        preinstalled.push_back("feature4");
+
+        FOREACH(it, preinstalled)
+        RUNNER_ASSERT(FeatureDAOReadOnly::isFeatureInstalled(*it));
+    }
+
+    //not installed
+    {
+        RUNNER_ASSERT(FeatureDAOReadOnly::isFeatureInstalled(
+                          "not_installed1") == false);
+        RUNNER_ASSERT(FeatureDAOReadOnly::isFeatureInstalled(
+                          "plugin1") == false);
+        RUNNER_ASSERT(FeatureDAOReadOnly::isFeatureInstalled("") == false);
+        RUNNER_ASSERT(FeatureDAOReadOnly::isFeatureInstalled("ff") == false);
+    }
+}
+
+/*
+ * Name: feature_dao_test_get_device_capab
+ * Description: -
+ * Expected: -
+ *
+ * TODO: fix test
+ */
+RUNNER_TEST(feature_dao_test_get_device_capab)
+{
+#if 0
+    //TODO do more tests
+
+    { //check deviceCaps
+        Feature f;
+        f.setName("new_dev_f4");
+        f.setLibraryName("new_dev_f4 lib_name");
+
+        FeatureDAOReadOnly::DeviceCapabilitiesList devList;
+        devList.insert("new_dev_f4 devcap1");
+        devList.insert("new_dev_f4 devcap2");
+
+        FOREACH(it, devList)
+        f.addDeviceCapability(*it);
+
+        FeatureHandle handle = FeatureDAO::RegisterFeature(f, "new_dev_f4 path");
+
+        FeatureDAOReadOnly dao(handle);
+
+        FeatureDAOReadOnly::DeviceCapabilitiesList gotList =
+            dao.GetDeviceCapabilities();
+        RUNNER_ASSERT_MSG(gotList.size() == devList.size(),
+                          "deviceCaps wrong");
+    }
+#endif
+}
+
+/*
+ * Name: feature_dao_test_is_device_capab_installed
+ * Description: Checks if FeatureDAOReadOnly::isDeviceCapabilityInstalled works
+ * correctly.
+ * Expected: correct capabilities should be present
+ */
+RUNNER_TEST(feature_dao_test_is_device_capab_installed)
+{
+    //installed
+    std::list<const char *> preinstalled;
+    preinstalled.push_back("devicecap1");
+    preinstalled.push_back("devicecap2");
+    preinstalled.push_back("devicecap3");
+    preinstalled.push_back("devicecap4");
+
+    FOREACH(it, preinstalled)
+    RUNNER_ASSERT(FeatureDAOReadOnly::isDeviceCapabilityInstalled(*it));
+
+    //not installed
+    std::list<const char *> notinstalled;
+    notinstalled.push_back("notinstalled1");
+    notinstalled.push_back("plugin1");
+    notinstalled.push_back("");
+    notinstalled.push_back("ff");
+
+    FOREACH(it, notinstalled)
+    RUNNER_ASSERT(!FeatureDAOReadOnly::isDeviceCapabilityInstalled(*it));
+}
+
+#undef RUNNER_ASSERT_WHAT_EQUALS
diff --git a/tests/dao/TestCases_GlobalDAO.cpp b/tests/dao/TestCases_GlobalDAO.cpp
new file mode 100644 (file)
index 0000000..65cb9e0
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   TestCases_GlobalDAO.cpp
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for global dao class.
+ */
+
+#include <list>
+#include <vector>
+#include <set>
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/exception.h>
+#include <dpl/string.h>
+#include <dpl/wrt-dao-rw/global_dao.h>
+#include <dpl/wrt-dao-ro/wrt_db_types.h>
+
+using namespace WrtDB;
+
+namespace {
+const DPL::String widgetPackage5(L"widgetpackage5");
+} // namespace
+
+RUNNER_TEST_GROUP_INIT(DAO)
+
+/*
+ * Name: global_dao_developer_mode
+ * Description: tests if developer mode is correctly set and get
+ * Expected: received developer shoudl match the one was set
+ */
+RUNNER_TEST(global_dao_developer_mode)
+{
+    bool prev_mode = GlobalDAO::GetDeveloperMode();
+    GlobalDAO::SetDeveloperMode(false);
+    RUNNER_ASSERT_MSG(!GlobalDAO::GetDeveloperMode(), "set false failed");
+
+    GlobalDAO::SetDeveloperMode(true);
+    RUNNER_ASSERT_MSG(GlobalDAO::GetDeveloperMode(), "set true failed");
+    GlobalDAO::SetDeveloperMode(prev_mode);
+}
+
+/*
+ * Name: home_network_data_usage
+ * Description: tests if HomeNetworkDataUsage is correctly set and get
+ * Expected: received developer shoudl match the one was set
+ */
+RUNNER_TEST(home_network_data_usage)
+{
+    GlobalDAO::NetworkAccessMode original =
+        GlobalDAO::GetHomeNetworkDataUsage();
+
+    GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
+    RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
+                      GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
+
+    GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::ALWAYS_ASK);
+    RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
+                      GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
+
+    GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NEVER_CONNECT);
+    RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
+                      GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
+
+    GlobalDAO::SetHomeNetworkDataUsage(original);
+    RUNNER_ASSERT_MSG(original == GlobalDAO::GetHomeNetworkDataUsage(),
+                      "Value not updated");
+}
+
+/*
+ * Name: roaming_data_usage
+ * Description: tests if RoamingDataUsage is correctly set and get
+ * Expected: received developer shoudl match the one was set
+ */
+RUNNER_TEST(roaming_data_usage)
+{
+    GlobalDAO::NetworkAccessMode original =
+        GlobalDAO::GetRoamingDataUsage();
+
+    GlobalDAO::SetRoamingDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
+    RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
+                      GlobalDAO::GetRoamingDataUsage(), "Value not updated");
+
+    GlobalDAO::SetRoamingDataUsage(GlobalDAO::ALWAYS_ASK);
+    RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
+                      GlobalDAO::GetRoamingDataUsage(), "Value not updated");
+
+    GlobalDAO::SetRoamingDataUsage(GlobalDAO::NEVER_CONNECT);
+    RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
+                      GlobalDAO::GetRoamingDataUsage(), "Value not updated");
+
+    GlobalDAO::SetRoamingDataUsage(original);
+    RUNNER_ASSERT_MSG(original == GlobalDAO::GetRoamingDataUsage(),
+                      "Value not updated");
+}
diff --git a/tests/dao/TestCases_PluginDAO.cpp b/tests/dao/TestCases_PluginDAO.cpp
new file mode 100644 (file)
index 0000000..6c73a7b
--- /dev/null
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   TestCases_PluginDAO.cpp
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for feature dao class.
+ */
+
+#include <list>
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/exception.h>
+#include <dpl/wrt-dao-rw/plugin_dao.h>
+//#include <plugin_install/plugin_objects.h>
+#include <dpl/wrt-dao-ro/wrt_db_types.h>
+#include <dpl/log/log.h>
+
+using namespace WrtDB;
+
+#define RUNNER_ASSERT_WHAT_EQUALS(in, test)                   \
+    { std::string tmp(in);                                     \
+      RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
+
+RUNNER_TEST_GROUP_INIT(DAO)
+
+/*
+ * Name: plugin_dao_test_register_plugins
+ * Description: registers new plugin and check if it was correctly registered
+ * Expected: plugin should be correctly registered
+ */
+RUNNER_TEST(plugin_dao_test_register_plugins)
+{
+    {
+        std::string libraryPath("np1 lib_path");
+        std::string libraryName("np1");
+
+        PluginMetafileData pluginData;
+        pluginData.m_libraryName = libraryName;
+
+        PluginHandle handle = PluginDAO::registerPlugin(pluginData, libraryPath);
+        PluginDAO::setPluginInstallationStatus(
+            handle,
+            PluginDAO::
+                INSTALLATION_COMPLETED);
+        RUNNER_ASSERT(PluginDAO::isPluginInstalled(libraryName) == true);
+
+        PluginDAO dao(handle);
+        std::string tmp;
+        tmp = dao.getLibraryPath(); //do for each
+        RUNNER_ASSERT_MSG(tmp == libraryPath, "Equals: " + tmp);
+    }
+
+    {
+        std::string libraryName("np2");
+
+        PluginMetafileData pluginData;
+        pluginData.m_libraryName = libraryName;
+
+        PluginHandle handle = PluginDAO::registerPlugin(pluginData, "");
+        PluginDAO::setPluginInstallationStatus(
+            handle,
+            PluginDAO::
+                INSTALLATION_COMPLETED);
+        RUNNER_ASSERT(PluginDAO::isPluginInstalled(libraryName) == true);
+
+        PluginDAO dao(handle);
+        RUNNER_ASSERT(dao.getLibraryPath() == "");
+    }
+}
+
+/*
+ * Name: plugin_dao_test_register_plugin_implemented_object
+ * Description: registers new PluginImplementedObject
+ * and check if it was correctly registered
+ * Expected: plugin dao shoudld be upodated with PluginImplementedObject
+ */
+RUNNER_TEST(plugin_dao_test_register_plugin_implemented_object)
+{
+    {
+        std::string libraryPath("np3 lib_path");
+        std::string libraryName("np3");
+
+        PluginMetafileData pluginData;
+        pluginData.m_libraryName = libraryName;
+
+        PluginHandle handle =
+            PluginDAO::registerPlugin(pluginData, libraryPath);
+        RUNNER_ASSERT(PluginDAO::isPluginInstalled(libraryName) == true);
+
+        std::string object1("object1");
+        std::string object2("object2");
+        PluginDAO::registerPluginImplementedObject(object1, handle);
+        PluginDAO::registerPluginImplementedObject(object2, handle);
+
+        PluginHandle retHandle1 =
+            PluginDAO::getPluginHandleForImplementedObject(object1);
+        PluginHandle retHandle2 =
+            PluginDAO::getPluginHandleForImplementedObject(object1);
+        RUNNER_ASSERT(retHandle1 == handle);
+        RUNNER_ASSERT(retHandle2 == handle);
+    }
+}
+
+/*
+ * Name: plugin_dao_test_register_plugin_implemented_object
+ * Description: registers dependecies for plugins and checks if they were saved
+ * Expected: registered dependecies should be returned from database
+ */
+RUNNER_TEST(plugin_dao_test_register_library_dependencies)
+{
+    {
+        std::string libraryPath("np4 lib_path");
+        std::string libraryName("np4");
+
+        PluginMetafileData pluginData;
+        pluginData.m_libraryName = libraryName;
+
+        PluginHandle handle =
+            PluginDAO::registerPlugin(pluginData, libraryPath);
+        PluginDAO::setPluginInstallationStatus(
+            handle,
+            PluginDAO::
+                INSTALLATION_COMPLETED);
+        RUNNER_ASSERT(PluginDAO::isPluginInstalled(libraryName) == true);
+
+        PluginHandle depHandles[] = { 117, 119 };
+
+        PluginHandleSetPtr dependencies(new PluginHandleSet);
+        dependencies->insert(depHandles[1]);
+        dependencies->insert(depHandles[2]);
+
+        PluginDAO::registerPluginLibrariesDependencies(handle, dependencies);
+
+        PluginDAO dao(handle);
+        PluginHandleSetPtr retDependencies;
+        retDependencies = dao.getLibraryDependencies();
+
+        RUNNER_ASSERT(
+            retDependencies->size() == sizeof(depHandles) /
+            sizeof(depHandles[0]));
+        RUNNER_ASSERT(
+            retDependencies->find(depHandles[1]) != retDependencies->end());
+        RUNNER_ASSERT(
+            retDependencies->find(depHandles[2]) != retDependencies->end());
+    }
+}
+
+/*
+ * Name: plugin_dao_test_register_required_object
+ * Description: registers required plugin objects for plugins and checks if they
+ * were saved
+ * Expected: registered required plugin objects should be returned from database
+ */
+RUNNER_TEST(plugin_dao_test_register_required_object)
+{
+    {
+        std::string libraryPath("np5 lib_path");
+        std::string libraryName("np5");
+
+        PluginMetafileData pluginData;
+        pluginData.m_libraryName = libraryName;
+
+        PluginHandle handle =
+            PluginDAO::registerPlugin(pluginData, libraryPath);
+        PluginDAO::setPluginInstallationStatus(
+            handle,
+            PluginDAO::
+                INSTALLATION_COMPLETED);
+        RUNNER_ASSERT(PluginDAO::isPluginInstalled(libraryName) == true);
+
+        const size_t numObjects = 2;
+        std::string objectReq[numObjects];
+        objectReq[0] = std::string("object1.req");
+        objectReq[1] = std::string("object2.req");
+        PluginDAO::registerPluginRequiredObject(objectReq[0], handle);
+        PluginDAO::registerPluginRequiredObject(objectReq[1], handle);
+
+        WrtDB::PluginObjectsDAO::ObjectsPtr objects =
+            PluginDAO::getRequiredObjectsForPluginHandle(handle);
+
+        RUNNER_ASSERT(objects->size() == numObjects
+                      && objects->find(objectReq[0]) != objects->end()
+                      && objects->find(objectReq[1]) != objects->end());
+    }
+}
+
+/*
+ * Name: plugin_dao_test_is_library_installed
+ * Description: tests if plugin isntallation/registrartion works
+ * Expected: only registered plugins should be reported as installed
+ */
+RUNNER_TEST(plugin_dao_test_is_library_installed)
+{
+    {
+        //exist
+        std::list<const char *> preinstalled;
+        preinstalled.push_back("plugin1");
+        preinstalled.push_back("plugin2");
+        preinstalled.push_back("plugin3");
+        preinstalled.push_back("p4");
+        preinstalled.push_back("p5");
+
+        FOREACH(it, preinstalled)
+        RUNNER_ASSERT_MSG(PluginDAO::isPluginInstalled(*it),
+                          std::string("Not found: ") + *it);
+    }
+
+    {
+        //does not exist
+        RUNNER_ASSERT_MSG(
+            PluginDAO::isPluginInstalled("not_installed1") == false,
+            "Found not_installed1");
+        RUNNER_ASSERT_MSG(PluginDAO::isPluginInstalled("p 4") == false,
+                          "Found p 4");
+        RUNNER_ASSERT_MSG(PluginDAO::isPluginInstalled("") == false,
+                          "Found <empty>");
+        RUNNER_ASSERT_MSG(PluginDAO::isPluginInstalled("p33") == false,
+                          "Found p33");
+        RUNNER_ASSERT_MSG(PluginDAO::isPluginInstalled("feature1") == false,
+                          "Found feature1");
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_plugin_handle_list
+ * Description: test of returning plugin handle list
+ * Expected: returned list should be no less than number of registered plugins
+ */
+RUNNER_TEST(plugin_dao_test_get_plugin_handle_list)
+{
+    PluginHandleList handles = PluginDAO::getPluginHandleList();
+    RUNNER_ASSERT(handles.size() >= 5);
+}
+
+/*
+ * Name: plugin_dao_test_constructor_name
+ * Description: tests construction of plugin dao based on plugin name
+ * Expected: Instance of dao should be constructed only
+ * if there is given plugin in database
+ */
+RUNNER_TEST(plugin_dao_test_constructor_name)
+{
+    {
+        //exist
+        std::list<const char *> preinstalled;
+        preinstalled.push_back("plugin1");
+        preinstalled.push_back("plugin2");
+        preinstalled.push_back("plugin3");
+        preinstalled.push_back("p4");
+        preinstalled.push_back("p5");
+
+        FOREACH(it, preinstalled)
+        {
+            PluginDAO dao(*it);
+            RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryName(), *it);
+        }
+    }
+
+    {
+        //does not exist
+        std::list<const char *> not_installed;
+        not_installed.push_back("plugin 1");
+        not_installed.push_back("");
+        not_installed.push_back("p 3");
+
+        FOREACH(it, not_installed)
+        {
+            Try {
+                //Plugin not exist
+                PluginDAO dao(*it);
+                RUNNER_ASSERT_MSG(false, "should not be found");
+            }
+            Catch(PluginDAO::Exception::PluginNotExist) {
+                continue;
+            }
+        }
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_plugin_properties
+ * Description: tests reading plugin properties from database
+ * Expected: Data, inserted into database, should be accessible via dao
+ */
+RUNNER_TEST(plugin_dao_test_get_plugin_properties)
+{
+    {
+        PluginDAO dao("p4");
+        RUNNER_ASSERT(dao.getPluginHandle() == 4);
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryName(), "p4");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryPath(), "path_to_p4");
+    }
+
+    {
+        PluginDAO dao(5);
+        RUNNER_ASSERT(dao.getPluginHandle() == 5);
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryName(), "p5");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryPath(), "path_to_p5");
+    }
+
+    {
+        PluginDAO dao(2);
+        RUNNER_ASSERT(dao.getPluginHandle() == 2);
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryName(), "plugin2");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryPath(), "path_to_plugin2");
+    }
+
+    {
+        PluginDAO dao(1);
+        RUNNER_ASSERT(dao.getPluginHandle() == 1);
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryName(), "plugin1");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getLibraryPath(), "");
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_implemented_objects_for_plugin_handle_1
+ * Description: tests receiving from dao Implemented Objects
+ * Expected: returned object is size 0
+ */
+RUNNER_TEST(plugin_dao_test_get_implemented_objects_for_plugin_handle_1)
+{
+    {
+        const int handle = 1;
+        PluginDAOReadOnly dao(handle);
+        auto dbHandle = dao.getPluginHandle();
+        RUNNER_ASSERT(dbHandle == handle);
+        auto objects = dao.getImplementedObjectsForPluginHandle(dbHandle);
+
+        RUNNER_ASSERT(objects.empty());
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_implemented_objects_for_plugin_handle_2
+ * Description: tests receiving from dao Implemented Objects
+ * Expected: returned object is size as it was inserted
+ */
+RUNNER_TEST(plugin_dao_test_get_implemented_objects_for_plugin_handle_2)
+{
+    {
+        std::set< std::string > preinstalled = {
+            ""
+        };
+
+        PluginDAOReadOnly dao(2);
+        auto dbHandle = dao.getPluginHandle();
+        auto objects = dao.getImplementedObjectsForPluginHandle(dbHandle);
+
+        //LogError("\n" << objects.size() << " " << preinstalled.size() <<
+        // "\n");
+
+        RUNNER_ASSERT(objects.size() == preinstalled.size());
+
+        FOREACH(dbObject, objects)
+        {
+            RUNNER_ASSERT(preinstalled.find(*dbObject) != preinstalled.end());
+        }
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_implemented_objects_for_plugin_handle_3
+ * Description: tests receiving from dao Implemented Objects
+ * Expected: returned objects list has preinserted object
+ */
+RUNNER_TEST(plugin_dao_test_get_implemented_objects_for_plugin_handle_3)
+{
+    {
+        std::set< std::string > preinstalled = {
+            "Plugin_3_Object_A"
+        };
+
+        PluginDAOReadOnly dao(3);
+        auto dbHandle = dao.getPluginHandle();
+        auto objects = dao.getImplementedObjectsForPluginHandle(dbHandle);
+        RUNNER_ASSERT(objects.size() == preinstalled.size());
+
+        FOREACH(dbObject, objects)
+        {
+            RUNNER_ASSERT(preinstalled.find(*dbObject) != preinstalled.end());
+        }
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_implemented_objects_for_plugin_handle_4
+ * Description: tests receiving from dao Implemented Objects
+ * Expected: returned objects list has all preinserted objects
+ */
+RUNNER_TEST(plugin_dao_test_get_implemented_objects_for_plugin_handle_4)
+{
+    {
+        std::set< std::string > preinstalled = {
+            "Plugin_4_Object_A",
+            "Plugin_4_Object_B",
+            "Plugin_4_Object_C",
+        };
+
+        PluginDAOReadOnly dao(4);
+        auto dbHandle = dao.getPluginHandle();
+        auto objects = dao.getImplementedObjectsForPluginHandle(dbHandle);
+        RUNNER_ASSERT(objects.size() == preinstalled.size());
+
+        FOREACH(dbObject, objects)
+        {
+            RUNNER_ASSERT(preinstalled.find(*dbObject) != preinstalled.end());
+        }
+    }
+}
+
+/*
+ * Name: plugin_dao_test_get_implemented_objects_for_plugin_handle_5
+ * Description: tests receiving from dao Implemented Objects
+ * Expected: returned objects list do not have object that was not inserted
+ */
+RUNNER_TEST(plugin_dao_test_get_implemented_objects_for_plugin_handle_5)
+{
+    {
+        std::set< std::string > preinstalled = {
+            "Plugin_5_Object_B",
+        };
+
+        PluginDAOReadOnly dao(5);
+        auto dbHandle = dao.getPluginHandle();
+        auto objects = dao.getImplementedObjectsForPluginHandle(dbHandle);
+        RUNNER_ASSERT(objects.size() == preinstalled.size());
+
+        FOREACH(dbObject, objects)
+        {
+            RUNNER_ASSERT(preinstalled.find(*dbObject) == preinstalled.end());
+        }
+    }
+}
+
+#undef RUNNER_ASSERT_WHAT_EQUALS
diff --git a/tests/dao/TestCases_PropertyDAO.cpp b/tests/dao/TestCases_PropertyDAO.cpp
new file mode 100644 (file)
index 0000000..effd898
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   TestCases_PropertyDAO.cpp
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for property dao class.
+ */
+
+#include <list>
+#include <map>
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/exception.h>
+#include <dpl/wrt-dao-rw/property_dao.h>
+#include <dpl/wrt-dao-ro/wrt_db_types.h>
+
+using namespace WrtDB;
+using namespace WrtDB::PropertyDAOReadOnly;
+
+// Widgets used "tizenid201", "tizenid202", "tizenid203", 2003(saved by
+// wrt_dao_tests_prepare_db.sh)
+
+#define RUNNER_ASSERT_WHAT_EQUALS(in, test)                   \
+    { std::string tmp(in);                                     \
+      RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
+
+#define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test)          \
+    {                                                     \
+        if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); } \
+        else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
+    }
+
+RUNNER_TEST_GROUP_INIT(DAO)
+
+/*
+ * Name: property_dao_get_lists
+ * Description: tests returning list of properties for given id
+ * Expected: data received should match those, which were inserted in prepare
+ * script
+ */
+RUNNER_TEST(property_dao_get_lists)
+{
+    { //property list
+        std::map<WrtDB::TizenAppId, size_t> prefsMap;
+        prefsMap.insert(std::pair<WrtDB::TizenAppId, size_t>(L"tizenid201", 2));
+        prefsMap.insert(std::pair<WrtDB::TizenAppId, size_t>(L"tizenid202", 1));
+        prefsMap.insert(std::pair<WrtDB::TizenAppId, size_t>(L"tizenid203", 2));
+        //no widget
+        prefsMap.insert(std::pair<WrtDB::TizenAppId, size_t>(L"non_exists", 0));
+
+        FOREACH(it, prefsMap) {
+            PropertyDAOReadOnly::WidgetPreferenceList prefs =
+                PropertyDAOReadOnly::GetPropertyList(it->first);
+            RUNNER_ASSERT(prefs.size() == it->second);
+        }
+    }
+
+    { //property key list
+        WidgetPropertyKeyList orig_2000;
+        orig_2000.push_back(DPL::FromUTF8String("key1_for_2000"));
+        orig_2000.push_back(DPL::FromUTF8String("key2_for_2000"));
+
+        WidgetPropertyKeyList orig_2001;
+        orig_2001.push_back(DPL::FromUTF8String("key1_for_2001"));
+
+        WidgetPropertyKeyList orig_2002;
+        orig_2002.push_back(DPL::FromUTF8String("key1_for_2002"));
+        orig_2002.push_back(DPL::FromUTF8String("key2_for_2002"));
+
+        std::map<WrtDB::TizenAppId, WidgetPropertyKeyList *> prefsKeyMap;
+        prefsKeyMap.insert(std::pair<WrtDB::TizenAppId, WidgetPropertyKeyList *>(
+                               L"tizenid201", &orig_2000));
+        prefsKeyMap.insert(std::pair<WrtDB::TizenAppId, WidgetPropertyKeyList *>(
+                               L"tizenid202", &orig_2001));
+        prefsKeyMap.insert(std::pair<WrtDB::TizenAppId, WidgetPropertyKeyList *>(
+                               L"tizenid203", &orig_2002));
+
+        FOREACH(it_out, prefsKeyMap) {
+            WidgetPropertyKeyList got = PropertyDAOReadOnly::GetPropertyKeyList(
+                    it_out->first);
+            RUNNER_ASSERT(got.size() == it_out->second->size());
+            //TODO
+            //            FOREACH(it_in, got)
+            //            {
+            //                RUNNER_ASSERT(it_out->second.
+            //            }
+        }
+    }
+}
+
+/*
+ * Name: property_dao_set_update_remove
+ * Description: tests set new property for widget, updating property and
+ * removing it
+ * Expected: given operation should works
+ */
+RUNNER_TEST(property_dao_set_update_remove)
+{
+    WidgetPropertyKeyList keys = PropertyDAOReadOnly::GetPropertyKeyList(
+            L"tizenid201");
+
+    //ADD
+    PropertyDAO::SetProperty(L"tizenid201",
+                             DPL::FromUTF8String("new_key"),
+                             DPL::FromUTF8String("new_value1"));
+
+    RUNNER_ASSERT_MSG(
+        keys.size() + 1 ==
+        PropertyDAOReadOnly::GetPropertyKeyList(L"tizenid201").size(),
+        "new property not added");
+    RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
+        PropertyDAOReadOnly::GetPropertyValue(L"tizenid201",
+                                              DPL::FromUTF8String("new_key")),
+        "new_value1");
+
+    //UPDATE
+    PropertyDAO::SetProperty(L"tizenid201",
+                             DPL::FromUTF8String("new_key"),
+                             DPL::FromUTF8String("new_value2"));
+    RUNNER_ASSERT_MSG(
+        keys.size() + 1 ==
+        PropertyDAOReadOnly::GetPropertyKeyList(L"tizenid201").size(),
+        "new property not added");
+    RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
+        PropertyDAOReadOnly::GetPropertyValue(L"tizenid201",
+                                              DPL::FromUTF8String("new_key")),
+        "new_value2");
+
+    //REMOVE
+    PropertyDAO::RemoveProperty(L"tizenid201", DPL::FromUTF8String("new_key"));
+
+    RUNNER_ASSERT_MSG(
+        keys.size() == PropertyDAOReadOnly::GetPropertyKeyList(
+            L"tizenid201").size(),
+        "property not removed");
+}
+
+/*
+ * Name: property_dao_get_value
+ * Description: tests if properties can be received from database
+ * Expected: value, which were inserted before test, should be present
+ */
+RUNNER_TEST(property_dao_get_value)
+{
+    RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
+        PropertyDAOReadOnly::GetPropertyValue(
+            L"tizenid201", DPL::FromUTF8String("key1_for_2000")),
+        "value_for_key1_2000");
+
+    RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
+        PropertyDAOReadOnly::GetPropertyValue(
+            L"tizenid201", DPL::FromUTF8String("key2_for_2000")),
+        "value_for_key2_2000");
+}
+
+#undef RUNNER_ASSERT_WHAT_EQUALS
diff --git a/tests/dao/TestCases_WidgetDAO.cpp b/tests/dao/TestCases_WidgetDAO.cpp
new file mode 100644 (file)
index 0000000..26280dd
--- /dev/null
@@ -0,0 +1,1112 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   TestCases_WidgetDAO.cpp
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for widget dao class.
+ */
+
+#include <list>
+#include <cstdlib>
+#include <cstdio>
+#include <string>
+#include <algorithm>
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/exception.h>
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/wrt_db_types.h>
+#include <dpl/string.h>
+#include <wrt_plugin_export.h>
+
+using namespace WrtDB;
+
+namespace {
+class WacSecurityMock : public WrtDB::IWacSecurity
+{
+  public:
+    WacSecurityMock() :
+        mRecognized(false),
+        mDistributorSigned(false),
+        mWacSigned(false)
+    {}
+
+    virtual const WidgetCertificateDataList& getCertificateList() const
+    {
+        return mList;
+    }
+
+    virtual bool isRecognized() const
+    {
+        return mRecognized;
+    }
+    virtual bool isDistributorSigned() const
+    {
+        return mDistributorSigned;
+    }
+    virtual bool isWacSigned() const
+    {
+        return mWacSigned;
+    }
+    virtual void getCertificateChainList(CertificateChainList& /*lst*/) const {}
+    virtual void getCertificateChainList(CertificateChainList& /*lst*/,
+                                         CertificateSource /*source*/) const {}
+
+    WrtDB::WidgetCertificateDataList& getCertificateListRef()
+    {
+        return mList;
+    }
+
+    void setRecognized(bool recognized)
+    {
+        mRecognized = recognized;
+    }
+    void setDistributorSigned(bool distributorSigned)
+    {
+        mDistributorSigned = distributorSigned;
+    }
+    void setWacSigned(bool wacSigned)
+    {
+        mWacSigned = wacSigned;
+    }
+
+  private:
+    WrtDB::WidgetCertificateDataList mList;
+    // author signature verified
+    bool mRecognized;
+    // known distribuor
+    bool mDistributorSigned;
+    // distributor is wac
+    bool mWacSigned;
+};
+
+TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo,
+                           const IWacSecurity& sec,
+                           int line)
+{
+    TizenAppId tizenAppId;
+    Try {
+        auto previous = WidgetDAO::getTizenAppidList();
+
+        // register widget
+        tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec);
+
+        RUNNER_ASSERT_MSG(!tizenAppId.empty(),
+                          "(called from line " << line << ")");
+
+        auto current = WidgetDAO::getTizenAppidList();
+        RUNNER_ASSERT_MSG(previous.size() + 1 == current.size(),
+                          "(called from line " << line << ")");
+
+        RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
+                              tizenAppId),
+                          "(called from line " << line << " tizenAppId: " <<
+                          tizenAppId << ")");
+    }
+    Catch(WidgetDAO::Exception::AlreadyRegistered) {
+        RUNNER_ASSERT_MSG(
+            false,
+            "Unexpected exception (called from line " << line << ")");
+    }
+    return tizenAppId;
+}
+
+#define REGISTER_WIDGET(regInfo, sec) _registerWidget((regInfo), \
+                                                      (sec), \
+                                                      __LINE__)
+} // namespace
+
+// Widgets used <2300,2500), 2000, 2001, 2002, 2003
+
+#define RUNNER_ASSERT_WHAT_EQUALS(in, test)                   \
+    { std::string tmp(in);                                     \
+      RUNNER_ASSERT_MSG(tmp == test, "Equals: [" + tmp + "]"); }
+
+#define RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(in, test)          \
+    {                                                     \
+        if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); } \
+        else { RUNNER_ASSERT_WHAT_EQUALS(DPL::ToUTF8String(*in), test); } \
+    }
+
+#define RUNNER_ASSERT_WHAT_EQUALS_OPTIONALINT(in, test)                   \
+    {                                                                 \
+        if (in.IsNull()) { RUNNER_ASSERT_MSG(false, "NULL"); }             \
+        else { RUNNER_ASSERT_MSG(*in == test, "Equals: [" + *in + "]"); } \
+    }
+
+RUNNER_TEST_GROUP_INIT(DAO)
+
+//2300
+/*
+ * Name: widget_dao_test_register_widget_empty_strings
+ * Description: Tests registeration of new widget with empty values
+ * Expected: widget should be registered in database
+ */
+RUNNER_TEST(widget_dao_test_register_widget_empty_strings)
+{
+    WidgetRegisterInfo regInfo;
+
+    //ext info
+    regInfo.shareHref = "";
+
+    //info
+    regInfo.configInfo.widget_id = DPL::FromUTF8String("");
+    regInfo.configInfo.version = DPL::FromUTF8String("");
+    regInfo.configInfo.width = 10;
+    regInfo.configInfo.height = 10;
+    regInfo.configInfo.authorName = DPL::FromUTF8String("");
+    regInfo.configInfo.authorEmail = DPL::FromUTF8String("");
+    regInfo.configInfo.authorHref = DPL::FromUTF8String("");
+    regInfo.baseFolder = "";
+    //TODO authenticated, etc...
+    regInfo.configInfo.flashNeeded = false;
+    regInfo.configInfo.minVersionRequired = DPL::FromUTF8String("1.0");
+    regInfo.configInfo.backSupported = true;
+
+    //loc info
+    ConfigParserData::LocalizedData locData;
+    locData.name = DPL::FromUTF8String("");
+    locData.shortName = DPL::FromUTF8String("");
+    locData.description = DPL::FromUTF8String("");
+    locData.license = DPL::FromUTF8String("");
+    locData.licenseFile = DPL::FromUTF8String("");
+    locData.licenseHref = DPL::FromUTF8String("");
+    regInfo.configInfo.localizedDataSet.insert(
+        std::make_pair(DPL::FromUTF8String("en"), locData));
+
+    //userAgentLoc
+
+    //icons
+    ConfigParserData::Icon icon(DPL::FromUTF8String(""));
+    icon.width = 10;
+    icon.height = 10;
+    LocaleSet locs;
+    locs.insert(DPL::FromUTF8String("en"));
+    WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
+    regInfo.localizationData.icons.push_back(locIcon);
+
+    //start file
+    WidgetRegisterInfo::StartFileProperties prop;
+    prop.encoding = DPL::FromUTF8String("");
+    prop.type = DPL::FromUTF8String("");
+    WidgetRegisterInfo::LocalizedStartFile file;
+    file.path = DPL::FromUTF8String("");
+    file.propertiesForLocales.insert(
+        std::make_pair(DPL::FromUTF8String("en"), prop));
+    regInfo.localizationData.startFiles.push_back(file);
+
+    //widget pref
+    ConfigParserData::Preference pref(DPL::FromUTF8String(""), false);
+    pref.value = DPL::FromUTF8String("");
+    regInfo.configInfo.preferencesList.insert(pref);
+
+    //widget feature
+    ConfigParserData::Feature feat(DPL::FromUTF8String(""), false);
+    ConfigParserData::Param par(DPL::FromUTF8String(("")));
+    par.value = DPL::FromUTF8String("");
+    feat.paramsList.insert(par);
+    regInfo.configInfo.featuresList.insert(feat);
+
+    //win modes
+    regInfo.configInfo.windowModes.insert(DPL::FromUTF8String(""));
+
+    //WARP info
+    ConfigParserData::AccessInfo access(DPL::FromUTF8String(""), true);
+    regInfo.configInfo.accessInfoSet.insert(access);
+
+    //certificates
+    WidgetCertificateData cert;
+    cert.owner = WidgetCertificateData::AUTHOR;
+    cert.type = WidgetCertificateData::ROOT;
+    cert.chainId = 1;
+    cert.strMD5Fingerprint = "";
+    cert.strSHA1Fingerprint = "";
+    cert.strCommonName = DPL::FromUTF8String("");
+
+    WacSecurityMock security;
+    security.getCertificateListRef().push_back(cert);
+
+    REGISTER_WIDGET(regInfo, security);
+}
+
+/*
+ * Name: widget_dao_test_register_widget_empty_strings
+ * Description: Tests possiblity of registering twice same content (different
+ * tizenId)
+ * Expected: it should be possible
+ */
+RUNNER_TEST(widget_dao_test_twice_install_same_widget)
+{
+    WacSecurityMock sec;
+    {
+        WidgetRegisterInfo regInfo;
+        REGISTER_WIDGET(regInfo, sec);
+    }
+    {
+        WidgetRegisterInfo regInfo;
+        REGISTER_WIDGET(regInfo, sec);
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_minimum_info
+ * Description: Tests simplest registeration of new widget
+ * Expected: widget should be registered in database
+ */
+RUNNER_TEST(widget_dao_test_register_widget_minimum_info)
+{
+    WacSecurityMock sec;
+    const std::size_t NUMBER_OF_WIDGETS = 5;
+
+    TizenAppId lastTizenAppId;
+
+    for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
+        WidgetRegisterInfo regInfo;
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+        lastTizenAppId = tizenAppId;
+
+        WidgetDAO dao(tizenAppId);
+        //TODO check nulls
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_info
+ * Description: Tests registeration of many widgets
+ * Expected: all widgets should be registered in database
+ */
+RUNNER_TEST(widget_dao_test_register_widget_info)
+{
+    WacSecurityMock sec;
+    const std::size_t NUMBER_OF_WIDGETS = 5;
+
+    for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
+        std::ostringstream str;
+        str << "register_info_test_" << number;
+
+        WidgetRegisterInfo regInfo;
+        regInfo.configInfo.widget_id = DPL::FromUTF8String(str.str());
+        regInfo.configInfo.version = DPL::FromUTF8String(str.str());
+        regInfo.configInfo.width = 10;
+        regInfo.configInfo.height = 10;
+        regInfo.configInfo.authorName = DPL::FromUTF8String(str.str());
+        regInfo.configInfo.authorEmail = DPL::FromUTF8String(str.str());
+        regInfo.configInfo.authorHref = DPL::FromUTF8String(str.str());
+        regInfo.baseFolder = str.str(); //base folder at the end has /
+        regInfo.configInfo.flashNeeded = false;
+        //TODO authenticated, etc...
+        //in wrt-installer: TaskWidgetConfig::fillWidgetConfig:
+        //regInfo.minVersion = regInfo.configInfo.minVersionRequired
+        regInfo.minVersion = DPL::FromUTF8String("1.0");
+        regInfo.configInfo.backSupported = true;
+
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+        WidgetDAO dao(tizenAppId);
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), str.str());
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), str.str());
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), str.str());
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(), str.str());
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), str.str());
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getBaseFolder(), str.str() + "/");
+        RUNNER_ASSERT(dao.getWebkitPluginsRequired() == false);
+        //        RUNNER_ASSERT(
+        //            dao.GetWidgetSecurityDomain() == WacSecurity::Trusted);
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_extended_info
+ * Description: Tests registeration of widget_extended_info
+ * Expected: registeration of extended inforamtion is checked
+ * via existence of backgroudn page value
+ */
+RUNNER_TEST(widget_dao_test_register_widget_extended_info)
+{
+    WacSecurityMock sec;
+    const std::size_t NUMBER_OF_WIDGETS = 5;
+
+    for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
+        std::ostringstream str;
+        str << "register_ext_info_test_" << number;
+
+        WidgetRegisterInfo regInfo;
+
+        //        regInfo.shareHref = str.str();
+        regInfo.configInfo.backgroundPage = L"background.html";
+
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+        WidgetDAO dao(tizenAppId);
+        //        RUNNER_ASSERT_WHAT_EQUALS(dao.GetShareHref(), str.str());
+
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getBackgroundPage(),
+                                           "background.html");
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_localized_info
+ * Description: Tests registeration of localized widgets information
+ * Expected: values received by dao should match those which were registered
+ */
+RUNNER_TEST(widget_dao_test_register_widget_localized_info)
+{
+    WacSecurityMock sec;
+    const std::size_t NUMBER_OF_WIDGETS = 5;
+
+    for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) {
+        WidgetRegisterInfo regInfo;
+        std::ostringstream str_en;
+        std::ostringstream str_pl;
+        str_en << "register_loc_info_test_en_" << number;
+        str_pl << "register_loc_info_test_pl_" << number;
+        { //EN
+            ConfigParserData::LocalizedData locDataEn;
+            locDataEn.name = DPL::FromUTF8String(str_en.str());
+            locDataEn.shortName = DPL::FromUTF8String(str_en.str());
+            locDataEn.description = DPL::FromUTF8String(str_en.str());
+            locDataEn.license = DPL::FromUTF8String(str_en.str());
+            locDataEn.licenseFile = DPL::FromUTF8String(str_en.str());
+            locDataEn.licenseHref = DPL::FromUTF8String(str_en.str());
+            regInfo.configInfo.localizedDataSet.insert(
+                std::make_pair(DPL::FromUTF8String("en"), locDataEn));
+        }
+
+        { //PL
+            ConfigParserData::LocalizedData locDataPl;
+            locDataPl.name = DPL::FromUTF8String(str_pl.str());
+            locDataPl.shortName = DPL::FromUTF8String(str_pl.str());
+            locDataPl.description = DPL::FromUTF8String(str_pl.str());
+            locDataPl.license = DPL::FromUTF8String(str_pl.str());
+            locDataPl.licenseFile = DPL::FromUTF8String(str_pl.str());
+            locDataPl.licenseHref = DPL::FromUTF8String(str_pl.str());
+            regInfo.configInfo.localizedDataSet.insert(
+                std::make_pair(DPL::FromUTF8String("pl"), locDataPl));
+        }
+
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+        WidgetDAO dao(tizenAppId);
+        RUNNER_ASSERT_MSG(dao.getLanguageTags().size() == 2,
+                          "language tags list invalid");
+
+        { //EN
+            WidgetLocalizedInfo locInfo =
+                dao.getLocalizedInfo(DPL::FromUTF8String("en"));
+
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
+                                               str_en.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
+                                               str_en.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
+                                               str_en.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
+                                               str_en.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
+                                               str_en.str());
+        }
+
+        { //PL
+            WidgetLocalizedInfo locInfo =
+                dao.getLocalizedInfo(DPL::FromUTF8String("pl"));
+
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.name,
+                                               str_pl.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.shortName,
+                                               str_pl.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.description,
+                                               str_pl.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.license,
+                                               str_pl.str());
+            RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(locInfo.licenseHref,
+                                               str_pl.str());
+        }
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_icons
+ * Description: Tests registeration of localized icons information
+ * Expected: values received by dao should match those which were registered
+ * for icon
+ */
+RUNNER_TEST(widget_dao_test_register_widget_icons)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+
+    ConfigParserData::Icon icon(L"icon1");
+    icon.width = 10;
+    icon.height = 10;
+    LocaleSet locs;
+    locs.insert(DPL::FromUTF8String("en"));
+    WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
+    regInfo.localizationData.icons.push_back(locIcon);
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+    WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
+
+    RUNNER_ASSERT(list.size() == regInfo.localizationData.icons.size());
+    WidgetDAOReadOnly::WidgetIconList::const_iterator it1 = list.begin();
+    WidgetRegisterInfo::LocalizedIconList::const_iterator it2 =
+        regInfo.localizationData.icons.begin();
+    for (; it1 != list.end() && it2 != regInfo.localizationData.icons.end();
+         ++it1, ++it2)
+    {
+        RUNNER_ASSERT(it2->height == it1->iconHeight);
+        RUNNER_ASSERT(it2->width == it1->iconWidth);
+        RUNNER_ASSERT(it2->src == it1->iconSrc);
+        RUNNER_ASSERT(it2->availableLocales == locs);
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_start_files
+ * Description: Tests registeration of localized start files
+ * Expected: no expectations as it should be removed
+ */
+RUNNER_TEST(widget_dao_test_register_widget_start_files)
+{
+    WacSecurityMock sec;
+
+    WidgetRegisterInfo::LocalizedStartFileList files;
+    WidgetRegisterInfo::StartFilePropertiesForLocalesMap map1;
+    WidgetRegisterInfo::StartFileProperties prop1;
+    prop1.encoding = DPL::FromUTF8String("enc1");
+    prop1.type = DPL::FromUTF8String("type1");
+
+    map1.insert(std::make_pair(DPL::FromUTF8String("en"), prop1));
+    map1.insert(std::make_pair(DPL::FromUTF8String("pl"), prop1));
+
+    WidgetRegisterInfo::LocalizedStartFile file1;
+    WidgetRegisterInfo::LocalizedStartFile file2;
+    file1.path = DPL::FromUTF8String("path1");
+    file1.propertiesForLocales = map1;
+    file2.path = DPL::FromUTF8String("path2");
+    file2.propertiesForLocales = map1;
+
+    files.push_back(file1);
+    files.push_back(file1);
+
+    WidgetRegisterInfo regInfo;
+    regInfo.localizationData.startFiles = files;
+
+    REGISTER_WIDGET(regInfo, sec);
+
+    //TODO no getter in WidgetDAO (getter in LocalizedWidgetDAO,
+    // but it will be removed
+}
+
+/*
+ * Name: widget_dao_test_register_widget_features
+ * Description: Tests registeration of features of widget
+ * Expected: number of features should match (for given widget reginfo)
+ */
+RUNNER_TEST(widget_dao_test_register_widget_features)
+{
+    WacSecurityMock sec;
+    ConfigParserData::FeaturesList features;
+    features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f1"), true));
+    features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f2")));
+    features.insert(ConfigParserData::Feature(DPL::FromUTF8String("f3"),
+                                              false));
+
+    WidgetRegisterInfo regInfo;
+    FOREACH(it, features)
+    regInfo.configInfo.featuresList.insert(*it);
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+    WidgetFeatureSet out = dao.getFeaturesList();
+    RUNNER_ASSERT_MSG(out.size() == features.size(),
+                      "wrong number of features");
+    //    FOREACH(it, out)
+    //        RUNNER_ASSERT(features.find(*it) != features.end());
+}
+
+/*
+ * Name: widget_dao_test_register_widget_security_settings
+ * Description: Tests registeration of dafault values of security settings
+ * Expected: widget should be registered in database.
+ * Returned values should match dafault.
+ */
+RUNNER_TEST(widget_dao_test_register_widget_security_settings)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "SecurityPopupUsage is not deafult on");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "GeolocationUsage is not deafult on");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebNotificationUsage is not deafult on");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebDatabaseUsage is not deafult on");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "FileSystemUsage is not deafult on");
+
+    dao.setSecurityPopupUsage(WrtDB::SETTINGS_TYPE_OFF);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "SecurityPopupUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "GeolocationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebNotificationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebDatabaseUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "FileSystemUsage - wrong value");
+
+    dao.setGeolocationUsage(WrtDB::SETTINGS_TYPE_ALWAYS_ASK);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "SecurityPopupUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "GeolocationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebNotificationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebDatabaseUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "FileSystemUsage - wrong value");
+
+    dao.setWebNotificationUsage(WrtDB::SETTINGS_TYPE_OFF);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "SecurityPopupUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "GeolocationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "WebNotificationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "WebDatabaseUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "FileSystemUsage - wrong value");
+
+    dao.setWebDatabaseUsage(WrtDB::SETTINGS_TYPE_ALWAYS_ASK);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "SecurityPopupUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "GeolocationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "WebNotificationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "WebDatabaseUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "FileSystemUsage - wrong value");
+
+    dao.setFileSystemUsage(WrtDB::SETTINGS_TYPE_OFF);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "SecurityPopupUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "GeolocationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "WebNotificationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "WebDatabaseUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "FileSystemUsage - wrong value");
+
+    dao.setFileSystemUsage(WrtDB::SETTINGS_TYPE_ON);
+    RUNNER_ASSERT_MSG(
+        dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "SecurityPopupUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "GeolocationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF,
+        "WebNotificationUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK,
+        "WebDatabaseUsage - wrong value");
+    RUNNER_ASSERT_MSG(
+        dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON,
+        "FileSystemUsage - wrong value");
+}
+
+/*
+ * Name: widget_dao_test_register_widget_win_modes
+ * Description: Tests registeration of window modes
+ * Expected: all modes should be returned from dao
+ */
+RUNNER_TEST(widget_dao_test_register_widget_win_modes)
+{
+    WacSecurityMock sec;
+    std::set<DPL::String> modes;
+    modes.insert(DPL::FromUTF8String("full"));
+    modes.insert(DPL::FromUTF8String("window"));
+
+    WidgetRegisterInfo regInfo;
+
+    FOREACH(it, modes)
+    regInfo.configInfo.windowModes.insert(*it);
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+    std::list<DPL::String> wins = dao.getWindowModes();
+    RUNNER_ASSERT_MSG(modes.size() == wins.size(),
+                      "wrong number of window modes");
+    FOREACH(it, wins)
+    RUNNER_ASSERT(modes.find(*it) != modes.end());
+}
+
+/*
+ * Name: widget_dao_test_register_widget_warp_info
+ * Description: Tests registeration of access info iris
+ * Expected: all access info iris should be returned from dao
+ */
+RUNNER_TEST(widget_dao_test_register_widget_warp_info)
+{
+    WacSecurityMock sec;
+    ConfigParserData::AccessInfoSet orig;
+    orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri1"),
+                                             true));
+    orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri2"),
+                                             false));
+    orig.insert(ConfigParserData::AccessInfo(DPL::FromUTF8String("iri3"),
+                                             true));
+
+    WidgetRegisterInfo regInfo;
+    FOREACH(it, orig)
+    regInfo.configInfo.accessInfoSet.insert(*it);
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+
+    WidgetAccessInfoList out;
+    dao.getWidgetAccessInfo(out);
+    RUNNER_ASSERT_MSG(out.size() == orig.size(),
+                      "wrong number of access info elem");
+    FOREACH(it, out){
+        ConfigParserData::AccessInfo tmp(it->strIRI, it->bSubDomains);
+        RUNNER_ASSERT(orig.find(tmp) != orig.end());
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_widget_certificates
+ * Description: Tests registeration of widget certificates
+ * Expected: all certificates should be returned from dao
+ * and should contain inserted data
+ */
+RUNNER_TEST(widget_dao_test_register_widget_certificates)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+
+    WidgetCertificateData cert;
+    cert.owner = WidgetCertificateData::AUTHOR;
+    cert.type = WidgetCertificateData::ROOT;
+    cert.chainId = 1;
+    cert.strMD5Fingerprint = "md5";
+    cert.strSHA1Fingerprint = "sha1";
+    cert.strCommonName = DPL::FromUTF8String("common name");
+
+    WidgetCertificateDataList& certListRef = sec.getCertificateListRef();
+    certListRef.push_back(cert);
+
+    // register widget
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+
+    // certificates
+    WidgetCertificateDataList recList = dao.getCertificateDataList();
+    RUNNER_ASSERT(recList.size() == certListRef.size());
+
+    auto recListIt = recList.begin();
+    auto certListIt = certListRef.begin();
+    for (; recListIt != recList.end() && certListIt != certListRef.end();
+         ++recListIt, ++certListIt)
+    {
+        RUNNER_ASSERT(recListIt->chainId == certListIt->chainId);
+        RUNNER_ASSERT(recListIt->owner == certListIt->owner);
+        RUNNER_ASSERT(recListIt->strCommonName == certListIt->strCommonName);
+        RUNNER_ASSERT(recListIt->strMD5Fingerprint ==
+                      certListIt->strMD5Fingerprint);
+        RUNNER_ASSERT(recListIt->strSHA1Fingerprint ==
+                      certListIt->strSHA1Fingerprint);
+        RUNNER_ASSERT(recListIt->type == certListIt->type);
+    }
+
+    // fingerprints
+    RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
+                                         WidgetCertificateData::ENDENTITY).
+                      empty());
+    RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::AUTHOR,
+                                         WidgetCertificateData::ENDENTITY).
+                      empty());
+    RUNNER_ASSERT(dao.getKeyFingerprints(WidgetCertificateData::DISTRIBUTOR,
+                                         WidgetCertificateData::ROOT).empty());
+
+    FingerPrintList fingerprints = dao.getKeyFingerprints(
+            WidgetCertificateData::AUTHOR,
+            WidgetCertificateData::ROOT);
+
+    RUNNER_ASSERT(fingerprints.size() == certListRef.size() * 2);
+    FOREACH(it, certListRef)
+    {
+        auto md5 = std::find(fingerprints.begin(),
+                             fingerprints.end(),
+                             it->strMD5Fingerprint);
+        RUNNER_ASSERT(md5 != fingerprints.end());
+
+        auto sha = std::find(fingerprints.begin(),
+                             fingerprints.end(),
+                             it->strSHA1Fingerprint);
+        RUNNER_ASSERT(sha != fingerprints.end());
+    }
+
+    // common names
+    RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
+                                           WidgetCertificateData::ENDENTITY).
+                      empty());
+    RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::AUTHOR,
+                                           WidgetCertificateData::ENDENTITY).
+                      empty());
+    RUNNER_ASSERT(dao.getKeyCommonNameList(WidgetCertificateData::DISTRIBUTOR,
+                                           WidgetCertificateData::ROOT).empty());
+
+    FingerPrintList commonNames = dao.getKeyCommonNameList(
+            WidgetCertificateData::AUTHOR,
+            WidgetCertificateData::ROOT);
+
+    RUNNER_ASSERT(commonNames.size() == certListRef.size());
+    FOREACH(it, certListRef)
+    {
+        auto cn = std::find(commonNames.begin(),
+                            commonNames.end(),
+                            DPL::ToUTF8String(it->strCommonName));
+        RUNNER_ASSERT(cn != commonNames.end());
+    }
+}
+
+/*
+ * Name: widget_dao_test_is_widget_installed
+ * Description: Tests checking if widgets are installed
+ * Expected: installed widgets should be stated as installed
+ */
+RUNNER_TEST(widget_dao_test_is_widget_installed)
+{
+    RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(L"tizenid201"));
+
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(tizenAppId));
+}
+
+/*
+ * Name: widget_dao_test_unregister_widget
+ * Description: Tests unregistering widgets
+ * Expected: widget register informations should be successfully removed
+ */
+RUNNER_TEST(widget_dao_test_unregister_widget)
+{
+    WacSecurityMock sec;
+    WidgetHandleList handles = WidgetDAO::getHandleList();
+
+    WidgetRegisterInfo regInfo;
+
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO::unregisterWidget(tizenAppId);
+
+    RUNNER_ASSERT_MSG(handles.size() == WidgetDAO::getHandleList().size(),
+                      "Widget unregister failed");
+}
+
+/*
+ * Name: widget_dao_test_register_or_update_widget
+ * Description: Tests reregistering widgets
+ * Expected: widget should be successfully replaced
+ */
+RUNNER_TEST(widget_dao_test_register_or_update_widget)
+{
+    WacSecurityMock sec;
+
+    WidgetRegisterInfo regInfo;
+    regInfo.configInfo.version = L"1.0";
+    regInfo.configInfo.authorName = L"AAA";
+
+    WidgetRegisterInfo regInfo2;
+    regInfo2.configInfo.version = L"1.1";
+    regInfo2.configInfo.authorName = L"BBB";
+
+    WrtDB::TizenAppId tizenAppId(L"abcdefghij");
+
+    //first installation
+    WidgetDAO::registerWidget(tizenAppId, regInfo, sec);
+    RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
+                          tizenAppId), "Widget is not registered");
+
+    //success full update
+    WidgetDAO::registerOrUpdateWidget(tizenAppId, regInfo2, sec);
+    RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(
+                          tizenAppId), "Widget is not reregistered");
+    WidgetDAO dao(tizenAppId);
+    RUNNER_ASSERT_MSG(
+        *dao.getVersion() == L"1.1", "Data widget was not updated");
+    RUNNER_ASSERT_MSG(
+        *dao.getAuthorName() == L"BBB", "Data widget was not updated");
+
+    WidgetDAO::unregisterWidget(tizenAppId);
+}
+
+/*
+ * Name: widget_dao_test_get_widget_tizenAppId_list
+ * Description: Tests getTizenAppidList API for backendlib
+ * Expected: For all position in database should be returned one item in list
+ */
+RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list)
+{
+    TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppidList();
+    RUNNER_ASSERT(tizenAppIds.size() >= 3);
+}
+
+/*
+ * Name: widget_dao_test_get_widget_list
+ * Description: Tests getTizenAppidList API for backendlib
+ * Expected: For all position in database should be returned one item in list
+ * Those item should contain valid tizenAppId
+ */
+RUNNER_TEST(widget_dao_test_get_widget_list)
+{
+    WidgetDAOReadOnlyList list = WidgetDAOReadOnly::getWidgetList();
+    RUNNER_ASSERT(list.size() >= 3);
+    RUNNER_ASSERT_MSG(!!list.front(), "widget dao exists");
+    WidgetDAOReadOnlyPtr dao = list.front();
+}
+
+/*
+ * Name: widget_dao_test_get_widget_attributes
+ * Description: Tests returning basic widget attributes by dao
+ * Expected: Attributes should match values inserted into database
+ */
+RUNNER_TEST(widget_dao_test_get_widget_attributes)
+{
+    {
+        TizenAppId tizenAppId = L"tizenid201";
+        WidgetDAO dao(tizenAppId);
+
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), "w_id_2000");
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), "1.0.0");
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), "a_name_2000");
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorEmail(),
+                                           "a_email_2000");
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorHref(), "a_href_2000");
+        RUNNER_ASSERT_WHAT_EQUALS(dao.getBaseFolder(), "basef_2000/");
+        RUNNER_ASSERT(dao.getWebkitPluginsRequired() == true);
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getMinimumWacVersion(), "1.0");
+    }
+}
+
+/*
+ * Name: widget_dao_test_localization
+ * Description: Tests inserting and returning localization info
+ * Expected: Values inserted into database should match values received from
+ * database
+ */
+RUNNER_TEST(widget_dao_test_localization)
+{
+    WacSecurityMock sec;
+
+    // icon
+    WidgetRegisterInfo regInfo;
+    ConfigParserData::Icon icon(L"icon1");
+    icon.width = 10;
+    icon.height = 10;
+    LocaleSet locs;
+    locs.insert(DPL::FromUTF8String("en"));
+    locs.insert(DPL::FromUTF8String("pl"));
+    WidgetRegisterInfo::LocalizedIcon locIcon(icon, locs);
+    regInfo.localizationData.icons.push_back(locIcon);
+
+    //start file
+    WidgetRegisterInfo::StartFileProperties prop_en;
+    prop_en.encoding = DPL::FromUTF8String("encoding_en");
+    prop_en.type = DPL::FromUTF8String("type_en");
+
+    WidgetRegisterInfo::StartFileProperties prop_pl;
+    prop_pl.encoding = DPL::FromUTF8String("encoding_pl");
+    prop_pl.type = DPL::FromUTF8String("type_pl");
+
+    WidgetRegisterInfo::LocalizedStartFile file;
+    file.path = DPL::FromUTF8String("path");
+    file.propertiesForLocales.insert(
+        std::make_pair(DPL::FromUTF8String("en"), prop_en));
+    file.propertiesForLocales.insert(
+        std::make_pair(DPL::FromUTF8String("pl"), prop_pl));
+    regInfo.localizationData.startFiles.push_back(file);
+
+    // register widget
+    TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+
+    WidgetDAO dao(tizenAppId);
+
+    // check localized icons
+    WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
+    RUNNER_ASSERT(locList.size() == locs.size());
+
+    // non-localized icon
+    WidgetDAO::WidgetIconList list = dao.getIconList();
+    int iconId = list.front().iconId;
+
+    // compare every icon with the origin
+    auto locsIt = locs.begin();
+    auto iconIt = locList.begin();
+    for (; locsIt != locs.end() && iconIt != locList.end(); ++locsIt,
+         ++iconIt)
+    {
+        RUNNER_ASSERT(iconIt->appId == dao.getHandle());
+        RUNNER_ASSERT(iconIt->iconId == iconId);
+        RUNNER_ASSERT(iconIt->widgetLocale == *locsIt);
+    }
+
+    // localized start file list
+    WidgetDAO::LocalizedStartFileList fList = dao.getLocalizedStartFileList();
+    RUNNER_ASSERT(fList.size() == file.propertiesForLocales.size());
+
+    int startFileId = dao.getStartFileList().front().startFileId;
+
+    FOREACH(it, fList)
+    {
+        RUNNER_ASSERT(it->appId == dao.getHandle());
+        auto propIt = file.propertiesForLocales.find(it->widgetLocale);
+        RUNNER_ASSERT(propIt != file.propertiesForLocales.end());
+        RUNNER_ASSERT(it->encoding == propIt->second.encoding);
+        RUNNER_ASSERT(it->type == propIt->second.type);
+        RUNNER_ASSERT(it->startFileId == startFileId);
+    }
+}
+
+/*
+ * Name: widget_dao_test_wac_security
+ * Description: Tests inserting and returning wac security information
+ * Expected: Values inserted into database should match values received from
+ * database
+ */
+RUNNER_TEST(widget_dao_test_wac_security)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+    {
+        // register widget
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+        WidgetDAO dao(tizenAppId);
+
+        RUNNER_ASSERT(!dao.isDistributorSigned());
+        RUNNER_ASSERT(!dao.isRecognized());
+        RUNNER_ASSERT(!dao.isWacSigned());
+    }
+    sec.setDistributorSigned(true);
+    sec.setRecognized(true);
+    sec.setWacSigned(true);
+    {
+        // register widget
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+        WidgetDAO dao(tizenAppId);
+
+        RUNNER_ASSERT(dao.isDistributorSigned());
+        RUNNER_ASSERT(dao.isRecognized());
+        RUNNER_ASSERT(dao.isWacSigned());
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_scp
+ * Description: Tests inserting and returning scp policy information
+ * Expected: Value inserted into database should match values received from
+ * database
+ */
+RUNNER_TEST(widget_dao_test_register_scp)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+    DPL::OptionalString policy = DPL::FromUTF8String("Some awesome csp policy");
+    regInfo.configInfo.cspPolicy = policy;
+    {
+        // register widget
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+        WidgetDAO dao(tizenAppId);
+
+        RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(
+            dao.getCspPolicy(), DPL::ToUTF8String(*policy));
+    }
+}
+
+/*
+ * Name: widget_dao_test_register_csp_empty
+ * Description: Tests inserting and returning empty csp policy
+ * Expected: Value inserted into database should match values received from
+ * database
+ */
+RUNNER_TEST(widget_dao_test_register_csp_empty)
+{
+    WacSecurityMock sec;
+    WidgetRegisterInfo regInfo;
+    {
+        // register widget
+        TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec);
+        WidgetDAO dao(tizenAppId);
+
+        RUNNER_ASSERT_MSG(dao.getCspPolicy().IsNull(), "Policy is not null");
+    }
+}
+#undef RUNNER_ASSERT_WHAT_EQUALS
diff --git a/tests/dao/tests_dao.cpp b/tests/dao/tests_dao.cpp
new file mode 100644 (file)
index 0000000..73456db
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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   tests_plugin_dao.cpp
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains tests for plugin dao class.
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
+
+int main (int argc, char *argv[])
+{
+    int ret = system("/usr/bin/wrt_dao_tests_prepare_db.sh start");
+    if (ret != 0) {
+        LogError("Preparation script has return error: " << ret
+                                                         << ". Quitting");
+        return -1;
+    }
+
+    WrtDB::WrtDatabase::attachToThreadRW();
+    CustomHandlerDB::Interface::attachDatabaseRW();
+
+    LogInfo("Starting tests");
+    int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc,
+                                                                           argv);
+
+    CustomHandlerDB::Interface::detachDatabase();
+    WrtDB::WrtDatabase::detachFromThread();
+
+    ret = system("/usr/bin/wrt_dao_tests_prepare_db.sh stop");
+    if (ret != 0) {
+        LogError("Finalization script has return error: " << ret);
+        return -1;
+    }
+    return status;
+}
diff --git a/tests/dao/wrt_dao_tests_prepare_db.sh b/tests/dao/wrt_dao_tests_prepare_db.sh
new file mode 100755 (executable)
index 0000000..c2bde92
--- /dev/null
@@ -0,0 +1,129 @@
+#!/bin/sh
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+WRT_DB=/opt/dbspace/.wrt.db
+WRT_DB_BCK=/tmp/wrt.db_backup
+
+if [ "x$1" == "xstart" ]; then
+    echo start;
+    cp $WRT_DB $WRT_DB_BCK
+    wrt_commons_create_clean_db.sh;
+
+    #simple plugins
+    INS_MIN_PLUGINPROP="insert into PluginProperties(PluginPropertiesId, InstallationState, PluginLibraryName"
+    INS_ALL_PLUGINPROP="insert into PluginProperties(PluginPropertiesId, InstallationState, PluginLibraryName, PluginLibraryPath)"
+    INS_PLUGIN_OBJECTS="insert into PluginImplementedObjects(PluginObject, PluginPropertiesId)"
+
+    sqlite3 $WRT_DB "${INS_MIN_PLUGINPROP}) VALUES(1, 1, 'plugin1')";
+    sqlite3 $WRT_DB "${INS_MIN_PLUGINPROP}, PluginLibraryPath) VALUES(2, 1, 'plugin2', 'path_to_plugin2')";
+    sqlite3 $WRT_DB "${INS_MIN_PLUGINPROP}) VALUES(3, 1, 'plugin3')";
+    sqlite3 $WRT_DB "${INS_ALL_PLUGINPROP} VALUES(4, 1, 'p4', 'path_to_p4')";
+    sqlite3 $WRT_DB "${INS_ALL_PLUGINPROP} VALUES(5, 1, 'p5', 'path_to_p5')";
+
+    #plugin dependendencies
+    #sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES(1, )";
+    sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES('', 2)";
+    sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES('Plugin_3_Object_A', 3)";
+    sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES('Plugin_4_Object_A', 4)";
+    sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES('Plugin_4_Object_B', 4)";
+    sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES('Plugin_4_Object_C', 4)";
+    sqlite3 $WRT_DB "${INS_PLUGIN_OBJECTS} VALUES('Plugin_5_Object_A', 5)";
+
+
+    #simple features
+    INS_ALL_FEATURESLIST="insert into FeaturesList(FeatureUUID, FeatureName, PluginPropertiesId)"
+    sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(1, 'feature1', 1)";
+    sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(2, 'feature2', 4)";
+    sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(3, 'feature3', 4)";
+    sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(4, 'feature4', 4)";
+
+    #device capabilities
+    INS_ALL_DEVICECAPS="insert into DeviceCapabilities(DeviceCapID, DeviceCapName, DeviceCapDefaultValue)"
+    sqlite3 $WRT_DB "${INS_ALL_DEVICECAPS} VALUES(1, 'devicecap1', 1)";
+    sqlite3 $WRT_DB "${INS_ALL_DEVICECAPS} VALUES(2, 'devicecap2', 2)";
+    sqlite3 $WRT_DB "${INS_ALL_DEVICECAPS} VALUES(3, 'devicecap3', 3)";
+    sqlite3 $WRT_DB "${INS_ALL_DEVICECAPS} VALUES(4, 'devicecap4', 4)";
+
+    #Widgets
+    INS_ALL_WIDGETEXT="insert into WidgetExtendedInfo(app_id, share_href, signature_type)"
+    INS_ALL_WIDGET="insert into WidgetInfo(app_id, widget_id, widget_version, widget_width, widget_height, author_name, author_email, author_href, base_folder, webkit_plugins_required, recognized, wac_signed, distributor_signed, min_version, tizen_appid)"
+    INS_ALL_WIDGET_LOC="insert into LocalizedWidgetInfo(app_id, widget_locale, widget_name, widget_shortname, widget_description, widget_license, widget_license_file, widget_license_href)"
+    INS_ALL_WIDGET_ICONS="insert into WidgetIcon(app_id, icon_src, icon_width, icon_height)"
+    INS_ALL_WIDGET_LOC_ICONS="insert into WidgetLocalizedIcon(app_id, icon_id, widget_locale)"
+    INS_ALL_WIDGET_STARTFILE="insert into WidgetStartFile(app_id, src)"
+    INS_ALL_WIDGET_LOC_STARTFILE="insert into WidgetLocalizedStartFile(app_id, start_file_id, widget_locale, type, encoding)"
+    INS_ALL_WIDGET_DEFPREF="insert into WidgetDefaultPreference(app_id, key_name, key_value, readonly)"
+    INS_ALL_WIDGET_PREF="insert into WidgetPreference(tizen_appid, key_name, key_value, readonly)"
+    INS_ALL_WIDGET_FEATURE="insert into WidgetFeature(app_id, name, required)"
+    INS_ALL_WIDGET_FEATURE_PARAM="insert into FeatureParam(widget_feature_id, name, value)"
+    INS_ALL_WIDGET_WINMODES="insert into WidgetWindowModes(app_id, window_mode)"
+    INS_ALL_WIDGET_WARP="insert into WidgetWARPInfo(app_id, iri, subdomain_access)"
+    INS_ALL_WIDGET_CERT="insert into WidgetCertificateFingerprint(app_id, owner, chainid, type, md5_fingerprint, sha1_fingerprint, common_name)"
+    INS_ALL_WIDGET_POWDERLEV="insert into PowderLevels(app_id, category, level)"
+    INS_ALL_WIDGET_POWDERLEV_CONT="insert into PowderLevelContexts(levelid, context)"
+
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2000, 'w_id_2000', '1.0.0', 100, 200, 'a_name_2000', 'a_email_2000', 'a_href_2000', 'basef_2000', 1, 1, 1, 1, '1.0', 'tizenid201')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2001, 'w_id_2001', '2.0.0', 100, 200, 'a_name_2001', 'a_email_2001', 'a_href_2001', 'basef_2001', 1, 1, 1, 1, '0.5', 'tizenid202')";
+    sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, tizen_appid) VALUES(2002, 0, 'tizenid203')";
+    sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, tizen_appid) VALUES(2003, 0, 'tizenid204')"; # for properties tests
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2000, 'share_href_2000', 0)";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2001, 'share_href_2001', 0)";
+    sqlite3 $WRT_DB "insert into WidgetExtendedInfo(app_id) VALUES(2002)";
+    sqlite3 $WRT_DB "insert into WidgetExtendedInfo(app_id) VALUES(2003)";
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC} VALUES(2000, 'en', 'w_name_2000_en', 'w_shortname_2000_en', 'w_desc_2000_en', 'w_lic_2000_en', 'w_licf_2000_en', 'w_lic_href_2000_en')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC} VALUES(2000, 'pl', 'w_name_2000_pl', 'w_shortname_2000_pl', 'w_desc_2000_pl', 'w_lic_2000_pl', 'w_licf_2000_pl', 'w_lic_href_2000_pl')";
+    sqlite3 $WRT_DB "insert into LocalizedWidgetInfo(app_id, widget_locale) VALUES(2002, 'en')";
+    sqlite3 $WRT_DB "insert into LocalizedWidgetInfo(app_id, widget_locale) VALUES(2003, 'en')";
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_ICONS} VALUES(2000, 'icon_src_2000', 50, 50)";
+    sqlite3 $WRT_DB "insert into WidgetIcon(app_id, icon_src) VALUES(2002, 'icon_src_2002')";
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_ICONS} VALUES(2000, 1, 'en')";
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2000, 'start_file_2000')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2001, 'start_file_2001')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2002, 'start_file_2002')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2003, 'start_file_2003')";
+
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2000, 1, 'en', '', '')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2001, 2, 'en', '', '')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2002, 3, 'en', '', '')";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2003, 4, 'en', '', '')";
+
+    #widget properties
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid201', 'key1_for_2000', 'value_for_key1_2000', 0)";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid201', 'key2_for_2000', 'value_for_key2_2000', 0)";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid202', 'key1_for_2001', 'value1_for_key_2001', 1)";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid203', 'key1_for_2002', 'value1_for_key_2002', 0)";
+    sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid203', 'key2_for_2002', 'value2_for_key_2002', 1)";
+
+    #create if not exists and fix autoincrement value
+    sqlite3 $WRT_DB "INSERT INTO WidgetInfo(tizen_appid) VALUES('temp')";
+    sqlite3 $WRT_DB "DELETE FROM WidgetInfo WHERE tizen_appid = 'temp'";
+    sqlite3 $WRT_DB "UPDATE sqlite_sequence SET seq = 2004 WHERE name = 'WidgetInfo'";
+
+    exit $?
+
+elif [ "x$1" == "xstop" ]; then
+    echo stop;
+    cp $WRT_DB_BCK $WRT_DB
+    exit $?
+else
+    exit 1
+fi
diff --git a/tests/dpl/CMakeLists.txt b/tests/dpl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1dea774
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+SET(TESTS_DPL_DIR "${TESTS_DIR}/dpl")
+
+ADD_SUBDIRECTORY(core)
+ADD_SUBDIRECTORY(db)
+ADD_SUBDIRECTORY(dbus)
+ADD_SUBDIRECTORY(event)
+#ADD_SUBDIRECTORY(localization) TODO localization mockups need to be fixed 
+ADD_SUBDIRECTORY(utils)
+ADD_SUBDIRECTORY(test)
diff --git a/tests/dpl/README b/tests/dpl/README
new file mode 100644 (file)
index 0000000..6641953
--- /dev/null
@@ -0,0 +1,13 @@
+Unit tests for dpl library functionality.
+There are 6 binaries: dpl-dbus-test-service, dpl-tests-core, dpl-tests-db,
+dpl-tests-dbus, dpl-tests-event, dpl-tests-utils.
+All binaries are using our test framework - it allows to use different types of
+output. Text output shows results on console - green passed.
+To run:
+1. Install wrt-extra on target
+2. Run for f in /usr/bin/dpl-tests-*; do $f --output=text; done
+
+Automatic: YES
+Included in Daily Build: YES (http://build01.sprc.samsung.pl/browse/LINUXNGWAP-INT)
+Included in Gerrit Builds: YES (http://build01.sprc.samsung.pl/browse/LINUXNGWAP-GERRIT)
+Number of test cases: 151
\ No newline at end of file
diff --git a/tests/dpl/core/.swp b/tests/dpl/core/.swp
new file mode 100644 (file)
index 0000000..e25a05b
Binary files /dev/null and b/tests/dpl/core/.swp differ
diff --git a/tests/dpl/core/CMakeLists.txt b/tests/dpl/core/CMakeLists.txt
new file mode 100644 (file)
index 0000000..48d2c93
--- /dev/null
@@ -0,0 +1,61 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Test files
+#
+# Define all DPL tests sources.
+# Runner is responsible for runnint it all and
+# generating proper output files
+#
+
+SET(TARGET_NAME "dpl-tests-core")
+
+# Set DPL tests sources
+SET(DPL_TESTS_CORE_SOURCES
+    ${TESTS_DPL_DIR}/core/main.cpp
+    ${TESTS_DPL_DIR}/core/test_address.cpp
+    ${TESTS_DPL_DIR}/core/test_binary_queue.cpp
+    ${TESTS_DPL_DIR}/core/test_foreach.cpp
+    ${TESTS_DPL_DIR}/core/test_fast_delegate.cpp
+    ${TESTS_DPL_DIR}/core/test_log_unhandled_exception.cpp
+    ${TESTS_DPL_DIR}/core/test_once.cpp
+    ${TESTS_DPL_DIR}/core/test_serialization.cpp
+    ${TESTS_DPL_DIR}/core/test_scoped_array.cpp
+    ${TESTS_DPL_DIR}/core/test_scoped_close.cpp
+    ${TESTS_DPL_DIR}/core/test_scoped_fclose.cpp
+    ${TESTS_DPL_DIR}/core/test_scoped_free.cpp
+    ${TESTS_DPL_DIR}/core/test_scoped_ptr.cpp
+    ${TESTS_DPL_DIR}/core/test_semaphore.cpp
+    ${TESTS_DPL_DIR}/core/test_shared_ptr.cpp
+    ${TESTS_DPL_DIR}/core/test_string.cpp
+    ${TESTS_DPL_DIR}/core/test_thread.cpp
+    ${TESTS_DPL_DIR}/core/test_type_list.cpp
+    ${TESTS_DPL_DIR}/core/test_zip_input.cpp
+)
+
+WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_EFL})
+WRT_TEST_BUILD(${TARGET_NAME} ${DPL_TESTS_CORE_SOURCES})
+WRT_TEST_INSTALL(${TARGET_NAME})
+
+INSTALL(FILES
+        ${TESTS_DPL_DIR}/core/data/sample.zip
+        DESTINATION /opt/share/wrt/wrt-commons/tests/core
+    )
diff --git a/tests/dpl/core/DESCRIPTION b/tests/dpl/core/DESCRIPTION
new file mode 100644 (file)
index 0000000..48e5394
--- /dev/null
@@ -0,0 +1,2 @@
+!!!options!!! stop
+Test code
diff --git a/tests/dpl/core/data/sample.zip b/tests/dpl/core/data/sample.zip
new file mode 100644 (file)
index 0000000..02417d8
Binary files /dev/null and b/tests/dpl/core/data/sample.zip differ
diff --git a/tests/dpl/core/main.cpp b/tests/dpl/core/main.cpp
new file mode 100644 (file)
index 0000000..42ffe3a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main
+ */
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+    return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}
+
diff --git a/tests/dpl/core/test_address.cpp b/tests/dpl/core/test_address.cpp
new file mode 100644 (file)
index 0000000..d887ca0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_address.cpp
+ * @author      Tomasz Swierczek (t.swierczek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test address
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/address.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: Address_InitialEmpty
+Description: tests empty constructor of DPL::Address
+Expected: string version of empy address equals ":0"
+*/
+RUNNER_TEST(Address_InitialEmpty)
+{
+    DPL::Address address;
+    RUNNER_ASSERT(address.ToString() == ":0");
+}
+
+/*
+Name: Address_InitialAddress
+Description: tests constructor of DPL::Address with name only
+Expected: string version of address equals given name and appended ":0"
+*/
+RUNNER_TEST(Address_InitialAddress)
+{
+    DPL::Address address("www.sample.com");
+    RUNNER_ASSERT(address.ToString() == "www.sample.com:0");
+}
+
+/*
+Name: Address_InitialAddress
+Description: tests constructor of DPL::Address with name  and port
+Expected: string version of address should look lik "adress name:port"
+*/
+RUNNER_TEST(Address_InitialAddressPort)
+{
+    DPL::Address address("www.somewhere.com", 8080);
+    RUNNER_ASSERT(address.ToString() == "www.somewhere.com:8080");
+}
+
+/*
+Name: Address_InitialAddress
+Description: tests getter of address
+Expected: address name and port should matches those passed in constructor
+*/
+RUNNER_TEST(Address_Getters)
+{
+    DPL::Address address("www.somewhere.com", 8080);
+    RUNNER_ASSERT(address.GetAddress() == "www.somewhere.com");
+    RUNNER_ASSERT(address.GetPort() == 8080);
+}
diff --git a/tests/dpl/core/test_binary_queue.cpp b/tests/dpl/core/test_binary_queue.cpp
new file mode 100644 (file)
index 0000000..cd8931d
--- /dev/null
@@ -0,0 +1,468 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_binary_queue.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test binary queue
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/binary_queue.h>
+RUNNER_TEST_GROUP_INIT(DPL)
+
+inline std::string BinaryQueueToString(const DPL::BinaryQueue &queue)
+{
+    char *buffer = new char[queue.Size()];
+    queue.Flatten(buffer, queue.Size());
+    std::string result = std::string(buffer, buffer + queue.Size());
+    delete[] buffer;
+    return result;
+}
+
+/*
+Name: BinaryQueue_InitialEmpty
+Description: tests emptiness of new constructed queue
+Expected: new queue should be empty
+*/
+RUNNER_TEST(BinaryQueue_InitialEmpty)
+{
+    DPL::BinaryQueue queue;
+    RUNNER_ASSERT(queue.Empty() == true);
+}
+
+/*
+Name: BinaryQueue_InitialSize
+Description: tests emptiness of new constructed queue
+Expected: new queue size should be equal 0
+*/
+RUNNER_TEST(BinaryQueue_InitialSize)
+{
+    DPL::BinaryQueue queue;
+    RUNNER_ASSERT(queue.Size() == 0);
+}
+
+/*
+Name: BinaryQueue_InitialCopy
+Description: tests emptiness of new copy-constructed empty queue
+Expected: queue constructed on base on empty queue should be empty
+*/
+RUNNER_TEST(BinaryQueue_InitialCopy)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy = queue;
+
+    RUNNER_ASSERT(copy.Size() == 0);
+}
+
+/*
+Name: BinaryQueue_InitialConsumeZero
+Description: tests consume method accepts 0 bytes
+Expected: it should be avaliable to discard 0 bytes from empty queue
+*/
+RUNNER_TEST(BinaryQueue_InitialConsumeZero)
+{
+    DPL::BinaryQueue queue;
+    queue.Consume(0);
+}
+
+/*
+Name: BinaryQueue_InitialFlattenConsumeZero
+Description: tests returning data from queue and discarding
+Expected: it should be able to call flattenconsume with empty buffer if 0 bytes are read
+*/
+RUNNER_TEST(BinaryQueue_InitialFlattenConsumeZero)
+{
+    DPL::BinaryQueue queue;
+    queue.FlattenConsume(NULL, 0);
+}
+
+/*
+Name: BinaryQueue_InitialFlattenZero
+Description: tests returning data from queue
+Expected: it should be able to call flatten with empty buffer if 0 bytes are read
+*/
+RUNNER_TEST(BinaryQueue_InitialFlattenZero)
+{
+    DPL::BinaryQueue queue;
+    queue.Flatten(NULL, 0);
+}
+
+/*
+Name: BinaryQueue_InitialConsumeOne
+Description: tests discarding more bytes than it is avaliable
+Expected: exception throw
+*/
+RUNNER_TEST(BinaryQueue_InitialConsumeOne)
+{
+    DPL::BinaryQueue queue;
+
+    Try
+    {
+        queue.Consume(1);
+    }
+    Catch(DPL::BinaryQueue::Exception::OutOfData)
+    {
+        return;
+    }
+
+    RUNNER_FAIL;
+}
+
+/*
+Name: BinaryQueue_InitialFlattenConsumeOne
+Description: tests reading and discarding more bytes than it is avaliable
+Expected: exception throw
+*/
+RUNNER_TEST(BinaryQueue_InitialFlattenConsumeOne)
+{
+    DPL::BinaryQueue queue;
+
+    Try
+    {
+        char data;
+        queue.FlattenConsume(&data, 1);
+    }
+    Catch(DPL::BinaryQueue::Exception::OutOfData)
+    {
+        return;
+    }
+
+    RUNNER_FAIL;
+}
+
+/*
+Name: BinaryQueue_InitialFlattenOne
+Description: tests reading more bytes than it is avaliable
+Expected: exception throw
+*/
+RUNNER_TEST(BinaryQueue_InitialFlattenOne)
+{
+    DPL::BinaryQueue queue;
+
+    Try
+    {
+        char data;
+        queue.Flatten(&data, 1);
+    }
+    Catch(DPL::BinaryQueue::Exception::OutOfData)
+    {
+        return;
+    }
+
+    RUNNER_FAIL;
+}
+
+/*
+Name: BinaryQueue_ZeroCopyFrom
+Description: tests coping content of empty queue to another (AppendCopyFrom)
+Expected: source queue should be empty
+*/
+RUNNER_TEST(BinaryQueue_ZeroCopyFrom)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    copy.AppendCopyFrom(queue);
+    RUNNER_ASSERT(queue.Empty());
+}
+
+/*
+Name: BinaryQueue_ZeroMoveFrom
+Description: tests moving content of empty queue to another
+Expected: source queue should be empty
+*/
+RUNNER_TEST(BinaryQueue_ZeroMoveFrom)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    copy.AppendMoveFrom(queue);
+    RUNNER_ASSERT(queue.Empty());
+}
+
+/*
+Name: BinaryQueue_ZeroCopyTo
+Description: tests moving content of empty queue to another (AppendCopyTo)
+Expected: source queue should be empty
+*/
+RUNNER_TEST(BinaryQueue_ZeroCopyTo)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    queue.AppendCopyTo(copy);
+    RUNNER_ASSERT(queue.Empty());
+}
+
+/*
+Name: BinaryQueue_InsertSingleCharacters
+Description: tests inserting single bytes to queue
+Expected: stringified content and size shoudl match expected
+*/
+RUNNER_TEST(BinaryQueue_InsertSingleCharacters)
+{
+    DPL::BinaryQueue queue;
+
+    queue.AppendCopy("a", 1);
+    queue.AppendCopy("b", 1);
+    queue.AppendCopy("c", 1);
+    queue.AppendCopy("d", 1);
+
+    RUNNER_ASSERT(queue.Size() == 4);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "abcd");
+}
+
+/*
+Name: BinaryQueue_Consume
+Description: tests comsuming portions of 1 or 2 bytes
+Expected: stringified content and size should match expected
+ Bytes should be pope from begin.
+*/
+RUNNER_TEST(BinaryQueue_Consume)
+{
+    DPL::BinaryQueue queue;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    RUNNER_ASSERT(queue.Size() == 6);
+
+    queue.Consume(1);
+    RUNNER_ASSERT(queue.Size() == 5);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "bcdef");
+
+    queue.Consume(2);
+    RUNNER_ASSERT(queue.Size() == 3);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "def");
+
+    queue.Consume(1);
+    RUNNER_ASSERT(queue.Size() == 2);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "ef");
+
+    queue.Consume(2);
+    RUNNER_ASSERT(queue.Size() == 0);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "");
+}
+
+/*
+Name: BinaryQueue_Flatten
+Description: tests comsuming portions of 1 and more bytes
+Expected: stringified content and size should match expected
+*/
+RUNNER_TEST(BinaryQueue_Flatten)
+{
+    DPL::BinaryQueue queue;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+    queue.AppendCopy("g", 1);
+
+    RUNNER_ASSERT(queue.Size() == 7);
+
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdefg");
+}
+
+/*
+Name: BinaryQueue_FlattenConsume
+Description: tests comsuming portions of 1 and more bytes
+Expected: stringified content and size should match expected
+ reading and discarding bytes should affect queue's size and content
+*/
+RUNNER_TEST(BinaryQueue_FlattenConsume)
+{
+    DPL::BinaryQueue queue;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    RUNNER_ASSERT(queue.Size() == 6);
+
+    char buffer[7] = { '\0' };
+    queue.FlattenConsume(buffer, 3);
+
+    RUNNER_ASSERT(queue.Size() == 3);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "def");
+}
+
+/*
+Name: BinaryQueue_AppendCopyFrom
+Description: tests creating copy of not empty queue (use of: AppendCopyFrom)
+Expected: stringified content and size should match expected
+ from original queue and it's copy
+*/
+RUNNER_TEST(BinaryQueue_AppendCopyFrom)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    copy.AppendCopyFrom(queue);
+
+    RUNNER_ASSERT(queue.Size() == 6);
+    RUNNER_ASSERT(copy.Size() == 6);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdef");
+    RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
+}
+
+/*
+Name: BinaryQueue_AppendCopyTo
+Description: tests creating copy of not empty queue (use of: AppendCopyTo)
+Expected: stringified content and size should match expected
+ from original queue and it's copy
+*/
+RUNNER_TEST(BinaryQueue_AppendCopyTo)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    queue.AppendCopyTo(copy);
+
+    RUNNER_ASSERT(queue.Size() == 6);
+    RUNNER_ASSERT(copy.Size() == 6);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdef");
+    RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
+}
+
+/*
+Name: BinaryQueue_AppendMoveFrom
+Description: tests moving content of not empty queue (use of: AppendMoveFrom)
+Expected: stringified content and size should match expected
+ for new queue. Old queue should be empty after operation
+*/
+RUNNER_TEST(BinaryQueue_AppendMoveFrom)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    copy.AppendMoveFrom(queue);
+
+    RUNNER_ASSERT(queue.Size() == 0);
+    RUNNER_ASSERT(copy.Size() == 6);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "");
+    RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
+}
+
+/*
+Name: BinaryQueue_AppendMoveFrom
+Description: tests moving content of not empty queue (use of: AppendMoveTo)
+Expected: stringified content and size should match expected
+ for new queue. Old queue should be empty after operation
+*/
+RUNNER_TEST(BinaryQueue_AppendMoveTo)
+{
+    DPL::BinaryQueue queue;
+    DPL::BinaryQueue copy;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    queue.AppendMoveTo(copy);
+
+    RUNNER_ASSERT(queue.Size() == 0);
+    RUNNER_ASSERT(copy.Size() == 6);
+    RUNNER_ASSERT(BinaryQueueToString(queue) == "");
+    RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
+}
+
+class Visitor :
+    public DPL::BinaryQueue::BucketVisitor
+{
+  private:
+    int m_index;
+
+  public:
+    Visitor() :
+        m_index(0)
+    {}
+
+    virtual void OnVisitBucket(const void *buffer, size_t bufferSize)
+    {
+        const char *str = static_cast<const char *>(buffer);
+
+        if (m_index == 0) {
+            RUNNER_ASSERT(bufferSize == 4);
+            RUNNER_ASSERT(str[0] == 'a');
+            RUNNER_ASSERT(str[1] == 'b');
+            RUNNER_ASSERT(str[2] == 'c');
+            RUNNER_ASSERT(str[3] == 'd');
+        } else if (m_index == 1) {
+            RUNNER_ASSERT(bufferSize == 2);
+            RUNNER_ASSERT(str[0] == 'e');
+            RUNNER_ASSERT(str[1] == 'f');
+        } else {
+            RUNNER_FAIL;
+        }
+
+        ++m_index;
+    }
+};
+
+/*
+Name: BinaryQueue_Visitor
+Description: tests byte by byte content of queue by use of visitor
+Expected: stringified content and size should match expected
+ Each byte should be at right position
+*/
+RUNNER_TEST(BinaryQueue_Visitor)
+{
+    DPL::BinaryQueue queue;
+
+    queue.AppendCopy("abcd", 4);
+    queue.AppendCopy("ef", 2);
+
+    Visitor visitor;
+    queue.VisitBuckets(&visitor);
+}
+
+RUNNER_TEST(BinaryQueue_AbstracInputRead)
+{
+    DPL::BinaryQueue queue;
+
+    queue.AppendCopy("abcd", 4);
+
+    queue.Read(0);
+
+    RUNNER_ASSERT(BinaryQueueToString(*queue.Read(1).get()) == "a");
+    RUNNER_ASSERT(BinaryQueueToString(*queue.Read(2).get()) == "bc");
+    RUNNER_ASSERT(BinaryQueueToString(*queue.Read(1).get()) == "d");
+
+    RUNNER_ASSERT(queue.Size() == 0);
+}
+
+/*
+Name: BinaryQueue_AbstracOutputWrite
+Description: tests appending one queue to another
+Expected: written bytes shoudl affect content and size of queue
+*/
+RUNNER_TEST(BinaryQueue_AbstracOutputWrite)
+{
+    DPL::BinaryQueue queue;
+    queue.AppendCopy("abcd", 4);
+
+    DPL::BinaryQueue stream;
+
+    stream.Write(queue, 4);
+
+    RUNNER_ASSERT(BinaryQueueToString(*queue.Read(4).get()) == "abcd");
+}
diff --git a/tests/dpl/core/test_fast_delegate.cpp b/tests/dpl/core/test_fast_delegate.cpp
new file mode 100644 (file)
index 0000000..dc9b34a
--- /dev/null
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_fast_delegate.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of fast delegate tests.
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/fast_delegate.h>
+#include <dpl/log/log.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+// Sample copied and adopted from
+// http://www.codeproject.com/KB/cpp/FastDelegate.aspx
+//
+// Demonstrate the syntax for FastDelegates.
+//                -Don Clugston, May 2004.
+// It's a really boring example, but it shows the most important cases.
+// Declare some functions of varying complexity...
+void SimpleStaticFunction(int num, const char *str);
+void SimpleStaticFunction(int num, const char *str)
+{
+    LogDebug("In SimpleStaticFunction. Num=" << num << ", str =" << str);
+}
+
+void SimpleVoidFunction();
+void SimpleVoidFunction()
+{
+    LogDebug("In SimpleVoidFunction with no parameters.");
+}
+
+class CBaseClass
+{
+  protected:
+    const char *m_name;
+
+  public:
+    CBaseClass(const char *name) :
+        m_name(name)
+    {}
+
+    virtual ~CBaseClass()
+    {}
+
+    void SimpleMemberFunction(int num, const char *str)
+    {
+        LogDebug("In SimpleMemberFunction in " << m_name << ". Num="
+                                               << num << ", str = " << str);
+    }
+
+    int SimpleMemberFunctionReturnsInt(int num, const char *str)
+    {
+        LogDebug(
+            "In SimpleMemberFunctionReturnsInt in " << m_name << ". Num="
+                                                    << num <<
+            ", str = " << str);
+        return -1;
+    }
+
+    void ConstMemberFunction(int num, const char *str) const
+    {
+        LogDebug("In ConstMemberFunction in " << m_name << ". Num="
+                                              << num << ", str = " << str);
+    }
+
+    virtual void SimpleVirtualFunction(int num, const char *str)
+    {
+        LogDebug("In SimpleVirtualFunction in " << m_name << ". Num="
+                                                << num << ", str = " << str);
+    }
+
+    static void StaticMemberFunction(int num, const char *str)
+    {
+        LogDebug("In StaticMemberFunction Num="
+                 << num << ", str = " << str);
+    }
+};
+
+class COtherClass
+{
+    double rubbish; // to ensure this class has non-zero size.
+
+  public:
+    virtual ~COtherClass()
+    {}
+
+    virtual void UnusedVirtualFunction(void)
+    {}
+    virtual void TrickyVirtualFunction(int num, const char *str) = 0;
+};
+
+class VeryBigClass
+{
+    int letsMakeThingsComplicated[400];
+};
+
+// This declaration ensures that we get a convoluted class heirarchy.
+class CDerivedClass :
+    public VeryBigClass,
+    virtual public COtherClass,
+    virtual public CBaseClass
+{
+    double m_somemember[8];
+
+  public:
+    CDerivedClass() :
+        CBaseClass("Base of Derived")
+    {
+        m_somemember[0] = 1.2345;
+    }
+
+    void SimpleDerivedFunction(int num, const char *str)
+    {
+        LogDebug("In SimpleDerivedFunction Num="
+                 << num << ", str = " << str);
+    }
+
+    virtual void AnotherUnusedVirtualFunction(int num, const char *str)
+    {
+        LogDebug(
+            "In AnotherUnusedVirtualFunction in " << m_name << ". Num="
+                                                  << num << ", str = " <<
+            str);
+    }
+
+    virtual void TrickyVirtualFunction(int num, const char *str)
+    {
+        LogDebug("In TrickyVirtualFunction in " << m_name << ". Num="
+                                                << num << ", str = " << str);
+    }
+};
+
+/*
+Name: FastDelegate_Test
+Description: tests several scenarios of using fast delegates
+Expected: function calls succeeded
+*/
+RUNNER_TEST(FastDelegate_Test)
+{
+    // Delegates with up to 8 parameters are supported.
+    // Here's the case for a void function.
+    // We declare a delegate and attach it to SimpleVoidFunction()
+    DPL::FastDelegate0<> noparameterdelegate(&SimpleVoidFunction);
+
+    // invoke the delegate - this calls SimpleVoidFunction()
+    noparameterdelegate();
+
+    LogDebug("-- Examples using two-parameter delegates (int, char *) --");
+
+    // By default, the return value is void.
+    typedef DPL::FastDelegate2<int, const char *> MyDelegate;
+
+    // If you want to have a non-void return value, put it at the end.
+    typedef DPL::FastDelegate2<int, const char *, int> IntMyDelegate;
+
+    MyDelegate funclist[12]; // delegates are initialized to empty
+    CBaseClass a("Base A");
+    CBaseClass b("Base B");
+    CDerivedClass d;
+    CDerivedClass c;
+
+    IntMyDelegate newdeleg;
+    newdeleg = DPL::MakeDelegate(&a,
+                                 &CBaseClass::SimpleMemberFunctionReturnsInt);
+
+    // Binding a simple member function
+    funclist[0].bind(&a, &CBaseClass::SimpleMemberFunction);
+
+    // You can also bind static (free) functions
+    funclist[1].bind(&SimpleStaticFunction);
+
+    // and static member functions
+    funclist[2].bind(&CBaseClass::StaticMemberFunction);
+
+    // and const member functions (these only need a const class pointer).
+    funclist[3].bind((const CBaseClass *) &a,
+                     &CBaseClass::ConstMemberFunction);
+
+    funclist[4].bind(&a, &CBaseClass::ConstMemberFunction);
+
+    // and virtual member functions
+    funclist[5].bind(&b, &CBaseClass::SimpleVirtualFunction);
+
+    // You can also use the = operator. For static functions, a fastdelegate
+    // looks identical to a simple function pointer.
+    funclist[6] = &CBaseClass::StaticMemberFunction;
+
+    // The weird rule about the class of derived member function pointers
+    // is avoided. For MSVC, you can use &CDerivedClass::SimpleVirtualFunction
+    // here, but DMC will complain. Note that as well as .bind(), you can also
+    // use the MakeDelegate() global function.
+    funclist[7] = DPL::MakeDelegate(&d, &CBaseClass::SimpleVirtualFunction);
+
+    // The worst case is an abstract virtual function of a virtually-derived
+    // class with at least one non-virtual base class. This is a VERY obscure
+    // situation, which you're unlikely to encounter in the real world.
+    // FastDelegate versions prior to 1.3 had problems with this case on VC6.
+    // Now, it works without problems on all compilers.
+    funclist[8].bind(&c, &CDerivedClass::TrickyVirtualFunction);
+
+    // BUT... in such cases you should be using the base class as an
+    // interface, anyway.
+    funclist[9].bind(&c, &COtherClass::TrickyVirtualFunction);
+
+    // Calling a function that was first declared in the derived class is
+    // straightforward
+    funclist[10] = DPL::MakeDelegate(&c, &CDerivedClass::SimpleDerivedFunction);
+
+    // You can also bind directly using the constructor
+    MyDelegate dg(&b, &CBaseClass::SimpleVirtualFunction);
+
+    const char *msg = "Looking for equal delegate";
+
+    for (int i = 0; i < 12; i++) {
+        LogDebug(i << ":");
+
+        // The == and != operators are provided
+        // Note that they work even for inline functions.
+        if (funclist[i] == dg) {
+            msg = "Found equal delegate";
+        }
+
+        // operator ! can be used to test for an empty delegate
+        // You can also use the .empty() member function.
+        if (!funclist[i]) {
+            LogDebug("Delegate is empty");
+        } else {
+            // Invocation generates optimal assembly code.
+            funclist[i](i, msg);
+        }
+    }
+}
diff --git a/tests/dpl/core/test_foreach.cpp b/tests/dpl/core/test_foreach.cpp
new file mode 100644 (file)
index 0000000..08d66df
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_foreach.cpp
+ * @author      Bartosz Janiak (b.janiak@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of foreach tests.
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <vector>
+#include <set>
+#include <list>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+static const size_t testContainerSize = 1024;
+
+template<typename Container>
+void VerifyForeach(Container& container)
+{
+    size_t i = 0;
+    FOREACH(it, container)
+    {
+        RUNNER_ASSERT(*it == i);
+        i++;
+    }
+    RUNNER_ASSERT(i == container.size());
+}
+
+#define VERIFY_FOREACH(container)                               \
+    {                                                           \
+        size_t i = 0;                                           \
+        FOREACH(it, container)                                  \
+        {                                                       \
+            RUNNER_ASSERT(*it == i);                            \
+            i++;                                                \
+        }                                                       \
+    }
+
+static size_t numberOfCallsToTemporaryList = 0;
+std::list<size_t> temporaryList();
+std::list<size_t> temporaryList()
+{
+    ++numberOfCallsToTemporaryList;
+    std::list<size_t> list;
+    for (size_t i = 0; i < testContainerSize; i++) {
+        list.push_back(i);
+    }
+    return list;
+}
+
+static size_t numberOfCallsToTemporaryVector = 0;
+std::vector<size_t> temporaryVector();
+std::vector<size_t> temporaryVector()
+{
+    ++numberOfCallsToTemporaryVector;
+    std::vector<size_t> vector;
+    for (size_t i = 0; i < testContainerSize; i++) {
+        vector.push_back(i);
+    }
+    return vector;
+}
+
+static size_t numberOfCallsToTemporarySet = 0;
+std::set<size_t> temporarySet();
+std::set<size_t> temporarySet()
+{
+    ++numberOfCallsToTemporarySet;
+    std::set<size_t> set;
+    for (size_t i = 0; i < testContainerSize; i++) {
+        set.insert(i);
+    }
+    return set;
+}
+
+/*
+Name: Foreach_std_containers
+Description: tests iterating contianers set, list, vector using foreach
+Expected: value supplied by foreach matches sequence of integers
+*/
+RUNNER_TEST(Foreach_std_containers)
+{
+    std::vector<size_t> vector;
+    std::list<size_t> list;
+    std::set<size_t> set;
+
+    for (size_t i = 0; i < testContainerSize; i++) {
+        vector.push_back(i);
+        list.push_back(i);
+        set.insert(i);
+    }
+
+    VerifyForeach(vector);
+    VerifyForeach(list);
+    VerifyForeach(set);
+
+    VERIFY_FOREACH(temporaryList());
+    VERIFY_FOREACH(temporaryVector());
+    VERIFY_FOREACH(temporarySet());
+
+    RUNNER_ASSERT(numberOfCallsToTemporaryList == 1);
+    RUNNER_ASSERT(numberOfCallsToTemporaryVector == 1);
+    RUNNER_ASSERT(numberOfCallsToTemporarySet == 1);
+}
diff --git a/tests/dpl/core/test_log_unhandled_exception.cpp b/tests/dpl/core/test_log_unhandled_exception.cpp
new file mode 100644 (file)
index 0000000..3299357
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_log_unhandled_exception.cpp
+ * @author      Pawel Sikorski (p.marcinkiew@samsung.com)
+ * @version     1.0
+ * @brief
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/exception.h>
+#include <iostream>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+class MyException
+{};
+
+class MyDPLException
+{
+  public:
+    DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+    DECLARE_EXCEPTION_TYPE(Base, MyException)
+};
+
+class MySTDException :
+    public std::exception
+{
+  public:
+    virtual const char* what() const throw()
+    {
+        return "my std exception occurred";
+    }
+};
+
+/*
+Name: Log_Unknown_Exception
+Description: tests exceptions catching macros
+Expected: unknown exception should be catched
+
+TODO: workaround abort call
+*/
+RUNNER_TEST(Log_Unknown_Exception)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
+    {
+        //        throw MyException();
+    }
+    UNHANDLED_EXCEPTION_HANDLER_END
+    RUNNER_ASSERT(true);
+}
+
+/*
+Name: Log_DPL_Exception
+Description: tests exceptions catching macros
+Expected: DPL exception should be catched
+
+TODO: workaround abort call
+*/
+RUNNER_TEST(Log_DPL_Exception)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
+    {
+        //        Throw(MyDPLException::MyException);
+    }
+    UNHANDLED_EXCEPTION_HANDLER_END
+    RUNNER_ASSERT(true);
+}
+
+/*
+Name: Log_STD_Exception
+Description: tests exceptions catching macros
+Expected: STD exception should be catched
+
+TODO: workaround abort call
+*/
+RUNNER_TEST(Log_STD_Exception)
+{
+    UNHANDLED_EXCEPTION_HANDLER_BEGIN
+    {
+        //        throw MySTDException();
+    }
+    UNHANDLED_EXCEPTION_HANDLER_END
+    RUNNER_ASSERT(true);
+}
diff --git a/tests/dpl/core/test_once.cpp b/tests/dpl/core/test_once.cpp
new file mode 100644 (file)
index 0000000..436aea4
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_once.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of once tests
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/once.h>
+#include <dpl/waitable_event.h>
+#include <dpl/waitable_handle.h>
+#include <dpl/thread.h>
+#include <dpl/atomic.h>
+#include <memory>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+namespace // anonymous
+{
+gint g_counter;
+
+void Delegate()
+{
+    ++g_counter;
+}
+} // namespace anonymous
+
+RUNNER_TEST(Once_DoubleCall)
+{
+    g_counter = 0;
+
+    DPL::Once once;
+
+    once.Call(&Delegate);
+    once.Call(&Delegate);
+
+    RUNNER_ASSERT_MSG(g_counter == 1, "Counter value is: " << g_counter);
+}
+
+class MyThread :
+    public DPL::Thread
+{
+  protected:
+    virtual int ThreadEntry()
+    {
+        DPL::WaitForSingleHandle(m_event->GetHandle());
+        m_once->Call(DPL::Once::Delegate(this, &MyThread::Call));
+        return 0;
+    }
+
+    void Call()
+    {
+        ++*m_atom;
+    }
+
+  public:
+    MyThread(DPL::WaitableEvent *event, DPL::Once *once, DPL::Atomic *atom) :
+        m_event(event), m_once(once), m_atom(atom)
+    {}
+
+  private:
+    DPL::WaitableEvent *m_event;
+    DPL::Once *m_once;
+    DPL::Atomic *m_atom;
+};
+
+/*
+Name: Once_MultiThreadCall
+Description: tests once call wrapper for use by multiple threads
+Expected: function should be called just once from one of running threads
+*/
+RUNNER_TEST(Once_MultiThreadCall)
+{
+    const size_t NUM_THREADS = 20;
+    typedef std::shared_ptr<MyThread> ThreadPtr;
+
+    ThreadPtr threads[NUM_THREADS];
+    DPL::WaitableEvent event;
+    DPL::Once once;
+    DPL::Atomic atom;
+
+    for (size_t i = 0; i < NUM_THREADS; ++i) {
+        (threads[i] = ThreadPtr(new MyThread(&event, &once, &atom)))->Run();
+    }
+
+    event.Signal();
+
+    for (size_t i = 0; i < NUM_THREADS; ++i) {
+        threads[i]->Quit();
+    }
+
+    RUNNER_ASSERT_MSG(atom == 1, "Atom value is: " << atom);
+}
diff --git a/tests/dpl/core/test_scoped_array.cpp b/tests/dpl/core/test_scoped_array.cpp
new file mode 100644 (file)
index 0000000..f2a3b4b
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_scoped_array.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test scoped array
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/scoped_array.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: ScopedArray_Zero
+Description: tests emptiness of empty scoped array
+Expected: array should be empty
+*/
+RUNNER_TEST(ScopedArray_Zero)
+{
+    DPL::ScopedArray<char> array;
+
+    RUNNER_ASSERT(!array);
+    RUNNER_ASSERT(!!!array);
+}
+
+/*
+Name: ScopedArray_NonZero
+Description: tests emptiness of not empty scoped array
+Expected: array should be not empty
+*/
+RUNNER_TEST(ScopedArray_NonZero)
+{
+    DPL::ScopedArray<char> array(new char[7]);
+
+    RUNNER_ASSERT(array);
+    RUNNER_ASSERT(!!array);
+}
+
+/*
+Name: ScopedArray_Reset
+Description: tests reseting content of array
+Expected: array should be empty after reset
+*/
+RUNNER_TEST(ScopedArray_Reset)
+{
+    DPL::ScopedArray<char> array(new char[7]);
+    array.Reset();
+
+    RUNNER_ASSERT(!array);
+
+    array.Reset(new char);
+    RUNNER_ASSERT(array);
+}
+
+/*
+Name: ScopedArray_ArrayOperator
+Description: tests accessing elements of array
+Expected: returned values should be equal to those which were set
+*/
+RUNNER_TEST(ScopedArray_ArrayOperator)
+{
+    DPL::ScopedArray<char> array(new char[7]);
+
+    array[1] = array[2] = 3;
+
+    RUNNER_ASSERT(array[1] == 3);
+    RUNNER_ASSERT(array[2] == 3);
+}
diff --git a/tests/dpl/core/test_scoped_close.cpp b/tests/dpl/core/test_scoped_close.cpp
new file mode 100644 (file)
index 0000000..3549fed
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_scoped_close.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test scoped close
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/scoped_close.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+// DUNNO
diff --git a/tests/dpl/core/test_scoped_fclose.cpp b/tests/dpl/core/test_scoped_fclose.cpp
new file mode 100644 (file)
index 0000000..7667a9e
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_scoped_fclose.cpp
+ * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test scoped fclose
+ */
+
+#include <cstdio>
+#include <cerrno>
+
+#include <dpl/test/test_runner.h>
+#include <dpl/scoped_fclose.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+namespace {
+FILE* MakeTmp()
+{
+    FILE* result = NULL;
+    do {
+        result = tmpfile();
+    } while (NULL != result && EINTR == errno);
+    return result;
+}
+} //anonymous namespace
+
+/*
+Name: ScopedFClose_Zero
+Description: tests if operator ! works correct for closed file
+Expected: file should be closed
+*/
+RUNNER_TEST(ScopedFClose_Zero)
+{
+    DPL::ScopedFClose file;
+
+    RUNNER_ASSERT(!file);
+    RUNNER_ASSERT(!!!file);
+}
+
+/*
+Name: ScopedArray_NonZero
+Description: tests if operator ! works correct for open file
+Expected: file should be open
+*/
+RUNNER_TEST(ScopedFClose_NonZero)
+{
+    DPL::ScopedFClose file(MakeTmp());
+
+    RUNNER_ASSERT(file);
+    RUNNER_ASSERT(!!file);
+}
+
+/*
+Name: ScopedFClose_Reset
+Description: tests reseting of scoped file
+Expected: file should be closed after reset
+*/
+RUNNER_TEST(ScopedFClose_Reset)
+{
+    DPL::ScopedFClose file(MakeTmp());
+    file.Reset();
+
+    RUNNER_ASSERT(!file);
+
+    file.Reset(MakeTmp());
+    RUNNER_ASSERT(file);
+}
+
diff --git a/tests/dpl/core/test_scoped_free.cpp b/tests/dpl/core/test_scoped_free.cpp
new file mode 100644 (file)
index 0000000..25bd6d6
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_scoped_free.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test scoped free
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/scoped_free.h>
+#include <malloc.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: ScopedFree_Zero
+Description: Checks emptiness of not set scoped free
+Expected: resource should be freed
+*/
+RUNNER_TEST(ScopedFree_Zero)
+{
+    DPL::ScopedFree<void> free;
+
+    RUNNER_ASSERT(!free);
+    RUNNER_ASSERT(!!!free);
+}
+
+/*
+Name: ScopedFree_NonZero
+Description: Checks emptiness of set scoped free
+Expected: resource should not be reported as freed
+*/
+RUNNER_TEST(ScopedFree_NonZero)
+{
+    DPL::ScopedFree<void> free(malloc(7));
+
+    RUNNER_ASSERT(free);
+    RUNNER_ASSERT(!!free);
+}
+
+/*
+Name: ScopedFree_Reset
+Description: Checks reseting scoped free
+Expected: resource should be freed after reset
+*/
+RUNNER_TEST(ScopedFree_Reset)
+{
+    DPL::ScopedFree<void> free(malloc(7));
+    free.Reset();
+
+    RUNNER_ASSERT(!free);
+
+    free.Reset(malloc(8));
+    RUNNER_ASSERT(free);
+}
diff --git a/tests/dpl/core/test_scoped_ptr.cpp b/tests/dpl/core/test_scoped_ptr.cpp
new file mode 100644 (file)
index 0000000..af17bac
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_scoped_ptr.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test scoped ptr
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/scoped_ptr.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: ScopedPtr_Zero
+Description: Checks if operator! works
+Expected: resource should be not set
+*/
+RUNNER_TEST(ScopedPtr_Zero)
+{
+    DPL::ScopedPtr<char> ptr;
+
+    RUNNER_ASSERT(!ptr);
+    RUNNER_ASSERT(!!!ptr);
+}
+
+/*
+Name: ScopedPtr_NonZero
+Description: Checks if operator! works
+Expected: resource should be set
+*/
+RUNNER_TEST(ScopedPtr_NonZero)
+{
+    DPL::ScopedPtr<char> ptr(new char(7));
+
+    RUNNER_ASSERT(ptr);
+    RUNNER_ASSERT(!!ptr);
+}
+
+/*
+Name: ScopedPtr_Reset
+Description: Checks reseting scoped ptr
+Expected: resource should be not set after reset
+*/
+RUNNER_TEST(ScopedPtr_Reset)
+{
+    DPL::ScopedPtr<char> ptr(new char(7));
+    ptr.Reset();
+
+    RUNNER_ASSERT(!ptr);
+
+    ptr.Reset(new char);
+    RUNNER_ASSERT(ptr);
+}
+
+/*
+Name: ScopedPtr_Operators
+Description: Checks access operator
+Expected: address of resource should be same as this, received from Get() method
+*/
+RUNNER_TEST(ScopedPtr_Operators)
+{
+    DPL::ScopedPtr<char> ptr(new char(7));
+
+    RUNNER_ASSERT(*ptr == *ptr.Get());
+}
diff --git a/tests/dpl/core/test_semaphore.cpp b/tests/dpl/core/test_semaphore.cpp
new file mode 100644 (file)
index 0000000..c93b365
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_semaphore.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of semaphore tests
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/lexical_cast.h>
+#include <dpl/semaphore.h>
+#include <dpl/thread.h>
+#include <dpl/log/log.h>
+#include <string>
+#include <ctime>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+class SemaphoreThread :
+    public DPL::Thread
+{
+    int m_delta;
+    int m_times;
+    int *m_value;
+    std::string m_semaphoreName;
+
+  public:
+    SemaphoreThread(int delta,
+                    int times,
+                    int *value,
+                    const std::string &semaphoreName) :
+        m_delta(delta),
+        m_times(times),
+        m_value(value),
+        m_semaphoreName(semaphoreName)
+    {}
+
+  protected:
+    virtual int ThreadEntry()
+    {
+        DPL::Semaphore semaphore(m_semaphoreName);
+
+        for (int i = 0; i < m_times; ++i) {
+            // Take scoped semaphore lock
+            DPL::Semaphore::ScopedLock lock(&semaphore);
+            *m_value += m_delta;
+        }
+
+        return 0;
+    }
+};
+
+/*
+Name: Semaphore_NamedIncrementDecrement
+Description: Checks if semaphore are working
+Expected: value should not change after all
+*/
+RUNNER_TEST(Semaphore_NamedIncrementDecrement)
+{
+    std::string semaphoreName =
+        "dpl_test_semaphore_" +
+        DPL::lexical_cast<std::string>(std::time(NULL));
+
+    int value = 0;
+    SemaphoreThread threadA(-1, 10000, &value, semaphoreName);
+    SemaphoreThread threadB(+1, 10000, &value, semaphoreName);
+
+    threadA.Run();
+    threadB.Run();
+
+    threadA.Quit();
+    threadB.Quit();
+
+    RUNNER_ASSERT_MSG(value == 0, "Final value is: " << value);
+}
diff --git a/tests/dpl/core/test_serialization.cpp b/tests/dpl/core/test_serialization.cpp
new file mode 100644 (file)
index 0000000..202589b
--- /dev/null
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_address.cpp
+ * @author      Tomasz Swierczek (t.swierczek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of serialization tests
+ */
+
+#include <vector>
+#include <string>
+#include <list>
+#include <map>
+
+#include <dpl/test/test_runner.h>
+#include <dpl/serialization.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+// test stream class
+class BinaryStream : public DPL::IStream
+{
+  public:
+    virtual void Read(size_t num, void * bytes)
+    {
+        for (unsigned i = 0; i < num; ++i) {
+            ((unsigned char*)bytes)[i] = data[i + readPosition];
+        }
+        readPosition += num;
+    }
+    virtual void Write(size_t num, const void * bytes)
+    {
+        for (unsigned i = 0; i < num; ++i) {
+            data.push_back(((unsigned char*)bytes)[i]);
+        }
+    }
+    BinaryStream()
+    {
+        readPosition = 0;
+    }
+    virtual ~BinaryStream(){}
+
+  private:
+    std::vector<unsigned char> data;
+    unsigned readPosition;
+};
+
+//test ISerializable class
+class TestClass : public DPL::ISerializable
+{
+  public:
+    TestClass(int val, std::string str1, std::string str2)
+    {
+        a = val;
+        b = str1;
+        c.push_back(str1);
+        c.push_back(str2);
+        c.push_back(str1 + str2);
+    }
+    TestClass(DPL::IStream& stream)
+    {
+        DPL::Deserialization::Deserialize(stream, a);
+        DPL::Deserialization::Deserialize(stream, b);
+        DPL::Deserialization::Deserialize(stream, c);
+    }
+    virtual void Serialize(DPL::IStream& stream) const
+    {
+        DPL::Serialization::Serialize(stream, a);
+        DPL::Serialization::Serialize(stream, b);
+        DPL::Serialization::Serialize(stream, c);
+    }
+    virtual ~TestClass(){}
+    virtual bool operator==(const TestClass& other)
+    {
+        return (a == other.a &&
+                b == other.b &&
+                c.size() == other.c.size() &&
+                c[0] == other.c[0] &&
+                c[1] == other.c[1] &&
+                c[2] == other.c[2]);
+    }
+
+  private:
+    int a;
+    std::string b;
+    std::vector<std::string> c;
+};
+
+/*
+Name: Serialize_primitives
+Description: Tests serialization of primitives types
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_primitives)
+{
+    int a = 1;
+    bool b = true;
+    unsigned c = 23;
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, a);
+    DPL::Serialization::Serialize(stream, b);
+    DPL::Serialization::Serialize(stream, c);
+    int test_int;
+    DPL::Deserialization::Deserialize(stream, test_int);
+    RUNNER_ASSERT(test_int == a);
+    bool test_bool;
+    DPL::Deserialization::Deserialize(stream, test_bool);
+    RUNNER_ASSERT(test_bool == b);
+    unsigned test_unsigned;
+    DPL::Deserialization::Deserialize(stream, test_unsigned);
+    RUNNER_ASSERT(test_unsigned == c);
+}
+
+/*
+Name: Serialize_primitive_pointers
+Description: Tests serialization of primitives pointer types
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_primitive_pointers)
+{
+    int a = 1;
+    bool b = true;
+    unsigned c = 23;
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, &a);
+    DPL::Serialization::Serialize(stream, &b);
+    DPL::Serialization::Serialize(stream, &c);
+    int* test_int;
+    DPL::Deserialization::Deserialize(stream, test_int);
+    RUNNER_ASSERT(test_int != NULL && *test_int == a);
+    bool* test_bool;
+    DPL::Deserialization::Deserialize(stream, test_bool);
+    RUNNER_ASSERT(test_bool != NULL && *test_bool == b);
+    unsigned* test_unsigned;
+    DPL::Deserialization::Deserialize(stream, test_unsigned);
+    RUNNER_ASSERT(test_unsigned != NULL && *test_unsigned == c);
+    delete test_int;
+    delete test_bool;
+    delete test_unsigned;
+}
+
+/*
+Name: Serialize_strings
+Description: Tests serialization of strings
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_strings)
+{
+    std::string str1 = "ALA MA KOTA";
+    std::string str2 = "MULTILINE\nTEST";
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, str1);
+    DPL::Serialization::Serialize(stream, str2);
+    std::string test_str1;
+    DPL::Deserialization::Deserialize(stream, test_str1);
+    RUNNER_ASSERT(test_str1 == str1);
+    std::string test_str2;
+    DPL::Deserialization::Deserialize(stream, test_str2);
+    RUNNER_ASSERT(test_str2 == str2);
+}
+
+/*
+Name: Serialize_string_pointers
+Description: Tests serialization of string pointers
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_string_pointers)
+{
+    std::string str1 = "ALA MA KOTA";
+    std::string str2 = "MULTILINE\nTEST";
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, &str1);
+    DPL::Serialization::Serialize(stream, &str2);
+    std::string* test_str1;
+    DPL::Deserialization::Deserialize(stream, test_str1);
+    RUNNER_ASSERT(test_str1 != NULL && *test_str1 == str1);
+    std::string* test_str2;
+    DPL::Deserialization::Deserialize(stream, test_str2);
+    RUNNER_ASSERT(test_str2 != NULL && *test_str2 == str2);
+    delete test_str1;
+    delete test_str2;
+}
+
+/*
+Name: Serialize_containers
+Description: Tests serialization of containers
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_containers)
+{
+    std::vector<int> vec;
+    vec.push_back(134);
+    vec.push_back(265);
+    std::list<bool> list;
+    list.push_back(true);
+    list.push_back(false);
+    std::pair<int, unsigned> pair;
+    pair.first = -23;
+    pair.second = 1234;
+    std::map<int, std::string> map;
+    map.insert(std::pair<int, std::string>(45, "ALA MA CZARNEGO KOTA"));
+    map.insert(std::pair<int, std::string>(-78, "...A MOZE\nMA\nWIELE LINIJEK"));
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, vec);
+    DPL::Serialization::Serialize(stream, list);
+    DPL::Serialization::Serialize(stream, pair);
+    DPL::Serialization::Serialize(stream, map);
+    std::vector<int> test_vec;
+    DPL::Deserialization::Deserialize(stream, test_vec);
+    RUNNER_ASSERT(test_vec.size() == vec.size() &&
+                  test_vec[0] == vec[0] && test_vec[1] == vec[1]);
+    std::list<bool> test_list;
+    DPL::Deserialization::Deserialize(stream, test_list);
+    RUNNER_ASSERT(test_list.size() == list.size() &&
+                  test_list.front() == list.front() &&
+                  test_list.back() == test_list.back());
+    std::pair<int, unsigned> test_pair;
+    DPL::Deserialization::Deserialize(stream, test_pair);
+    RUNNER_ASSERT(test_pair.first == pair.first &&
+                  test_pair.second == pair.second);
+    std::map<int, std::string> test_map;
+    DPL::Deserialization::Deserialize(stream, test_map);
+    RUNNER_ASSERT(test_map.size() == map.size() &&
+                  test_map.at(45) == map.at(45) &&
+                  test_map.at(-78) == map.at(-78));
+}
+
+/*
+Name: Serialize_objects
+Description: Tests serialization of DPL::ISerializable derived objects
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_objects)
+{
+    TestClass a(123, "ASDGHUADB\n\n5679b^^()*", "TEST_STRING"),
+    b(679, "HUSPIDNSAHDPA", "\nASDSADASD\naDSADASD8");
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, a);
+    DPL::Serialization::Serialize(stream, b);
+    TestClass test_a(0, "", ""), test_b(0, "", "");
+    DPL::Deserialization::Deserialize(stream, test_a);
+    RUNNER_ASSERT(test_a == a);
+    DPL::Deserialization::Deserialize(stream, test_b);
+    RUNNER_ASSERT(test_b == b);
+}
+
+/*
+Name: Serialize_all
+Description: Tests serialization of compound objects
+Expected: serialized value after deserialization
+ should be equal to deserialied value
+*/
+RUNNER_TEST(Serialize_all)
+{
+    std::map<std::string, std::vector<TestClass*> > map;
+    std::vector<TestClass*> vec;
+    vec.push_back(new TestClass(123, "ASDGHUADB\n\n5679b^^()*", "TEST_STRING"));
+    vec.push_back(new TestClass(679, "HUSPIDNSAHDPA", "\nASDSADASD\naDSADASD8"));
+    map.insert(std::pair<std::string, std::vector<TestClass*> >("KEY1", vec));
+    map.insert(std::pair<std::string, std::vector<TestClass*> >("KEY2", vec));
+    BinaryStream stream;
+
+    DPL::Serialization::Serialize(stream, map);
+
+    std::map<std::string, std::vector<TestClass*> > test_map;
+    DPL::Deserialization::Deserialize(stream, test_map);
+    RUNNER_ASSERT(map.size() == test_map.size());
+    std::vector<TestClass*> test_vec1, test_vec2;
+    test_vec1 = map.at("KEY1");
+    test_vec2 = test_map.at("KEY1");
+    RUNNER_ASSERT(test_vec1.size() == test_vec2.size());
+    unsigned i;
+    for (i = 0; i < test_vec1.size(); ++i) {
+        RUNNER_ASSERT((*test_vec1[i]) == (*test_vec2[i]));
+    }
+    test_vec1 = map.at("KEY2");
+    test_vec2 = test_map.at("KEY2");
+    RUNNER_ASSERT(test_vec1.size() == test_vec2.size());
+    for (i = 0; i < test_vec1.size(); ++i) {
+        RUNNER_ASSERT((*test_vec1[i]) == (*test_vec2[i]));
+    }
+}
+
diff --git a/tests/dpl/core/test_shared_ptr.cpp b/tests/dpl/core/test_shared_ptr.cpp
new file mode 100644 (file)
index 0000000..8e59075
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_shared_ptr.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test shared ptr
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/shared_ptr.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: SharedPtr_Zero
+Description: Tests behaviour of null shared pointer
+Expected: pointer should imitate null pointer
+*/
+RUNNER_TEST(SharedPtr_Zero)
+{
+    DPL::SharedPtr<char> ptr;
+
+    RUNNER_ASSERT(!ptr);
+    RUNNER_ASSERT(!!!ptr);
+    RUNNER_ASSERT(ptr == DPL::SharedPtr<char>());
+}
+
+/*
+Name: SharedPtr_NonZero
+Description: Tests behaviour of not null shared pointer
+Expected: pointer should imitate null pointer
+*/
+RUNNER_TEST(SharedPtr_NonZero)
+{
+    DPL::SharedPtr<char> ptr(new char(7));
+
+    RUNNER_ASSERT(ptr);
+    RUNNER_ASSERT(!!ptr);
+    RUNNER_ASSERT(ptr != DPL::SharedPtr<char>());
+}
+
+/*
+Name: SharedPtr_Copy
+Description: Tests equality of shared pointer pointing same resource
+Expected: pointers should imitate primitive pointer bahaviour
+*/
+RUNNER_TEST(SharedPtr_Copy)
+{
+    DPL::SharedPtr<char> ptr1(new char(7));
+    DPL::SharedPtr<char> ptr2(new char(7));
+
+    RUNNER_ASSERT(ptr1 != ptr2);
+
+    ptr2 = ptr1;
+
+    RUNNER_ASSERT(ptr1 == ptr2);
+}
+
+/*
+Name: SharedPtr_Reset
+Description: Tests reseting shared pointer
+Expected: pointers should imitate primitive pointer bahaviour after reset
+*/
+RUNNER_TEST(SharedPtr_Reset)
+{
+    DPL::SharedPtr<char> ptr(new char(7));
+    ptr.Reset();
+
+    RUNNER_ASSERT(!ptr);
+
+    ptr.Reset(new char);
+    RUNNER_ASSERT(ptr);
+}
+
+/*
+Name: SharedPtr_RefCounting
+Description: Tests use count od shared pointer
+Expected: counters should be equal for equal pointers
+ Count number should match expected
+*/
+RUNNER_TEST(SharedPtr_RefCounting)
+{
+    DPL::SharedPtr<char> ptr1(new char(7));
+    DPL::SharedPtr<char> ptr2;
+
+    ptr2 = ptr1;
+
+    RUNNER_ASSERT(ptr1 == ptr2);
+    RUNNER_ASSERT(ptr1.GetUseCount() == ptr2.GetUseCount());
+    RUNNER_ASSERT(ptr1.GetUseCount() == 2);
+}
+
+/*
+Name: SharedPtr_Operators
+Description: Tests use of operator*
+Expected: pointers should imitate primitive pointer bahaviour
+*/
+RUNNER_TEST(SharedPtr_Operators)
+{
+    DPL::SharedPtr<char> ptr(new char(7));
+
+    RUNNER_ASSERT(*ptr == *ptr.Get());
+}
diff --git a/tests/dpl/core/test_string.cpp b/tests/dpl/core/test_string.cpp
new file mode 100644 (file)
index 0000000..dd2bd8a
--- /dev/null
@@ -0,0 +1,418 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_string.cpp
+ * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of string tests
+ */
+#include <stdlib.h>
+#include <cmath>
+#include <cstring>
+#include <vector>
+#include <dpl/test/test_runner.h>
+#include <dpl/string.h>
+#include <dpl/sstream.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+unsigned char GetBaseCode(int index);
+unsigned char GetBaseCode(int index)
+{
+    /* aaaack but it's fast and const should make it shared text page. */
+    static const unsigned char pr2six[256] = {
+        /* ASCII table */
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
+        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
+        64, 0, 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, 64, 64, 64, 64, 64,
+        64, 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, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+        64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
+    };
+    return pr2six[index];
+}
+
+/* Function adapted from APR library (http://apr.apache.org/) */
+int wbxml_base64_decode(const char *buffer, char **result);
+int wbxml_base64_decode(const char *buffer, char **result)
+{
+    int nbytesdecoded = 0, nprbytes = 0;
+    const char *bufin = NULL;
+    char *bufout = NULL;
+
+    if ((buffer == NULL) || (result == NULL)) {
+        return 0;
+    }
+
+    /* Initialize output buffer */
+    *result = NULL;
+
+    bufin = buffer;
+    while (GetBaseCode(*(bufin++)) <= 63) {}
+
+    nprbytes = (bufin - buffer) - 1;
+    nbytesdecoded = ((nprbytes + 3) / 4) * 3;
+
+    /* Malloc result buffer */
+    if ((*result = (char*) malloc(nbytesdecoded + 1)) == NULL) {
+        return 0;
+    }
+    memset(*result, 0, nbytesdecoded + 1);
+
+    bufout = *result;
+    bufin = buffer;
+
+    while (nprbytes > 4) {
+        *(bufout++) =
+            (char)(GetBaseCode(*bufin) << 2 | GetBaseCode(bufin[1]) >> 4);
+        *(bufout++) =
+            (char)(GetBaseCode(bufin[1]) << 4 | GetBaseCode(bufin[2]) >> 2);
+        *(bufout++) = (char)(GetBaseCode(bufin[2]) << 6 | GetBaseCode(bufin[3]));
+        bufin += 4;
+        nprbytes -= 4;
+    }
+
+    /* Note: (nprbytes == 1) would be an error, so just ingore that case */
+    if (nprbytes > 1) {
+        *(bufout++) =
+            (char)(GetBaseCode(*bufin) << 2 | GetBaseCode(bufin[1]) >> 4);
+    }
+    if (nprbytes > 2) {
+        *(bufout++) =
+            (char)(GetBaseCode(bufin[1]) << 4 | GetBaseCode(bufin[2]) >> 2);
+    }
+    if (nprbytes > 3) {
+        *(bufout++) = (char)(GetBaseCode(bufin[2]) << 6 | GetBaseCode(bufin[3]));
+    }
+
+    nbytesdecoded -= (4 - nprbytes) & 3;
+
+    return nbytesdecoded;
+}
+
+//#define TEST_CONVERSION(in_string, out_string, buffer_type, function
+
+const char utf32Encoded[] =
+    "RDAAAI0wAABvMAAAazAAAHswAAB4MAAAaDAAAAAwAABhMAAAijAAAGwwAACLMAAAkjAAAAAwAACP\
+MAAASzAAAIgwAABfMAAAjDAAAF0wAAAAMAAAZDAAAG0wAABqMAAAiTAAAIAwAAAAMAAARjAAAJAw\
+AABuMAAASjAAAE8wAACEMAAAfjAAAAAwAABRMAAAdTAAAFMwAABIMAAAZjAAAAAwAABCMAAAVTAA\
+AE0wAACGMAAAgTAAAH8wAABXMAAAADAAAJEwAAByMAAAgjAAAFswAABZMAAACgAAANsFAADaBQAA\
+IAAAANQFAADqBQAA6AUAAOEFAADnBQAAIAAAAOAFAADkBQAA5QUAACAAAADiBQAA3AUAACAAAADS\
+BQAA1QUAANYFAADcBQAAIAAAAOcFAADYBQAA3wUAACwAAAAgAAAA6QUAANMFAADXBQAA4wUAACAA\
+AADQBQAA6gUAACAAAADmBQAA0QUAANkFAAAgAAAA3AUAAN4FAADZBQAA3QUAAAoAAACk0AAApMIA\
+AFjHAAAgAAAA4KwAACDHAABwyAAAdKwAAEDHAAAgAAAAhccAACDCAAB8sAAArLkAACAAAADMuQAA\
+mLAAAHzFAAAgAAAAWNUAAOCsAAAgAAAAudIAAMS8AABc1QAAIAAAADCuAAAgwgAAQMcAACAAAABE\
+1QAAlMYAAFjOAAAgAAAASsUAAOSyAAAKAAAAUAAAAGMAAABoAAAAbgAAAAUBAAAHAQAAIAAAAHcA\
+AAAgAAAAdAAAABkBAAAgAAAAQgEAAPMAAABkAAAAegEAACAAAABqAAAAZQAAAHwBAABhAAAAIAAA\
+AGwAAAB1AAAAYgAAACAAAABvAAAAWwEAAG0AAAAgAAAAcwAAAGsAAAByAAAAegAAAHkAAABEAQAA\
+IAAAAGYAAABpAAAAZwAAAC4AAAAKAAAAQgAAAGwAAABvAAAAdwAAAHoAAAB5AAAAIAAAAG4AAABp\
+AAAAZwAAAGgAAAB0AAAALQAAAGYAAAByAAAAdQAAAG0AAABwAAAAcwAAACAAAAB2AAAAZQAAAHgA\
+AAAnAAAAZAAAACAAAABKAAAAYQAAAGMAAABrAAAAIAAAAFEAAAAuAAAACgAAAEYGAAA1BgAAIAAA\
+AC0GAABDBgAASgYAAEUGAAAgAAAARAYAAEcGAAAgAAAAMwYAADEGAAAgAAAAQgYAACcGAAA3BgAA\
+OQYAACAAAABIBgAAMAYAAEgGAAAgAAAANAYAACMGAABGBgAAIAAAADkGAAA4BgAASgYAAEUGAAAg\
+AAAARQYAAEMGAAAqBgAASAYAACgGAAAgAAAAOQYAAEQGAABJBgAAIAAAACsGAABIBgAAKAYAACAA\
+AAAjBgAALgYAADYGAAAxBgAAIAAAAEgGAABFBgAAOgYAAEQGAABBBgAAIAAAACgGAAAsBgAARAYA\
+AC8GAAAgAAAAIwYAADIGAAAxBgAAQgYAACAAAAAKAAAAEgQAACAAAABHBAAAMAQAAEkEAAAwBAAA\
+RQQAACAAAABOBAAAMwQAADAEAAAgAAAANgQAADgEAAA7BAAAIAAAADEEAABLBAAAIAAAAEYEAAA4\
+BAAAQgQAAEAEAABDBAAAQQQAAD8AAAAgAAAAFAQAADAEAAAsAAAAIAAAAD0EAAA+BAAAIAAAAEQE\
+AAAwBAAAOwQAAEwEAABIBAAAOAQAADIEAABLBAAAOQQAACAAAABNBAAAOgQAADcEAAA1BAAAPAQA\
+AD8EAAA7BAAATwQAAEAEAAAhAAAACgAAAKQDAACsAwAAxwMAALkDAADDAwAAxAMAALcDAAAgAAAA\
+sQMAALsDAADOAwAAwAMAALcDAAC+AwAAIAAAALIDAACxAwAAxgMAAK4DAADCAwAAIAAAAMgDAAC3\
+AwAAvAMAAK0DAAC9AwAAtwMAACAAAACzAwAAtwMAACwAAAAgAAAAtAMAAMEDAACxAwAAwwMAALoD\
+AAC1AwAAuwMAAK8DAAC2AwAAtQMAALkDAAAgAAAAxQMAAMADAACtAwAAwQMAACAAAAC9AwAAyQMA\
+ALgDAADBAwAAvwMAAM0DAAAgAAAAugMAAMUDAAC9AwAAzAMAAMIDAAAKAAAAVgAAAGkAAABjAAAA\
+dAAAAG8AAAByAAAAIAAAAGoAAABhAAAAZwAAAHQAAAAgAAAAegAAAHcAAAD2AAAAbAAAAGYAAAAg\
+AAAAQgAAAG8AAAB4AAAAawAAAOQAAABtAAAAcAAAAGYAAABlAAAAcgAAACAAAABxAAAAdQAAAGUA\
+AAByAAAAIAAAAPwAAABiAAAAZQAAAHIAAAAgAAAAZAAAAGUAAABuAAAAIAAAAGcAAAByAAAAbwAA\
+AN8AAABlAAAAbgAAACAAAABTAAAAeQAAAGwAAAB0AAAAZQAAAHIAAAAgAAAARAAAAGUAAABpAAAA\
+YwAAAGgAAAAKAAAAlokAAM6RAAAhcQAAUJYAAONeAAAM/wAAl3oAABZZAAAJZwAAzYUAAClZAAAK\
+AAAACgAAAAAAAAA=";
+
+const char utf8Encoded[] =
+    "44GE44KN44Gv44Gr44G744G444Go44CA44Gh44KK44Gs44KL44KS44CA44KP44GL44KI44Gf44KM\
+44Gd44CA44Gk44Gt44Gq44KJ44KA44CA44GG44KQ44Gu44GK44GP44KE44G+44CA44GR44G144GT\
+44GI44Gm44CA44GC44GV44GN44KG44KB44G/44GX44CA44KR44Gy44KC44Gb44GZCteb15og15TX\
+qteo16HXpyDXoNek16Ug16LXnCDXkteV15bXnCDXp9eY158sINep15PXl9ejINeQ16og16bXkdeZ\
+INec157XmdedCu2CpOyKpOydmCDqs6DsnKDsobDqsbTsnYAg7J6F7Iig64G866asIOunjOuCmOyV\
+vCDtlZjqs6Ag7Yq567OE7ZWcIOq4sOyIoOydgCDtlYTsmpTsuZgg7JWK64ukClBjaG7EhcSHIHcg\
+dMSZIMWCw7NkxbogamXFvGEgbHViIG/Fm20gc2tyennFhCBmaWcuCkJsb3d6eSBuaWdodC1mcnVt\
+cHMgdmV4J2QgSmFjayBRLgrZhti1INit2YPZitmFINmE2Ycg2LPYsSDZgtin2LfYuSDZiNiw2Ygg\
+2LTYo9mGINi52LjZitmFINmF2YPYqtmI2Kgg2LnZhNmJINir2YjYqCDYo9iu2LbYsSDZiNmF2LrZ\
+hNmBINio2KzZhNivINij2LLYsdmCIArQkiDRh9Cw0YnQsNGFINGO0LPQsCDQttC40Lsg0LHRiyDR\
+htC40YLRgNGD0YE/INCU0LAsINC90L4g0YTQsNC70YzRiNC40LLRi9C5INGN0LrQt9C10LzQv9C7\
+0Y/RgCEKzqTOrM+HzrnPg8+EzrcgzrHOu8+Oz4DOt86+IM6yzrHPhs6uz4Igz4jOt868zq3Ovc63\
+IM6zzrcsIM60z4HOsc+DzrrOtc67zq/Ots61zrkgz4XPgM6tz4Egzr3Pic64z4HOv8+NIM66z4XO\
+vc+Mz4IKVmljdG9yIGphZ3QgenfDtmxmIEJveGvDpG1wZmVyIHF1ZXIgw7xiZXIgZGVuIGdyb8Of\
+ZW4gU3lsdGVyIERlaWNoCuimlumHjueEoemZkOW7o++8jOeql+WkluacieiXjeWkqQoKAA==";
+
+const char asciiEncodedIso1[] =
+    "ISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZ\
+WltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fgA=";
+
+const char asciiEncodedUtf32[] =
+    "IQAAACIAAAAjAAAAJAAAACUAAAAmAAAAJwAAACgAAAApAAAAKgAAACsAAAAsAAAALQAAAC4AAAAv\
+AAAAMAAAADEAAAAyAAAAMwAAADQAAAA1AAAANgAAADcAAAA4AAAAOQAAADoAAAA7AAAAPAAAAD0A\
+AAA+AAAAPwAAAEAAAABBAAAAQgAAAEMAAABEAAAARQAAAEYAAABHAAAASAAAAEkAAABKAAAASwAA\
+AEwAAABNAAAATgAAAE8AAABQAAAAUQAAAFIAAABTAAAAVAAAAFUAAABWAAAAVwAAAFgAAABZAAAA\
+WgAAAFsAAABcAAAAXQAAAF4AAABfAAAAYAAAAGEAAABiAAAAYwAAAGQAAABlAAAAZgAAAGcAAABo\
+AAAAaQAAAGoAAABrAAAAbAAAAG0AAABuAAAAbwAAAHAAAABxAAAAcgAAAHMAAAB0AAAAdQAAAHYA\
+AAB3AAAAeAAAAHkAAAB6AAAAewAAAHwAAAB9AAAAfgAAAAAAAAA=";
+
+/*
+Name: String_ConverterFromASCII
+Description: tests construction of string from ascii data
+Expected: data stored in buffer should match expected
+*/
+RUNNER_TEST(String_ConverterFromASCII)
+{
+    char* inStr = NULL;
+    int inSize = wbxml_base64_decode(asciiEncodedIso1, &inStr);
+    RUNNER_ASSERT(inSize > 0);
+    RUNNER_ASSERT(NULL != inStr);
+    inStr[inSize] = '\0';
+    {
+        DPL::String asciiString = DPL::FromASCIIString(inStr);
+
+        std::string result = DPL::ToUTF8String(asciiString);
+
+        RUNNER_ASSERT(strlen(inStr) == result.size());
+
+        RUNNER_ASSERT(0 == memcmp(inStr, result.c_str(), result.size()));
+    }
+
+    free(inStr);
+}
+
+/*
+Name: String_ConverterFromUTF8
+Description: tests construction of string from UTF-8 data
+Expected: data stored in buffer should match expected
+*/
+RUNNER_TEST(String_ConverterFromUTF8)
+{
+    char* inStr = NULL;
+    int inSize = wbxml_base64_decode(asciiEncodedIso1, &inStr);
+    RUNNER_ASSERT(inSize > 0);
+    RUNNER_ASSERT(NULL != inStr);
+    {
+        DPL::String asciiString = DPL::FromUTF8String(inStr);
+
+        std::string result = DPL::ToUTF8String(asciiString);
+
+        RUNNER_ASSERT(strlen(inStr) == result.size());
+
+        RUNNER_ASSERT(0 == memcmp(inStr, result.c_str(), result.size()));
+    }
+
+    free(inStr);
+}
+
+/*
+Name: String_ConverterFromUTF32
+Description: tests construction of string from UTF-32 data
+Expected: data stored in buffer should match expected
+*/
+RUNNER_TEST(String_ConverterFromUTF32)
+{
+    wchar_t* inStr = NULL;
+    int inSize =
+        wbxml_base64_decode(utf32Encoded, reinterpret_cast<char**>(&inStr));
+    RUNNER_ASSERT(inSize > 0);
+    RUNNER_ASSERT(NULL != inStr);
+    char* outStr = NULL;
+    int outSize = wbxml_base64_decode(utf8Encoded, &outStr);
+    RUNNER_ASSERT(outSize > 0);
+    RUNNER_ASSERT(NULL != outStr);
+    outStr[outSize] = '\0';
+    {
+        DPL::String utfString = DPL::FromUTF32String(inStr);
+        std::string result = DPL::ToUTF8String(utfString);
+
+        RUNNER_ASSERT(strlen(outStr) == result.size());
+        RUNNER_ASSERT(0 == memcmp(outStr, result.c_str(), result.size()));
+
+        RUNNER_ASSERT(inSize / sizeof(wchar_t) - 1 == utfString.size());
+        RUNNER_ASSERT(0 ==
+                      memcmp(inStr, &(utfString[0]), utfString.size() *
+                             sizeof(wchar_t)));
+    }
+
+    free(inStr);
+}
+
+template<typename DelimiterType>
+void String_TokenizeReal(const DelimiterType& delimiter)
+{
+    DPL::String str(L".##..abc.#.");
+    std::vector<DPL::String> tokens;
+    DPL::Tokenize(str, delimiter, std::back_inserter(tokens));
+
+    std::vector<DPL::String> expectedTokens;
+    for (int i = 0; i < 5; i++) {
+        expectedTokens.push_back(L"");
+    }
+    expectedTokens.push_back(L"abc");
+    for (int i = 0; i < 3; i++) {
+        expectedTokens.push_back(L"");
+    }
+
+    RUNNER_ASSERT(expectedTokens == tokens);
+    tokens.clear();
+    expectedTokens.clear();
+
+    DPL::Tokenize(str, delimiter, std::back_inserter(tokens), true);
+    expectedTokens.push_back(L"abc");
+    RUNNER_ASSERT(expectedTokens == tokens);
+}
+
+/*
+Name: String_Tokenize
+Description: tests of string splitting
+Expected: returned substring should match expected values
+*/
+RUNNER_TEST(String_Tokenize)
+{
+    String_TokenizeReal(L"#.");
+    String_TokenizeReal(L".#");
+    String_TokenizeReal(L".....####.###..");
+    String_TokenizeReal(DPL::String(L".#"));
+
+    std::vector<std::string> tokens;
+    DPL::Tokenize(std::string("abc.def"), '.', std::back_inserter(tokens));
+    std::vector<std::string> expectedTokens;
+    expectedTokens.push_back("abc");
+    expectedTokens.push_back("def");
+
+    RUNNER_ASSERT(tokens == expectedTokens);
+}
+
+template <typename TemplateArgumentCharTraits>
+void TestInStreams(
+    std::basic_string<typename TemplateArgumentCharTraits::char_type,
+                      TemplateArgumentCharTraits> argumentInString,
+    std::basic_string<typename TemplateArgumentCharTraits::char_type,
+                      TemplateArgumentCharTraits> argumentResultString)
+{
+    typedef std::basic_string<typename TemplateArgumentCharTraits::char_type,
+                              TemplateArgumentCharTraits>
+    String;
+    std::basic_istringstream<typename TemplateArgumentCharTraits::char_type,
+                             TemplateArgumentCharTraits>
+    istream(argumentInString);
+    int intValue = 0;
+    double doubleValue = 0.0;
+    float floatValue = 0.0;
+    String stringValue;
+
+    istream >> intValue;
+    RUNNER_ASSERT(!istream.fail());
+    istream >> doubleValue;
+    RUNNER_ASSERT(!istream.fail());
+    istream >> floatValue;
+    RUNNER_ASSERT(!istream.fail());
+    istream >> stringValue;
+    RUNNER_ASSERT(!istream.fail());
+
+    RUNNER_ASSERT(1 == intValue);
+    RUNNER_ASSERT(fabs(1.1f - doubleValue) < 0.00001);
+    RUNNER_ASSERT(fabs(1.1f - floatValue) < 0.00001);
+    RUNNER_ASSERT(argumentResultString == stringValue);
+}
+
+template <typename TemplateArgumentCharTraits>
+void TestOutStreams(
+    std::basic_string<typename TemplateArgumentCharTraits::char_type,
+                      TemplateArgumentCharTraits> argumentInString,
+    std::basic_string<typename TemplateArgumentCharTraits::char_type,
+                      TemplateArgumentCharTraits> argumentResultString)
+{
+    typedef std::basic_string<typename TemplateArgumentCharTraits::char_type,
+                              TemplateArgumentCharTraits>
+    String;
+
+    std::basic_ostringstream<typename TemplateArgumentCharTraits::char_type,
+                             TemplateArgumentCharTraits>
+    ostream;
+
+    int intValue = 1;
+    double doubleValue = 1.1;
+    float floatValue = 1.1f;
+    String stringValue = argumentInString;
+
+    ostream << intValue;
+    RUNNER_ASSERT(!ostream.fail());
+    ostream << doubleValue;
+    RUNNER_ASSERT(!ostream.fail());
+    ostream << floatValue;
+    RUNNER_ASSERT(!ostream.fail());
+    ostream << stringValue;
+    RUNNER_ASSERT(!ostream.fail());
+
+    RUNNER_ASSERT(ostream.str() == argumentResultString);
+}
+
+/*
+Name: String_Streams
+Description: tests of input/output stream
+Expected: returned substrign should match expected values
+*/
+RUNNER_TEST(String_Streams)
+{
+    TestInStreams<std::char_traits<char> >("1 1.1 1.1 test", "test");
+    TestInStreams<std::char_traits<wchar_t> >(L"1 1.1 1.1 test", L"test");
+    TestInStreams<DPL::CharTraits>(L"1 1.1 1.1 test", L"test");
+    TestOutStreams<std::char_traits<char> >("test", "11.11.1test");
+    TestOutStreams<std::char_traits<wchar_t> >(L"test", L"11.11.1test");
+    TestOutStreams<DPL::CharTraits>(L"test", L"11.11.1test");
+}
+
+/*
+Name: String_CompareCaseSensitive
+Description: tests case sensitive comparision
+Expected: strings should be equal
+*/
+RUNNER_TEST(String_CompareCaseSensitive)
+{
+    RUNNER_ASSERT(
+        DPL::StringCompare(
+            DPL::FromUTF32String(L"Ala Makota ma żołądkówkę"),
+            DPL::FromUTF32String(L"Ala Makota ma żołądkówkę")) == 0);
+}
+
+/*
+Name: String_CompareCaseInsensitive
+Description: tests case insensitive comparision
+Expected: strings should be equal
+*/
+RUNNER_TEST(String_CompareCaseInsensitive)
+{
+    RUNNER_ASSERT(
+        DPL::StringCompare(
+            DPL::FromUTF32String(L"Ala Makota ma żołądkówkę"),
+            DPL::FromUTF32String(L"AlA MakOTA ma ŻoŁąDKÓwkę"),
+            true) == 0);
+}
+
diff --git a/tests/dpl/core/test_thread.cpp b/tests/dpl/core/test_thread.cpp
new file mode 100644 (file)
index 0000000..5db0dc1
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_thread.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of thread tests
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/thread.h>
+#include <dpl/log/log.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+bool g_wasFooDeleted;
+
+class Foo
+{
+  public:
+    int id;
+    Foo(int i = 0) : id(i)
+    {
+        LogInfo("Foo: ctor: " << id);
+    }
+
+    ~Foo()
+    {
+        LogInfo("Foo: dtor: " << id);
+        g_wasFooDeleted = true;
+    }
+
+    void Bar()
+    {
+        LogInfo("Foo: bar");
+    }
+};
+
+typedef DPL::ThreadLocalVariable<Foo> TlsFoo;
+TlsFoo g_foo;
+
+class FooThread :
+    public DPL::Thread
+{
+  protected:
+    virtual int ThreadEntry()
+    {
+        LogInfo("In thread");
+
+        RUNNER_ASSERT(!g_foo);
+        RUNNER_ASSERT(g_foo.IsNull());
+
+        g_foo = Foo();
+        g_foo->Bar();
+
+        return 0;
+    }
+};
+
+/*
+Name: Thread_ThreadLocalVariable_FooDeletion
+Description: tests local thread variable pattern
+Expected: local thread variables should not be affected by other threads
+*/
+RUNNER_TEST(Thread_ThreadLocalVariable_FooDeletion)
+{
+    static TlsFoo staticFooForMain;
+    staticFooForMain = Foo(1);
+
+    TlsFoo fooForMain;
+    fooForMain = Foo(2);
+
+    RUNNER_ASSERT(!g_foo);
+    RUNNER_ASSERT(g_foo.IsNull());
+
+    g_wasFooDeleted = false;
+
+    FooThread thread1;
+    thread1.Run();
+    thread1.Quit();
+
+    RUNNER_ASSERT(!g_foo);
+    RUNNER_ASSERT(g_foo.IsNull());
+
+    RUNNER_ASSERT(g_wasFooDeleted == true);
+
+    FooThread thread2;
+    thread2.Run();
+    thread2.Quit();
+
+    RUNNER_ASSERT(!g_foo);
+    RUNNER_ASSERT(g_foo.IsNull());
+}
diff --git a/tests/dpl/core/test_type_list.cpp b/tests/dpl/core/test_type_list.cpp
new file mode 100644 (file)
index 0000000..b3e6285
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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       test_type_list.cpp
+ * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/type_list.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: TypeList_TypeCount
+Description: tests size of typelist idiom
+Expected: size should match
+*/
+RUNNER_TEST(TypeList_TypeCount)
+{
+    typedef DPL::TypeListDecl<int, char, int[64]>::Type TestTypeList1;
+    typedef DPL::TypeListDecl<int>::Type TestTypeList2;
+    typedef DPL::TypeListDecl<>::Type TestTypeList3;
+    typedef DPL::TypeList<int, TestTypeList1> TestTypeList4;
+
+    RUNNER_ASSERT(TestTypeList1::Size == 3);
+    RUNNER_ASSERT(TestTypeList2::Size == 1);
+    RUNNER_ASSERT(TestTypeList3::Size == 0);
+    RUNNER_ASSERT(TestTypeList4::Size == 4);
+
+    RUNNER_ASSERT(TestTypeList4::Tail::Tail::Size == 2);
+}
diff --git a/tests/dpl/core/test_zip_input.cpp b/tests/dpl/core/test_zip_input.cpp
new file mode 100644 (file)
index 0000000..c62accb
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_zip_input.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of zip input tests
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/zip_input.h>
+#include <dpl/foreach.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/abstract_waitable_output_adapter.h>
+#include <dpl/binary_queue.h>
+#include <dpl/scoped_array.h>
+#include <dpl/copy.h>
+#include <dpl/log/log.h>
+
+namespace {
+const char* PATH_NO_FILE = "/opt/share/wrt/wrt-commons/tests/core/no_such_file";
+const char* PATH_ARCHIVE = "/opt/share/wrt/wrt-commons/tests/core/sample.zip";
+const char* ARCHIVED_FILE = "sample.txt";
+}
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: ZipInput_OpenFailed
+Description: tests opening non existing file
+Expected: exception throw
+*/
+RUNNER_TEST(ZipInput_OpenFailed)
+{
+    bool opened = true;
+
+    Try
+    {
+        DPL::ZipInput zip(PATH_NO_FILE);
+        (void)zip;
+    }
+    Catch(DPL::ZipInput::Exception::OpenFailed)
+    {
+        opened = false;
+    }
+
+    RUNNER_ASSERT(opened == false);
+}
+
+/*
+Name: ZipInput_OpenFile
+Description: tests opening existing file
+Expected: zip stats should mkatch expected
+*/
+RUNNER_TEST(ZipInput_OpenFile)
+{
+    DPL::ZipInput zip(PATH_ARCHIVE);
+
+    FOREACH(iter, zip)
+    {
+        LogDebug("---------");
+        LogDebug("FileInfo: ");
+#define FIELD(X) LogDebug(#X ": " << iter->X)
+        FIELD(name);
+        FIELD(comment);
+        FIELD(compressedSize);
+        FIELD(uncompressedSize);
+#undef  FIELD
+    }
+}
+
+/*
+Name: ZipInput_UnzipSingleFile
+Description: tests opening existing file and unzipping single file
+Expected: right content
+*/
+RUNNER_TEST(ZipInput_UnzipSingleFile)
+{
+    DPL::ZipInput zip(PATH_ARCHIVE);
+    DPL::ZipInput::File *file = zip.OpenFile(ARCHIVED_FILE);
+    DPL::AbstractWaitableInputAdapter fileAdapter(file);
+    DPL::BinaryQueue buffer;
+    DPL::AbstractWaitableOutputAdapter bufferAdapter(&buffer);
+
+    DPL::Copy(&fileAdapter, &bufferAdapter);
+
+    DPL::ScopedArray<char> data(new char[buffer.Size() + 1]);
+    buffer.Flatten(data.Get(), buffer.Size());
+    data[buffer.Size()] = '\0';
+
+    RUNNER_ASSERT(std::string(data.Get()) == "test");
+}
diff --git a/tests/dpl/db/CMakeLists.txt b/tests/dpl/db/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f4b5c22
--- /dev/null
@@ -0,0 +1,49 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Lukasz Marek (l.marek@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Test files
+#
+# Define all DPL tests sources.
+# Runner is responsible for runnint it all and
+# generating proper output files
+#
+
+SET(TARGET_NAME "dpl-tests-db")
+
+# Set DPL tests sources
+SET(DPL_TESTS_DB_SOURCES
+    ${TESTS_DPL_DIR}/db/main.cpp
+    ${TESTS_DPL_DIR}/db/test_orm.cpp
+    ${TESTS_DPL_DIR}/db/test_sql_connection.cpp
+)
+
+ADD_SUBDIRECTORY(orm)
+
+#include subdirectory
+WRT_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/orm)
+WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_DB_EFL})
+WRT_TEST_BUILD(${TARGET_NAME} ${DPL_TESTS_DB_SOURCES})
+WRT_TEST_INSTALL(${TARGET_NAME})
+
+INSTALL(FILES
+        ${TESTS_DPL_DIR}/db/orm/dpl_orm_test.db
+        DESTINATION /opt/share/wrt/wrt-commons/tests/db
+)
diff --git a/tests/dpl/db/main.cpp b/tests/dpl/db/main.cpp
new file mode 100644 (file)
index 0000000..4ed6191
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main.
+ */
+
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+    return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}
diff --git a/tests/dpl/db/orm/CMakeLists.txt b/tests/dpl/db/orm/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b7ebafb
--- /dev/null
@@ -0,0 +1,11 @@
+WRT_INTROSPECT_TARGET(db ${TARGET_DPL_DB_EFL})
+WRT_CONVERT_TO_GCC_LIST(db_INCLUDE_DIRS_GCC ${db_INCLUDE_DIRS})
+
+ADD_CUSTOM_COMMAND( OUTPUT dpl_orm_test_db.sql
+  COMMAND rm -f ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db
+  COMMAND C_INCLUDE_PATH=${db_INCLUDE_DIRS_GCC} gcc -Wall -E ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db.sql
+  COMMAND sqlite3 ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db ".read ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db.sql" || rm -f ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db
+  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db_sql_generator.h ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db
+)
+
+ADD_CUSTOM_TARGET( Sqlite3Db ALL DEPENDS dpl_orm_test_db.sql )
diff --git a/tests/dpl/db/orm/dpl_orm_test_db b/tests/dpl/db/orm/dpl_orm_test_db
new file mode 100644 (file)
index 0000000..0d1963b
--- /dev/null
@@ -0,0 +1,88 @@
+
+CREATE_TABLE(TestTableInsert)
+    COLUMN(ColumnOptInt,            INT,)
+    COLUMN(ColumnOptText,           TEXT,)
+    COLUMN_NOT_NULL(ColumnInt,      INT, DEFAULT 99)
+    COLUMN_NOT_NULL(ColumnInt2,     INT,)
+    COLUMN_NOT_NULL(ColumnText,     TEXT,)
+CREATE_TABLE_END()
+
+CREATE_TABLE(TestTableDelete)
+    COLUMN(ColumnOptInt,            INT,)
+    COLUMN(ColumnOptText,           TEXT,)
+    COLUMN_NOT_NULL(ColumnInt,      INT, DEFAULT 99)
+    COLUMN_NOT_NULL(ColumnInt2,     INT,)
+    COLUMN_NOT_NULL(ColumnText,     TEXT,)
+CREATE_TABLE_END()
+
+SQL(
+    INSERT INTO TestTableDelete VALUES(1, "two", 3, 4, "five");
+    INSERT INTO TestTableDelete VALUES(6, "seven", 8, 9, "ten");
+    INSERT INTO TestTableDelete (ColumnInt2, ColumnText) VALUES(11, "twelve");
+    INSERT INTO TestTableDelete (ColumnInt2, ColumnText) VALUES(13, "fourteen");
+)
+
+CREATE_TABLE(TestTable)
+    COLUMN(ColumnOptInt,            INT,)
+    COLUMN(ColumnOptText,           TEXT,)
+    COLUMN_NOT_NULL(ColumnInt,      INT, DEFAULT 99)
+    COLUMN_NOT_NULL(ColumnInt2,     INT,)
+    COLUMN_NOT_NULL(ColumnText,     TEXT,)
+CREATE_TABLE_END()
+
+SQL(
+    INSERT INTO TestTable VALUES(1, "two", 3, 4, "five");
+    INSERT INTO TestTable VALUES(6, "seven", 8, 9, "ten");
+    INSERT INTO TestTable (ColumnInt2, ColumnText) VALUES(11, "twelve");
+    INSERT INTO TestTable (ColumnInt2, ColumnText) VALUES(13, "fourteen");
+)
+
+CREATE_TABLE(TestTableJoin1)
+    COLUMN_NOT_NULL(TestID, INT,)
+    COLUMN_NOT_NULL(TestText, TEXT,)
+    COLUMN(TestNumber,      INT,)
+    TABLE_CONSTRAINTS(
+        PRIMARY KEY(TestID)
+    )
+CREATE_TABLE_END()
+
+CREATE_TABLE(TestTableJoin2)
+    COLUMN_NOT_NULL(TestID, INT,)
+    COLUMN_NOT_NULL(TestText1,       TEXT,)
+    COLUMN_NOT_NULL(TestText2,       TEXT,)
+    TABLE_CONSTRAINTS(
+        PRIMARY KEY(TestID)
+    )
+CREATE_TABLE_END()
+
+CREATE_TABLE(TestTableJoin3)
+    COLUMN_NOT_NULL(TestID, INT,)
+    COLUMN(Value3,          INT,)
+    COLUMN(TestText33,      TEXT,)
+    TABLE_CONSTRAINTS(
+        PRIMARY KEY(TestID)
+    )
+CREATE_TABLE_END()
+
+SQL(
+    INSERT INTO TestTableJoin1 VALUES(1, "text val 1", 111);
+    INSERT INTO TestTableJoin1 VALUES(2, "text val 2", 222);
+    INSERT INTO TestTableJoin1 VALUES(3, "text val 3", 333);
+    INSERT INTO TestTableJoin1 VALUES(4, "text val 4", 444);
+    INSERT INTO TestTableJoin1 VALUES(5, "text val 5", 555);
+    INSERT INTO TestTableJoin1 VALUES(6, "text val 6", 666);
+
+    INSERT INTO TestTableJoin2 VALUES(1, "01", "text2 1");
+    INSERT INTO TestTableJoin2 VALUES(2, "02", "text2 2");
+    INSERT INTO TestTableJoin2 VALUES(3, "03", "text2 3");
+    INSERT INTO TestTableJoin2 VALUES(4, " 4 ", "text2 4");
+    INSERT INTO TestTableJoin2 VALUES(5, "*5*", "text2 5");
+    INSERT INTO TestTableJoin2 VALUES(10, "6", "text2 6");
+
+    INSERT INTO TestTableJoin3 VALUES(1, 111, "test 1");
+    INSERT INTO TestTableJoin3 VALUES(2, 111, "test 2");
+    INSERT INTO TestTableJoin3 VALUES(3, 222, "test 3");
+    INSERT INTO TestTableJoin3 VALUES(6, 222, "test 4");
+    INSERT INTO TestTableJoin3 (TestID, TestText33) VALUES(7, "test 5");
+    INSERT INTO TestTableJoin3 (TestID, TestText33) VALUES(10, "test 6");
+)
diff --git a/tests/dpl/db/orm/dpl_orm_test_db_definitions b/tests/dpl/db/orm/dpl_orm_test_db_definitions
new file mode 100644 (file)
index 0000000..da79427
--- /dev/null
@@ -0,0 +1,5 @@
+DATABASE_START(dpl_orm_test)
+
+#include "dpl_orm_test_db"
+
+DATABASE_END()
diff --git a/tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h b/tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h
new file mode 100644 (file)
index 0000000..cac41cc
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        dpl_orm_test_db_sql_generator.h
+ * @author      Lukasz Marek (l.marek@samsung.com)
+ * @version     1.0
+ * @brief       Macro definitions for generating the SQL input file from
+ * database definition.
+ */
+
+//Do not include this file directly! It is used only for SQL code generation.
+
+#include <dpl/db/orm_macros.h>
+
+#include "dpl_orm_test_db_definitions"
diff --git a/tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h.gch b/tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h.gch
new file mode 100644 (file)
index 0000000..5bd675d
Binary files /dev/null and b/tests/dpl/db/orm/dpl_orm_test_db_sql_generator.h.gch differ
diff --git a/tests/dpl/db/orm/generator_dpl_orm_test.h b/tests/dpl/db/orm/generator_dpl_orm_test.h
new file mode 100644 (file)
index 0000000..39bb1b7
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 ORM_GENERATOR_DPL_ORM_TEST_H
+#define ORM_GENERATOR_DPL_ORM_TEST_H
+
+#define ORM_GENERATOR_DATABASE_NAME dpl_orm_test_db_definitions
+#include <dpl/db/orm_generator.h>
+#undef ORM_GENERATOR_DATABASE_NAME
+
+#endif
diff --git a/tests/dpl/db/test_orm.cpp b/tests/dpl/db/test_orm.cpp
new file mode 100644 (file)
index 0000000..500f43d
--- /dev/null
@@ -0,0 +1,1140 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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 <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/db/thread_database_support.h>
+#include <generator_dpl_orm_test.h>
+#include <sstream>
+
+const char* PATH_DB = "/opt/share/wrt/wrt-commons/tests/db/dpl_orm_test.db";
+
+//utils
+
+#define TEST_REPETITION 16
+
+class SmartAttach
+{
+  public:
+
+    SmartAttach(bool autoattach = true) :
+        m_interface(PATH_DB,
+                    DPL::DB::SqlConnection::Flag::UseLucene),
+        m_autoattach(autoattach)
+    {
+        if (m_autoattach) {
+            m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
+        }
+    }
+
+    ~SmartAttach()
+    {
+        if (m_autoattach) {
+            m_interface.DetachFromThread();
+        }
+    }
+
+    DPL::DB::ThreadDatabaseSupport* get()
+    {
+        return &m_interface;
+    }
+
+  private:
+    DPL::DB::ThreadDatabaseSupport m_interface;
+    bool m_autoattach;
+};
+
+template<typename ContainerType1, typename ContainerType2>
+bool ContainerContentsEqual(const ContainerType1& container1,
+                            const ContainerType2& container2)
+{
+    using namespace DPL::DB::ORM::dpl_orm_test::TestTableInsert;
+    typedef std::set<typename ContainerType1::value_type> Set1;
+    typedef std::set<typename ContainerType2::value_type> Set2;
+    Set1 set1(container1.begin(), container1.end());
+    Set2 set2(container2.begin(), container2.end());
+
+    for (typename Set1::iterator it = set1.begin();
+         it != set1.end();
+         it++)
+    {
+        LogDebug("Set1 element: " << *it);
+    }
+
+    for (typename Set2::iterator it = set2.begin(); it != set2.end(); it++) {
+        LogDebug("Set2 element: " << *it);
+    }
+
+    return set1 == set2;
+}
+
+template<typename T>
+std::list<T> makeList(const T& a, const T& b)
+{
+    std::list<T> list;
+    list.push_back(a);
+    list.push_back(b);
+    return list;
+}
+
+//tests
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: ORM_SelectSingleValue
+Description: tests quering single value of single row from database
+Expected: Values should match those which were prepared
+*/
+RUNNER_TEST(ORM_SelectSingleValue)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    //Getting each column
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        int result;
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptInt>())
+                          == 6, "Got " <<
+                          result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        DPL::String result;
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptText>(
+                                   )) == L"seven",
+                          "Got " << result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        int result;
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt>(
+                                   )) == 8, "Got " << result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        int result;
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 9, "Got " << result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        DPL::String result;
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnText>(
+                                   )) == L"ten", "Got " << result);
+    }
+
+    //Where on each column
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnOptInt>(6));
+        int result;
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptInt>())
+                          == 6, "Got " <<
+                          result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnOptText>(DPL::String(L"seven")));
+        DPL::String result;
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptText>(
+                                   )) == L"seven",
+                          "Got " << result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        int result;
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt>(
+                                   )) == 8, "Got " << result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt2>(9));
+        int result;
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 9, "Got " << result);
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnText>(L"ten"));
+        DPL::String result;
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnText>(
+                                   )) == L"ten", "Got " << result);
+    }
+}
+
+/*
+Name: ORM_SelectSingleRow
+Description: tests quering single row from database
+Expected: Values should match those which were prepared
+*/
+RUNNER_TEST(ORM_SelectSingleRow)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(3));
+        TestTable::Row result = select.GetSingleRow();
+        TestTable::Row expected;
+        expected.Set_ColumnOptInt(1);
+        expected.Set_ColumnOptText(DPL::String(L"two"));
+        expected.Set_ColumnInt(3);
+        expected.Set_ColumnInt2(4);
+        expected.Set_ColumnText(L"five");
+        RUNNER_ASSERT_MSG(result == expected, "Got " << result);
+    }
+
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnOptText>(DPL::String(L"seven")));
+        TestTable::Row result = select.GetSingleRow();
+        TestTable::Row expected;
+        expected.Set_ColumnOptInt(6);
+        expected.Set_ColumnOptText(DPL::String(L"seven"));
+        expected.Set_ColumnInt(8);
+        expected.Set_ColumnInt2(9);
+        expected.Set_ColumnText(L"ten");
+        RUNNER_ASSERT_MSG(result == expected, "Got " << result);
+    }
+}
+
+/*
+Name: ORM_SelectRowList
+Description: tests quering multiple row from database
+Expected: Values should match those which were prepared
+*/
+RUNNER_TEST(ORM_SelectRowList)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(3));
+        std::list<TestTable::Row> result = select.GetRowList();
+        RUNNER_ASSERT_MSG(result.size() == 1, "Got " << result.size());
+
+        TestTable::Row expected;
+        expected.Set_ColumnOptInt(1);
+        expected.Set_ColumnOptText(DPL::String(L"two"));
+        expected.Set_ColumnInt(3);
+        expected.Set_ColumnInt2(4);
+        expected.Set_ColumnText(L"five");
+        RUNNER_ASSERT_MSG(*(result.begin()) == expected, "Got " <<
+                          *(result.begin()) );
+    }
+
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnOptText>(DPL::String(L"seven")));
+        std::list<TestTable::Row> result = select.GetRowList();
+        RUNNER_ASSERT_MSG(result.size() == 1, "Got " << result.size());
+
+        TestTable::Row expected;
+        expected.Set_ColumnOptInt(6);
+        expected.Set_ColumnOptText(DPL::String(L"seven"));
+        expected.Set_ColumnInt(8);
+        expected.Set_ColumnInt2(9);
+        expected.Set_ColumnText(L"ten");
+        RUNNER_ASSERT_MSG(*(result.begin()) == expected, "Got " <<
+                          *(result.begin()) );
+    }
+
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Equals<TestTable::ColumnInt>(99));
+        std::list<TestTable::Row> result = select.GetRowList();
+
+        TestTable::Row expected1;
+        expected1.Set_ColumnInt(99);
+        expected1.Set_ColumnInt2(11);
+        expected1.Set_ColumnText(L"twelve");
+
+        TestTable::Row expected2;
+        expected2.Set_ColumnInt(99);
+        expected2.Set_ColumnInt2(13);
+        expected2.Set_ColumnText(L"fourteen");
+
+        RUNNER_ASSERT(ContainerContentsEqual(makeList(expected1,
+                                                      expected2), result));
+    }
+}
+
+/*
+Name: ORM_SelectValueList
+Description: tests quering single column from multiple row from database
+Expected: Values should match those which were prepared
+*/
+RUNNER_TEST(ORM_SelectValueList)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    //Getting each column
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnInt>(),
+                                             makeList(99, 99)));
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnInt2>(),
+                                             makeList(11, 13)));
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnText>(),
+                                             makeList(DPL::String(L"twelve"),
+                                                      DPL::String(L"fourteen"))));
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnOptText>(),
+                                             makeList(DPL::Optional<DPL::String>
+                                                          ::Null,
+                                                      DPL::Optional<DPL::String>
+                                                          ::Null)));
+    }
+
+    //Where on each column
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnInt2>(),
+                                             makeList(11, 13)));
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnOptText>(DPL::Optional<DPL::String>::
+                                                      Null));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnInt2>(),
+                                             makeList(11, 13)));
+    }
+    {
+        TestTable::Select select(interface.get());
+        select.Where(Is<TestTable::ColumnInt>(99));
+        RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::
+                                                                     ColumnInt2>(),
+                                             makeList(11, 13)));
+    }
+}
+
+/*
+Name: ORM_MultipleCalls
+Description: tests sequnece of different queries
+Expected: Values should match those which were prepared
+*/
+RUNNER_TEST(ORM_MultipleCalls)
+{
+    for (int j = 0; j < TEST_REPETITION; j++) {
+        for (int i = 0; i < TEST_REPETITION; i++) {
+            ORM_SelectSingleValue();
+        }
+
+        for (int i = 0; i < TEST_REPETITION; i++) {
+            ORM_SelectSingleRow();
+        }
+
+        for (int i = 0; i < TEST_REPETITION; i++) {
+            ORM_SelectRowList();
+        }
+
+        for (int i = 0; i < TEST_REPETITION; i++) {
+            ORM_SelectValueList();
+        }
+    }
+}
+
+/*
+Name: ORM_Insert
+Description: tests insering rows into database
+Expected: Values should be inserted
+*/
+RUNNER_TEST(ORM_Insert)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+
+    TestTableInsert::Select select1(interface.get());
+    std::list<int> resultList = select1.GetValueList<TestTableInsert::ColumnInt>();
+    RUNNER_ASSERT_MSG(resultList.empty(),
+                      "Returned list has wrong size: " << resultList.size());
+
+    std::list<TestTableInsert::Row> list;
+
+    TestTableInsert::Insert insert(interface.get());
+    TestTableInsert::Row row;
+    row.Set_ColumnOptInt(1);
+    row.Set_ColumnInt2(2);
+    row.Set_ColumnText(L"three");
+    insert.Values(row);
+    insert.Execute();
+
+    row.Set_ColumnInt(99);
+    list.push_back(row);
+    {
+        TestTableInsert::Select select2(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select2.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    TestTableInsert::Insert insert2(interface.get());
+    TestTableInsert::Row row2;
+    row2.Set_ColumnInt(4);
+    row2.Set_ColumnInt2(5);
+    row2.Set_ColumnText(L"six");
+    insert2.Values(row2);
+    insert2.Execute();
+
+    list.push_back(row2);
+    {
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    TestTableInsert::Insert insert3(interface.get());
+    TestTableInsert::Row row3;
+    row3.Set_ColumnOptInt(1);
+    row3.Set_ColumnInt2(7);
+    row3.Set_ColumnText(L"eight");
+    insert3.Values(row3);
+    insert3.Execute();
+
+    row3.Set_ColumnInt(99);
+    list.push_back(row3);
+    {
+        TestTableInsert::Select select3(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select3.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    TestTableInsert::Insert insert4(interface.get());
+    TestTableInsert::Row row4;
+    row4.Set_ColumnOptInt(9);
+    row4.Set_ColumnInt2(10);
+    row4.Set_ColumnText(L"eleven");
+    insert4.Values(row4);
+    insert4.Execute();
+
+    row4.Set_ColumnInt(99);
+    list.push_back(row4);
+    {
+        TestTableInsert::Select select4(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select4.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    // restore original table state
+    {
+        TestTableInsert::Delete del(interface.get());
+        del.Execute();
+
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT(select.GetRowList().size() == 0);
+    }
+}
+
+/*
+Name: ORM_MultipleBindInsert
+Description: repeats ORM_Insert test several times
+Expected: Values should be inserted
+*/
+RUNNER_TEST(ORM_MultipleBindInsert)
+{
+    for (int i = 0; i < TEST_REPETITION; i++) {
+        ORM_Insert();
+    }
+}
+
+/*
+Name: ORM_Delete
+Description: tests deleting rows from database
+Expected: deleted rows should not exist
+*/
+RUNNER_TEST(ORM_Delete)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    TestTableDelete::Select selectStart(interface.get());
+    selectStart.OrderBy(DPL::TypeListDecl<OrderingAscending<TestTableDelete::
+                                                                ColumnInt2> >());
+    std::list<TestTableDelete::Row> list = selectStart.GetRowList();
+    std::list<TestTableDelete::Row> originalList = list;
+
+    std::vector<TestTableDelete::Row> vector(list.begin(), list.end());
+    RUNNER_ASSERT_MSG(
+        list.size() == 4, "Returned list has wrong size: " << list.size());
+
+    typedef DPL::String S;
+
+    //no-act deletes
+    {
+        TestTableDelete::Delete del(interface.get());
+        del.Where(And(Equals<TestTableDelete::ColumnOptInt>(1),
+                      Equals<TestTableDelete::ColumnOptText>(S(L"seven"))));
+        del.Execute();
+
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    {
+        TestTableDelete::Delete del(interface.get());
+        del.Where(And(Equals<TestTableDelete::ColumnOptInt>(6),
+                      Equals<TestTableDelete::ColumnOptText>(S(L"two"))));
+        del.Execute();
+
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    {
+        TestTableDelete::Delete del(interface.get());
+        del.Where(Equals<TestTableDelete::ColumnInt2>(10));
+        del.Execute();
+
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    //act deletes
+    {
+        list.remove(vector[1]);
+
+        TestTableDelete::Delete del(interface.get());
+        del.Where(And(Equals<TestTableDelete::ColumnOptInt>(6),
+                      Equals<TestTableDelete::ColumnText>(L"ten")));
+        del.Execute();
+
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    {
+        list.remove(vector[2]);
+        list.remove(vector[3]);
+
+        TestTableDelete::Delete del(interface.get());
+        del.Where(Is<TestTableDelete::ColumnOptText>(DPL::Optional<DPL::String>
+                                                         ::Null));
+        del.Execute();
+
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    {
+        TestTableDelete::Delete del(interface.get());
+        del.Execute();
+
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(
+            select.GetRowList().size() == 0, "Returned list is not empty");
+    }
+
+    // Restore original table state
+    // This also tests if multiple different binds for Insert are working
+    // properly
+    for (std::list<TestTableDelete::Row>::iterator i = originalList.begin();
+         i != originalList.end();
+         i++)
+    {
+        TestTableDelete::Insert insert(interface.get());
+        insert.Values(*i);
+        insert.Execute();
+    }
+
+    {
+        TestTableDelete::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              originalList),
+                          "Returned list doesn't match.");
+    }
+}
+
+/*
+Name: ORM_MultipleBindDelete
+Description: repeats ORM_Delete test several times
+Expected: Values should be deleted
+*/
+RUNNER_TEST(ORM_MultipleBindDelete)
+{
+    for (int i = 0; i < TEST_REPETITION; i++) {
+        ORM_Delete();
+    }
+}
+
+/*
+Name: ORM_MultipleBindWhere
+Description: tests if multiple bind of same query obejct works
+Expected: Each bind and execution of query should be correct
+*/
+RUNNER_TEST(ORM_MultipleBindWhere)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    {
+        TestTable::Select select(interface.get());
+        int result;
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptInt>())
+                          == 6, "Got " <<
+                          result);
+
+        select.Where(Equals<TestTable::ColumnInt>(3));
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptInt>())
+                          == 1, "Got " <<
+                          result);
+
+        select.Where(Equals<TestTable::ColumnInt>(8));
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptInt>())
+                          == 6, "Got " <<
+                          result);
+
+        select.Where(Equals<TestTable::ColumnInt>(3));
+        RUNNER_ASSERT_MSG((result =
+                               *select.GetSingleValue<TestTable::ColumnOptInt>())
+                          == 1, "Got " <<
+                          result);
+    }
+
+    {
+        TestTable::Select select(interface.get());
+        int result;
+        select.Where(And(Equals<TestTable::ColumnInt>(99),
+                         Equals<TestTable::ColumnText>(L"fourteen")));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 13, "Got " << result);
+
+        select.Where(And(Equals<TestTable::ColumnInt>(99),
+                         Equals<TestTable::ColumnText>(L"twelve")));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 11, "Got " << result);
+
+        select.Where(And(Equals<TestTable::ColumnInt>(99),
+                         Equals<TestTable::ColumnText>(L"fourteen")));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 13, "Got " << result);
+
+        select.Where(And(Equals<TestTable::ColumnInt>(99),
+                         Equals<TestTable::ColumnText>(L"twelve")));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 11, "Got " << result);
+    }
+
+    {
+        TestTable::Select select(interface.get());
+        int result;
+        select.Where(And(Equals<TestTable::ColumnText>(L"fourteen"),
+                         Equals<TestTable::ColumnInt>(99)));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 13, "Got " << result);
+
+        select.Where(And(Equals<TestTable::ColumnText>(L"twelve"),
+                         Equals<TestTable::ColumnInt>(99)));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 11, "Got " << result);
+
+        select.Where(And(Equals<TestTable::ColumnText>(L"fourteen"),
+                         Equals<TestTable::ColumnInt>(99)));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 13, "Got " << result);
+
+        select.Where(And(Equals<TestTable::ColumnText>(L"twelve"),
+                         Equals<TestTable::ColumnInt>(99)));
+        RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>(
+                                   )) == 11, "Got " << result);
+    }
+}
+
+/*
+Name: ORM_Update
+Description: tests rows update in database
+Expected: Successful update
+*/
+RUNNER_TEST(ORM_Update)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+
+    std::list<TestTableInsert::Row> list;
+
+    TestTableInsert::Delete del(interface.get());
+    del.Execute();
+
+    // INSERT
+    {
+        TestTableInsert::Insert insert(interface.get());
+        TestTableInsert::Row row;
+        row.Set_ColumnOptInt(5);
+        row.Set_ColumnInt2(2);
+        row.Set_ColumnText(L"two");
+        insert.Values(row);
+        insert.Execute();
+
+        row.Set_ColumnInt(99);
+        list.push_back(row);
+    }
+    {
+        TestTableInsert::Insert insert(interface.get());
+        TestTableInsert::Row row;
+        row.Set_ColumnOptInt(1);
+        row.Set_ColumnInt2(2);
+        row.Set_ColumnText(L"three");
+        insert.Values(row);
+        insert.Execute();
+
+        row.Set_ColumnInt(99);
+        list.push_back(row);
+    }
+    {
+        TestTableInsert::Insert insert(interface.get());
+        TestTableInsert::Row row;
+        row.Set_ColumnOptInt(2);
+        row.Set_ColumnInt2(3);
+        row.Set_ColumnText(L"three");
+        insert.Values(row);
+        insert.Execute();
+
+        row.Set_ColumnInt(99);
+        list.push_back(row);
+
+        // CHECK
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+    {
+        // UPDATE - no rows
+        TestTableInsert::Update update(interface.get());
+        TestTableInsert::Row row;
+        row.Set_ColumnInt2(4);
+        row.Set_ColumnText(L"four");
+        update.Values(row);
+        update.Where(Equals<TestTableInsert::ColumnInt2>(12));
+        update.Execute();
+
+        // CHECK
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+    {
+        // UPDATE - one row
+        TestTableInsert::Update update(interface.get());
+        TestTableInsert::Row row;
+        row.Set_ColumnInt2(2);
+        row.Set_ColumnText(L"four");
+        update.Values(row);
+        update.Where(Equals<TestTableInsert::ColumnInt2>(3));
+        update.Execute();
+
+        list.back().Set_ColumnInt2(2);
+        list.back().Set_ColumnText(L"four");
+
+        // CHECK
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    {
+        // UPDATE - multiple rows
+        TestTableInsert::Update update(interface.get());
+        TestTableInsert::Row row;
+        row.Set_ColumnText(L"dup");
+        update.Values(row);
+        update.Where(Equals<TestTableInsert::ColumnInt2>(2));
+        update.Execute();
+
+        FOREACH(it, list)
+        {
+            it->Set_ColumnText(L"dup");
+        }
+
+        // CHECK
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT_MSG(ContainerContentsEqual(
+                              select.GetRowList(),
+                              list), "Returned list doesn't match.");
+    }
+
+    // restore original table state
+    {
+        TestTableInsert::Delete del2(interface.get());
+        del2.Execute();
+
+        TestTableInsert::Select select(interface.get());
+        RUNNER_ASSERT(select.GetRowList().size() == 0);
+    }
+}
+
+/*
+Name: ORM_MultipleBindUpdate
+Description: repeats ORM_Update severl times
+Expected: Successful update
+*/
+RUNNER_TEST(ORM_MultipleBindUpdate)
+{
+    for (int i = 0; i < TEST_REPETITION; i++) {
+        ORM_Update();
+    }
+}
+
+/*
+Name: ORM_transactions
+Description: checks creation of transation object
+Expected: Successful creation of transaction object
+*/
+RUNNER_TEST(ORM_transactions)
+{
+    SmartAttach interface;
+    DPL::DB::ORM::dpl_orm_test::ScopedTransaction transaction(interface.get());
+}
+
+/*
+Name: ORM_MultiAttach
+Description: checks correct behaviou in case of multiple tries to attach to database
+Expected: Methods attaching/dettaching should be prepared for multiple calling
+*/
+RUNNER_TEST(ORM_MultiAttach)
+{
+    SmartAttach interface(false);
+    RUNNER_ASSERT_MSG(
+        !interface.get()->IsAttached(), "Is attached, but shouldn't be.");
+    interface.get()->AttachToThread();
+    RUNNER_ASSERT_MSG(
+        interface.get()->IsAttached(), "Isn't attached, but should be.");
+    interface.get()->AttachToThread();
+    RUNNER_ASSERT_MSG(
+        interface.get()->IsAttached(), "Isn't attached, but should be.");
+    interface.get()->DetachFromThread();
+    RUNNER_ASSERT_MSG(
+        interface.get()->IsAttached(), "Isn't attached, but should be.");
+    interface.get()->DetachFromThread();
+    RUNNER_ASSERT_MSG(
+        !interface.get()->IsAttached(), "Is attached, but shouldn't be.");
+}
+
+/*
+Name: ORM_Join
+Description: tests ORM's join operation
+Expected: values should insist correct join operation
+*/
+RUNNER_TEST(ORM_Join)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+
+    typedef DPL::TypeListDecl<TestTableJoin1::TestText,
+                              TestTableJoin2::TestText2,
+                              DPL::TypeListGuard>::Type JoinColumns;
+
+    /* Test for correct join:
+     * 5 ids from first table matches 5 ids from second table thus join result
+     * contains 5 rows */
+    TestTableJoin1::Select select(interface.get());
+    select.Join<JoinColumns>(Equal<TestTableJoin1::TestID,
+                                   TestTableJoin2::TestID>());
+    std::list<CustomRow<JoinColumns> > rowlist =
+        select.GetCustomRowList<JoinColumns, CustomRow<JoinColumns> >();
+
+    RUNNER_ASSERT_MSG(
+        rowlist.size() == 5, "Invalid number of rows fetched: " << rowlist.size());
+
+    std::string text;
+    std::ostringstream oss;
+    int cnt = 0;
+    FOREACH(rowit, rowlist)
+    {
+        cnt++;
+
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin1::TestText>());
+        oss << "text val " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from first column: "
+                          << text << " expected: " << oss.str());
+        oss.str(std::string());
+
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin2::TestText2>());
+        oss << "text2 " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from second column: "
+                          << text << " expected: " << oss.str());
+        oss.str(std::string());
+    }
+    /* Test for empty join:
+     * None of number values from first table matches ids from second table
+     * - join result should be empty */
+    TestTableJoin1::Select select2(interface.get());
+    select2.Join<JoinColumns>(Equal<TestTableJoin1::TestNumber,
+                                    TestTableJoin2::TestID>());
+    rowlist = select2.GetCustomRowList<JoinColumns, CustomRow<JoinColumns> >();
+
+    RUNNER_ASSERT_MSG(rowlist.empty(), "Result should be empty but it is not!");
+
+    /* Test for "converted" join:
+     * - join made with int column and text column as keys
+     * - expected 5 matching rows (one row of 6 should not be matched)*/
+    TestTableJoin1::Select select3(interface.get());
+    select3.Join<JoinColumns>(Equal<TestTableJoin1::TestID,
+                                    TestTableJoin2::TestText1>());
+    rowlist = select3.GetCustomRowList<JoinColumns, CustomRow<JoinColumns> >();
+    RUNNER_ASSERT_MSG(
+        rowlist.size() == 5, "Expected 5 rows while received: " << rowlist.size());
+    cnt = 0;
+    FOREACH(rowit, rowlist)
+    {
+        cnt++;
+        // look at last two insertions into TestTableJoin2
+        // for this skip understanding
+        if (cnt == 5) {
+            cnt = 6;
+        }
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin1::TestText>());
+        oss << "text val " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from first column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin2::TestText2>());
+        oss << "text2 " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from second column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+    }
+
+    /* Test for join with non-unique nullable columns given as keys*/
+    typedef DPL::TypeListDecl<TestTableJoin1::TestText,
+                              TestTableJoin3::TestText33,
+                              DPL::TypeListGuard>::Type JoinTables2;
+    TestTableJoin1::Select select4(interface.get());
+    select4.Join<JoinTables2>(Equal<TestTableJoin1::TestNumber,
+                                    TestTableJoin3::Value3>());
+    std::list<CustomRow<JoinTables2> > rowlist2 =
+        select4.GetCustomRowList<JoinTables2, CustomRow<JoinTables2> >();
+    RUNNER_ASSERT_MSG(
+        rowlist2.size() == 4, "Expected 4 rows while received: " <<
+        rowlist.size());
+    cnt = 0;
+    DPL::Optional<DPL::String> optext;
+    FOREACH(rowit, rowlist2)
+    {
+        cnt++;
+
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin1::TestText>());
+        // values expected in subsequent (1,2,3,4) iterations: 1 1 2 2
+        oss << "text val " << (1 + (int)(cnt / 3));
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from first column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+
+        optext = (*rowit).GetColumnData<TestTableJoin3::TestText33>();
+        text = DPL::ToUTF8String(*optext);
+        oss << "test " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from second column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+    }
+
+    /* Test for join made on three tables:
+     * - 3 text columns selected for join
+     * - Equal made for TestID of (table1 and table2) and (table1 and table3) */
+    typedef DPL::TypeListDecl<TestTableJoin1::TestText,
+                              TestTableJoin2::TestText2,
+                              TestTableJoin3::TestText33,
+                              DPL::TypeListGuard>::Type Join3Tables;
+    TestTableJoin1::Select select5(interface.get());
+    select5.Join<Join3Tables>(Equal<TestTableJoin1::TestID,
+                                    TestTableJoin2::TestID>());
+    select5.Join<Join3Tables>(Equal<TestTableJoin1::TestID,
+                                    TestTableJoin3::TestID>());
+    std::list<CustomRow<Join3Tables> > rowlist3tab =
+        select5.GetCustomRowList<Join3Tables, CustomRow<Join3Tables> >();
+    RUNNER_ASSERT_MSG(
+        rowlist3tab.size() == 3, "Expected 3 rows while received: " <<
+        rowlist3tab.size());
+    cnt = 0;
+    FOREACH(rowit, rowlist3tab)
+    {
+        cnt++;
+
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin1::TestText>());
+        oss << "text val " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from first column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+
+        text =
+            DPL::ToUTF8String((*rowit).GetColumnData<TestTableJoin2::TestText2>());
+        oss << "text2 " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from first column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+
+        optext = (*rowit).GetColumnData<TestTableJoin3::TestText33>();
+        text = DPL::ToUTF8String(*optext);
+        oss << "test " << cnt;
+        RUNNER_ASSERT_MSG(text.compare(
+                              oss.str()) == 0,
+                          "Invalid value from second column: "
+                          << text << " expected: " << oss.str() <<
+                          " iteration: " << cnt);
+        oss.str(std::string());
+    }
+}
+
+RUNNER_TEST(ORM_SelectOrderByMultipleColumns)
+{
+    SmartAttach interface;
+    using namespace DPL::DB::ORM;
+    using namespace DPL::DB::ORM::dpl_orm_test;
+    {
+        TestTableJoin3::Select select(interface.get());
+
+        // testing: " ORDER BY Value3 ASC, TestID DESC, TestID ASC"
+        select.OrderBy(DPL::TypeListDecl<OrderingAscending<TestTableJoin3::
+                                                               Value3>,
+                                         OrderingDescending<TestTableJoin3::
+                                                                TestText33>,
+                                         OrderingAscending<TestTableJoin3::
+                                                               TestID> >());
+
+        std::list<TestTableJoin3::Row> result = select.GetRowList();
+        std::list<TestTableJoin3::Row>::const_iterator iter = result.begin();
+        { //1 row
+            RUNNER_ASSERT_MSG(*iter->Get_TestText33() ==
+                              DPL::FromASCIIString(
+                                  "test 6"), "Wrong row 1 order");
+            RUNNER_ASSERT_MSG(iter->Get_TestID() == 10, "Wrong row 1 order");
+            iter++;
+        }
+        { //2 row
+            RUNNER_ASSERT_MSG(*iter->Get_TestText33() ==
+                              DPL::FromASCIIString(
+                                  "test 5"), "Wrong row 2 order");
+            RUNNER_ASSERT_MSG(iter->Get_TestID() == 7, "Wrong row 2 order");
+            iter++;
+        }
+        { //3 row
+            RUNNER_ASSERT_MSG(iter->Get_Value3() == 111, "Wrong row 3 order");
+            RUNNER_ASSERT_MSG(*iter->Get_TestText33() ==
+                              DPL::FromASCIIString(
+                                  "test 2"), "Wrong row 3 order");
+            RUNNER_ASSERT_MSG(iter->Get_TestID() == 2, "Wrong row 3 order");
+            iter++;
+        }
+        { //4 row
+            RUNNER_ASSERT_MSG(iter->Get_Value3() == 111, "Wrong row 4 order");
+            RUNNER_ASSERT_MSG(*iter->Get_TestText33() ==
+                              DPL::FromASCIIString(
+                                  "test 1"), "Wrong row 4 order");
+            RUNNER_ASSERT_MSG(iter->Get_TestID() == 1, "Wrong row 4 order");
+            iter++;
+        }
+        { //5 row
+            RUNNER_ASSERT_MSG(iter->Get_Value3() == 222, "Wrong row 5 order");
+            RUNNER_ASSERT_MSG(*iter->Get_TestText33() ==
+                              DPL::FromASCIIString(
+                                  "test 4"), "Wrong row 5 order");
+            RUNNER_ASSERT_MSG(iter->Get_TestID() == 6, "Wrong row 5 order");
+            iter++;
+        }
+        { //6 row
+            RUNNER_ASSERT_MSG(iter->Get_Value3() == 222, "Wrong row 6 order");
+            RUNNER_ASSERT_MSG(*iter->Get_TestText33() ==
+                              DPL::FromASCIIString(
+                                  "test 3"), "Wrong row 6 order");
+            RUNNER_ASSERT_MSG(iter->Get_TestID() == 3, "Wrong row 6 order");
+            iter++;
+        }
+    }
+}
diff --git a/tests/dpl/db/test_sql_connection.cpp b/tests/dpl/db/test_sql_connection.cpp
new file mode 100644 (file)
index 0000000..0f37b2d
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_sql_connection.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of sql connection tests
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/db/sql_connection.h>
+#include <dpl/db/naive_synchronization_object.h>
+#include <memory>
+#include <dpl/log/log.h>
+#include <sstream>
+#include <string>
+#include <cstdlib>
+#include <ctime>
+
+extern const char* PATH_DB;
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+class AbstractSynchronizationObjectGenerator
+{
+  public:
+    virtual ~AbstractSynchronizationObjectGenerator() {}
+
+    virtual DPL::DB::SqlConnection::SynchronizationObject *Create() = 0;
+};
+
+class NaiveSynchronizationObjectGenerator :
+    public AbstractSynchronizationObjectGenerator
+{
+  public:
+    virtual DPL::DB::SqlConnection::SynchronizationObject *Create()
+    {
+        return new DPL::DB::NaiveSynchronizationObject();
+    }
+};
+
+void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator);
+
+class StressGenerator :
+    public DPL::Thread
+{
+  private:
+    size_t m_prefix;
+    std::string m_dbFileName;
+    AbstractSynchronizationObjectGenerator *m_generator;
+
+  protected:
+    virtual int ThreadEntry()
+    {
+        DPL::DB::SqlConnection connection(
+            m_dbFileName,
+            DPL::DB::SqlConnection::Flag::None,
+            DPL::DB::SqlConnection::Flag::RW,
+            m_generator->Create());
+
+        DPL::DB::SqlConnection::DataCommandAutoPtr countCommand =
+            connection.PrepareDataCommand(
+                "SELECT COUNT(*) FROM test WHERE value=?");
+
+        for (size_t i = 0; i < 10; ++i) {
+            std::ostringstream valueStream;
+
+            valueStream << "value_";
+            valueStream << static_cast<unsigned long>(m_prefix);
+            valueStream << "_";
+            valueStream << static_cast<unsigned long>(i);
+
+            std::string value = valueStream.str();
+
+            connection.ExecCommand(
+                "INSERT INTO test VALUES ('%s');",
+                value.c_str());
+
+            countCommand->BindString(1, value.c_str());
+
+            RUNNER_ASSERT(countCommand->Step());
+
+            RUNNER_ASSERT(countCommand->GetColumnString(0) == "1");
+
+            countCommand->Reset();
+        }
+
+        countCommand.reset();
+
+        return 0;
+    }
+
+  public:
+    StressGenerator(size_t prefix,
+                    const std::string &dbFileName,
+                    AbstractSynchronizationObjectGenerator *generator) :
+        m_prefix(prefix),
+        m_dbFileName(dbFileName),
+        m_generator(generator)
+    {}
+};
+
+typedef std::shared_ptr<DPL::Thread> ThreadPtr;
+
+void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator)
+{
+    DPL::DB::SqlConnection connection(PATH_DB,
+                                      DPL::DB::SqlConnection::Flag::UseLucene,
+                                      DPL::DB::SqlConnection::Flag::RW);
+
+    connection.ExecCommand("CREATE TABLE test(value TEXT);");
+
+    const size_t STRESS_GENERATOR_COUNT = 5;
+    ThreadPtr stressGenerators[STRESS_GENERATOR_COUNT];
+
+    for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i) {
+        stressGenerators[i].reset(
+            new StressGenerator(i, PATH_DB, generator));
+
+        stressGenerators[i]->Run();
+    }
+
+    for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i) {
+        stressGenerators[i]->Quit();
+    }
+
+    connection.ExecCommand("DROP TABLE test;");
+}
+
+/*
+Name: SqlConnection_MassiveReadWrite_NaiveSynchronization
+Description: tests massive multiple quiries from many threads
+Expected: no ORM/db failures
+*/
+RUNNER_TEST(SqlConnection_MassiveReadWrite_NaiveSynchronization)
+{
+    srand(time(NULL));
+
+    NaiveSynchronizationObjectGenerator m_generator;
+    MassiveReadWriteTest(&m_generator);
+}
+
+/*
+Name: SqlConnection_Not_Connected_Lucene
+Description: tests connection to not existing database with Lucene option
+Expected: exception throw
+*/
+RUNNER_TEST(SqlConnection_Not_Connected_Lucene)
+{
+    Try {
+        DPL::DB::SqlConnection connection(
+            "/notexisitingdirectiory/foo",
+            DPL::DB::SqlConnection::Flag::
+                UseLucene,
+            DPL::DB::SqlConnection::Flag::RW);
+        RUNNER_ASSERT_MSG(false,
+                          "connection should throw on accessing "
+                          "nonexistent file as a database");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::ConnectionBroken)
+    {
+        RUNNER_ASSERT(true);
+    } catch (DPL::Exception) {
+        RUNNER_ASSERT_MSG(false, "Wrong exception found");
+    }
+}
+
+/*
+Name: SqlConnection_Not_Connected
+Description: tests connection to not existing database without Lucene option
+Expected: exception throw
+*/
+RUNNER_TEST(SqlConnection_Not_Connected)
+{
+    Try {
+        DPL::DB::SqlConnection connection("/notexisitingdirectiory/foo",
+                                          DPL::DB::SqlConnection::Flag::None,
+                                          DPL::DB::SqlConnection::Flag::RW);
+        RUNNER_ASSERT_MSG(false,
+                          "connection should throw on accessing "
+                          "nonexistent file as a database");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::ConnectionBroken)
+    {
+        RUNNER_ASSERT(true);
+    } catch (DPL::Exception) {
+        RUNNER_ASSERT_MSG(false, "Wrong exception found");
+    }
+}
+
+/*
+Name: SqlConnection_Null_Query
+Description: tests resistance to passing NULL as query in ExecCommand
+Expected: exception throw
+*/
+RUNNER_TEST(SqlConnection_Null_Query)
+{
+    DPL::DB::SqlConnection connection(PATH_DB,
+                                      DPL::DB::SqlConnection::Flag::UseLucene,
+                                      DPL::DB::SqlConnection::Flag::RW);
+    Try
+    {
+        connection.ExecCommand(NULL);
+        RUNNER_ASSERT_MSG(false,
+                          "Null pointer should not be accepted");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::SyntaxError)
+    {
+        RUNNER_ASSERT(true);
+    } catch (DPL::Exception) {
+        RUNNER_ASSERT_MSG(false, "Wrong exception found");
+    }
+}
+
+/*
+Name: SqlConnection_Bad_Query
+Description: tests resistance to passing trash as query in ExecCommand
+Expected: exception throw
+*/
+RUNNER_TEST(SqlConnection_Bad_Query)
+{
+    DPL::DB::SqlConnection connection(PATH_DB,
+                                      DPL::DB::SqlConnection::Flag::UseLucene,
+                                      DPL::DB::SqlConnection::Flag::RW);
+    Try
+    {
+        connection.ExecCommand("Some stupid string");
+        RUNNER_ASSERT_MSG(false, "This string should not be accepted");
+    }
+    Catch(DPL::DB::SqlConnection::Exception::SyntaxError)
+    {
+        RUNNER_ASSERT(true);
+    } catch (DPL::Exception) {
+        RUNNER_ASSERT_MSG(false, "Wrong exception found");
+    }
+}
diff --git a/tests/dpl/dbus/CMakeLists.txt b/tests/dpl/dbus/CMakeLists.txt
new file mode 100644 (file)
index 0000000..066ad79
--- /dev/null
@@ -0,0 +1,63 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+INCLUDE(FindPkgConfig)
+
+PKG_CHECK_MODULES(DEPENDENCIES gthread-2.0 REQUIRED) 
+
+SET(TARGET_DBUS_TESTS "dpl-tests-dbus")
+SET(TARGET_DBUS_TEST_SERVICE "dpl-dbus-test-service")
+
+SET(DBUS_TESTS_SRCS
+    ${TESTS_DPL_DIR}/dbus/main.cpp
+    ${TESTS_DPL_DIR}/dbus/test_cases.cpp
+    ${TESTS_DPL_DIR}/dbus/dbus_test.cpp
+    ${TESTS_COMMON_DIR}/src/loop_control.cpp
+)
+
+SET(DBUS_TEST_SERVICE_SRCS
+    ${TESTS_DPL_DIR}/dbus/test_service.cpp
+    ${TESTS_COMMON_DIR}/src/loop_control.cpp
+)
+
+WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_DBUS_TESTS} ${TARGET_DPL_DBUS_EFL})
+WRT_TEST_INCLUDE_DIRECTORIES(${TARGET_DBUS_TESTS}
+    ${TESTS_COMMON_DIR}/include
+    ${DEPENDENCIES_INCLUDE_DIRS}
+)
+WRT_TEST_LINK_DIRECTORIES(${TARGET_DBUS_TESTS} ${DEPENDENCIES_LIBRARY_DIRS})
+WRT_TEST_TARGET_LINK_LIBRARIES(${TARGET_DBUS_TESTS} ${DEPENDENCIES_LIBRARIES})
+WRT_TEST_BUILD(${TARGET_DBUS_TESTS} ${DBUS_TESTS_SRCS})
+WRT_TEST_INSTALL(${TARGET_DBUS_TESTS})
+
+WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_DBUS_TEST_SERVICE} ${TARGET_DPL_DBUS_EFL})
+WRT_TEST_INCLUDE_DIRECTORIES(${TARGET_DBUS_TEST_SERVICE}
+    ${TESTS_COMMON_DIR}/include
+    ${DEPENDENCIES_INCLUDE_DIRS}
+)
+WRT_TEST_LINK_DIRECTORIES(${TARGET_DBUS_TEST_SERVICE} ${DEPENDENCIES_LIBRARY_DIRS})
+WRT_TEST_TARGET_LINK_LIBRARIES(${TARGET_DBUS_TEST_SERVICE} ${DEPENDENCIES_LIBRARIES})
+WRT_TEST_BUILD(${TARGET_DBUS_TEST_SERVICE} ${DBUS_TEST_SERVICE_SRCS})
+WRT_TEST_INSTALL(${TARGET_DBUS_TEST_SERVICE})
+
+INSTALL(FILES
+        ${TESTS_DPL_DIR}/dbus/data/org.tizen.DBusTestService.service
+        DESTINATION /usr/share/dbus-1/services
+)
diff --git a/tests/dpl/dbus/data/org.tizen.DBusTestService.service b/tests/dpl/dbus/data/org.tizen.DBusTestService.service
new file mode 100644 (file)
index 0000000..f024543
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.tizen.DBusTestService
+Exec=/usr/bin/dpl-dbus-test-service
diff --git a/tests/dpl/dbus/dbus_test.cpp b/tests/dpl/dbus/dbus_test.cpp
new file mode 100644 (file)
index 0000000..2e8d51b
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    dbus_test.cpp
+ * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @brief   Implementation file for DBusTest and DBusTestManager.
+ */
+
+#include <dpl/test/test_runner.h>
+#include "loop_control.h"
+#include "dbus_test.h"
+
+DBusTest::DBusTest(const std::string& name) :
+    m_name(name),
+    m_status(Status::NONE)
+{}
+
+void DBusTest::run(unsigned int timeout)
+{
+    DPL::Event::ControllerEventHandler<TimeoutEvent>::Touch();
+    DPL::Event::ControllerEventHandler<QuitEvent>::Touch();
+
+    DPL::Event::ControllerEventHandler<TimeoutEvent>::PostTimedEvent(
+        TimeoutEvent(), timeout);
+
+    LoopControl::wrt_start_loop();
+
+    switch (m_status) {
+    case Status::FAILED:
+        throw DPL::Test::TestRunner::TestFailed(m_name.c_str(),
+                                                __FILE__,
+                                                __LINE__,
+                                                m_message);
+
+    case Status::SUCCESS:
+    case Status::NONE:
+    default:
+        break;
+    }
+}
+
+void DBusTest::quit()
+{
+    DPL::Event::ControllerEventHandler<QuitEvent>::PostEvent(QuitEvent());
+}
+
+void DBusTest::setStatus(Status status)
+{
+    m_status = status;
+}
+
+void DBusTest::setMessage(const std::string& message)
+{
+    m_message = message;
+}
+
+void DBusTest::success()
+{
+    m_status = Status::SUCCESS;
+}
+
+void DBusTest::fail(const std::string& message)
+{
+    m_status = Status::FAILED;
+    m_message = message;
+}
+
+void DBusTest::OnEventReceived(const TimeoutEvent& /*event*/)
+{
+    fail("Test timed out.");
+
+    // Saving one event dispatch since Quit and Timeout work on the same thread.
+    LoopControl::wrt_end_loop();
+}
+
+void DBusTest::OnEventReceived(const QuitEvent& /*event*/)
+{
+    LoopControl::wrt_end_loop();
+}
+
+DBusTestManager& DBusTestManager::getInstance()
+{
+    static DBusTestManager instance;
+    return instance;
+}
+
+DBusTestManager::DBusTestManager() : m_test(NULL) { }
+
+DBusTest& DBusTestManager::getCurrentTest() const
+{
+    Assert(NULL != m_test && "Test not set.");
+
+    return *m_test;
+}
+
+void DBusTestManager::setCurrentTest(DBusTest& test)
+{
+    m_test = &test;
+}
+
+void DBusTestManager::clear()
+{
+    m_test = NULL;
+}
diff --git a/tests/dpl/dbus/dbus_test.h b/tests/dpl/dbus/dbus_test.h
new file mode 100644 (file)
index 0000000..3c7ffe9
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    dbus_test.h
+ * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @brief   Header file for DBusTest and DBusTestManager.
+ */
+
+#ifndef WRT_TESTS_DBUS_TESTS_DBUS_TEST_H
+#define WRT_TESTS_DBUS_TESTS_DBUS_TEST_H
+
+#include <string>
+#include <dpl/event/controller.h>
+#include <dpl/generic_event.h>
+
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+DECLARE_GENERIC_EVENT_0(TimeoutEvent)
+
+class DBusTest :
+    private DPL::Event::Controller<DPL::TypeListDecl<QuitEvent,
+                                                     TimeoutEvent>::Type>
+{
+  public:
+    enum class Status
+    {
+        NONE,
+        SUCCESS,
+        FAILED
+    };
+
+    explicit DBusTest(const std::string& name);
+
+    void run(unsigned int timeout);
+    void quit();
+
+    void setStatus(Status status);
+    void setMessage(const std::string& message);
+
+    void success();
+    void fail(const std::string& message = std::string());
+
+  private:
+    void OnEventReceived(const TimeoutEvent& event);
+    void OnEventReceived(const QuitEvent& event);
+
+    std::string m_name;
+    Status m_status;
+    std::string m_message;
+};
+
+class DBusTestManager : private DPL::Noncopyable
+{
+  public:
+    static DBusTestManager& getInstance();
+
+    DBusTest& getCurrentTest() const;
+    void setCurrentTest(DBusTest& test);
+
+    void clear();
+
+  private:
+    DBusTestManager();
+
+    DBusTest* m_test;
+};
+
+#define DBUS_TEST(TestProc)                                                    \
+    void DBus##TestProc();                                                     \
+    RUNNER_TEST(TestProc)                                                      \
+    {                                                                          \
+        DBusTest test(#TestProc);                                              \
+        DBusTestManager::getInstance().setCurrentTest(test);                   \
+        DBus##TestProc();                                                      \
+        DBusTestManager::getInstance().clear();                                \
+    }                                                                          \
+    void DBus##TestProc()
+
+#endif
diff --git a/tests/dpl/dbus/main.cpp b/tests/dpl/dbus/main.cpp
new file mode 100644 (file)
index 0000000..d06a4c0
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main.
+ */
+
+#include "loop_control.h"
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+
+int main(int argc, char *argv[])
+{
+    LoopControl::init_loop(argc, argv);
+
+    LogInfo("Running tests");
+    int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc,
+                                                                           argv);
+
+    return status;
+}
diff --git a/tests/dpl/dbus/test_cases.cpp b/tests/dpl/dbus/test_cases.cpp
new file mode 100644 (file)
index 0000000..0d855ef
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    TestCases.cpp
+ * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for test cases for DBus internal tests.
+ */
+
+#include <string>
+#include <dpl/test/test_runner.h>
+#include <dpl/event/event_listener.h>
+#include <dpl/dbus/exception.h>
+#include <dpl/dbus/connection.h>
+#include <dpl/dbus/interface.h>
+#include "dbus_test.h"
+
+namespace {
+const std::string dbusServiceName = "org.freedesktop.DBus";
+const std::string dbusObjectPath = "/";
+const std::string dbusInterfaceName = "org.freedesktop.DBus";
+const std::string dbusMethodGetId = "GetId";
+
+const std::string serviceName = "org.tizen.DBusTestService";
+const std::string objectPath = "/org/tizen/DBusTestService";
+const std::string interfaceName = "org.tizen.DBusTestService";
+const std::string methodNameEcho = "echo";
+const std::string methodNameQuit = "quit";
+const std::string nodeInfo =
+    "<?xml version='1.0'?>"
+    "<node>"
+    "  <interface name='" + interfaceName + "'>"
+                                            "    <method name='" +
+    methodNameEcho + "'>"
+                     "      <arg type='s' name='challenge' direction='in'/>"
+                     "      <arg type='s' name='response' direction='out'/>"
+                     "    </method>"
+                     "    <method name='"
+    + methodNameQuit + "'>"
+                       "    </method>"
+                       "  </interface>"
+                       "</node>";
+
+const std::string challenge = "Hello world!";
+
+const int DEFAULT_TIMEOUT = 2; // in seconds
+}
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+/*
+Name: AcquireSessionBus
+Description: tests acquiring session bus
+Expected: no exceptions
+*/
+RUNNER_TEST(AcquireSessionBus)
+{
+    try {
+        DPL::DBus::Connection::sessionBus();
+    } catch (const DPL::DBus::Exception& ex) {
+        RUNNER_ASSERT_MSG(false, ex.DumpToString());
+    }
+}
+
+/*
+Name: AcquireSystemBus
+Description: tests acquiring system bus
+Expected: no exceptions
+*/
+RUNNER_TEST(AcquireSystemBus)
+{
+    try {
+        DPL::DBus::Connection::systemBus();
+    } catch (const DPL::DBus::Exception& ex) {
+        RUNNER_ASSERT_MSG(false, ex.DumpToString());
+    }
+}
+
+/*
+Name: ParseNodeInfo
+Description: creates dbus interface from xml string
+Expected: interface should be created correctly
+*/
+RUNNER_TEST(ParseNodeInfo)
+{
+    try {
+        auto ifaces = DPL::DBus::Interface::fromXMLString(nodeInfo);
+        RUNNER_ASSERT(!ifaces.empty());
+
+        auto iface = ifaces.at(0);
+        RUNNER_ASSERT(NULL != iface->getVTable());
+        RUNNER_ASSERT(NULL != iface->getInfo());
+    } catch (const DPL::DBus::Exception& ex) {
+        RUNNER_ASSERT_MSG(false, ex.DumpToString());
+    }
+}
+
+/*
+Name: InvokeRemoteMethod
+Description: performs procedure call via dbus
+Expected: call should return not empty id
+*/
+RUNNER_TEST(InvokeRemoteMethod)
+{
+    try {
+        auto connection = DPL::DBus::Connection::systemBus();
+        auto freedesktop = connection->createObjectProxy(dbusServiceName,
+                                                         dbusObjectPath);
+        auto getId = freedesktop->createMethodProxy<std::string>
+                (dbusInterfaceName, dbusMethodGetId);
+        RUNNER_ASSERT(!getId().empty());
+    } catch (const DPL::DBus::Exception& ex) {
+        RUNNER_ASSERT_MSG(false, ex.DumpToString());
+    }
+}
+
+class RegisterServiceListener :
+    public DPL::Event::EventListener<DPL::DBus::ConnectionEvents::
+                                         ServiceNameAcquiredEvent>
+{
+  public:
+    void OnEventReceived(
+        const DPL::DBus::ConnectionEvents::ServiceNameAcquiredEvent& event)
+    {
+        DBusTest& test = DBusTestManager::getInstance().getCurrentTest();
+
+        auto name = event.GetArg0();
+        if (serviceName == name) {
+            test.success();
+        } else {
+            test.fail("Acquired service name: " + name);
+        }
+        test.quit();
+    }
+};
+
+/*
+Name: RegisterService
+Description: tests event listener for AcquiredEvent in context of dbus
+Expected: event should be received
+*/
+DBUS_TEST(RegisterService)
+{
+    try {
+        RegisterServiceListener listener;
+
+        auto connection = DPL::DBus::Connection::sessionBus();
+        connection->DPL::Event::EventSupport<DPL::DBus::ConnectionEvents::
+                                                 ServiceNameAcquiredEvent>::
+            AddListener(&listener);
+        connection->registerService(serviceName);
+
+        DBusTestManager::getInstance().getCurrentTest().run(DEFAULT_TIMEOUT);
+    } catch (const DPL::DBus::Exception& ex) {
+        RUNNER_ASSERT_MSG(false, ex.DumpToString());
+    }
+}
+
+/**
+ * This test checks:
+ * - object registration (done on the wrt-dbus-test-service side)
+ * - service registration (done on the wrt-dbus-test-service side)
+ * - dispatching method calls (done on the wrt-dbus-test-service side)
+ * - launching dbus service on demand
+ * - invoking remote method(s)
+ */
+DBUS_TEST(InvokeTestService)
+{
+    try {
+        auto connection = DPL::DBus::Connection::sessionBus();
+        auto testService = connection->createObjectProxy(serviceName,
+                                                         objectPath);
+        auto echo = testService->createMethodProxy<std::string, std::string>
+                (interfaceName, methodNameEcho);
+        auto response = echo(challenge);
+
+        testService->createMethodProxy<void>(interfaceName, methodNameQuit) ();
+
+        RUNNER_ASSERT_MSG(response == challenge,
+                          "[challenge = " << challenge <<
+                          ", response = " << response << "]");
+    } catch (const DPL::DBus::Exception& ex) {
+        RUNNER_ASSERT_MSG(false, ex.DumpToString());
+    }
+}
diff --git a/tests/dpl/dbus/test_service.cpp b/tests/dpl/dbus/test_service.cpp
new file mode 100644 (file)
index 0000000..510e4c5
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    test_service.cpp
+ * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @brief   Implementation file for wrt-dbus-test-service.
+ */
+
+#include <string>
+#include <dpl/dbus/connection.h>
+#include <dpl/dbus/object.h>
+#include <dpl/dbus/interface.h>
+#include <dpl/dbus/dispatcher.h>
+#include <loop_control.h>
+
+namespace {
+const std::string serviceName = "org.tizen.DBusTestService";
+const std::string objectPath = "/org/tizen/DBusTestService";
+const std::string interfaceName = "org.tizen.DBusTestService";
+const std::string methodNameEcho = "echo";
+const std::string methodNameQuit = "quit";
+const std::string nodeInfo =
+    "<?xml version='1.0'?>"
+    "<node>"
+    "  <interface name='" + interfaceName + "'>"
+                                            "    <method name='" +
+    methodNameEcho + "'>"
+                     "      <arg type='s' name='challenge' direction='in'/>"
+                     "      <arg type='s' name='response' direction='out'/>"
+                     "    </method>"
+                     "    <method name='"
+    + methodNameQuit + "'>"
+                       "    </method>"
+                       "  </interface>"
+                       "</node>";
+}
+
+class TestServiceDispatcher : public DPL::DBus::Dispatcher
+{
+  private:
+    void onMethodCall(GDBusConnection* /*connection*/,
+                      const gchar* /*sender*/,
+                      const gchar* /*objectPath*/,
+                      const gchar* /*interfaceName*/,
+                      const gchar* methodName,
+                      GVariant* parameters,
+                      GDBusMethodInvocation* invocation)
+    {
+        if (methodNameEcho == methodName) {
+            LogDebug("Echo");
+            g_dbus_method_invocation_return_value(invocation,
+                                                  parameters);
+        } else if (methodNameQuit == methodName) {
+            LogDebug("Quit");
+            g_dbus_method_invocation_return_value(invocation, NULL);
+            LoopControl::wrt_end_loop();
+        }
+    }
+};
+
+int main(int argc, char* argv[])
+{
+    LoopControl::init_loop(argc, argv);
+    TestServiceDispatcher dispatcher;
+
+    auto iface = DPL::DBus::Interface::fromXMLString(nodeInfo).at(0);
+    iface->setDispatcher(&dispatcher);
+    auto object = DPL::DBus::Object::create(objectPath, iface);
+    auto connection = DPL::DBus::Connection::sessionBus();
+    connection->registerObject(object);
+    connection->registerService(serviceName);
+    LoopControl::wrt_start_loop();
+
+    return 0;
+}
diff --git a/tests/dpl/event/CMakeLists.txt b/tests/dpl/event/CMakeLists.txt
new file mode 100644 (file)
index 0000000..de3db4a
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Test files
+#
+# Define all DPL tests sources.
+# Runner is responsible for runnint it all and
+# generating proper output files
+#
+
+SET(TARGET_NAME "dpl-tests-event")
+
+# Set DPL tests sources
+SET(DPL_TESTS_EVENT_SOURCES
+    ${TESTS_DPL_DIR}/event/main.cpp
+    ${TESTS_DPL_DIR}/event/test_controller.cpp
+    ${TESTS_DPL_DIR}/event/test_event_support.cpp
+    ${TESTS_DPL_DIR}/event/test_ic_delegate.cpp
+    ${TESTS_DPL_DIR}/event/test_property.cpp
+)
+
+WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_EVENT_EFL})
+WRT_TEST_BUILD(${TARGET_NAME} ${DPL_TESTS_EVENT_SOURCES})
+WRT_TEST_INSTALL(${TARGET_NAME})
\ No newline at end of file
diff --git a/tests/dpl/event/main.cpp b/tests/dpl/event/main.cpp
new file mode 100644 (file)
index 0000000..4ed6191
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main.
+ */
+
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+    return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}
diff --git a/tests/dpl/event/test_controller.cpp b/tests/dpl/event/test_controller.cpp
new file mode 100644 (file)
index 0000000..8f0a630
--- /dev/null
@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_controller.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test controller
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/event/controller.h>
+#include <dpl/thread.h>
+#include <dpl/generic_event.h>
+#include <dpl/waitable_handle.h>
+#include <dpl/waitable_event.h>
+#include <dpl/type_list.h>
+#include <dpl/application.h>
+#include <dpl/atomic.h>
+#include <list>
+#include <vector>
+#include <memory>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+class IntController :
+    public DPL::Event::Controller<DPL::TypeListDecl<int>::Type>
+{
+  private:
+    int m_value;
+
+  protected:
+    virtual void OnEventReceived(const int &event)
+    {
+        m_value = event;
+    }
+
+  public:
+    IntController() :
+        m_value(-1)
+    {}
+
+    int Value() const
+    {
+        return m_value;
+    }
+};
+
+DECLARE_GENERIC_EVENT_1(DoneSignalEvent, DPL::WaitableEvent *)
+
+class ThreadController :
+    public DPL::Event::Controller<DPL::TypeListDecl<DoneSignalEvent>::Type>
+{
+  private:
+    DPL::Thread *m_value;
+
+  protected:
+    virtual void OnEventReceived(const DoneSignalEvent &event)
+    {
+        m_value = DPL::Thread::GetCurrentThread();
+        event.GetArg0()->Signal();
+    }
+
+  public:
+    ThreadController() :
+        m_value(NULL)
+    {}
+
+    DPL::Thread *Value() const
+    {
+        return m_value;
+    }
+};
+
+struct StrangeStruct
+{
+    int a;
+    float b;
+    double c;
+};
+
+class StrangeController :
+    public DPL::Event::Controller<DPL::TypeListDecl<char, short, int, long,
+                                                    unsigned char,
+                                                    unsigned short,
+                                                    unsigned int, unsigned long,
+                                                    float, double,
+                                                    StrangeStruct>::Type>
+{
+  protected:
+    virtual void OnEventReceived(const char &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const short &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const int &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const long &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const unsigned char &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const unsigned short &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const unsigned int &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const unsigned long &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const float &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const double &event)
+    {
+        (void)event;
+    }
+    virtual void OnEventReceived(const StrangeStruct &event)
+    {
+        (void)event;
+    }
+};
+
+/*
+Name: Controller_InitSimple
+Description: tests initialization of simple int controller
+Expected: no exceptions
+*/
+RUNNER_TEST(Controller_InitSimple)
+{
+    IntController controller;
+    controller.Touch();
+    RUNNER_ASSERT(controller.Value() == -1);
+}
+
+/*
+Name: Controller_InitStrange
+Description: tests initialization of struct controller
+Expected: no exceptions
+*/
+RUNNER_TEST(Controller_InitStrange)
+{
+    StrangeController controller;
+    controller.Touch();
+}
+
+/*
+Name: Controller_PostEventToThread
+Description: tests post events to other thread
+Expected: thread id gathered in event handling method should match id of created thread
+*/
+RUNNER_TEST(Controller_PostEventToThread)
+{
+    ThreadController controller;
+    controller.Touch();
+
+    DPL::Thread thread;
+    thread.Run();
+
+    controller.SwitchToThread(&thread);
+
+    DPL::WaitableEvent waitHandle;
+
+    controller.PostEvent(DoneSignalEvent(&waitHandle));
+
+    DPL::WaitForSingleHandle(waitHandle.GetHandle());
+
+    controller.SwitchToThread(NULL);
+
+    RUNNER_ASSERT(controller.Value() == &thread);
+}
+
+/*
+Name: Controller_PostTimedEventToThread
+Description: tests post events to other thread with time delay
+Expected: thread id gathered in event handling method should match id of created thread
+*/
+RUNNER_TEST(Controller_PostTimedEventToThread)
+{
+    ThreadController controller;
+    controller.Touch();
+
+    DPL::Thread thread;
+    thread.Run();
+
+    controller.SwitchToThread(&thread);
+
+    DPL::WaitableEvent waitHandle;
+
+    controller.PostTimedEvent(DoneSignalEvent(&waitHandle), 0.5);
+
+    DPL::WaitForSingleHandle(waitHandle.GetHandle());
+
+    controller.SwitchToThread(NULL);
+
+    RUNNER_ASSERT(controller.Value() == &thread);
+}
+
+DECLARE_GENERIC_EVENT_2(TouchInThread, DPL::WaitableEvent *, DPL::Thread * *)
+DECLARE_GENERIC_EVENT_2(TouchedControllerSignal,
+                        DPL::WaitableEvent *,
+                        DPL::Thread * *)
+
+class TouchInThreadController :
+    public DPL::Event::Controller<DPL::TypeListDecl<TouchInThread>::Type>,
+    private DPL::Event::Controller<DPL::TypeListDecl<TouchedControllerSignal>::
+                                       Type>
+{
+  public:
+    typedef DPL::Event::Controller<DPL::TypeListDecl<TouchInThread>::Type>
+    PublicController;
+    typedef DPL::Event::Controller<DPL::TypeListDecl<TouchedControllerSignal>::
+                                       Type> PrivateController;
+
+    virtual void OnEventReceived(const TouchInThread &event)
+    {
+        // Touch controller in thread
+        PrivateController::Touch();
+
+        // Post signal
+        PrivateController::PostEvent(TouchedControllerSignal(event.GetArg0(),
+                                                             event.GetArg1()));
+    }
+
+    virtual void OnEventReceived(const TouchedControllerSignal &event)
+    {
+        // Return touched thread
+        *event.GetArg1() = DPL::Thread::GetCurrentThread();
+
+        // Signal waitable event
+        event.GetArg0()->Signal();
+    }
+};
+
+/*
+Name: Controller_TouchInThread
+Description: tests ability to touch (initizilize / set destination thread) in creatd thread
+ other than thread were controlelr object was created
+Expected: thread id gathered in event handling method should match id of created thread
+*/
+RUNNER_TEST(Controller_TouchInThread)
+{
+    TouchInThreadController controller;
+    controller.PublicController::Touch();
+
+    DPL::Thread thread;
+    thread.Run();
+
+    controller.PublicController::SwitchToThread(&thread);
+
+    DPL::WaitableEvent waitHandle;
+    DPL::Thread *touchedThread = NULL;
+
+    controller.PublicController::PostEvent(TouchInThread(&waitHandle,
+                                                         &touchedThread));
+
+    DPL::WaitForSingleHandle(waitHandle.GetHandle());
+
+    controller.PublicController::SwitchToThread(NULL);
+
+    RUNNER_ASSERT(touchedThread == &thread);
+}
+
+/*
+Name: Controller_SynchronizedEvent
+Description: tests ability to post synchronized events to ther thread
+Expected: correct value should be saved when event was handled
+*/
+RUNNER_TEST(Controller_SynchronizedEvent)
+{
+    IntController controller;
+    controller.Touch();
+
+    DPL::Thread thread;
+    thread.Run();
+
+    controller.SwitchToThread(&thread);
+    controller.PostSyncEvent(12345);
+    controller.SwitchToThread(NULL);
+
+    RUNNER_ASSERT(controller.Value() == 12345);
+}
+
+const int ControllersNumber = 5;
+const int MaxEventsPerController = 1;
+const int MaxEvents = ControllersNumber * MaxEventsPerController;
+const int ControllersPerThread = 1;
+
+class TestController; //Forward Declaration
+
+typedef std::shared_ptr<TestController> ControllerPtr;
+typedef std::shared_ptr<DPL::Thread> ThreadPtr;
+typedef std::vector<ControllerPtr> ControllerList;
+typedef std::list<ThreadPtr> ThreadList;
+
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+class QuitController :
+    public DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>,
+    public DPL::ApplicationExt
+{
+  public:
+    explicit QuitController() : DPL::ApplicationExt(1, NULL, "test-app")
+    {
+        Touch();
+    }
+
+  protected:
+    virtual void OnEventReceived(const QuitEvent &)
+    {
+        Quit();
+    }
+};
+
+struct TestContext
+{
+    ControllerList controllers;
+    ThreadList threads;
+    QuitController quitter;
+    DPL::Atomic g_ReceivedCounter;
+    DPL::Atomic g_SentCounter;
+};
+typedef std::unique_ptr<TestContext> TestContextPtr;
+TestContextPtr testContextPtr;
+
+DECLARE_GENERIC_EVENT_0(StartSendEvent)
+DECLARE_GENERIC_EVENT_0(RandomEvent)
+class TestController :
+    public DPL::Event::Controller<DPL::TypeListDecl<RandomEvent,
+                                                    StartSendEvent>::Type>
+{
+  public:
+    explicit TestController()
+    {
+        Touch();
+    }
+
+  protected:
+    virtual void OnEventReceived(const RandomEvent &)
+    {
+        ++testContextPtr->g_ReceivedCounter;
+        if (testContextPtr->g_ReceivedCounter == MaxEvents) {
+            testContextPtr->quitter.DPL::Event::ControllerEventHandler<
+                QuitEvent>::PostEvent(QuitEvent());
+            return;
+        }
+    }
+    virtual void OnEventReceived(const StartSendEvent &)
+    {
+        for (int i = 0; i < MaxEventsPerController; ++i) {
+            if (testContextPtr->g_SentCounter > MaxEvents) {
+                return;
+            }
+            ++testContextPtr->g_SentCounter;
+            int id = rand() % static_cast<int>(testContextPtr->controllers.size());
+            testContextPtr->controllers.at(id)->DPL::Event::
+                ControllerEventHandler<RandomEvent>::PostEvent(RandomEvent());
+        }
+    }
+};
+
+/*
+Name: Controllers_MultipleEvents
+Description: tests controller coooperation.
+ This runs many controllers in many threads. Each controller sends
+ to other randomly chosen controller events.
+Expected: Test is supposed to be ended when all limits of sent event will be reach
+ -> all scheduled event will be sent and received.
+*/
+RUNNER_TEST(Controllers_MultipleEvents)
+{
+    srand(time(NULL) );
+
+    testContextPtr.reset(new TestContext());
+    testContextPtr->controllers.reserve(ControllersNumber);
+
+    for (int i = 0; i < ControllersNumber; ++i) {
+        if (testContextPtr->controllers.size() % ControllersPerThread == 0) {
+            ThreadPtr thread = ThreadPtr(new DPL::Thread());
+            testContextPtr->threads.push_back(thread);
+            thread->Run();
+        }
+
+        ControllerPtr controller = ControllerPtr(new TestController());
+        testContextPtr->controllers.push_back(controller);
+        if (testContextPtr->controllers.size() % 2 == 0) {
+            //This controller is being switched to thread (otherwise it is
+            // touched to main thread)
+            ThreadPtr thread = testContextPtr->threads.back();
+            controller->SwitchToThread(thread.get());
+        }
+        controller->DPL::Event::ControllerEventHandler<StartSendEvent>::
+            PostEvent(StartSendEvent());
+    }
+    testContextPtr->quitter.Exec();
+    RUNNER_ASSERT(
+        testContextPtr->g_SentCounter == testContextPtr->g_ReceivedCounter);
+    testContextPtr.reset();
+}
diff --git a/tests/dpl/event/test_event_support.cpp b/tests/dpl/event/test_event_support.cpp
new file mode 100644 (file)
index 0000000..e900e9c
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_event_support.cpp
+ * @author      Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
+ * @author      Pawel Sikorski (p.sikorski@samsung.com)
+ * @version     1.0
+ * @brief       This file contains test for event support
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/generic_event.h>
+#include <dpl/event/event_listener.h>
+#include <dpl/event/event_support.h>
+#include <dpl/application.h>
+#include <dpl/event/controller.h>
+#include <dpl/fast_delegate.h>
+#include <dpl/log/log.h>
+
+DECLARE_GENERIC_EVENT_0(TestEvent)
+
+class TestListener : public DPL::Event::EventListener<TestEvent>
+{
+  public:
+    explicit TestListener() : m_dummyVar(0) { }
+    void OnEventReceived(const TestEvent &)
+    {
+        m_dummyVar = 1;
+    }
+    int GetDummyVar() const
+    {
+        return m_dummyVar;
+    }
+    void ZeroDummyVar()
+    {
+        m_dummyVar = 0;
+    }
+
+  private:
+    int m_dummyVar;
+};
+
+class TestEventSupport :
+    public DPL::Event::EventSupport<TestEvent>
+{
+  public:
+    void TestEmitEvent()
+    {
+        EmitEvent(TestEvent());
+    }
+};
+
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+
+class QuitController :
+    public DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>,
+    public DPL::ApplicationExt
+{
+  public:
+    QuitController() : DPL::ApplicationExt(1, NULL, "test-app")
+    {
+        Touch();
+    }
+
+  protected:
+    virtual void OnEventReceived(const QuitEvent &)
+    {
+        Quit();
+    }
+};
+
+/*
+Name: EventSupport_DestroyBeforeProcessing
+Description: tests if remoign listener is full successfull
+Expected: dummy var should be affected by explicit call of ZeroDummyVar(),
+ but no by emitting event after removing listener
+*/
+RUNNER_TEST(EventSupport_DestroyBeforeProcessing)
+{
+    QuitController quitter;
+    quitter.PostTimedEvent(QuitEvent(), 1.0);
+
+    TestListener eventListener;
+    {
+        TestEventSupport eventSupport;
+        eventSupport.AddListener(&eventListener);
+        eventSupport.TestEmitEvent();
+        eventSupport.RemoveListener(&eventListener);
+    }
+    eventListener.ZeroDummyVar();
+
+    quitter.Exec();
+    RUNNER_ASSERT(eventListener.GetDummyVar() == 0);
+}
+
+int g_delegateTest;
+
+void OnDelegateTest(const int &k);
+
+void OnDelegateTest(const int &k)
+{
+    LogInfo("Got delegate call");
+    g_delegateTest = k;
+}
+
+class DelegateTestSupport :
+    public DPL::Event::EventSupport<int>
+{
+  public:
+    void Test()
+    {
+        EmitEvent(7);
+    }
+};
+
+/*
+Name: EventSupport_BindDelegate
+Description: tests if event support derived class successfully propagates
+ event to registered listener
+Expected: value of event should be passed to listener
+*/
+RUNNER_TEST(EventSupport_BindDelegate)
+{
+    g_delegateTest = 0;
+
+    DelegateTestSupport support;
+    support.AddListener(&OnDelegateTest);
+
+    QuitController quitter;
+    quitter.PostTimedEvent(QuitEvent(), 1.0);
+
+    support.Test();
+
+    quitter.Exec();
+
+    support.RemoveListener(&OnDelegateTest);
+
+    RUNNER_ASSERT(g_delegateTest == 7);
+}
diff --git a/tests/dpl/event/test_ic_delegate.cpp b/tests/dpl/event/test_ic_delegate.cpp
new file mode 100644 (file)
index 0000000..77856f4
--- /dev/null
@@ -0,0 +1,603 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_ic_delegate.cpp
+ * @author      Pawel Sikorski (p.sikorski@samsung.com)
+ * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of fast delegate tests.
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/application.h>
+#include <dpl/event/controller.h>
+#include <dpl/log/log.h>
+#include <dpl/fast_delegate.h>
+#include <dpl/event/inter_context_delegate.h>
+#include <dpl/thread.h>
+#include <dpl/waitable_event.h>
+#include <dpl/assert.h>
+#include <dpl/mutex.h>
+#include <dpl/type_list.h>
+#include <memory>
+RUNNER_TEST_GROUP_INIT(DPL)
+
+const int IntVal = 123;
+const std::string StringVal = "someString";
+
+typedef DPL::Event::ICDelegate<> GetNothingDlpType;
+typedef DPL::Event::ICDelegate<int> GetIntDlgType;
+typedef DPL::Event::ICDelegate<int, std::string> GetIntAndStringDlgType;
+DECLARE_GENERIC_EVENT_1(GetNothingEvent, GetNothingDlpType)
+DECLARE_GENERIC_EVENT_1(GetIntEvent, GetIntDlgType)
+DECLARE_GENERIC_EVENT_1(GetIntAndStringEvent, GetIntAndStringDlgType)
+
+class ICTestController :
+    public DPL::Event::Controller<DPL::TypeListDecl<GetNothingEvent,
+                                                    GetIntEvent,
+                                                    GetIntAndStringEvent>::Type>
+{
+  public:
+    ICTestController() { }
+
+  protected:
+    virtual void OnEventReceived(const GetNothingEvent& event)
+    {
+        event.GetArg0() (); //calling intercontext delegate
+    }
+    virtual void OnEventReceived(const GetIntEvent& event)
+    {
+        event.GetArg0() (IntVal); //calling intercontext delegate
+    }
+
+    virtual void OnEventReceived(const GetIntAndStringEvent& event)
+    {
+        event.GetArg0() (IntVal, StringVal); //calling intercontext delegate
+    }
+};
+
+struct TestResult
+{
+    TestResult() :
+        m_correctThread0(false),
+        m_correctThread1(false),
+        m_correctThread2(false),
+        m_int(-1),
+        m_int2(-1),
+        m_string("")
+    {}
+
+    void TestEventsPassed()
+    {
+        RUNNER_ASSERT(m_correctThread0);
+        RUNNER_ASSERT(m_correctThread1);
+        RUNNER_ASSERT(m_int == IntVal);
+        RUNNER_ASSERT(m_correctThread2);
+        RUNNER_ASSERT(m_int2 == IntVal);
+        RUNNER_ASSERT(m_string == StringVal);
+    }
+
+    void TestEventsDidNotPass()
+    {
+        RUNNER_ASSERT(!m_correctThread0);
+        RUNNER_ASSERT(!m_correctThread1);
+        RUNNER_ASSERT(m_int == -1);
+        RUNNER_ASSERT(!m_correctThread2);
+        RUNNER_ASSERT(m_int2 == -1);
+        RUNNER_ASSERT(m_string == "");
+    }
+
+    bool m_correctThread0;
+    bool m_correctThread1;
+    bool m_correctThread2;
+    int m_int;
+    int m_int2;
+    std::string m_string;
+};
+
+class TestContextFreeClass :
+    protected DPL::Thread,
+    public DPL::Event::ICDelegateSupport<TestContextFreeClass>
+{
+  public:
+    TestContextFreeClass(ICTestController* controller, TestResult* result) :
+        Thread(),
+        m_testResult(result),
+        m_controller(controller)
+    {
+        LogDebug("Context thread id = " << this);
+    }
+
+    void Run()
+    {
+        LogDebug("Running Context Free thread");
+        Thread::Run();
+    }
+
+    void Quit()
+    {
+        LogDebug("Exiting Context Free thread");
+        Thread::Quit();
+    }
+
+    void Wait()
+    {
+        LogDebug("Waiting for thread");
+        DPL::WaitForSingleHandle(m_waitable.GetHandle());
+    }
+
+  protected:
+    void OnNothing()
+    {
+        LogDebug("Received nothing in thread = " << GetCurrentThread());
+        m_testResult->m_correctThread0 = (GetCurrentThread() == this);
+    }
+
+    void OnIntReceive(int val)
+    {
+        LogDebug("Received int in thread = " << GetCurrentThread());
+        m_testResult->m_correctThread1 = (GetCurrentThread() == this);
+        m_testResult->m_int = val;
+    }
+
+    void OnIntAndStringReceive(int val, std::string stringval)
+    {
+        LogDebug("Received int and string in thread = " << GetCurrentThread());
+        m_testResult->m_correctThread2 = (GetCurrentThread() == this);
+        m_testResult->m_int2 = val;
+        m_testResult->m_string = stringval;
+        m_waitable.Signal();
+    }
+
+    virtual int ThreadEntry()
+    {
+        GetNothingEvent getNothingEvent(
+            makeICDelegate(
+                &TestContextFreeClass::OnNothing));
+        m_controller->DPL::Event::ControllerEventHandler<GetNothingEvent>::
+            PostEvent(
+            getNothingEvent);
+
+        GetIntEvent getIntEvent(
+            makeICDelegate(
+                &TestContextFreeClass::OnIntReceive));
+        m_controller->DPL::Event::ControllerEventHandler<GetIntEvent>::
+            PostEvent(
+            getIntEvent);
+
+        GetIntAndStringEvent getIntAndStringEvent(
+            makeICDelegate(
+                &TestContextFreeClass::OnIntAndStringReceive));
+        m_controller->DPL::Event::ControllerEventHandler<GetIntAndStringEvent>
+            ::PostEvent(
+            getIntAndStringEvent);
+
+        return Thread::ThreadEntry();
+    }
+
+  private:
+    TestResult* m_testResult;
+    DPL::WaitableEvent m_waitable;
+    ICTestController* m_controller;
+};
+
+/*
+Name: ICDelegate_0
+Description: checks if delegetes are correctly called
+Expected: delegates should be called from right context
+*/
+RUNNER_TEST(ICDelegate_0)
+{
+    DPL::Thread thread;
+    thread.Run();
+    LogDebug("Controller thread id = " << &thread);
+
+    ICTestController testController;
+    testController.Touch();
+    testController.SwitchToThread(&thread);
+
+    TestResult result;
+    TestContextFreeClass* contextFree =
+        new TestContextFreeClass(&testController, &result);
+    result.TestEventsDidNotPass();
+
+    thread.Run();
+    contextFree->Run();
+    contextFree->Wait();
+    contextFree->Quit();
+    thread.Quit();
+
+    delete contextFree;
+
+    result.TestEventsPassed();
+}
+
+/*
+Name: ICDelegate_1
+Description: checks if delegetes are correctly called
+Expected: delegates should be called from right context
+*/
+RUNNER_TEST(ICDelegate_1)
+{
+    DPL::Thread thread;
+    LogDebug("Controller thread id = " << &thread);
+
+    ICTestController testController;
+    testController.Touch();
+    testController.SwitchToThread(&thread);
+
+    TestResult result;
+    TestContextFreeClass* contextFree =
+        new TestContextFreeClass(&testController, &result);
+    result.TestEventsDidNotPass();
+
+    contextFree->Run();
+    contextFree->Quit();
+    delete contextFree; //deleting Delegates before actual Events are worked out
+    thread.Run();
+    thread.Quit();
+
+    result.TestEventsDidNotPass();
+}
+
+class TestContextFree;
+class TestRunnerInThread;
+
+namespace {
+const int ControllersPerThread = 40;
+const int ContextFreePerThread = 180;
+const int TestsPerController = 110;
+const int TestThreads = 23;
+const int TestsPerThread = 100;
+const int NumberOfEvents = 230;
+
+typedef std::shared_ptr<ICTestController> ICTestControllerPtr;
+typedef std::shared_ptr<TestContextFree> TestContextFreePtr;
+typedef std::shared_ptr<TestRunnerInThread> TestRunnerInThreadPtr;
+typedef std::shared_ptr<DPL::Thread> ThreadPtr;
+
+DPL::Mutex mutex;
+std::list<TestContextFreePtr> frees;
+std::list<ICTestControllerPtr> ctrls;
+std::list<TestRunnerInThreadPtr> frees_threads;
+std::list<ThreadPtr> ctrls_threads;
+}
+
+class TestContextFree : public DPL::Event::ICDelegateSupport<TestContextFree>
+{
+  public:
+    TestContextFree(ICTestController* controller,
+                    int eventsCount) :
+        m_controller(controller),
+        m_eventsCount(eventsCount)
+    {}
+
+    void Wait()
+    {
+        LogDebug("Waiting for thread");
+        DPL::WaitForSingleHandle(m_waitable.GetHandle());
+    }
+
+    void OnNothing()
+    {
+        LogDebug("Got");
+        m_eventsCount--;
+        if (m_eventsCount > 0) {
+            LogDebug("posting next event");
+            GetIntAndStringEvent getIntAndStringEvent(
+                makeICDelegate(
+                    &TestContextFree::OnIntAndStringReceive));
+            LogDebug("posting next event ...");
+            m_controller->DPL::Event::ControllerEventHandler<
+                GetIntAndStringEvent>::PostEvent(
+                getIntAndStringEvent);
+            LogDebug("posting next event done");
+        } else {
+            LogDebug("test finished");
+            m_waitable.Signal();
+        }
+    }
+
+    void OnIntReceive(int)
+    {
+        LogDebug("Got");
+        m_eventsCount--;
+        if (m_eventsCount > 0) {
+            LogDebug("posting next event");
+            GetNothingEvent getNothingEvent(
+                makeICDelegate(
+                    &TestContextFree::OnNothing));
+            LogDebug("posting next event ...");
+            m_controller->DPL::Event::ControllerEventHandler<GetNothingEvent>::
+                PostEvent(
+                getNothingEvent);
+            LogDebug("posting next event done");
+        } else {
+            LogDebug("test finished");
+            m_waitable.Signal();
+        }
+    }
+
+    void OnIntAndStringReceive(int, std::string)
+    {
+        LogDebug("Got");
+        m_eventsCount--;
+        if (m_eventsCount > 0) {
+            LogDebug("posting next event");
+
+            GetIntEvent getIntEvent(
+                makeICDelegate(
+                    &TestContextFree::OnIntReceive));
+            LogDebug("posting next event ...");
+            m_controller->DPL::Event::ControllerEventHandler<GetIntEvent>::
+                PostEvent(
+                getIntEvent);
+            LogDebug("posting next event done");
+        } else {
+            LogDebug("test finished");
+            m_waitable.Signal();
+        }
+    }
+
+    void StartTestOnNothing()
+    {
+        GetNothingEvent getNothingEvent(
+            makeICDelegate(
+                &TestContextFree::OnNothing));
+        m_controller->DPL::Event::ControllerEventHandler<GetNothingEvent>::
+            PostEvent(
+            getNothingEvent);
+    }
+
+    void StartTestOnInt()
+    {
+        GetIntEvent getIntEvent(
+            makeICDelegate(
+                &TestContextFree::OnIntReceive));
+        m_controller->DPL::Event::ControllerEventHandler<GetIntEvent>::
+            PostEvent(
+            getIntEvent);
+    }
+
+    void StartTestOnIntAndString()
+    {
+        GetIntAndStringEvent getIntAndStringEvent(
+            makeICDelegate(
+                &TestContextFree::OnIntAndStringReceive));
+        m_controller->DPL::Event::ControllerEventHandler<GetIntAndStringEvent>
+            ::PostEvent(
+            getIntAndStringEvent);
+    }
+
+    bool CheckTest()
+    {
+        LogDebug("Checking test result");
+        return m_eventsCount == 0;
+    }
+
+  private:
+    ICTestController* m_controller;
+    int m_eventsCount;
+    DPL::WaitableEvent m_waitable;
+};
+
+class TestRunnerInThread : public DPL::Thread
+{
+  public:
+    TestRunnerInThread(int events, int tests) :
+        m_eventsCount(events),
+        m_tests(tests) {}
+
+    void WaitForInit()
+    {
+        LogDebug("Waiting for thread");
+        DPL::WaitForSingleHandle(m_init.GetHandle());
+    }
+
+  protected:
+    virtual int ThreadEntry()
+    {
+        LogDebug("Thread starts");
+        {
+            DPL::Mutex::ScopedLock lock(&mutex);
+            for (int i = 0; i < m_tests; ++i) {
+                if (i % TestsPerController == 0) {
+                    if (ctrls.size() % ControllersPerThread == 0) {
+                        ThreadPtr thread(new DPL::Thread());
+                        thread->Run();
+                        ctrls_threads.push_back(thread);
+                    }
+                    ICTestControllerPtr ptr(new ICTestController());
+                    ptr->Touch();
+                    ptr->SwitchToThread(ctrls_threads.back().get());
+                    ctrls.push_back(ptr);
+
+                    TestContextFreePtr t(new TestContextFree(ctrls.back().get(),
+                                                             m_eventsCount));
+                    t->StartTestOnNothing();
+                    LogDebug("");
+                    frees.push_back(t);
+                }
+            }
+        }
+        m_init.Signal();
+        LogDebug("Thread starts loop");
+        return DPL::Thread::ThreadEntry();
+    }
+
+  private:
+    DPL::WaitableEvent m_init;
+    int m_eventsCount;
+    int m_tests;
+};
+
+/*
+Name: ICDelegate_2
+Description: checks if delegetes are correctly called
+Expected: delegates should be called from right context
+*/
+RUNNER_TEST(ICDelegate_2)
+{
+    LogDebug("Creating test threads");
+    for (int i = 0; i < TestThreads; ++i) {
+        TestRunnerInThreadPtr ptr(
+            new TestRunnerInThread(NumberOfEvents, TestsPerThread));
+        frees_threads.push_back(ptr);
+        frees_threads.back()->Run();
+    }
+
+    FOREACH(it, frees_threads) {
+        (*it)->WaitForInit();
+    }
+    LogDebug("Creating test threads done");
+
+    FOREACH(it, frees) {
+        LogDebug("...");
+        (*it)->Wait();
+    }
+
+    FOREACH(it, frees) {
+        RUNNER_ASSERT((*it)->CheckTest());
+    }
+
+    frees.clear();
+
+    FOREACH(it, frees_threads) {
+        (*it)->Quit();
+    }
+
+    frees_threads.clear();
+
+    FOREACH(it, ctrls) {
+        (*it)->SwitchToThread(NULL);
+    }
+
+    FOREACH(it, ctrls_threads) {
+        (*it)->Quit();
+    }
+
+    ctrls.clear();
+    ctrls_threads.clear();
+}
+
+namespace ReuseCheck {
+const int ReuseCount = 5;
+typedef DPL::Event::ICDelegate<> GetNothingDlpType;
+DECLARE_GENERIC_EVENT_1(ReuseCountEvent, GetNothingDlpType)
+
+class ICReuseTestController :
+    public DPL::Event::Controller<DPL::TypeListDecl<ReuseCountEvent>::Type>
+{
+  public:
+    ICReuseTestController()
+    {
+        m_reuseCount = 0;
+    }
+
+  protected:
+    virtual void OnEventReceived(const ReuseCountEvent& event)
+    {
+        event.GetArg0() (); //calling intercontext delegate
+        if (++m_reuseCount < ReuseCount) {
+            LogInfo("[Send] Reuse: " << m_reuseCount);
+            DPL::Event::ControllerEventHandler<ReuseCountEvent>::PostEvent(
+                event);
+        }
+    }
+
+    int m_reuseCount;
+};
+
+class ReuseTestContextFreeClass :
+    protected DPL::Thread,
+    public DPL::Event::ICDelegateSupport<ReuseTestContextFreeClass>
+{
+  public:
+    ReuseTestContextFreeClass(ICReuseTestController* controller) :
+        Thread(),
+        m_controller(controller),
+        m_reuseCount(0)
+    { }
+
+    void Run()
+    {
+        Thread::Run();
+    }
+    void Quit()
+    {
+        Thread::Quit();
+    }
+    void Wait()
+    {
+        DPL::WaitForSingleHandle(m_waitable.GetHandle());
+    }
+
+  protected:
+    void OnReuseReceive()
+    {
+        LogDebug("[Received] : " << ++m_reuseCount);
+        if (m_reuseCount == ReuseCount) {
+            m_waitable.Signal();
+        }
+    }
+
+    virtual int ThreadEntry()
+    {
+        ReuseCountEvent reuseEvent(
+            makeICDelegate(
+                &ReuseTestContextFreeClass::OnReuseReceive,
+                DPL::Event::ICD::Reuse::Yes));
+        m_controller->DPL::Event::ControllerEventHandler<ReuseCountEvent>::
+            PostEvent(
+            reuseEvent);
+
+        return Thread::ThreadEntry();
+    }
+
+  private:
+    DPL::WaitableEvent m_waitable;
+    ICReuseTestController* m_controller;
+    int m_reuseCount;
+};
+
+/*
+Name: ICDelegate_3
+Description: checks if delegetes are correctly called
+Expected: delegates should be called from right context
+*/
+RUNNER_TEST(ICDelegate_3)
+{
+    DPL::Thread thread;
+    thread.Run();
+    LogDebug("Controller thread id = " << &thread);
+
+    ICReuseTestController testController;
+    testController.Touch();
+    testController.SwitchToThread(&thread);
+
+    ReuseTestContextFreeClass* contextFree =
+        new ReuseTestContextFreeClass(&testController);
+
+    thread.Run();
+    contextFree->Run();
+    contextFree->Wait();
+    contextFree->Quit();
+    thread.Quit();
+
+    delete contextFree;
+
+    RUNNER_ASSERT(true);
+}
+} //namespace ReuseCheck
diff --git a/tests/dpl/event/test_property.cpp b/tests/dpl/event/test_property.cpp
new file mode 100644 (file)
index 0000000..d72d02e
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_property.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test property
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/event/property.h>
+#include <dpl/event/model.h>
+#include <string>
+
+namespace {
+const int PROPERTY_VALUE_INT = 2;
+const std::string PROPERTY_VALUE_STRING = "aaa";
+}
+
+int ReadSomething2(DPL::Event::Model */*model*/);
+int ReadSomething2(DPL::Event::Model */*model*/)
+{
+    return PROPERTY_VALUE_INT;
+}
+
+std::string ReadSomething(DPL::Event::Model */*model*/);
+std::string ReadSomething(DPL::Event::Model */*model*/)
+{
+    return PROPERTY_VALUE_STRING;
+}
+
+void WriteSomething(const std::string & /*value*/, DPL::Event::Model */*model*/);
+void WriteSomething(const std::string & /*value*/, DPL::Event::Model */*model*/)
+{}
+
+class MyModel :
+    public DPL::Event::Model
+{
+  public:
+    ~MyModel() {}
+
+    DPL::Event::Property<std::string>
+    Caption;
+
+    DPL::Event::Property<std::string>
+    Testproperty0;
+
+    DPL::Event::Property<std::string, DPL::Event::PropertyReadOnly>
+    Testproperty1;
+
+    DPL::Event::Property<std::string, DPL::Event::PropertyReadWrite>
+    Testproperty2;
+
+    DPL::Event::Property<std::string, DPL::Event::PropertyReadWrite,
+                         DPL::Event::PropertyStorageCached> Testproperty3;
+
+    DPL::Event::Property<std::string, DPL::Event::PropertyReadWrite,
+                         DPL::Event::PropertyStorageDynamic> Testproperty4;
+
+    DPL::Event::Property<int, DPL::Event::PropertyReadOnly,
+                         DPL::Event::PropertyStorageDynamicCached>
+    Testproperty5;
+
+    MyModel() :
+        Caption(this, "Foo caption"),
+        Testproperty0(this, "", &ReadSomething),
+        Testproperty1(this),
+        Testproperty2(this),
+        Testproperty3(this),
+        Testproperty4(this, "test", &ReadSomething, &WriteSomething),
+        Testproperty5(this, &ReadSomething2)
+    {}
+};
+
+std::string g_caption;
+
+void OnNameChanged(const DPL::Event::PropertyEvent<std::string> &event);
+void OnNameChanged(const DPL::Event::PropertyEvent<std::string> &event)
+{
+    g_caption = event.value;
+}
+
+/*
+Name: Model_Test
+Description: tests accessing and changing models properties
+Expected: listener should get changed value
+*/
+RUNNER_TEST(Model_Test)
+{
+    MyModel model;
+
+    g_caption = "It is a bad caption";
+
+    model.Caption.AddListener(&OnNameChanged);
+    model.Caption.Set("Test name");
+
+    RUNNER_ASSERT(model.Testproperty4.Get() == PROPERTY_VALUE_STRING);
+    RUNNER_ASSERT(PROPERTY_VALUE_INT == model.Testproperty5.Get());
+    RUNNER_ASSERT(g_caption == "Test name");
+    RUNNER_ASSERT(model.Caption.Get() == "Test name");
+
+    model.Caption.RemoveListener(&OnNameChanged);
+}
diff --git a/tests/dpl/localization/CMakeLists.txt b/tests/dpl/localization/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a50727a
--- /dev/null
@@ -0,0 +1,51 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Test files
+#
+# Define all DPL tests sources.
+# Runner is responsible for runnint it all and
+# generating proper output files
+#
+
+SET(TARGET_LOC "dpl-tests-loc")
+
+SET(LOC_TESTS_SOURCES
+    ${DPL_TESTS_DIR}/localization/test_localization.cpp
+    ${DPL_TESTS_DIR}/localization/test_suite01.cpp
+    #${DPL_TESTS_DIR}/localization/mockup_src/widget_dao.cpp
+    #${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp
+    #${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp
+)
+
+#WRT_INCLUDE_DIRECTORIES(
+    #${SYS_EFL_INCLUDE_DIRS}
+    #${DPL_TEST_INCLUDE_DIR}
+    #${DPL_TESTS_DIR}/localization/mockup_include
+    #${PROJECT_SOURCE_DIR}/modules/localization/include
+#)
+
+#LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
+
+WRT_TEST_BUILD(${TARGET_LOC} ${LOC_TESTS_SOURCES})
+WRT_TEST_INSTALL(${TARGET_LOC})
+
+ADD_SUBDIRECTORY(files)
diff --git a/tests/dpl/localization/files/CMakeLists.txt b/tests/dpl/localization/files/CMakeLists.txt
new file mode 100644 (file)
index 0000000..17c7fda
--- /dev/null
@@ -0,0 +1,19 @@
+INSTALL(FILES
+    ${DPL_TESTS_DIR}/localization/files/one
+    DESTINATION
+    /opt/share/widget/tests/localization/widget1/locales/pl-en
+  )
+
+INSTALL(FILES
+    ${DPL_TESTS_DIR}/localization/files/one
+    ${DPL_TESTS_DIR}/localization/files/two
+    DESTINATION
+    /opt/share/widget/tests/localization/widget2/locales/pl-en
+  )
+
+INSTALL(FILES
+    ${DPL_TESTS_DIR}/localization/files/two
+    DESTINATION
+    /opt/share/widget/tests/localization/widget2/locales/en-en
+  )
+
diff --git a/tests/dpl/localization/files/one b/tests/dpl/localization/files/one
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/dpl/localization/files/two b/tests/dpl/localization/files/two
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/dpl/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h b/tests/dpl/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h
new file mode 100644 (file)
index 0000000..06b7294
--- /dev/null
@@ -0,0 +1,481 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    common_dao_types.h
+ * @author  Michal Ciepielski (m.ciepielski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of common data types for wrtdb
+ */
+
+#ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_
+#define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_
+
+#include <set>
+#include <string>
+#include <map>
+#include <vector>
+#include <list>
+#include <dpl/optional_typedefs.h>
+#include <memory>
+
+namespace WrtDB {
+namespace Powder {
+typedef std::set<DPL::String> StringSet;
+//! Widget description
+struct Description
+{
+    //!Content level
+    typedef enum
+    {
+        Level0 = 0,
+        Level1,
+        Level2,
+        Level3,
+        Level4,
+        Level5,
+        LevelUnknown
+    } LevelEnum;
+    struct LevelEntry
+    {
+        LevelEnum level; //!< content level
+
+        typedef StringSet Context;
+
+        //! POWDER context
+        //! xa    This material appears in an artistic context
+        //! xb    This material appears in an educational context
+        //! xc    This material appears in a medical context
+        //! xd    This material appears in a sports context
+        //! xe    This material appears in a violent context
+        Context context;
+        explicit LevelEntry(LevelEnum level = LevelUnknown);
+        //! Function checks if context is valid
+        //! \param[in] level POWDER content level
+        //! \param[in] context POWDER context
+        bool isContextValid(LevelEnum level,
+                            const DPL::OptionalString& context) const;
+    };
+
+    struct CategoryEntry
+    {
+        //! Levels entries for POWDER description
+        typedef std::vector <LevelEntry> LevelsContainer;
+        LevelsContainer levels;
+        //! Function checks if context is valid
+        //! \param[out] reason set if context invalid
+        //! \param[in] level POWDER content level
+        //! \param[in] context POWDER context
+        bool isCategoryValid(LevelEntry& reason,
+                             LevelEnum level,
+                             const DPL::OptionalString& context) const;
+    };
+
+    //! POWDER Category -> Category entry map for Widget
+    //!
+    //! nu    Nudity
+    //! se    Sex
+    //! vi    Violence
+    //! la    Potentially offensive language
+    //! dr    Drug use
+    //! ga    Gambling
+    //! ha    Hate or harmful activities
+    //! ug    Use of user-generated content
+    typedef std::map<DPL::String, CategoryEntry> CategoryEntries;
+
+    CategoryEntries categories;
+
+    //! Age rating for widget
+    //! If Null not set
+    DPL::OptionalInt ageRating;
+};
+} // namespace Powder
+
+namespace ChildProtection {
+//! Blacklist with forbidden URLs
+//! It should be stored in WidgetDAO
+typedef std::vector<DPL::String> BlackList;
+
+//! Widget Child protection record
+//! Record should be stored in WingetDAO
+struct Record
+{
+    //! Child protection enabled
+    bool enabled;
+    explicit Record(bool enabled) :
+        enabled(enabled)
+    {}
+};
+
+//! Powder processing
+struct PowderRules
+{
+    //! Rule set by parent about forbidden category
+    //! Powder category
+    //! nu    Nudity
+    //! se    Sex
+    //! vi    Violence
+    //! la    Potentially offensive language
+    //! dr    Drug use
+    //! ga    Gambling
+    //! ha    Hate or harmful activities
+    //! ug    Use of user-generated content
+    //! Powder context
+    //! xa    This material appears in an artistic conteaxt
+    //! xb    This material appears in an educational context
+    //! xc    This material appears in a medical context
+    //! xd    This material appears in a sports context
+    //! xe    This material appears in a violent context
+    struct CategoryRule
+    {
+        DPL::String category;
+        Powder::Description::LevelEnum level;
+        DPL::OptionalString context;
+        explicit CategoryRule(
+            const DPL::String& category = DPL::String(),
+            Powder::Description::LevelEnum level =
+                Powder::Description::LevelUnknown,
+            const DPL::OptionalString& context =
+                DPL::OptionalString());
+    };
+
+    struct PowderResult
+    {
+        //! Reasoning outcome: part of POWDER description used to invalidate
+        Powder::Description::LevelEntry invalidDescription;
+        //! Reasoning outcome: rule set by parent not full filed by description
+        CategoryRule invalidRule;
+
+        //! Reasoning outcome: type of invalidity
+        enum InvalidReason
+        {
+            InvalidRule, //!< One of rules was not fulfilled
+            InvalidAge, //!< Age is invalid
+            AgeRatingNotSet, //!< Age rating for widget is not set
+            Valid //!< Description valid
+        };
+        InvalidReason reason;
+        explicit PowderResult(
+            InvalidReason reason = Valid,
+            const Powder::Description::LevelEntry&
+            invalidDescription =
+                Powder::Description::LevelEntry(),
+            const CategoryRule& invalidRule = CategoryRule());
+    };
+
+    typedef std::pair<bool, PowderResult> ResultPair;
+
+    //! Function checks if rule is fulfilled by description
+    //! \param[in] rule checked rule
+    //! \param[in] description
+    //! \retval true rule is valid
+    //! \retval false rule is invalid
+    ResultPair isRuleValidForDescription(const CategoryRule& rule,
+                                         const Powder::Description& description)
+    const;
+    //! Function checks if age limit is fulfilled by description
+    //! \param[in] description
+    //! \retval true age is valid
+    //! \retval false age is invalid
+    ResultPair isAgeValidForDescription(
+        const Powder::Description& description) const;
+
+    //! It is the maximum age rating valid for child
+    //! Uniform age is stored in WidgetDAO
+    DPL::OptionalInt ageLimit;
+
+    //! Set to true if age rating is required
+    //! If ageLimit is not set value is ignored
+    bool isAgeRatingRequired;
+
+    //! Set of rules configured by parent
+    //! Rules are stored in WidgetDAO and are uniform for all widgets
+    typedef std::vector<CategoryRule> RulesContainer;
+    RulesContainer rules;
+
+    //! Function check if Widget description is valid for ChildProtection
+    //! configuration
+    //! \param description widget description
+    //! \retval true widget is valid
+    //! \retval false widget is invalid
+    ResultPair isDescriptionValid(const Powder::Description& description)
+    const;
+
+    PowderRules() :
+        isAgeRatingRequired(false)
+    {}
+};
+} // namespace ChildProtection
+
+class PluginMetafileData
+{
+  public:
+    struct Feature
+    {
+        std::string m_name;
+        std::set<std::string> m_deviceCapabilities;
+
+        bool operator< (const Feature& obj) const
+        {
+            return m_name < obj.m_name;
+        }
+    };
+    typedef std::set<Feature> FeatureContainer;
+
+  public:
+
+    PluginMetafileData()
+    {}
+
+    std::string m_libraryName;
+    std::string m_featuresInstallURI;
+    std::string m_featuresKeyCN;
+    std::string m_featuresRootCN;
+    std::string m_featuresRootFingerprint;
+
+    FeatureContainer m_featureContainer;
+};
+
+class PluginObjectsDAO
+{
+  public:
+    typedef std::set<std::string> Objects;
+    typedef std::shared_ptr<Objects> ObjectsPtr;
+
+  public:
+    explicit PluginObjectsDAO() {}
+
+  protected:
+    ObjectsPtr m_implemented;
+    ObjectsPtr m_dependent;
+};
+
+/**
+ * @brief Widget id describes web-runtime global widget identifier.
+ *
+ * Notice that only up to one widget can exist at the same time.
+ * DbWidgetHandle can be translated into corresponding WidgetModel by invoking
+ * FindWidgetModel routine.
+ */
+typedef int DbWidgetHandle;
+
+/**
+ * @brief Structure to hold the information of widget's size
+ */
+struct DbWidgetSize
+{
+    DPL::OptionalInt width;
+    DPL::OptionalInt height;
+
+    DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null,
+                 DPL::OptionalInt h = DPL::OptionalInt::Null) :
+        width(w),
+        height(h)
+    {}
+};
+
+inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB)
+{
+    if (!objA.height || !objA.width || !objB.width || !objB.height) {
+        return false;
+    } else {
+        return *objA.height == *objB.height && *objA.width == *objB.width;
+    }
+}
+
+/**
+ * Widget [G]lobal [U]nique [ID]entifier
+ * Orginated from appstore ID
+ */
+typedef DPL::OptionalString WidgetGUID;
+
+struct WidgetAccessInfo
+{
+    DPL::String strIRI;                /* origin iri */
+    bool bSubDomains;                  /* do we want access to subdomains ? */
+
+    bool operator ==(const WidgetAccessInfo& info) const
+    {
+        return info.strIRI == strIRI &&
+               info.bSubDomains == bSubDomains;
+    }
+};
+
+typedef std::list<WidgetAccessInfo> WidgetAccessInfoList;
+
+typedef std::list<DPL::String> WindowModeList;
+
+/**
+ * @brief Widget configuration parameter key
+ */
+typedef DPL::String WidgetParamKey;
+
+/**
+ * @brief Widget configuration parameter value
+ */
+typedef DPL::String WidgetParamValue;
+
+/**
+ * @brief A map of widget configuration parameters.
+ *
+ * Widget configuration parameters are read from database and are stored
+ * along with feature that they describe.
+ */
+typedef std::multimap<WidgetParamKey, WidgetParamValue> WidgetParamMap;
+
+/**
+ * @brief Widget feature host information about possible javascript extensions
+ *        that widget may use
+ *
+ * Widget features are declared in configuration file in widget installation
+ * package. Each declared special feature is contained in some wrt-plugin that
+ * declares to implement it. After widget launch wrt searches for proper plugin
+ * libraries and load needed features.
+ *
+ * Widget features can be required or optional. It is possible to start widget
+ * without missing feature. When required feature cannot be loaded widget will
+ * not start.
+ */
+
+enum {
+    INVALID_PLUGIN_HANDLE = -1
+};
+typedef int DbPluginHandle;
+
+struct DbWidgetFeature
+{
+    DPL::String name;        /// Feature name
+    bool required;           /// Whether feature is required
+    DbPluginHandle pluginId;            /// Plugin id that implement this
+                                        // feature
+    WidgetParamMap params;   /// Widget's params
+
+    DbWidgetFeature() :
+        required(false),
+        pluginId(INVALID_PLUGIN_HANDLE)
+    {}
+};
+
+inline bool operator < (const DbWidgetFeature &objA,
+                        const DbWidgetFeature &objB)
+{
+    return objA.name.compare(objB.name) < 0;
+}
+
+inline bool operator==(const DbWidgetFeature &featureA,
+                       const DbWidgetFeature &featureB)
+{
+    return featureA.name == featureB.name &&
+           featureA.required == featureB.required &&
+           featureA.pluginId == featureB.pluginId;
+}
+
+/**
+ * @brief Default container for features list
+ */
+typedef std::multiset<DbWidgetFeature> DbWidgetFeatureSet;
+
+/**
+ * @brief Default container with DbWidgetHandle's
+ */
+typedef std::list<DbWidgetHandle> DbWidgetHandleList;
+
+/**
+ * @brief Widget specific type
+ *
+ * Widget type describes belowed in WAC, TIZEN WebApp
+ */
+enum AppType
+{
+    APP_TYPE_UNKNOWN = 0, // unknown
+    APP_TYPE_WAC20, // WAC 2.0
+    APP_TYPE_TIZENWEBAPP, // slp webapp
+};
+
+class WidgetType
+{
+  public:
+    WidgetType() :
+        appType(APP_TYPE_UNKNOWN)
+    {}
+    WidgetType(const AppType type) :
+        appType(type)
+    {}
+    bool operator== (const AppType& other) const
+    {
+        return appType == other;
+    }
+    std::string getApptypeToString()
+    {
+        switch (appType) {
+#define X(x) case x: return #x;
+            X(APP_TYPE_UNKNOWN)
+            X(APP_TYPE_WAC20)
+            X(APP_TYPE_TIZENWEBAPP)
+#undef X
+        default:
+            return "UNKNOWN";
+        }
+    }
+
+    AppType appType;
+};
+} // namespace WrtDB
+
+struct WidgetSetting
+{
+    DPL::String settingName;
+    DPL::String settingValue;
+
+    bool operator ==(const WidgetSetting& info) const
+    {
+        return (info.settingName == settingName &&
+                info.settingValue == settingValue);
+    }
+    bool operator !=(const WidgetSetting& info) const
+    {
+        return (info.settingName != settingName ||
+                info.settingValue != settingValue);
+    }
+};
+
+typedef std::list<WidgetSetting> WidgetSettings;
+
+/**
+ * @brief Widget Application Service
+ *
+ * Application sercvice describes details of behaviour
+ * when widget receives aul bundle data.
+ */
+struct WidgetApplicationService
+{
+  public:
+    DPL::String src;       /* start uri */
+    DPL::String operation; /* service name */
+    DPL::String scheme;    /* scheme type*/
+    DPL::String mime;      /* mime type */
+
+    bool operator== (const WidgetApplicationService& other) const
+    {
+        return src == other.src &&
+               operation == other.operation &&
+               scheme == other.scheme &&
+               mime == other.mime;
+    }
+};
+
+typedef std::list<WidgetApplicationService> WidgetApplicationServiceList;
+#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */
diff --git a/tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h b/tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h
new file mode 100644 (file)
index 0000000..264c6e4
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of widget dao class.
+ *
+ * @file    widget_dao_read_only.h
+ * @author  Yang Jie (jie2.yang@samsung.com)
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of widget dao
+ */
+
+#ifndef _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
+#define _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
+
+#include <time.h>
+
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+
+#include <dpl/string.h>
+#include <dpl/exception.h>
+#include <dpl/optional_typedefs.h>
+
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+//#include "../wrt-dao-ro/common_dao_types.h"
+
+typedef DPL::OptionalString WidgetGUID;
+
+namespace ConfigParserData {
+struct Icon
+{
+    Icon(const DPL::String& src) : src(src)
+    {}
+    DPL::String src;
+    DPL::OptionalInt width;
+    DPL::OptionalInt height;
+    bool operator==(const Icon&) const;
+    bool operator!=(const Icon&) const;
+    bool operator >(const Icon&) const;
+    bool operator>=(const Icon&) const;
+    bool operator <(const Icon&) const;
+    bool operator<=(const Icon&) const;
+};
+} // namespace ConfigParserData
+namespace WrtDB {
+typedef std::list<DPL::String> StringList;
+
+struct WidgetLocalizedInfo
+{
+    DPL::OptionalString name;
+    DPL::OptionalString shortName;
+    DPL::OptionalString description;
+    DPL::OptionalString license;
+    DPL::OptionalString licenseHref;
+};
+
+typedef std::list<DPL::String> LanguageTagList;
+
+class WidgetDAO
+{
+  public:
+    /**
+     * WidgetDAO Exception classes
+     */
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
+        DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty)
+        DECLARE_EXCEPTION_TYPE(Base, GUIDisNull)
+        DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult)
+        DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist)
+        DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered)
+    };
+
+  protected:
+    DbWidgetHandle m_widgetHandle;
+
+  public:
+    struct WidgetLocalizedIconRow
+    {
+        int appId;
+        int iconId;
+        DPL::String widgetLocale;
+    };
+    typedef std::list<WidgetLocalizedIconRow> WidgetLocalizedIconList;
+
+    struct WidgetIconRow
+    {
+        int iconId;
+        int appId;
+        DPL::String iconSrc;
+        DPL::OptionalInt iconWidth;
+        DPL::OptionalInt iconHeight;
+    };
+    typedef std::list<WidgetIconRow> WidgetIconList;
+
+    struct WidgetStartFileRow
+    {
+        int startFileId;
+        int appId;
+        DPL::String src;
+    };
+    typedef std::list<WidgetStartFileRow> WidgetStartFileList;
+
+    struct WidgetLocalizedStartFileRow
+    {
+        int startFileId;
+        int appId;
+        DPL::String widgetLocale;
+        DPL::String type;
+        DPL::String encoding;
+    };
+    typedef std::list<WidgetLocalizedStartFileRow> LocalizedStartFileList;
+
+    /**
+     * This is a constructor.
+     *
+     * @param[in] widgetHandle application id of widget.
+     */
+    WidgetDAO(DbWidgetHandle widgetHandle) :
+        m_widgetHandle(widgetHandle)
+    {}
+
+    /**
+     * Destructor
+     */
+    virtual ~WidgetDAO(){}
+
+    /**
+     * This method returns widget handle(m_widgetHandle).
+     *
+     * @return widget handle(m_widgetHandle).
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     * DB table.
+     */
+    DbWidgetHandle getHandle() const
+    {
+        return m_widgetHandle;
+    }
+    DbWidgetHandle getHandle(const WidgetGUID GUID) const;
+    static DbWidgetHandle getHandle(const DPL::String tizenAppId);
+
+    /**
+     * This method returns the root directory of widget resource.
+     *
+     * @return path name of root directory.
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     * DB table.
+     */
+    DPL::String getPath() const;
+    void setPath(const DPL::String &path) const;
+
+    /**
+     * This method returns the defaultlocale for the widget.
+     *
+     * @return defaultlocale
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     *  DB table.
+     */
+    DPL::OptionalString getDefaultlocale() const;
+
+    /**
+     * This method returns list of localized icons files;
+     *
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     *  DB table.
+     */
+    WidgetLocalizedIconList getLocalizedIconList() const;
+
+    /**
+     * This method returns list of icons files;
+     *
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     *  DB table.
+     */
+    WidgetIconList getIconList() const;
+
+    /**
+     * This method returns list of localized start files;
+     *
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     *  DB table.
+     */
+    LocalizedStartFileList getLocalizedStartFileList() const;
+    void setLocalizedStartFileList(const LocalizedStartFileList &list) const;
+    /**
+     * This method returns list of start files;
+     *
+     * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table.
+     * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in
+     *  DB table.
+     */
+    WidgetStartFileList getStartFileList() const;
+    void setStartFileList(const WidgetStartFileList &list) const;
+
+    WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const;
+
+  protected:
+    static std::map<DbWidgetHandle, WidgetStartFileList> s_startFileMap;
+    static std::map<DbWidgetHandle,
+                    LocalizedStartFileList> s_localizedStartFileMap;
+    static std::map<DbWidgetHandle, DPL::String> s_pathMap;
+};
+} // namespace WrtDB
+
+#endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
+
diff --git a/tests/dpl/localization/mockup_src/widget_dao.cpp b/tests/dpl/localization/mockup_src/widget_dao.cpp
new file mode 100644 (file)
index 0000000..170aad7
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of widget dao class.
+ *
+ * @file    widget_dao_read_only.cpp
+ * @author  Yang Jie (jie2.yang@samsung.com)
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @author  Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief   This file contains the declaration of widget dao
+ */
+
+//#include "../mockup_include/dpl/wrt-dao-rw/widget_dao.h"
+#include <dpl/wrt-dao-rw/widget_dao.h>
+
+#include <sstream>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/sstream.h>
+
+namespace WrtDB {
+std::map<DbWidgetHandle,
+         WidgetDAO::WidgetStartFileList> WidgetDAO::s_startFileMap;
+std::map<DbWidgetHandle,
+         WidgetDAO::LocalizedStartFileList> WidgetDAO::s_localizedStartFileMap;
+std::map<DbWidgetHandle, DPL::String> WidgetDAO::s_pathMap;
+
+DbWidgetHandle WidgetDAO::getHandle(const WidgetGUID /* GUID */) const
+{
+    LogError("Not impleneted!");
+    return 0;
+}
+
+DbWidgetHandle WidgetDAO::getHandle(const DPL::String /* tizenAppId */)
+{
+    LogError("Not implemented!");
+    return 0;
+}
+
+DPL::String WidgetDAO::getPath() const
+{
+    return s_pathMap[m_widgetHandle];
+}
+
+void WidgetDAO::setPath(const DPL::String &path) const
+{
+    s_pathMap[m_widgetHandle] = path;
+}
+
+WidgetLocalizedInfo
+WidgetDAO::getLocalizedInfo(const DPL::String& /* languageTag */)
+const
+{
+    LogError("Not implemented!");
+    return WidgetLocalizedInfo();
+}
+
+DPL::OptionalString WidgetDAO::getDefaultlocale() const
+{
+    LogError("Not implemented!");
+    return DPL::OptionalString();
+}
+
+WidgetDAO::WidgetLocalizedIconList WidgetDAO::getLocalizedIconList() const
+{
+    LogError("Not implemented!");
+    return WidgetLocalizedIconList();
+}
+
+WidgetDAO::WidgetIconList WidgetDAO::getIconList() const
+{
+    LogError("Not implemented!");
+    return WidgetIconList();
+}
+
+WidgetDAO::LocalizedStartFileList WidgetDAO::getLocalizedStartFileList() const
+{
+    return s_localizedStartFileMap[m_widgetHandle];
+}
+
+void WidgetDAO::setLocalizedStartFileList(const LocalizedStartFileList &list)
+const
+{
+    s_localizedStartFileMap[m_widgetHandle] = list;
+}
+
+WidgetDAO::WidgetStartFileList WidgetDAO::getStartFileList() const
+{
+    return s_startFileMap[m_widgetHandle];
+}
+
+void WidgetDAO::setStartFileList(const WidgetStartFileList &list) const
+{
+    s_startFileMap[m_widgetHandle] = list;
+}
+} // namespace WrtDB
diff --git a/tests/dpl/localization/test_localization.cpp b/tests/dpl/localization/test_localization.cpp
new file mode 100644 (file)
index 0000000..42ffe3a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main
+ */
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+    return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}
+
diff --git a/tests/dpl/localization/test_suite01.cpp b/tests/dpl/localization/test_suite01.cpp
new file mode 100644 (file)
index 0000000..d3cb174
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * This file contains the declaration of widget dao class.
+ *
+ * @file    test_suite01.cpp
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <dpl/log/log.h>
+#include <dpl/test/test_runner.h>
+
+//#include "mockup_include/dpl/wrt-dao-rw/widget_dao.h"
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/localization/w3c_file_localization.h>
+
+namespace {
+WrtDB::LanguageTagList generateLanguageTags()
+{
+    WrtDB::LanguageTagList tags;
+    tags.push_back(L"pl-pl");
+    tags.push_back(L"en-en");
+    tags.push_back(L"pl-en");
+    return tags;
+}
+
+static const WrtDB::LanguageTagList languageTags = generateLanguageTags();
+static const DPL::String widget1Path =
+    L"/opt/share/widget/tests/localization/widget1/";
+static const DPL::String widget2Path =
+    L"/opt/share/widget/tests/localization/widget2/";
+} // anonymous namespace
+
+RUNNER_TEST(test01_getFilePathInWidgetPackageFromUrl){
+    const int widgetHandle = 1;
+    WrtDB::WidgetDAO dao(widgetHandle);
+    //dao.setPath(widget1Path);
+
+    auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
+            widgetHandle,
+            languageTags,
+            L"widget://one");
+
+    RUNNER_ASSERT(
+        *result ==
+        L"/opt/share/widget/tests/localization/widget1/locales/pl-en/one");
+}
+
+RUNNER_TEST(test02_getFilePathInWidgetPackageFromUrl){
+    const int widgetHandle = 2;
+    WrtDB::WidgetDAO dao(widgetHandle);
+    //dao.setPath(widget2Path);
+
+    auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
+            widgetHandle,
+            languageTags,
+            L"widget://one");
+
+    RUNNER_ASSERT(
+        *result ==
+        L"/opt/share/widget/tests/localization/widget2/locales/pl-en/one");
+}
+
+RUNNER_TEST(test03_getFilePathInWidgetPackageFromUrl){
+    const int widgetHandle = 2;
+    WrtDB::WidgetDAO dao(widgetHandle);
+    //dao.setPath(widget2Path);
+
+    auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
+            widgetHandle,
+            languageTags,
+            L"widget://two");
+
+    RUNNER_ASSERT(
+        *result ==
+        L"/opt/share/widget/tests/localization/widget2/locales/en-en/two");
+}
+
+RUNNER_TEST(test04_getFilePathInWidgetPackage){
+    const int widgetHandle = 1;
+    WrtDB::WidgetDAO dao(widgetHandle);
+    //dao.setPath(widget1Path);
+
+    auto result = W3CFileLocalization::getFilePathInWidgetPackage(
+            widgetHandle,
+            languageTags,
+            L"one");
+
+    RUNNER_ASSERT(*result == L"locales/pl-en/one");
+}
+
+RUNNER_TEST(test05_getFilePathInWidgetPackage){
+    const int widgetHandle = 2;
+    WrtDB::WidgetDAO dao(widgetHandle);
+    //dao.setPath(widget2Path);
+
+    auto result = W3CFileLocalization::getFilePathInWidgetPackage(
+            widgetHandle,
+            languageTags,
+            L"two");
+
+    RUNNER_ASSERT(*result == L"locales/en-en/two");
+}
+
diff --git a/tests/dpl/test/CMakeLists.txt b/tests/dpl/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6e34912
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+# @version     1.0
+# @brief
+#
+
+SET(TARGET_NAME "dpl-tests-test")
+
+# Set DPL tests sources
+SET(DPL_TESTS_UTIL_SOURCES
+    ${TESTS_DPL_DIR}/test/main.cpp
+    ${TESTS_DPL_DIR}/test/runner_child.cpp
+)
+
+#WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_UTILS_EFL})
+WRT_TEST_BUILD(${TARGET_NAME} ${DPL_TESTS_UTIL_SOURCES})
+WRT_TEST_INSTALL(${TARGET_NAME})
diff --git a/tests/dpl/test/main.cpp b/tests/dpl/test/main.cpp
new file mode 100644 (file)
index 0000000..42ffe3a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main
+ */
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+    return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}
+
diff --git a/tests/dpl/test/runner_child.cpp b/tests/dpl/test/runner_child.cpp
new file mode 100644 (file)
index 0000000..d911270
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    widget_version.cpp
+ * @author  Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for test cases for engine internal tests
+ */
+#include <dpl/test/test_runner_child.h>
+#include <unistd.h>
+#include <vector>
+#include <sys/types.h>
+#include <signal.h>
+
+RUNNER_TEST_GROUP_INIT(DPL_TESTS_TEST_CHILD)
+
+RUNNER_TEST(t00_pass)
+{
+    RUNNER_ASSERT_MSG(1, "This test should pass");
+}
+
+RUNNER_CHILD_TEST(t01_pass)
+{
+    RUNNER_ASSERT_MSG(1, "This test should pass");
+}
+
+RUNNER_CHILD_TEST(t02_fail)
+{
+    RUNNER_ASSERT_MSG(0, "This test should fail");
+}
+
+RUNNER_CHILD_TEST(t03_fail_timeout)
+{
+    sleep(20);
+    RUNNER_ASSERT_MSG(1, "This test should fail");
+}
+
+RUNNER_CHILD_TEST(t04_fail)
+{
+    RUNNER_ASSERT_MSG(1, "This test should fail");
+    RUNNER_ASSERT_MSG(1, "This test should fail");
+    RUNNER_ASSERT_MSG(1, "This test should fail");
+    RUNNER_ASSERT_MSG(1, "This test should fail");
+    RUNNER_ASSERT_MSG(0, "This test should fail");
+}
+
+RUNNER_CHILD_TEST(t05_fail_child_died)
+{
+    kill(getpid(), SIGKILL);
+    RUNNER_ASSERT_MSG(1, "This test should fail");
+}
+
+RUNNER_CHILD_TEST(t06_pass_8_second_test)
+{
+    sleep(8);
+    RUNNER_ASSERT_MSG(1, "This test should pass");
+}
+
+RUNNER_CHILD_TEST(t07_fail_unknown_exception)
+{
+    throw("hello");
+}
+
+RUNNER_CHILD_TEST(t08_fail_unknown_exception)
+{
+    throw(1);
+}
+
+RUNNER_CHILD_TEST(t09_fail_you_should_see_text_normal_assert)
+{
+    RUNNER_ASSERT_MSG(0, "Normal assert");
+}
+
+RUNNER_CHILD_TEST(t10_pass)
+{
+    RUNNER_ASSERT_MSG(1, "Normal assert");
+}
+
diff --git a/tests/dpl/unused/test_caller.cpp b/tests/dpl/unused/test_caller.cpp
new file mode 100644 (file)
index 0000000..6f1a1ff
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_address.cpp
+ * @author      Tomasz Swierczek (t.swierczek@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of caller tests
+ */
+
+#include <dpl/test_runner.h>
+#include <dpl/serialization.h>
+#include <dpl/caller.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+// test stream class
+class BinaryStream : public DPL::IStream
+{
+  public:
+    virtual void Read(size_t num, void * bytes)
+    {
+        for (unsigned i = 0; i < num; ++i) {
+            ((unsigned char*)bytes)[i] = data[i + readPosition];
+        }
+        readPosition += num;
+    }
+    virtual void Write(size_t num, const void * bytes)
+    {
+        for (unsigned i = 0; i < num; ++i) {
+            data.push_back(((unsigned char*)bytes)[i]);
+        }
+    }
+    BinaryStream()
+    {
+        readPosition = 0;
+    }
+    virtual ~BinaryStream(){}
+
+  private:
+    std::vector<unsigned char> data;
+    unsigned readPosition;
+};
+
+static int return_func(int a, bool b)
+{
+    if (b) {
+        return a;
+    } else {
+        return 0;
+    }
+}
+
+static int called = 0;
+
+static void void_func(int a)
+{
+    called = a;
+}
+
+static struct VoidDelegate
+{
+    void operator()(int a)
+    {
+        called = a;
+    }
+} voidDelegate;
+
+static struct ReturnDelegate
+{
+    int operator()(int a)
+    {
+        return a;
+    }
+} returnDelegate;
+
+RUNNER_TEST(Caller_function_void)
+{
+    int a = 23;
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, a);
+    called = 0;
+    DPL::Caller::Call(stream, void_func);
+    RUNNER_ASSERT(called == a);
+}
+
+RUNNER_TEST(Caller_function_return)
+{
+    int a = 23;
+    bool b = true;
+    BinaryStream stream;
+    DPL::Serialization::Serialize(stream, a);
+    DPL::Serialization::Serialize(stream, b);
+    int result = DPL::Caller::Call(stream, return_func);
+    RUNNER_ASSERT(result == a);
+}
+
+RUNNER_TEST(Caller_delegate_void)
+{
+    int a = 23;
+    BinaryStream stream;
+    called = 0;
+    DPL::Serialization::Serialize(stream, a);
+    DPL::Caller::CallDelegate(stream, voidDelegate);
+    RUNNER_ASSERT(called == a);
+}
+
+RUNNER_TEST(Caller_delegate_return)
+{
+    int a = 23;
+    BinaryStream stream;
+    called = 0;
+    DPL::Serialization::Serialize(stream, a);
+    int result = 0;
+    DPL::Caller::CallDelegate(stream, returnDelegate, result);
+    RUNNER_ASSERT(result == a);
+}
diff --git a/tests/dpl/unused/test_crypto_hash.cpp b/tests/dpl/unused/test_crypto_hash.cpp
new file mode 100644 (file)
index 0000000..dd208b6
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_crypto_hash.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of test crypto hash
+ */
+#include <dpl/test_runner.h>
+#include <dpl/crypto_hash.h>
+RUNNER_TEST_GROUP_INIT(DPL)
+
+#define TEST_CRYPTO_HASH(Class, Input, Output)   \
+    Class crypto;                                \
+    crypto.Append(Input);                        \
+    crypto.Finish();                             \
+    RUNNER_ASSERT(crypto.ToString() == Output);
+
+RUNNER_TEST(CryptoHash_MD2)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD2,
+                     "sample_input_string",
+                     "c9f26439c9882cccc98467dbdf07b1fc");
+}
+
+RUNNER_TEST(CryptoHash_MD4)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD4,
+                     "sample_input_string",
+                     "8cd0720f7ec98c8e5f008afb54054677");
+}
+
+RUNNER_TEST(CryptoHash_MD5)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::MD5,
+                     "sample_input_string",
+                     "eb7ae4f28fecbd1fd777d9b7495fc8ec");
+}
+
+RUNNER_TEST(CryptoHash_SHA)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA,
+                     "sample_input_string",
+                     "0a5725f3586616a4049730f3ba14c8aeda79ab21");
+}
+
+RUNNER_TEST(CryptoHash_SHA1)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA1,
+                     "sample_input_string",
+                     "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
+}
+
+RUNNER_TEST(CryptoHash_DSS)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS,
+                     "sample_input_string",
+                     "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
+}
+
+RUNNER_TEST(CryptoHash_DSS1)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::DSS1,
+                     "sample_input_string",
+                     "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
+}
+
+RUNNER_TEST(CryptoHash_ECDSA)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::ECDSA,
+                     "sample_input_string",
+                     "be0ed9040af0c2b772b2dd0776f6966b5f4d1206");
+}
+
+RUNNER_TEST(CryptoHash_SHA224)
+{
+    TEST_CRYPTO_HASH(DPL::Crypto::Hash::SHA224,
+                     "sample_input_string",
+                     "d4dde2370eb869f6e790133b94d58e45417392b9d899af883a274011");
+}
+
+RUNNER_TEST(CryptoHash_SHA256)
+{
+    TEST_CRYPTO_HASH(
+        DPL::Crypto::Hash::SHA256,
+        "sample_input_string",
+        "a470ec7c783ac51f9eb1772132e6bde1a053bbc81650719dd0ac62ecd93caf12");
+}
+
+RUNNER_TEST(CryptoHash_SHA384)
+{
+    TEST_CRYPTO_HASH(
+        DPL::Crypto::Hash::SHA384,
+        "sample_input_string",
+        "63d8bfa95c95c6906d1816965431c065278a655c60f786c9b246c1f73ba7ac557007f5064ba54ebd3a1988e6f37baa97");
+}
+
+RUNNER_TEST(CryptoHash_SHA512)
+{
+    TEST_CRYPTO_HASH(
+        DPL::Crypto::Hash::SHA512,
+        "sample_input_string",
+        "799317a140741937d9e5d8dbf9d3045d2c220de5ac33b3d5897acf873291ed14379eb15ef406d2284313d40edb0e01affac8efeb01cb47c2042e3e62a4a83d7d");
+}
diff --git a/tests/dpl/unused/test_message_queue.cpp b/tests/dpl/unused/test_message_queue.cpp
new file mode 100644 (file)
index 0000000..3322413
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_message_queue.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of message queue tests
+ */
+#include <dpl/test_runner.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/abstract_waitable_output_adapter.h>
+#include <dpl/message_queue.h>
+#include <dpl/binary_queue.h>
+#include <dpl/copy.h>
+#include <dpl/log.h>
+#include <dpl/application.h>
+#include <dpl/controller.h>
+#include <dpl/generic_event.h>
+
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+
+class QuitController :
+    public DPL::Controller<DPL::TypeListDecl<QuitEvent>::Type>,
+    public DPL::ApplicationExt
+{
+  public:
+    QuitController() : DPL::ApplicationExt(1, NULL, "test-app")
+    {
+        Touch();
+    }
+
+  protected:
+    virtual void OnEventReceived(const QuitEvent &)
+    {
+        Quit();
+    }
+};
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+class CopyThread :
+    public DPL::Thread
+{
+  private:
+    bool m_success;
+    DPL::AbstractWaitableInput *m_input;
+    DPL::AbstractWaitableOutput *m_output;
+    std::size_t m_dataSize;
+
+  public:
+    CopyThread(DPL::AbstractWaitableInput *input,
+               DPL::AbstractWaitableOutput *output,
+               std::size_t dataSize) :
+        m_success(true),
+        m_input(input),
+        m_output(output),
+        m_dataSize(dataSize)
+    {
+        LogInfo("Thread created");
+    }
+
+  protected:
+    virtual int ThreadEntry()
+    {
+        LogInfo("Entering copy thread");
+
+        Try
+        {
+            DPL::Copy(m_input, m_output, m_dataSize);
+        }
+        Catch(DPL::CopyFailed)
+        {
+            m_success = false;
+
+            LogWarning("Copy failed!");
+            return 0;
+        }
+
+        LogInfo("Copy finished");
+        return 0;
+    }
+};
+
+inline std::string BinaryQueueToString(const DPL::BinaryQueue &queue)
+{
+    char *buffer = new char[queue.Size()];
+    queue.Flatten(buffer, queue.Size());
+    std::string result = std::string(buffer, buffer + queue.Size());
+    delete[] buffer;
+    return result;
+}
+
+RUNNER_TEST(MessageQueue_DoubleCopy)
+{
+    DPL::BinaryQueue dataA;
+    DPL::MessageQueue dataB("/test_mqueue_dataB", true, false, 0660, true);
+    DPL::MessageQueue dataC("/test_mqueue_dataC", true, false, 0660, true);
+    DPL::BinaryQueue dataD;
+
+    DPL::AbstractWaitableInputAdapter dataAdapterA(&dataA);
+    DPL::AbstractWaitableOutputAdapter dataAdapterD(&dataD);
+
+    const std::string testData =
+        "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
+        "Cras elementum venenatis velit, sit amet vehicula odio gravida a."
+        "Curabitur id nibh id ante adipiscing sollicitudin."
+        "Maecenas in tellus vel augue vehicula pharetra hendrerit cursus est."
+        ""
+        "Ut malesuada quam porttitor dui euismod lacinia."
+        "Phasellus quis lectus sed lectus dictum tincidunt et vitae leo."
+        "Fusce id est massa, condimentum bibendum urna."
+        "Donec venenatis quam eget sapien vulputate egestas."
+        "Maecenas scelerisque lorem a neque molestie a varius erat condimentum."
+        "Maecenas varius hendrerit ligula, sed iaculis justo pretium id."
+        "Nunc sit amet nisl vitae justo tristique suscipit id eget tortor."
+        ""
+        "Pellentesque sollicitudin nulla at metus dapibus tincidunt."
+        "Integer consequat justo eget dui imperdiet iaculis."
+        "Sed vestibulum ipsum vitae libero accumsan non molestie metus adipiscing."
+        ""
+        "Vivamus quis dui enim, in blandit urna."
+        "In imperdiet lacus at orci elementum a scelerisque dui blandit."
+        "Donec vulputate enim metus, eget convallis ante."
+        "Etiam mollis enim eget eros pulvinar nec sagittis justo fermentum."
+        ""
+        "Vestibulum sed nunc eu leo lobortis ultrices."
+        "Nullam placerat nulla et est blandit nec interdum nunc pulvinar."
+        "Vivamus a lectus eget dui fermentum hendrerit.";
+
+    QuitController quitter;
+    quitter.PostTimedEvent(QuitEvent(), 1.0);
+
+    CopyThread threadA(&dataAdapterA, &dataB, testData.size());
+    CopyThread threadB(&dataB, &dataC, testData.size());
+    CopyThread threadC(&dataC, &dataAdapterD, testData.size());
+
+    dataA.AppendCopy(testData.c_str(), testData.size());
+
+    threadA.Run();
+    threadB.Run();
+    threadC.Run();
+
+    quitter.Exec();
+
+    threadA.Quit();
+    threadB.Quit();
+    threadC.Quit();
+
+    // Now, test data should be in dataD
+    RUNNER_ASSERT(BinaryQueueToString(dataD) == testData);
+}
diff --git a/tests/dpl/unused/test_shm.cpp b/tests/dpl/unused/test_shm.cpp
new file mode 100644 (file)
index 0000000..4f2d93a
--- /dev/null
@@ -0,0 +1,1664 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    test_shm.h
+ * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for test cases for shared data framework
+ */
+
+#include <stdlib.h>
+#include <ctime>
+#include <sys/shm.h>
+#include <dpl/semaphore.h>
+#include <dpl/test_runner.h>
+#include <dpl/thread.h>
+#include <dpl/controller.h>
+#include <dpl/generic_event.h>
+#include <dpl/log.h>
+#include <dpl/shared_object.h>
+#include <dpl/shared_property.h>
+#include <memory>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+using namespace DPL;
+
+namespace {
+const SharedMemory::Key SHM_KEY = 12345;
+const char* SEM_NAME = "/wrt_engine_shared_object_semaphore";
+const size_t VERSION = 1;
+
+const size_t MAX_THREADS = 10;
+const size_t TEST_AND_SET_REPEATS = 100;
+
+const size_t SHARED_PROP_REPEATS = 3;
+
+const size_t SINGLETON_TEST_REPEATS = 3;
+
+// maximum random delay in singleton listener addition/removal
+const size_t MAX_SINGLETON_LISTENER_DELAY = 50;
+
+const int SINGLE_PROCESS_REPEATS = 50;
+
+/*
+ * 5 seconds expected timeout for waitable events
+ * 30 seconds unexpected timeout for waitable events
+ * We don't want to block tests
+ */
+const size_t EXPECTED_WAITABLE_TIMEOUT = 5 * 1000;
+const size_t UNEXPECTED_WAITABLE_TIMEOUT = 30 * 1000;
+
+bool g_enumTestCorrect = false;
+bool g_enumTestIncorrect = false;
+size_t g_delegateCalls = 0;
+
+void Wait(DPL::WaitableEvent& event, bool expectedTimeout = false)
+{
+    LogDebug("WaitForSingleHandle...");
+    DPL::WaitableHandleIndexList list = DPL::WaitForSingleHandle(
+            event.GetHandle(),
+            expectedTimeout ?
+            EXPECTED_WAITABLE_TIMEOUT : UNEXPECTED_WAITABLE_TIMEOUT);
+    if (list.size() == 0) {
+        LogDebug("...timeout.");
+    } else {
+        LogDebug("...signaled.");
+        event.Reset();
+    }
+
+    if (expectedTimeout) {
+        RUNNER_ASSERT(list.size() == 0);
+    } else {
+        RUNNER_ASSERT(list.size() == 1);
+    }
+}
+
+void RemoveIpcs()
+{
+    Try {
+        SharedMemory::Remove(SHM_KEY);
+    }
+    Catch(SharedMemory::Exception::RemoveFailed) {
+        // ignore
+    }
+
+    Try {
+        DPL::Semaphore::Remove(SEM_NAME);
+    }
+    Catch(DPL::Semaphore::Exception::RemoveFailed) {
+        // ignore
+    }
+}
+
+typedef DPL::TypeListDecl<int, int, char, int[64]>::Type TestTypeList;
+typedef DPL::TypeListDecl<int, int, char, int[63]>::Type TestTypeList2;
+typedef DPL::TypeListDecl<int, int, char, int[63], int>::Type TestTypeList3;
+
+typedef SharedObject<TestTypeList> TestSharedObject;
+typedef SharedObject<TestTypeList2> TestSharedObject2;
+typedef SharedObject<TestTypeList3> TestSharedObject3;
+
+typedef std::shared_ptr<TestSharedObject> TestSharedObjectPtr;
+
+const int INIT_EVENT = 0;
+const int DESTROY_EVENT = 1;
+
+int g_values[TestTypeList::Size];
+
+/*
+ * helper listening controller
+ */
+template <typename SharedType>
+class ListeningController :
+    public DPL::Controller<DPL::TypeListDecl<int>::Type>
+{
+  public:
+    explicit ListeningController(DPL::WaitableEvent* waitable);
+    ~ListeningController();
+
+    virtual void OnEventReceived(const int &event);
+
+    virtual void OnEvent(const int /*event*/) {}
+
+  protected:
+    std::shared_ptr<SharedType> m_so;
+    DPL::Thread m_thread;
+    DPL::WaitableEvent* m_waitable;
+};
+
+template <typename SharedType>
+ListeningController<SharedType>::ListeningController(
+    DPL::WaitableEvent* waitable) :
+    m_waitable(waitable)
+{
+    Touch();
+    m_thread.Run();
+    SwitchToThread(&m_thread);
+    PostEvent(INIT_EVENT);
+}
+
+template <typename SharedType>
+ListeningController<SharedType>::~ListeningController()
+{
+    m_thread.Quit();
+}
+
+template <typename SharedType>
+void ListeningController<SharedType>::OnEventReceived(const int& event)
+{
+    if (event == INIT_EVENT) {
+        m_so = SharedObjectFactory<SharedType>::Create(SHM_KEY, SEM_NAME);
+        OnEvent(event);
+        m_waitable->Signal();
+    } else if (event == DESTROY_EVENT) {
+        LogDebug("Destroying shared object");
+        OnEvent(event);
+
+        // deregister, destroy ad notify main thread
+        m_so.Reset();
+        LogDebug("4");
+        m_waitable->Signal();
+        LogDebug("5");
+    } else {
+        OnEvent(event);
+    }
+}
+
+typedef DPL::TypeListDecl<size_t, bool>::Type SharedTypeList;
+
+class TestSharedObject4;
+typedef std::shared_ptr<TestSharedObject4> TestSharedObject4Ptr;
+
+class TestSharedObject4 : public SharedObject<SharedTypeList>
+{
+  public:
+    enum
+    {
+        SIZE_T,
+        BOOLEAN
+    };
+
+    static TestSharedObject4Ptr Create()
+    {
+        return SharedObjectFactory<TestSharedObject4>::Create(SHM_KEY, SEM_NAME);
+    }
+
+    ~TestSharedObject4()
+    {
+        LogDebug("dtor");
+    }
+
+  protected:
+    explicit TestSharedObject4(const std::string& semaphore) :
+        SharedObject<SharedTypeList>(semaphore)
+    {}
+
+  private:
+    void Init()
+    {
+        SetPropertyInternal<BOOLEAN>(false);
+    }
+    friend class SharedObjectFactory<TestSharedObject4>;
+};
+} // anonymus namespace
+
+//////////////////////////////////////////////
+
+RUNNER_TEST(SharedMemory_002_AccessByType)
+{
+    RemoveIpcs();
+
+    SharedData<TestTypeList> str;
+
+    // access by type
+    str.Embedded<0, int>::value = 4;
+    str.Embedded<1, int>::value = 5;
+    str.Embedded<2, char>::value = 'd';
+    str.Embedded<3, int[64]>::value[0] = 1;
+    str.Embedded<3, int[64]>::value[1] = 20;
+
+    RUNNER_ASSERT((str.Embedded<0, int>::value) == 4);
+    RUNNER_ASSERT((str.Embedded<1, int>::value) == 5);
+    RUNNER_ASSERT((str.Embedded<2, char>::value) == 'd');
+    RUNNER_ASSERT((str.Embedded<3, int[64]>::value[0]) == 1);
+    RUNNER_ASSERT((str.Embedded<3, int[64]>::value[1]) == 20);
+}
+
+//////////////////////////////////////////////
+
+RUNNER_TEST(SharedMemory_003_AccessByIndex)
+{
+    RemoveIpcs();
+
+    SharedData<TestTypeList> str;
+    // access by enum
+    str.Embedded<0, TestTypeList::Element<0>::Type>::value = 4;
+    str.Embedded<1, TestTypeList::Element<1>::Type>::value = 5;
+    str.Embedded<2, TestTypeList::Element<2>::Type>::value = 'd';
+    str.Embedded<3, TestTypeList::Element<3>::Type>::value[0] = 1;
+    str.Embedded<3, TestTypeList::Element<3>::Type>::value[1] = 20;
+
+    RUNNER_ASSERT(
+        (str.Embedded<0, TestTypeList::Element<0>::Type>::value) == 4);
+    RUNNER_ASSERT(
+        (str.Embedded<1, TestTypeList::Element<1>::Type>::value) == 5);
+    RUNNER_ASSERT(
+        (str.Embedded<2, TestTypeList::Element<2>::Type>::value) == 'd');
+    RUNNER_ASSERT(
+        (str.Embedded<3, TestTypeList::Element<3>::Type>::value[0]) == 1);
+    RUNNER_ASSERT(
+        (str.Embedded<3, TestTypeList::Element<3>::Type>::value[1]) == 20);
+}
+
+//////////////////////////////////////////////
+
+RUNNER_TEST(SharedMemory_004_SimplifiedAccess)
+{
+    RemoveIpcs();
+
+    SharedData<TestTypeList> str;
+
+    // access via PropertyRef
+    str.PropertyRef<1>() = 3;
+    RUNNER_ASSERT(str.PropertyRef<1>() == 3);
+
+    int (&array)[64] = str.PropertyRef<3>();
+    array[0] = 2;
+    RUNNER_ASSERT(str.PropertyRef<3>()[0] == 2);
+
+    str.PropertyRef<3>()[1] = 19;
+    RUNNER_ASSERT(str.PropertyRef<3>()[1] == 19);
+
+    // access via macro
+    str.SHARED_PROPERTY(0) = 2;
+    RUNNER_ASSERT(str.SHARED_PROPERTY(0) == 2);
+
+    str.SHARED_PROPERTY(2) = 'c';
+    RUNNER_ASSERT(str.SHARED_PROPERTY(2) == 'c');
+
+    str.SHARED_PROPERTY(3)[2] = 10;
+    RUNNER_ASSERT(str.SHARED_PROPERTY(3)[2] == 10);
+
+    // old style check
+    RUNNER_ASSERT((str.Embedded<0, int>::value) == 2);
+    RUNNER_ASSERT((str.Embedded<1, int>::value) == 3);
+    RUNNER_ASSERT((str.Embedded<2, char>::value) == 'c');
+    RUNNER_ASSERT((str.Embedded<3, int[64]>::value[0]) == 2);
+    RUNNER_ASSERT((str.Embedded<3, int[64]>::value[1]) == 19);
+    RUNNER_ASSERT((str.Embedded<3, int[64]>::value[2]) == 10);
+}
+
+//////////////////////////////////////////////
+
+struct SharedStruct
+{
+    int a;
+    int b;
+    char c;
+    int d[64];
+};
+
+typedef std::shared_ptr<SharedMemory::Segment<SharedStruct> > SharedStructPtr;
+
+RUNNER_TEST(SharedMemory_010_BaseShmTest)
+{
+    RemoveIpcs();
+
+    typedef std::unique_ptr<SharedMemory> SharedMemoryPtr;
+
+    // write
+    SharedMemoryPtr shm;
+    Try {
+        shm.Reset(SharedMemory::Create<SharedStruct>(SHM_KEY, false));
+    }
+    Catch(SharedMemory::Exception::NotFound) {
+        shm.Reset(SharedMemory::Create<SharedStruct>(SHM_KEY, true, true));
+    }
+
+    SharedStructPtr str = shm->Attach<SharedStruct>();
+
+    str->Data()->a = 1;
+    str->Data()->b = 2;
+    str->Data()->c = '3';
+    str->Data()->d[0] = 4;
+    str->Data()->d[1] = 5;
+
+    // read
+    SharedMemoryPtr shm2;
+    Try {
+        shm2.Reset(SharedMemory::Create<SharedStruct>(SHM_KEY, false));
+    }
+    Catch(SharedMemory::Exception::NotFound) {
+        shm2.Reset(SharedMemory::Create<SharedStruct>(SHM_KEY, true, true));
+    }
+
+    SharedStructPtr str2 = shm2->Attach<SharedStruct>();
+    SharedStructPtr str3 = shm2->Attach<SharedStruct>();
+
+    RUNNER_ASSERT(str2->Data()->a == 1);
+    RUNNER_ASSERT(str2->Data()->b == 2);
+    RUNNER_ASSERT(str2->Data()->c == '3');
+    RUNNER_ASSERT(str2->Data()->d[0] == 4);
+    RUNNER_ASSERT(str2->Data()->d[1] == 5);
+
+    RUNNER_ASSERT(str3->Data()->a == 1);
+    RUNNER_ASSERT(str3->Data()->b == 2);
+    RUNNER_ASSERT(str3->Data()->c == '3');
+    RUNNER_ASSERT(str3->Data()->d[0] == 4);
+    RUNNER_ASSERT(str3->Data()->d[1] == 5);
+
+    str2->Data()->b = 4;
+    str2->Data()->c = 'c';
+    str2->Data()->d[0] = 0;
+    RUNNER_ASSERT(str3->Data()->a == 1);
+    RUNNER_ASSERT(str3->Data()->b == 4);
+    RUNNER_ASSERT(str3->Data()->c == 'c');
+    RUNNER_ASSERT(str3->Data()->d[0] == 0);
+    RUNNER_ASSERT(str3->Data()->d[1] == 5);
+}
+
+//////////////////////////////////////////////
+
+RUNNER_TEST(SharedMemory_020_SharedObjectTest)
+{
+    RemoveIpcs();
+
+    typedef SharedObject<SharedTypeList> MySharedObj;
+
+    MySharedObj::Ptr so =
+        SharedObjectFactory<MySharedObj>::Create(SHM_KEY, SEM_NAME);
+
+    RUNNER_ASSERT((so->GetProperty<0, size_t>()) == 0);
+    so->SetProperty<0, size_t>(4);
+    RUNNER_ASSERT((so->GetProperty<0, size_t>()) == 4);
+}
+
+//////////////////////////////////////////////
+
+class InitTestSharedObject : public TestSharedObject
+{
+  protected:
+    explicit InitTestSharedObject(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+    virtual void Init();    // from SharedObject
+
+  private:
+    friend class SharedObjectFactory<InitTestSharedObject>;
+};
+
+void InitTestSharedObject::Init()
+{
+    SetPropertyInternal<0>(1);
+    SetPropertyInternal<1>(2);
+    SetPropertyInternal<2>('c');
+}
+
+RUNNER_TEST(SharedMemory_021_InitTest)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    std::shared_ptr<InitTestSharedObject> sho =
+        SharedObjectFactory<InitTestSharedObject>::Create(
+            SHM_KEY, SEM_NAME);
+    RUNNER_ASSERT((sho->GetProperty<0, int>()) == 1);
+    RUNNER_ASSERT((sho->GetProperty<1, int>()) == 2);
+    RUNNER_ASSERT((sho->GetProperty<2, char>()) == 'c');
+}
+
+//////////////////////////////////////////////
+
+class VersionTestSO1 : public TestSharedObject
+{
+  protected:
+    explicit VersionTestSO1(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+    virtual SizeType GetVersion() const
+    {
+        return 1;
+    }                                                    // from SharedObject
+
+  private:
+    friend class SharedObjectFactory<VersionTestSO1>;
+};
+
+class VersionTestSO2 : public TestSharedObject
+{
+  protected:
+    explicit VersionTestSO2(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+    virtual SizeType GetVersion() const
+    {
+        return 2;
+    }                                                    // from SharedObject
+
+  private:
+    friend class SharedObjectFactory<VersionTestSO2>;
+};
+
+RUNNER_TEST(SharedMemory_022_InvalidVersionTest)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    std::shared_ptr<VersionTestSO1> sho =
+        SharedObjectFactory<VersionTestSO1>::Create(SHM_KEY, SEM_NAME);
+
+    Try {
+        std::shared_ptr<VersionTestSO2> sho2 =
+            SharedObjectFactory<VersionTestSO2>::Create(SHM_KEY, SEM_NAME);
+
+        RUNNER_ASSERT_MSG(false, "Invalid shm version has been accepted");
+    }
+    Catch(SharedObjectBase::Exception::InvalidVersion) {
+        RUNNER_ASSERT(true);
+    }
+}
+
+//////////////////////////////////////////////
+
+RUNNER_TEST(SharedMemory_023_InvalidSizeTest)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    typedef SharedObject<TestTypeList> SO1;
+    typedef SharedObject<TestTypeList2> SO2;
+
+    SO1::Ptr sho = SharedObjectFactory<SO1>::Create(SHM_KEY, SEM_NAME);
+
+    Try {
+        SO2::Ptr sho2 = SharedObjectFactory<SO2>::Create(SHM_KEY, SEM_NAME);
+
+        RUNNER_ASSERT_MSG(false, "Invalid shm size has been accepted");
+    }
+    Catch(SharedObjectBase::Exception::InvalidSize) {
+        RUNNER_ASSERT(true);
+    }
+}
+
+//////////////////////////////////////////////
+
+class MagicTestSO1 : public TestSharedObject
+{
+  protected:
+    explicit MagicTestSO1(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+    // from SharedObject
+    virtual MagicType GetMagicNumber() const
+    {
+        return 661;
+    }
+
+  private:
+    friend class SharedObjectFactory<MagicTestSO1>;
+};
+
+class MagicTestSO2 : public TestSharedObject
+{
+  protected:
+    explicit MagicTestSO2(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+    // from SharedObject
+    virtual MagicType GetMagicNumber() const
+    {
+        return 662;
+    }
+
+  private:
+    friend class SharedObjectFactory<MagicTestSO2>;
+};
+
+RUNNER_TEST(SharedMemory_024_InvalidMagicTest)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    std::shared_ptr<MagicTestSO1> sho =
+        SharedObjectFactory<MagicTestSO1>::Create(SHM_KEY, SEM_NAME);
+
+    Try {
+        std::shared_ptr<MagicTestSO2> sho2 =
+            SharedObjectFactory<MagicTestSO2>::Create(SHM_KEY, SEM_NAME);
+
+        RUNNER_ASSERT_MSG(false, "Invalid shm magic number has been accepted");
+    }
+    Catch(SharedObjectBase::Exception::InvalidMagicNumber) {
+        RUNNER_ASSERT(true);
+    }
+}
+
+//////////////////////////////////////////////
+
+/*
+ * Listening shared object
+ */
+class EnumTestSO1 : public TestSharedObject
+{
+  public:
+    void SetWaitable(DPL::WaitableEvent* waitable)
+    {
+        m_waitable = waitable;
+    }
+
+  protected:
+    explicit EnumTestSO1(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+    virtual void PropertyChanged(size_t propertyEnum);
+
+  private:
+    friend class SharedObjectFactory<EnumTestSO1>;
+
+    DPL::WaitableEvent* m_waitable;
+};
+
+void EnumTestSO1::PropertyChanged(size_t propertyEnum)
+{
+    if (propertyEnum == 1) {
+        LogDebug("Property enum " << propertyEnum << " correctly set");
+        g_enumTestCorrect = true;
+    }
+    if (propertyEnum == 4) {
+        // This is bad. We only have 4 types
+        LogError("Property enum " << propertyEnum << " should be skipped");
+        g_enumTestIncorrect = true;
+    }
+    // confirm property change notification
+    m_waitable->Signal();
+}
+
+class EnumController : public ListeningController<EnumTestSO1>
+{
+  public:
+    explicit EnumController(DPL::WaitableEvent* waitable) :
+        ListeningController<EnumTestSO1>(waitable) {}
+
+    virtual void OnEvent(const int event);
+};
+
+void EnumController::OnEvent(const int event)
+{
+    if (event == INIT_EVENT) {
+        m_so->SetWaitable(m_waitable);
+    }
+}
+
+/*
+ * Writing shared object with correct size but different number of types
+ */
+class EnumTestSO2 : public TestSharedObject3
+{
+  protected:
+    explicit EnumTestSO2(const std::string& semaphore) :
+        TestSharedObject3(semaphore) {}
+
+  private:
+    friend class SharedObjectFactory<EnumTestSO2>;
+};
+
+RUNNER_TEST(SharedMemory_025_InvalidEnumTest)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    g_enumTestCorrect = false;
+    g_enumTestIncorrect = false;
+
+    DPL::WaitableEvent waitable;
+
+    // create listening controller and wait until it registers
+    EnumController controller(&waitable);
+    Wait(waitable);
+    LogDebug("Listening controller created");
+
+    // create writing shared object
+    std::shared_ptr<EnumTestSO2> sho2 =
+        SharedObjectFactory<EnumTestSO2>::Create(SHM_KEY, SEM_NAME);
+    DPL::WaitableHandleIndexList list;
+
+    // write property and wait for confirmation
+    sho2->SetProperty<1>(2);
+    Wait(waitable);
+
+    // write incorrect property and wait for confirmation
+    // we expect timeout
+    sho2->SetProperty<4>(2);
+    Wait(waitable, true);
+
+    // schedule listener deregistration and wait for confirmation
+    controller.PostEvent(DESTROY_EVENT);
+    Wait(waitable);
+
+    // check results
+    RUNNER_ASSERT(g_enumTestCorrect == true);
+    RUNNER_ASSERT(g_enumTestIncorrect == false);
+}
+
+//////////////////////////////////////////////
+
+class MultiThreadSO : public TestSharedObject
+{
+  public:
+    void TestAndSetProperty();
+
+  protected:
+    explicit MultiThreadSO(const std::string& semaphore) :
+        TestSharedObject(semaphore) {}
+
+  private:
+    friend class SharedObjectFactory<MultiThreadSO>;
+};
+
+void MultiThreadSO::TestAndSetProperty()
+{
+    ScopedFlaggedLock lock(*this);
+
+    int value = PropertyRef<0, int>();
+    DPL::Thread::MicroSleep(100);
+    SetPropertyInternal<0>(value + 1);
+}
+
+class ShmController : public ListeningController<MultiThreadSO>
+{
+  public:
+    explicit ShmController(DPL::WaitableEvent* event) :
+        ListeningController<MultiThreadSO>(event), m_counter(0)
+    {}
+
+    virtual void OnEventReceived(const int& event);
+
+  private:
+    size_t m_counter;
+};
+
+void ShmController::OnEventReceived(const int& event)
+{
+    if (event == INIT_EVENT) {
+        m_so = SharedObjectFactory<MultiThreadSO>::Create(SHM_KEY, SEM_NAME);
+        PostEvent(2);
+    } else if (event == DESTROY_EVENT) {
+        LogDebug("Destroying shared object");
+        // deregister, destroy ad notify main thread
+        m_so.Reset();
+        m_waitable->Signal();
+    } else if (event == 2) {
+        m_so->TestAndSetProperty();
+        m_counter++;
+        if (m_counter >= TEST_AND_SET_REPEATS) {
+            LogDebug("Max tests reached. Finishing thread");
+            PostEvent(DESTROY_EVENT);
+            return;
+        }
+        PostEvent(2);
+    }
+}
+
+RUNNER_TEST(SharedMemory_030_MultithreadTest)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    typedef SharedObject<TestTypeList> SHO;
+    SHO::Ptr sho = SharedObjectFactory<SHO>::Create(SHM_KEY, SEM_NAME);
+
+    ShmController* controller[MAX_THREADS];
+    DPL::WaitableEvent finalEvent[MAX_THREADS];
+
+    for (size_t i = 0; i < MAX_THREADS; ++i) {
+        controller[i] = new ShmController(&finalEvent[i]);
+    }
+
+    for (size_t i = 0; i < MAX_THREADS; ++i) {
+        Wait(finalEvent[i]);
+    }
+
+    for (size_t i = 0; i < MAX_THREADS; ++i) {
+        delete controller[i];
+        controller[i] = NULL;
+    }
+
+    int value = sho->GetProperty<0, int>();
+    LogDebug("Final value is " << value << ", expected " <<
+             MAX_THREADS * TEST_AND_SET_REPEATS);
+    RUNNER_ASSERT(value == MAX_THREADS * TEST_AND_SET_REPEATS);
+}
+
+//////////////////////////////////////////////
+
+class MyModel10 : public DPL::Model
+{
+  public:
+    explicit MyModel10(const TestSharedObject4Ptr& shared_object) :
+        DPL::Model(), boolValue(this, shared_object) {}
+
+    SharedProperty<bool, TestSharedObject4::BOOLEAN, TestSharedObject4>
+    boolValue;
+};
+
+/*
+ * Listening controller
+ */
+class ShmController3 : public ListeningController<TestSharedObject4>
+{
+  public:
+    explicit ShmController3(DPL::WaitableEvent* event) :
+        ListeningController<TestSharedObject4>(event)
+    {}
+
+    virtual void OnEvent(const int event);
+
+    void OnValueChanged(const DPL::PropertyEvent<bool>& event);
+
+  private:
+    typedef std::unique_ptr<MyModel10> MyModelPtr;
+
+    // model with property bound to shared object
+    MyModelPtr m_model;
+};
+
+void ShmController3::OnEvent(const int event)
+{
+    if (event == INIT_EVENT) {
+        m_model.Reset(new MyModel10(m_so));
+        m_model->boolValue.AddListener(
+            DPL::FastDelegate<void (const DPL::PropertyEvent<bool>&)>(
+                this,
+                &ShmController3::OnValueChanged));
+    } else if (event == DESTROY_EVENT) {
+        m_model->boolValue.RemoveListener(
+            DPL::FastDelegate<void (const DPL::PropertyEvent<bool>&)>(
+                this,
+                &ShmController3::OnValueChanged));
+        m_model.Reset();
+    }
+}
+
+void ShmController3::OnValueChanged(const DPL::PropertyEvent<bool>& event)
+{
+    if (event.value) {
+        // change back
+        m_model->boolValue.Set(false);
+    } else {
+        LogError("Expected value = true, got false");
+    }
+
+    m_waitable->Signal();
+}
+
+RUNNER_TEST(SharedMemory_050_SharedProperty)
+{
+    RemoveIpcs();
+
+    bool result = true;
+    DPL::WaitableEvent waitable;
+    // listener controller
+    ShmController3 controller(&waitable);
+    Wait(waitable);
+
+    TestSharedObject4Ptr sharedObject = TestSharedObject4::Create();
+
+    for (size_t i = 0; i < SHARED_PROP_REPEATS; ++i) {
+        sharedObject->SetProperty<TestSharedObject4::BOOLEAN>(true);
+        Wait(waitable);
+        result = sharedObject->GetProperty<TestSharedObject4::BOOLEAN,
+                                           bool>();
+        RUNNER_ASSERT(result == false);
+    }
+    controller.PostEvent(DESTROY_EVENT);
+    Wait(waitable);
+}
+
+//////////////////////////////////////////////
+
+class MyModel2 : public DPL::Model
+{
+  public:
+    explicit MyModel2(const TestSharedObjectPtr& shared_object) :
+        counter(this, shared_object) {}
+
+    SharedProperty<int, 0, TestSharedObject> counter;
+};
+
+class SPController : public ListeningController<TestSharedObject>
+{
+  public:
+    explicit SPController(DPL::WaitableEvent* event) :
+        ListeningController<TestSharedObject>(event), m_repeats(1) {}
+
+    virtual void OnEvent(const int event);
+
+    void OnValueChanged1(const DPL::PropertyEvent<int>& event);
+    void OnValueChanged2(const DPL::PropertyEvent<int>& event);
+
+  private:
+    std::unique_ptr<MyModel2> m_model1;
+    std::unique_ptr<MyModel2> m_model2;
+
+    int m_repeats;
+    std::shared_ptr<TestSharedObject> m_so2;
+};
+
+void SPController::OnEvent(const int event)
+{
+    if (event == INIT_EVENT) {
+        m_so2 = SharedObjectFactory<TestSharedObject>::Create(SHM_KEY,
+                                                              SEM_NAME);
+
+        // create and register 2 models sharing the same property
+        m_model1.Reset(new MyModel2(m_so));
+        m_model2.Reset(new MyModel2(m_so2));
+        m_model1->counter.AddListener(
+            DPL::FastDelegate<void (const DPL::PropertyEvent<int>&)>(
+                this,
+                &SPController::OnValueChanged1));
+        m_model2->counter.AddListener(
+            DPL::FastDelegate<void (const DPL::PropertyEvent<int>&)>(
+                this,
+                &SPController::OnValueChanged2));
+        m_model1->counter.Set(1);
+    } else if (event == DESTROY_EVENT) {
+        m_model1->counter.RemoveListener(
+            DPL::FastDelegate<void (const DPL::PropertyEvent<int>&)>(
+                this,
+                &SPController::OnValueChanged1));
+        m_model2->counter.RemoveListener(
+            DPL::FastDelegate<void (const DPL::PropertyEvent<int>&)>(
+                this,
+                &SPController::OnValueChanged2));
+
+        m_model1.Reset();
+        m_model2.Reset();
+        m_so2.Reset();
+    }
+}
+
+void SPController::OnValueChanged1(const DPL::PropertyEvent<int>& event)
+{
+    if (m_repeats >= SINGLE_PROCESS_REPEATS) {
+        PostEvent(DESTROY_EVENT);
+        return;
+    }
+
+    LogDebug("[1] Value changed to " << event.value);
+    m_repeats++;
+    m_model1->counter.Set(event.value + 1);
+}
+
+void SPController::OnValueChanged2(const DPL::PropertyEvent<int>& event)
+{
+    if (m_repeats >= SINGLE_PROCESS_REPEATS) {
+        PostEvent(DESTROY_EVENT);
+        return;
+    }
+
+    LogDebug("[2] Value changed to " << event.value);
+    m_repeats++;
+    m_model2->counter.Set(event.value + 1);
+}
+
+RUNNER_TEST(SharedMemory_060_SingleProcess)
+{
+    RemoveIpcs();
+
+    DPL::WaitableEvent waitable;
+    SPController controller(&waitable);
+    TestSharedObjectPtr sho = SharedObjectFactory<TestSharedObject>::Create(
+            SHM_KEY,
+            SEM_NAME);
+
+    // wait for creation
+    Wait(waitable);
+
+    // wait for destruction
+    Wait(waitable);
+
+    int value = sho->GetProperty<0, int>();
+
+    LogDebug("final value: " << value);
+
+    // check value
+    RUNNER_ASSERT(value == SINGLE_PROCESS_REPEATS);
+}
+
+//////////////////////////////////////////////
+
+class ListenerTestController : public ListeningController<TestSharedObject>,
+    public ISharedObjectListener<0, int>,
+    public ISharedObjectListener<1, int>,
+    public ISharedObjectListener<2, char>,
+    public ISharedObjectListener<3, int[64]>
+{
+  public:
+    explicit ListenerTestController(DPL::WaitableEvent* event) :
+        ListeningController<TestSharedObject>(event) {}
+
+    ~ListenerTestController();
+
+    virtual void OnEvent(const int event);
+
+    virtual void ValueChanged(size_t propertyEnum,
+                              const int& value,
+                              const void* info = NULL);
+    virtual void ValueChanged(size_t propertyEnum,
+                              const char& value,
+                              const void* info = NULL);
+    virtual void ValueChanged(size_t propertyEnum,
+                              const int(&value)[64],
+                              const void* info = NULL);
+};
+
+ListenerTestController::~ListenerTestController()
+{}
+
+void ListenerTestController::OnEvent(const int event)
+{
+    if (event == INIT_EVENT) {
+        // add self as a listener to shared object
+        m_so->AddListener<0, int>(this);
+        m_so->AddListener<1, int>(this);
+        m_so->AddListener<2, char>(this);
+        m_so->AddListener<3, int[64]>(this);
+    } else if (event == DESTROY_EVENT) {
+        // remove self from listener list
+        m_so->RemoveListener<0, int>(this);
+        m_so->RemoveListener<1, int>(this);
+        m_so->RemoveListener<2, char>(this);
+        m_so->RemoveListener<3, int[64]>(this);
+    }
+}
+
+void ListenerTestController::ValueChanged(size_t propertyEnum,
+                                          const int& value,
+                                          const void* /*info*/)
+{
+    LogDebug("ValueChanged(int) " << propertyEnum << " " << value);
+    if ((propertyEnum == 0 &&
+         value == 1) || (propertyEnum == 1 && value == 2))
+    {
+        g_values[propertyEnum]++;
+        if (g_values[propertyEnum] == 3) {
+            m_waitable->Signal();
+        }
+    }
+}
+
+void ListenerTestController::ValueChanged(size_t propertyEnum,
+                                          const char& value,
+                                          const void* /*info*/)
+{
+    LogDebug("ValueChanged(char) " << propertyEnum << " " << value);
+    if (propertyEnum == 2 && value == 'c') {
+        g_values[propertyEnum]++;
+        if (g_values[propertyEnum] == 3) {
+            m_waitable->Signal();
+        }
+    }
+}
+
+void ListenerTestController::ValueChanged(size_t propertyEnum,
+                                          const int(&value)[64],
+                                          const void* /*info*/)
+{
+    LogDebug("ValueChanged(int[64]) " << propertyEnum << " " << value[5]);
+    if (propertyEnum == 3 && value[5] == 5) {
+        g_values[propertyEnum]++;
+        if (g_values[propertyEnum] == 3) {
+            m_waitable->Signal();
+        }
+    }
+}
+
+RUNNER_TEST(SharedMemory_070_SharedObjectListeners)
+{
+    RemoveIpcs();
+
+    // setup global flags
+    for (size_t i = 0; i < TestTypeList::Size; ++i) {
+        g_values[i] = 0;
+    }
+
+    // create shared object
+    TestSharedObjectPtr sho = SharedObjectFactory<TestSharedObject>::Create(
+            SHM_KEY, SEM_NAME);
+
+    // create 1st listener and wait for it
+    DPL::WaitableEvent waitable;
+    ListenerTestController c1(&waitable);
+    Wait(waitable);
+
+    // create 2nd listener and wait for it
+    ListenerTestController c2(&waitable);
+    Wait(waitable);
+
+    // create 3rd listener and wait for it
+    ListenerTestController c3(&waitable);
+    Wait(waitable);
+
+    // set properties and wait for result
+    sho->SetProperty<0, int>(1);
+    Wait(waitable);
+
+    RUNNER_ASSERT(g_values[0] == 3);
+
+    sho->SetProperty<1, int>(2);
+    Wait(waitable);
+
+    RUNNER_ASSERT(g_values[1] == 3);
+
+    sho->SetProperty<2, char>('c');
+    Wait(waitable);
+
+    RUNNER_ASSERT(g_values[2] == 3);
+
+    int array[64];
+    memset(array, 64 * sizeof(array[0]), 0);
+    array[5] = 5;
+    sho->SetProperty<3, int[64]>(array);
+    Wait(waitable);
+
+    RUNNER_ASSERT(g_values[3] == 3);
+
+    // finalize listeners
+    c1.PostEvent(DESTROY_EVENT);
+    Wait(waitable);
+
+    c2.PostEvent(DESTROY_EVENT);
+    Wait(waitable);
+
+    c3.PostEvent(DESTROY_EVENT);
+    Wait(waitable);
+}
+
+//////////////////////////////////////////////
+
+/*
+ * class simulating DB access
+ */
+class DAO : public DPL::Noncopyable
+{
+  public:
+    DAO() : m_boolValue(false) {}
+
+    void SetBoolValue(const bool& value)
+    {
+        m_boolValue = value;
+    }
+
+    bool GetBoolValue() const
+    {
+        return m_boolValue;
+    }
+
+  private:
+    bool m_boolValue;
+};
+
+/*
+ * Model with property having set delegate defined
+ */
+class MyModel3 : public DPL::Model
+{
+  public:
+    typedef SharedPropertyEx<bool,
+                             TestSharedObject4::BOOLEAN,
+                             TestSharedObject4> PropertyType;
+
+    MyModel3(const TestSharedObject4Ptr& shared_object, DAO* dao) :
+        boolValue(this,
+                  shared_object,
+                  PropertyType::SetDelegate(dao, &DAO::SetBoolValue))
+    {}
+
+    PropertyType boolValue;
+};
+
+RUNNER_TEST(SharedMemory_090_SetPropertyDelegate)
+{
+    RemoveIpcs();
+
+    // dao object
+    DAO dao;
+
+    // create shared object
+    TestSharedObject4Ptr sho = TestSharedObject4::Create();
+
+    // set property but call dao delegate within semaphore
+    sho->SetProperty<TestSharedObject4::BOOLEAN>(
+        true,
+        MyModel3::PropertyType::SetDelegate(&dao, &DAO::SetBoolValue));
+
+    // check dao value
+    RUNNER_ASSERT(dao.GetBoolValue() == true);
+
+    // check shared object value
+    bool shoValue = sho->GetProperty<TestSharedObject4::BOOLEAN, bool>();
+    RUNNER_ASSERT(shoValue == true);
+
+    // try the same with shared property
+    MyModel3 model(sho, &dao);
+
+    // set property
+    model.boolValue.Set(false);
+
+    // check dao value
+    RUNNER_ASSERT(dao.GetBoolValue() == false);
+
+    // check sho value
+    shoValue = sho->GetProperty<TestSharedObject4::BOOLEAN, bool>();
+    RUNNER_ASSERT(shoValue == false);
+
+    // check property value
+    RUNNER_ASSERT(model.boolValue.Get() == false);
+}
+
+//////////////////////////////////////////////
+
+/*
+ * Lazy initialization test shared object
+ */
+class LazySharedObject : public SharedObject<TestTypeList>
+{
+  public:
+    explicit LazySharedObject(const std::string& semaphore) :
+        SharedObject<TestTypeList>(semaphore)
+        , m_read(false)
+    {}
+
+    void Init();
+
+    bool IsRead() const
+    {
+        return m_read;
+    }
+
+  private:
+    friend class SharedObjectFactory<LazySharedObject>;
+
+    bool m_read;
+};
+
+void LazySharedObject::Init()
+{
+    SetPropertyInternal<0>(42);
+    m_read = true;
+}
+
+RUNNER_TEST(SharedMemory_100_LazyInit)
+{
+    RemoveIpcs();
+
+    typedef std::shared_ptr<LazySharedObject> LazySharedObjectPtr;
+
+    // create shared object
+    LazySharedObjectPtr sho = SharedObjectFactory<LazySharedObject>::Create(
+            SHM_KEY, SEM_NAME);
+
+    RUNNER_ASSERT(sho->IsRead() == false);
+
+    // get property causing lazy init
+    int value = sho->GetProperty<0, int>();
+
+    RUNNER_ASSERT(sho->IsRead() == true);
+    RUNNER_ASSERT(value == 42);
+
+    // create another object
+    LazySharedObjectPtr sho2 = SharedObjectFactory<LazySharedObject>::Create(
+            SHM_KEY, SEM_NAME);
+
+    RUNNER_ASSERT(sho2->IsRead() == false);
+
+    // get property NOT causing lazy init
+    value = sho2->GetProperty<0, int>();
+
+    RUNNER_ASSERT(sho2->IsRead() == false);
+    RUNNER_ASSERT(value == 42);
+
+    // destroy both objects
+    sho.Reset();
+    sho2.Reset();
+
+    // create shared object
+    LazySharedObjectPtr sho3 = SharedObjectFactory<LazySharedObject>::Create(
+            SHM_KEY, SEM_NAME);
+
+    RUNNER_ASSERT(sho3->IsRead() == false);
+
+    // set property causing lazy init
+    sho3->SetProperty<0>(43);
+    value = sho3->GetProperty<0, int>();
+
+    RUNNER_ASSERT(sho3->IsRead() == true);
+    RUNNER_ASSERT(value == 43);
+}
+
+//////////////////////////////////////////////
+
+bool SetCondition(const int& readValue, int& setValue);
+bool SetCondition(const int& readValue, int& setValue)
+{
+    LogDebug("Condition delegate called with read value = " << readValue <<
+             " and set value = " << setValue);
+
+    if (readValue > 3) {
+        LogDebug("Condition is false");
+        return false;
+    }
+
+    LogDebug("Condition is true");
+    if (4 == setValue) {
+        setValue = 10;
+        LogDebug("Changing set value to " << setValue);
+    }
+    return true;
+}
+
+void SetDelegate(const int& readValue);
+void SetDelegate(const int& readValue)
+{
+    LogDebug("Set delegate called " << readValue);
+    g_delegateCalls++;
+}
+
+RUNNER_TEST(SharedMemory_120_ConditionalSet)
+{
+    RemoveIpcs();
+
+    TestSharedObjectPtr sho = SharedObjectFactory<TestSharedObject>::Create(
+            SHM_KEY,
+            SEM_NAME);
+
+    g_delegateCalls = 0;
+
+    RUNNER_ASSERT(0 == (sho->GetProperty<0, int>()));
+
+    DPL::FastDelegate<bool (const int&, int&)> condition(&SetCondition);
+    DPL::FastDelegate<void (const int&)> delegate(&SetDelegate);
+
+    bool succeeded = false;
+
+    succeeded = sho->ConditionalSetProperty<0>(-2, condition);
+
+    RUNNER_ASSERT(succeeded);
+    RUNNER_ASSERT(-2 == (sho->GetProperty<0, int>()));
+
+    succeeded = sho->ConditionalSetProperty<0>(4, condition, delegate);
+
+    RUNNER_ASSERT(succeeded);
+    RUNNER_ASSERT(10 == (sho->GetProperty<0, int>()));
+    RUNNER_ASSERT(1 == g_delegateCalls);
+
+    succeeded = sho->ConditionalSetProperty<0>(5, condition);
+
+    RUNNER_ASSERT(!succeeded);
+    RUNNER_ASSERT(10 == (sho->GetProperty<0, int>()));
+
+    succeeded = sho->ConditionalSetProperty<0>(666, condition, delegate);
+
+    RUNNER_ASSERT(!succeeded);
+    RUNNER_ASSERT(10 == (sho->GetProperty<0, int>()));
+    RUNNER_ASSERT(1 == g_delegateCalls);
+}
+
+//////////////////////////////////////////////
+
+/*
+ * Shared object used by multiple threads as a singleton.
+ */
+class MTSharedObject : public SharedObject<TestTypeList>
+{
+  public:
+    explicit MTSharedObject(const std::string& semaphore) :
+        SharedObject<TestTypeList>(semaphore)
+    {}
+
+    void Clear();
+
+  private:
+    friend class SharedObjectFactory<MTSharedObject>;
+};
+
+typedef std::shared_ptr<MTSharedObject> MTSharedObjectPtr;
+
+void MTSharedObject::Clear()
+{
+    int array[64] = {};
+    SetProperty<0>(0);
+    SetProperty<1>(0);
+    SetProperty<2>(static_cast<char>(0));
+    SetProperty<3>(array);
+}
+
+/*
+ * Shared object singleton
+ */
+class SharedObjectSingleton
+{
+  public:
+    static MTSharedObjectPtr Instance();
+    static void Destroy();
+
+  private:
+    static MTSharedObjectPtr m_sho;
+    static DPL::Mutex m_mutex;
+};
+
+MTSharedObjectPtr SharedObjectSingleton::m_sho;
+DPL::Mutex SharedObjectSingleton::m_mutex;
+
+MTSharedObjectPtr SharedObjectSingleton::Instance()
+{
+    DPL::Mutex::ScopedLock lock(&m_mutex);
+    if (!m_sho) {
+        m_sho = SharedObjectFactory<MTSharedObject>::Create(SHM_KEY, SEM_NAME);
+    }
+    return m_sho;
+}
+
+void SharedObjectSingleton::Destroy()
+{
+    DPL::Mutex::ScopedLock lock(&m_mutex);
+    m_sho.Reset();
+}
+
+/*
+ * Listening controller
+ */
+class ShmController4 : public ListeningController<MTSharedObject>,
+    public ISharedObjectListener<0, int>,
+    public ISharedObjectListener<1, int>,
+    public ISharedObjectListener<2, char>,
+    public ISharedObjectListener<3, int[64]>
+{
+  public:
+    enum {
+        ADD_LISTENERS = 2,
+        REMOVE_LISTENERS = 3,
+        DESTROY_SINGLETON = 4
+    };
+
+    explicit ShmController4(DPL::WaitableEvent* event) :
+        ListeningController<MTSharedObject>(event)
+    {}
+
+    virtual void OnEventReceived(const int& event);
+
+    virtual void ValueChanged(size_t propertyEnum,
+                              const int& value,
+                              const void* info = NULL);
+    virtual void ValueChanged(size_t propertyEnum,
+                              const char& value,
+                              const void* info = NULL);
+    virtual void ValueChanged(size_t propertyEnum,
+                              const int(&value)[64],
+                              const void* info = NULL);
+
+    bool NotRegistered();
+
+  private:
+    void Sleep();
+
+    size_t m_counter;
+};
+
+void ShmController4::ValueChanged(size_t propertyEnum,
+                                  const int& value,
+                                  const void* /*info*/)
+{
+    LogDebug("ValueChanged(int) " << propertyEnum << " " << value);
+    if ((propertyEnum == 0 && value == 1) ||
+        (propertyEnum == 1 && value == 11))
+    {
+        m_waitable->Signal();
+    }
+}
+
+void ShmController4::ValueChanged(size_t propertyEnum,
+                                  const char& value,
+                                  const void* /*info*/)
+{
+    LogDebug("ValueChanged(char) " << propertyEnum << " " << value);
+    if (propertyEnum == 2 && value == 'a') {
+        m_waitable->Signal();
+    }
+}
+
+void ShmController4::ValueChanged(size_t propertyEnum,
+                                  const int(&value)[64],
+                                  const void* /*info*/)
+{
+    LogDebug("ValueChanged(int[64]) " << propertyEnum << " " << value[5]);
+    if (propertyEnum == 3 && value[0] == 0 && value[1] == 1 && value[2] == 2) {
+        m_waitable->Signal();
+    }
+}
+
+void ShmController4::Sleep()
+{
+    DPL::Thread::GetCurrentThread()->MiliSleep(
+        rand() % MAX_SINGLETON_LISTENER_DELAY);
+}
+
+void ShmController4::OnEventReceived(const int& event)
+{
+    switch (event) {
+    case INIT_EVENT:
+        m_so = SharedObjectSingleton::Instance();
+        m_waitable->Signal();
+        break;
+
+    case DESTROY_EVENT:
+        LogDebug("Destroying shared object");
+        // deregister, destroy and notify main thread
+        m_so.Reset();
+        m_waitable->Signal();
+        break;
+
+    case ADD_LISTENERS:
+        // add listener and notify
+        m_so->AddListener<0, int>(this);
+        Sleep();
+        m_so->AddListener<1, int>(this);
+        Sleep();
+        m_so->AddListener<2, char>(this);
+        Sleep();
+        m_so->AddListener<3, int[64]>(this);
+        Sleep();
+        m_waitable->Signal();
+        break;
+
+    case REMOVE_LISTENERS:
+        // remove listener and notify
+        m_so->RemoveListener<0, int>(this);
+        Sleep();
+        m_so->RemoveListener<1, int>(this);
+        Sleep();
+        m_so->RemoveListener<2, char>(this);
+        Sleep();
+        m_so->RemoveListener<3, int[64]>(this);
+        Sleep();
+        m_waitable->Signal();
+        break;
+
+    case DESTROY_SINGLETON:
+        SharedObjectSingleton::Destroy();
+        m_waitable->Signal();
+        break;
+
+    default:
+        LogError("Unsupported event received: " << event);
+    }
+}
+
+void MultipleWait(DPL::WaitableEvent(&event)[MAX_THREADS]);
+void MultipleWait(DPL::WaitableEvent(&event)[MAX_THREADS])
+{
+    for (size_t i = 0; i < MAX_THREADS; ++i) {
+        Wait(event[i]);
+    }
+}
+
+/*
+ * Try to remove property listener. If there's no such listener an exception
+ * should be thrown.
+ */
+#define LISTENER_ASSERT(property) \
+    Try { \
+        singleton->RemoveListener<(property)>(controller[i]); \
+        LogError("Controller " << i << " is still listening for property " \
+                               << #property); \
+        RUNNER_ASSERT_MSG(false, "No listeners expected"); \
+    } \
+    Catch(MTSharedObject::Exception::ListenerNotFound) { \
+        RUNNER_ASSERT(true); \
+    } \
+
+// test
+RUNNER_TEST(SharedMemory_130_SharedObjectSingleton)
+{
+    RemoveIpcs();   // we need non existing shm
+
+    srand(time(NULL));
+
+    // writer shared object
+    TestSharedObjectPtr sho = SharedObjectFactory<TestSharedObject>::Create(
+            SHM_KEY, SEM_NAME);
+
+    ShmController4* controller[MAX_THREADS];
+    DPL::WaitableEvent waitable[MAX_THREADS];
+
+    const int array[64] = { 0, 1, 2 };
+
+    // Create and wait for notification. Make sure that the thread/controller 0
+    // is created first
+    LogInfo("Creating controllers");
+    for (size_t i = 0; i < MAX_THREADS; ++i) {
+        controller[i] = new ShmController4(&waitable[i]);
+        Wait(waitable[i]);
+    }
+
+    // singleton will be created by thread/controller 0 by now
+    MTSharedObjectPtr singleton = SharedObjectSingleton::Instance();
+
+    for (size_t repeats = 0; repeats < SINGLETON_TEST_REPEATS; ++repeats) {
+        LogInfo("%%%%%%%%%%%%%%%%%%%%%");
+        LogInfo("Iteration " << repeats + 1 << " of " << SINGLETON_TEST_REPEATS);
+        singleton->Clear();
+
+        // add listeners
+        LogInfo("Adding listeners");
+        for (size_t i = 0; i < MAX_THREADS; ++i) {
+            controller[i]->PostEvent(ShmController4::ADD_LISTENERS);
+        }
+        // wait for listeners
+        MultipleWait(waitable);
+
+        RUNNER_ASSERT((singleton->GetProperty<0, int>()) == 0);
+        RUNNER_ASSERT((singleton->GetProperty<1, int>()) == 0);
+        RUNNER_ASSERT((singleton->GetProperty<2, char>()) == 0);
+
+        int checkArray[64] = {};
+        singleton->GetProperty<3>(checkArray);
+        RUNNER_ASSERT(checkArray[0] == 0);
+        RUNNER_ASSERT(checkArray[1] == 0);
+        RUNNER_ASSERT(checkArray[2] == 0);
+
+        // change
+        LogInfo("Setting property 0");
+        sho->SetProperty<0>(1);
+        // wait for confirmations
+        MultipleWait(waitable);
+
+        // change
+        LogInfo("Setting property 1");
+        sho->SetProperty<1>(11);
+        // wait for confirmations
+        MultipleWait(waitable);
+
+        // change
+        LogInfo("Setting property 2");
+        sho->SetProperty<2>('a');
+        // wait for confirmations
+        MultipleWait(waitable);
+
+        // change
+        LogInfo("Setting property 3");
+        sho->SetProperty<3>(array);
+        // wait for confirmations
+        MultipleWait(waitable);
+
+        // remove listeners
+        LogInfo("Removing listeners");
+        for (size_t i = 0; i < MAX_THREADS; ++i) {
+            controller[i]->PostEvent(ShmController4::REMOVE_LISTENERS);
+        }
+        // wait for listeners
+        MultipleWait(waitable);
+
+        // check if listeners array is empty
+        LogInfo("Checking listeners");
+        for (size_t i = 0; i < MAX_THREADS; ++i) {
+            LISTENER_ASSERT(0);
+            LISTENER_ASSERT(1);
+            LISTENER_ASSERT(2);
+            LISTENER_ASSERT(3);
+        }
+
+        RUNNER_ASSERT((singleton->GetProperty<0, int>()) == 1);
+        RUNNER_ASSERT((singleton->GetProperty<1, int>()) == 11);
+        RUNNER_ASSERT((singleton->GetProperty<2, char>()) == 'a');
+        singleton->GetProperty<3>(checkArray);
+        RUNNER_ASSERT(checkArray[0] == 0);
+        RUNNER_ASSERT(checkArray[1] == 1);
+        RUNNER_ASSERT(checkArray[2] == 2);
+    }
+
+    singleton.Reset();
+
+    // Destroy controllers and wait for confirmation. Make sure that
+    // thread/controller 0 is destroyed in the end
+    LogInfo("Destroying controllers");
+    for (int i = MAX_THREADS - 1; i >= 0; --i) {
+        controller[i]->PostEvent(DESTROY_EVENT);
+        Wait(waitable[i]);
+        if (i == 0) {
+            /*
+             * Destroy singleton before thread that created it finishes.
+             * This is to properly close all waitable handles opened by
+             * SharedObject in thread 0.
+             */
+            LogInfo("Destroying singleton");
+            controller[i]->PostEvent(ShmController4::DESTROY_SINGLETON);
+            Wait(waitable[i]);
+        }
+        delete controller[i];
+    }
+}
+
+#undef LISTENER_ASSERT
+
+/*
+ *  test preconditions & postconditions:
+ *   - no existing shared memory with given SHM_KEY
+ *   - no existing semaphore of given SEM_NAME
+ */
+RUNNER_TEST(SharedMemory_001_Preconditions) {
+    RemoveIpcs();
+}
+
+RUNNER_TEST(SharedMemory_999_Postconditions) {
+    RemoveIpcs();
+}
diff --git a/tests/dpl/unused/test_sql_connection.cpp b/tests/dpl/unused/test_sql_connection.cpp
new file mode 100644 (file)
index 0000000..4525c98
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_sql_connection.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of sql connection tests
+ */
+
+/*
+ *
+ * This test has been saved from original test_sql_connection.cpp in wrt-commons
+ * project.
+ *
+ */
+
+#include <dpl/naive_synchronization_object.h>
+
+RUNNER_TEST(SqlConnection_MassiveReadWrite_SemaphoreSynchronization)
+{
+    srand(time(NULL));
+
+    std::ostringstream dbSemaporeFileNameStream;
+    dbSemaporeFileNameStream << "dpl_tests_dbso_sem_";
+    dbSemaporeFileNameStream << rand() << ".sem";
+
+    std::string dbSemaphoreFileName = dbSemaporeFileNameStream.str();
+
+    SemaphoreSynchronizationObjectGenerator m_generator(dbSemaphoreFileName);
+    MassiveReadWriteTest(&m_generator);
+}
diff --git a/tests/dpl/unused/test_task.cpp b/tests/dpl/unused/test_task.cpp
new file mode 100644 (file)
index 0000000..995f1cb
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        test_task.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of task tests
+ */
+#include <dpl/test_runner.h>
+#include <dpl/task.h>
+#include <dpl/log.h>
+
+RUNNER_TEST_GROUP_INIT(DPL)
+
+class MySingleTask :
+    public DPL::TaskDecl<MySingleTask>
+{
+  protected:
+    void StepOne()
+    {}
+
+  public:
+    MySingleTask() :
+        DPL::TaskDecl<MySingleTask>(this)
+    {
+        AddStep(&MySingleTask::StepOne);
+    }
+};
+
+class MyMultiTask :
+    public DPL::MultiTaskDecl<MyMultiTask>
+{
+  protected:
+    typedef DPL::MultiTaskDecl<MyMultiTask> BaseType;
+
+    void StepOne()
+    {
+        LogInfo("Step one");
+    }
+
+    void StepTwo()
+    {
+        LogInfo("Step two");
+    }
+
+    void StepThree()
+    {
+        LogInfo("Step three");
+    }
+
+  public:
+    MyMultiTask() :
+        BaseType(this, 2)
+    {
+        BaseType::StepList depListStepThree;
+        depListStepThree.push_back(&MyMultiTask::StepOne);
+        depListStepThree.push_back(&MyMultiTask::StepTwo);
+        AddStep(&MyMultiTask::StepThree, depListStepThree);
+
+        BaseType::StepList depListStepTwo;
+        depListStepTwo.push_back(&MyMultiTask::StepOne);
+        AddStep(&MyMultiTask::StepTwo, depListStepTwo);
+
+        BaseType::StepList depListStepOne;
+        AddStep(&MyMultiTask::StepOne, depListStepOne);
+    }
+};
+
+RUNNER_TEST(Task_SingleTask)
+{
+    MySingleTask task;
+    while (task.NextStep()) {}
+}
+
+RUNNER_TEST(Task_MultiTask)
+{
+    MyMultiTask task;
+    while (task.NextStep()) {}
+}
diff --git a/tests/dpl/utils/CMakeLists.txt b/tests/dpl/utils/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b3ce494
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT 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        CMakeLists.txt
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+SET(TARGET_NAME "dpl-tests-utils")
+
+# Set DPL tests sources
+SET(DPL_TESTS_UTIL_SOURCES
+    ${TESTS_DPL_DIR}/utils/main.cpp
+    ${TESTS_DPL_DIR}/utils/widget_version.cpp
+    ${TESTS_DPL_DIR}/utils/bash_utils.cpp
+    ${TESTS_DPL_DIR}/utils/wrt_utility.cpp
+)
+
+#WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_NAME} ${TARGET_DPL_UTILS_EFL})
+WRT_TEST_BUILD(${TARGET_NAME} ${DPL_TESTS_UTIL_SOURCES})
+WRT_TEST_INSTALL(${TARGET_NAME})
diff --git a/tests/dpl/utils/bash_utils.cpp b/tests/dpl/utils/bash_utils.cpp
new file mode 100644 (file)
index 0000000..7dac1fc
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    bash_utils.cpp
+ * @author  Iwanek Tomasz
+ * @version 1.0
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/utils/bash_utils.h>
+#include <dpl/log/log.h>
+
+using namespace BashUtils;
+
+RUNNER_TEST_GROUP_INIT(DPL_BASH_UTILS)
+
+/*
+Name: Bash_Utils_escape_arg
+Description:tests ecaping bash special characters for command arguments
+Expected: matching string
+*/
+RUNNER_TEST(Bash_Utils_escape_arg)
+{
+    RUNNER_ASSERT_MSG(escape_arg(std::string(
+                                     "valid")) == "\"valid\"",
+                      "Valid argument failed");
+    LogDebug("\"val\\!d\"" << " " << escape_arg(std::string("val!d")));
+    RUNNER_ASSERT_MSG(escape_arg(std::string(
+                                     "val!d")) == "\"val\\!d\"",
+                      "Single escaped character in argument failed");
+    LogDebug("\"v\\$l\\$\\$\"" << " " << escape_arg(std::string("v$l$$")));
+    RUNNER_ASSERT_MSG(escape_arg(std::string(
+                                     "v$l$$")) == "\"v\\$l\\$\\$\"",
+                      "Multiple occurences of single special character in argument failed");
+    LogDebug("\"v\\`\\$\\\"\\!d\\`\"" << " " <<
+             escape_arg(std::string("v`$\"!d`")));
+    RUNNER_ASSERT_MSG(escape_arg(std::string(
+                                     "v`$\"!d`")) == "\"v\\`\\$\\\"\\!d\\`\"",
+                      "Multiple occurences of multiple special character in argument failed");
+}
diff --git a/tests/dpl/utils/main.cpp b/tests/dpl/utils/main.cpp
new file mode 100644 (file)
index 0000000..42ffe3a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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        main.cpp
+ * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version     1.0
+ * @brief       This file is the implementation file of main
+ */
+#include <dpl/test/test_runner.h>
+
+int main(int argc, char *argv[])
+{
+    return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+}
+
diff --git a/tests/dpl/utils/widget_version.cpp b/tests/dpl/utils/widget_version.cpp
new file mode 100644 (file)
index 0000000..f00c715
--- /dev/null
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    widget_version.cpp
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for test cases for engine internal tests
+ */
+#include <dpl/test/test_runner.h>
+#include <dpl/utils/widget_version.h>
+
+RUNNER_TEST_GROUP_INIT(DPL_WIDGET_VERSION)
+
+/*
+Name: WidgetVersion_M2_O0
+Description: tests correct parsing of version widget in format: [major].[minor]
+Expected: major and minor parts matches expected values
+*/
+RUNNER_TEST(WidgetVersion_M2_O0)
+{
+    DPL::String raw(L"1.2");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == true);
+    RUNNER_ASSERT(version.Major() == DPL::String(L"1"));
+    RUNNER_ASSERT(version.Minor() == DPL::String(L"2"));
+    RUNNER_ASSERT(version.Micro() == DPL::Optional<DPL::String>());
+    RUNNER_ASSERT(version.Optional() == DPL::Optional<DPL::String>());
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M2_O0_nonwac_1
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M2_O0_nonwac_1)
+{
+    DPL::String raw(L"a1.2");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M2_O0_nonwac_2
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M2_O0_nonwac_2)
+{
+    DPL::String raw(L"1.2a");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M2_O0_nonwac_3
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M2_O0_nonwac_3)
+{
+    DPL::String raw(L"aaa1.2bbb");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M2_O0_nonwac_4
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M2_O0_nonwac_4)
+{
+    DPL::String raw(L"1a.a2");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M2_O0_long
+Description: tests correct parsing of version widget in format: [major].[minor]
+ for huge number
+Expected: major and minor parts matches expected values
+*/
+RUNNER_TEST(WidgetVersion_M2_O0_long)
+{
+    DPL::String raw(
+        L"123456789012345678901234567890.98765432109876543210987654321");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == true);
+    RUNNER_ASSERT(version.Major() ==
+                  DPL::String(L"123456789012345678901234567890"));
+    RUNNER_ASSERT(version.Minor() ==
+                  DPL::String(L"98765432109876543210987654321"));
+    RUNNER_ASSERT(version.Micro() == DPL::Optional<DPL::String>());
+    RUNNER_ASSERT(version.Optional() == DPL::Optional<DPL::String>());
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O0
+Description: tests correct wac version number
+Expected: major and minor and micro parts matches expected values.
+ Version should be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O0)
+{
+    DPL::String raw(L"1.2.3");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == true);
+    RUNNER_ASSERT(version.Major() == DPL::String(L"1"));
+    RUNNER_ASSERT(version.Minor() == DPL::String(L"2"));
+    RUNNER_ASSERT(version.Micro() == DPL::Optional<DPL::String>(L"3"));
+    RUNNER_ASSERT(version.Optional() == DPL::Optional<DPL::String>());
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O0_nonwac_1
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O0_nonwac_1)
+{
+    DPL::String raw(L"a1a.2.3");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O0_nonwac_2
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O0_nonwac_2)
+{
+    DPL::String raw(L"1.b2.3");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O0_nonwac_3
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O0_nonwac_3)
+{
+    DPL::String raw(L"1.2.3c");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O0_nonwac_4
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O0_nonwac_4)
+{
+    DPL::String raw(L"1.2.3a");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O1_1
+Description: tests correct wac version number with optional part
+Expected: major and minor and micro and optional parts matches expected values.
+ Version should be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O1_1)
+{
+    DPL::String raw(L"1.2.3 test111");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == true);
+    RUNNER_ASSERT(version.Major() == DPL::String(L"1"));
+    RUNNER_ASSERT(version.Minor() == DPL::String(L"2"));
+    RUNNER_ASSERT(version.Micro() == DPL::Optional<DPL::String>(L"3"));
+    RUNNER_ASSERT(version.Optional() == DPL::Optional<DPL::String>(L"test111"));
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O1_1
+Description: tests correct wac version number with numeric optional part
+Expected: major and minor and micro and optional parts matches expected values.
+ Version should be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O1_2)
+{
+    DPL::String raw(L"1.2.3 111");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == true);
+    RUNNER_ASSERT(version.Major() == DPL::String(L"1"));
+    RUNNER_ASSERT(version.Minor() == DPL::String(L"2"));
+    RUNNER_ASSERT(version.Micro() == DPL::Optional<DPL::String>(L"3"));
+    RUNNER_ASSERT(version.Optional() == DPL::Optional<DPL::String>(L"111"));
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M3_O1_3
+Description: tests if version is recognized as wac version number
+ when trailer spaces exists
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M3_O1_3)
+{
+    DPL::String raw(L"1.2.3 ");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_M2_O1_1
+Description: tests if version is recognized as wac version number
+ when optional part
+Expected: version should be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_M2_O1_1)
+{
+    DPL::String raw(L"1.2 t");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == true);
+    RUNNER_ASSERT(version.Major() == DPL::String(L"1"));
+    RUNNER_ASSERT(version.Minor() == DPL::String(L"2"));
+    RUNNER_ASSERT(version.Micro() == DPL::Optional<DPL::String>());
+    RUNNER_ASSERT(version.Optional() == DPL::Optional<DPL::String>(L"t"));
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Strange_0
+Description: tests if version is recognized as wac version number
+Expected: version should be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_Strange_0)
+{
+    DPL::String raw(L"1");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Strange_1
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_Strange_1)
+{
+    DPL::String raw(L".1");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Strange_2
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_Strange_2)
+{
+    DPL::String raw(L"..1");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Strange_3
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_Strange_3)
+{
+    DPL::String raw(L"...1");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Strange_4
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_Strange_4)
+{
+    DPL::String raw(L"qwerty");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Strange_5
+Description: tests if version is recognized as wac version number
+Expected: version should not be recognized as wac compatible
+*/
+RUNNER_TEST(WidgetVersion_Strange_5)
+{
+    DPL::String raw(L"!@#$%^&*()_+   ^&%^*&%$^*&%*()&   JHKJLHKJLH   685685687");
+    WidgetVersion version(raw);
+
+    RUNNER_ASSERT(version.IsWac() == false);
+    RUNNER_ASSERT(version.Raw() == raw);
+}
+
+/*
+Name: WidgetVersion_Compare_0
+Description: tests version comparision in format [major].[minor]
+Expected: compare should work as expected
+*/
+RUNNER_TEST(WidgetVersion_Compare_0)
+{
+    RUNNER_ASSERT(WidgetVersion(L"1.1") < WidgetVersion(L"1.2"));
+}
+
+/*
+Name: WidgetVersion_Compare_1
+Description: tests version comparision in format [major].[minor]
+Expected: compare should work as expected
+*/
+RUNNER_TEST(WidgetVersion_Compare_1)
+{
+    RUNNER_ASSERT(WidgetVersion(L"01.001") < WidgetVersion(L"0001.002"));
+}
+
+/*
+Name: WidgetVersion_Compare_2
+Description: tests version equality in format [major].[minor]
+Expected: versions should be equal
+*/
+RUNNER_TEST(WidgetVersion_Compare_2)
+{
+    RUNNER_ASSERT(WidgetVersion(L"0.1") == WidgetVersion(L"00.1"));
+}
+
+/*
+Name: WidgetVersion_Compare_3
+Description: tests version comparision in format [major].[minor] [optional]
+Expected: compare should work as expected
+*/
+RUNNER_TEST(WidgetVersion_Compare_3)
+{
+    RUNNER_ASSERT(WidgetVersion(L"1.00000000000000") >=
+                  WidgetVersion(L"1.0 test"));
+}
+
+/*
+Name: WidgetVersion_Compare_4
+Description: tests version comparision for huge numbers
+Expected: compare should work as expected
+*/
+RUNNER_TEST(WidgetVersion_Compare_4)
+{
+    RUNNER_ASSERT(WidgetVersion(
+                      L"19647963733338932479072098437089778943732432.00000000000000004324324324324321")
+                  > WidgetVersion(L"4324324324324324324321.000432"));
+}
+
+/*
+Name: WidgetVersion_Compare_5
+Description: tests equality in format [major].[minor]
+Expected: versions should be equal
+*/
+RUNNER_TEST(WidgetVersion_Compare_5)
+{
+    RUNNER_ASSERT(WidgetVersion(L"12345.1") == WidgetVersion(L"12345.1"));
+}
+
+/*
+Name: WidgetVersion_Compare_6
+Description: tests version equality in format [major].[minor]
+Expected: versions should not be equal
+*/
+RUNNER_TEST(WidgetVersion_Compare_6)
+{
+    RUNNER_ASSERT(WidgetVersion(L"1.1") != WidgetVersion(L"1.11"));
+}
+
+/*
+Name: WidgetVersion_Compare_7
+Description: tests version equality in format [major].[minor] [optional]
+Expected: versions should be equal, optional part should not be taken into account
+*/
+RUNNER_TEST(WidgetVersion_Compare_7)
+{
+    RUNNER_ASSERT(WidgetVersion(L"000123000.0 notatest") ==
+                  WidgetVersion(L"00123000.0 testtesttest"));
+}
diff --git a/tests/dpl/utils/wrt_utility.cpp b/tests/dpl/utils/wrt_utility.cpp
new file mode 100644 (file)
index 0000000..eb78ed6
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT 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    wrt_utility.cpp
+ * @author  Janusz Majnert (j.majnert@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for test cases for wrt_utility functions
+ */
+#include <string>
+#include <fstream>
+#include <errno.h>
+#include <pwd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <dpl/test/test_runner.h>
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/log/log.h>
+
+RUNNER_TEST_GROUP_INIT(DPL_WRT_UTILITY)
+
+/*
+Name: wrt_utility_WrtUtilJoinPaths
+Description: join paths test
+Expected: correctly used separator
+*/
+RUNNER_TEST(wrt_utility_WrtUtilJoinPaths)
+{
+    std::string result;
+
+    WrtUtilJoinPaths(result, "a/b/c/", "e/f/g.asd");
+    RUNNER_ASSERT(result == "a/b/c/e/f/g.asd");
+
+    WrtUtilJoinPaths(result, "/a/b/c", "/e/f/g/");
+    RUNNER_ASSERT(result == "/a/b/c/e/f/g/");
+
+    WrtUtilJoinPaths(result, "/a/b/c/", "/e/f/g/");
+    RUNNER_ASSERT(result == "/a/b/c/e/f/g/");
+
+    WrtUtilJoinPaths(result, "/a/b/c", "e/f/g/");
+    RUNNER_ASSERT(result == "/a/b/c/e/f/g/");
+}
+
+/**
+ * Create recursive path with specified permissions.
+ * Check if folders exist.
+ * Check if permissions are set.
+ */
+RUNNER_TEST(wrt_utility_WrtUtilMakeDir)
+{
+    struct stat st;
+    //First delete the dir if it exists
+    WrtUtilRemove("/tmp/test");
+    WrtUtilMakeDir("/tmp/test/1/2/3/4/5/6/7/8/9", 0755);
+    if (stat("/tmp/test/1/2/3/4/5/6/7/8/9", &st) == 0) {
+        RUNNER_ASSERT_MSG(st.st_mode & S_IRWXU,
+                          "read, write, execute/search by owner");
+        RUNNER_ASSERT_MSG(st.st_mode & S_IXGRP,
+                          "execute/search permission, group");
+        RUNNER_ASSERT_MSG(st.st_mode & S_IRGRP, "read permission, group");
+        RUNNER_ASSERT_MSG(!(st.st_mode & S_IWGRP),
+                          "NO write permission, group ");
+        RUNNER_ASSERT_MSG(st.st_mode & S_IXOTH,
+                          "execute/search permission, others");
+        RUNNER_ASSERT_MSG(st.st_mode & S_IROTH, "read permission, others");
+        RUNNER_ASSERT_MSG(!(st.st_mode & S_IWOTH),
+                          "NO write permission, others ");
+    } else {
+        RUNNER_ASSERT_MSG(false, "Cannot stat folder");
+    }
+}
+
+/**
+ * Create directory without permission to write.
+ */
+RUNNER_TEST(wrt_utility_WrtUtilMakeDir_PermissionError)
+{
+    if (0 == getuid()) {
+        //Change UID to execute the test correctly
+        errno = 0;
+        struct passwd *p = getpwnam("app");
+        if (p == NULL) {
+            int error = errno;
+            RUNNER_ASSERT_MSG(false, "Getting app user UID failed: "
+                              << (error ==
+                                  0 ? "No error detected" : strerror(error)));
+        }
+        if (setuid(p->pw_uid) != 0) {
+            int error = errno;
+            RUNNER_ASSERT_MSG(false, "Changing to app user's UID failed: "
+                              << (error ==
+                                  0 ? "No error detected" : strerror(error)));
+        }
+    }
+    RUNNER_ASSERT_MSG(WrtUtilMakeDir("/tmp/test2/1",
+                                     0055) == false,
+                      "Creating directory '1' in /temp/test2/ should have failed");
+    //Going back to root UID
+    if (setuid(0) != 0) {
+        int error = errno;
+        LogWarning("Changing back to root UID failed: "
+                   << (error == 0 ? "No error detected" : strerror(error)));
+    }
+}
+
+/**
+ * Create directory with file inside.
+ * Check if file was removed with directory.
+ */
+RUNNER_TEST(wrt_utility_WrtUtilRemoveDir) {
+    RUNNER_ASSERT_MSG(WrtUtilMakeDir("/tmp/test3/", 0755) == true,
+                      "Could not set up directory for test");
+
+    std::ofstream file;
+    file.open("/tmp/test3/example.txt");
+    file.close();
+    struct stat tmp;
+    RUNNER_ASSERT_MSG(stat("/tmp/test3/example.txt", &tmp) == 0,
+                      "Couldn't create the test file");
+
+    WrtUtilRemove("/tmp/test3");
+    if (stat("/tmp/test3", &tmp) != 0) {
+        int error = errno;
+        RUNNER_ASSERT(error == ENOENT);
+        return;
+    }
+    RUNNER_ASSERT(false);
+}
+
+/**
+ * Try to remove not existing folder.
+ */
+RUNNER_TEST(wrt_utility_WrtUtilRemoveDir_NoDirError)
+{
+    //First making sure the test dir doesn't exist
+    WrtUtilRemove("/tmp/NOT_EXISTING");
+
+    RUNNER_ASSERT_MSG(WrtUtilRemove("/tmp/NOT_EXISTING") == false,
+                      "Removing non existing directory returned success");
+}
+
+/*
+Name: wrt_utility_WrtUtilFileExists
+Description: tests file existence
+Expected: existing file should be reported as existing
+*/
+RUNNER_TEST(wrt_utility_WrtUtilFileExists)
+{
+    std::ofstream file;
+    file.open("/tmp/test_file1");
+    file.close();
+    RUNNER_ASSERT(WrtUtilFileExists("/tmp/test_file1"));
+
+    WrtUtilRemove("/tmp/test_file1");
+    RUNNER_ASSERT(WrtUtilFileExists("/tmp/test_file1") == false);
+}
+
+/*
+Name: wrt_utility_WrtUtilDirExists
+Description: tests directory existence
+Expected: existing directory should be reported as existing
+*/
+RUNNER_TEST(wrt_utility_WrtUtilDirExists)
+{
+    RUNNER_ASSERT(WrtUtilDirExists("/tmp"));
+    RUNNER_ASSERT(WrtUtilDirExists("/UNAVAILABLE_DIR") == false);
+}
diff --git a/uncrustify.cfg b/uncrustify.cfg
new file mode 100644 (file)
index 0000000..2bf1d96
--- /dev/null
@@ -0,0 +1,170 @@
+indent_align_string=true\r
+indent_braces=false\r
+indent_braces_no_func=false\r
+indent_brace_parent=false\r
+indent_namespace=false\r
+indent_extern=false\r
+indent_class=true\r
+indent_class_colon=false\r
+indent_else_if=false\r
+indent_func_call_param=false\r
+indent_func_def_param=false\r
+indent_func_proto_param=false\r
+indent_func_class_param=false\r
+indent_func_ctor_var_param=false\r
+indent_template_param=false\r
+indent_func_param_double=false\r
+indent_relative_single_line_comments=false\r
+indent_col1_comment=true\r
+indent_access_spec_body=false\r
+indent_paren_nl=false\r
+indent_comma_paren=false\r
+indent_bool_paren=false\r
+indent_square_nl=false\r
+indent_preserve_sql=false\r
+indent_align_assign=false\r
+sp_balance_nested_parens=false\r
+align_keep_tabs=false\r
+align_with_tabs=false\r
+align_on_tabstop=false\r
+align_number_left=false\r
+align_func_params=false\r
+align_same_func_call_params=false\r
+align_var_def_colon=false\r
+align_var_def_attribute=false\r
+align_var_def_inline=false\r
+align_right_cmt_mix=false\r
+align_on_operator=false\r
+align_mix_var_proto=false\r
+align_single_line_func=false\r
+align_single_line_brace=false\r
+align_nl_cont=false\r
+align_left_shift=true\r
+nl_collapse_empty_body=true\r
+nl_assign_leave_one_liners=false\r
+nl_class_leave_one_liners=false\r
+nl_enum_leave_one_liners=false\r
+nl_getset_leave_one_liners=false\r
+nl_func_leave_one_liners=false\r
+nl_if_leave_one_liners=false\r
+nl_multi_line_cond=true\r
+nl_multi_line_define=false\r
+nl_before_case=false\r
+nl_after_case=false\r
+nl_after_return=false\r
+nl_after_semicolon=true\r
+nl_after_brace_open=false\r
+nl_after_brace_open_cmt=false\r
+nl_after_vbrace_open=false\r
+nl_after_brace_close=false\r
+nl_define_macro=false\r
+nl_squeeze_ifdef=false\r
+nl_ds_struct_enum_cmt=false\r
+nl_ds_struct_enum_close_brace=false\r
+nl_create_if_one_liner=false\r
+nl_create_for_one_liner=false\r
+nl_create_while_one_liner=false\r
+ls_for_split_full=true\r
+ls_func_split_full=true\r
+nl_after_multiline_comment=false\r
+eat_blanks_after_open_brace=true\r
+eat_blanks_before_close_brace=true\r
+mod_pawn_semicolon=false\r
+mod_full_paren_if_bool=false\r
+mod_remove_extra_semicolon=true\r
+mod_sort_import=false\r
+mod_sort_using=false\r
+mod_sort_include=false\r
+mod_move_case_break=false\r
+mod_remove_empty_return=false\r
+cmt_indent_multi=true\r
+cmt_c_group=false\r
+cmt_c_nl_start=false\r
+cmt_c_nl_end=false\r
+cmt_cpp_group=false\r
+cmt_cpp_nl_start=false\r
+cmt_cpp_nl_end=false\r
+cmt_cpp_to_c=false\r
+cmt_star_cont=true\r
+cmt_multi_check_last=true\r
+cmt_insert_before_preproc=false\r
+pp_indent_at_level=false\r
+pp_region_indent_code=false\r
+pp_if_indent_code=false\r
+pp_define_at_level=false\r
+indent_columns=4\r
+indent_member=4\r
+indent_access_spec=-2\r
+code_width=80\r
+nl_max=2\r
+nl_before_access_spec=2\r
+cmt_width=80\r
+indent_with_tabs=0\r
+sp_arith=force\r
+sp_assign=force\r
+sp_enum_assign=force\r
+sp_pp_concat=remove\r
+sp_pp_stringify=remove\r
+sp_bool=force\r
+sp_compare=force\r
+sp_paren_brace=force\r
+sp_angle_paren=remove\r
+sp_before_sparen=force\r
+sp_inside_sparen=remove\r
+sp_after_sparen=force\r
+sp_sparen_brace=force\r
+sp_before_semi=remove\r
+sp_after_semi_for_empty=remove\r
+sp_before_square=remove\r
+sp_before_squares=remove\r
+sp_inside_square=remove\r
+sp_after_comma=force\r
+sp_before_comma=remove\r
+sp_after_class_colon=force\r
+sp_before_class_colon=force\r
+sp_before_case_colon=remove\r
+sp_inside_braces=add\r
+sp_inside_fparens=remove\r
+sp_inside_fparen=remove\r
+sp_func_call_paren=remove\r
+sp_func_class_paren=remove\r
+sp_else_brace=force\r
+sp_brace_else=force\r
+sp_catch_brace=force\r
+sp_brace_catch=force\r
+sp_try_brace=force\r
+sp_before_dc=remove\r
+sp_after_dc=remove\r
+sp_not=remove\r
+sp_inv=remove\r
+sp_addr=remove\r
+sp_member=remove\r
+sp_deref=remove\r
+sp_sign=remove\r
+sp_incdec=remove\r
+sp_cond_colon=force\r
+sp_cond_question=force\r
+sp_case_label=force\r
+nl_assign_brace=remove\r
+nl_if_brace=remove\r
+nl_brace_else=remove\r
+nl_elseif_brace=remove\r
+nl_else_brace=remove\r
+nl_else_if=remove\r
+nl_try_brace=remove\r
+nl_for_brace=remove\r
+nl_catch_brace=remove\r
+nl_brace_catch=remove\r
+nl_while_brace=remove\r
+nl_do_brace=remove\r
+nl_brace_while=remove\r
+nl_switch_brace=remove\r
+nl_namespace_brace=remove\r
+nl_class_brace=force\r
+nl_fdef_brace=force\r
+pos_class_comma=trail\r
+pos_class_colon=trail\r
+mod_full_brace_do=add\r
+mod_full_brace_for=add\r
+mod_full_brace_if=add\r
+mod_full_brace_while=add\r
diff --git a/uncrustify.sh b/uncrustify.sh
new file mode 100755 (executable)
index 0000000..49ad3cf
--- /dev/null
@@ -0,0 +1 @@
+uncrustify -c uncrustify.cfg --no-backup `find . -regex "\(.*\.cpp\|.*\.h\|.*\.c\|.*\.cc\)" | grep -v "orm.h\|orm_generator.h\|3rdparty\|examples"`
diff --git a/wrt-commons b/wrt-commons
new file mode 100644 (file)
index 0000000..12a4281
--- /dev/null
@@ -0,0 +1,290 @@
+wrt-commons:
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 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
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+3rdparty/fastdelegate :
+License
+
+The source code attached to this article is released into the public domain.
+You may use it for any purpose. Frankly, writing the article was about ten
+times as much work as writing the code. Of course, if you create great software
+using the code, I would be interested to hear about it. And submissions are always welcome.
+
+
+3rdparty/minizip :
+MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
+
+Introduction
+---------------------
+MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html )
+
+When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0.
+All possible work was done for compatibility.
+
+
+Background
+---------------------
+When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 
+support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ )
+
+That was used as a starting point. And after that ZIP64 support was added to zip.c
+some refactoring and code cleanup was also done.
+
+
+Changed from MiniZip 1.0 to MiniZip 1.1
+---------------------------------------
+* Added ZIP64 support for unzip ( by Even Rouault )
+* Added ZIP64 support for zip ( by Mathias Svensson )
+* Reverted some changed that Even Rouault did.
+* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
+* Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
+* Added BZIP Compress method for zip
+* Did some refactoring and code cleanup
+
+
+Credits
+
+ Gilles Vollant    - Original MiniZip author
+ Even Rouault      - ZIP64 unzip Support
+ Daniel Borca      - BZip Compression method support in unzip
+ Mathias Svensson  - ZIP64 zip support
+ Mathias Svensson  - BZip Compression method support in zip
+
+ Resources
+
+ ZipLayout   http://result42.com/projects/ZipFileLayout
+             Command line tool for Windows that shows the layout and information of the headers in a zip archive.
+             Used when debugging and validating the creation of zip files using MiniZip64
+
+
+ ZIP App Note  http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+               Zip File specification
+
+
+Notes.
+ * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
+
+License
+----------------------------------------------------------
+   Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+----------------------------------------------------------
+
diff --git a/wrt-commons.manifest b/wrt-commons.manifest
new file mode 100644 (file)
index 0000000..fb4bfc3
--- /dev/null
@@ -0,0 +1,13 @@
+<manifest>
+  <define>
+    <domain name="wrt-commons"/>
+    <provide>   
+        <label name="wrt-commons::db_wrt"/>
+        <label name="wrt-commons::db_wrt_autosave"/>
+        <label name="wrt-commons::db_wrt_custom_handler"/>
+    </provide>
+  </define>
+  <request>
+    <domain name="_"/>
+  </request>
+</manifest>