diff options
author | <philippe colliot> | 2016-05-02 11:56:51 +0200 |
---|---|---|
committer | <philippe colliot> | 2016-05-02 11:56:51 +0200 |
commit | 368cc50e9579d7ce7751c1a24c48072b9027592f (patch) | |
tree | 20ad67d0e11c03740a732120e125dd375f8e6dcd /src/navigation | |
parent | 6fac401ce307b2b0f07cdedc881131a36418bc72 (diff) | |
download | poi-service-368cc50e9579d7ce7751c1a24c48072b9027592f.tar.gz |
Fix a bug into the configuration API
Diffstat (limited to 'src/navigation')
8 files changed, 350 insertions, 287 deletions
diff --git a/src/navigation/README b/src/navigation/README index 78a2fd1..e125fe3 100644 --- a/src/navigation/README +++ b/src/navigation/README @@ -134,5 +134,21 @@ Due to a different way to manage the build, some specific settings are required: cmake -DYOCTO_BUILD=ON ../ +=============================== +How To for Common API (experimental) +=============================== +You need to pass as parameter to the cmake the link to your patched dbus library (required by CommonAPI) + +cd build +cmake -DWITH_PLUGIN_MIGRATION=ON -DWITH_FRANCA_DBUS_INTERFACE=ON -DDBUS_LIB_PATH=<DBus patched lib Path> -DCOMMONAPI_DBUS_TOOL_DIR=<common-api-dbus-tools folder> -DCOMMONAPI_TOOL_DIR=<common-api-tools folder> -DWITH_DEBUG=ON ../ +make +cd .. + +Copy the configuration file ./resource/commonapi-dbus.ini in a directory of your choice + +Set the environment variable COMMONAPI_DBUS_DEFAULT_CONFIG before starting the poi-manager-server. + +Example: +export COMMONAPI_DBUS_DEFAULT_CONFIG=<your path>/commonapi-dbus.ini diff --git a/src/navigation/map-viewer/configuration-plugin/genivi_mapviewer_configuration.cxx b/src/navigation/map-viewer/configuration-plugin/genivi_mapviewer_configuration.cxx index d0f7d5b..b3c74a8 100644 --- a/src/navigation/map-viewer/configuration-plugin/genivi_mapviewer_configuration.cxx +++ b/src/navigation/map-viewer/configuration-plugin/genivi_mapviewer_configuration.cxx @@ -119,8 +119,7 @@ country_2_to_3(const char *in) return map_2_to_3(country_map, sizeof(country_map)/sizeof(country_map[0]), in); } - -std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > unitsOfMeasurement; +std::map< int32_t, int32_t > m_unitsOfMeasurement; class Configuration : public org::genivi::mapviewer::Configuration_adaptor, @@ -144,31 +143,31 @@ class Configuration return ret; } - void - SetUnitsOfMeasurement(const std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant >& unitsOfMeasurementList) - { - unitsOfMeasurement=unitsOfMeasurementList; - std::vector< DBusCommonAPIEnumeration > changed; - changed.push_back(GENIVI_MAPVIEWER_UNITS_OF_MEASUREMENT); - ConfigurationChanged(changed); - } + void + SetUnitsOfMeasurement(const std::map< int32_t, int32_t >& unitsOfMeasurement) + { + m_unitsOfMeasurement=unitsOfMeasurement; + std::vector< int32_t > changed; + changed.push_back(GENIVI_MAPVIEWER_UNITS_OF_MEASUREMENT); + ConfigurationChanged(changed); + } - std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > - GetUnitsOfMeasurement() - { - return unitsOfMeasurement; - } + std::map< int32_t, int32_t > + GetUnitsOfMeasurement() + { + return m_unitsOfMeasurement; + } - std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > + std::map< int32_t, std::vector< int32_t > > GetSupportedUnitsOfMeasurement() { - std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > ret; - std::vector< uint16_t > length; + std::map< int32_t, std::vector< int32_t > > ret; + std::vector< int32_t > length; length.push_back(GENIVI_MAPVIEWER_MILE); length.push_back(GENIVI_MAPVIEWER_METER); - ret[GENIVI_MAPVIEWER_LENGTH]=variant_array_uint16(length); + ret[GENIVI_MAPVIEWER_LENGTH]=length; return ret; - } + } void SetTimeFormat(const DBusCommonAPIEnumeration& timeFormat) @@ -274,6 +273,6 @@ plugin_init(void) conn = new DBus::Connection(DBus::Connection::SessionBus()); conn->setup(&dispatcher); conn->request_name("org.genivi.mapviewer.Configuration"); - unitsOfMeasurement[GENIVI_MAPVIEWER_LENGTH]._2=variant_enumeration(GENIVI_MAPVIEWER_KM); + m_unitsOfMeasurement[GENIVI_MAPVIEWER_LENGTH]=GENIVI_MAPVIEWER_KM; server=new Configuration(*conn); } diff --git a/src/navigation/navigation-core/configuration-plugin/genivi_navigationcore_configuration.cxx b/src/navigation/navigation-core/configuration-plugin/genivi_navigationcore_configuration.cxx index 45b1de1..b2a665b 100644 --- a/src/navigation/navigation-core/configuration-plugin/genivi_navigationcore_configuration.cxx +++ b/src/navigation/navigation-core/configuration-plugin/genivi_navigationcore_configuration.cxx @@ -121,7 +121,7 @@ country_2_to_3(const char *in) } -std::map< int32_t, DBusCommonAPIVariant > unitsOfMeasurement; +std::map< int32_t, int32_t > m_unitsOfMeasurement; class Configuration : public org::genivi::navigationcore::Configuration_adaptor, @@ -146,28 +146,28 @@ class Configuration } void - SetUnitsOfMeasurement(const std::map< int32_t, DBusCommonAPIVariant >& unitsOfMeasurementList) + SetUnitsOfMeasurement(const std::map< int32_t, int32_t >& unitsOfMeasurement) { - unitsOfMeasurement=unitsOfMeasurementList; + m_unitsOfMeasurement=unitsOfMeasurement; std::vector< int32_t > changed; changed.push_back(GENIVI_NAVIGATIONCORE_UNITS_OF_MEASUREMENT); ConfigurationChanged(changed); } - std::map< int32_t, DBusCommonAPIVariant > + std::map< int32_t, int32_t > GetUnitsOfMeasurement() { - return unitsOfMeasurement; + return m_unitsOfMeasurement; } - std::map< int32_t, DBusCommonAPIVariant > + std::map< int32_t, std::vector< int32_t > > GetSupportedUnitsOfMeasurement() { - std::map< int32_t, DBusCommonAPIVariant > ret; - std::vector< DBusCommonAPIEnumeration > length; + std::map< int32_t, std::vector< int32_t > > ret; + std::vector< int32_t > length; length.push_back(GENIVI_NAVIGATIONCORE_MILE); length.push_back(GENIVI_NAVIGATIONCORE_METER); - ret[GENIVI_NAVIGATIONCORE_LENGTH]=variant_array_enumeration(length); + ret[GENIVI_NAVIGATIONCORE_LENGTH]=length; return ret; } @@ -288,6 +288,6 @@ plugin_init(void) conn = new DBus::Connection(DBus::Connection::SessionBus()); conn->setup(&dispatcher); conn->request_name("org.genivi.navigationcore.Configuration"); - unitsOfMeasurement[GENIVI_NAVIGATIONCORE_LENGTH]._2=variant_enumeration(GENIVI_NAVIGATIONCORE_KM); + m_unitsOfMeasurement[GENIVI_NAVIGATIONCORE_LENGTH]=GENIVI_NAVIGATIONCORE_KM; server=new Configuration(*conn); } diff --git a/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt index b93497d..b059f06 100644 --- a/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt @@ -18,31 +18,43 @@ project(configuration-server-plugin) message(STATUS ${PROJECT_NAME}) +option(DBUS_LIB_PATH + "Path to the patched DBus library") + set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") set(PARENT_API navigationcore) set(ROOT_API navigation) set(API_VERSION_MAJOR 0) -set(API_VERSION_MINOR 1) -set(API_VERSION "v${API_VERSION_MAJOR}_${API_VERSION_MINOR}") +set(API_VERSION "v${API_VERSION_MAJOR}") set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") set(PRJ_SRC_GEN_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi/${ROOT_API}/${PARENT_API}) set(PRJ_SRC_GEN_NAVIGATION_TYPES_PATH ${COMMONAPI_GEN_DIR}/org/genivi/${ROOT_API}) +# DBus Path +if(DBUS_LIB_PATH) + message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH}) + set(DBUS_INCLUDE_DIRS ${DBUS_LIB_PATH}/include/dbus-1.0 ${DBUS_LIB_PATH}/lib/dbus-1.0/include) + set(DBUS_LIBDIR ${DBUS_LIB_PATH}/lib) + set(DBUS_LIBRARIES ${DBUS_LIB_PATH}/lib/libdbus-1.so) +else() + message(FATAL_ERROR "Please specify the path to your patched DBus library using -D DBUS_LIB_PATH=yourPath") +endif() + # Packages find_package(PkgConfig REQUIRED) -find_package(CommonAPI 3.1.2 REQUIRED) -find_package(CommonAPI-DBus 3.1.2 REQUIRED) +find_package(CommonAPI 3.1.5 REQUIRED) +find_package(CommonAPI-DBus 3.1.5 REQUIRED) -pkg_check_modules(DBUS "dbus-1 >= 1.4") -pkg_check_modules(COMMONAPI "CommonAPI >= 3.1") -pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1") +#pkg_check_modules(DBUS "dbus-1 >= 1.8.4") // #to be fixed, it doesn't work so the paths are set manually (see above) +pkg_check_modules(COMMONAPI "CommonAPI >= 3.1.5") +pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1.5") pkg_check_modules(GOBJECT gobject-2.0) pkg_check_modules(GLIB REQUIRED glib-2.0) # Source Files -FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") @@ -77,6 +89,5 @@ set(LIBRARIES ) # Build service -add_executable(${PROJECT_NAME} ${PRJ_SRCS}) -target_link_libraries(${PROJECT_NAME} ${LIBRARIES}) +module_add_library(genivi_navigationcore_configuration_server genivi_navigationcore_configuration.cxx ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-configuration_adaptor.h) diff --git a/src/navigation/navigation-core/configuration-server-plugin/configuration-server-plugin-stub.cpp b/src/navigation/navigation-core/configuration-server-plugin/configuration-server-plugin-stub.cpp deleted file mode 100644 index d9e15be..0000000 --- a/src/navigation/navigation-core/configuration-server-plugin/configuration-server-plugin-stub.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @licence app begin@ -* SPDX-License-Identifier: MPL-2.0 -* -* \copyright Copyright (C) 2013-2015, PCA Peugeot Citroen -* -* \file configuration-server-plugin-stub.cpp -* -* \brief This file is part of the poi proof of concept. -* -* \author Philippe Colliot <philippe.colliot@mpsa.com> -* -* \version 0.1 -* -* This Source Code Form is subject to the terms of the -* Mozilla Public License (MPL), v. 2.0. -* If a copy of the MPL was not distributed with this file, -* You can obtain one at http://mozilla.org/MPL/2.0/. -* -* For further information see http://www.genivi.org/. -* -* List of changes: -* <date>, <name>, <description of change> -* -* @licence end@ -*/ -#include "configuration-server-plugin-stub.h" - -NavigationCoreConfigurationServerStub::NavigationCoreConfigurationServerStub() -{ - -} - -NavigationCoreConfigurationServerStub::~NavigationCoreConfigurationServerStub() -{ - -} - -void NavigationCoreConfigurationServerStub::getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::setLocale(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _languageCode, std::string _countryCode, std::string _scriptCode, setLocaleReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationCoreConfiguration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationCoreConfiguration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply) -{ - -} - -void NavigationCoreConfigurationServerStub::getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply) -{ - -} - diff --git a/src/navigation/navigation-core/configuration-server-plugin/configuration-server-plugin-stub.h b/src/navigation/navigation-core/configuration-server-plugin/configuration-server-plugin-stub.h deleted file mode 100644 index 383e658..0000000 --- a/src/navigation/navigation-core/configuration-server-plugin/configuration-server-plugin-stub.h +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @licence app begin@ -* SPDX-License-Identifier: MPL-2.0 -* -* \copyright Copyright (C) 2013-2015, PCA Peugeot Citroen -* -* \file configuration-server-plugin.h -* -* \brief This file is part of the poi proof of concept. -* -* \author Philippe Colliot <philippe.colliot@mpsa.com> -* -* \version 0.1 -* -* This Source Code Form is subject to the terms of the -* Mozilla Public License (MPL), v. 2.0. -* If a copy of the MPL was not distributed with this file, -* You can obtain one at http://mozilla.org/MPL/2.0/. -* -* For further information see http://www.genivi.org/. -* -* List of changes: -* <date>, <name>, <description of change> -* -* @licence end@ -*/ -#ifndef CONFIGURATIONSERVERSTUBIMPL_H_ -#define CONFIGURATIONSERVERSTUBIMPL_H_ - -#include <CommonAPI/CommonAPI.hpp> - -#include <org/genivi/CommonTypes.hpp> -#include <org/genivi/navigation/NavigationTypes.hpp> -#include <org/genivi/navigation/navigationcore/NavigationCoreTypes.hpp> -#include <v0_1/org/genivi/navigation/navigationcore/NavigationCoreConfigurationStubDefault.hpp> - -using namespace std; -using namespace v0_1::org::genivi::navigation::navigationcore; -using namespace org::genivi::navigation; -using namespace org::genivi; - - -class NavigationCoreConfigurationServerStub: public NavigationCoreConfigurationStubDefault { - -public: - NavigationCoreConfigurationServerStub(); - ~NavigationCoreConfigurationServerStub(); - void getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply); - void setLocale(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _languageCode, std::string _countryCode, std::string _scriptCode, setLocaleReply_t _reply); - void getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply); - void getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply); - void setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply); - void getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply); - void getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply); - void setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationCoreConfiguration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply); - void getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply); - void getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply); - void setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationCoreConfiguration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply); - void getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply); - void getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply); - -private: - -}; - -#endif /* CONFIGURATIONSERVERSTUBIMPL_H_ */ diff --git a/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx new file mode 100644 index 0000000..85752e0 --- /dev/null +++ b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx @@ -0,0 +1,283 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2015, PCA Peugeot Citroen +* +* \file main.cpp +* +* \brief This file is part of the poi proof of concept. +* +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* +* \version 0.1 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), v. 2.0. +* If a copy of the MPL was not distributed with this file, +* You can obtain one at http://mozilla.org/MPL/2.0/. +* +* For further information see http://www.genivi.org/. +* +* List of changes: +* <date>, <name>, <description of change> +* +* @licence end@ +*/ +#include <stdbool.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <sys/types.h> +#include <iostream> +#include <fstream> +#include <cmath> +#include <thread> +#include <typeinfo> +#include <glib.h> + +#include "config.h" +#define USE_PLUGINS 1 +#include "debug.h" +#include "plugin.h" +#include "event.h" + +#include <CommonAPI/CommonAPI.hpp> +#include <org/genivi/CommonTypes.hpp> +#include <org/genivi/navigation/NavigationTypes.hpp> +#include <org/genivi/navigation/navigationcore/NavigationCoreTypes.hpp> +#include <v0/org/genivi/navigation/navigationcore/ConfigurationStubDefault.hpp> + +#if (!DEBUG_ENABLED) +#undef dbg +#define dbg(level,...) ; +#endif + +typedef struct { + const char *c3; + const char *c2; +} map32_t; + +static const map32_t language_map[] = { + {"deu","de"}, + {"eng","en"}, + {"fra","fr"}, + {"jpn","jp"}, +}; + +static const map32_t country_map[] = { + {"CHE","CH"}, + {"DEU","DE"}, + {"FRA","FR"}, + {"USA","US"}, + {"JPN","JP"}, +}; + +static const char * +map_3_to_2(const map32_t *map, int len, const char *in) +{ + int i; + for (i = 0 ; i < len ; i++) + if (!strcmp(map[i].c3,in)) + return map[i].c2; + return ""; +} + +static const char * +map_2_to_3(const map32_t *map, int len, const char *in) +{ + int i; + for (i = 0 ; i < len ; i++) + if (!strcmp(map[i].c2,in)) + return map[i].c3; + return ""; +} + +static const char * +language_3_to_2(const char *in) +{ + return map_3_to_2(language_map, sizeof(language_map)/sizeof(language_map[0]), in); +} + +static const char * +language_2_to_3(const char *in) +{ + return map_2_to_3(language_map, sizeof(language_map)/sizeof(language_map[0]), in); +} + +static const char * +country_3_to_2(const char *in) +{ + return map_3_to_2(country_map, sizeof(country_map)/sizeof(country_map[0]), in); +} + +static const char * +country_2_to_3(const char *in) +{ + return map_2_to_3(country_map, sizeof(country_map)/sizeof(country_map[0]), in); +} + +using namespace std; +using namespace v0::org::genivi::navigation::navigationcore; +using namespace org::genivi::navigation; +using namespace org::genivi; + +Configuration::UnitsOfMeasurementValue value; +Configuration::UnitsOfMeasurement unit = {{Configuration::UnitsOfMeasurementAttribute::LENGTH, value }}; +static std::vector<Configuration::UnitsOfMeasurement> unitsOfMeasurementList; + +NavigationTypes::Locale en_US { "eng","USA", "Latn" }; +NavigationTypes::Locale fr_FR { "fra","FRA", "Latn" }; +NavigationTypes::Locale de_DE { "deu","DEU", "Latn" }; +NavigationTypes::Locale jp_JP { "jpn","JPN", "Hrkt" }; +static std::vector< NavigationTypes::Locale> localeList; + +class NavigationCoreConfigurationServerStub: public ConfigurationStubDefault { + +public: + NavigationCoreConfigurationServerStub(); + ~NavigationCoreConfigurationServerStub(); + void getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply); + void setLocale(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _languageCode, std::string _countryCode, std::string _scriptCode, setLocaleReply_t _reply); + void getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply); + void getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply); + void setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply); + void getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply); + void getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply); + void setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply); + void getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply); + void getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply); + void setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply); + void getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply); + void getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply); + +private: + CommonTypes::Version m_version; + Configuration::UnitsOfMeasurement m_unitsOfMeasurement; + std::string m_languageCode, m_countryCode, m_scriptCode; +}; + +NavigationCoreConfigurationServerStub::NavigationCoreConfigurationServerStub() +{ + m_version.setVersionMajor(3); + m_version.setVersionMinor(0); + m_version.setVersionMicro(0); + m_version.setDate("21-01-2014"); + + localeList.push_back(en_US); + localeList.push_back(fr_FR); + localeList.push_back(de_DE); + localeList.push_back(jp_JP); + + unitsOfMeasurementList.push_back(unit); + + //default init + m_languageCode = localeList.at(0).getLanguageCode(); + m_countryCode = localeList.at(0).getCountryCode(); + m_scriptCode = localeList.at(0).getScriptCode(); + + m_unitsOfMeasurement[Configuration::UnitsOfMeasurementAttribute::LENGTH] = Configuration::UnitsOfMeasurementValue::KM; + +} + +NavigationCoreConfigurationServerStub::~NavigationCoreConfigurationServerStub() +{ + +} + +void NavigationCoreConfigurationServerStub::getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply) +{ + _reply(m_version); +} + +void NavigationCoreConfigurationServerStub::setLocale(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _languageCode, std::string _countryCode, std::string _scriptCode, setLocaleReply_t _reply) +{ + std::vector<Configuration::Settings> changedSettings; + + m_languageCode = _languageCode; + m_countryCode = _countryCode; + m_scriptCode = _scriptCode; + + changedSettings.push_back(Configuration::Settings::LOCALE); + + fireConfigurationChangedEvent(changedSettings); +} + +void NavigationCoreConfigurationServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply) +{ + _reply(m_languageCode,m_countryCode,m_scriptCode); +} + +void NavigationCoreConfigurationServerStub::getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply) +{ + +} + +void NavigationCoreConfigurationServerStub::getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply) +{ + +} + +void +plugin_init(void) +{ + event_request_system("glib","genivi_navigationcore_configuration"); + + // Common API data init + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); + + const std::string &domain = "local"; + const std::string &instance = "Configuration"; + + std::string connection = "Configuration"; + + std::shared_ptr<NavigationCoreConfigurationServerStub> myServiceConfiguration = std::make_shared<NavigationCoreConfigurationServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration, connection); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration, connection); + } +} + diff --git a/src/navigation/navigation-core/configuration-server-plugin/main.cpp b/src/navigation/navigation-core/configuration-server-plugin/main.cpp deleted file mode 100644 index 1755085..0000000 --- a/src/navigation/navigation-core/configuration-server-plugin/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @licence app begin@ -* SPDX-License-Identifier: MPL-2.0 -* -* \copyright Copyright (C) 2013-2015, PCA Peugeot Citroen -* -* \file main.cpp -* -* \brief This file is part of the poi proof of concept. -* -* \author Philippe Colliot <philippe.colliot@mpsa.com> -* -* \version 0.1 -* -* This Source Code Form is subject to the terms of the -* Mozilla Public License (MPL), v. 2.0. -* If a copy of the MPL was not distributed with this file, -* You can obtain one at http://mozilla.org/MPL/2.0/. -* -* For further information see http://www.genivi.org/. -* -* List of changes: -* <date>, <name>, <description of change> -* -* @licence end@ -*/ -#include <stdbool.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <sys/types.h> -#include <iostream> -#include <fstream> -#include <cmath> -#include <thread> -#include <typeinfo> -#include <glib.h> - -#include <CommonAPI/CommonAPI.hpp> //Defined in the Common API Runtime library -#include "configuration-server-plugin-stub.h" - -int main(int argc , char** argv ) -{ - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - - // Common API data init - std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); - - const std::string &domain = "local"; - const std::string &instance = "Configuration"; - - std::string connection = "Configuration"; - - std::shared_ptr<NavigationCoreConfigurationServerStub> myServiceConfiguration = std::make_shared<NavigationCoreConfigurationServerStub>(); - - bool successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration, connection); - while (!successfullyRegistered) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration, connection); - } - - GMainLoop * mainloop ; - - // Create a new GMainLoop with default context and initial state of "not running " - mainloop = g_main_loop_new (g_main_context_default() , FALSE ); - - // Send a feedback to the user - cout << "configuration server started" << endl; - - g_main_loop_run ( mainloop ); - - return EXIT_SUCCESS; -} - |