YES! We finally have dynamic signals between Core and Client, meaning that arbitrary
[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 #include "message.h"
30
31 class Server;
32 class SignalProxy;
33 class Storage;
34
35 class CoreSession : public QObject {
36   Q_OBJECT
37
38   public:
39     CoreSession(UserId, Storage *, QObject *parent = 0);
40     ~CoreSession();
41
42     QList<BufferId> buffers() const;
43     UserId userId() const;
44     QVariant sessionState();
45
46   public slots:
47     //! Store a piece session-wide data and distribute it to connected clients.
48     void storeSessionData(const QString &key, const QVariant &data);
49
50     void addClient(QIODevice *connection);
51
52   public:
53     //! Retrieve a piece of session-wide data.
54     QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant());
55
56     //CoreProxy *proxy();
57     SignalProxy *signalProxy() const;
58
59   public slots:
60     void connectToNetwork(QString);
61     //void processSignal(ClientSignal, QVariant, QVariant, QVariant);
62     void sendBacklog(BufferId, QVariant, QVariant);
63     void msgFromGui(BufferId, QString message);
64     void sendServerStates();
65
66   signals:
67     //void proxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
68
69     void msgFromGui(QString net, QString buf, QString message);
70     void displayMsg(Message message);
71     void displayStatusMsg(QString, QString);
72
73     void connectToIrc(QString net);
74     void disconnectFromIrc(QString net);
75     void serverStateRequested();
76
77     void backlogData(BufferId, QVariantList, bool done);
78
79     void bufferIdUpdated(BufferId);
80     void sessionDataChanged(const QString &key);
81     void sessionDataChanged(const QString &key, const QVariant &data);
82
83   private slots:
84     void recvStatusMsgFromServer(QString msg);
85     void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
86     void serverConnected(QString net);
87     void serverDisconnected(QString net);
88
89   private:
90     UserId user;
91
92     //CoreProxy *coreProxy;
93     SignalProxy *_signalProxy;
94     Storage *storage;
95     QHash<QString, Server *> servers;
96
97     QVariantMap sessionData;
98     QMutex mutex;
99
100 };
101
102 #endif