From: Christian Kamm Date: Tue, 14 Mar 2017 14:57:57 +0000 (+0100) Subject: Account server version: Helper to create versions X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~790^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b98876e265b612df7aea21c3b33bb930ce570192;p=nextcloud-desktop.git Account server version: Helper to create versions Hex literals don't work well with version 10: 0x100000 doesn't do the right thing. --- diff --git a/src/gui/creds/httpcredentialsgui.cpp b/src/gui/creds/httpcredentialsgui.cpp index 6f84f4bf5..26ad6ec8b 100644 --- a/src/gui/creds/httpcredentialsgui.cpp +++ b/src/gui/creds/httpcredentialsgui.cpp @@ -70,13 +70,14 @@ void HttpCredentialsGui::askFromUserAsync() QString HttpCredentialsGui::requestAppPasswordText(const Account* account) { - if (account->serverVersionInt() < 0x090100) { - // Older server than 9.1 does not have trhe feature to request App Password + if (account->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) { + // Older server than 9.1 does not have the feature to request App Password return QString(); } + QString path = QLatin1String("/index.php/settings/personal?section=apppasswords"); return tr("Click here to request an app password from the web interface.") - .arg(account->url().toString() + QLatin1String("/index.php/settings/personal?section=apppasswords")); + .arg(account->url().toString() + path); } diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 831807da8..7506e4f92 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -176,7 +176,7 @@ void ShareDialog::showSharingUi() // We only do user/group sharing from 8.2.0 bool userGroupSharing = theme->userGroupSharing() - && _accountState->account()->serverVersionInt() >= ((8 << 16) + (2 << 8)); + && _accountState->account()->serverVersionInt() >= Account::makeServerVersion(8, 2, 0); bool autoShare = !userGroupSharing; diff --git a/src/gui/sharemanager.cpp b/src/gui/sharemanager.cpp index 08f2092d5..7b6032bbb 100644 --- a/src/gui/sharemanager.cpp +++ b/src/gui/sharemanager.cpp @@ -343,7 +343,7 @@ QSharedPointer ShareManager::parseLinkShare(const QVariantMap &data) // From ownCloud server 8.2 the url field is always set for public shares if (data.contains("url")) { url = QUrl(data.value("url").toString()); - } else if (_account->serverVersionInt() >= (8 << 16)) { + } else if (_account->serverVersionInt() >= Account::makeServerVersion(8, 0, 0)) { // From ownCloud server version 8 on, a different share link scheme is used. url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("index.php/s/") + data.value("token").toString())).toString(); } else { diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp index c1b798e5b..e339d6a1c 100644 --- a/src/gui/shareusergroupwidget.cpp +++ b/src/gui/shareusergroupwidget.cpp @@ -254,7 +254,7 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index) * https://github.com/owncloud/client/issues/4996 */ if (sharee->type() == Sharee::Federated - && _account->serverVersionInt() < 0x090100) { + && _account->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) { int permissions = SharePermissionRead | SharePermissionUpdate; if (!_isFile) { permissions |= SharePermissionCreate | SharePermissionDelete; @@ -343,7 +343,7 @@ ShareWidget::ShareWidget(QSharedPointer share, * https://github.com/owncloud/client/issues/4996 */ if (share->getShareType() == Share::TypeRemote - && share->account()->serverVersionInt() < 0x090100) { + && share->account()->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) { _ui->permissionShare->setVisible(false); _ui->permissionToolButton->setVisible(false); } diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index dac1e0f6d..361c7a34f 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -404,7 +404,7 @@ void SocketApi::command_SHARE(const QString& localFile, SocketListener* listener listener->sendMessage(message); } else if (!theme->linkSharing() && ( !theme->userGroupSharing() || - shareFolder->accountState()->account()->serverVersionInt() < ((8 << 16) + (2 << 8)))) { + shareFolder->accountState()->account()->serverVersionInt() < Account::makeServerVersion(8, 2, 0))) { const QString message = QLatin1String("SHARE:NOP:")+QDir::toNativeSeparators(localFile); listener->sendMessage(message); } else { diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 2918d2a39..b92609459 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -396,9 +396,14 @@ int Account::serverVersionInt() const { // FIXME: Use Qt 5.5 QVersionNumber auto components = serverVersion().split('.'); - return (components.value(0).toInt() << 16) - + (components.value(1).toInt() << 8) - + components.value(2).toInt(); + return makeServerVersion(components.value(0).toInt(), + components.value(1).toInt(), + components.value(2).toInt()); +} + +int Account::makeServerVersion(int majorVersion, int minorVersion, int patchVersion) +{ + return (majorVersion << 16) + (minorVersion << 8) + patchVersion; } bool Account::serverVersionUnsupported() const @@ -407,7 +412,7 @@ bool Account::serverVersionUnsupported() const // not detected yet, assume it is fine. return false; } - return serverVersionInt() < 0x070000; + return serverVersionInt() < makeServerVersion(7, 0, 0); } void Account::setServerVersion(const QString& version) @@ -423,7 +428,7 @@ void Account::setServerVersion(const QString& version) bool Account::rootEtagChangesNotOnlySubFolderEtags() { - return (serverVersionInt() >= 0x080100); + return (serverVersionInt() >= makeServerVersion(8, 1, 0)); } void Account::setNonShib(bool nonShib) diff --git a/src/libsync/account.h b/src/libsync/account.h index 5e5ab4944..e081121b3 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -148,6 +148,7 @@ public: /** Access the server version */ QString serverVersion() const; int serverVersionInt() const; + static int makeServerVersion(int majorVersion, int minorVersion, int patchVersion); void setServerVersion(const QString &version); /** Whether the server is too old. diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 51a3ab319..f5bc11f5e 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -767,7 +767,7 @@ void PropagateDownloadFile::downloadFinished() // Apply the remote permissions // Older server versions sometimes provide empty remote permissions // see #4450 - don't adjust the write permissions there. - const int serverVersionGoodRemotePerm = 0x070000; // 7.0.0 + const int serverVersionGoodRemotePerm = Account::makeServerVersion(7, 0, 0); if (propagator()->account()->serverVersionInt() >= serverVersionGoodRemotePerm) { FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(), !_item->_remotePerm.contains('W')); diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index 916dcdcf9..612aab004 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -145,7 +145,7 @@ void PropagateUploadFileV1::startNextChunk() parallelChunkUpload = env != "false" && env != "0"; } else { int versionNum = propagator()->account()->serverVersionInt(); - if (versionNum < 0x080003) { + if (versionNum < Account::makeServerVersion(8, 0, 3)) { // Disable parallel chunk upload severs older than 8.0.3 to avoid too many // internal sever errors (#2743, #2938) parallelChunkUpload = false; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 333fdd9e7..047732d48 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -930,7 +930,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult) } // Check for invalid character in old server version - if (_account->serverVersionInt() < 0x080100) { + if (_account->serverVersionInt() < Account::makeServerVersion(8, 1, 0)) { // Server version older than 8.1 don't support these character in filename. static const QRegExp invalidCharRx("[\\\\:?*\"<>|]"); for (auto it = syncItems.begin(); it != syncItems.end(); ++it) { @@ -961,7 +961,8 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult) && _discoveryMainThread->_dataFingerprint != databaseFingerprint) { qDebug() << "data fingerprint changed, assume restore from backup" << databaseFingerprint << _discoveryMainThread->_dataFingerprint; restoreOldFiles(syncItems); - } else if (!_hasForwardInTimeFiles && _backInTimeFiles >= 2 && _account->serverVersionInt() < 0x090100) { + } else if (!_hasForwardInTimeFiles && _backInTimeFiles >= 2 + && _account->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) { // The server before ownCloud 9.1 did not have the data-fingerprint property. So in that // case we use heuristics to detect restored backup. This is disabled with newer version // because this causes troubles to the user and is not as reliable as the data-fingerprint.