mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: rename args to conform to C++11 § 17.6.4.3.2
Fixed typo and small style improvements.
This commit is contained in:
parent
32909559b6
commit
4f9cb0b008
|
@ -504,9 +504,9 @@ void Core::onConnectionStatusChanged(Tox*/* tox*/, uint32_t friendId, TOX_CONNEC
|
|||
}
|
||||
|
||||
void Core::onGroupInvite(Tox*, uint32_t friendId, TOX_CONFERENCE_TYPE type,
|
||||
const uint8_t *data, size_t length, void* _core)
|
||||
const uint8_t* data, size_t length, void* vCore)
|
||||
{
|
||||
Core* core = static_cast<Core*>(_core);
|
||||
Core* core = static_cast<Core*>(vCore);
|
||||
QByteArray pk((char*)data, length);
|
||||
if (type == TOX_CONFERENCE_TYPE_TEXT)
|
||||
{
|
||||
|
@ -525,12 +525,11 @@ void Core::onGroupInvite(Tox*, uint32_t friendId, TOX_CONFERENCE_TYPE type,
|
|||
}
|
||||
|
||||
void Core::onGroupMessage(Tox*, uint32_t groupId, uint32_t peerId, TOX_MESSAGE_TYPE type,
|
||||
const uint8_t* _message, size_t length, void* _core)
|
||||
const uint8_t* cMessage, size_t length, void* vCore)
|
||||
{
|
||||
Core* core = static_cast<Core*>(_core);
|
||||
QString message = CString::toString(_message, length);
|
||||
bool isAction;
|
||||
isAction = type == TOX_MESSAGE_TYPE_ACTION;
|
||||
Core* core = static_cast<Core*>(vCore);
|
||||
QString message = CString::toString(cMessage, length);
|
||||
bool isAction = type == TOX_MESSAGE_TYPE_ACTION;
|
||||
emit core->groupMessageReceived(groupId, peerId, message, isAction);
|
||||
}
|
||||
|
||||
|
@ -542,15 +541,15 @@ void Core::onGroupNamelistChange(Tox*, uint32_t groupId, uint32_t peerId,
|
|||
}
|
||||
|
||||
void Core::onGroupTitleChange(Tox*, uint32_t groupId, uint32_t peerId,
|
||||
const uint8_t* _title, size_t length, void* _core)
|
||||
const uint8_t* cTitle, size_t length, void* vCore)
|
||||
{
|
||||
Core* core = static_cast<Core*>(_core);
|
||||
Core* core = static_cast<Core*>(vCore);
|
||||
QString author = core->getGroupPeerName(groupId, peerId);
|
||||
QString title = CString::toString(_title, length);
|
||||
QString title = CString::toString(cTitle, length);
|
||||
emit core->groupTitleChanged(groupId, author, title);
|
||||
}
|
||||
|
||||
void Core::onReadReceiptCallback(Tox*, uint32_t friendId, uint32_t receipt, void *core)
|
||||
void Core::onReadReceiptCallback(Tox*, uint32_t friendId, uint32_t receipt, void* core)
|
||||
{
|
||||
emit static_cast<Core*>(core)->receiptRecieved(friendId, receipt);
|
||||
}
|
||||
|
@ -643,7 +642,7 @@ void Core::sendTyping(uint32_t friendId, bool typing)
|
|||
emit failedToSetTyping(typing);
|
||||
}
|
||||
|
||||
void Core::sendGroupMessageWithType(int groupId, const QString &message, TOX_MESSAGE_TYPE type)
|
||||
void Core::sendGroupMessageWithType(int groupId, const QString& message, TOX_MESSAGE_TYPE type)
|
||||
{
|
||||
QList<CString> cMessages = splitMessage(message, MAX_GROUP_MESSAGE_LEN);
|
||||
|
||||
|
@ -665,7 +664,7 @@ void Core::sendGroupMessageWithType(int groupId, const QString &message, TOX_MES
|
|||
qCritical() << "Conference not found";
|
||||
return;
|
||||
case TOX_ERR_CONFERENCE_SEND_MESSAGE_FAIL_SEND:
|
||||
qCritical() << "Fail send";
|
||||
qCritical() << "Conference message failed to send";
|
||||
return;
|
||||
case TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION:
|
||||
qCritical() << "No connection";
|
||||
|
@ -710,7 +709,7 @@ void Core::changeGroupTitle(int groupId, const QString& title)
|
|||
qCritical() << "Conference not found";
|
||||
break;
|
||||
case TOX_ERR_CONFERENCE_TITLE_FAIL_SEND:
|
||||
qCritical() << "Fail send";
|
||||
qCritical() << "Conference title failed to send";
|
||||
break;
|
||||
case TOX_ERR_CONFERENCE_TITLE_INVALID_LENGTH:
|
||||
qCritical() << "Invalid length";
|
||||
|
@ -1083,13 +1082,13 @@ QString Core::getGroupPeerName(int groupId, int peerId) const
|
|||
TOX_ERR_CONFERENCE_PEER_QUERY error;
|
||||
size_t length = tox_conference_peer_get_name_size(tox, groupId, peerId, &error);
|
||||
if (!parsePeerQueryError(error))
|
||||
return QString();
|
||||
return QString{};
|
||||
|
||||
bool success = tox_conference_peer_get_name(tox, groupId, peerId, nameArray, &error);
|
||||
if (!parsePeerQueryError(error) || !success)
|
||||
{
|
||||
qWarning() << "getGroupPeerName: Unknown error";
|
||||
return QString();
|
||||
return QString{};
|
||||
}
|
||||
|
||||
return CString::toString(nameArray, length);
|
||||
|
@ -1120,33 +1119,37 @@ QList<QString> Core::getGroupPeerNames(int groupId) const
|
|||
if (!tox)
|
||||
{
|
||||
qWarning() << "Can't get group peer names, tox is null";
|
||||
return QList<QString>();
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t result = getGroupNumberPeers(groupId);
|
||||
if (result == std::numeric_limits<uint32_t>::max())
|
||||
uint32_t nPeers = getGroupNumberPeers(groupId);
|
||||
if (nPeers == std::numeric_limits<uint32_t>::max())
|
||||
{
|
||||
qWarning() << "getGroupPeerNames: Unable to get number of peers";
|
||||
return QList<QString>();
|
||||
return {};
|
||||
}
|
||||
|
||||
uint16_t nPeers = static_cast<uint16_t>(result);
|
||||
std::unique_ptr<uint8_t[][TOX_MAX_NAME_LENGTH]> namesArray{new uint8_t[nPeers][TOX_MAX_NAME_LENGTH]};
|
||||
// TODO: Change to std::vector
|
||||
std::unique_ptr<uint8_t[][TOX_MAX_NAME_LENGTH]> namesArray{
|
||||
new uint8_t[nPeers][TOX_MAX_NAME_LENGTH]};
|
||||
|
||||
std::unique_ptr<uint16_t[]> lengths{new uint16_t[nPeers]};
|
||||
TOX_ERR_CONFERENCE_PEER_QUERY error;
|
||||
|
||||
uint32_t count = tox_conference_peer_count(tox, groupId, &error);
|
||||
if (!parsePeerQueryError(error))
|
||||
return QList<QString>();
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (count != nPeers)
|
||||
{
|
||||
qWarning() << "getGroupPeerNames: Unexpected peer count";
|
||||
return QList<QString>();
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<QString> names;
|
||||
for (uint16_t i = 0; i < nPeers; ++i)
|
||||
for (uint32_t i = 0; i < nPeers; ++i)
|
||||
{
|
||||
lengths[i] = tox_conference_peer_get_name_size(tox, groupId, i, &error);
|
||||
bool ok = tox_conference_peer_get_name(tox, groupId, i, namesArray[i], &error);
|
||||
|
@ -1174,7 +1177,7 @@ bool Core::parseConferenceJoinError(TOX_ERR_CONFERENCE_JOIN error) const
|
|||
qCritical() << "Conference duplicate";
|
||||
return false;
|
||||
case TOX_ERR_CONFERENCE_JOIN_FAIL_SEND:
|
||||
qCritical() << "Fail send";
|
||||
qCritical() << "Conference join failed to send";
|
||||
return false;
|
||||
case TOX_ERR_CONFERENCE_JOIN_FRIEND_NOT_FOUND:
|
||||
qCritical() << "Friend not found";
|
||||
|
@ -1242,7 +1245,7 @@ void Core::quitGroupChat(int groupId) const
|
|||
case TOX_ERR_CONFERENCE_DELETE_OK:
|
||||
return;
|
||||
case TOX_ERR_CONFERENCE_DELETE_CONFERENCE_NOT_FOUND:
|
||||
qCritical() << "Conferenct not found";
|
||||
qCritical() << "Conference not found";
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
|
@ -1262,7 +1265,7 @@ void Core::groupInviteFriend(uint32_t friendId, int groupId)
|
|||
qCritical() << "Conference not found";
|
||||
break;
|
||||
case TOX_ERR_CONFERENCE_INVITE_FAIL_SEND:
|
||||
qCritical() << "Fail send";
|
||||
qCritical() << "Conference invite failed to send";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1317,7 +1320,9 @@ bool Core::hasFriendWithAddress(const QString &addr) const
|
|||
{
|
||||
// Valid length check
|
||||
if (addr.length() != (TOX_ADDRESS_SIZE * 2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString pubkey = addr.left(TOX_PUBLIC_KEY_SIZE * 2);
|
||||
return hasFriendWithPublicKey(pubkey);
|
||||
|
|
|
@ -222,7 +222,7 @@ private:
|
|||
static void onGroupTitleChange(Tox* tox, uint32_t groupId, uint32_t peerId,
|
||||
const uint8_t* title, size_t length, void* core);
|
||||
static void onReadReceiptCallback(Tox* tox, uint32_t friendId,
|
||||
uint32_t receipt, void *core);
|
||||
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;
|
||||
|
|
|
@ -666,9 +666,9 @@ void CoreAV::sendNoVideo()
|
|||
}
|
||||
}
|
||||
|
||||
void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool video, void *_self)
|
||||
void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool video, void* vSelf)
|
||||
{
|
||||
CoreAV* self = static_cast<CoreAV*>(_self);
|
||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||
|
||||
// Run this slow callback asynchronously on the AV thread to avoid deadlocks with what our caller (toxcore) holds
|
||||
// Also run the code to switch to the CoreAV thread in yet another thread, in case CoreAV
|
||||
|
@ -681,8 +681,8 @@ void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool vid
|
|||
QThread::yieldCurrentThread(); // Shouldn't spin for long, we have priority
|
||||
|
||||
QMetaObject::invokeMethod(self, "callCallback", Qt::QueuedConnection,
|
||||
Q_ARG(ToxAV*, toxav), Q_ARG(uint32_t, friendNum),
|
||||
Q_ARG(bool, audio), Q_ARG(bool, video), Q_ARG(void*, _self));
|
||||
Q_ARG(ToxAV*, toxav), Q_ARG(uint32_t, friendNum),
|
||||
Q_ARG(bool, audio), Q_ARG(bool, video), Q_ARG(void*, vSelf));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -711,9 +711,9 @@ void CoreAV::callCallback(ToxAV* toxav, uint32_t friendNum, bool audio, bool vid
|
|||
self->threadSwitchLock.clear(std::memory_order_release);
|
||||
}
|
||||
|
||||
void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, void *_self)
|
||||
void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, void* vSelf)
|
||||
{
|
||||
CoreAV* self = static_cast<CoreAV*>(_self);
|
||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||
|
||||
// Run this slow callback asynchronously on the AV thread to avoid deadlocks with what our caller (toxcore) holds
|
||||
// Also run the code to switch to the CoreAV thread in yet another thread, in case CoreAV
|
||||
|
@ -727,7 +727,7 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
|
|||
|
||||
QMetaObject::invokeMethod(self, "stateCallback", Qt::QueuedConnection,
|
||||
Q_ARG(ToxAV*, toxav), Q_ARG(uint32_t, friendNum),
|
||||
Q_ARG(uint32_t, state), Q_ARG(void*, _self));
|
||||
Q_ARG(uint32_t, state), Q_ARG(void*, vSelf));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -784,25 +784,25 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
|
|||
self->threadSwitchLock.clear(std::memory_order_release);
|
||||
}
|
||||
|
||||
void CoreAV::bitrateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t arate, uint32_t vrate, void *_self)
|
||||
void CoreAV::bitrateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t arate, uint32_t vrate, void* vSelf)
|
||||
{
|
||||
CoreAV* self = static_cast<CoreAV*>(_self);
|
||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||
|
||||
// Run this slow path callback asynchronously on the AV thread to avoid deadlocks
|
||||
if (QThread::currentThread() != self->coreavThread.get())
|
||||
{
|
||||
return (void)QMetaObject::invokeMethod(self, "bitrateCallback", Qt::QueuedConnection,
|
||||
Q_ARG(ToxAV*, toxav), Q_ARG(uint32_t, friendNum),
|
||||
Q_ARG(uint32_t, arate), Q_ARG(uint32_t, vrate), Q_ARG(void*, _self));
|
||||
Q_ARG(uint32_t, arate), Q_ARG(uint32_t, vrate), Q_ARG(void*, vSelf));
|
||||
}
|
||||
|
||||
qDebug() << "Recommended bitrate with"<<friendNum<<" is now "<<arate<<"/"<<vrate<<", ignoring it";
|
||||
}
|
||||
|
||||
void CoreAV::audioFrameCallback(ToxAV *, uint32_t friendNum, const int16_t *pcm,
|
||||
size_t sampleCount, uint8_t channels, uint32_t samplingRate, void *_self)
|
||||
size_t sampleCount, uint8_t channels, uint32_t samplingRate, void* vSelf)
|
||||
{
|
||||
CoreAV* self = static_cast<CoreAV*>(_self);
|
||||
CoreAV* self = static_cast<CoreAV*>(vSelf);
|
||||
if (!self->calls.contains(friendNum))
|
||||
return;
|
||||
|
||||
|
|
|
@ -300,10 +300,12 @@ void CoreFile::removeFile(uint32_t friendId, uint32_t fileId)
|
|||
fileMap.remove(key);
|
||||
}
|
||||
|
||||
void CoreFile::onFileReceiveCallback(Tox*, uint32_t friendId, uint32_t fileId, uint32_t kind,
|
||||
uint64_t filesize, const uint8_t *fname, size_t fnameLen, void *_core)
|
||||
void CoreFile::onFileReceiveCallback(Tox*, uint32_t friendId, uint32_t fileId,
|
||||
uint32_t kind, uint64_t filesize,
|
||||
const uint8_t* fname, size_t fnameLen,
|
||||
void* vCore)
|
||||
{
|
||||
Core* core = static_cast<Core*>(_core);
|
||||
Core* core = static_cast<Core*>(vCore);
|
||||
|
||||
if (kind == TOX_FILE_KIND_AVATAR)
|
||||
{
|
||||
|
@ -445,10 +447,12 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
|
|||
emit static_cast<Core*>(core)->fileTransferInfo(*file);
|
||||
}
|
||||
|
||||
void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fileId, uint64_t position,
|
||||
const uint8_t *data, size_t length, void *_core)
|
||||
void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId,
|
||||
uint32_t fileId, uint64_t position,
|
||||
const uint8_t* data, size_t length,
|
||||
void* vCore)
|
||||
{
|
||||
Core* core = static_cast<Core*>(_core);
|
||||
Core* core = static_cast<Core*>(vCore);
|
||||
ToxFile* file = findFile(friendId, fileId);
|
||||
if (!file)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user