diff --git a/src/core/core.cpp b/src/core/core.cpp index 6d4acf9e8..5a1f753f2 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -582,7 +582,7 @@ QString Core::getFriendRequestErrorMessage(const ToxId& friendId, const QString& "Error while sending friendship request"); } - if (message.length() > TOX_MAX_FRIEND_REQUEST_LENGTH) { + if (message.length() > static_cast(tox_max_friend_request_length())) { return tr("Your message is too long!", "Error while sending friendship request"); } @@ -1100,7 +1100,7 @@ uint32_t Core::getGroupNumberPeers(int groupId) const */ QString Core::getGroupPeerName(int groupId, int peerId) const { - uint8_t nameArray[TOX_MAX_NAME_LENGTH]; + uint8_t nameArray[tox_max_name_length()]; TOX_ERR_CONFERENCE_PEER_QUERY error; size_t length = tox_conference_peer_get_name_size(tox, groupId, peerId, &error); if (!parsePeerQueryError(error)) { @@ -1161,7 +1161,8 @@ QStringList Core::getGroupPeerNames(int groupId) const QStringList names; for (uint32_t i = 0; i < nPeers; ++i) { - uint8_t name[TOX_MAX_NAME_LENGTH] = {0}; + uint8_t name[tox_max_name_length()]; + memset(name, 0, tox_max_name_length()); size_t length = tox_conference_peer_get_name_size(tox, groupId, i, &error); bool ok = tox_conference_peer_get_name(tox, groupId, i, name, &error); if (ok && parsePeerQueryError(error)) { @@ -1410,7 +1411,7 @@ QString Core::getPeerName(const ToxPk& id) const return name; } - uint8_t* cname = new uint8_t[nameSize < TOX_MAX_NAME_LENGTH ? TOX_MAX_NAME_LENGTH : nameSize]; + uint8_t* cname = new uint8_t[nameSize < tox_max_name_length() ? tox_max_name_length() : nameSize]; if (!tox_friend_get_name(tox, friendId, cname, nullptr)) { qWarning() << "getPeerName: Can't get name of friend " + QString().setNum(friendId); delete[] cname; diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 7b4531160..34c9f27cb 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -610,7 +610,7 @@ void ChatForm::dropEvent(QDropEvent* ev) QFile file(info.absoluteFilePath()); QString urlString = url.toString(); - if (url.isValid() && !url.isLocalFile() && urlString.length() < TOX_MAX_MESSAGE_LENGTH) { + if (url.isValid() && !url.isLocalFile() && urlString.length() < static_cast(tox_max_message_length())) { SendMessageStr(urlString); continue; } @@ -949,7 +949,7 @@ void ChatForm::SendMessageStr(QString msg) msg.remove(0, ACTION_PREFIX.length()); } - QStringList splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH); + QStringList splittedMsg = Core::splitMessage(msg, tox_max_message_length()); QDateTime timestamp = QDateTime::currentDateTime(); for (const QString& part : splittedMsg) { diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index f14f39465..a9ac62a23 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -57,8 +57,8 @@ ProfileForm::ProfileForm(QWidget* parent) core = Core::getInstance(); bodyUI->userNameLabel->setToolTip(tr("Tox user names cannot exceed %1 characters.") - .arg(TOX_MAX_NAME_LENGTH)); - bodyUI->userName->setMaxLength(TOX_MAX_NAME_LENGTH); + .arg(tox_max_name_length())); + bodyUI->userName->setMaxLength(tox_max_name_length()); // tox toxId = new ClickableTE(); diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 3a1f42e06..ed0f60fc9 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -432,7 +432,7 @@ void FriendWidget::mouseMoveEvent(QMouseEvent* ev) void FriendWidget::setAlias(const QString& _alias) { - QString alias = _alias.left(128); // same as TOX_MAX_NAME_LENGTH + QString alias = _alias.left(tox_max_name_length()); Friend* f = FriendList::findFriend(friendId); f->setAlias(alias); Settings::getInstance().setFriendAlias(f->getPublicKey(), alias);