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

style(core): Style fixes

This commit is contained in:
Diadlo 2016-07-07 13:10:53 +03:00
parent 9471065feb
commit f8eda7eb57
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
9 changed files with 45 additions and 53 deletions

View File

@ -618,7 +618,7 @@ int Core::sendAction(uint32_t friendId, const QString &action)
void Core::sendTyping(uint32_t friendId, bool typing)
{
bool ret = tox_self_set_typing(tox, friendId, typing, nullptr);
if (ret == false)
if (!ret)
emit failedToSetTyping(typing);
}
@ -656,9 +656,9 @@ void Core::changeGroupTitle(int groupId, const QString& title)
emit groupTitleChanged(groupId, getUsername(), title);
}
void Core::sendFile(uint32_t friendId, QString Filename, QString FilePath, long long filesize)
void Core::sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize)
{
CoreFile::sendFile(this, friendId, Filename, FilePath, filesize);
CoreFile::sendFile(this, friendId, filename, filePath, filesize);
}
void Core::sendAvatarFile(uint32_t friendId, const QByteArray& data)
@ -701,15 +701,14 @@ void Core::removeFriend(uint32_t friendId, bool fake)
if (!isReady() || fake)
return;
if (tox_friend_delete(tox, friendId, nullptr) == false)
if (!tox_friend_delete(tox, friendId, nullptr))
{
emit failedToRemoveFriend(friendId);
return;
}
else
{
profile.saveToxSave();
emit friendRemoved(friendId);
}
}
void Core::removeGroup(int groupId, bool fake)
@ -741,16 +740,15 @@ void Core::setUsername(const QString& username)
CString cUsername(username);
if (tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr) == false)
if (!tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr))
{
emit failedToSetUsername(username);
return;
}
else
{
emit usernameSet(username);
if (ready)
profile.saveToxSave();
}
}
void Core::setAvatar(const QByteArray& data)
@ -817,16 +815,15 @@ void Core::setStatusMessage(const QString& message)
CString cMessage(message);
if (tox_self_set_status_message(tox, cMessage.data(), cMessage.size(), nullptr) == false)
if (!tox_self_set_status_message(tox, cMessage.data(), cMessage.size(), nullptr))
{
emit failedToSetStatusMessage(message);
return;
}
else
{
if (ready)
profile.saveToxSave();
emit statusMessageSet(message);
}
}
void Core::setStatus(Status status)
@ -1188,7 +1185,7 @@ QString Core::getPeerName(const ToxId& id) const
return name;
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) == false)
if (!tox_friend_get_name(tox, friendId, cname, nullptr))
{
qWarning() << "getPeerName: Can't get name of friend "+QString().setNum(friendId);
delete[] cname;

View File

@ -115,7 +115,7 @@ public slots:
int sendAction(uint32_t friendId, const QString& action);
void sendTyping(uint32_t friendId, bool typing);
void sendFile(uint32_t friendId, QString Filename, QString FilePath, long long filesize);
void sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize);
void sendAvatarFile(uint32_t friendId, const QByteArray& data);
void cancelFileSend(uint32_t friendId, uint32_t fileNum);
void cancelFileRecv(uint32_t friendId, uint32_t fileNum);

View File

@ -171,7 +171,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
}
qDebug() << QString("Starting call with %1").arg(friendNum);
if(calls.contains(friendNum))
if (calls.contains(friendNum))
{
qWarning() << QString("Can't start call with %1, we're already in this call!").arg(friendNum);
return false;
@ -545,12 +545,13 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
return;
}
if(!self->calls.contains(friendNum))
if (!self->calls.contains(friendNum))
{
qWarning() << QString("stateCallback called, but call %1 is already dead").arg(friendNum);
self->threadSwitchLock.clear(std::memory_order_release);
return;
}
ToxFriendCall& call = self->calls[friendNum];
if (state & TOXAV_FRIEND_CALL_STATE_ERROR)

View File

@ -77,7 +77,6 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d
qWarning() << "sendAvatarFile: Can't create the Tox file sender, error"<<err;
return;
}
//qDebug() << QString("sendAvatarFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId);
ToxFile file{fileNum, friendId, "", "", ToxFile::SENDING};
file.filesize = filesize;
@ -89,22 +88,22 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d
addFile(friendId, fileNum, file);
}
void CoreFile::sendFile(Core* core, uint32_t friendId, QString Filename, QString FilePath, long long filesize)
void CoreFile::sendFile(Core* core, uint32_t friendId, QString filename, QString filePath, long long filesize)
{
QMutexLocker mlocker(&fileSendMutex);
QByteArray fileName = Filename.toUtf8();
QByteArray fileName = filename.toUtf8();
uint32_t fileNum = tox_file_send(core->tox, friendId, TOX_FILE_KIND_DATA, filesize, nullptr,
(uint8_t*)fileName.data(), fileName.size(), nullptr);
if (fileNum == std::numeric_limits<uint32_t>::max())
{
qWarning() << "sendFile: Can't create the Tox file sender";
emit core->fileSendFailed(friendId, Filename);
emit core->fileSendFailed(friendId, filename);
return;
}
qDebug() << QString("sendFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId);
ToxFile file{fileNum, friendId, fileName, FilePath, ToxFile::SENDING};
ToxFile file{fileNum, friendId, fileName, filePath, ToxFile::SENDING};
file.filesize = filesize;
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
tox_file_get_file_id(core->tox, friendId, fileNum, (uint8_t*)file.resumeFileId.data(), nullptr);
@ -350,7 +349,6 @@ void CoreFile::onFileControlCallback(Tox*, uint32_t friendId, uint32_t fileId,
void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
uint64_t pos, size_t length, void* core)
{
//qDebug() << "File data req of "<<length<<" at "<<pos<<" for file "<<friendId<<':'<<fileId;
ToxFile* file = findFile(friendId, fileId);
if (!file)
@ -362,7 +360,6 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
// If we reached EOF, ack and cleanup the transfer
if (!length)
{
//qDebug("onFileDataCallback: File sending completed");
if (file->fileKind != TOX_FILE_KIND_AVATAR)
{
emit static_cast<Core*>(core)->fileTransferFinished(*file);
@ -408,9 +405,6 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fileId, uint64_t position,
const uint8_t *data, size_t length, void *_core)
{
//qDebug() << QString("Received chunk for %1:%2 pos %3 size %4")
// .arg(friendId).arg(fileId).arg(position).arg(length);
Core* core = static_cast<Core*>(_core);
ToxFile* file = findFile(friendId, fileId);
if (!file)

View File

@ -46,7 +46,7 @@ private:
// Internal file sending APIs, used by Core. Public API in core.h
private:
static void sendFile(Core *core, uint32_t friendId, QString Filename, QString FilePath, long long filesize);
static void sendFile(Core *core, uint32_t friendId, QString filename, QString filePath, long long filesize);
static void sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& data);
static void pauseResumeFileSend(Core* core, uint32_t friendId, uint32_t fileId);
static void pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileId);

View File

@ -6,9 +6,9 @@
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
ToxFile::ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction)
: fileKind{TOX_FILE_KIND_DATA}, fileNum(FileNum), friendId(FriendId), fileName{FileName},
filePath{FilePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0},
ToxFile::ToxFile(uint32_t fileNum, uint32_t friendId, QByteArray filename, QString filePath, FileDirection Direction)
: fileKind{TOX_FILE_KIND_DATA}, fileNum(fileNum), friendId(friendId), fileName{filename},
filePath{filePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0},
status{STOPPED}, direction{Direction}
{
}

View File

@ -36,7 +36,7 @@ struct ToxFile
};
ToxFile()=default;
ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction);
ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString filePath, FileDirection Direction);
~ToxFile(){}
bool operator==(const ToxFile& other) const;

View File

@ -31,11 +31,11 @@
#include "src/group.h"
Friend::Friend(uint32_t FriendId, const ToxId &UserId)
: userName{Core::getInstance()->getPeerName(UserId)},
userID{UserId}, friendId{FriendId}
: userName{Core::getInstance()->getPeerName(UserId)}
, userID(UserId), friendId(FriendId)
, hasNewEvents(0), friendStatus(Status::Offline)
{
hasNewEvents = 0;
friendStatus = Status::Offline;
if (userName.size() == 0)
userName = UserId.publicKey;

View File

@ -191,7 +191,6 @@ void Nexus::showMainGUI()
connect(core, &Core::groupPeerAudioPlaying, widget, &Widget::onGroupPeerAudioPlaying);
connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated);
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult);
connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult);
@ -221,6 +220,7 @@ Core* Nexus::getCore()
Nexus& nexus = getInstance();
if (!nexus.profile)
return nullptr;
return nexus.profile->getCore();
}