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

Merge branch 'pr1733'

This commit is contained in:
tux3 2015-05-25 22:22:57 +02:00
commit 4a8bc7a0ce
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -180,43 +180,49 @@ void Core::make_tox(QByteArray savedata)
} }
} }
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), nullptr); TOX_ERR_NEW tox_err;
if (tox == nullptr) 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;
toxOptions.ipv6_enabled = false; case TOX_ERR_NEW_PORT_ALLOC:
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), nullptr); if (enableIPv6)
if (tox == nullptr)
{ {
if (toxOptions.proxy_type != TOX_PROXY_TYPE_NONE) toxOptions.ipv6_enabled = false;
tox = tox_new(&toxOptions, (uint8_t*)savedata.data(), savedata.size(), &tox_err);
if (tox_err == TOX_ERR_NEW_OK)
{ {
qCritical() << "bad proxy! no toxcore!"; qWarning() << "Core failed to start with IPv6, falling back to IPv4. LAN discovery may not work properly.";
emit badProxy(); break;
} }
else
{
qCritical() << "Tox core failed to start";
emit failedToStart();
}
return;
} }
else
{ qCritical() << "can't to bind the port";
qWarning() << "Core failed to start with IPv6, falling back to IPv4. LAN discovery may not work properly."; emit failedToStart();
} return;
} case TOX_ERR_NEW_PROXY_BAD_HOST:
else if (toxOptions.proxy_type != TOX_PROXY_TYPE_NONE) case TOX_ERR_NEW_PROXY_BAD_PORT:
{ qCritical() << "bad proxy";
emit badProxy(); emit badProxy();
return; return;
} case TOX_ERR_NEW_PROXY_NOT_FOUND:
else 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"; qCritical() << "Tox core failed to start";
emit failedToStart(); emit failedToStart();
return; return;
}
} }
toxav = toxav_new(tox, TOXAV_MAX_CALLS); toxav = toxav_new(tox, TOXAV_MAX_CALLS);