QString HttpCredentialsGui::requestAppPasswordText(const Account* account)
{
- if (account->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) {
- // Older server than 9.1 does not have the feature to request App Password
- return QString();
- }
-
+ int version = account->serverVersionInt();
QString path;
- if (account->serverVersionInt() < Account::makeServerVersion(10, 0, 0)) {
+
+ // Version may not be available before login on new servers!
+ if (!version || version >= Account::makeServerVersion(10, 0, 0)) {
+ path = QLatin1String("/index.php/settings/personal?sectionid=security#apppasswords");
+ } else if (version >= Account::makeServerVersion(9, 1, 0)) {
path = QLatin1String("/index.php/settings/personal?section=apppasswords");
} else {
- path = QLatin1String("/index.php/settings/personal?sectionid=security#apppasswords");
+ // Older server than 9.1 does not have the feature to request App Password
+ return QString();
}
+
return tr("<a href=\"%1\">Click here</a> to request an app password from the web interface.")
.arg(account->url().toString() + path);
}
Utility::escape(CheckServerJob::versionString(info)),
Utility::escape(serverVersion)));
+ // Note with newer servers we get the version actually only later in capabilities
+ // https://github.com/owncloud/core/pull/27473/files
_ocWizard->account()->setServerVersion(serverVersion);
QString p = url.path();
const Capabilities &capabilities() const;
void setCapabilities(const QVariantMap &caps);
- /** Access the server version */
+ /** Access the server version
+ *
+ * For servers >= 10.0.0, this can be the empty string until capabilities
+ * have been received.
+ */
QString serverVersion() const;
+
+ /** Server version for easy comparison.
+ *
+ * Example: serverVersionInt() >= makeServerVersion(11, 2, 3)
+ *
+ * Will be 0 if the version is not available yet.
+ */
int serverVersionInt() const;
+
static int makeServerVersion(int majorVersion, int minorVersion, int patchVersion);
void setServerVersion(const QString &version);
void ConnectionValidator::slotStatusFound(const QUrl&url, const QVariantMap &info)
{
+ // Newer servers don't disclose any version in status.php anymore
+ // https://github.com/owncloud/core/pull/27473/files
+ // so this string can be empty.
+ QString serverVersion = CheckServerJob::version(info);
+
// status.php was found.
qDebug() << "** Application: ownCloud found: "
<< url << " with version "
<< CheckServerJob::versionString(info)
- << "(" << CheckServerJob::version(info) << ")";
-
- QString version = CheckServerJob::version(info);
- _account->setServerVersion(version);
+ << "(" << serverVersion << ")";
- // We cannot deal with servers < 5.0.0
- if (version.contains('.') && version.split('.')[0].toInt() < 5) {
- _errors.append( tr("The configured server for this client is too old") );
- _errors.append( tr("Please update to the latest server and restart the client.") );
- reportResult( ServerVersionMismatch );
+ if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
return;
}
- // We attempt to work with servers >= 5.0.0 but warn users.
- // Check usages of Account::serverVersionUnsupported() for details.
-
// now check the authentication
if (_account->credentials()->ready())
QTimer::singleShot( 0, this, SLOT( checkAuthentication() ));
auto caps = json.value("ocs").toMap().value("data").toMap().value("capabilities");
qDebug() << "Server capabilities" << caps;
_account->setCapabilities(caps.toMap());
+
+ // New servers also report the version in the capabilities
+ QString serverVersion = caps.toMap()["core"].toMap()["status"].toMap()["version"].toString();
+ if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
+ return;
+ }
+
fetchUser();
}
job->start();
}
+bool ConnectionValidator::setAndCheckServerVersion(const QString& version)
+{
+ qDebug() << _account->url() << "has server version" << version;
+ _account->setServerVersion(version);
+
+ // We cannot deal with servers < 5.0.0
+ if (_account->serverVersionInt()
+ && _account->serverVersionInt() < Account::makeServerVersion(5, 0, 0)) {
+ _errors.append( tr("The configured server for this client is too old") );
+ _errors.append( tr("Please update to the latest server and restart the client.") );
+ reportResult( ServerVersionMismatch );
+ return false;
+ }
+
+ // We attempt to work with servers >= 5.0.0 but warn users.
+ // Check usages of Account::serverVersionUnsupported() for details.
+
+ return true;
+}
+
void ConnectionValidator::slotUserFetched(const QVariantMap &json)
{
QString user = json.value("ocs").toMap().value("data").toMap().value("id").toString();
void checkServerCapabilities();
void fetchUser();
+ /** Sets the account's server version
+ *
+ * Returns false and reports ServerVersionMismatch for very old servers.
+ */
+ bool setAndCheckServerVersion(const QString& version);
+
QStringList _errors;
AccountPtr _account;
bool _isCheckingServerAndAuth;
}
qDebug() << "status.php returns: " << status << " " << reply()->error() << " Reply: " << reply();
- if( status.contains("installed")
- && status.contains("version")
- && status.contains("versionstring") ) {
-
+ if( status.contains("installed") ) {
emit instanceFound(reply()->url(), status);
} else {
qDebug() << "No proper answer on " << reply()->url();