From 0e91d59454d311bc2dd207c6fb93c417c622ac00 Mon Sep 17 00:00:00 2001 From: sudden6 Date: Sun, 10 May 2015 16:08:09 +0200 Subject: [PATCH 1/3] rework the logging and debug output --- qtox.pro | 1 + src/main.cpp | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/qtox.pro b/qtox.pro index 5b17c786c..000cf1ab7 100644 --- a/qtox.pro +++ b/qtox.pro @@ -51,6 +51,7 @@ DEFINES += GIT_VERSION=\"\\\"$$quote($$GIT_VERSION)\\\"\" TIMESTAMP = $$system($1 2>null||echo 0||a;rm null;date +%s||echo 0) # I'm so sorry DEFINES += TIMESTAMP=$$TIMESTAMP DEFINES += LOG_TO_FILE +DEFINES += QT_MESSAGELOGCONTEXT android { ANDROID_TOOLCHAIN=/opt/android/toolchain-r9d-17/ diff --git a/src/main.cpp b/src/main.cpp index 633f13372..9d60a66f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,26 +43,49 @@ #define EXIT_UPDATE_MACX_FAIL 216 #ifdef LOG_TO_FILE -static QtMessageHandler dflt; static QTextStream* logFile {nullptr}; static QMutex mutex; +#endif -void myMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QString& msg) +void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QString& msg) { - if (!logFile) - return; - // Silence qWarning spam due to bug in QTextBrowser (trying to open a file for base64 images) if (ctxt.function == QString("virtual bool QFSFileEngine::open(QIODevice::OpenMode)") && msg == QString("QFSFileEngine::open: No file name specified")) return; + QString LogMsg = QString("[%1] %2:%3 : ") + .arg(QTime::currentTime().toString("HH:mm:ss.zzz")).arg(ctxt.file).arg(ctxt.line); + switch (type) + { + case QtDebugMsg: + LogMsg += "Debug"; + break; + case QtWarningMsg: + LogMsg += "Warning"; + break; + case QtCriticalMsg: + LogMsg += "Critical"; + break; + case QtFatalMsg: + LogMsg += "Fatal"; + break; + } + + LogMsg += ": " + msg + "\n"; + + QTextStream out(stderr, QIODevice::WriteOnly); + out << LogMsg; + +#ifdef LOG_TO_FILE + if (!logFile) + return; + QMutexLocker locker(&mutex); - dflt(type, ctxt, msg); - *logFile << QTime::currentTime().toString("HH:mm:ss' '") << msg << '\n'; + *logFile << LogMsg; logFile->flush(); -} #endif +} int opencvErrorHandler(int status, const char* func_name, const char* err_msg, const char* file_name, int line, void*) @@ -74,6 +97,7 @@ int opencvErrorHandler(int status, const char* func_name, const char* err_msg, int main(int argc, char *argv[]) { + qInstallMessageHandler(logMessageHandler); // Enable log as early as possible QApplication a(argc, argv); a.setApplicationName("qTox"); a.setOrganizationName("Tox"); @@ -118,17 +142,15 @@ int main(int argc, char *argv[]) #ifdef LOG_TO_FILE logFile = new QTextStream; - dflt = qInstallMessageHandler(nullptr); QFile logfile(QDir(Settings::getSettingsDirPath()).filePath("qtox.log")); if (logfile.open(QIODevice::Append)) { logFile->setDevice(&logfile); *logFile << QDateTime::currentDateTime().toString("\nyyyy-MM-dd HH:mm:ss' file logger starting\n'"); - qInstallMessageHandler(myMessageHandler); } else { - fprintf(stderr, "Couldn't open log file!\n"); + qWarning() << "Couldn't open log file!\n"; delete logFile; logFile = nullptr; } From 1506a9a30e17bbe06bfe753a485c4d8e285ad694 Mon Sep 17 00:00:00 2001 From: sudden6 Date: Mon, 11 May 2015 14:54:03 +0200 Subject: [PATCH 2/3] Change log messages to fit new log format --- src/audio.cpp | 43 +++++----- src/autoupdate.cpp | 44 +++++----- src/avatarbroadcaster.cpp | 2 +- src/chatlog/content/filetransferwidget.cpp | 2 +- src/core/core.cpp | 69 ++++++++-------- src/core/coreav.cpp | 94 +++++++++++----------- src/core/coreencryption.cpp | 14 ++-- src/core/corefile.cpp | 60 +++++++------- src/friendlist.cpp | 2 +- src/group.cpp | 2 +- src/grouplist.cpp | 2 +- src/historykeeper.cpp | 4 +- src/ipc.cpp | 24 +++--- src/main.cpp | 2 +- src/misc/db/encrypteddb.cpp | 8 +- src/misc/settings.cpp | 8 +- src/misc/style.cpp | 2 +- src/nexus.cpp | 2 +- src/profilelocker.cpp | 10 +-- src/toxdns.cpp | 12 +-- src/toxme.cpp | 2 +- src/video/cameraworker.cpp | 16 ++-- src/widget/androidgui.cpp | 4 +- src/widget/form/settings/generalform.cpp | 2 +- src/widget/friendwidget.cpp | 2 +- src/widget/systemtrayicon.cpp | 10 +-- src/widget/videosurface.cpp | 4 +- src/widget/widget.cpp | 20 ++--- 28 files changed, 230 insertions(+), 236 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index e2cfb6d1a..9239f5f14 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -43,13 +43,6 @@ ALCcontext* Audio::alContext{nullptr}; ALuint Audio::alMainSource{0}; float Audio::outputVolume{1.0}; -void audioDebugLog(QString msg) -{ -#if (AUDIO_DEBUG) - qDebug()<<"Audio: "<resetCallSources(); // Force to regen each group call's sources @@ -157,7 +150,7 @@ void Audio::openInput(const QString& inDevDescr) void Audio::openOutput(const QString& outDevDescr) { - audioDebugLog("Trying to open output "+outDevDescr); + qDebug() << "Trying to open output " + outDevDescr; QMutexLocker lock(audioOutLock); auto* tmp = alOutDev; alOutDev = nullptr; @@ -168,7 +161,7 @@ void Audio::openOutput(const QString& outDevDescr) if (!alOutDev) { - qWarning() << "Audio: Cannot open output audio device"; + qWarning() << "Cannot open output audio device " + outDevDescr; } else { @@ -181,7 +174,7 @@ void Audio::openOutput(const QString& outDevDescr) alContext=alcCreateContext(alOutDev,nullptr); if (!alcMakeContextCurrent(alContext)) { - qWarning() << "Audio: Cannot create output audio context"; + qWarning() << "Cannot create output audio context"; alcCloseDevice(alOutDev); } else @@ -190,7 +183,7 @@ void Audio::openOutput(const QString& outDevDescr) } - qDebug() << "Audio: Opening audio output "<resetCallSources(); // Force to regen each group call's sources @@ -198,7 +191,7 @@ void Audio::openOutput(const QString& outDevDescr) void Audio::closeInput() { - audioDebugLog("Closing input"); + qDebug() << "Closing input"; QMutexLocker lock(audioInLock); if (alInDev) { @@ -209,14 +202,14 @@ void Audio::closeInput() } else { - qWarning() << "Audio: Failed to close input"; + qWarning() << "Failed to close input"; } } } void Audio::closeOutput() { - audioDebugLog("Closing output"); + qDebug() << "Closing output"; QMutexLocker lock(audioOutLock); if (alContext && alcMakeContextCurrent(nullptr) == ALC_TRUE) alcDestroyContext(alContext); @@ -226,7 +219,7 @@ void Audio::closeOutput() if (alcCloseDevice(alOutDev) == ALC_TRUE) alOutDev = nullptr; else - qWarning() << "Audio: Failed to close output"; + qWarning() << "Failed to close output"; } } @@ -299,7 +292,7 @@ void Audio::playAudioBuffer(ALuint alSource, const int16_t *data, int samples, u } else { - qDebug() << "Audio: Dropped frame"; + qDebug() << "Dropped frame"; return; } diff --git a/src/autoupdate.cpp b/src/autoupdate.cpp index 9ed79bb1c..786343b3c 100644 --- a/src/autoupdate.cpp +++ b/src/autoupdate.cpp @@ -101,7 +101,7 @@ AutoUpdater::VersionInfo AutoUpdater::getUpdateVersion() if (reply->error() != QNetworkReply::NoError) { - qWarning() << "AutoUpdater: getUpdateVersion: network error: "<errorString(); + qWarning() << "getUpdateVersion: network error: " + reply->errorString(); reply->deleteLater(); manager->deleteLater(); return versionInfo; @@ -116,7 +116,7 @@ AutoUpdater::VersionInfo AutoUpdater::getUpdateVersion() // Check updater protocol version if ((int)data[0] != '2') { - qWarning() << "AutoUpdater: getUpdateVersion: Bad version "<<(uint8_t)data[0]; + qWarning() << "getUpdateVersion: Bad version " << (uint8_t)data[0]; return versionInfo; } @@ -128,7 +128,7 @@ AutoUpdater::VersionInfo AutoUpdater::getUpdateVersion() if (crypto_sign_verify_detached(sig, msg, msgData.size(), key) != 0) { - qCritical() << "AutoUpdater: getUpdateVersion: RECEIVED FORGED VERSION FILE FROM "< AutoUpdater::parseFlist(QByteArray flistData) if (flistData.isEmpty()) { - qWarning() << "AutoUpdater::parseflist: Empty data"; + qWarning() << "parseflist: Empty data"; return flist; } // Check version if (flistData[0] != '1') { - qWarning() << "AutoUpdater: parseflist: Bad version "<<(uint8_t)flistData[0]; + qWarning() << "parseflist: Bad version "<<(uint8_t)flistData[0]; return flist; } flistData = flistData.mid(1); @@ -162,7 +162,7 @@ QList AutoUpdater::parseFlist(QByteArray flistData) // Check signature if (flistData.size() < (int)(crypto_sign_BYTES)) { - qWarning() << "AutoUpdater::parseflist: Truncated data"; + qWarning() << "parseflist: Truncated data"; return flist; } else @@ -171,7 +171,7 @@ QList AutoUpdater::parseFlist(QByteArray flistData) unsigned char* msg = (unsigned char*)msgData.data(); if (crypto_sign_verify_detached((unsigned char*)flistData.data(), msg, msgData.size(), key) != 0) { - qCritical() << "AutoUpdater: parseflist: FORGED FLIST FILE"; + qCritical() << "parseflist: FORGED FLIST FILE"; return flist; } flistData = flistData.mid(crypto_sign_BYTES); @@ -211,7 +211,7 @@ QByteArray AutoUpdater::getUpdateFlist() if (reply->error() != QNetworkReply::NoError) { - qWarning() << "AutoUpdater: getUpdateFlist: network error: "<errorString(); + qWarning() << "getUpdateFlist: network error: " + reply->errorString(); reply->deleteLater(); manager->deleteLater(); return flist; @@ -231,7 +231,7 @@ QByteArray AutoUpdater::getLocalFlist() QFile flistFile("flist"); if (!flistFile.open(QIODevice::ReadOnly)) { - qWarning() << "AutoUpdater::getLocalFlist: Can't open local flist"; + qWarning() << "getLocalFlist: Can't open local flist"; return flist; } @@ -269,7 +269,7 @@ AutoUpdater::UpdateFile AutoUpdater::getUpdateFile(UpdateFileMeta fileMeta) if (reply->error() != QNetworkReply::NoError) { - qWarning() << "AutoUpdater: getUpdateFile: network error: "<errorString(); + qWarning() << "getUpdateFile: network error: " + reply->errorString(); reply->deleteLater(); manager->deleteLater(); return file; @@ -304,7 +304,7 @@ bool AutoUpdater::downloadUpdate() return false; } - qDebug() << "AutoUpdater: Need to update "<isFriendOnline(friendId)) return; - qDebug() << "AvatarBroadcaster: Sending avatar to "<sendAvatarFile(friendId, avatarData); friendsSentTo[friendId] = true; } diff --git a/src/chatlog/content/filetransferwidget.cpp b/src/chatlog/content/filetransferwidget.cpp index c64b5845a..4f2b32c76 100644 --- a/src/chatlog/content/filetransferwidget.cpp +++ b/src/chatlog/content/filetransferwidget.cpp @@ -121,7 +121,7 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path) if (Nexus::tryRemoveFile(filepath)) Core::getInstance()->acceptFileRecvRequest(fileInfo.friendId, fileInfo.fileNum, filepath); else - qWarning() << "Warning: Cannot write to " << filepath; + qWarning() << "Cannot write to " << filepath; } void FileTransferWidget::acceptTransfer(const QString &filepath) diff --git a/src/core/core.cpp b/src/core/core.cpp index abf81b489..241e491be 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -55,7 +55,7 @@ QThread* Core::coreThread{nullptr}; Core::Core(Camera* cam, QThread *CoreThread, QString loadPath) : tox(nullptr), toxav(nullptr), camera(cam), loadPath(loadPath), ready{false} { - qDebug() << "Core: loading Tox from" << loadPath; + qDebug() << "loading Tox from" << loadPath; coreThread = CoreThread; @@ -160,11 +160,11 @@ void Core::make_tox(QByteArray savedata) if (proxyAddr.length() > 255) { - qWarning() << "Core: proxy address" << proxyAddr << "is too long"; + qWarning() << "proxy address" << proxyAddr << "is too long"; } else if (proxyAddr != "" && proxyPort > 0) { - qDebug() << "Core: using proxy" << proxyAddr << ":" << proxyPort; + qDebug() << "using proxy" << proxyAddr << ":" << proxyPort; // protection against changings in TOX_PROXY_TYPE enum if (proxyType == ProxyType::ptSOCKS5) toxOptions.proxy_type = TOX_PROXY_TYPE_SOCKS5; @@ -191,7 +191,7 @@ void Core::make_tox(QByteArray savedata) { if (toxOptions.proxy_type != TOX_PROXY_TYPE_NONE) { - qCritical() << "Core: bad proxy! no toxcore!"; + qCritical() << "bad proxy! no toxcore!"; emit badProxy(); } else @@ -230,7 +230,7 @@ void Core::make_tox(QByteArray savedata) void Core::start() { - qDebug() << "Core: Starting up"; + qDebug() << "Starting up"; QByteArray savedata = loadToxSave(loadPath); @@ -310,7 +310,7 @@ void Core::start() } else { - qDebug() << "Core: Error loading self avatar"; + qDebug() << "Error loading self avatar"; } ready = true; @@ -374,15 +374,15 @@ bool Core::checkConnection() if (toxConnected && !isConnected) { - qDebug() << "Core: Connected to DHT"; + qDebug() << "Connected to DHT"; emit connected(); isConnected = true; - //if (count) qDebug() << "Core: disconnect count:" << count; + //if (count) qDebug() << "disconnect count:" << count; //count = 0; } else if (!toxConnected && isConnected) { - qDebug() << "Core: Disconnected to DHT"; + qDebug() << "Disconnected to DHT"; emit disconnected(); isConnected = false; //count++; @@ -398,12 +398,12 @@ void Core::bootstrapDht() int listSize = dhtServerList.size(); if (listSize == 0) { - qDebug() << "Settings: no bootstrap list?!?"; + qDebug() << "no bootstrap list?!?"; return; } static int j = qrand() % listSize; - qDebug() << "Core: Bootstrapping to the DHT ..."; + qDebug() << "Bootstrapping to the DHT ..."; int i=0; while (i < 2) // i think the more we bootstrap, the more we jitter because the more we overwrite nodes @@ -412,12 +412,13 @@ void Core::bootstrapDht() if (tox_bootstrap(tox, dhtServer.address.toLatin1().data(), dhtServer.port, CUserId(dhtServer.userId).data(), nullptr) == 1) { - qDebug() << QString("Core: Bootstrapping from ")+dhtServer.name+QString(", addr ")+dhtServer.address.toLatin1().data() - +QString(", port ")+QString().setNum(dhtServer.port); + qDebug() << "Bootstrapping from " + dhtServer.name + + ", addr " + dhtServer.address.toLatin1().data() + + ", port " + QString().setNum(dhtServer.port); } else { - qDebug() << "Core: Error bootstrapping from "+dhtServer.name; + qDebug() << "Error bootstrapping from "+dhtServer.name; } j++; @@ -498,17 +499,17 @@ void Core::onGroupInvite(Tox*, int32_t friendNumber, uint8_t type, const uint8_t QByteArray pk((char*)data, length); if (type == TOX_GROUPCHAT_TYPE_TEXT) { - qDebug() << QString("Core: Text group invite by %1").arg(friendNumber); + qDebug() << QString("Text group invite by %1").arg(friendNumber); emit static_cast(core)->groupInviteReceived(friendNumber,type,pk); } else if (type == TOX_GROUPCHAT_TYPE_AV) { - qDebug() << QString("Core: AV group invite by %1").arg(friendNumber); + qDebug() << QString("AV group invite by %1").arg(friendNumber); emit static_cast(core)->groupInviteReceived(friendNumber,type,pk); } else { - qWarning() << "Core: Group invite with unknown type "<(core)->groupNamelistChanged(groupnumber, peernumber, change); } void Core::onGroupTitleChange(Tox*, int groupnumber, int peernumber, const uint8_t* title, uint8_t len, void* _core) { - qDebug() << "Core: group" << groupnumber << "title changed by" << peernumber; + qDebug() << "group" << groupnumber << "title changed by" << peernumber; Core* core = static_cast(_core); QString author; if (peernumber >= 0) @@ -572,7 +573,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag } else { - qDebug() << "Core: requesting friendship of "+friendAddress; + qDebug() << "requesting friendship of "+friendAddress; CString cMessage(message); uint32_t friendId = tox_friend_add(tox, CFriendAddress(friendAddress).data(), @@ -877,7 +878,7 @@ QByteArray Core::loadToxSave(QString path) } QFile configurationFile(path); - qDebug() << "Core::loadConfiguration: reading from " << path; + qDebug() << "loadConfiguration: reading from " << path; if (!configurationFile.exists()) { @@ -972,9 +973,9 @@ void Core::switchConfiguration(const QString& _profile) } if (profile.isEmpty()) - qDebug() << "Core: creating new Id"; + qDebug() << "creating new Id"; else - qDebug() << "Core: switching from" << Settings::getInstance().getCurrentProfile() << "to" << profile; + qDebug() << "switching from" << Settings::getInstance().getCurrentProfile() << "to" << profile; saveConfiguration(); saveCurrentInformation(); // part of a hack, see core.h @@ -1070,7 +1071,7 @@ QString Core::getGroupPeerName(int groupId, int peerId) const int length = tox_group_peername(tox, groupId, peerId, nameArray); if (length == -1) { - qWarning() << "Core::getGroupPeerName: Unknown error"; + qWarning() << "getGroupPeerName: Unknown error"; return name; } name = CString::toString(nameArray, length); @@ -1085,7 +1086,7 @@ ToxID Core::getGroupPeerToxID(int groupId, int peerId) const int res = tox_group_peer_pubkey(tox, groupId, peerId, rawID); if (res == -1) { - qWarning() << "Core::getGroupPeerToxID: Unknown error"; + qWarning() << "getGroupPeerToxID: Unknown error"; return peerToxID; } @@ -1099,7 +1100,7 @@ QList Core::getGroupPeerNames(int groupId) const int nPeers = getGroupNumberPeers(groupId); if (nPeers == -1) { - qWarning() << "Core::getGroupPeerNames: Unable to get number of peers"; + qWarning() << "getGroupPeerNames: Unable to get number of peers"; return names; } uint8_t namesArray[nPeers][TOX_MAX_NAME_LENGTH]; @@ -1107,7 +1108,7 @@ QList Core::getGroupPeerNames(int groupId) const int result = tox_group_get_names(tox, groupId, namesArray, lengths, nPeers); if (result != nPeers) { - qWarning() << "Core::getGroupPeerNames: Unexpected result"; + qWarning() << "getGroupPeerNames: Unexpected result"; return names; } for (int i=0; i::max()) { - qWarning() << "Core::getPeerName: No such peer "+id.toString(); + qWarning() << "getPeerName: No such peer "+id.toString(); return name; } const size_t nameSize = tox_friend_get_name_size(tox, friendId, nullptr); if (nameSize == SIZE_MAX) { - //qDebug() << "Core::getPeerName: Can't get name of friend "+QString().setNum(friendId)+" ("+id.toString()+")"; + //qDebug() << "getPeerName: Can't get name of friend "+QString().setNum(friendId)+" ("+id.toString()+")"; return name; } uint8_t* cname = new uint8_t[nameSizecall_type == av_TypeVideo) { - qDebug() << QString("Core: answering call %1 with video").arg(callId); + qDebug() << QString("answering call %1 with video").arg(callId); toxav_answer(toxav, callId, transSettings); } else { - qDebug() << QString("Core: answering call %1 without video").arg(callId); + qDebug() << QString("answering call %1 without video").arg(callId); toxav_answer(toxav, callId, transSettings); } @@ -163,14 +163,14 @@ void Core::answerCall(int32_t callId) void Core::hangupCall(int32_t callId) { - qDebug() << QString("Core: hanging up call %1").arg(callId); + qDebug() << QString("hanging up call %1").arg(callId); calls[callId].active = false; toxav_hangup(toxav, callId); } void Core::rejectCall(int32_t callId) { - qDebug() << QString("Core: rejecting call %1").arg(callId); + qDebug() << QString("rejecting call %1").arg(callId); calls[callId].active = false; toxav_reject(toxav, callId, nullptr); } @@ -183,7 +183,7 @@ void Core::startCall(uint32_t friendId, bool video) cSettings.max_video_height = TOXAV_MAX_VIDEO_HEIGHT; if (video) { - qDebug() << QString("Core: Starting new call with %1 with video").arg(friendId); + qDebug() << QString("Starting new call with %1 with video").arg(friendId); cSettings.call_type = av_TypeVideo; if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0) { @@ -191,14 +191,14 @@ void Core::startCall(uint32_t friendId, bool video) } else { - qWarning() << QString("Core: Failed to start new video call with %1").arg(friendId); + qWarning() << QString("Failed to start new video call with %1").arg(friendId); emit avCallFailed(friendId); return; } } else { - qDebug() << QString("Core: Starting new call with %1 without video").arg(friendId); + qDebug() << QString("Starting new call with %1 without video").arg(friendId); cSettings.call_type = av_TypeAudio; if (toxav_call(toxav, &callId, friendId, &cSettings, TOXAV_RINGING_TIME) == 0) { @@ -206,7 +206,7 @@ void Core::startCall(uint32_t friendId, bool video) } else { - qWarning() << QString("Core: Failed to start new audio call with %1").arg(friendId); + qWarning() << QString("Failed to start new audio call with %1").arg(friendId); emit avCallFailed(friendId); return; } @@ -215,14 +215,14 @@ void Core::startCall(uint32_t friendId, bool video) void Core::cancelCall(int32_t callId, uint32_t friendId) { - qDebug() << QString("Core: Cancelling call with %1").arg(friendId); + qDebug() << QString("Cancelling call with %1").arg(friendId); calls[callId].active = false; toxav_cancel(toxav, callId, friendId, nullptr); } void Core::cleanupCall(int32_t callId) { - qDebug() << QString("Core: cleaning up call %1").arg(callId); + qDebug() << QString("cleaning up call %1").arg(callId); calls[callId].active = false; disconnect(calls[callId].sendAudioTimer,0,0,0); calls[callId].sendAudioTimer->stop(); @@ -296,13 +296,13 @@ void Core::sendCallAudio(int32_t callId, ToxAv* toxav) int r; if ((r = toxav_prepare_audio_frame(toxav, callId, dest, framesize*2, (int16_t*)buf, framesize)) < 0) { - qDebug() << "Core: toxav_prepare_audio_frame error"; + qDebug() << "toxav_prepare_audio_frame error"; calls[callId].sendAudioTimer->start(); return; } if ((r = toxav_send_audio(toxav, callId, dest, r)) < 0) - qDebug() << "Core: toxav_send_audio error"; + qDebug() << "toxav_send_audio error"; } calls[callId].sendAudioTimer->start(); } @@ -328,20 +328,20 @@ void Core::sendCallVideo(int32_t callId) int result; if ((result = toxav_prepare_video_frame(toxav, callId, videobuf, videobufsize, &frame)) < 0) { - qDebug() << QString("Core: toxav_prepare_video_frame: error %1").arg(result); + qDebug() << QString("toxav_prepare_video_frame: error %1").arg(result); vpx_img_free(&frame); calls[callId].sendVideoTimer->start(); return; } if ((result = toxav_send_video(toxav, callId, (uint8_t*)videobuf, result)) < 0) - qDebug() << QString("Core: toxav_send_video error: %1").arg(result); + qDebug() << QString("toxav_send_video error: %1").arg(result); vpx_img_free(&frame); } else { - qDebug("Core::sendCallVideo: Invalid frame (bad camera ?)"); + qDebug("sendCallVideo: Invalid frame (bad camera ?)"); } calls[callId].sendVideoTimer->start(); @@ -369,10 +369,10 @@ void Core::onAvCancel(void* _toxav, int32_t callId, void* core) int friendId = toxav_get_peer_id(toxav, callId, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV cancel"; + qWarning() << "Received invalid AV cancel"; return; } - qDebug() << QString("Core: AV cancel from %1").arg(friendId); + qDebug() << QString("AV cancel from %1").arg(friendId); calls[callId].active = false; @@ -394,11 +394,11 @@ void Core::onAvReject(void* _toxav, int32_t callId, void* core) int friendId = toxav_get_peer_id(toxav, callId, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV reject"; + qWarning() << "Received invalid AV reject"; return; } - qDebug() << QString("Core: AV reject from %1").arg(friendId); + qDebug() << QString("AV reject from %1").arg(friendId); emit static_cast(core)->avRejected(friendId, callId); } @@ -410,10 +410,10 @@ void Core::onAvEnd(void* _toxav, int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV end"; + qWarning() << "Received invalid AV end"; return; } - qDebug() << QString("Core: AV end from %1").arg(friendId); + qDebug() << QString("AV end from %1").arg(friendId); cleanupCall(call_index); @@ -427,18 +427,18 @@ void Core::onAvRinging(void* _toxav, int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV ringing"; + qWarning() << "Received invalid AV ringing"; return; } if (calls[call_index].videoEnabled) { - qDebug() << QString("Core: AV ringing with %1 with video").arg(friendId); + qDebug() << QString("AV ringing with %1 with video").arg(friendId); emit static_cast(core)->avRinging(friendId, call_index, true); } else { - qDebug() << QString("Core: AV ringing with %1 without video").arg(friendId); + qDebug() << QString("AV ringing with %1 without video").arg(friendId); emit static_cast(core)->avRinging(friendId, call_index, false); } } @@ -450,10 +450,10 @@ void Core::onAvRequestTimeout(void* _toxav, int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV request timeout"; + qWarning() << "Received invalid AV request timeout"; return; } - qDebug() << QString("Core: AV request timeout with %1").arg(friendId); + qDebug() << QString("AV request timeout with %1").arg(friendId); cleanupCall(call_index); @@ -467,10 +467,10 @@ void Core::onAvPeerTimeout(void* _toxav, int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV peer timeout"; + qWarning() << "Received invalid AV peer timeout"; return; } - qDebug() << QString("Core: AV peer timeout with %1").arg(friendId); + qDebug() << QString("AV peer timeout with %1").arg(friendId); cleanupCall(call_index); @@ -485,7 +485,7 @@ void Core::onAvInvite(void* _toxav, int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV invite"; + qWarning() << "Received invalid AV invite"; return; } @@ -493,19 +493,19 @@ void Core::onAvInvite(void* _toxav, int32_t call_index, void* core) int err = toxav_get_peer_csettings(toxav, call_index, 0, transSettings); if (err != av_ErrorNone) { - qWarning() << "Core::onAvInvite: error getting call type"; + qWarning() << "onAvInvite: error getting call type"; delete transSettings; return; } if (transSettings->call_type == av_TypeVideo) { - qDebug() << QString("Core: AV invite from %1 with video").arg(friendId); + qDebug() << QString("AV invite from %1 with video").arg(friendId); emit static_cast(core)->avInvite(friendId, call_index, true); } else { - qDebug() << QString("Core: AV invite from %1 without video").arg(friendId); + qDebug() << QString("AV invite from %1 without video").arg(friendId); emit static_cast(core)->avInvite(friendId, call_index, false); } @@ -519,7 +519,7 @@ void Core::onAvStart(void* _toxav, int32_t call_index, void* core) int friendId = toxav_get_peer_id(toxav, call_index, 0); if (friendId < 0) { - qWarning() << "Core: Received invalid AV start"; + qWarning() << "Received invalid AV start"; return; } @@ -527,20 +527,20 @@ void Core::onAvStart(void* _toxav, int32_t call_index, void* core) int err = toxav_get_peer_csettings(toxav, call_index, 0, transSettings); if (err != av_ErrorNone) { - qWarning() << "Core::onAvStart: error getting call type"; + qWarning() << "onAvStart: error getting call type"; delete transSettings; return; } if (transSettings->call_type == av_TypeVideo) { - qDebug() << QString("Core: AV start from %1 with video").arg(friendId); + qDebug() << QString("AV start from %1 with video").arg(friendId); prepareCall(friendId, call_index, toxav, true); emit static_cast(core)->avStart(friendId, call_index, true); } else { - qDebug() << QString("Core: AV start from %1 without video").arg(friendId); + qDebug() << QString("AV start from %1 without video").arg(friendId); prepareCall(friendId, call_index, toxav, false); emit static_cast(core)->avStart(friendId, call_index, false); } @@ -553,7 +553,7 @@ void Core::playAudioBuffer(ALuint alSource, const int16_t *data, int samples, un { if (!channels || channels > 2) { - qWarning() << "Core::playAudioBuffer: trying to play on "<stop(); @@ -657,7 +657,7 @@ void Core::sendGroupCallAudio(int groupId, ToxAv* toxav) if (toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf, framesize, av_DefaultSettings.audio_channels, av_DefaultSettings.audio_sample_rate) < 0) { - qDebug() << "Core: toxav_group_send_audio error"; + qDebug() << "toxav_group_send_audio error"; groupCalls[groupId].sendAudioTimer->start(); return; } diff --git a/src/core/coreencryption.cpp b/src/core/coreencryption.cpp index 5096d58ac..93b311088 100644 --- a/src/core/coreencryption.cpp +++ b/src/core/coreencryption.cpp @@ -112,7 +112,7 @@ QByteArray Core::encryptData(const QByteArray& data, PasswordType passtype) if (!tox_pass_key_encrypt(reinterpret_cast(data.data()), data.size(), pwsaltedkeys[passtype], encrypted, nullptr)) { - qWarning() << "Core::encryptData: encryption failed"; + qWarning() << "encryptData: encryption failed"; return QByteArray(); } return QByteArray(reinterpret_cast(encrypted), data.size() + TOX_PASS_ENCRYPTION_EXTRA_LENGTH); @@ -128,7 +128,7 @@ QByteArray Core::decryptData(const QByteArray& data, PasswordType passtype) if (!tox_pass_key_decrypt(reinterpret_cast(data.data()), data.size(), pwsaltedkeys[passtype], decrypted, nullptr)) { - qWarning() << "Core::decryptData: decryption failed"; + qWarning() << "decryptData: decryption failed"; return QByteArray(); } return QByteArray(reinterpret_cast(decrypted), sz); @@ -147,7 +147,7 @@ QByteArray Core::getSaltFromFile(QString filename) QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "Core: file" << filename << "doesn't exist"; + qWarning() << "file" << filename << "doesn't exist"; return QByteArray(); } QByteArray data = file.read(TOX_PASS_ENCRYPTION_EXTRA_LENGTH); @@ -156,7 +156,7 @@ QByteArray Core::getSaltFromFile(QString filename) uint8_t *salt = new uint8_t[TOX_PASS_SALT_LENGTH]; if (!tox_get_salt(reinterpret_cast(data.data()), salt)) { - qWarning() << "Core: can't get salt from" << filename << "header"; + qWarning() << "can't get salt from" << filename << "header"; return QByteArray(); } @@ -263,7 +263,7 @@ void Core::checkEncryptedHistory() useOtherPassword(ptHistory); if (!exists || HistoryKeeper::checkPassword()) { - qDebug() << "Core: using main password for chat history"; + qDebug() << "using main password for chat history"; return; } clearPassword(ptHistory); @@ -299,7 +299,7 @@ void Core::saveConfiguration(const QString& path) if (!isReady()) { - qWarning() << "Core::saveConfiguration: Tox not started, aborting!"; + qWarning() << "saveConfiguration: Tox not started, aborting!"; return; } @@ -310,7 +310,7 @@ void Core::saveConfiguration(const QString& path) return; } - qDebug() << "Core: writing tox_save to " << path; + qDebug() << "writing tox_save to " << path; uint32_t fileSize = tox_get_savedata_size(tox); bool encrypt = Settings::getInstance().getEncryptTox(); diff --git a/src/core/corefile.cpp b/src/core/corefile.cpp index 11c8dc5ff..744318f2f 100644 --- a/src/core/corefile.cpp +++ b/src/core/corefile.cpp @@ -24,10 +24,10 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d nullptr, filename, TOX_HASH_LENGTH, nullptr); if (fileNum == std::numeric_limits::max()) { - qWarning() << "CoreFile::sendAvatarFile: Can't create the Tox file sender"; + qWarning() << "sendAvatarFile: Can't create the Tox file sender"; return; } - //qDebug() << QString("CoreFile::sendAvatarFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId); + //qDebug() << QString("sendAvatarFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId); ToxFile file{fileNum, friendId, "", "", ToxFile::SENDING}; file.filesize = filesize; @@ -48,11 +48,11 @@ void CoreFile::sendFile(Core* core, uint32_t friendId, QString Filename, QString (uint8_t*)fileName.data(), fileName.size(), nullptr); if (fileNum == std::numeric_limits::max()) { - qWarning() << "CoreFile::sendFile: Can't create the Tox file sender"; + qWarning() << "sendFile: Can't create the Tox file sender"; emit core->fileSendFailed(friendId, Filename); return; } - qDebug() << QString("CoreFile::sendFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId); + qDebug() << QString("sendFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId); ToxFile file{fileNum, friendId, fileName, FilePath, ToxFile::SENDING}; file.filesize = filesize; @@ -60,7 +60,7 @@ void CoreFile::sendFile(Core* core, uint32_t friendId, QString Filename, QString tox_file_get_file_id(core->tox, friendId, fileNum, (uint8_t*)file.resumeFileId.data(), nullptr); if (!file.open(false)) { - qWarning() << QString("CoreFile::sendFile: Can't open file, error: %1").arg(file.file->errorString()); + qWarning() << QString("sendFile: Can't open file, error: %1").arg(file.file->errorString()); } addFile(friendId, fileNum, file); @@ -72,7 +72,7 @@ void CoreFile::pauseResumeFileSend(Core* core, uint32_t friendId, uint32_t fileI ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::pauseResumeFileSend: No such file in queue"); + qWarning("pauseResumeFileSend: No such file in queue"); return; } if (file->status == ToxFile::TRANSMITTING) @@ -88,7 +88,7 @@ void CoreFile::pauseResumeFileSend(Core* core, uint32_t friendId, uint32_t fileI tox_file_control(core->tox, file->friendId, file->fileNum, TOX_FILE_CONTROL_RESUME, nullptr); } else - qWarning() << "CoreFile::pauseResumeFileSend: File is stopped"; + qWarning() << "pauseResumeFileSend: File is stopped"; } void CoreFile::pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileId) @@ -96,7 +96,7 @@ void CoreFile::pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileI ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::cancelFileRecv: No such file in queue"); + qWarning("cancelFileRecv: No such file in queue"); return; } if (file->status == ToxFile::TRANSMITTING) @@ -112,7 +112,7 @@ void CoreFile::pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileI tox_file_control(core->tox, file->friendId, file->fileNum, TOX_FILE_CONTROL_RESUME, nullptr); } else - qWarning() << "CoreFile::pauseResumeFileRecv: File is stopped or broken"; + qWarning() << "pauseResumeFileRecv: File is stopped or broken"; } void CoreFile::cancelFileSend(Core* core, uint32_t friendId, uint32_t fileId) @@ -120,7 +120,7 @@ void CoreFile::cancelFileSend(Core* core, uint32_t friendId, uint32_t fileId) ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::cancelFileSend: No such file in queue"); + qWarning("cancelFileSend: No such file in queue"); return; } file->status = ToxFile::STOPPED; @@ -135,7 +135,7 @@ void CoreFile::cancelFileRecv(Core* core, uint32_t friendId, uint32_t fileId) ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::cancelFileRecv: No such file in queue"); + qWarning("cancelFileRecv: No such file in queue"); return; } file->status = ToxFile::STOPPED; @@ -149,7 +149,7 @@ void CoreFile::rejectFileRecvRequest(Core* core, uint32_t friendId, uint32_t fil ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::rejectFileRecvRequest: No such file in queue"); + qWarning("rejectFileRecvRequest: No such file in queue"); return; } file->status = ToxFile::STOPPED; @@ -163,13 +163,13 @@ void CoreFile::acceptFileRecvRequest(Core* core, uint32_t friendId, uint32_t fil ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::acceptFileRecvRequest: No such file in queue"); + qWarning("acceptFileRecvRequest: No such file in queue"); return; } file->setFilePath(path); if (!file->open(true)) { - qWarning() << "CoreFile::acceptFileRecvRequest: Unable to open file"; + qWarning() << "acceptFileRecvRequest: Unable to open file"; return; } file->status = ToxFile::TRANSMITTING; @@ -182,7 +182,7 @@ ToxFile* CoreFile::findFile(uint32_t friendId, uint32_t fileId) uint64_t key = ((uint64_t)friendId<<32) + (uint64_t)fileId; if (!fileMap.contains(key)) { - qWarning() << "CoreFile::findFile: File transfer with ID "<close(); @@ -213,7 +213,7 @@ void CoreFile::onFileReceiveCallback(Tox*, uint32_t friendId, uint32_t fileId, u uint64_t filesize, const uint8_t *fname, size_t fnameLen, void *_core) { Core* core = static_cast(_core); - qDebug() << QString("CoreFile: Received file request %1:%2 kind %3") + qDebug() << QString("Received file request %1:%2 kind %3") .arg(friendId).arg(fileId).arg(kind); if (kind == TOX_FILE_KIND_AVATAR) @@ -256,25 +256,25 @@ void CoreFile::onFileControlCallback(Tox*, uint32_t friendId, uint32_t fileId, ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::onFileControlCallback: No such file in queue"); + qWarning("onFileControlCallback: No such file in queue"); return; } if (control == TOX_FILE_CONTROL_CANCEL) { - qDebug() << "CoreFile::onFileControlCallback: Received cancel for file "<(core)->fileTransferCancelled(*file); removeFile(friendId, fileId); } else if (control == TOX_FILE_CONTROL_PAUSE) { - qDebug() << "CoreFile::onFileControlCallback: Received pause for file "<status = ToxFile::PAUSED; emit static_cast(core)->fileTransferRemotePausedUnpaused(*file, true); } else if (control == TOX_FILE_CONTROL_RESUME) { - qDebug() << "CoreFile::onFileControlCallback: Received pause for file "<status = ToxFile::TRANSMITTING; emit static_cast(core)->fileTransferRemotePausedUnpaused(*file, false); } @@ -292,14 +292,14 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId, ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::onFileDataCallback: No such file in queue"); + qWarning("onFileDataCallback: No such file in queue"); return; } // If we reached EOF, ack and cleanup the transfer if (!length) { - //qDebug("CoreFile::onFileDataCallback: File sending completed"); + //qDebug("onFileDataCallback: File sending completed"); if (file->fileKind != TOX_FILE_KIND_AVATAR) emit static_cast(core)->fileTransferFinished(*file); removeFile(friendId, fileId); @@ -321,7 +321,7 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId, nread = file->file->read((char*)data.get(), length); if (nread <= 0) { - qWarning("CoreFile::onFileDataCallback: Failed to read from file"); + qWarning("onFileDataCallback: Failed to read from file"); emit static_cast(core)->fileTransferCancelled(*file); tox_file_send_chunk(tox, friendId, fileId, pos, nullptr, 0, nullptr); removeFile(friendId, fileId); @@ -332,7 +332,7 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId, if (!tox_file_send_chunk(tox, friendId, fileId, pos, data.get(), nread, nullptr)) { - qWarning("CoreFile::onFileDataCallback: Failed to send data chunk"); + qWarning("onFileDataCallback: Failed to send data chunk"); return; } if (file->fileKind != TOX_FILE_KIND_AVATAR) @@ -342,13 +342,13 @@ 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("CoreFile: Received chunk for %1:%2 pos %3 size %4") + //qDebug() << QString("Received chunk for %1:%2 pos %3 size %4") // .arg(friendId).arg(fileId).arg(position).arg(length); ToxFile* file = findFile(friendId, fileId); if (!file) { - qWarning("CoreFile::onFileRecvChunkCallback: No such file in queue"); + qWarning("onFileRecvChunkCallback: No such file in queue"); tox_file_control(tox, friendId, fileId, TOX_FILE_CONTROL_CANCEL, nullptr); return; } @@ -356,7 +356,7 @@ void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fil if (file->bytesSent != position) { /// TODO: Allow ooo receiving for non-stream transfers, with very careful checking - qWarning("CoreFile::onFileRecvChunkCallback: Received a chunk out-of-order, aborting transfer"); + qWarning("onFileRecvChunkCallback: Received a chunk out-of-order, aborting transfer"); if (file->fileKind != TOX_FILE_KIND_AVATAR) emit static_cast(core)->fileTransferCancelled(*file); tox_file_control(tox, friendId, fileId, TOX_FILE_CONTROL_CANCEL, nullptr); @@ -372,7 +372,7 @@ void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fil pic.loadFromData(file->avatarData); if (!pic.isNull()) { - qDebug() << "Core: Got"<avatarData.size()<<"bytes of avatar data from" + qDebug() << "Got"<avatarData.size()<<"bytes of avatar data from" << static_cast(core)->getFriendUsername(friendId); Settings::getInstance().saveAvatar(pic, static_cast(core)->getFriendAddress(friendId)); Settings::getInstance().saveAvatarHash(file->fileName, static_cast(core)->getFriendAddress(friendId)); diff --git a/src/friendlist.cpp b/src/friendlist.cpp index 100d07169..ffe095329 100644 --- a/src/friendlist.cpp +++ b/src/friendlist.cpp @@ -28,7 +28,7 @@ Friend* FriendList::addFriend(int friendId, const ToxID& userId) { auto friendChecker = friendList.find(friendId); if (friendChecker != friendList.end()) - qWarning() << "FriendList::addFriend: friendId already taken"; + qWarning() << "addFriend: friendId already taken"; Friend* newfriend = new Friend(friendId, userId); friendList[friendId] = newfriend; diff --git a/src/group.cpp b/src/group.cpp index 78932545c..36f75a70e 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -47,7 +47,7 @@ Group::~Group() void Group::addPeer(int peerId, QString name) { if (peers.contains(peerId)) - qWarning() << "Group::addPeer: peerId already used, overwriting anyway"; + qWarning() << "addPeer: peerId already used, overwriting anyway"; if (name.isEmpty()) peers[peerId] = ""; else diff --git a/src/grouplist.cpp b/src/grouplist.cpp index 52ea2f66f..6dbb8c542 100644 --- a/src/grouplist.cpp +++ b/src/grouplist.cpp @@ -25,7 +25,7 @@ Group* GroupList::addGroup(int groupId, const QString& name, bool isAvGroupchat) { auto checker = groupList.find(groupId); if (checker != groupList.end()) - qWarning() << "GroupList::addGroup: groupId already taken"; + qWarning() << "addGroup: groupId already taken"; Group* newGroup = new Group(groupId, name, isAvGroupchat); groupList[groupId] = newGroup; diff --git a/src/historykeeper.cpp b/src/historykeeper.cpp index b47b5c1d2..a5113f486 100644 --- a/src/historykeeper.cpp +++ b/src/historykeeper.cpp @@ -432,9 +432,9 @@ bool HistoryKeeper::removeHistory(int encrypted) QList HistoryKeeper::exportMessagesDeleteFile(int encrypted) { auto msgs = getInstance()->exportMessages(); - qDebug() << "HistoryKeeper: count" << msgs.size() << "messages exported"; + qDebug() << "count" << msgs.size() << "messages exported"; if (!removeHistory(encrypted)) - qWarning() << "HistoryKeeper: couldn't delete old log file!"; + qWarning() << "couldn't delete old log file!"; return msgs; } diff --git a/src/ipc.cpp b/src/ipc.cpp index 858dc4195..0669ee954 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -39,10 +39,10 @@ IPC::IPC() qsrand(time(0)); globalId = ((uint64_t)qrand()) * ((uint64_t)qrand()) * ((uint64_t)qrand()); - qDebug() << "IPC: Our global ID is " << globalId; + qDebug() << "Our global ID is " << globalId; if (globalMemory.create(sizeof(IPCMemory))) { - qDebug() << "IPC: Creating the global shared memory and taking ownership"; + qDebug() << "Creating the global shared memory and taking ownership"; if (globalMemory.lock()) { IPCMemory* mem = global(); @@ -53,16 +53,16 @@ IPC::IPC() } else { - qWarning() << "IPC: Couldn't lock to take ownership"; + qWarning() << "Couldn't lock to take ownership"; } } else if (globalMemory.attach()) { - qDebug() << "IPC: Attaching to the global shared memory"; + qDebug() << "Attaching to the global shared memory"; } else { - qDebug() << "IPC: Failed to attach to the global shared memory, giving up"; + qDebug() << "Failed to attach to the global shared memory, giving up"; return; // We won't be able to do any IPC without being attached, let's get outta here } @@ -119,13 +119,13 @@ time_t IPC::postEvent(const QString &name, const QByteArray& data/*=QByteArray() mem->lastEvent = evt->posted = result = qMax(mem->lastEvent + 1, time(0)); evt->dest = dest; evt->sender = getpid(); - qDebug() << "IPC: postEvent " << name << "to" << dest; + qDebug() << "postEvent " << name << "to" << dest; } globalMemory.unlock(); return result; } else - qDebug() << "IPC: Failed to lock in postEvent()"; + qDebug() << "Failed to lock in postEvent()"; return 0; } @@ -137,7 +137,7 @@ bool IPC::isCurrentOwner() void* data = globalMemory.data(); if (!data) { - qWarning() << "IPC: isCurrentOwner failed to access the memory, returning false"; + qWarning() << "isCurrentOwner failed to access the memory, returning false"; globalMemory.unlock(); return false; } @@ -147,7 +147,7 @@ bool IPC::isCurrentOwner() } else { - qWarning() << "IPC: isCurrentOwner failed to lock, returning false"; + qWarning() << "isCurrentOwner failed to lock, returning false"; return false; } } @@ -178,7 +178,7 @@ bool IPC::isEventAccepted(time_t time) } else { - qWarning() << "IPC: isEventAccepted failed to lock, returning false"; + qWarning() << "isEventAccepted failed to lock, returning false"; } return result; } @@ -254,7 +254,7 @@ void IPC::processEvents() // Only the owner processes events. But if the previous owner's dead, we can take ownership now if (difftime(time(0), mem->lastProcessed) >= OWNERSHIP_TIMEOUT_S) { - qDebug() << "IPC: Previous owner timed out, taking ownership" << mem->globalId << "->" << globalId; + qDebug() << "Previous owner timed out, taking ownership" << mem->globalId << "->" << globalId; // Ignore events that were not meant for this instance memset(mem, 0, sizeof(IPCMemory)); mem->globalId = globalId; @@ -269,7 +269,7 @@ void IPC::processEvents() auto it = eventHandlers.find(name); if (it != eventHandlers.end()) { - qDebug() << "IPC: Processing event: " << name << ":" << evt->posted << "=" << evt->accepted; + qDebug() << "Processing event: " << name << ":" << evt->posted << "=" << evt->accepted; evt->accepted = runEventHandler(it.value(), evt->data); if (evt->dest == 0) { diff --git a/src/main.cpp b/src/main.cpp index 9d60a66f8..46e4fabcd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) } else { - qWarning() << "Error: -p profile" << profile + ".tox" << "doesn't exist"; + qCritical() << "-p profile" << profile + ".tox" << "doesn't exist"; return EXIT_FAILURE; } } diff --git a/src/misc/db/encrypteddb.cpp b/src/misc/db/encrypteddb.cpp index 1228dc21d..8f504c2a9 100644 --- a/src/misc/db/encrypteddb.cpp +++ b/src/misc/db/encrypteddb.cpp @@ -33,7 +33,7 @@ EncryptedDb::EncryptedDb(const QString &fname, QList initList) : QByteArray fileContent; if (pullFileContent(fileName, buffer)) { - qDebug() << "EncryptedDb: writing old data"; + qDebug() << "writing old data"; encrFile.setFileName(fileName); encrFile.open(QIODevice::ReadOnly); fileContent = encrFile.readAll(); @@ -78,7 +78,7 @@ bool EncryptedDb::pullFileContent(const QString &fname, QByteArray &buf) QFile dbFile(fname); if (!dbFile.open(QIODevice::ReadOnly)) { - qDebug() << "EncryptedDb::pullFileContent: file doesn't exist"; + qDebug() << "pullFileContent: file doesn't exist"; buf = QByteArray(); return false; } @@ -87,7 +87,7 @@ bool EncryptedDb::pullFileContent(const QString &fname, QByteArray &buf) while (!dbFile.atEnd()) { QByteArray encrChunk = dbFile.read(encryptedChunkSize); - qDebug() << "EncryptedDb::pullFileContent: got chunk:" << encrChunk.size(); + qDebug() << "pullFileContent: got chunk:" << encrChunk.size(); buf = Core::getInstance()->decryptData(encrChunk, Core::ptHistory); if (buf.size() > 0) { @@ -95,7 +95,7 @@ bool EncryptedDb::pullFileContent(const QString &fname, QByteArray &buf) } else { - qWarning() << "EncryptedDb::pullFileContent: Encrypted history log is corrupted: can't decrypt, will be deleted"; + qWarning() << "pullFileContent: Encrypted history log is corrupted: can't decrypt, will be deleted"; buf = QByteArray(); return false; } diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index 56c8dbff6..a75d0cd91 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -204,7 +204,7 @@ void Settings::load() } } - qDebug() << "Settings: Loading from "<("Status"); diff --git a/src/profilelocker.cpp b/src/profilelocker.cpp index b033410c4..e7e758062 100644 --- a/src/profilelocker.cpp +++ b/src/profilelocker.cpp @@ -53,7 +53,7 @@ void ProfileLocker::unlock() void ProfileLocker::clearAllLocks() { - qDebug() << "ProfileLocker::clearAllLocks: Wiping out all lock files"; + qDebug() << "clearAllLocks: Wiping out all lock files"; if (lockfile) unlock(); @@ -72,7 +72,7 @@ void ProfileLocker::assertLock() { if (!lockfile) { - qCritical() << "ProfileLocker::assertLock: We don't seem to own any lock!"; + qCritical() << "assertLock: We don't seem to own any lock!"; deathByBrokenLock(); } @@ -82,11 +82,11 @@ void ProfileLocker::assertLock() unlock(); if (lock(tmp)) { - qCritical() << "ProfileLocker::assertLock: Lock file was lost, but could be restored"; + qCritical() << "assertLock: Lock file was lost, but could be restored"; } else { - qCritical() << "ProfileLocker::assertLock: Lock file was lost, and could *NOT* be restored"; + qCritical() << "assertLock: Lock file was lost, and could *NOT* be restored"; deathByBrokenLock(); } } @@ -94,6 +94,6 @@ void ProfileLocker::assertLock() void ProfileLocker::deathByBrokenLock() { - qCritical() << "ProfileLocker: Lock is *BROKEN*, exiting immediately"; + qCritical() << "Lock is *BROKEN*, exiting immediately"; abort(); } diff --git a/src/toxdns.cpp b/src/toxdns.cpp index 6d6b7ee3f..968903d32 100644 --- a/src/toxdns.cpp +++ b/src/toxdns.cpp @@ -172,7 +172,7 @@ QString ToxDNS::queryTox3(const tox3_server& server, const QString &record, bool void* tox_dns3 = tox_dns3_new(server.pubkey); if (!tox_dns3) { - qWarning() << "queryTox3: failed to create a tox_dns3 object for "< keypair = Core::getInstance()->getKeypair(); if (keypair.first.isEmpty() || keypair.second.isEmpty()) { - qWarning() << "Toxme::prepareEncryptedJson: Couldn't get our keypair, aborting"; + qWarning() << "prepareEncryptedJson: Couldn't get our keypair, aborting"; return QByteArray(); } diff --git a/src/video/cameraworker.cpp b/src/video/cameraworker.cpp index d4b1abb17..772f9a7c4 100644 --- a/src/video/cameraworker.cpp +++ b/src/video/cameraworker.cpp @@ -50,14 +50,14 @@ void CameraWorker::onStart() void CameraWorker::_suspend() { - qDebug() << "CameraWorker: Suspend"; + qDebug() << "Suspend"; clock->stop(); unsubscribe(); } void CameraWorker::_resume() { - qDebug() << "CameraWorker: Resume"; + qDebug() << "Resume"; subscribe(); clock->start(); } @@ -126,7 +126,7 @@ void CameraWorker::_probeResolutions() unsubscribe(); - qDebug() << "CameraWorker: Resolutions" <clock->stop(); // prevent log spamming - qDebug() << "CameraWorker: stopped clock"; + qDebug() << "stopped clock"; } if (!bSuccess) { - qDebug() << "CameraWorker: Cannot read frame"; + qDebug() << "Cannot read frame"; return; } diff --git a/src/widget/androidgui.cpp b/src/widget/androidgui.cpp index c64e75524..aba6de0d4 100644 --- a/src/widget/androidgui.cpp +++ b/src/widget/androidgui.cpp @@ -94,11 +94,11 @@ void AndroidGUI::keyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Back) { - qDebug() << "AndroidGUI: Back key pressed, quitting"; + qDebug() << "Back key pressed, quitting"; qApp->exit(0); } else if (event->key() == Qt::Key_Menu) { - qDebug() << "AndroidGUI: Menu key pressed"; + qDebug() << "Menu key pressed"; } } diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index e97589c44..f52736395 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -360,7 +360,7 @@ void GeneralForm::reloadSmiles() QList emoticons = SmileyPack::getInstance().getEmoticons(); if (emoticons.isEmpty()) { // sometimes there are no emoticons available, don't crash in this case - qDebug() << "GeneralForm::reloadSmilies: No emoticons found"; + qDebug() << "reloadSmilies: No emoticons found"; return; } diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 4f0c13de8..3555e9adf 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -109,7 +109,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) { dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir); autoAccept->setChecked(true); - qDebug() << "FriendWidget: setting auto accept dir for" << friendId << "to" << dir; + qDebug() << "setting auto accept dir for" << friendId << "to" << dir; Settings::getInstance().setAutoAcceptDir(id, dir); } } diff --git a/src/widget/systemtrayicon.cpp b/src/widget/systemtrayicon.cpp index 922001c27..dedafa054 100644 --- a/src/widget/systemtrayicon.cpp +++ b/src/widget/systemtrayicon.cpp @@ -18,7 +18,7 @@ SystemTrayIcon::SystemTrayIcon() #ifdef ENABLE_SYSTRAY_UNITY_BACKEND else if (desktop == "unity") { - qDebug() << "SystemTrayIcon: Using Unity backend"; + qDebug() << "Using Unity backend"; gtk_init(nullptr, nullptr); QString settingsDir = Settings::getSettingsDirPath(); QFile iconFile(settingsDir+"/icon.png"); @@ -44,7 +44,7 @@ SystemTrayIcon::SystemTrayIcon() #ifdef ENABLE_SYSTRAY_GTK_BACKEND else if (desktop == "xfce" || desktop.contains("gnome")) { - qDebug() << "SystemTrayIcon: Using GTK backend"; + qDebug() << "Using GTK backend"; backendType = SystrayBackendType::GTK; gtk_init(nullptr, nullptr); void (*callbackFreeImage)(guchar*, gpointer) = @@ -80,7 +80,7 @@ SystemTrayIcon::SystemTrayIcon() else if (desktop == "kde" && getenv("KDE_SESSION_VERSION") == QString("5")) { - qDebug() << "SystemTrayIcon: Using Status Notifier backend"; + qDebug() << "Using Status Notifier backend"; backendType = SystrayBackendType::StatusNotifier; gtk_init(nullptr, nullptr); snMenu = gtk_menu_new(); @@ -105,11 +105,11 @@ SystemTrayIcon::SystemTrayIcon() && getenv("KDE_SESSION_VERSION") == QString("5")) { backendType = SystrayBackendType::KDE5; - qWarning() << "SystemTrayIcon: Detected a KDE5 session, but we don't have Status Notifier support. Disabling the systray icon"; + qWarning() << "Detected a KDE5 session, but we don't have Status Notifier support. Disabling the systray icon"; } else { - qDebug() << "SystemTrayIcon: Using the Qt backend"; + qDebug() << "Using the Qt backend"; qtIcon = new QSystemTrayIcon; backendType = SystrayBackendType::Qt; connect(qtIcon, &QSystemTrayIcon::activated, this, &SystemTrayIcon::activated); diff --git a/src/widget/videosurface.cpp b/src/widget/videosurface.cpp index 7d6ccf949..b8ba2c9f2 100644 --- a/src/widget/videosurface.cpp +++ b/src/widget/videosurface.cpp @@ -71,7 +71,7 @@ void VideoSurface::setSource(VideoSource *src) void VideoSurface::initializeGL() { QGLWidget::initializeGL(); - qDebug() << "VideoSurface: Init"; + qDebug() << "Init"; // pbo pbo[0] = new QOpenGLBuffer(QOpenGLBuffer::PixelUnpackBuffer); pbo[0]->setUsagePattern(QOpenGLBuffer::StreamDraw); @@ -156,7 +156,7 @@ void VideoSurface::paintGL() if (pboAllocSize != currFrame.frameData.size()) { - qDebug() << "VideoSurface: Resize pbo " << currFrame.frameData.size() << "(" << currFrame.resolution << ")" << "bytes (before" << pboAllocSize << ")"; + qDebug() << "Resize pbo " << currFrame.frameData.size() << "(" << currFrame.resolution << ")" << "bytes (before" << pboAllocSize << ")"; pbo[0]->bind(); pbo[0]->allocate(currFrame.frameData.size()); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 91a65ca79..ea6843727 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -313,7 +313,7 @@ void Widget::updateIcons() Widget::~Widget() { - qDebug() << "Widget: Deleting Widget"; + qDebug() << "Deleting Widget"; AutoUpdater::abortUpdates(); if (icon) icon->hide(); @@ -609,7 +609,7 @@ void Widget::reloadHistory() void Widget::addFriend(int friendId, const QString &userId) { - //qDebug() << "Widget: Adding friend with id" << userId; + //qDebug() << "Adding friend with id" << userId; ToxID userToxId = ToxID::fromString(userId); Friend* newfriend = FriendList::addFriend(friendId, userToxId); contactListWidget->moveWidget(newfriend->getFriendWidget(),Status::Offline); @@ -654,7 +654,7 @@ void Widget::addFriend(int friendId, const QString &userId) QPixmap avatar = Settings::getInstance().getSavedAvatar(userId); if (!avatar.isNull()) { - //qWarning() << "Widget: loadded avatar for id" << userId; + //qWarning() << "loadded avatar for id" << userId; newfriend->getChatForm()->onAvatarChange(friendId, avatar); newfriend->getFriendWidget()->onAvatarChange(friendId, avatar); } @@ -931,14 +931,14 @@ void Widget::onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray in int groupId = Nexus::getCore()->joinGroupchat(friendId, type, (uint8_t*)invite.data(), invite.length()); if (groupId < 0) { - qWarning() << "Widget::onGroupInviteReceived: Unable to accept group invite"; + qWarning() << "onGroupInviteReceived: Unable to accept group invite"; return; } } } else { - qWarning() << "Widget::onGroupInviteReceived: Unknown groupchat type:"<= autoAwayTime) { - qDebug() << "Widget: auto away activated at" << QTime::currentTime().toString(); + qDebug() << "auto away activated at" << QTime::currentTime().toString(); emit statusSet(Status::Away); autoAwayActive = true; } @@ -1138,7 +1138,7 @@ void Widget::onUserAwayCheck() { if (autoAwayActive && (!autoAwayTime || Platform::getIdleTime() < autoAwayTime)) { - qDebug() << "Widget: auto away deactivated at" << QTime::currentTime().toString(); + qDebug() << "auto away deactivated at" << QTime::currentTime().toString(); emit statusSet(Status::Online); autoAwayActive = false; } @@ -1203,7 +1203,7 @@ void Widget::onTryCreateTrayIcon() disconnect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon); if (!icon) { - qWarning() << "Widget: No system tray detected!"; + qWarning() << "No system tray detected!"; show(); } } From e3eb4ea503fcac57fb5198380892e6a128d09419 Mon Sep 17 00:00:00 2001 From: sudden6 Date: Mon, 11 May 2015 15:01:09 +0200 Subject: [PATCH 3/3] remove useless code opencv uses exceptions for error handling --- src/main.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 46e4fabcd..eeabbeefb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -87,14 +87,6 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt #endif } -int opencvErrorHandler(int status, const char* func_name, const char* err_msg, - const char* file_name, int line, void*) -{ - qWarning() << "OpenCV: ERROR ("<applicationDirPath() != "/Applications/qtox.app/Contents/MacOS") { qDebug() << "OS X: Not in Applications folder";