From cb31b34dbea210a8890004fd59dea3139b00be6c Mon Sep 17 00:00:00 2001 From: Philippe Lelong Date: Wed, 14 Dec 2016 17:08:53 +0100 Subject: add visa, start websocket implementation Signed-off-by: Philippe Lelong --- HomeScreen/HomeScreen.pro | 2 +- HomeScreen/qml/Home.qml | 14 ++++++++++++++ HomeScreen/qml/images/Home/home.qrc | 1 + HomeScreen/qml/images/Home/visa.png | Bin 156768 -> 61687 bytes HomeScreen/src2/usermanagement.cpp | 28 ++++++++++++++++++++++++++++ HomeScreen/src2/usermanagement.h | 6 ++++++ WindowManager/WindowManager.pro | 2 +- WindowManager/src/windowmanager.cpp | 4 ++-- WindowManager/src/windowmanager.hpp | 4 ++-- 9 files changed, 55 insertions(+), 6 deletions(-) diff --git a/HomeScreen/HomeScreen.pro b/HomeScreen/HomeScreen.pro index 50dcbba..c526f12 100644 --- a/HomeScreen/HomeScreen.pro +++ b/HomeScreen/HomeScreen.pro @@ -14,7 +14,7 @@ TEMPLATE = app TARGET = HomeScreen -QT = qml quick widgets dbus +QT = qml quick widgets dbus websockets CONFIG += c++11 include(../interfaces/interfaces.pri) diff --git a/HomeScreen/qml/Home.qml b/HomeScreen/qml/Home.qml index 36f3f8a..2e0f490 100644 --- a/HomeScreen/qml/Home.qml +++ b/HomeScreen/qml/Home.qml @@ -40,6 +40,17 @@ Item { source: './images/B14-90.png' visible: false } + Image { + id: visa + width: 200 + height: 124 + anchors.right: parent.right + anchors.rightMargin: 20 + anchors.top: parent.top + anchors.topMargin: 20 + source: './images/visa.png' + visible: false + } Item { id: hello anchors.horizontalCenter: parent.horizontalCenter @@ -83,6 +94,9 @@ Item { sign90.visible = show } + function showVisa(show) { + visa.visible = show + } GridView { anchors.centerIn: parent width: cellHeight * 3 diff --git a/HomeScreen/qml/images/Home/home.qrc b/HomeScreen/qml/images/Home/home.qrc index 4a112ce..14e2828 100644 --- a/HomeScreen/qml/images/Home/home.qrc +++ b/HomeScreen/qml/images/Home/home.qrc @@ -20,5 +20,6 @@ HMI_AppLauncher_Settings_Active-01.png HMI_AppLauncher_Settings_Inactive-01.png B14-90.png + visa.png diff --git a/HomeScreen/qml/images/Home/visa.png b/HomeScreen/qml/images/Home/visa.png index 2249621..1c854bc 100755 Binary files a/HomeScreen/qml/images/Home/visa.png and b/HomeScreen/qml/images/Home/visa.png differ diff --git a/HomeScreen/src2/usermanagement.cpp b/HomeScreen/src2/usermanagement.cpp index bbbbac1..f973001 100644 --- a/HomeScreen/src2/usermanagement.cpp +++ b/HomeScreen/src2/usermanagement.cpp @@ -11,6 +11,7 @@ UserManagement::UserManagement(QObject *home, QObject *shortcutArea, QObject *st connect(&timerTest, SIGNAL(timeout()), this, SLOT(slot_timerTest())); timerTest.setSingleShot(false); timerTest.start(5000); + connectWebsockets(QStringLiteral("wss://echo.websocket.org")); } void UserManagement::slot_timerTest() { @@ -25,10 +26,37 @@ void UserManagement::slot_timerTest() if(currentLanguage == "fr") { QLocale::setDefault(QLocale("fr_FR")); QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, true)); + QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false)); QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Bonjour José!")); } else { QLocale::setDefault(QLocale("en_US")); QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, false)); + QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, true)); QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Hello José!")); } } +void UserManagement::connectWebsockets(const QUrl &url) +{ + QSslConfiguration config = QSslConfiguration::defaultConfiguration(); + config.setProtocol(QSsl::SecureProtocols); + webSocket.setSslConfiguration(config); + connect(&webSocket, &QWebSocket::connected, this, &UserManagement::onConnected); + connect(&webSocket, &QWebSocket::disconnected, this, &UserManagement::onClosed); + webSocket.open(QUrl(url)); +} +void UserManagement::onConnected() +{ + connect(&webSocket, &QWebSocket::textMessageReceived, + this, &UserManagement::onTextMessageReceived); + webSocket.sendTextMessage(QStringLiteral("Hello, world!")); + +} +void UserManagement::onTextMessageReceived(QString message) +{ + qWarning()<<"message received:"< #include "applicationmodel.h" #include +#include class UserManagement : public QObject { Q_OBJECT @@ -14,6 +15,9 @@ signals: public slots: void slot_timerTest(); + void onConnected(); + void onClosed(); + void onTextMessageReceived(QString message); private: QObject *home; QObject *shortcutArea; @@ -21,6 +25,8 @@ private: ApplicationModel *appModel; QTimer timerTest; QString currentLanguage; + QWebSocket webSocket; + void connectWebsockets(const QUrl &url); }; #endif // USERMANAGEMENT_H diff --git a/WindowManager/WindowManager.pro b/WindowManager/WindowManager.pro index 5aa7320..335693f 100644 --- a/WindowManager/WindowManager.pro +++ b/WindowManager/WindowManager.pro @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +#DEFINES += COMPIL_MAITAI TEMPLATE = app TARGET = WindowManager QT = core dbus diff --git a/WindowManager/src/windowmanager.cpp b/WindowManager/src/windowmanager.cpp index e21e5e1..fcd92a4 100644 --- a/WindowManager/src/windowmanager.cpp +++ b/WindowManager/src/windowmanager.cpp @@ -109,7 +109,7 @@ WindowManager::~WindowManager() #endif delete mp_layoutAreaToSurfaceIdAssignment; } -/* maitai +#ifndef COMPIL_MAITAI int WindowManager::getLayerRenderOrder(t_ilm_layer id_array[]) { int i, j; @@ -122,7 +122,7 @@ int WindowManager::getLayerRenderOrder(t_ilm_layer id_array[]) return j; } -*/ +#endif void WindowManager::dumpScene() { qDebug("\n"); diff --git a/WindowManager/src/windowmanager.hpp b/WindowManager/src/windowmanager.hpp index d9ec68c..b0bbb3c 100644 --- a/WindowManager/src/windowmanager.hpp +++ b/WindowManager/src/windowmanager.hpp @@ -50,9 +50,9 @@ private: unsigned int m_screenHeight; int* m_showLayers; - /* maitai +#ifndef COMPIL_MAITAI int getLayerRenderOrder(t_ilm_layer id_array[]); - */ +#endif void dumpScene(); -- cgit 1.2.3-korg