diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index c73e7abc5..a6536406e 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -27,11 +27,16 @@ #include "src/video/corevideosource.h" #include "src/video/videoframe.h" #include "util/compatiblerecursivemutex.h" +#include "util/toxcoreerrorparser.h" + #include #include #include #include #include + +#include + #include /** @@ -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); diff --git a/util/include/util/toxcoreerrorparser.h b/util/include/util/toxcoreerrorparser.h index 55ae0e815..418e99cb2 100644 --- a/util/include/util/toxcoreerrorparser.h +++ b/util/include/util/toxcoreerrorparser.h @@ -22,6 +22,7 @@ #include #include +#include /** * @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 diff --git a/util/src/toxcoreerrorparser.cpp b/util/src/toxcoreerrorparser.cpp index 333fb2c05..c53f69cd6 100644 --- a/util/src/toxcoreerrorparser.cpp +++ b/util/src/toxcoreerrorparser.cpp @@ -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; +}