aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-11-11 00:48:02 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-11-11 00:48:02 -0800
commit15a79164e5bb3dd51185371a17d9ae8b48b40a85 (patch)
tree480c168c333917dd2688971601670cd1831f4661
parent147fc413436c62abbf8f5f054ca49b3d390eefa2 (diff)
Switch from DBus interface to rewritten agl-service-nagivation binding via the libqtappfw wrapper interface. Bug-AGL: SPEC-2880 Change-Id: I4244de4db250af438dda6b6173940f6a49fe34f2 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--CMakeLists.txt7
-rw-r--r--MainApp.cpp119
-rw-r--r--MainApp.h13
-rw-r--r--config.xml.in2
-rw-r--r--main.cpp19
5 files changed, 25 insertions, 135 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fd1cd0..dd6be29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,21 +25,20 @@ pkg_check_modules(QT5_CORE REQUIRED Qt5Core)
pkg_check_modules(JSON REQUIRED json-c)
pkg_check_modules(QT5_WIDGETS REQUIRED Qt5Widgets)
pkg_check_modules(QT5_NETWORK REQUIRED Qt5Network)
-pkg_check_modules(AGL_NAVIAPI REQUIRED libnaviapi-agl)
-pkg_check_modules(AFBWSC REQUIRED libafbwsc)
+pkg_check_modules(QTAPPFW REQUIRED qtappfw)
pkg_check_modules(QLIBWIN REQUIRED qlibwindowmanager)
pkg_check_modules(LIBHS REQUIRED libhomescreen)
-include_directories( ${PROJECT_SOURCE_DIR}/ ${AFBWSC_INCLUDE_DIRS} ${AGL_NAVIAPI_INCLUDE_DIRS} ${QT5_CORE_INCLUDE_DIRS} ${QT5_WIDGETS_INCLUDE_DIRS} ${QT5_NETWORK_INCLUDE_DIRS} ${JSON_INCLUDE_DIRS} ${QLIBWIN_INCLUDE_DIRS} ${LIBHS_INCLUDE_DIRS} )
+include_directories( ${PROJECT_SOURCE_DIR}/ ${QTAPPFW_INCLUDE_DIRS} ${QT5_CORE_INCLUDE_DIRS} ${QT5_WIDGETS_INCLUDE_DIRS} ${QT5_NETWORK_INCLUDE_DIRS} ${JSON_INCLUDE_DIRS} ${QLIBWIN_INCLUDE_DIRS} ${LIBHS_INCLUDE_DIRS} )
qt5_wrap_cpp(yelp_client_SRC MainApp.h InfoPanelLabel.h ClickableLabel.h Keyboard.h)
QT5_ADD_RESOURCES(yelp_client_QRC yelp-client.qrc)
add_executable( yelp-client main.cpp MainApp.cpp InfoPanel.cpp InfoPanelLabel.cpp Keyboard.cpp yelp-client.qrc ${yelp_client_SRC} ${yelp_client_QRC})
#target_link_libraries( yelp-client binderclient )
-target_link_libraries( yelp-client ${AFBWSC_LIBRARIES} ${AGL_NAVIAPI_LIBRARIES} ${JSON_LIBRARIES} ${QLIBWIN_LIBRARIES} ${LIBHS_LIBRARIES} )
+target_link_libraries( yelp-client ${QTAPPFW_LIBRARIES} ${JSON_LIBRARIES} ${QLIBWIN_LIBRARIES} ${LIBHS_LIBRARIES} )
qt5_use_modules(yelp-client Core Widgets Network)
install (TARGETS yelp-client DESTINATION bin)
diff --git a/MainApp.cpp b/MainApp.cpp
index 8ff0488..f4c858d 100644
--- a/MainApp.cpp
+++ b/MainApp.cpp
@@ -52,13 +52,13 @@
using namespace std;
-MainApp::MainApp():QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
+MainApp::MainApp(Navigation *navigation):QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
networkManager(this),searchBtn(QIcon(tr(":/images/loupe-90.png")), tr(""), this),
lineEdit(this),keyboard(QRect(0, 688, COMPLETE_W_WITH_KB, 720), this),
mutex(QMutex::Recursive),token(""),currentSearchingText(""),currentSearchedText(""),
pSearchReply(NULL),pInfoPanel(NULL),pResultList(NULL),currentLatitude(36.136261),currentLongitude(-115.151254),
navicoreSession(0),currentIndex(0),fontId(-1),isInfoScreen(false),
- isInputDisplayed(false),isKeyboard(false),isAglNavi(false)
+ isInputDisplayed(false),isKeyboard(false),isAglNavi(false), naviapi(navigation)
{
//this->setAttribute(Qt::WA_TranslucentBackground);
this->setStyleSheet("border: none;");
@@ -117,8 +117,6 @@ MainApp::MainApp():QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
isAglNavi = true;
connect(this, SIGNAL(positionGotSignal()), this, SLOT(positionGot()));
- connect(this, SIGNAL(allRoutesGotSignal()), this, SLOT(allRoutesGot()));
- connect(this, SIGNAL(routeCreatedSignal()), this, SLOT(routeCreated()));
this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
this->setStyleSheet("background-image: url(:/images/AGL_POI_Background.png);");
@@ -277,11 +275,7 @@ void MainApp::textChanged(const QString & text)
}
this->currentSearchingText = text;
- /* we need to know our current position */
- std::vector<int32_t> Params;
- Params.push_back(naviapi::NAVICORE_LONGITUDE);
- Params.push_back(naviapi::NAVICORE_LATITUDE);
- naviapi.getPosition(Params);
+ emit positionGotSignal();
mutex.unlock();
}
@@ -580,7 +574,7 @@ void MainApp::SetDestination(int index)
this->destinationLatitude = Businesses[index].Latitude;
this->destinationLongitude = Businesses[index].Longitude;
- naviapi.getAllRoutes();
+ SetWayPoints(0);
mutex.unlock();
}
@@ -768,18 +762,6 @@ bool MainApp::IsCoordinatesConsistent(Business & business)
}
/* end of workaround */
-bool MainApp::CheckNaviApi(int argc, char *argv[])
-{
- bool ret = naviapi.connect(argc, argv, this);
-
- if (ret == true)
- {
- naviapi.getAllSessions();
- }
-
- return ret;
-}
-
int MainApp::AuthenticatePOI(const QString & CredentialsFile)
{
char buf[512];
@@ -901,12 +883,7 @@ int MainApp::StartMonitoringUserInput()
void MainApp::SetWayPoints(uint32_t myRoute)
{
/* set the destination : */
- naviapi::Waypoint destWp(this->destinationLatitude, this->destinationLongitude);
- std::vector<naviapi::Waypoint> myWayPoints;
- myWayPoints.push_back(destWp);
- naviapi.setWaypoints(navicoreSession, myRoute, true, myWayPoints);
-
- naviapi.calculateRoute(navicoreSession, myRoute);
+ naviapi->sendWaypoint(this->destinationLatitude, this->destinationLongitude);
/* reset search: */
currentSearchingText = tr("");
@@ -948,60 +925,6 @@ void MainApp::getAllSessions_reply(const std::map< uint32_t, std::string >& allS
mutex.unlock();
}
-
-void MainApp::getPosition_reply(std::map< int32_t, naviapi::variant > position)
-{
- mutex.lock();
-
- std::map< int32_t, naviapi::variant >::iterator it;
- for (it = position.begin(); it != position.end(); it++)
- {
- if (it->first == naviapi::NAVICORE_LATITUDE)
- {
- currentLatitude = it->second._double;
- }
- else if (it->first == naviapi::NAVICORE_LONGITUDE)
- {
- currentLongitude = it->second._double;
- }
- }
-
- TRACE_INFO("Current position: %f, %f", currentLatitude, currentLongitude);
-
- mutex.unlock();
-
- emit positionGotSignal();
-}
-
-void MainApp::getAllRoutes_reply(std::vector< uint32_t > allRoutes)
-{
- mutex.lock();
-
- uint32_t routeHandle = 0;
-
- if (allRoutes.size() != 0)
- {
- routeHandle = allRoutes[0];
- }
-
- this->currentRouteHandle = routeHandle;
-
- mutex.unlock();
-
- emit allRoutesGotSignal();
-}
-
-void MainApp::createRoute_reply(uint32_t routeHandle)
-{
- mutex.lock();
-
- this->currentRouteHandle = routeHandle;
-
- mutex.unlock();
-
- emit routeCreatedSignal();
-}
-
void MainApp::positionGot()
{
mutex.lock();
@@ -1023,35 +946,3 @@ void MainApp::positionGot()
mutex.unlock();
}
-
-void MainApp::allRoutesGot()
-{
- mutex.lock();
-
- /* check if a route already exists, if not create it : */
- if (this->currentRouteHandle == 0)
- {
- naviapi.createRoute(navicoreSession);
- }
- else
- {
- naviapi.pauseSimulation(navicoreSession);
- naviapi.setSimulationMode(navicoreSession, false);
- naviapi.cancelRouteCalculation(navicoreSession, this->currentRouteHandle);
- sleep(1);
-
- SetWayPoints(this->currentRouteHandle);
- }
-
- mutex.unlock();
-}
-
-void MainApp::routeCreated()
-{
- mutex.lock();
-
- SetWayPoints(this->currentRouteHandle);
-
- mutex.unlock();
-}
-
diff --git a/MainApp.h b/MainApp.h
index 66defee..7d0b9de 100644
--- a/MainApp.h
+++ b/MainApp.h
@@ -12,16 +12,15 @@
#include "InfoPanel.h"
#include "Keyboard.h"
-#include <libnavicore.hpp>
+#include <navigation.h>
-class MainApp: public QMainWindow, public naviapi::NavicoreListener
+class MainApp: public QMainWindow
{
Q_OBJECT
public:
- explicit MainApp();
+ explicit MainApp(Navigation *navigation);
~MainApp();
- bool CheckNaviApi(int argc, char *argv[]);
int AuthenticatePOI(const QString & CredentialsFile);
int StartMonitoringUserInput();
void setInfoScreen(bool val) { isInfoScreen = val; }
@@ -39,7 +38,7 @@ class MainApp: public QMainWindow, public naviapi::NavicoreListener
int FillResultList(std::vector<Business> & list, int focusIndex = 0);
void SetWayPoints(uint32_t myRoute);
- naviapi::Navicore naviapi;
+ Navigation *naviapi;
QNetworkAccessManager networkManager;
QPushButton searchBtn;
QLineEdit lineEdit;
@@ -68,7 +67,7 @@ class MainApp: public QMainWindow, public naviapi::NavicoreListener
public:
void getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions);
- void getPosition_reply(std::map< int32_t, naviapi::variant > position);
+ //void getPosition_reply(std::map< int32_t, naviapi::variant > position);
void getAllRoutes_reply(std::vector< uint32_t > allRoutes);
void createRoute_reply(uint32_t routeHandle);
@@ -84,8 +83,6 @@ class MainApp: public QMainWindow, public naviapi::NavicoreListener
void cancelClicked();
void positionGot();
- void allRoutesGot();
- void routeCreated();
signals:
void allSessionsGotSignal();
diff --git a/config.xml.in b/config.xml.in
index bec206d..a20cdef 100644
--- a/config.xml.in
+++ b/config.xml.in
@@ -6,7 +6,7 @@
<description>POI App</description>
<author>AISIN AW</author>
<feature name="urn:AGL:widget:required-api">
- <param name="naviapi" value="ws" />
+ <param name="navigation" value="ws" />
<param name="windowmanager" value="ws" />
<param name="homescreen" value="ws" />
</feature>
diff --git a/main.cpp b/main.cpp
index 77e910f..2f360f3 100644
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,7 @@
#include <libhomescreen.hpp>
#include <qlibwindowmanager.h>
+#include <navigation.h>
#define DEFAULT_CREDENTIALS_FILE "/etc/poikey"
@@ -40,6 +41,15 @@ int main(int argc, char *argv[], char *env[])
QString secret = QString(argv[2]);
std::string token = secret.toStdString();
+ QUrl bindingAddress;
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), secret);
+ bindingAddress.setQuery(query);
+
if (qwm->init(port, secret) != 0) {
exit(EXIT_FAILURE);
}
@@ -51,7 +61,7 @@ int main(int argc, char *argv[], char *env[])
qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, SyncDrawHandler);
- mainapp = new MainApp();
+ mainapp = new MainApp(new Navigation(bindingAddress));
hs->init(port, token.c_str());
@@ -61,13 +71,6 @@ int main(int argc, char *argv[], char *env[])
mainapp->setInfoScreen(true);
mainapp->setKeyboard(true);
- /* check naviapi */
- if (mainapp->CheckNaviApi(argc, argv) == false)
- {
- cerr << "Error: naviapi check failed" << endl;
- return -1;
- }
-
/* then, authenticate connexion to POI service: */
if (mainapp->AuthenticatePOI(credentialsFile) < 0)
{