diff options
author | asanoaozora <fifitaneki@hotmail.com> | 2016-06-24 16:41:10 +0200 |
---|---|---|
committer | asanoaozora <fifitaneki@hotmail.com> | 2016-06-24 16:41:10 +0200 |
commit | f85c53ed7978ea6e5e30f3574c626a2e7a1a2194 (patch) | |
tree | 185d1c6688d2d11f11808b9f57b2ad5742529888 /src | |
parent | 79fa3754af2abc3c9ea51c7f889a6ac8ffc72a0a (diff) | |
download | poi-service-f85c53ed7978ea6e5e30f3574c626a2e7a1a2194.tar.gz |
CommonAPI: navigationcore locationinput plugin OK
Diffstat (limited to 'src')
5 files changed, 775 insertions, 55 deletions
diff --git a/src/navigation/navigation-core/CMakeLists.txt b/src/navigation/navigation-core/CMakeLists.txt index c9fad47..65e2e1b 100644 --- a/src/navigation/navigation-core/CMakeLists.txt +++ b/src/navigation/navigation-core/CMakeLists.txt @@ -45,15 +45,29 @@ find_program(XSLTPROC xsltproc REQUIRED) # Generate the config file for navit/navigation-core if(NOT ${YOCTO_CONFIG}) - execute_process( - OUTPUT_FILE ${NAVIT_BIN_DIR}/navit_genivi_navigationcore.xml - COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_navigationcore.xsl ${navit_SOURCE_DIR}/navit/navit_shipped.xml - ) + if (WITH_PLUGIN_MIGRATION) + execute_process( + OUTPUT_FILE ${NAVIT_BIN_DIR}/navit_genivi_navigationcore.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_navigationcore_capi.xsl ${navit_SOURCE_DIR}/navit/navit_shipped.xml + ) + else() + execute_process( + OUTPUT_FILE ${NAVIT_BIN_DIR}/navit_genivi_navigationcore.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_navigationcore.xsl ${navit_SOURCE_DIR}/navit/navit_shipped.xml + ) + endif() else() - execute_process( - OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/navit_genivi_navigationcore.xml - COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_navigationcore.xsl ${NAVIT_CMAKE_DIR}/../navit/navit_shipped.xml - ) + if (WITH_PLUGIN_MIGRATION) + execute_process( + OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/navit_genivi_navigationcore.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_navigationcore_capi.xsl ${NAVIT_CMAKE_DIR}/../navit/navit_shipped.xml + ) + else() + execute_process( + OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/navit_genivi_navigationcore.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_navigationcore.xsl ${NAVIT_CMAKE_DIR}/../navit/navit_shipped.xml + ) + endif() endif() add_definitions(-DPLUGIN=1) @@ -75,12 +89,9 @@ if(${YOCTO_CONFIG}) include_directories(${STAGING_INCDIR}/navit) endif() -add_subdirectory(configuration-plugin) add_subdirectory(guidance-plugin) -add_subdirectory(locationinput-plugin) - add_subdirectory(mapmatchedposition-plugin) add_subdirectory(routing-plugin) @@ -92,5 +103,9 @@ add_subdirectory(enhancedposition-plugin) if (WITH_PLUGIN_MIGRATION) set(FRANCA_DIR "${API_DIR}/franca") add_subdirectory(configuration-server-plugin) + add_subdirectory(locationinput-server-plugin) +else() + add_subdirectory(configuration-plugin) + add_subdirectory(locationinput-plugin) endif() 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 index b16a418..88c15de 100644 --- a/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx +++ b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx @@ -78,50 +78,6 @@ static const map32_t country_map[] = { {"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); -} - class NavigationCoreConfigurationServerStub: public ConfigurationStubDefault { public: diff --git a/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt new file mode 100644 index 0000000..8600ed9 --- /dev/null +++ b/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt @@ -0,0 +1,116 @@ +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# Component Name: configuration-server-plugin +# +# Author: Philippe Colliot +# +# Copyright (C) 2015, PCA Peugeot Citroën +# +# License: +# This Source Code Form is subject to the terms of the +# Mozilla Public License, 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/. +# +# @licence end@ +########################################################################### +project(locationinput-server-plugin) +cmake_minimum_required(VERSION 2.8) + +message(STATUS ${PROJECT_NAME}) + +set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") + + + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) + + +# 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 -DDBUS_LIB_PATH=yourPath") +endif() + +# Packages +find_package(CommonAPI 3.1.5 REQUIRED) +find_package(CommonAPI-DBus 3.1.5 REQUIRED) + + +#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) +pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) + + +# Add the Franca files (that will generate the CommonAPI stuff) +set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") +add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") + +# Path to the generated files +set(API_VERSION_MAJOR 4) +set(API_VERSION "v${API_VERSION_MAJOR}") +set(PRJ_SRC_GEN_ROOT_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi) #files shared by all the APIs +set(PRJ_SRC_GEN_NAVIGATION_PATH ${PRJ_SRC_GEN_ROOT_PATH}/navigation) #files shared by the navigation APIs +set(PRJ_SRC_GEN_NAVIGATIONCORE_PATH ${PRJ_SRC_GEN_NAVIGATION_PATH}/navigationcore) #files shared by the navigationcore APIs + +# Source Files +set(FRANCA_FILE "LocationInput") +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) +FILE(GLOB PRJ_STUB_GEN_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*Types.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Types.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}DBusStub*.cpp ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}Types.cpp ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}DBusDeployment.cpp ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}StubDefault.cpp + ) +FILE(GLOB PRJ_STUB_IMPL_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}Stub*.cpp + ) + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) + +include_directories( + ${COMMONAPI_GEN_DIR} + ${PRJ_SRC_GEN_ROOT_PATH} + ${PRJ_SRC_GEN_NAVIGATION_PATH} + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH} + ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} + ${GOBJECT_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} + ${DBUS_CPP_GLIB_INCLUDE_DIRS} +) + +link_directories( + ${DBUS_LIBDIR} + ${COMMONAPI_LIBDIR} + ${COMMONAPI_DBUS_LIBDIR} + ${GOBJECT_LIBRARY_DIRS} + ${GLIB_LIBRARY_DIRS} + ${DBUS_CPP_GLIB_DIRS} +) + +set(LIBRARIES + ${DBUS_LIBRARIES} + ${COMMONAPI_LIBRARIES} + ${COMMONAPI_DBUS_LIBRARIES} + ${GOBJECT_LIBRARIES} + ${GLIB_LIBRARIES} + ${DBUS_CPP_GLIB_LIBRARIES} +) + +# Build service +module_add_library(genivi_navigationcore_locationinput_server ${PRJ_SRCS}) +target_link_libraries(genivi_navigationcore_locationinput_server ${LIBRARIES}) + diff --git a/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx b/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx new file mode 100644 index 0000000..db45729 --- /dev/null +++ b/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx @@ -0,0 +1,570 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +* +* \file genivi_navigationcore_locationinput.cxx +* +* \brief This file is part of the Navit POC. +* +* \author Martin Schaller <martin.schaller@it-schaller.de> +* +* \version 1.0 +* +* 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 <dbus-c++/glib-integration.h> +#include "config.h" +#define USE_PLUGINS 1 +#include "debug.h" +#include "plugin.h" +#include "item.h" +#include "config_.h" +#include "navit.h" +#include "search.h" +#include "callback.h" +#include "event.h" +#include "coord.h" +#include "transform.h" + +#include <CommonAPI/CommonAPI.hpp> +#include <CommonTypes.hpp> +#include <NavigationTypes.hpp> +#include <NavigationCoreTypes.hpp> +#include <LocationInputStubDefault.hpp> + +#if (!DEBUG_ENABLED) +#undef dbg +#define dbg(level,...) ; +#endif + +using namespace v4::org::genivi::navigation::navigationcore; +using namespace v4::org::genivi::navigation; +using namespace v4::org::genivi; + +class LocationInputServerStub; + +class LocationInputObj +{ + public: + struct search_list *m_sl; + NavigationTypes::Handle m_handle; + NavigationTypes::Handle m_session; + LocationInput::AddressAttribute m_criterion; + uint32_t m_windowsize; + struct attr m_search; + LocationInputServerStub *mp_locationinput; + struct callback *m_callback; + struct event_idle *m_event; + bool m_spell; + bool m_spell_backspace; + std::vector< std::vector< LocationInput::Address > > m_data; + int m_chunk; + int m_count; + void SetSelectionCriterion(NavigationTypes::Handle SessionHandle, LocationInput::AddressAttribute SelectionCriterion); + void Search(NavigationTypes::Handle SessionHandle, const std::string& InputString, uint32_t MaxWindowSize); + void SelectEntry(const NavigationTypes::Handle& SessionHandle, const uint32_t& Index); + struct navit *get_navit(void); + struct mapset *get_mapset(struct navit *navit); + void IdleStop(void); + void Idle(void); + void Spell(NavigationTypes::Handle SessionHandle, const std::string& InputCharacter, uint32_t MaxWindowSize); + void RequestListUpdate(NavigationTypes::Handle sessionHandle, const uint16_t& offset, uint16_t maxWindowSize); + void GetEntry(uint16_t index, LocationInput::Address &entry); + void ValidateAddress(NavigationTypes::Handle sessionHandle, const LocationInput::Address &inputAddress); + LocationInputObj(LocationInputServerStub *locationinput, uint32_t handle); + ~LocationInputObj(); +}; + +class LocationInputServerStub : public LocationInputStubDefault { + +public: + LocationInputServerStub(){ + m_version.setVersionMajor(3); + m_version.setVersionMinor(0); + m_version.setVersionMicro(0); + m_version.setDate("21-01-2014"); + } + + ~LocationInputServerStub(){} + + /** + * description: getVersion = This method returns the API version implemented by the server + * application + */ + void getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply) { + _reply(m_version); + } + + /** + * description: createLocationInput = This method creates a new location input and retrieves a + * handle + */ + void createLocationInput(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, createLocationInputReply_t _reply){ + uint32_t LocationInputHandle; + dbg(lvl_debug,"enter\n"); + LocationInputHandle=1; + while (mp_handles[LocationInputHandle]) { + LocationInputHandle++; + if (LocationInputHandle == 256) + throw DBus::ErrorLimitsExceeded("Out of location handles"); + } + mp_handles[LocationInputHandle]=new LocationInputObj(this, LocationInputHandle); + _reply(LocationInputHandle); + } + + /** + * description: deleteLocationInput = This method deletes a location input and its associated + * resources + */ + void deleteLocationInput(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, deleteLocationInputReply_t _reply){ + dbg(lvl_debug,"enter\n"); + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + delete(obj); + mp_handles[_locationInputHandle]=NULL; + _reply(); + } + + /** + * description: getSupportedAddressAttributes = This method retrieves the supported address + * attributes + */ + void getSupportedAddressAttributes(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedAddressAttributesReply_t _reply){ + LocationInput::AddressAttributeList addressAttributes; + addressAttributes.resize(5); + addressAttributes[0]=LocationInput::AddressAttribute::COUNTRY; + addressAttributes[1]=LocationInput::AddressAttribute::CITY; + addressAttributes[2]=LocationInput::AddressAttribute::STREET; + addressAttributes[3]=LocationInput::AddressAttribute::HOUSENUMBER; + addressAttributes[4]=LocationInput::AddressAttribute::FULL_ADDRESS; + _reply(addressAttributes); + } + + /** + * description: setAddress = This method sets the address to start with for the LocationInput + * identified by the given handle + */ + void setAddress(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, LocationInput::Address _address, setAddressReply_t _reply){ + dbg(lvl_debug,"enter\n"); + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + throw DBus::ErrorNotSupported("Not yet supported"); + _reply(); + } + + /** + * description: setSelectionCriterion = This method sets the selection criterion for the + * current speller, search input and the corresponding result-lists for the + * current session + */ + void setSelectionCriterion(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, LocationInput::AddressAttribute _selectionCriterion, setSelectionCriterionReply_t _reply){ + dbg(lvl_debug,"enter\n"); + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + obj->SetSelectionCriterion(_sessionHandle, _selectionCriterion); + _reply(); + } + + /** + * description: spell = This method sends the next spell input for the current session + */ + void spell(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, std::string _inputCharacter, uint16_t _maxWindowSize, spellReply_t _reply){ + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + obj->Spell(_sessionHandle, _inputCharacter, _maxWindowSize); + _reply(); + } + + /** + * description: search = This method sends the search input for the current session + */ + void search(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, std::string _inputString, uint16_t _maxWindowSize, searchReply_t _reply){ + dbg(lvl_debug,"enter\n"); + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + obj->Search(_sessionHandle, _inputString, _maxWindowSize); + _reply(); + } + + /** + * description: requestListUpdate = This method sends a request for more list elements for the + * current session + */ + void requestListUpdate(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, uint16_t _offset, uint16_t _maxWindowSize, requestListUpdateReply_t _reply){ + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + + obj->RequestListUpdate(_sessionHandle, _offset, _maxWindowSize); + _reply(); + } + + /** + * description: selectEntry = This method triggers selection of a result list entry by index + */ + void selectEntry(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, uint16_t _index, selectEntryReply_t _reply){ + dbg(lvl_debug,"enter\n"); + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + obj->SelectEntry(_sessionHandle, _index); + _reply(); + } + + /** + * description: getEntry = This method synchronously gets the address for the given result list + * entry + */ + void getEntry(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, uint16_t _index, getEntryReply_t _reply){ + LocationInput::Address ret; + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + obj->GetEntry(_index, ret); + _reply(ret); + } + + /** + * description: validateAddress = This method validates an address from different sources than + * Navigation + */ + void validateAddress(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, LocationInput::Address _inputAddress, validateAddressReply_t _reply){ + LocationInputObj *obj=mp_handles[_locationInputHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("location handle invalid"); + obj->ValidateAddress(_sessionHandle, _inputAddress); + _reply(); + } + + /** + * description: reverseGeocode = This method transforms a geocoordinate into an address + */ + void reverseGeocode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, ::v4::org::genivi::navigation::NavigationTypes::Coordinate2D _coordinate, reverseGeocodeReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + +private: + CommonTypes::Version m_version; + std::map<uint32_t, LocationInputObj *> mp_handles; + +}; + +struct navit * +LocationInputObj::get_navit(void) +{ + struct attr navit; + if (!config_get_attr(config, attr_navit, &navit, NULL)) + return NULL; + return navit.u.navit; +} +struct mapset * +LocationInputObj::get_mapset(struct navit *navit) +{ + struct attr mapset; + if (!navit_get_attr(navit, attr_mapset, &mapset, NULL)) + return NULL; + return mapset.u.mapset; +} + +void +LocationInputObj::SetSelectionCriterion(NavigationTypes::Handle SessionHandle, LocationInput::AddressAttribute SelectionCriterion) +{ + m_criterion=SelectionCriterion; + switch(m_criterion) { + case LocationInput::AddressAttribute::COUNTRY: + m_search.type=attr_country_name; + break; + case LocationInput::AddressAttribute::CITY: + m_search.type=attr_town_name; + break; + case LocationInput::AddressAttribute::STREET: + m_search.type=attr_street_name; + break; + case LocationInput::AddressAttribute::HOUSENUMBER: + m_search.type=attr_house_number; + break; + case LocationInput::AddressAttribute::FULL_ADDRESS: + m_search.type=attr_address; + break; + default: + throw DBus::ErrorInvalidArgs("Invalid selection criterion"); + } + g_free(m_search.u.str); + m_search.u.str=NULL; + mp_locationinput->fireCurrentSelectionCriterionEvent(m_handle, m_criterion); +} + +void +LocationInputObj::Search(NavigationTypes::Handle SessionHandle, const std::string& InputString, uint32_t MaxWindowSize) +{ + IdleStop(); + g_free(m_search.u.str); + + m_session=SessionHandle; + m_search.u.str=g_strdup(InputString.c_str()); + m_windowsize=MaxWindowSize; + m_spell=false; + + search_list_search(m_sl, &m_search, 0); + m_event=event_add_idle(0, m_callback); +} + +void +LocationInputObj::Spell(NavigationTypes::Handle SessionHandle, const std::string& InputCharacter, uint32_t MaxWindowSize) +{ + IdleStop(); + + m_spell=true; + m_spell_backspace=false; + m_session=SessionHandle; + char *newstr; + const char *input=InputCharacter.c_str(); + int len=strlen(input)+1; + dbg(lvl_debug,"input '%s' (%d)\n",input,strlen(input)); + if (m_search.u.str && strlen(m_search.u.str)) { + const char *i=input; + char c; + newstr=g_strdup(m_search.u.str); + dbg(lvl_debug,"string %s\n",newstr); + while ((c=*i++)) { + dbg(lvl_debug,"char '%c'\n",c); + if (c == '\b') { + m_spell_backspace=true; + *g_utf8_prev_char(newstr+strlen(newstr))='\0'; + } else { + int len=strlen(newstr); + newstr=g_renew(char,newstr,len+2); + newstr[len]=c; + newstr[len+1]='\0'; + } + dbg(lvl_debug,"string now %s\n",newstr); + } + } else { + if (strcmp(input,"\b")) + newstr=g_strdup(input); + else + newstr=NULL; + } + g_free(m_search.u.str); + dbg(lvl_debug,"search string '%s' (%d)\n",newstr,strlen(newstr)); + m_search.u.str=newstr; + m_windowsize=MaxWindowSize; + + search_list_search(m_sl, &m_search, 1); + dbg(lvl_debug,"backspace %d\n",m_spell_backspace); + m_event=event_add_idle(0, m_callback); + +} + +void +LocationInputObj::RequestListUpdate(NavigationTypes::Handle sessionHandle, const uint16_t& offset, uint16_t maxWindowSize) +{ + //for the time being, maxWindowSize is not used, the size is set during the Spell or the Search + //note that it gets all the results in one shot (to be improved!), per bunch of maxWindowSize data + //not really what is specified.. + //offset is supposed to be n*maxWindowSize in that case + + if (m_windowsize > 0) + { + int i = offset/m_windowsize; + int shift = offset%m_windowsize; + uint16_t window=m_data[i].size(); + mp_locationinput->fireSearchResultListEvent(m_handle, m_count, (offset-shift), window, m_data[i]); + } +} + +void +LocationInputObj::SelectEntry(const NavigationTypes::Handle &SessionHandle, const uint32_t& Index) +{ + LocationInput::Address *res=NULL; + std::vector<LocationInput::AddressAttribute> next; + std::size_t window=0; + bool guidable=false; + for (std::size_t i = 0 ; i < m_data.size() ; i++) { + if (Index >= window && Index < window+m_data[i].size()) { + res=&m_data[i][Index-window]; + break; + } + window+=m_data[i].size(); + } + if (!res) + throw DBus::ErrorInvalidArgs("Invalid index"); + search_list_select(m_sl, m_search.type, Index+1, 1); + switch(m_criterion) { + case LocationInput::AddressAttribute::COUNTRY: + next.push_back(LocationInput::AddressAttribute::COUNTRY); + next.push_back(LocationInput::AddressAttribute::CITY); + break; + case LocationInput::AddressAttribute::CITY: + next.push_back(LocationInput::AddressAttribute::COUNTRY); + next.push_back(LocationInput::AddressAttribute::CITY); + next.push_back(LocationInput::AddressAttribute::STREET); + break; + case LocationInput::AddressAttribute::STREET: + case LocationInput::AddressAttribute::HOUSENUMBER: + next.push_back(LocationInput::AddressAttribute::COUNTRY); + next.push_back(LocationInput::AddressAttribute::CITY); + next.push_back(LocationInput::AddressAttribute::STREET); + next.push_back(LocationInput::AddressAttribute::HOUSENUMBER); + break; + } + if (res->find(LocationInput::AddressAttribute::LATITUDE) != res->end()) + guidable=true; + mp_locationinput->fireContentUpdatedEvent(m_handle, guidable, next, *res); +} + +void +LocationInputObj::IdleStop(void) +{ + if (m_event) { + event_remove_idle(m_event); + m_event=NULL; + } +} + +void +LocationInputObj::Idle(void) +{ + dbg(lvl_debug,"enter\n"); + mp_locationinput->fireSearchStatusEvent(m_handle, LocationInput::SearchStatus::SEARCHING); + struct search_list_result *res; + int chunk=0; + uint16_t count=0; + m_data.resize(0); + m_data.resize(1); + while ((res=search_list_get_result(m_sl))) { + LocationInput::Address entry; + if (res->country && res->country->name) { + dbg(lvl_debug,"country %s\n",res->country->name); + entry[LocationInput::AddressAttribute::COUNTRY] = std::string(res->country->name); + } + if (res->town && res->town->common.town_name) { + dbg(lvl_debug,"town %s\n",res->town->common.town_name); + entry[LocationInput::AddressAttribute::CITY] = std::string(res->town->common.town_name); + } + if (res->street && res->street->name) { + dbg(lvl_debug,"street %s\n",res->street->name); + entry[LocationInput::AddressAttribute::STREET] = std::string(res->street->name); + } + if (res->house_number && res->house_number->house_number) { + dbg(lvl_debug,"house number %s\n",res->house_number->house_number); + entry[LocationInput::AddressAttribute::HOUSENUMBER] = std::string(res->house_number->house_number); + } + if (res->c) { + struct coord_geo g; + struct coord c; + c.x=res->c->x; + c.y=res->c->y; + transform_to_geo(res->c->pro, &c, &g); + entry[LocationInput::AddressAttribute::LATITUDE] = g.lat; + entry[LocationInput::AddressAttribute::LONGITUDE] = g.lng; + } + m_data[chunk].push_back(entry); + if (m_data[chunk].size() >= m_windowsize) { + chunk++; + m_data.resize(chunk+1); + } + count++; + } + + // the search_list_get_unique has been removed from the svn in the r5549, so navit needs to be patched for upper versions + if (m_spell) { + char *unique; + if (m_spell_backspace) + unique=g_strdup(m_search.u.str); + else + unique=search_list_get_unique(m_sl, NULL); + m_spell_backspace=false; + if (unique) { + g_free(m_search.u.str); + m_search.u.str=unique; + char *next=search_list_get_unique(m_sl, unique); + if (next) { + mp_locationinput->fireSpellResultEvent(m_handle, unique, next, false); + g_free(next); + } + } + else + mp_locationinput->fireSpellResultEvent(m_handle, "", "\b", false); + } + + m_count = count; //amount of data + m_chunk = chunk; //amount of lists of data + + mp_locationinput->fireSearchStatusEvent(m_handle, LocationInput::SearchStatus::FINISHED); + IdleStop(); + +} + +static void +LocationInputObj_Idle(LocationInputObj *obj) +{ + obj->Idle(); +} + +void +LocationInputObj::GetEntry(uint16_t index, LocationInput::Address &entry) +{ +} + +void +LocationInputObj::ValidateAddress(NavigationTypes::Handle sessionHandle, const LocationInput::Address &inputAddress) +{ +} + +LocationInputObj::LocationInputObj(LocationInputServerStub *locationinput, uint32_t handle) +{ + mp_locationinput=locationinput; + m_handle=handle; + m_sl=search_list_new(get_mapset(get_navit())); + m_count=0; + m_chunk=0; + m_search.type=attr_none; + m_search.u.str=NULL; + m_event=NULL; + m_callback=callback_new_1(reinterpret_cast<void (*)(void)>(LocationInputObj_Idle), this); +} + +LocationInputObj::~LocationInputObj() +{ + IdleStop(); + callback_destroy(m_callback); + g_free(m_search.u.str); + search_list_destroy(m_sl); +} + +void +plugin_init(void) +{ + // Common API data init + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); + + const std::string &domain = "local"; + const std::string &instance = "LocationInput"; + + std::shared_ptr<LocationInputServerStub> myServiceLocationInput = std::make_shared<LocationInputServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instance, myServiceLocationInput); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myServiceLocationInput); + } +} diff --git a/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl b/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl new file mode 100644 index 0000000..74cc2bc --- /dev/null +++ b/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl @@ -0,0 +1,63 @@ +<?xml version="1.0"?> +<!-- ************************************************************************ +* Component Name: Navit POC +* Author: Martin Schaller <martin.schaller@it-schaller.de> +* +* Copyright (C) 2012, GENIVI Alliance, Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +************************************************************************ --> +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude"> + <xsl:template match="/config/plugins/plugin[1]" priority="1" > + <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/configuration-server-plugin/.libs/libgenivi_navigationcore_configuration_server.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/locationinput-server-plugin/.libs/libgenivi_navigationcore_locationinput_server.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/routing-plugin/.libs/libgenivi_navigationcore_routing.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/session-plugin/.libs/libgenivi_navigationcore_session.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/guidance-plugin/.libs/libgenivi_navigationcore_guidance.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/mapmatchedposition-plugin/.libs/libgenivi_navigationcore_mapmatchedposition.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../navigation-core/enhancedposition-plugin/.libs/libgenivi_positioning_enhancedposition.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../poi-cam/.libs/libgenivi_poiservice_cam_navit.so" ondemand="no"/> + </xsl:template> + <xsl:template match="/config/plugins/plugin"> + <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit"> + <xsl:copy><xsl:attribute name="flags">3</xsl:attribute><xsl:apply-templates select="@*|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/graphics"> + <xsl:copy><xsl:attribute name="enabled">no</xsl:attribute><xsl:apply-templates select="@*|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/gui"> + <xsl:copy><xsl:attribute name="enabled">no</xsl:attribute><xsl:apply-templates select="@*[not(name()='enabled')]|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/vehicle[@name='Local GPS']"> + <xsl:copy><xsl:attribute name="enabled">no</xsl:attribute><xsl:apply-templates select="@*[not(name()='enabled')]|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/vehicle[@name='Demo']"> + <vehicle name="EnhancedPosition" profilename="car" active="yes" source="enhancedposition://"/> + <xsl:text>
 </xsl:text> + <xsl:copy><xsl:attribute name="active">no</xsl:attribute><xsl:apply-templates select="@*[not(name()='enabled' or name()='active')]|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template> +</xsl:transform> |