|
|
|
|
@ -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)); |
|
|
|
|
|