blob: 3096cf7d871df2ab56e43589d66885353797c9d4 [file] [log] [blame]
Andreas Traczyk43c08232018-10-31 13:42:09 -04001/***************************************************************************
Sébastien Blin68abac92019-01-02 17:41:31 -05002 * Copyright (C) 2019-2019 by Savoir-faire Linux *
Andreas Traczyk43c08232018-10-31 13:42:09 -04003 * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#pragma once
20
21#include <QDebug>
22#include <QWebEngineView>
23
24#include "api/conversationmodel.h"
25
26class PrivateBridging : public QObject
27{
28 Q_OBJECT
29public:
30 explicit PrivateBridging(QObject* parent = nullptr) : QObject(parent) {};
31 ~PrivateBridging() {};
32
33 // exposed to JS through QWebChannel
34 Q_INVOKABLE int deleteInteraction(const QString& arg);
35 Q_INVOKABLE int retryInteraction(const QString& arg);
36 Q_INVOKABLE int openFile(const QString& arg);
37 Q_INVOKABLE int acceptFile(const QString& arg);
38 Q_INVOKABLE int refuseFile(const QString& arg);
39 Q_INVOKABLE int sendMessage(const QString & arg);
40 Q_INVOKABLE int sendFile();
41 Q_INVOKABLE int log(const QString& arg);
Sébastien Blin942d1022018-12-13 09:49:03 -050042 Q_INVOKABLE int acceptInvitation();
43 Q_INVOKABLE int refuseInvitation();
44 Q_INVOKABLE int blockConversation();
Andreas Traczyk43c08232018-10-31 13:42:09 -040045};
46
47class MessageWebView : public QWebEngineView
48{
49 Q_OBJECT
50public:
51 explicit MessageWebView(QWidget* parent = nullptr);
52 ~MessageWebView();
53
54 void buildView();
55
56 void insertStyleSheet(const QString &name, const QString &source);
57 void removeStyleSheet(const QString &name);
58
59 void clear();
60 void setDisplayLinks(bool display);
61 void printNewInteraction(lrc::api::ConversationModel& conversationModel,
62 uint64_t msgId,
63 const lrc::api::interaction::Info& interaction);
64 void updateInteraction(lrc::api::ConversationModel& conversationModel,
65 uint64_t msgId,
66 const lrc::api::interaction::Info& interaction);
67 void removeInteraction(uint64_t interactionId);
68 void printHistory(lrc::api::ConversationModel& conversationModel,
69 const std::map<uint64_t,
Andreas Traczyk43865372018-12-27 12:12:35 -050070 lrc::api::interaction::Info> interactions,
71 bool fadeIn = false);
Andreas Traczyk43c08232018-10-31 13:42:09 -040072 void setSenderImage(const std::string& sender,
73 const std::string& senderImage);
Andreas Traczyk43865372018-12-27 12:12:35 -050074 void setInvitation(bool show,
75 const std::string& contactUri = "",
76 const std::string& contactId = "");
Andreas Traczyk43c08232018-10-31 13:42:09 -040077 void hideMessages();
78
Andreas Traczyk43865372018-12-27 12:12:35 -050079signals:
80 void conversationRemoved();
81
Andreas Traczyk43c08232018-10-31 13:42:09 -040082private slots:
83 void slotLoadFinished();
84
85private:
86 QWebChannel* webChannel_;
87 PrivateBridging* jsBridge_;
88
89};