1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

use toxcore error codes

This commit is contained in:
Сухарик 2015-05-25 23:09:09 +03:00
parent c3e70d6c59
commit fe7dc995d6

View File

@ -180,44 +180,50 @@ void Core::make_tox(QByteArray savedata)
}
}
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), nullptr);
if (tox == nullptr)
TOX_ERR_NEW tox_err;
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), &tox_err);
switch (tox_err)
{
if (enableIPv6) // Fallback to IPv4
case TOX_ERR_NEW_OK:
break;
case TOX_ERR_NEW_PORT_ALLOC:
if (enableIPv6)
{
toxOptions.ipv6_enabled = false;
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), nullptr);
if (tox == nullptr)
{
if (toxOptions.proxy_type != TOX_PROXY_TYPE_NONE)
{
qCritical() << "bad proxy! no toxcore!";
emit badProxy();
}
else
{
qCritical() << "Tox core failed to start";
emit failedToStart();
}
return;
}
else
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), &tox_err);
if (tox_err == TOX_ERR_NEW_OK)
{
qWarning() << "Core failed to start with IPv6, falling back to IPv4. LAN discovery may not work properly.";
break;
}
}
else if (toxOptions.proxy_type != TOX_PROXY_TYPE_NONE)
{
qCritical() << "can't to bind the port";
emit failedToStart();
return;
case TOX_ERR_NEW_PROXY_BAD_HOST:
case TOX_ERR_NEW_PROXY_BAD_PORT:
qCritical() << "bad proxy";
emit badProxy();
return;
}
else
{
case TOX_ERR_NEW_PROXY_NOT_FOUND:
qCritical() << "proxy not found";
emit badProxy();
return;
case TOX_ERR_NEW_LOAD_ENCRYPTED:
qCritical() << "load data is encrypted";
emit failedToStart();
return;
case TOX_ERR_NEW_LOAD_BAD_FORMAT:
qCritical() << "bad load data format";
emit failedToStart();
return;
default:
qCritical() << "Tox core failed to start";
emit failedToStart();
return;
}
}
toxav = toxav_new(tox, TOXAV_MAX_CALLS);
if (toxav == nullptr)