Browse Source

use toxcore error codes

pull/1733/head
Сухарик 10 years ago
parent
commit
fe7dc995d6
  1. 60
      src/core/core.cpp

60
src/core/core.cpp

@ -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
{
qWarning() << "Core failed to start with IPv6, falling back to IPv4. LAN discovery may not work properly.";
} }
}
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(); 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);

Loading…
Cancel
Save