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("<a href=\"%1\">Click here</a> 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);
}
// 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;
// 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 {
* 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;
* 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);
}
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 {
{
// 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
// not detected yet, assume it is fine.
return false;
}
- return serverVersionInt() < 0x070000;
+ return serverVersionInt() < makeServerVersion(7, 0, 0);
}
void Account::setServerVersion(const QString& version)
bool Account::rootEtagChangesNotOnlySubFolderEtags()
{
- return (serverVersionInt() >= 0x080100);
+ return (serverVersionInt() >= makeServerVersion(8, 1, 0));
}
void Account::setNonShib(bool nonShib)
/** 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.
// 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'));
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;
}
// 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) {
&& _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.