code cleanup
[quassel.git] / src / client / clientsyncer.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 _CLIENTSYNCER_H_
22 #define _CLIENTSYNCER_H_
23
24 #include <QPointer>
25 #include <QString>
26 #include <QTcpSocket>
27 #include <QSslSocket>
28 #include <QVariantMap>
29
30 class IrcUser;
31 class IrcChannel;
32
33 class ClientSyncer : public QObject {
34   Q_OBJECT
35
36   public:
37     ClientSyncer(QObject *parent = 0);
38     ~ClientSyncer();
39
40   signals:
41     void recvPartialItem(quint32 avail, quint32 size);
42     void connectionError(const QString &errorMsg);
43     void connectionMsg(const QString &msg);
44     void sessionProgress(quint32 part, quint32 total);
45     void networksProgress(quint32 part, quint32 total);
46     void channelsProgress(quint32 part, quint32 total);
47     void ircUsersProgress(quint32 part, quint32 total);
48     void socketStateChanged(QAbstractSocket::SocketState);
49     void socketDisconnected();
50
51     void startLogin();
52     void loginFailed(const QString &error);
53     void loginSuccess();
54     void syncFinished();
55     void startCoreSetup(const QVariantList &);
56     void coreSetupSuccess();
57     void coreSetupFailed(const QString &error);
58
59     void encrypted(bool);
60
61   public slots:
62     void connectToCore(const QVariantMap &);
63     void loginToCore(const QString &user, const QString &passwd);
64     void disconnectFromCore();
65
66   private slots:
67     void coreSocketError(QAbstractSocket::SocketError);
68     void coreHasData();
69     void coreSocketConnected();
70     void coreSocketDisconnected();
71
72     void clientInitAck(const QVariantMap &msg);
73
74   // for sync progress
75     void networkInitDone();
76     void ircUserAdded(IrcUser *);
77     void ircUserRemoved(QObject *);
78     void ircUserInitDone(IrcUser *);
79     void ircChannelAdded(IrcChannel *);
80     void ircChannelRemoved(QObject *);
81     void ircChannelInitDone(IrcChannel *);
82     void checkSyncState();
83
84     void syncToCore(const QVariantMap &sessionState);
85     void sessionStateReceived(const QVariantMap &state);
86
87     void doCoreSetup(const QVariant &setupData);
88     void sslErrors(const QList<QSslError> &errors);
89   
90   private:
91     QPointer<QIODevice> socket;
92     quint32 blockSize;
93     QVariantMap coreConnectionInfo;
94
95     QSet<QObject *> netsToSync, channelsToSync, usersToSync;
96     int numNetsToSync, numChannelsToSync, numUsersToSync;
97
98 };
99
100 #endif