#include "usermanagement.h"
-#include <QApplication>
#include <QDebug>
#include <QtCore/QJsonDocument>
#include <QByteArray>
UserManagement::UserManagement(QObject *root) : QObject()
{
home = root->findChild<QObject *>("Home");
+ QObject::connect(home, SIGNAL(disconnect()),
+ this, SLOT(slot_disconnect()));
logo = root->findChild<QObject *>("Logo_colour");
shortcutArea = root->findChild<QObject *>("ShortcutArea");
statusArea = root->findChild<QObject *>("StatusArea");
this->appModel = home->findChild<ApplicationModel *>("ApplicationModel");
sequence = 0;
+ isRed = false;
+ connect(&timerRed, SIGNAL(timeout()), this, SLOT(slot_turnOffRed()));
+ timerRed.setSingleShot(true);
+ timerRed.setInterval(3000);
#ifdef REAL_SERVER
connectWebsockets();
#else
launchServer();
#endif
}
+void UserManagement::slot_disconnect()
+{
+ appModel->changeOrder(-1);
+ timerRed.stop();
+ slot_turnOffRed();
+ QMetaObject::invokeMethod(home, "languageChanged");
+ QMetaObject::invokeMethod(shortcutArea, "languageChanged", Q_ARG(QVariant, "en"));
+ QMetaObject::invokeMethod(statusArea, "languageChanged", Q_ARG(QVariant, "en"));
+ QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, false));
+ QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false), Q_ARG(QVariant, ""));
+ QMetaObject::invokeMethod(home, "changeFlag", Q_ARG(QVariant, "./images/us_flag.png"));
+}
+
void UserManagement::setUser(const User &user)
{
+ int hash = qHash(user.name + user.first_name);
+ timerRed.stop();
appModel->changeLanguage(user.graphPreferredLanguage);
- QMetaObject::invokeMethod(logo, "setImage", Q_ARG(QVariant, "./images/Utility_Logo_Colour-01.png"));
+ appModel->changeOrder(hash);
+ slot_turnOffRed();
QMetaObject::invokeMethod(home, "languageChanged");
QMetaObject::invokeMethod(shortcutArea, "languageChanged", Q_ARG(QVariant, user.graphPreferredLanguage));
QMetaObject::invokeMethod(statusArea, "languageChanged", Q_ARG(QVariant, user.graphPreferredLanguage));
- QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, true));
- QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, true), Q_ARG(QVariant, "---- ---- ---- " + user.ccNumberMasked));
+ QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, !user.graphActions.contains("Exceed 100 Kph")));
+ if(user.ccNumberMasked.isEmpty())
+ QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false), Q_ARG(QVariant, ""));
+ else
+ QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, true), Q_ARG(QVariant, user.ccNumberMasked));
const QString welcome = QString("%1").arg(user.graphPreferredLanguage == "fr" ? "Bonjour " : "Hello") + " ";
QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, welcome + user.first_name));
+ QMetaObject::invokeMethod(home, "changeFlag", Q_ARG(QVariant, user.graphPreferredLanguage == "fr" ? "./images/french_flag.png" : "./images/us_flag.png"));
+}
+void UserManagement::slot_turnOffRed()
+{
+ if(!isRed)
+ return;
+ QMetaObject::invokeMethod(logo, "setImage", Q_ARG(QVariant, "./images/Utility_Logo_Colour-01.png"));
+ isRed = false;
}
+
void UserManagement::connectWebsockets()
{
#ifdef REAL_SERVER
}
QVariantMap map = list.at(2).toMap();
if(list.first().toInt() == 5) {
- QMetaObject::invokeMethod(logo, "setImage", Q_ARG(QVariant, "./images/Utility_Logo_Red-01.png"));
+ if(!isRed)
+ QMetaObject::invokeMethod(logo, "setImage", Q_ARG(QVariant, "./images/Utility_Logo_Red-01.png"));
+ isRed = true;
+ timerRed.start();
map = map["data"].toMap();
if(map["eventName"].toString() == "login") {
//qWarning()<<"login received in client";
user.loc.setX(temp.at(0).toDouble());
user.loc.setY(temp.at(1).toDouble());
}
+ user.graphActions = map["graphActions"].toString().split(",");
user.country = map["country"].toString();
user.mail = map["mail"].toString();
user.city = map["city"].toString();
}
void UserManagement::processTextMessage(QString message)
{
- QString clientDetails_1 = "{\"postal_address\":\"201 Mission Street\",\"loc\":\"37.7914374,-122.3950694\""
+ QString clientDetails_1 = "{\"postal_address\":\"201 Mission Street\",\"loc\":\"37.7914374,-122.3950694\",\"graphActions\":\"Install App,Update Software,Exceed 100 Kph,Open Trunk,View Online\""
",\"country\":\"USA\",\"mail\":\"bjensen@example.com\",\"city\":\"San Francisco\",\"graphEmail\":"
"\"bjensen@example.com\",\"graphPreferredLanguage\":\"en\",\"ccNumberMasked\":\"-111\",\"ccExpYear\""
":\"19\",\"ccExpMonth\":\"01\",\"description\":\"Original description\",\"groups\":[],\"last_name\":\""
{
if(!pSocket)
return;
+ if(sequence > 3) {
+ timerTest.stop();
+ return;
+ }
pSocket->sendTextMessage("[5,\"agl-identity-agent/event\",{\"event\":\"agl-identity-agent\/event\",\"data\":{\"eventName\":\"incoming\",\"accountid\":\"D2:D4:71:0D:B5:F1\",\"nickname\":\"D2:D4:71:0D:B5:F1\"},\"jtype\":\"afb-event\"}]");
pSocket->sendTextMessage("[5,\"agl-identity-agent/event\",{\"event\":\"agl-identity-agent\/event\",\"data\":{\"eventName\":\"login\",\"accountid\":\"null\"},\"jtype\":\"afb-event\"}]");
}