nextcloud-desktop/src/libsync/connectionvalidator.h

75 lines
1.9 KiB
C
Raw Normal View History

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 "owncloudlib.h"
2013-05-04 18:01:45 +04:00
#include <QObject>
#include <QStringList>
2013-10-23 16:48:44 +04:00
#include <QVariantMap>
#include <QNetworkReply>
#include "accountfwd.h"
2013-05-04 18:01:45 +04:00
2014-11-10 00:34:07 +03:00
namespace OCC {
2013-05-04 18:01:45 +04:00
class OWNCLOUDSYNC_EXPORT ConnectionValidator : public QObject
2013-05-04 18:01:45 +04:00
{
Q_OBJECT
public:
explicit ConnectionValidator(AccountPtr account, QObject *parent = 0);
2013-05-04 18:01:45 +04:00
enum Status {
Undefined,
Connected,
NotConfigured,
ServerVersionMismatch,
CredentialsWrong,
StatusNotFound,
UserCanceledCredentials,
// actually also used for other errors on the authed request
Timeout
2013-05-04 18:01:45 +04:00
};
static QString statusString( Status );
static bool isNetworkError( Status status );
2013-05-04 18:01:45 +04:00
public slots:
/// Checks the server and the authentication.
void checkServerAndAuth();
/// Checks authentication only.
void checkAuthentication();
2013-05-04 18:01:45 +04:00
signals:
void connectionResult( ConnectionValidator::Status status, QStringList errors );
2013-05-04 18:01:45 +04:00
protected slots:
void slotStatusFound(const QUrl&url, const QVariantMap &info);
void slotNoStatusFound(QNetworkReply *reply);
void slotJobTimeout(const QUrl& url);
2013-05-04 18:01:45 +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:
void reportResult(Status status);
2013-05-04 18:01:45 +04:00
QStringList _errors;
AccountPtr _account;
2013-05-04 18:01:45 +04:00
};
}
#endif // CONNECTIONVALIDATOR_H