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