Cmd::Cmd(QObject *parent) : QObject(parent), boucle(true), tailleMessage(0), out(stdout, QIODevice::WriteOnly), in(stdin, QIODevice::ReadOnly) { m_socket = new QLocalSocket(this); connect(m_socket, SIGNAL(connected()), this, SLOT(onConnexion())); connect(m_socket, SIGNAL(disconnected()), this, SLOT(onDeconnexion())); connect(m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(onError(QLocalSocket::LocalSocketError))); connect(m_socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)), this, SLOT(onStateChanged(QLocalSocket::LocalSocketState))); connect(m_socket, SIGNAL(readyRead()), this, SLOT(donneesRecues())); m_socket->connectToServer("CrafterServer"); out << tr("demarrage\n"); connect(this, SIGNAL(quit()), qApp, SLOT(quit())); }
XDCC::XDCC( QIrc * bot, QString dest, QString filename ) { parent_irc = bot; server = new QTcpServer( this ); socket = 0; if( !server->listen(QHostAddress::Any, 5990) ) { parent_irc->warning( tr( "can't lister on port 5990" ) ); deleteLater(); return; } connect( server, SIGNAL( newConnection() ), this, SLOT( onConnexion() ) ); connect( server, SIGNAL( destroyed( QObject * ) ), this, SLOT( onDeletion( QObject * ) ) ); fichier = QFileInfo( filename ); parent_irc->send( dest, QString( "DCC SEND \"%1\" %2 %3 %4" ).arg( fichier.fileName() ).arg( parent_irc->ip() ).arg( 5990 ).arg( fichier.size() ) ); QTimer::singleShot( 10000, this, SLOT( onTimerTimeout() ) ); }