54af24ede946166308b10b508e67acd65e876e6d
[quassel.git] / src / core / coresession.h
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by The Quassel IRC Development 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) any later version.                                   *
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 _CORESESSION_H_
22 #define _CORESESSION_H_
23
24 #include <QObject>
25 #include <QString>
26 #include <QVariant>
27
28 #include "coreproxy.h"
29
30 class Server;
31 class Storage;
32
33 class CoreSession : public QObject {
34   Q_OBJECT
35
36   public:
37     CoreSession(UserId, Storage *);
38     ~CoreSession();
39
40     QList<BufferId> buffers() const;
41     UserId userId() const;
42     QVariant sessionState();
43
44   public slots:
45     //! Store a piece session-wide data and distribute it to connected clients.
46     void storeSessionData(const QString &key, const QVariant &data);
47
48   public:
49     //! Retrieve a piece of session-wide data.
50     QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant());
51
52     CoreProxy *proxy();
53
54   public slots:
55     void connectToIrc(QStringList);
56     void processSignal(ClientSignal, QVariant, QVariant, QVariant);
57     void sendBacklog(BufferId, QVariant, QVariant);
58     void msgFromGui(BufferId, QString message);
59     void sendServerStates();
60
61   signals:
62     void proxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
63
64     void msgFromGui(QString net, QString buf, QString message);
65     void displayMsg(Message message);
66     void displayStatusMsg(QString, QString);
67
68     void connectToIrc(QString net);
69     void disconnectFromIrc(QString net);
70     void serverStateRequested();
71
72     void backlogData(BufferId, QList<QVariant>, bool done);
73
74     void bufferIdUpdated(BufferId);
75     void sessionDataChanged(const QString &key);
76     void sessionDataChanged(const QString &key, const QVariant &data);
77
78   private slots:
79     void recvStatusMsgFromServer(QString msg);
80     void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
81     void serverConnected(QString net);
82     void serverDisconnected(QString net);
83
84   private:
85     UserId user;
86
87     CoreProxy *coreProxy;
88     Storage *storage;
89     QHash<QString, Server *> servers;
90
91     VarMap sessionData;
92     QMutex mutex;
93
94 };
95
96 #endif