Switch some dirty hacking to using real infrastructure. A Chatline now contains three...
[quassel.git] / src / qtui / coreconnectdlg.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
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(QWidget *parent = 0, bool = false);
39     ~CoreConnectDlg();
40
41   private slots:
42
43     /*** Phase Null: Accounts ***/
44     void restartPhaseNull();
45
46     void on_accountList_itemSelectionChanged();
47     void on_autoConnect_clicked(bool);
48
49     void on_addAccount_clicked();
50     void on_editAccount_clicked();
51     void on_deleteAccount_clicked();
52
53     void on_accountList_itemDoubleClicked(QListWidgetItem *item);
54     void on_accountButtonBox_accepted();
55
56     void setAccountWidgetStates();
57
58     /*** Phase One: Connection ***/
59     void connectToCore();
60
61     void initPhaseError(const QString &error);
62     void initPhaseMsg(const QString &msg);
63     void initPhaseSocketState(QAbstractSocket::SocketState);
64     void encrypted(bool);
65
66     /*** Phase Two: Login ***/
67     void startLogin();
68     void doLogin();
69     void doLogin(const QVariantMap &loginData);
70     void loginFailed(const QString &);
71     void startCoreConfig(const QVariantList &backends);
72     void configWizardAccepted();
73     void configWizardRejected();
74     void on_launchCoreConfigWizard_clicked();
75
76     void setLoginWidgetStates();
77
78     /*** Phase Three: Sync ***/
79     void startSync();
80     void syncFinished();
81
82     void coreSessionProgress(quint32, quint32);
83     void coreNetworksProgress(quint32, quint32);
84     void coreChannelsProgress(quint32, quint32);
85     void coreIrcUsersProgress(quint32, quint32);
86
87   private:
88     Ui::CoreConnectDlg ui;
89
90     AccountId autoConnectAccount;
91     QHash<AccountId, QVariantMap> accounts;
92     QVariantMap accountData;
93     AccountId account;
94
95     bool doingAutoConnect;
96
97     QVariantList storageBackends;
98
99     ClientSyncer *clientSyncer;
100     CoreConfigWizard *wizard;
101 };
102
103 class CoreAccountEditDlg : public QDialog {
104   Q_OBJECT
105
106   public:
107     CoreAccountEditDlg(AccountId id, const QVariantMap &data, const QStringList &existing = QStringList(), QWidget *parent = 0);
108
109     QVariantMap accountData();
110
111   private slots:
112     void on_host_textChanged(const QString &);
113     void on_accountName_textChanged(const QString &);
114     void on_useRemote_toggled(bool);
115
116     void setWidgetStates();
117
118   private:
119     Ui::CoreAccountEditDlg ui;
120
121     QStringList existing;
122     QVariantMap account;
123 };
124
125 #endif