From ededa7e3ef24a8cea9e513fa008ef481c1675457 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Fri, 30 Aug 2019 11:43:58 -0400 Subject: Initial check in Initial check in of the original repository: git://github.com/AGLExport/genivi-navi-yelp-client.git as of commit c2691cb265d9198542482a860f1df378e8c2708b. Bug-AGL: SPEC-2787 Signed-off-by: Scott Murray Change-Id: I7405367387622fb788a5712ed24005ee6d7ce495 --- main.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..a43e37b --- /dev/null +++ b/main.cpp @@ -0,0 +1,88 @@ +#include +#include +#include "MainApp.h" +#include + +#include +#include + + +#define DEFAULT_CREDENTIALS_FILE "/etc/poikey" + +using namespace std; + +QLibWindowmanager* qwm; +LibHomeScreen* hs; +QString graphic_role; +MainApp *mainapp; + +void SyncDrawHandler(json_object *object) +{ + qwm->endDraw(graphic_role); +} + +void TapShortcutHandler(json_object *object) +{ + qwm->activateWindow(graphic_role); +} + +int main(int argc, char *argv[], char *env[]) +{ + int opt; + QApplication a(argc, argv); + QString credentialsFile(DEFAULT_CREDENTIALS_FILE); + qwm = new QLibWindowmanager(); + hs = new LibHomeScreen(); + graphic_role = QString("poi"); + + QString pt = QString(argv[1]); + int port = pt.toInt(); + QString secret = QString(argv[2]); + std::string token = secret.toStdString(); + + if (qwm->init(port, secret) != 0) { + exit(EXIT_FAILURE); + } + + if (qwm->requestSurface(graphic_role) != 0) { + cerr << "Error: wm check failed" << endl; + exit(EXIT_FAILURE); + } + + qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, SyncDrawHandler); + + mainapp = new MainApp(); + + hs->init(port, token.c_str()); + + hs->set_event_handler(LibHomeScreen::Event_TapShortcut, TapShortcutHandler); + + //force setting + 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) + { + cerr << "Error: POI server authentication failed" << endl; + return -1; + } + + cerr << "authentication succes !" << endl; + + /* now, let's start monitor user inut (register callbacks): */ + if (mainapp->StartMonitoringUserInput() < 0) + return -1; + + qwm->activateWindow(graphic_role); + + /* main loop: */ + return a.exec(); +} -- cgit 1.2.3-korg