First working version of internal core connection.
[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(bool = false, QWidget *parent = 0);
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   void on_useInternalCore_clicked();
53
54   void on_accountList_itemDoubleClicked(QListWidgetItem *item);
55   void on_accountButtonBox_accepted();
56
57   void setAccountWidgetStates();
58
59   /*** Phase One: Connection ***/
60   void connectToCore();
61
62   void initPhaseError(const QString &error);
63   void initPhaseMsg(const QString &msg);
64   void initPhaseSocketState(QAbstractSocket::SocketState);
65   void encrypted(bool);
66
67   /*** Phase Two: Login ***/
68   void startLogin();
69   void doLogin();
70   void doLogin(const QVariantMap &loginData);
71   void loginFailed(const QString &);
72   void startCoreConfig(const QVariantList &backends);
73   void configWizardAccepted();
74   void configWizardRejected();
75   void on_launchCoreConfigWizard_clicked();
76
77   void setLoginWidgetStates();
78
79   /*** Phase Three: Sync ***/
80   void startSync();
81   void syncFinished();
82
83   void coreSessionProgress(quint32, quint32);
84   void coreNetworksProgress(quint32, quint32);
85
86 private:
87   Ui::CoreConnectDlg ui;
88
89   AccountId autoConnectAccount;
90   QHash<AccountId, QVariantMap> accounts;
91   QVariantMap accountData;
92   AccountId account;
93
94   bool doingAutoConnect;
95
96   QVariantList storageBackends;
97
98   ClientSyncer *clientSyncer;
99   CoreConfigWizard *wizard;
100 };
101
102 class CoreAccountEditDlg : public QDialog {
103   Q_OBJECT
104
105 public:
106   CoreAccountEditDlg(AccountId id, const QVariantMap &data, const QStringList &existing = QStringList(), QWidget *parent = 0);
107
108   QVariantMap accountData();
109
110 private slots:
111   void on_host_textChanged(const QString &);
112   void on_accountName_textChanged(const QString &);
113   void on_useRemote_toggled(bool);
114
115   void setWidgetStates();
116
117 private:
118   Ui::CoreAccountEditDlg ui;
119
120   QStringList existing;
121   QVariantMap account;
122 };
123
124 #endif