1 /***************************************************************************
2 * Copyright (C) 2005/06 by The Quassel Team *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
26 #include <QSqlDatabase>
31 #include "coreproxy.h"
35 class Core : public QObject {
39 static Core * instance();
40 static void destroy();
42 static CoreSession * session(UserId);
43 static CoreSession * guiSession();
44 static CoreSession * createSession(UserId);
47 void recvProxySignal(CoreSignal, QVariant, QVariant, QVariant);
48 bool startListening(uint port = 4242);
50 void incomingConnection();
52 void clientDisconnected();
53 void updateGlobalData(UserId, QString);
59 static Core *instanceptr;
61 void processClientInit(QTcpSocket *socket, const QVariant &v);
62 void processClientUpdate(QTcpSocket *socket, QString key, const QVariant &data);
65 QHash<UserId, CoreSession *> sessions;
68 QTcpServer server; // TODO: implement SSL
69 QHash<QTcpSocket *, UserId> validClients;
70 QHash<QTcpSocket *, quint32> blockSizes;
73 class CoreSession : public QObject {
77 CoreSession(UserId, Storage *);
80 QList<BufferId> buffers() const;
81 inline UserId userId();
82 QVariant sessionState();
86 void connectToIrc(QStringList);
87 void processSignal(GUISignal, QVariant, QVariant, QVariant);
88 void sendBacklog(BufferId, QVariant, QVariant);
89 void msgFromGui(BufferId, QString message);
90 void sendServerStates();
93 void proxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
95 void msgFromGui(QString net, QString buf, QString message);
96 void displayMsg(Message message);
97 void displayStatusMsg(QString, QString);
99 void connectToIrc(QString net);
100 void disconnectFromIrc(QString net);
101 void serverStateRequested();
103 void backlogData(BufferId, QList<QVariant>, bool done);
105 void bufferIdUpdated(BufferId);
108 //void recvProxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
109 void globalDataUpdated(UserId, QString);
110 void recvStatusMsgFromServer(QString msg);
111 void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
112 void serverDisconnected(QString net);
115 CoreProxy *coreProxy;
117 QHash<QString, Server *> servers;
123 class Core : public QObject {
130 QList<BufferId> getBuffers();
133 void connectToIrc(QStringList);
134 void sendBacklog(BufferId, QVariant, QVariant);
135 void msgFromGUI(BufferId, QString message);
138 void msgFromGUI(QString net, QString buf, QString message);
139 void displayMsg(Message message);
140 void displayStatusMsg(QString, QString);
142 void connectToIrc(QString net);
143 void disconnectFromIrc(QString net);
144 void serverStateRequested();
146 void backlogData(BufferId, QList<QVariant>, bool done);
148 void bufferIdUpdated(BufferId);
151 void globalDataUpdated(QString);
152 void recvStatusMsgFromServer(QString msg);
153 void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
154 void serverDisconnected(QString net);
158 QHash<QString, Server *> servers;