ce79fc8839293d2feb89f1095d60a952373a19bb
[quassel.git] / network / server.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 by The Quassel 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 _SERVER_H_
22 #define _SERVER_H_
23
24 #include <QtCore>
25 #include <QtNetwork>
26
27 #define DEFAULT_PORT 6667
28
29 /**
30  * This is a server object, managing a single connection to an IRC server, handling the associated channels and so on.
31  * We have this run in its own thread mainly to not block other server objects or the core if something goes wrong,
32  * e.g. if some scripts starts running wild...
33  */
34
35 class Server : public QThread {
36   Q_OBJECT
37
38   public:
39     Server();
40     ~Server();
41
42     void run();
43
44     // serverState state();
45
46   public slots:
47     // void setServerOptions();
48     void connectToIrc(const QString &host, quint16 port = DEFAULT_PORT);
49     void disconnectFromIrc();
50
51     void putRawLine(const QString &input /*, Buffer *source = 0 */);
52
53   signals:
54     //void outputLine(const QString & /*, Buffer *target = 0 */);
55
56     void recvLine(const QString&);
57
58   private slots:
59     void socketHasData();
60     void socketError(QAbstractSocket::SocketError);
61     void socketConnected();
62     void socketDisconnected();
63     void socketStateChanged(QAbstractSocket::SocketState);
64
65   private:
66     QTcpSocket *socket;
67     QTextStream stream;
68
69 };
70
71 /*
72 class TcpConnection : public QThread {
73   Q_OBJECT
74
75
76   public:
77     void run();
78     QAbstractSocket::SocketState state() const;
79
80   public slots:
81     void connectToHost(const QString &host, quint16 port = DEFAULT_PORT);
82     void disconnectFromHost();
83     void sendLine(const QString &);
84
85   signals:
86     void recvLine(QString);
87     void error(QAbstractSocket::SocketError);
88     void connected();
89     void disconnected();
90     void stateChanged(QAbstractSocket::SocketState);
91
92   private:
93     QTcpSocket socket;
94     QTextStream stream;
95 };
96 */
97
98 #endif