Open HTTP and HTTPS messages through the desktop URL handler
This commit is contained in:
1 parent
25116ac7a5
commit
b8ef1cdfcc
2 files changed
+18
-3
No files matched your search
@@ -38,6 +38,8 @@ extern "C" {
|
||||
#include <QClipboard>
|
||||
#include <QStyle>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
@@ -550,7 +552,7 @@ void MainWindow::setupConnects() {
|
||||
connect(m_accountList, &AccountList::pmRequested, this, &MainWindow::onPmRequested);
|
||||
connect(m_accountList, &AccountList::inviteRequested, this, &MainWindow::onInviteToPmRequested);
|
||||
connect(m_messageList, &MessageList::inviteRequested, this, &MainWindow::onInviteToPmRequested);
|
||||
connect(m_messageList, &MessageList::inviteLinkActivated, this, &MainWindow::onInviteLinkActivated);
|
||||
connect(m_messageList, &MessageList::linkActivated, this, &MainWindow::onMessageLinkActivated);
|
||||
connect(m_messageList, &MessageList::readPositionChanged,
|
||||
this, [this](const QString& channelId, qint64 lastReadMsgId) {
|
||||
Q_UNUSED(lastReadMsgId);
|
||||
@@ -695,7 +697,20 @@ void MainWindow::onInviteToPmRequested(const QString& source, quint64 peer, cons
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onInviteLinkActivated(const QString& link) {
|
||||
void MainWindow::onMessageLinkActivated(const QString& link) {
|
||||
if (!link.startsWith(QStringLiteral("utun://"))) {
|
||||
const QUrl url(link, QUrl::StrictMode);
|
||||
if (!url.isValid() || url.host().isEmpty() || (url.scheme() != "http" && url.scheme() != "https")) {
|
||||
GUI_ERROR("message link: invalid web address bytes=%d", (int)link.size());
|
||||
QMessageBox::warning(this, tr("Ссылка"), tr("Некорректная ссылка.")); return;
|
||||
}
|
||||
if (!QDesktopServices::openUrl(url)) {
|
||||
GUI_ERROR("message link: external open failed scheme=%s host=%s", qPrintable(url.scheme()), qPrintable(url.host()));
|
||||
QMessageBox::warning(this, tr("Ссылка"), tr("Не удалось открыть ссылку. Проверьте наличие браузера.")); return;
|
||||
}
|
||||
GUI_INFO("message link: external open requested scheme=%s host=%s", qPrintable(url.scheme()), qPrintable(url.host()));
|
||||
return;
|
||||
}
|
||||
const auto invite = decodeInviteLink(link);
|
||||
if (!invite.error.isEmpty()) {
|
||||
GUI_ERROR("invite link: invalid error=%s", qPrintable(invite.error));
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
/* DM (p2p чат) */
|
||||
void onPmRequested(const QString& chId, quint64 nodeId, const QString& name);
|
||||
void onInviteToPmRequested(const QString& source, quint64 peer, const QString& name);
|
||||
void onInviteLinkActivated(const QString& link);
|
||||
void onMessageLinkActivated(const QString& link);
|
||||
void onDmConvUpdated(const QString& convId);
|
||||
void onDmMsgReceived(const QString& convId, quint64 author);
|
||||
|
||||
|
||||
Reference in new issue
Block a user