From 53330daab739d5fec01e89639c1264354fbaccb9 Mon Sep 17 00:00:00 2001 From: sudden6 Date: Fri, 29 Jan 2016 23:30:07 +0100 Subject: [PATCH] toxme now supports proxies --- src/widget/form/addfriendform.cpp | 40 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/widget/form/addfriendform.cpp b/src/widget/form/addfriendform.cpp index 03d30c2bd..e5de57e48 100644 --- a/src/widget/form/addfriendform.cpp +++ b/src/widget/form/addfriendform.cpp @@ -109,29 +109,19 @@ void AddFriendForm::onSendTriggered() { 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 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 if (toxId.toString().isEmpty()) { @@ -139,10 +129,16 @@ Ignore the proxy and connect to the Internet directly?"), QMessageBox::Yes|QMess return; } } - emit friendRequested(toxId.toString(), getMessage()); - this->toxId.clear(); - this->message.clear(); + id = toxId.toString(); } + + 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)