2013-05-04 18:01:45 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONNECTIONVALIDATOR_H
|
|
|
|
#define CONNECTIONVALIDATOR_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
2013-10-23 16:48:44 +04:00
|
|
|
#include <QVariantMap>
|
|
|
|
#include <QNetworkReply>
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
2013-10-23 16:48:44 +04:00
|
|
|
class Account;
|
|
|
|
|
2013-05-04 18:01:45 +04:00
|
|
|
class ConnectionValidator : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-10-23 16:48:44 +04:00
|
|
|
explicit ConnectionValidator(Account *account, QObject *parent = 0);
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
enum Status {
|
|
|
|
Undefined,
|
|
|
|
Connected,
|
|
|
|
NotConfigured,
|
|
|
|
ServerVersionMismatch,
|
|
|
|
CredentialsTooManyAttempts,
|
|
|
|
CredentialError,
|
|
|
|
CredentialsUserCanceled,
|
|
|
|
CredentialsWrong,
|
|
|
|
StatusNotFound
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
QStringList errors() const;
|
2013-10-11 13:43:23 +04:00
|
|
|
bool networkError() const;
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
void checkConnection();
|
|
|
|
|
2013-07-05 15:14:48 +04:00
|
|
|
QString statusString( Status ) const;
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void connectionResult( ConnectionValidator::Status );
|
2013-07-05 15:14:48 +04:00
|
|
|
// void connectionAvailable();
|
|
|
|
// void connectionFailed();
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
protected slots:
|
2013-10-28 23:01:59 +04:00
|
|
|
void slotStatusFound(const QUrl&url, const QVariantMap &info);
|
|
|
|
void slotNoStatusFound(QNetworkReply *reply);
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
void slotCheckAuthentication();
|
2013-10-28 23:01:59 +04:00
|
|
|
void slotAuthFailed(QNetworkReply *reply);
|
2013-10-23 16:48:44 +04:00
|
|
|
void slotAuthSuccess();
|
2013-05-04 18:01:45 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
QStringList _errors;
|
2013-10-23 16:48:44 +04:00
|
|
|
Account *_account;
|
2013-10-11 13:43:23 +04:00
|
|
|
bool _networkError;
|
2013-05-04 18:01:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CONNECTIONVALIDATOR_H
|