From cc6df2c294d6a8d70f88790d9c66eee5e869adb4 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Tue, 28 Aug 2018 22:34:05 -0700 Subject: [PATCH] chore(core): use new toxcore enum typenames Fix #5287 --- INSTALL.fa.md | 2 +- INSTALL.md | 2 +- src/core/core.cpp | 46 ++++++++++++++++++++--------------------- src/core/core.h | 16 +++++++------- src/core/coreav.cpp | 4 ++-- src/core/corefile.cpp | 4 ++-- src/core/corefile.h | 2 +- src/core/toxlogger.cpp | 2 +- src/core/toxlogger.h | 2 +- src/core/toxoptions.cpp | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/INSTALL.fa.md b/INSTALL.fa.md index e5eb85865..995c2a6a8 100644 --- a/INSTALL.fa.md +++ b/INSTALL.fa.md @@ -49,7 +49,7 @@ |---------------|-------------|----------------------------------------------------------| | [Qt] | >= 5.5.0 | concurrent, core, gui, network, opengl, svg, widget, xml | | [GCC]/[MinGW] | >= 4.8 | C++11 enabled | -| [toxcore] | = 0.1.\* | core, av | +| [toxcore] | >= 0.2.6 | core, av | | [FFmpeg] | >= 2.6.0 | avformat, avdevice, avcodec, avutil, swscale | | [CMake] | >= 2.8.11 | | | [OpenAL Soft] | >= 1.16.0 | | diff --git a/INSTALL.md b/INSTALL.md index 81eee6636..d95c653d5 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -38,7 +38,7 @@ |---------------|-------------|----------------------------------------------------------| | [Qt] | >= 5.5.0 | concurrent, core, gui, network, opengl, svg, widget, xml | | [GCC]/[MinGW] | >= 4.8 | C++11 enabled | -| [toxcore] | = 0.1.\* | core, av | +| [toxcore] | >= 0.2.6 | core, av | | [FFmpeg] | >= 2.6.0 | avformat, avdevice, avcodec, avutil, swscale | | [CMake] | >= 2.8.11 | | | [OpenAL Soft] | >= 1.16.0 | | diff --git a/src/core/core.cpp b/src/core/core.cpp index 7751767d7..45fbbaf6e 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -132,7 +132,7 @@ ToxCorePtr Core::makeToxCore(const QByteArray& savedata, const ICoreSettings* co return {}; } - TOX_ERR_NEW tox_err; + Tox_Err_New tox_err; core->tox = ToxPtr(tox_new(*toxOptions, &tox_err)); switch (tox_err) { @@ -400,7 +400,7 @@ void Core::onFriendRequest(Tox*, const uint8_t* cFriendPk, const uint8_t* cMessa emit static_cast(core)->friendRequestReceived(friendPk, requestMessage); } -void Core::onFriendMessage(Tox*, uint32_t friendId, TOX_MESSAGE_TYPE type, const uint8_t* cMessage, +void Core::onFriendMessage(Tox*, uint32_t friendId, Tox_Message_Type type, const uint8_t* cMessage, size_t cMessageSize, void* core) { bool isAction = (type == TOX_MESSAGE_TYPE_ACTION); @@ -426,7 +426,7 @@ void Core::onStatusMessageChanged(Tox*, uint32_t friendId, const uint8_t* cMessa emit static_cast(core)->friendStatusMessageChanged(friendId, message); } -void Core::onUserStatusChanged(Tox*, uint32_t friendId, TOX_USER_STATUS userstatus, void* core) +void Core::onUserStatusChanged(Tox*, uint32_t friendId, Tox_User_Status userstatus, void* core) { Status status; switch (userstatus) { @@ -446,7 +446,7 @@ void Core::onUserStatusChanged(Tox*, uint32_t friendId, TOX_USER_STATUS userstat emit static_cast(core)->friendStatusChanged(friendId, status); } -void Core::onConnectionStatusChanged(Tox*, uint32_t friendId, TOX_CONNECTION status, void* core) +void Core::onConnectionStatusChanged(Tox*, uint32_t friendId, Tox_Connection status, void* core) { Status friendStatus = status != TOX_CONNECTION_NONE ? Status::Online : Status::Offline; // Ignore Online because it will be emited from onUserStatusChanged @@ -458,7 +458,7 @@ void Core::onConnectionStatusChanged(Tox*, uint32_t friendId, TOX_CONNECTION sta } } -void Core::onGroupInvite(Tox* tox, uint32_t friendId, TOX_CONFERENCE_TYPE type, +void Core::onGroupInvite(Tox* tox, uint32_t friendId, Tox_Conference_Type type, const uint8_t* cookie, size_t length, void* vCore) { Core* core = static_cast(vCore); @@ -491,7 +491,7 @@ void Core::onGroupInvite(Tox* tox, uint32_t friendId, TOX_CONFERENCE_TYPE type, } } -void Core::onGroupMessage(Tox*, uint32_t groupId, uint32_t peerId, TOX_MESSAGE_TYPE type, +void Core::onGroupMessage(Tox*, uint32_t groupId, uint32_t peerId, Tox_Message_Type type, const uint8_t* cMessage, size_t length, void* vCore) { Core* core = static_cast(vCore); @@ -648,7 +648,7 @@ void Core::sendTyping(uint32_t friendId, bool typing) } } -bool parseConferenceSendMessageError(TOX_ERR_CONFERENCE_SEND_MESSAGE error) +bool parseConferenceSendMessageError(Tox_Err_Conference_Send_Message error) { switch (error) { case TOX_ERR_CONFERENCE_SEND_MESSAGE_OK: @@ -671,12 +671,12 @@ bool parseConferenceSendMessageError(TOX_ERR_CONFERENCE_SEND_MESSAGE error) return false; default: - qCritical() << "Unknown TOX_ERR_CONFERENCE_SEND_MESSAGE error"; + qCritical() << "Unknown Tox_Err_Conference_Send_Message error"; return false; } } -void Core::sendGroupMessageWithType(int groupId, const QString& message, TOX_MESSAGE_TYPE type) +void Core::sendGroupMessageWithType(int groupId, const QString& message, Tox_Message_Type type) { QMutexLocker ml{coreLoopLock.get()}; @@ -684,7 +684,7 @@ void Core::sendGroupMessageWithType(int groupId, const QString& message, TOX_MES for (auto& part : cMessages) { ToxString cMsg(part); - TOX_ERR_CONFERENCE_SEND_MESSAGE error; + Tox_Err_Conference_Send_Message error; bool ok = tox_conference_send_message(tox.get(), groupId, type, cMsg.data(), cMsg.size(), &error); if (!ok || !parseConferenceSendMessageError(error)) { @@ -713,7 +713,7 @@ void Core::changeGroupTitle(int groupId, const QString& title) QMutexLocker ml{coreLoopLock.get()}; ToxString cTitle(title); - TOX_ERR_CONFERENCE_TITLE error; + Tox_Err_Conference_Title error; bool success = tox_conference_set_title(tox.get(), groupId, cTitle.data(), cTitle.size(), &error); if (success && error == TOX_ERR_CONFERENCE_TITLE_OK) { emit groupTitleChanged(groupId, getUsername(), title); @@ -820,7 +820,7 @@ void Core::removeGroup(int groupId, bool fake) return; } - TOX_ERR_CONFERENCE_DELETE error; + Tox_Err_Conference_Delete error; bool success = tox_conference_delete(tox.get(), groupId, &error); if (success && error == TOX_ERR_CONFERENCE_DELETE_OK) { av->leaveGroupCall(groupId); @@ -974,7 +974,7 @@ void Core::setStatus(Status status) { QMutexLocker ml{coreLoopLock.get()}; - TOX_USER_STATUS userstatus; + Tox_User_Status userstatus; switch (status) { case Status::Online: userstatus = TOX_USER_STATUS_NONE; @@ -1079,7 +1079,7 @@ QVector Core::getFriendList() const * @param error Error to handle. * @return True if no error, false otherwise. */ -bool Core::parsePeerQueryError(TOX_ERR_CONFERENCE_PEER_QUERY error) const +bool Core::parsePeerQueryError(Tox_Err_Conference_Peer_Query error) const { switch (error) { case TOX_ERR_CONFERENCE_PEER_QUERY_OK: @@ -1111,7 +1111,7 @@ uint32_t Core::getGroupNumberPeers(int groupId) const { QMutexLocker ml{coreLoopLock.get()}; - TOX_ERR_CONFERENCE_PEER_QUERY error; + Tox_Err_Conference_Peer_Query error; uint32_t count = tox_conference_peer_count(tox.get(), groupId, &error); if (!parsePeerQueryError(error)) { return std::numeric_limits::max(); @@ -1127,7 +1127,7 @@ QString Core::getGroupPeerName(int groupId, int peerId) const { QMutexLocker ml{coreLoopLock.get()}; - TOX_ERR_CONFERENCE_PEER_QUERY error; + Tox_Err_Conference_Peer_Query error; size_t length = tox_conference_peer_get_name_size(tox.get(), groupId, peerId, &error); if (!parsePeerQueryError(error)) { return QString{}; @@ -1152,7 +1152,7 @@ ToxPk Core::getGroupPeerPk(int groupId, int peerId) const QMutexLocker ml{coreLoopLock.get()}; uint8_t friendPk[TOX_PUBLIC_KEY_SIZE] = {0x00}; - TOX_ERR_CONFERENCE_PEER_QUERY error; + Tox_Err_Conference_Peer_Query error; bool success = tox_conference_peer_get_public_key(tox.get(), groupId, peerId, friendPk, &error); if (!parsePeerQueryError(error) || !success) { qWarning() << "getGroupPeerToxId: Unknown error"; @@ -1180,7 +1180,7 @@ QStringList Core::getGroupPeerNames(int groupId) const return {}; } - TOX_ERR_CONFERENCE_PEER_QUERY error; + Tox_Err_Conference_Peer_Query error; uint32_t count = tox_conference_peer_count(tox.get(), groupId, &error); if (!parsePeerQueryError(error)) { return {}; @@ -1214,7 +1214,7 @@ QStringList Core::getGroupPeerNames(int groupId) const * @param error Error to handle. * @return True if no error, false otherwise. */ -bool Core::parseConferenceJoinError(TOX_ERR_CONFERENCE_JOIN error) const +bool Core::parseConferenceJoinError(Tox_Err_Conference_Join error) const { switch (error) { case TOX_ERR_CONFERENCE_JOIN_OK: @@ -1268,7 +1268,7 @@ uint32_t Core::joinGroupchat(const GroupInvite& inviteInfo) const switch (confType) { case TOX_CONFERENCE_TYPE_TEXT: { qDebug() << QString("Trying to join text groupchat invite sent by friend %1").arg(friendId); - TOX_ERR_CONFERENCE_JOIN error; + Tox_Err_Conference_Join error; uint32_t groupId = tox_conference_join(tox.get(), friendId, cookie, cookieLength, &error); return parseConferenceJoinError(error) ? groupId : std::numeric_limits::max(); } @@ -1290,7 +1290,7 @@ void Core::groupInviteFriend(uint32_t friendId, int groupId) { QMutexLocker ml{coreLoopLock.get()}; - TOX_ERR_CONFERENCE_INVITE error; + Tox_Err_Conference_Invite error; tox_conference_invite(tox.get(), friendId, groupId, &error); switch (error) { @@ -1315,7 +1315,7 @@ int Core::createGroup(uint8_t type) QMutexLocker ml{coreLoopLock.get()}; if (type == TOX_CONFERENCE_TYPE_TEXT) { - TOX_ERR_CONFERENCE_NEW error; + Tox_Err_Conference_New error; uint32_t groupId = tox_conference_new(tox.get(), &error); switch (error) { @@ -1347,7 +1347,7 @@ bool Core::isFriendOnline(uint32_t friendId) const { QMutexLocker ml{coreLoopLock.get()}; - TOX_CONNECTION connetion = tox_friend_get_connection_status(tox.get(), friendId, nullptr); + Tox_Connection connetion = tox_friend_get_connection_status(tox.get(), friendId, nullptr); return connetion != TOX_CONNECTION_NONE; } diff --git a/src/core/core.h b/src/core/core.h index 25a40d47f..b6162eb8c 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -213,20 +213,20 @@ private: static void onFriendRequest(Tox* tox, const uint8_t* cUserId, const uint8_t* cMessage, size_t cMessageSize, void* core); - static void onFriendMessage(Tox* tox, uint32_t friendId, TOX_MESSAGE_TYPE type, + static void onFriendMessage(Tox* tox, uint32_t friendId, Tox_Message_Type type, const uint8_t* cMessage, size_t cMessageSize, void* core); static void onFriendNameChange(Tox* tox, uint32_t friendId, const uint8_t* cName, size_t cNameSize, void* core); static void onFriendTypingChange(Tox* tox, uint32_t friendId, bool isTyping, void* core); static void onStatusMessageChanged(Tox* tox, uint32_t friendId, const uint8_t* cMessage, size_t cMessageSize, void* core); - static void onUserStatusChanged(Tox* tox, uint32_t friendId, TOX_USER_STATUS userstatus, + static void onUserStatusChanged(Tox* tox, uint32_t friendId, Tox_User_Status userstatus, void* core); - static void onConnectionStatusChanged(Tox* tox, uint32_t friendId, TOX_CONNECTION status, + static void onConnectionStatusChanged(Tox* tox, uint32_t friendId, Tox_Connection status, void* core); - static void onGroupInvite(Tox* tox, uint32_t friendId, TOX_CONFERENCE_TYPE type, + static void onGroupInvite(Tox* tox, uint32_t friendId, Tox_Conference_Type type, const uint8_t* cookie, size_t length, void* vCore); - static void onGroupMessage(Tox* tox, uint32_t groupId, uint32_t peerId, TOX_MESSAGE_TYPE type, + static void onGroupMessage(Tox* tox, uint32_t groupId, uint32_t peerId, Tox_Message_Type type, const uint8_t* cMessage, size_t length, void* vCore); #if TOX_VERSION_IS_API_COMPATIBLE(0, 2, 0) static void onGroupPeerListChange(Tox*, uint32_t groupId, void* core); @@ -240,9 +240,9 @@ private: const uint8_t* cTitle, size_t length, void* vCore); static void onReadReceiptCallback(Tox* tox, uint32_t friendId, uint32_t receipt, void* core); - void sendGroupMessageWithType(int groupId, const QString& message, TOX_MESSAGE_TYPE type); - bool parsePeerQueryError(TOX_ERR_CONFERENCE_PEER_QUERY error) const; - bool parseConferenceJoinError(TOX_ERR_CONFERENCE_JOIN error) const; + void sendGroupMessageWithType(int groupId, const QString& message, Tox_Message_Type type); + bool parsePeerQueryError(Tox_Err_Conference_Peer_Query error) const; + bool parseConferenceJoinError(Tox_Err_Conference_Join error) const; bool checkConnection(); void checkEncryptedHistory(); diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index 19813b200..7c32f55d7 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -697,8 +697,8 @@ bool CoreAV::isGroupCallOutputMuted(const Group* g) const bool CoreAV::isGroupAvEnabled(int groupId) const { Tox* tox = Core::getInstance()->tox.get(); - TOX_ERR_CONFERENCE_GET_TYPE error; - TOX_CONFERENCE_TYPE type = tox_conference_get_type(tox, groupId, &error); + Tox_Err_Conference_Get_Type error; + Tox_Conference_Type type = tox_conference_get_type(tox, groupId, &error); switch (error) { case TOX_ERR_CONFERENCE_GET_TYPE_OK: break; diff --git a/src/core/corefile.cpp b/src/core/corefile.cpp index 73c25b3b9..54a333120 100644 --- a/src/core/corefile.cpp +++ b/src/core/corefile.cpp @@ -80,7 +80,7 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d tox_hash(avatarHash, (uint8_t*)data.data(), data.size()); uint64_t filesize = data.size(); - TOX_ERR_FILE_SEND error; + Tox_Err_File_Send error; uint32_t fileNum = tox_file_send(core->tox.get(), friendId, TOX_FILE_KIND_AVATAR, filesize, avatarHash, avatarHash, TOX_HASH_LENGTH, &error); @@ -367,7 +367,7 @@ void CoreFile::handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept } void CoreFile::onFileControlCallback(Tox*, uint32_t friendId, uint32_t fileId, - TOX_FILE_CONTROL control, void* core) + Tox_File_Control control, void* core) { ToxFile* file = findFile(friendId, fileId); if (!file) { diff --git a/src/core/corefile.h b/src/core/corefile.h index 6a0395ba8..c75603fd4 100644 --- a/src/core/corefile.h +++ b/src/core/corefile.h @@ -71,7 +71,7 @@ private: uint64_t filesize, const uint8_t* fname, size_t fnameLen, void* vCore); static void onFileControlCallback(Tox* tox, uint32_t friendId, uint32_t fileId, - TOX_FILE_CONTROL control, void* core); + Tox_File_Control control, void* core); static void onFileDataCallback(Tox* tox, uint32_t friendId, uint32_t fileId, uint64_t pos, size_t length, void* core); static void onFileRecvChunkCallback(Tox* tox, uint32_t friendId, uint32_t fileId, uint64_t position, diff --git a/src/core/toxlogger.cpp b/src/core/toxlogger.cpp index 9aed48b97..d0ef02d56 100644 --- a/src/core/toxlogger.cpp +++ b/src/core/toxlogger.cpp @@ -25,7 +25,7 @@ QByteArray cleanPath(const char *file) * @brief Log message handler for toxcore log messages * @note See tox.h for the parameter definitions */ -void onLogMessage(Tox *tox, TOX_LOG_LEVEL level, const char *file, uint32_t line, +void onLogMessage(Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func, const char *message, void *user_data) { const QByteArray cleanedPath = cleanPath(file); diff --git a/src/core/toxlogger.h b/src/core/toxlogger.h index 624bf8c91..b210e13ea 100644 --- a/src/core/toxlogger.h +++ b/src/core/toxlogger.h @@ -6,7 +6,7 @@ #include namespace ToxLogger { - void onLogMessage(Tox *tox, TOX_LOG_LEVEL level, const char *file, uint32_t line, + void onLogMessage(Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func, const char *message, void *user_data); } diff --git a/src/core/toxoptions.cpp b/src/core/toxoptions.cpp index 7b1e2c907..176fe58f6 100644 --- a/src/core/toxoptions.cpp +++ b/src/core/toxoptions.cpp @@ -95,7 +95,7 @@ std::unique_ptr ToxOptions::makeToxOptions(const QByteArray& savedat qWarning() << "proxy address" << proxyAddr << "is too long"; } else if (!proxyAddr.isEmpty() && proxyPort > 0) { qDebug() << "using proxy" << proxyAddr << ":" << proxyPort; - // protection against changings in TOX_PROXY_TYPE enum + // protection against changings in Tox_Proxy_Type enum if (proxyType == ICoreSettings::ProxyType::ptSOCKS5) { tox_options_set_proxy_type(*toxOptions, TOX_PROXY_TYPE_SOCKS5); } else if (proxyType == ICoreSettings::ProxyType::ptHTTP) {