Browse Source

fix: Don't even try to add ourselves as a friend in the Tox URI handler

pull/4183/head
tux3 9 years ago
parent
commit
bfda028a2a
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 20
      src/net/toxuri.cpp

20
src/net/toxuri.cpp

@ -79,9 +79,10 @@ bool handleToxURI(const QString &toxURI) @@ -79,9 +79,10 @@ bool handleToxURI(const QString &toxURI)
toxId = Toxme::lookup(toxaddr);
if (!toxId.isValid())
{
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning, "qTox",
QMessageBox::tr("%1 is not a valid Toxme address.")
.arg(toxaddr), QMessageBox::Ok, nullptr);
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
QMessageBox::tr("Couldn't add friend"),
QMessageBox::tr("%1 is not a valid Toxme address.")
.arg(toxaddr), QMessageBox::Ok, nullptr);
messageBox->setButtonText(QMessageBox::Ok, QMessageBox::tr("Ok"));
QObject::connect(messageBox, &QMessageBox::finished, messageBox, &QMessageBox::deleteLater);
messageBox->show();
@ -89,6 +90,19 @@ bool handleToxURI(const QString &toxURI) @@ -89,6 +90,19 @@ bool handleToxURI(const QString &toxURI)
}
}
if (toxId == core->getSelfId())
{
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
QMessageBox::tr("Couldn't add friend"),
QMessageBox::tr("You can't add yourself as a friend!",
"When trying to add your own Tox ID as friend"),
QMessageBox::Ok, nullptr);
messageBox->setButtonText(QMessageBox::Ok, QMessageBox::tr("Ok"));
QObject::connect(messageBox, &QMessageBox::finished, messageBox, &QMessageBox::deleteLater);
messageBox->show();
return false;
}
ToxURIDialog *dialog = new ToxURIDialog(0, toxaddr, QObject::tr("%1 here! Tox me maybe?",
"Default message in Tox URI friend requests. Write something appropriate!")
.arg(Nexus::getCore()->getUsername()));

Loading…
Cancel
Save