From b952fa64eee19f780b7fcb4419ca92fe631c5cea Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 2 Jul 2018 11:01:52 +0200 Subject: [PATCH 1/4] Restore logger installation Signed-off-by: Roeland Jago Douma --- src/libsync/logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index c8ce68c3c..a9bd94648 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -50,7 +50,7 @@ Logger::Logger(QObject *parent) { qSetMessagePattern("[%{function} \t%{message}"); #ifndef NO_MSG_HANDLER - // qInstallMessageHandler(mirallLogCatcher); + qInstallMessageHandler(mirallLogCatcher); #else Q_UNUSED(mirallLogCatcher) #endif From e87135945352d7b01c544b052c12d66896f07274 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 2 Jul 2018 11:03:58 +0200 Subject: [PATCH 2/4] Remove unneeded ; Signed-off-by: Roeland Jago Douma --- src/libsync/configfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 9e7c0a84c..86a1b7c11 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -94,7 +94,7 @@ static chrono::milliseconds millisecondsValue(const QSettings &setting, const ch chrono::milliseconds defaultValue) { return chrono::milliseconds(setting.value(QLatin1String(key), qlonglong(defaultValue.count())).toLongLong()); -}; +} ConfigFile::ConfigFile() { From ce545b1e47d86f8484fe6219d8b4c47dd3c04cf5 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 2 Jul 2018 12:45:44 +0200 Subject: [PATCH 3/4] propage*encrypted Q_UNUSED Signed-off-by: Roeland Jago Douma --- src/libsync/propagatedownloadencrypted.cpp | 8 +-- src/libsync/propagateuploadencrypted.cpp | 59 ++++++++++++---------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/libsync/propagatedownloadencrypted.cpp b/src/libsync/propagatedownloadencrypted.cpp index f8de072e2..f807cadce 100644 --- a/src/libsync/propagatedownloadencrypted.cpp +++ b/src/libsync/propagatedownloadencrypted.cpp @@ -106,10 +106,10 @@ bool PropagateDownloadEncrypted::decryptFile(QFile& tmpFile) tmpFile.close(); QFile _tmpOutput(_propagator->getFilePath(tmpFileName), this); - bool fileDecrypted = EncryptionHelper::fileDecryption(_encryptedInfo.encryptionKey, - _encryptedInfo.initializationVector, - &tmpFile, - &_tmpOutput); + EncryptionHelper::fileDecryption(_encryptedInfo.encryptionKey, + _encryptedInfo.initializationVector, + &tmpFile, + &_tmpOutput); qCDebug(lcPropagateDownloadEncrypted) << "Decryption finished" << tmpFile.fileName() << _tmpOutput.fileName(); diff --git a/src/libsync/propagateuploadencrypted.cpp b/src/libsync/propagateuploadencrypted.cpp index f0334aa68..b9e659d87 100644 --- a/src/libsync/propagateuploadencrypted.cpp +++ b/src/libsync/propagateuploadencrypted.cpp @@ -114,8 +114,10 @@ void PropagateUploadEncrypted::slotFolderLockedSuccessfully(const QByteArray& fi void PropagateUploadEncrypted::slotFolderEncryptedMetadataError(const QByteArray& fileId, int httpReturnCode) { - qCDebug(lcPropagateUploadEncrypted()) << "Error Getting the encrypted metadata. unlock the folder."; - unlockFolder(); + Q_UNUSED(fileId); + Q_UNUSED(httpReturnCode); + qCDebug(lcPropagateUploadEncrypted()) << "Error Getting the encrypted metadata. unlock the folder."; + unlockFolder(); } void PropagateUploadEncrypted::slotFolderEncryptedMetadataReceived(const QJsonDocument &json, int statusCode) @@ -207,14 +209,15 @@ void PropagateUploadEncrypted::slotFolderEncryptedMetadataReceived(const QJsonDo void PropagateUploadEncrypted::slotUpdateMetadataSuccess(const QByteArray& fileId) { - qCDebug(lcPropagateUploadEncrypted) << "Uploading of the metadata success, Encrypting the file"; - QFileInfo outputInfo(_completeFileName); + Q_UNUSED(fileId); + qCDebug(lcPropagateUploadEncrypted) << "Uploading of the metadata success, Encrypting the file"; + QFileInfo outputInfo(_completeFileName); - qCDebug(lcPropagateUploadEncrypted) << "Encrypted Info:" << outputInfo.path() << outputInfo.fileName() << outputInfo.size(); - qCDebug(lcPropagateUploadEncrypted) << "Finalizing the upload part, now the actuall uploader will take over"; - emit finalized(outputInfo.path() + QLatin1Char('/') + outputInfo.fileName(), - _item->_file.section(QLatin1Char('/'), 0, -2) + QLatin1Char('/') + outputInfo.fileName(), - outputInfo.size()); + qCDebug(lcPropagateUploadEncrypted) << "Encrypted Info:" << outputInfo.path() << outputInfo.fileName() << outputInfo.size(); + qCDebug(lcPropagateUploadEncrypted) << "Finalizing the upload part, now the actuall uploader will take over"; + emit finalized(outputInfo.path() + QLatin1Char('/') + outputInfo.fileName(), + _item->_file.section(QLatin1Char('/'), 0, -2) + QLatin1Char('/') + outputInfo.fileName(), + outputInfo.size()); } void PropagateUploadEncrypted::slotUpdateMetadataError(const QByteArray& fileId, int httpErrorResponse) @@ -226,30 +229,32 @@ void PropagateUploadEncrypted::slotUpdateMetadataError(const QByteArray& fileId, void PropagateUploadEncrypted::slotFolderLockedError(const QByteArray& fileId, int httpErrorCode) { - /* try to call the lock from 5 to 5 seconds - and fail if it's more than 5 minutes. */ - QTimer::singleShot(5000, this, [this, fileId]{ - if (!_currentLockingInProgress) { - qCDebug(lcPropagateUploadEncrypted) << "Error locking the folder while no other update is locking it up."; - qCDebug(lcPropagateUploadEncrypted) << "Perhaps another client locked it."; - qCDebug(lcPropagateUploadEncrypted) << "Abort"; - return; - } + Q_UNUSED(httpErrorCode); + /* try to call the lock from 5 to 5 seconds + * and fail if it's more than 5 minutes. */ + QTimer::singleShot(5000, this, [this, fileId]{ + if (!_currentLockingInProgress) { + qCDebug(lcPropagateUploadEncrypted) << "Error locking the folder while no other update is locking it up."; + qCDebug(lcPropagateUploadEncrypted) << "Perhaps another client locked it."; + qCDebug(lcPropagateUploadEncrypted) << "Abort"; + return; + } - // Perhaps I should remove the elapsed timer if the lock is from this client? - if (_folderLockFirstTry.elapsed() > /* five minutes */ 1000 * 60 * 5 ) { - qCDebug(lcPropagateUploadEncrypted) << "One minute passed, ignoring more attemps to lock the folder."; - return; - } - slotTryLock(fileId); - }); + // Perhaps I should remove the elapsed timer if the lock is from this client? + if (_folderLockFirstTry.elapsed() > /* five minutes */ 1000 * 60 * 5 ) { + qCDebug(lcPropagateUploadEncrypted) << "One minute passed, ignoring more attemps to lock the folder."; + return; + } + slotTryLock(fileId); + }); - qCDebug(lcPropagateUploadEncrypted) << "Folder" << fileId << "Coundn't be locked."; + qCDebug(lcPropagateUploadEncrypted) << "Folder" << fileId << "Coundn't be locked."; } void PropagateUploadEncrypted::slotFolderEncryptedIdError(QNetworkReply *r) { - qCDebug(lcPropagateUploadEncrypted) << "Error retrieving the Id of the encrypted folder."; + Q_UNUSED(r); + qCDebug(lcPropagateUploadEncrypted) << "Error retrieving the Id of the encrypted folder."; } void PropagateUploadEncrypted::slotFolderEncryptedStatusError(int error) From 08abc71acbc89b5c07234d2bb36aa9e87f989c74 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 2 Jul 2018 13:02:15 +0200 Subject: [PATCH 4/4] gui Q_UNUSED Signed-off-by: Roeland Jago Douma --- src/gui/accountsettings.cpp | 32 +++++++++++++++++++++++++--- src/gui/accountstate.cpp | 2 +- src/gui/creds/webflowcredentials.cpp | 2 ++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index fec87fa02..a47af797c 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -304,6 +304,8 @@ void AccountSettings::slotEncryptionFlagSuccess(const QByteArray& fileId) void AccountSettings::slotEncryptionFlagError(const QByteArray& fileId, int httpErrorCode) { + Q_UNUSED(fileId); + Q_UNUSED(httpErrorCode); qDebug() << "Error on the encryption flag"; } @@ -344,6 +346,8 @@ void AccountSettings::slotUploadMetadataSuccess(const QByteArray& folderId) void AccountSettings::slotUpdateMetadataError(const QByteArray& folderId, int httpReturnCode) { + Q_UNUSED(httpReturnCode); + const auto token = accountsState()->account()->e2e()->tokenForFolder(folderId); auto unlockJob = new UnlockEncryptFolderApiJob(accountsState()->account(), folderId, token); connect(unlockJob, &UnlockEncryptFolderApiJob::success, @@ -355,15 +359,23 @@ void AccountSettings::slotUpdateMetadataError(const QByteArray& folderId, int ht void AccountSettings::slotLockForEncryptionError(const QByteArray& fileId, int httpErrorCode) { + Q_UNUSED(fileId); + Q_UNUSED(httpErrorCode); + qCInfo(lcAccountSettings()) << "Locking error" << httpErrorCode; } void AccountSettings::slotUnlockFolderError(const QByteArray& fileId, int httpErrorCode) { + Q_UNUSED(fileId); + Q_UNUSED(httpErrorCode); + qCInfo(lcAccountSettings()) << "Unlocking error!"; } void AccountSettings::slotUnlockFolderSuccess(const QByteArray& fileId) { + Q_UNUSED(fileId); + qCInfo(lcAccountSettings()) << "Unlocking success!"; } @@ -475,27 +487,41 @@ void AccountSettings::slotDecryptionFlagSuccess(const QByteArray& fileId) } } -void AccountSettings::slotDecryptionFlagError(const QByteArray& fileID, int httpReturnCode) +void AccountSettings::slotDecryptionFlagError(const QByteArray& fileId, int httpReturnCode) { + Q_UNUSED(fileId); + Q_UNUSED(httpReturnCode); + qDebug() << "Error Setting the Decryption Flag"; } void AccountSettings::slotUnlockForDecryptionError(const QByteArray& fileId, int httpReturnCode) { + Q_UNUSED(fileId); + Q_UNUSED(httpReturnCode); + qDebug() << "Error unlocking folder after decryption"; } void AccountSettings::slotDeleteMetadataError(const QByteArray& fileId, int httpReturnCode) { - qDebug() << "Error deleting the metadata"; + Q_UNUSED(fileId); + Q_UNUSED(httpReturnCode); + + qDebug() << "Error deleting the metadata"; } void AccountSettings::slotLockForDecryptionError(const QByteArray& fileId, int httpReturnCode) { - qDebug() << "Error Locking for decryption"; + Q_UNUSED(fileId); + Q_UNUSED(httpReturnCode); + + qDebug() << "Error Locking for decryption"; } void AccountSettings::slotSubfolderContextMenuRequested(const QModelIndex& index, const QPoint& pos) { + Q_UNUSED(pos); + QMenu menu; auto ac = menu.addAction(tr("Open folder")); connect(ac, &QAction::triggered, this, &AccountSettings::slotOpenCurrentLocalSubFolder); diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index e4303d4f7..50a4f617d 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -34,8 +34,8 @@ AccountState::AccountState(AccountPtr account) , _state(AccountState::Disconnected) , _connectionStatus(ConnectionValidator::Undefined) , _waitingForNewCredentials(false) - , _maintenanceToConnectedDelay(60000 + (qrand() % (4 * 60000))) // 1-5min delay , _notificationsEtagResponseHeader("*") + , _maintenanceToConnectedDelay(60000 + (qrand() % (4 * 60000))) // 1-5min delay { qRegisterMetaType("AccountState*"); diff --git a/src/gui/creds/webflowcredentials.cpp b/src/gui/creds/webflowcredentials.cpp index c62b954c6..2b70c5328 100644 --- a/src/gui/creds/webflowcredentials.cpp +++ b/src/gui/creds/webflowcredentials.cpp @@ -102,6 +102,8 @@ void WebFlowCredentials::askFromUser() { } void WebFlowCredentials::slotAskFromUserCredentialsProvided(const QString &user, const QString &pass, const QString &host) { + Q_UNUSED(host); + if (_user != user) { qCInfo(lcWebFlowCredentials()) << "Authed with the wrong user!";