mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
calculate tox id length from definition in tox.h instead of setting it manually
This commit is contained in:
parent
a7b243fe14
commit
4372fea9ea
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include <QFont>
|
||||
#include <QMessageBox>
|
||||
#include <tox/tox.h>
|
||||
|
||||
#define TOX_ID_SIZE 76
|
||||
#define TOX_ID_LENGTH 2*TOX_FRIEND_ADDRESS_SIZE
|
||||
|
||||
AddFriendForm::AddFriendForm() : dns(this)
|
||||
{
|
||||
|
@ -50,7 +51,7 @@ void AddFriendForm::show(Ui::Widget &ui)
|
|||
bool AddFriendForm::isToxId(const QString &value) const
|
||||
{
|
||||
const QRegularExpression hexRegExp("^[A-Fa-f0-9]+$");
|
||||
return value.length() == TOX_ID_SIZE && value.contains(hexRegExp);
|
||||
return value.length() == TOX_ID_LENGTH && value.contains(hexRegExp);
|
||||
}
|
||||
|
||||
void AddFriendForm::showWarning(const QString &message) const
|
||||
|
@ -117,12 +118,12 @@ void AddFriendForm::handleDnsLookup()
|
|||
}
|
||||
|
||||
idx += idKeyWord.length();
|
||||
if (entry.length() < idx + static_cast<int>(TOX_ID_SIZE)) {
|
||||
if (entry.length() < idx + static_cast<int>(TOX_ID_LENGTH)) {
|
||||
showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS"));
|
||||
return;
|
||||
}
|
||||
|
||||
const QString friendAdress = entry.mid(idx, TOX_ID_SIZE);
|
||||
const QString friendAdress = entry.mid(idx, TOX_ID_LENGTH);
|
||||
if (!isToxId(friendAdress)) {
|
||||
showWarning(tr("The DNS lookup does not contain a valid Tox ID", "Error with the DNS"));
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user