mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr2894'
This commit is contained in:
commit
7a846b85e0
@ -108,6 +108,7 @@ AutoUpdater::VersionInfo AutoUpdater::getUpdateVersion()
|
|||||||
return versionInfo;
|
return versionInfo;
|
||||||
|
|
||||||
QNetworkAccessManager *manager = new QNetworkAccessManager;
|
QNetworkAccessManager *manager = new QNetworkAccessManager;
|
||||||
|
manager->setProxy(Settings::getInstance().getProxy());
|
||||||
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(checkURI)));
|
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(checkURI)));
|
||||||
while (!reply->isFinished())
|
while (!reply->isFinished())
|
||||||
{
|
{
|
||||||
@ -222,6 +223,7 @@ QByteArray AutoUpdater::getUpdateFlist()
|
|||||||
QByteArray flist;
|
QByteArray flist;
|
||||||
|
|
||||||
QNetworkAccessManager *manager = new QNetworkAccessManager;
|
QNetworkAccessManager *manager = new QNetworkAccessManager;
|
||||||
|
manager->setProxy(Settings::getInstance().getProxy());
|
||||||
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(flistURI)));
|
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(flistURI)));
|
||||||
while (!reply->isFinished())
|
while (!reply->isFinished())
|
||||||
{
|
{
|
||||||
@ -278,6 +280,7 @@ AutoUpdater::UpdateFile AutoUpdater::getUpdateFile(UpdateFileMeta fileMeta,
|
|||||||
file.metadata = fileMeta;
|
file.metadata = fileMeta;
|
||||||
|
|
||||||
QNetworkAccessManager *manager = new QNetworkAccessManager;
|
QNetworkAccessManager *manager = new QNetworkAccessManager;
|
||||||
|
manager->setProxy(Settings::getInstance().getProxy());
|
||||||
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(filesURI+fileMeta.id)));
|
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(filesURI+fileMeta.id)));
|
||||||
QObject::connect(reply, &QNetworkReply::downloadProgress, progressCallback);
|
QObject::connect(reply, &QNetworkReply::downloadProgress, progressCallback);
|
||||||
while (!reply->isFinished())
|
while (!reply->isFinished())
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "toxme.h"
|
#include "toxme.h"
|
||||||
#include "src/core/core.h"
|
#include "src/core/core.h"
|
||||||
|
#include <src/persistence/settings.h>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -35,6 +36,7 @@ QByteArray Toxme::makeJsonRequest(QString url, QString json, QNetworkReply::Netw
|
|||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
|
||||||
QNetworkAccessManager netman;
|
QNetworkAccessManager netman;
|
||||||
|
netman.setProxy(Settings::getInstance().getProxy());
|
||||||
QNetworkRequest request{url};
|
QNetworkRequest request{url};
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply* reply = netman.post(request,json.toUtf8());
|
QNetworkReply* reply = netman.post(request,json.toUtf8());
|
||||||
@ -62,6 +64,7 @@ QByteArray Toxme::getServerPubkey(QString url, QNetworkReply::NetworkError &erro
|
|||||||
|
|
||||||
// Get key
|
// Get key
|
||||||
QNetworkAccessManager netman;
|
QNetworkAccessManager netman;
|
||||||
|
netman.setProxy(Settings::getInstance().getProxy());
|
||||||
QNetworkRequest request{url};
|
QNetworkRequest request{url};
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply* reply = netman.get(request);
|
QNetworkReply* reply = netman.get(request);
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
|
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
|
||||||
|
|
||||||
@ -777,6 +778,29 @@ void Settings::setForceTCP(bool newValue)
|
|||||||
forceTCP = newValue;
|
forceTCP = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QNetworkProxy Settings::getProxy() const
|
||||||
|
{
|
||||||
|
QNetworkProxy proxy;
|
||||||
|
switch(Settings::getProxyType())
|
||||||
|
{
|
||||||
|
case ProxyType::ptNone:
|
||||||
|
proxy.setType(QNetworkProxy::NoProxy);
|
||||||
|
break;
|
||||||
|
case ProxyType::ptSOCKS5:
|
||||||
|
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||||
|
break;
|
||||||
|
case ProxyType::ptHTTP:
|
||||||
|
proxy.setType(QNetworkProxy::HttpProxy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
proxy.setType(QNetworkProxy::NoProxy);
|
||||||
|
qWarning() << "Invalid Proxy type, setting to NoProxy";
|
||||||
|
}
|
||||||
|
proxy.setHostName(Settings::getProxyAddr());
|
||||||
|
proxy.setPort(Settings::getProxyPort());
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
ProxyType Settings::getProxyType() const
|
ProxyType Settings::getProxyType() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
|
#include <QNetworkProxy>
|
||||||
#include "src/core/corestructs.h"
|
#include "src/core/corestructs.h"
|
||||||
|
|
||||||
class ToxId;
|
class ToxId;
|
||||||
@ -109,6 +110,8 @@ public:
|
|||||||
bool getForceTCP() const;
|
bool getForceTCP() const;
|
||||||
void setForceTCP(bool newValue);
|
void setForceTCP(bool newValue);
|
||||||
|
|
||||||
|
QNetworkProxy getProxy() const;
|
||||||
|
|
||||||
QString getProxyAddr() const;
|
QString getProxyAddr() const;
|
||||||
void setProxyAddr(const QString& newValue);
|
void setProxyAddr(const QString& newValue);
|
||||||
|
|
||||||
|
@ -109,29 +109,19 @@ void AddFriendForm::onSendTriggered()
|
|||||||
{
|
{
|
||||||
QString id = toxId.text().trimmed();
|
QString id = toxId.text().trimmed();
|
||||||
|
|
||||||
if (ToxId::isToxId(id))
|
if (!ToxId::isToxId(id))
|
||||||
{
|
{
|
||||||
if (id.toUpper() == Core::getInstance()->getSelfId().toString().toUpper())
|
|
||||||
GUI::showWarning(tr("Couldn't add friend"), tr("You can't add yourself as a friend!","When trying to add your own Tox ID as friend"));
|
|
||||||
else
|
|
||||||
emit friendRequested(id, getMessage());
|
|
||||||
|
|
||||||
this->toxId.clear();
|
|
||||||
this->message.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Settings::getInstance().getProxyType() != ProxyType::ptNone)
|
|
||||||
{
|
|
||||||
QMessageBox::StandardButton btn = QMessageBox::warning(main, "qTox", tr("qTox needs to use the Tox DNS, but can't do it through a proxy.\n\
|
|
||||||
Ignore the proxy and connect to the Internet directly?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
|
||||||
if (btn != QMessageBox::Yes)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ToxId toxId = Toxme::lookup(id); // Try Toxme
|
ToxId toxId = Toxme::lookup(id); // Try Toxme
|
||||||
if (toxId.toString().isEmpty()) // If it isn't supported
|
if (toxId.toString().isEmpty()) // If it isn't supported
|
||||||
{
|
{
|
||||||
|
qDebug() << "Toxme didn't return a ToxID, trying ToxDNS";
|
||||||
|
if (Settings::getInstance().getProxyType() != ProxyType::ptNone)
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton btn = QMessageBox::warning(main, "qTox", tr("qTox needs to use the Tox DNS, but can't do it through a proxy.\n\
|
||||||
|
Ignore the proxy and connect to the Internet directly?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
||||||
|
if (btn != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
}
|
||||||
toxId = ToxDNS::resolveToxAddress(id, true); // Use ToxDNS
|
toxId = ToxDNS::resolveToxAddress(id, true); // Use ToxDNS
|
||||||
if (toxId.toString().isEmpty())
|
if (toxId.toString().isEmpty())
|
||||||
{
|
{
|
||||||
@ -139,10 +129,16 @@ Ignore the proxy and connect to the Internet directly?"), QMessageBox::Yes|QMess
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit friendRequested(toxId.toString(), getMessage());
|
id = toxId.toString();
|
||||||
this->toxId.clear();
|
|
||||||
this->message.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id.toUpper() == Core::getInstance()->getSelfId().toString().toUpper())
|
||||||
|
GUI::showWarning(tr("Couldn't add friend"), tr("You can't add yourself as a friend!","When trying to add your own Tox ID as friend"));
|
||||||
|
else
|
||||||
|
emit friendRequested(id, getMessage());
|
||||||
|
|
||||||
|
this->toxId.clear();
|
||||||
|
this->message.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFriendForm::onIdChanged(const QString &id)
|
void AddFriendForm::onIdChanged(const QString &id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user