mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
chore: log self and friends network connection type
This commit is contained in:
parent
ef47c00c8d
commit
7a683fa5c2
|
@ -757,9 +757,27 @@ bool Core::checkConnection()
|
|||
{
|
||||
ASSERT_CORE_THREAD;
|
||||
static bool isConnected = false;
|
||||
bool toxConnected = tox_self_get_connection_status(tox.get()) != TOX_CONNECTION_NONE;
|
||||
auto selfConnection = tox_self_get_connection_status(tox.get());
|
||||
QString connectionName;
|
||||
bool toxConnected = false;
|
||||
switch (selfConnection)
|
||||
{
|
||||
case TOX_CONNECTION_NONE:
|
||||
toxConnected = false;
|
||||
break;
|
||||
case TOX_CONNECTION_TCP:
|
||||
toxConnected = true;
|
||||
connectionName = "a TCP relay";
|
||||
break;
|
||||
case TOX_CONNECTION_UDP:
|
||||
toxConnected = true;
|
||||
connectionName = "the UDP DHT";
|
||||
break;
|
||||
qWarning() << "tox_self_get_connection_status returned unknown enum!";
|
||||
}
|
||||
|
||||
if (toxConnected && !isConnected) {
|
||||
qDebug() << "Connected to the DHT";
|
||||
qDebug().noquote() << "Connected to" << connectionName;
|
||||
emit connected();
|
||||
} else if (!toxConnected && isConnected) {
|
||||
qDebug() << "Disconnected from the DHT";
|
||||
|
@ -882,8 +900,24 @@ void Core::onUserStatusChanged(Tox*, uint32_t friendId, Tox_User_Status userstat
|
|||
void Core::onConnectionStatusChanged(Tox*, uint32_t friendId, Tox_Connection status, void* vCore)
|
||||
{
|
||||
Core* core = static_cast<Core*>(vCore);
|
||||
Status::Status friendStatus =
|
||||
status != TOX_CONNECTION_NONE ? Status::Status::Online : Status::Status::Offline;
|
||||
Status::Status friendStatus;
|
||||
switch (status)
|
||||
{
|
||||
case TOX_CONNECTION_NONE:
|
||||
friendStatus = Status::Status::Offline;
|
||||
qDebug() << "Disconnected from friend" << friendId;
|
||||
break;
|
||||
case TOX_CONNECTION_TCP:
|
||||
friendStatus = Status::Status::Online;
|
||||
qDebug() << "Connected to friend" << friendId << "through a TCP relay";
|
||||
break;
|
||||
case TOX_CONNECTION_UDP:
|
||||
friendStatus = Status::Status::Online;
|
||||
qDebug() << "Connected to friend" << friendId << "directly with UDP";
|
||||
break;
|
||||
qWarning() << "tox_callback_friend_connection_status returned unknown enum!";
|
||||
}
|
||||
|
||||
// Ignore Online because it will be emited from onUserStatusChanged
|
||||
bool isOffline = friendStatus == Status::Status::Offline;
|
||||
if (isOffline) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user