mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(core): Add error parsing for Toxav_Err_Call_Control
This commit is contained in:
parent
6c9c380915
commit
47a20f6061
|
@ -27,11 +27,16 @@
|
|||
#include "src/video/corevideosource.h"
|
||||
#include "src/video/videoframe.h"
|
||||
#include "util/compatiblerecursivemutex.h"
|
||||
#include "util/toxcoreerrorparser.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include <tox/toxav.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
/**
|
||||
|
@ -266,7 +271,9 @@ bool CoreAV::answerCall(uint32_t friendNum, bool video)
|
|||
return true;
|
||||
} else {
|
||||
qWarning() << "Failed to answer call with error" << err;
|
||||
toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, nullptr);
|
||||
Toxav_Err_Call_Control controlErr;
|
||||
toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, &controlErr);
|
||||
PARSE_ERR(controlErr);
|
||||
calls.erase(it);
|
||||
return false;
|
||||
}
|
||||
|
@ -306,8 +313,9 @@ bool CoreAV::cancelCall(uint32_t friendNum)
|
|||
QMutexLocker coreLocker{&coreLock};
|
||||
|
||||
qDebug() << QString("Cancelling call with %1").arg(friendNum);
|
||||
if (!toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, nullptr)) {
|
||||
qWarning() << QString("Failed to cancel call with %1").arg(friendNum);
|
||||
Toxav_Err_Call_Control err;
|
||||
toxav_call_control(toxav.get(), friendNum, TOXAV_CALL_CONTROL_CANCEL, &err);
|
||||
if (!PARSE_ERR(err)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -735,7 +743,9 @@ void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool vid
|
|||
auto it = self->calls.emplace(friendNum, std::move(call));
|
||||
if (it.second == false) {
|
||||
qWarning() << QString("Rejecting call invite from %1, we're already in that call!").arg(friendNum);
|
||||
toxav_call_control(toxav, friendNum, TOXAV_CALL_CONTROL_CANCEL, nullptr);
|
||||
Toxav_Err_Call_Control err;
|
||||
toxav_call_control(toxav, friendNum, TOXAV_CALL_CONTROL_CANCEL, &err);
|
||||
PARSE_ERR(err);
|
||||
return;
|
||||
}
|
||||
qDebug() << QString("Received call invite from %1").arg(friendNum);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include <tox/tox.h>
|
||||
#include <tox/toxav.h>
|
||||
|
||||
/**
|
||||
* @brief Parse and log toxcore error enums.
|
||||
|
@ -54,4 +55,5 @@ namespace ToxcoreErrorParser {
|
|||
bool parseErr(Tox_Err_File_Get error, int line);
|
||||
bool parseErr(Tox_Err_File_Send error, int line);
|
||||
bool parseErr(Tox_Err_File_Send_Chunk error, int line);
|
||||
bool parseErr(Toxav_Err_Call_Control error, int line);
|
||||
} // namespace ToxcoreErrorParser
|
||||
|
|
|
@ -543,3 +543,29 @@ bool ToxcoreErrorParser::parseErr(Tox_Err_File_Send_Chunk error, int line)
|
|||
qCritical() << line << "Unknown Tox_Err_File_Send_Chunk error code:" << error;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToxcoreErrorParser::parseErr(Toxav_Err_Call_Control error, int line)
|
||||
{
|
||||
switch (error) {
|
||||
case TOXAV_ERR_CALL_CONTROL_OK:
|
||||
return true;
|
||||
|
||||
case TOXAV_ERR_CALL_CONTROL_SYNC:
|
||||
qCritical() << line << ": Synchronization error occurred.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND:
|
||||
qCritical() << line << ": The friend_number passed did not designate a valid friend.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL:
|
||||
qCritical() << line << ": This client is currently not in a call with the friend.";
|
||||
return false;
|
||||
|
||||
case TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION:
|
||||
qCritical() << line << ": Call already paused or resumed.";
|
||||
return false;
|
||||
}
|
||||
qCritical() << line << "Unknown Toxav_Err_Call_Control error code:" << error;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user