1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Update for toxcore API break

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-02-01 01:25:22 +01:00
parent 4d5b924d0d
commit d6b34aef78
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 8 additions and 8 deletions

View File

@ -742,7 +742,7 @@ void Core::acceptFriendRequest(const QString& userId)
void Core::requestFriendship(const QString& friendAddress, const QString& message)
{
const QString userId = friendAddress.mid(0, TOX_CLIENT_ID_SIZE * 2);
const QString userId = friendAddress.mid(0, TOX_PUBLIC_KEY_SIZE * 2);
if (hasFriendWithAddress(friendAddress))
{
@ -1439,7 +1439,7 @@ void Core::loadFriends()
// assuming there are not that many friends to fill up the whole stack
int32_t *ids = new int32_t[friendCount];
tox_get_friendlist(tox, ids, friendCount);
uint8_t clientId[TOX_CLIENT_ID_SIZE];
uint8_t clientId[TOX_PUBLIC_KEY_SIZE];
for (int32_t i = 0; i < static_cast<int32_t>(friendCount); ++i) {
if (tox_get_client_id(tox, ids[i], clientId) == 0) {
emit friendAdded(ids[i], CUserId::toString(clientId));
@ -1500,7 +1500,7 @@ ToxID Core::getGroupPeerToxID(int groupId, int peerId) const
{
ToxID peerToxID;
uint8_t rawID[TOX_CLIENT_ID_SIZE];
uint8_t rawID[TOX_PUBLIC_KEY_SIZE];
int res = tox_group_peer_pubkey(tox, groupId, peerId, rawID);
if (res == -1)
{
@ -1706,14 +1706,14 @@ bool Core::hasFriendWithAddress(const QString &addr) const
return false;
}
QString pubkey = addr.left(TOX_CLIENT_ID_SIZE * 2);
QString pubkey = addr.left(TOX_PUBLIC_KEY_SIZE * 2);
return hasFriendWithPublicKey(pubkey);
}
bool Core::hasFriendWithPublicKey(const QString &pubkey) const
{
// Valid length check
if (pubkey.length() != (TOX_CLIENT_ID_SIZE * 2))
if (pubkey.length() != (TOX_PUBLIC_KEY_SIZE * 2))
{
return false;
}
@ -1746,9 +1746,9 @@ bool Core::hasFriendWithPublicKey(const QString &pubkey) const
QString Core::getFriendAddress(int friendNumber) const
{
// If we don't know the full address of the client, return just the id, otherwise get the full address
uint8_t rawid[TOX_CLIENT_ID_SIZE];
uint8_t rawid[TOX_PUBLIC_KEY_SIZE];
tox_get_client_id(tox, friendNumber, rawid);
QByteArray data((char*)rawid,TOX_CLIENT_ID_SIZE);
QByteArray data((char*)rawid,TOX_PUBLIC_KEY_SIZE);
QString id = data.toHex().toUpper();
QString addr = Settings::getInstance().getFriendAdress(id);

View File

@ -56,7 +56,7 @@ uint16_t CData::fromString(const QString& data, uint8_t* cData)
// CUserId
const uint16_t CUserId::SIZE{TOX_CLIENT_ID_SIZE};
const uint16_t CUserId::SIZE{TOX_PUBLIC_KEY_SIZE};
CUserId::CUserId(const QString &userId) :
CData(userId, SIZE < userId.size() ? userId.size() : SIZE)