1/*
2 * Copyright (C) by Klaas Freitag <freitag@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15#ifndef OWNCLOUDSETUPWIZARD_H
16#define OWNCLOUDSETUPWIZARD_H
17
18#include <QObject>
19#include <QWidget>
20#include <QProcess>
21#include <QNetworkReply>
22#include <QPointer>
23
24#include "accountfwd.h"
25#include "theme.h"
26#include "networkjobs.h"
27
28#include "wizard/owncloudwizardcommon.h"
29
30namespace OCC {
31
32class AccountState;
33
34class OwncloudWizard;
35
36/**
37 * @brief The OwncloudSetupWizard class
38 * @ingroup gui
39 */
40class OwncloudSetupWizard : public QObject
41{
42 Q_OBJECT
43public:
44 /** Run the wizard */
45 static void runWizard(QObject *obj, const char *amember, QWidget *parent = 0);
46 static bool bringWizardToFrontIfVisible();
47signals:
48 // overall dialog close signal.
49 void ownCloudWizardDone(int);
50
51private slots:
52 void slotCheckServer(const QString &);
53 void slotSystemProxyLookupDone(const QNetworkProxy &proxy);
54
55 void slotFindServer();
56 void slotFindServerBehindRedirect();
57 void slotFoundServer(const QUrl &, const QJsonObject &);
58 void slotNoServerFound(QNetworkReply *reply);
59 void slotNoServerFoundTimeout(const QUrl &url);
60
61 void slotDetermineAuthType();
62
63 void slotConnectToOCUrl(const QString &);
64 void slotAuthError();
65
66 void slotCreateLocalAndRemoteFolders(const QString &, const QString &);
67 void slotRemoteFolderExists(QNetworkReply *);
68 void slotCreateRemoteFolderFinished(QNetworkReply::NetworkError);
69 void slotAssistantFinished(int);
70
71private:
72 explicit OwncloudSetupWizard(QObject *parent = 0);
73 ~OwncloudSetupWizard();
74 void startWizard();
75 void testOwnCloudConnect();
76 void createRemoteFolder();
77 void finalizeSetup(bool);
78 bool ensureStartFromScratch(const QString &localFolder);
79 AccountState *applyAccountChanges();
80 bool checkDowngradeAdvised(QNetworkReply *reply);
81
82 OwncloudWizard *_ocWizard;
83 QString _initLocalFolder;
84 QString _remoteFolder;
85};
86}
87
88#endif // OWNCLOUDSETUPWIZARD_H
89