diff options
Diffstat (limited to 'src/poi-service')
-rw-r--r-- | src/poi-service/poi-common/poi-common-data-model.h | 9 | ||||
-rw-r--r-- | src/poi-service/poi-server/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/poi-service/poi-server/main.cpp | 181 | ||||
-rw-r--r-- | src/poi-service/poi-server/poi-server-class.h | 63 |
4 files changed, 230 insertions, 25 deletions
diff --git a/src/poi-service/poi-common/poi-common-data-model.h b/src/poi-service/poi-common/poi-common-data-model.h index 2fca49d..ce7841d 100644 --- a/src/poi-service/poi-common/poi-common-data-model.h +++ b/src/poi-service/poi-common/poi-common-data-model.h @@ -108,6 +108,15 @@ public: iter.append_uint16(value); return var; } + + DBus::Variant createVariantArrayUint16(std::vector< uint16_t > value) + { + DBus::Variant var; + DBus::MessageIter iter=var.writer(); + iter << value; + return var; + } + }; class DBus_version : DBus_dataFormatConverter // (qqqs) diff --git a/src/poi-service/poi-server/CMakeLists.txt b/src/poi-service/poi-server/CMakeLists.txt index 3956282..32759dd 100644 --- a/src/poi-service/poi-server/CMakeLists.txt +++ b/src/poi-service/poi-server/CMakeLists.txt @@ -17,6 +17,7 @@ ########################################################################### project(poi-server) cmake_minimum_required(VERSION 2.8) +set(CMAKE_XXX_FLAGS "${CMAKE_XXX_FLAGS} -std=gnu++11") message(STATUS "poi-server") @@ -41,7 +42,6 @@ include_directories(${GOBJECT_INCLUDE_DIRS}) include_directories(${DBUS_INCLUDE_DIRS}) include_directories(${DBUS_CPP_GLIB_INCLUDE_DIRS}) - link_directories( ${DBUS_CPP_LIBRARY_DIRS} ${GLIB_LIBRARY_DIRS} diff --git a/src/poi-service/poi-server/main.cpp b/src/poi-service/poi-server/main.cpp index e1605c7..a72ee9c 100644 --- a/src/poi-service/poi-server/main.cpp +++ b/src/poi-service/poi-server/main.cpp @@ -42,6 +42,8 @@ static const char* poiSearch_SERVICE_NAME = "org.genivi.poiservice.POISearch"; static const char* poiSearch_OBJECT_PATH = "/org/genivi/poiservice/POISearch"; +static const char* poiConfiguration_SERVICE_NAME = "org.genivi.poiservice.Configuration"; +static const char* poiConfiguration_OBJECT_PATH = "/org/genivi/poiservice/Configuration"; static const char* poiContentAccess_SERVICE_NAME = "org.genivi.poiservice.POIContentAccess"; static const char* poiContentAccess_OBJECT_PATH = "/org/genivi/poiservice/POIContentAccess"; static const char* contentAccessModule_OBJECT_PATH = "/org/genivi/poiservice/POIContentAccessModule"; @@ -61,6 +63,7 @@ static DBus::Glib::BusDispatcher *dispatcher; static DBus::Connection *dbusConnection; static poiSearchServer *serverPoiSearch; static poiContentAccessServer *serverpoiContentAccess; +static poiConfigurationServer *serverpoiConfiguration; static Routing *clientRouting; // class Routing @@ -116,6 +119,11 @@ contentAccessModule::~contentAccessModule() { } +void contentAccessModule::ConfigurationChanged(const std::vector< uint16_t >& changedSettings) +{ + +} + // class poiContentAccessServer poiContentAccessServer::poiContentAccessServer(DBus::Connection &connection) @@ -505,11 +513,11 @@ void poiContentAccessServer::SetRegisteredAttributeCategoryFlag(camId_t camId, c } } -void poiContentAccessServer::SetLanguage(std::string LanguageCode, std::string CountryCode) +void poiContentAccessServer::SetLocale(std::string languageCode, std::string countryCode, string scriptCode) { if (m_camId != INVALID_HANDLE) { //only one cam managed - mp_contentAccessModule->SetLanguage(LanguageCode,CountryCode); + mp_contentAccessModule->SetLocale(languageCode,countryCode, scriptCode); } } @@ -663,8 +671,6 @@ poiSearchServer::poiSearchServer(DBus::Connection &connection, const char* poiDa version.micro = 0; version.date = "19-12-2012"; m_version.set(version); - m_languageCode = "fra"; //french by default (ISO 639-2) - m_countryCode = "FRA"; //france by default (ISO 3166-1 alpha-3) m_poiSearchHandle = INVALID_HANDLE; m_poiSearchProximity = false; //by default search around the current location mp_database = new Database(poiDatabaseFileName); @@ -826,19 +832,6 @@ DBus_version::DBus_version_t poiSearchServer::GetVersion() return(m_version.getDBus()); } -void poiSearchServer::GetLanguage(std::string& languageCode, std::string& countryCode) -{ - // in fact only one language and one country available - languageCode = m_languageCode; - countryCode = m_countryCode; -} - -void poiSearchServer::SetLanguage(const std::string& languageCode, const std::string& countryCode) -{ - m_languageCode = languageCode; - m_countryCode = countryCode; -} - std::vector< ::DBus::Struct< categoryId_t, bool > > poiSearchServer::ValidateCategories(const std::vector< categoryId_t >& categories) { std::vector< ::DBus::Struct< categoryId_t, bool > > table; @@ -1003,7 +996,7 @@ handleId_t poiSearchServer::CreatePoiSearchHandle() //set the handle for the content access server mp_poiContentAccess->SetPoiSearchHandle(m_poiSearchHandle); //set the language used by the content access server - mp_poiContentAccess->SetLanguage(m_languageCode,m_countryCode); + mp_poiContentAccess->SetLocale(m_languageCode,m_countryCode, m_scriptCode); } return (m_poiSearchHandle); } @@ -1602,6 +1595,15 @@ std::vector< DBus_searchResultDetails::DBus_searchResultDetails_t > poiSearchSer // Specific methods +void poiSearchServer::SetLocale(std::string languageCode, std::string countryCode, std::string scriptCode) +{ + m_languageCode = languageCode; + m_countryCode = countryCode; + m_scriptCode = scriptCode; + + mp_poiContentAccess->SetLocale(languageCode,countryCode,scriptCode); //update poi content access data (to set the cam data) +} + void poiSearchServer::ConnectToRoutingClient(Routing *client) { mp_Routing = client; //link to the instance of routing @@ -1931,6 +1933,141 @@ uint32_t poiSearchServer::calculateOrthoDistance(const double a,const double b,c return ((uint32_t)((a*pointP.longitude - pointP.latitude + b)/sqrt(1 + a*a))); } +// class poiConfigurationServer + +// DBus methods + +poiConfigurationServer::poiConfigurationServer(DBus::Connection &connection) + : DBus::ObjectAdaptor(connection, poiConfiguration_OBJECT_PATH) +{ + //version is hard coded + DBus_version::version_t version; + version.major = 1; + version.minor = 0; + version.micro = 0; + version.date = "19-12-2012"; + m_version.set(version); + m_languageCode = "fra"; //french by default (ISO 639-2) + m_countryCode = "FRA"; //france by default (ISO 3166-1 alpha-3) + m_scriptCode = "Latn"; //Latin by default (4-letter ISO 15924 codes) + m_timeFormat = GENIVI_NAVIGATIONCORE_24H; + std::vector< uint16_t > length; + DBus_dataFormatConverter dataConverter; + length.push_back(GENIVI_NAVIGATIONCORE_METER); + m_unitsOfMeasurementList[GENIVI_NAVIGATIONCORE_LENGTH]=dataConverter.createVariantArrayUint16(length); + m_coordinatesFormat = GENIVI_NAVIGATIONCORE_DEGREES; +} + +poiConfigurationServer::~poiConfigurationServer() +{ + +} + + +DBus_version::DBus_version_t poiConfigurationServer::GetVersion() +{ + return(m_version.getDBus()); +} + +void poiConfigurationServer::SetUnitsOfMeasurement(const std::map< uint16_t, ::DBus::Variant >& unitsOfMeasurementList) +{ + m_unitsOfMeasurementList = unitsOfMeasurementList; + std::vector< uint16_t > changed; + changed.push_back(GENIVI_NAVIGATIONCORE_UNITS_OF_MEASUREMENT); + ConfigurationChanged(changed); +} + +std::map< uint16_t, ::DBus::Variant > poiConfigurationServer::GetUnitsOfMeasurement() +{ + return m_unitsOfMeasurementList; +} + +std::map< uint16_t, ::DBus::Variant > poiConfigurationServer::GetSupportedUnitsOfMeasurement() +{ + std::map< uint16_t, ::DBus::Variant > ret; + std::vector< uint16_t > length; + DBus_dataFormatConverter dataConverter; + length.push_back(GENIVI_NAVIGATIONCORE_METER); + ret[GENIVI_NAVIGATIONCORE_LENGTH]=dataConverter.createVariantArrayUint16(length); + return ret; +} + +void poiConfigurationServer::SetTimeFormat(const uint16_t& timeFormat) +{ + m_timeFormat = timeFormat; + std::vector< uint16_t > changed; + changed.push_back(GENIVI_NAVIGATIONCORE_TIME_FORMAT); + ConfigurationChanged(changed); +} + +uint16_t poiConfigurationServer::GetTimeFormat() +{ + return m_timeFormat; +} + +std::vector< uint16_t > poiConfigurationServer::GetSupportedTimeFormats() +{ + std::vector< uint16_t > ret; + ret.push_back(GENIVI_NAVIGATIONCORE_24H); + return ret; +} + +void poiConfigurationServer::SetCoordinatesFormat(const uint16_t& coordinatesFormat) +{ + m_coordinatesFormat = coordinatesFormat; + std::vector< uint16_t > changed; + changed.push_back(GENIVI_NAVIGATIONCORE_COORDINATES_FORMAT); + ConfigurationChanged(changed); +} + +uint16_t poiConfigurationServer::GetCoordinatesFormat() +{ + return m_coordinatesFormat; +} + +std::vector< uint16_t > poiConfigurationServer::GetSupportedCoordinatesFormats() +{ + std::vector< uint16_t > ret; + ret.push_back(GENIVI_NAVIGATIONCORE_DEGREES); + return ret; +} + +void poiConfigurationServer::SetLocale(const std::string& languageCode, const std::string& countryCode, const std::string& scriptCode) +{ + m_languageCode = languageCode; + m_countryCode = countryCode; + m_scriptCode = scriptCode; + std::vector< uint16_t > changed; + changed.push_back(GENIVI_NAVIGATIONCORE_LOCALE); + ConfigurationChanged(changed); + + mp_poiSearch->SetLocale(languageCode,countryCode,scriptCode); //update poi search data +} + +void poiConfigurationServer::GetLocale(std::string& languageCode, std::string& countryCode, std::string& scriptCode) +{ + languageCode = m_languageCode; + countryCode = m_countryCode; + scriptCode = m_scriptCode; +} + +std::vector< ::DBus::Struct< std::string, std::string, std::string > > poiConfigurationServer::GetSupportedLocales() +{ + std::vector< ::DBus::Struct< std::string, std::string, std::string > > ret; + ::DBus::Struct< std::string, std::string, std::string > en_US { "eng","USA", "Latn" }; + ::DBus::Struct< std::string, std::string, std::string > fr_FR { "fra","FRA", "Latn" }; + ret.push_back(en_US); + ret.push_back(fr_FR); + return ret; +} + +//specific methods + +void poiConfigurationServer::ConnectTopoiSearchServer(poiSearchServer *poiSearch) +{ + mp_poiSearch = poiSearch; //link to the instance of poi search +} + const char* program_name; //file to sink outputs @@ -2025,9 +2162,16 @@ int main(int argc , char** argv ) dbusConnection->request_name(poiSearch_SERVICE_NAME); serverPoiSearch=new poiSearchServer(*dbusConnection,database_filename,serverpoiContentAccess); + // create the server for Configuration + dbusConnection->request_name(poiConfiguration_SERVICE_NAME); + serverpoiConfiguration=new poiConfigurationServer(*dbusConnection); + // connect the serverPoiSearch to the serverpoiContentAccess serverpoiContentAccess->ConnectTopoiSearchServer(serverPoiSearch); + // connect the serverPoiSearch to the serverpoiConfiguration + serverpoiConfiguration->ConnectTopoiSearchServer(serverPoiSearch); + // create a client for Routing clientRouting = new Routing(*dbusConnection); @@ -2047,6 +2191,7 @@ int main(int argc , char** argv ) // clean memory delete serverPoiSearch; delete serverpoiContentAccess; + delete serverpoiConfiguration; delete clientRouting; delete dbusConnection; delete dispatcher; diff --git a/src/poi-service/poi-server/poi-server-class.h b/src/poi-service/poi-server/poi-server-class.h index 9e65016..aedafad 100644 --- a/src/poi-service/poi-server/poi-server-class.h +++ b/src/poi-service/poi-server/poi-server-class.h @@ -33,6 +33,7 @@ #include "../../../api/include/genivi-poiservice-constants.h" #include "../../../api/include/genivi-poiservice-poisearch_adaptor.h" #include "../../../api/include/genivi-poiservice-poicontentaccess_adaptor.h" +#include "../../../api/include/genivi-poiservice-configuration_adaptor.h" #include "../../../api/include/genivi-navigationcore-routing_proxy.h" #include "../../../api/include/genivi-poiservice-contentaccessmodule_proxy.h" #include "../../../src/poi-service/poi-common/poi-common-data-model.h" @@ -96,6 +97,8 @@ public: ~contentAccessModule(); + void ConfigurationChanged(const std::vector< uint16_t >& changedSettings); + private: }; @@ -152,7 +155,7 @@ public: void SetRegisteredAttributeCategoryFlag(camId_t camId,categoryId_t categoryId, attributeId_t attributeId); - void SetLanguage(std::string LanguageCode, std::string CountryCode); + void SetLocale(std::string languageCode, std::string countryCode, std::string scriptCode); uint16_t searchAroundALocation(DBus_geoCoordinate3D::geoCoordinate3D_t location,const std::string* inputString, uint16_t sortOption); @@ -225,10 +228,6 @@ public: DBus_version::DBus_version_t GetVersion(); - void GetLanguage(std::string& languageCode, std::string& countryCode); - - void SetLanguage(const std::string& languageCode, const std::string& countryCode); - std::vector< ::DBus::Struct< categoryId_t, bool > > ValidateCategories(const std::vector< categoryId_t >& categories); std::vector< DBus_categoryIdName::DBus_categoryIdName_t > GetAvailableCategories(); @@ -265,6 +264,10 @@ public: std::vector< DBus_searchResultDetails::DBus_searchResultDetails_t > GetPoiDetails(const std::vector< poiId_t >& id); + // Specific methods + + void SetLocale(std::string languageCode, std::string countryCode, std::string scriptCode); + private: @@ -307,7 +310,7 @@ private: // DBus data DBus_version m_version; - std::string m_languageCode, m_countryCode; + std::string m_languageCode, m_countryCode, m_scriptCode; handleId_t m_poiSearchHandle; // the POC is limited to the management of one handle ! categoryId_t m_rootCategory; uint8_t m_sessionHandle; @@ -339,5 +342,53 @@ private: poi_category_t m_availableCategoryTable[MAX_CATEGORIES]; }; +class poiConfigurationServer +: public org::genivi::poiservice::Configuration_adaptor, + public DBus::IntrospectableAdaptor, + public DBus::ObjectAdaptor +{ + +public: + + poiConfigurationServer(DBus::Connection &connection); + + ~poiConfigurationServer(); + +//implementation of the DBus methods of the Configuration component + + DBus_version::DBus_version_t GetVersion(); + + void SetUnitsOfMeasurement(const std::map< uint16_t, ::DBus::Variant >& unitsOfMeasurementList); + std::map< uint16_t, ::DBus::Variant > GetUnitsOfMeasurement(); + std::map< uint16_t, ::DBus::Variant > GetSupportedUnitsOfMeasurement(); + void SetTimeFormat(const uint16_t& timeFormat); + uint16_t GetTimeFormat(); + std::vector< uint16_t > GetSupportedTimeFormats(); + void SetCoordinatesFormat(const uint16_t& coordinatesFormat); + uint16_t GetCoordinatesFormat(); + std::vector< uint16_t > GetSupportedCoordinatesFormats(); + void SetLocale(const std::string& languageCode, const std::string& countryCode, const std::string& scriptCode); + void GetLocale(std::string& languageCode, std::string& countryCode, std::string& scriptCode); + std::vector< ::DBus::Struct< std::string, std::string , std::string> > GetSupportedLocales(); + +// specific methods + + void ConnectTopoiSearchServer(poiSearchServer *poiSearch); + +private: + + +// private data + + poiSearchServer *mp_poiSearch; + +// DBus data + DBus_version m_version; + std::string m_languageCode, m_countryCode, m_scriptCode; + uint16_t m_coordinatesFormat; + std::map< uint16_t, ::DBus::Variant > m_unitsOfMeasurementList; + uint16_t m_timeFormat; +}; + #endif // POIPOCSERVERCLASS_H |