cac4721e4a8fcef9e1904c5f8ae448a2d349ecbc
[quassel.git] / src / qtui / coreconnectdlg.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef CORECONNECTDLG_H
22 #define CORECONNECTDLG_H
23
24 #include <QAbstractSocket>
25
26 #include "types.h"
27
28 #include "ui_coreconnectdlg.h"
29 #include "ui_coreaccounteditdlg.h"
30
31 class ClientSyncer;
32 class CoreConfigWizard;
33
34 class CoreConnectDlg : public QDialog {
35   Q_OBJECT
36
37 public:
38   CoreConnectDlg(bool = false, QWidget *parent = 0);
39   ~CoreConnectDlg();
40
41 // signals:
42 //   void newClientSyncer(ClientSyncer *);
43
44 private slots:
45   /*** Phase Null: Accounts ***/
46   void restartPhaseNull();
47
48   void on_accountList_itemSelectionChanged();
49   void on_autoConnect_clicked(bool);
50
51   void on_addAccount_clicked();
52   void on_editAccount_clicked();
53   void on_deleteAccount_clicked();
54   void on_useInternalCore_clicked();
55
56   void on_accountList_itemDoubleClicked(QListWidgetItem *item);
57   void on_accountButtonBox_accepted();
58
59   void setAccountWidgetStates();
60
61   /*** Phase One: Connection ***/
62   void connectToCore();
63
64   void initPhaseError(const QString &error);
65   void initPhaseMsg(const QString &msg);
66   void initPhaseSocketState(QAbstractSocket::SocketState);
67
68   /*** Phase Two: Login ***/
69   void startLogin();
70   void doLogin();
71   void doLogin(const QVariantMap &loginData);
72   void loginFailed(const QString &);
73   void startCoreConfig(const QVariantList &backends);
74   void configWizardAccepted();
75   void configWizardRejected();
76   void on_launchCoreConfigWizard_clicked();
77
78   void setLoginWidgetStates();
79
80   /*** Phase Three: Sync ***/
81   void startSync();
82   void syncFinished();
83
84   void coreSessionProgress(quint32, quint32);
85   void coreNetworksProgress(quint32, quint32);
86
87 private:
88   AccountId findFreeAccountId();
89
90   Ui::CoreConnectDlg ui;
91
92   AccountId autoConnectAccount;
93   QHash<AccountId, QVariantMap> accounts;
94   AccountId _internalAccountId;
95   QVariantMap accountData;
96   AccountId account;
97
98   bool doingAutoConnect;
99
100   QVariantList storageBackends;
101
102   ClientSyncer *clientSyncer;
103   CoreConfigWizard *wizard;
104 };
105
106 class CoreAccountEditDlg : public QDialog {
107   Q_OBJECT
108
109 public:
110   CoreAccountEditDlg(AccountId id, const QVariantMap &data, const QStringList &existing = QStringList(), QWidget *parent = 0);
111
112   QVariantMap accountData();
113
114 private slots:
115   void on_host_textChanged(const QString &);
116   void on_accountName_textChanged(const QString &);
117
118   void setWidgetStates();
119
120 private:
121   Ui::CoreAccountEditDlg ui;
122
123   QStringList existing;
124   QVariantMap account;
125 };
126
127 #endif