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 ***************************************************************************/
30 #define DEFAULT_PORT 6667
35 * This is a server object, managing a single connection to an IRC server, handling the associated channels and so on.
36 * We have this run in its own thread mainly to not block other server objects or the core if something goes wrong,
37 * e.g. if some scripts starts running wild...
40 class Server : public QThread {
50 // serverState state();
51 bool isConnected() { return socket.state() == QAbstractSocket::ConnectedState; }
54 // void setServerOptions();
55 void connectToIrc(const QString &host, quint16 port = DEFAULT_PORT);
56 void disconnectFromIrc();
58 void putRawLine(QString input);
59 void putCmd(QString cmd, QStringList params, QString prefix = 0);
62 //void outputLine(const QString & /*, Buffer *target = 0 */);
64 void recvRawServerMsg(QString);
65 void recvLine(QString); // temp, should send a message to the GUI
69 void socketError(QAbstractSocket::SocketError);
70 void socketConnected();
71 void socketDisconnected();
72 void socketStateChanged(QAbstractSocket::SocketState);
74 /* Message Handlers */
75 /* handleXxxxFromServer(QString prefix, QStringList params); */
76 void handleNoticeFromServer(QString, QStringList);
77 void handlePingFromServer(QString, QStringList);
79 void defaultHandlerForServer(QString cmd, QString prefix, QStringList params);
85 void handleServerMsg(QString rawMsg);
86 void handleUserMsg(QString usrMsg);
87 //static inline void dispatchServerMsg(Message *msg) { msg->getServer()->handleServerMsg(msg); }
88 //static inline void dispatchUserMsg(Message *msg) { msg->getServer()->handleUserMsg(msg); }
90 class ParseError : public Exception {
92 ParseError(QString cmd, QString prefix, QStringList params);
95 class UnknownCmdError : public Exception {
97 UnknownCmdError(QString cmd, QString prefix, QStringList params);