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 * localSession();
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(ClientSignal, 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 serverConnected(QString net);
113 void serverDisconnected(QString net);
116 CoreProxy *coreProxy;
118 QHash<QString, Server *> servers;
124 class Core : public QObject {
131 QList<BufferId> getBuffers();
134 void connectToIrc(QStringList);
135 void sendBacklog(BufferId, QVariant, QVariant);
136 void msgFromGUI(BufferId, QString message);
139 void msgFromGUI(QString net, QString buf, QString message);
140 void displayMsg(Message message);
141 void displayStatusMsg(QString, QString);
143 void connectToIrc(QString net);
144 void disconnectFromIrc(QString net);
145 void serverStateRequested();
147 void backlogData(BufferId, QList<QVariant>, bool done);
149 void bufferIdUpdated(BufferId);
152 void globalDataUpdated(QString);
153 void recvStatusMsgFromServer(QString msg);
154 void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
155 void serverDisconnected(QString net);
159 QHash<QString, Server *> servers;