1 #include <QApplication>
6 #include <libhomescreen.hpp>
7 #include <navigation.h>
9 #define DEFAULT_CREDENTIALS_FILE "/etc/poikey"
13 static QString graphic_role;
14 static MainApp *mainapp;
15 static LibHomeScreen* hs;
17 // Callback to drive raising navigation app
18 static void NavWindowRaiseHandler(void)
21 hs->showWindow("navigation", nullptr);
25 static void ShowWindowHandler(json_object *object)
30 int main(int argc, char *argv[], char *env[])
33 QApplication a(argc, argv);
34 QString credentialsFile(DEFAULT_CREDENTIALS_FILE);
36 hs = new LibHomeScreen();
37 graphic_role = QString("poi");
38 a.setDesktopFileName(graphic_role);
40 QString pt = QString(argv[1]);
41 int port = pt.toInt();
42 QString secret = QString(argv[2]);
43 std::string token = secret.toStdString();
46 bindingAddress.setScheme(QStringLiteral("ws"));
47 bindingAddress.setHost(QStringLiteral("localhost"));
48 bindingAddress.setPort(port);
49 bindingAddress.setPath(QStringLiteral("/api"));
51 query.addQueryItem(QStringLiteral("token"), secret);
52 bindingAddress.setQuery(query);
54 mainapp = new MainApp(new Navigation(bindingAddress));
57 mainapp->setInfoScreen(true);
58 mainapp->setKeyboard(true);
60 // hook up callback to start/raise navigation app
61 mainapp->setNavWindowRaiseCallback(NavWindowRaiseHandler);
63 hs->init(port, token.c_str());
64 hs->set_event_handler(LibHomeScreen::Event_ShowWindow, ShowWindowHandler);
66 /* then, authenticate connexion to POI service: */
67 if (mainapp->AuthenticatePOI(credentialsFile) < 0)
69 cerr << "Error: POI server authentication failed" << endl;
73 cerr << "authentication succes !" << endl;
75 /* now, let's start monitor user inut (register callbacks): */
76 if (mainapp->StartMonitoringUserInput() < 0)