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 socket = new QTcpSocket();
33 connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
34 connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
35 connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
36 connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
37 connect(socket, SIGNAL(readyRead()), this, SLOT(socketHasData()));
39 stream.setDevice(socket);
40 //connectToIrc("irc.quakenet.org", 6667);
45 QAbstractSocket::SocketState TcpConnection::state( ) const {
46 return socket.state();
50 void Server::connectToIrc( const QString & host, quint16 port ) {
51 qDebug() << "Connecting...";
52 socket->connectToHost(host, port);
55 void Server::disconnectFromIrc( ) {
56 socket->disconnectFromHost();
59 void Server::putRawLine( const QString &s ) {
60 qDebug() << "Raw line: " << s;
61 stream << s << "\r\n" << flush;
64 void Server::socketHasData( ) {
65 while(socket->canReadLine()) {
66 QString s = stream.readLine();
67 qDebug() << "Read: " << s;
68 emit recvLine(s + "\n");
72 void Server::socketError( QAbstractSocket::SocketError err ) {
73 qDebug() << "Socket Error!";
77 void Server::socketConnected( ) {
78 qDebug() << "Socket connected!";
82 void Server::socketDisconnected( ) {
83 qDebug() << "Socket disconnected!";
84 //emit disconnected();
87 void Server::socketStateChanged(QAbstractSocket::SocketState state) {
88 qDebug() << "Socket state changed: " << state;