Merge pull request #5170 from owncloud/add_capabilities_owncloudcmd

add server capabilities to owncloudcmd
This commit is contained in:
Piotr Mrówczyński 2016-09-21 22:28:41 +02:00 committed by GitHub
commit b7eb37dc03

View file

@ -29,6 +29,7 @@
#include "syncengine.h"
#include "syncjournaldb.h"
#include "config.h"
#include "connectionvalidator.h"
#include "cmd.h"
@ -69,6 +70,8 @@ struct CmdOptions {
// So we have to use a global variable
CmdOptions *opts = 0;
const qint64 timeoutToUseMsec = qMax(1000, ConnectionValidator::DefaultCallingIntervalMsec - 5*1000);
class EchoDisabler
{
public:
@ -389,6 +392,23 @@ int main(int argc, char **argv) {
account->setCredentials(cred);
account->setSslErrorHandler(sslErrorHandler);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
//obtain capabilities using event loop
QEventLoop loop;
JsonApiJob *job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/capabilities"));
job->setTimeout(timeoutToUseMsec);
QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QVariantMap &json) {
auto caps = json.value("ocs").toMap().value("data").toMap().value("capabilities");
qDebug() << "Server capabilities" << caps;
account->setCapabilities(caps.toMap());
loop.quit();
});
job->start();
loop.exec();
#endif
// much lower age than the default since this utility is usually made to be run right after a change in the tests
SyncEngine::minimumFileAgeForUpload = 0;