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 ***************************************************************************/
24 #include <QAbstractSocket>
26 #include <QStringList>
32 #include "signalproxy.h"
36 class IrcServerHandler;
37 class UserInputHandler;
42 * This is a server object, managing a single connection to an IRC server, handling the associated channels and so on.
43 * We have this running in its own thread mainly to not block other server objects or the core if something goes wrong,
44 * e.g. if some scripts starts running wild...
47 class Server : public QThread {
51 Server(UserId uid, uint networkId, QString network);
54 UserId userId() const { return _userId; }
56 // serverState state();
57 bool isConnected() const { return socket.state() == QAbstractSocket::ConnectedState; }
59 uint networkId() const;
60 QString networkName(); // hasbeen getNetwork()
62 NetworkInfo *networkInfo() { return _networkInfo; }
63 IrcServerHandler *ircServerHandler() {return _ircServerHandler; }
64 UserInputHandler *userInputHandler() {return _userInputHandler; }
65 CtcpHandler *ctcpHandler() {return _ctcpHandler; }
68 // void setServerOptions();
69 void connectToIrc(QString net);
70 void disconnectFromIrc(QString net);
71 void userInput(uint netid, QString buffer, QString msg);
73 void putRawLine(QString input);
74 void putCmd(QString cmd, QStringList params, QString prefix = 0);
79 void serverState(QString net, QVariantMap data);
80 void recvRawServerMsg(QString);
81 void displayStatusMsg(QString);
82 //void displayMsg(Message msg);
83 void displayMsg(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
84 void connected(uint networkId);
85 void disconnected(uint networkId);
87 void synchronizeClients();
89 void queryRequested(QString network, QString nick);
95 void socketError(QAbstractSocket::SocketError);
96 void socketConnected();
97 void socketDisconnected();
98 void socketStateChanged(QAbstractSocket::SocketState);
106 IrcServerHandler *_ircServerHandler;
107 UserInputHandler *_userInputHandler;
108 CtcpHandler *_ctcpHandler;
110 NetworkInfo *_networkInfo;
112 QVariantMap networkSettings;
113 QVariantMap identity;
115 CoreSession *coreSession() const;
117 class ParseError : public Exception {
119 ParseError(QString cmd, QString prefix, QStringList params);
122 class UnknownCmdError : public Exception {
124 UnknownCmdError(QString cmd, QString prefix, QStringList params);