message/call views: ui overhaul

This patch:
- implements QWebEngineView as the view for interactions
- reorganizes the main widget's layout in order to share views
  between in-call and out-of-call messaging views
- fixes behavioral bugs and crashes
- cannot be built with the mingw compiler due to lack of support for
  QWebEngine, and must be built natively with msvc and includes some
  build script modifications
- should be thought of as a new client

Change-Id: I59d8c68dc8384e85fb006f30d8313482c00d6c85
diff --git a/messagewebview.h b/messagewebview.h
new file mode 100644
index 0000000..72b15e7
--- /dev/null
+++ b/messagewebview.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Savoir-faire Linux                                *
+ * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>          *
+ *                                                                         *
+ * This program is free software; you can redistribute it and/or modify    *
+ * it under the terms of the GNU General Public License as published by    *
+ * the Free Software Foundation; either version 3 of the License, or       *
+ * (at your option) any later version.                                     *
+ *                                                                         *
+ * This program is distributed in the hope that it will be useful,         *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
+ * GNU General Public License for more details.                            *
+ *                                                                         *
+ * You should have received a copy of the GNU General Public License       *
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
+ **************************************************************************/
+
+#pragma once
+
+#include <QDebug>
+#include <QWebEngineView>
+
+#include "api/conversationmodel.h"
+
+class PrivateBridging : public QObject
+{
+    Q_OBJECT
+public:
+    explicit PrivateBridging(QObject* parent = nullptr) : QObject(parent) {};
+    ~PrivateBridging() {};
+
+    // exposed to JS through QWebChannel
+    Q_INVOKABLE int deleteInteraction(const QString& arg);
+    Q_INVOKABLE int retryInteraction(const QString& arg);
+    Q_INVOKABLE int openFile(const QString& arg);
+    Q_INVOKABLE int acceptFile(const QString& arg);
+    Q_INVOKABLE int refuseFile(const QString& arg);
+    Q_INVOKABLE int sendMessage(const QString & arg);
+    Q_INVOKABLE int sendFile();
+    Q_INVOKABLE int log(const QString& arg);
+
+};
+
+class MessageWebView : public QWebEngineView
+{
+    Q_OBJECT
+public:
+    explicit MessageWebView(QWidget* parent = nullptr);
+    ~MessageWebView();
+
+    void buildView();
+
+    void insertStyleSheet(const QString &name, const QString &source);
+    void removeStyleSheet(const QString &name);
+
+    void clear();
+    void setDisplayLinks(bool display);
+    void printNewInteraction(lrc::api::ConversationModel& conversationModel,
+                             uint64_t msgId,
+                             const lrc::api::interaction::Info& interaction);
+    void updateInteraction(lrc::api::ConversationModel& conversationModel,
+                           uint64_t msgId,
+                           const lrc::api::interaction::Info& interaction);
+    void removeInteraction(uint64_t interactionId);
+    void printHistory(lrc::api::ConversationModel& conversationModel,
+                      const std::map<uint64_t,
+                      lrc::api::interaction::Info> interactions);
+    void setSenderImage(const std::string& sender,
+                        const std::string& senderImage);
+    void setInvitation(bool show, const std::string& contactUri);
+    void hideMessages();
+
+private slots:
+    void slotLoadFinished();
+
+private:
+    QWebChannel* webChannel_;
+    PrivateBridging* jsBridge_;
+
+};