summaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-08-30 11:43:58 -0400
committerScott Murray <scott.murray@konsulko.com>2019-08-30 11:45:55 -0400
commitededa7e3ef24a8cea9e513fa008ef481c1675457 (patch)
tree86a4c79d066b9638b11c0f127ad8f3c66c38c4f7 /main.cpp
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
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 <scott.murray@konsulko.com> Change-Id: I7405367387622fb788a5712ed24005ee6d7ce495
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp88
1 files changed, 88 insertions, 0 deletions
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 <QApplication>
+#include <iostream>
+#include "MainApp.h"
+#include <getopt.h>
+
+#include <libhomescreen.hpp>
+#include <qlibwindowmanager.h>
+
+
+#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();
+}