Exemplo n.º 1
0
TSock::TSock(QTcpSocket *sock, QObject *parent) :
  QObject(parent),
  listenPort(0)
{

    if (sock == NULL)
        socket = new QTcpSocket;
    else
        socket = sock;

    connect(socket, SIGNAL(connected()),
            this, SLOT(socketConnected()));

    connect(socket, SIGNAL(disconnected()),
            this, SLOT(socketDisconnected()));

    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(socketError(QAbstractSocket::SocketError)));

    connect(socket, SIGNAL(readyRead()),
            this, SLOT(socketDataReady()));


    connect(&server, SIGNAL(newConnection()),
            this, SLOT(serverConnection()));
}
/*!
    Constructs an assistant client with the given \a parent.
    The \a path specifies the path to the Qt Assistant executable.
    If \a path is an empty string the system path (\c{%PATH%} or \c $PATH)
    is used.
*/
QAssistantClient::QAssistantClient( const QString &path, QObject *parent )
    : QObject( parent ), host ( QLatin1String("localhost") )
{
    if ( path.isEmpty() )
        assistantCommand = QLatin1String("assistant");
    else {
        QFileInfo fi( path );
        if ( fi.isDir() )
            assistantCommand = path + QLatin1String("/assistant");
        else
            assistantCommand = path;
    }

#if defined(Q_OS_MAC)
    assistantCommand += QLatin1String(".app/Contents/MacOS/assistant");
#endif

    socket = new QTcpSocket( this );
    connect( socket, SIGNAL(connected()),
            SLOT(socketConnected()) );
    connect( socket, SIGNAL(disconnected()),
            SLOT(socketConnectionClosed()) );
    connect( socket, SIGNAL(error(QAbstractSocket::SocketError)),
             SLOT(socketError()) );
    opened = false;
    proc = new QProcess( this );
    port = 0;
    pageBuffer = QLatin1String("");
    connect( proc, SIGNAL(readyReadStandardError()),
             this, SLOT(readStdError()) );
    connect( proc, SIGNAL(error(QProcess::ProcessError)),
        this, SLOT(procError(QProcess::ProcessError)) );
}
Exemplo n.º 3
0
void ClientApplication::start() {
	if (!parseCommandLine()) {
		QMessageBox::critical(NULL, applicationName(), trUtf8("Error in the command line arguments. Arguments:\n--host <h>\tConnect to the server on host <h>.\n--local\tRun client locally.\n--port <p>\tUse port <p> to connect to the server."));
		quit();
		return;
	}
	if (mode == mUnspecified) {
		ConnectDialog connectDialog;
		int code = connectDialog.exec();
		if (code == QDialog::Rejected) {
			quit();
			return;
		}
		if (connectDialog.local()) {
			mode = mLocal;
		}
		else {
			mode = mRemote;
			host = connectDialog.host();
			port = connectDialog.port();
		}
	}
	if (mode == mLocal) {
		theTrainer.reset(new Trainer());
		showMainWindow();
	}
	else {
		ProxyTrainer *trainer = new ProxyTrainer();
		theTrainer.reset(trainer);
		connect(trainer, SIGNAL(socketConnected()), SLOT(showMainWindow()));
		connect(trainer, SIGNAL(socketDisconnected()), SLOT(socketDisconnected()));
		connect(trainer, SIGNAL(socketError(QString)), SLOT(socketError(QString)));
		trainer->socketConnectToHost(host, port);
	}
}
Exemplo n.º 4
0
IndiClient::IndiClient(const int &attempts) : mPort(indi::PORT), mAttempts(attempts), mAttempt(1)
{
    connect(&mQTcpSocket, SIGNAL(connected()), SLOT(socketConnected()));
    connect(&mQTcpSocket, SIGNAL(disconnected()), SLOT(socketDisconnected()));
    connect(&mQTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));
    connect(&mQTcpSocket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
}
Exemplo n.º 5
0
bool MjpegClient::connectTo(const QString& host, int port, QString url, const QString& user, const QString& pass)
{
    if(url.isEmpty())
        url = "/";

    m_host = host;
    m_port = port > 0 ? port : 80;
    m_url = url;
    m_user = user;
    m_pass = pass;

    if(m_socket)
    {
        m_socket->abort();
        delete m_socket;
        m_socket = 0;
    }

    m_socket = new QTcpSocket(this);
    connect(m_socket, SIGNAL(readyRead()),    this,   SLOT(dataReady()));
    connect(m_socket, SIGNAL(disconnected()), this,   SLOT(lostConnection()));
    connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(socketDisconnected()));
    connect(m_socket, SIGNAL(connected()),    this, SIGNAL(socketConnected()));
    connect(m_socket, SIGNAL(connected()),    this,   SLOT(connectionReady()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError)));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(lostConnection(QAbstractSocket::SocketError)));

    m_socket->connectToHost(host,port);
    m_socket->setReadBufferSize(1024 * 1024);

    return true;
}
Exemplo n.º 6
0
tlen::tlen( QObject* parent ): QObject( parent ) {
	state = tlen::Disconnected;

	hostname = "s1.tlen.pl";
	hostport = 443;
	Secure = false;
	Reconnect = false;

	Status= tlen::unavailable;
	Descr="";

	tmpDoc=new QDomDocument;

	socket=new QTcpSocket();
	ping=new QTimer();

	connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
	connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
	connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));

	connect(this, SIGNAL(tlenLoggedIn()), this, SLOT(writeStatus()));
	connect(this, SIGNAL(statusUpdate()), this, SLOT(writeStatus()));

	connect(this, SIGNAL(eventReceived(QDomNode)), this, SLOT(event(QDomNode)));

	connect(ping, SIGNAL(timeout()), this, SLOT(sendPing()));
	srand(time(NULL));
}
Exemplo n.º 7
0
/*!
    Constructs an assistant client object. The \a path specifies the
    path to the Qt Assistant executable. If \a path is an empty
    string the system path (\c{%PATH%} or \c $PATH) is used.

    The assistant client object is a child of \a parent and is called
    \a name.
*/
QAssistantClient::QAssistantClient( const QString &path, QObject *parent, const char *name )
    : QObject( parent, name ), host ( "localhost" )
{
    if ( path.isEmpty() )
	assistantCommand = "assistant";
    else {
	QFileInfo fi( path );
	if ( fi.isDir() )
	    assistantCommand = path + "/assistant";
	else
	    assistantCommand = path;
    }

#if defined(Q_OS_MACX)
    assistantCommand += ".app/Contents/MacOS/assistant";
#elif defined(Q_WS_WIN)
    if (!assistantCommand.endsWith(".exe"))
        assistantCommand += ".exe";
#endif
    socket = new QSocket( this );
    connect( socket, SIGNAL( connected() ),
	    SLOT( socketConnected() ) );
    connect( socket, SIGNAL( connectionClosed() ),
	    SLOT( socketConnectionClosed() ) );
    connect( socket, SIGNAL( error( int ) ),
	    SLOT( socketError( int ) ) );
    opened = FALSE;
    proc = new QProcess( this );
    port = 0;
    pageBuffer = "";
    connect( proc, SIGNAL( readyReadStderr() ),
	     this, SLOT( readStdError() ) );
}
Exemplo n.º 8
0
BtLocalDevice::BtLocalDevice(QObject *parent) :
    QObject(parent), securityFlags(QBluetooth::NoSecurity)
{
    localDevice = new QBluetoothLocalDevice(this);
    connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)),
            this, SIGNAL(error(QBluetoothLocalDevice::Error)));
    connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
            this, SIGNAL(hostModeStateChanged()));
    connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)),
            this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)));
    connect(localDevice, SIGNAL(deviceConnected(QBluetoothAddress)),
            this, SLOT(connected(QBluetoothAddress)));
    connect(localDevice, SIGNAL(deviceDisconnected(QBluetoothAddress)),
            this, SLOT(disconnected(QBluetoothAddress)));
    connect(localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)),
            this, SLOT(pairingDisplayConfirmation(QBluetoothAddress,QString)));

    if (localDevice->isValid()) {
        deviceAgent = new QBluetoothDeviceDiscoveryAgent(this);
        connect(deviceAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
                this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
        connect(deviceAgent, SIGNAL(finished()),
                this, SLOT(discoveryFinished()));
        connect(deviceAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
                this, SLOT(discoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
        connect(deviceAgent, SIGNAL(canceled()),
                this, SLOT(discoveryCanceled()));

        serviceAgent = new QBluetoothServiceDiscoveryAgent(this);
        connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
                this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
        connect(serviceAgent, SIGNAL(finished()),
                this, SLOT(serviceDiscoveryFinished()));
        connect(serviceAgent, SIGNAL(canceled()),
                this, SLOT(serviceDiscoveryCanceled()));
        connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
                this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error)));

        socket = new QBluetoothSocket(SOCKET_PROTOCOL, this);
        connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)),
                this, SLOT(socketStateChanged(QBluetoothSocket::SocketState)));
        connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)),
                this, SLOT(socketError(QBluetoothSocket::SocketError)));
        connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
        connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
        connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
        setSecFlags(socket->preferredSecurityFlags());

        server = new QBluetoothServer(SOCKET_PROTOCOL, this);
        connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection()));
        connect(server, SIGNAL(error(QBluetoothServer::Error)),
                this, SLOT(serverError(QBluetoothServer::Error)));
    } else {
        deviceAgent = 0;
        serviceAgent = 0;
        socket = 0;
        server = 0;
    }
}
Exemplo n.º 9
0
//nimmt das datenobjekt entgegen und legt einen tcpSocket an
Client::Client(Daten *data,QObject *parent) :
    QObject(parent)
{
    this->data = data;
    tcpSocket = new QTcpSocket(this);
    connected = false;
    QObject::connect(this,SIGNAL(socketConnected()),this,SLOT(sendMessage()));
}
Exemplo n.º 10
0
void Peer::socketConnected()
{
    log(this) << QString::fromLatin1("Peer [%1] connected").arg(getAddressPort()) << endl;

    disconnect(socket, SIGNAL(connectedToPeer()), this, SLOT(socketConnected()));

    setState(ConnectedState);
}
Exemplo n.º 11
0
ExtPlaneConnection::ExtPlaneConnection(QObject *parent) : QTcpSocket(parent), updateInterval(0.333) {
    connect(this, SIGNAL(connected()), this, SLOT(socketConnected()));
    connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
    connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
    connect(&reconnectTimer, SIGNAL(timeout()), this, SLOT(tryReconnect()));
    server_ok = false;
    enableSimulatedRefs = false;
}
Exemplo n.º 12
0
Qip::Qip()
{
    state = Start;
    socket = new QSocket( this );
    connect( socket, SIGNAL(connected()), SLOT(socketConnected()) );
    connect( socket, SIGNAL(connectionClosed()), SLOT(socketConnectionClosed()) );
    connect( socket, SIGNAL(readyRead()), SLOT(socketReadyRead()) );
    connect( socket, SIGNAL(error(int)), SLOT(socketError(int)) );
}
Exemplo n.º 13
0
void ClientInfo::connectToServer()
{
    delete socket;
    socket = new QSocket( this );
    connect( socket, SIGNAL(connected()), SLOT(socketConnected()) );
    connect( socket, SIGNAL(connectionClosed()), SLOT(socketConnectionClosed()) );
    connect( socket, SIGNAL(readyRead()), SLOT(socketReadyRead()) );
    connect( socket, SIGNAL(error(int)), SLOT(socketError(int)) );

    socket->connectToHost( edHost->text(), edPort->text().toInt() );
}
Exemplo n.º 14
0
c_client::c_client(const QString &host, Q_UINT16 port, MyDialog1 *mdlg)
{
  socket = new QSocket(this);
  connect(socket, SIGNAL(connected()), SLOT(socketConnected()));
  connect(socket, SIGNAL(connectionClosed()), SLOT(socketConnectionClosed()));
  connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
  connect(socket, SIGNAL(error(int)), SLOT(socketError(int)));
  
  mydlg = mdlg;
  // mydlg->statusEdit->append("Michon: Trying to connect to the server\n");
  socket->connectToHost(host, port);
}
Exemplo n.º 15
0
void ContactRequestClient::sendRequest()
{
    close();

    socket = new Tor::TorSocket(this);
    connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
    connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadable()));
    socket->setMaxAttemptInterval(600);

    state = WaitConnect;
    socket->connectToHost(user->hostname(), user->port());
}
Exemplo n.º 16
0
TCClientSocket::TCClientSocket( int port, QObject *parent )
: QTcpSocket( parent )
, miBlockSize(0)
{
	line = 0;
  mConnectPort = port;
  connect( this, SIGNAL(connected()), this,SLOT(socketConnected()) );
  connect( this, SIGNAL(disconnected()),this,SLOT(socketConnectionClosed()) );
  connect( this, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(socketError(QAbstractSocket::SocketError)) );
  connect( this, SIGNAL(delayedCloseFinished()), SLOT(socketClosed()) );
  connect( this, SIGNAL(readyRead()), this, SLOT(readyRead()) );
  connect( this, SIGNAL(readyRead(TCClientSocket*)), parent, SLOT(readyRead(TCClientSocket*)) );
  connect(this, SIGNAL(sendText(const QString&)),parent, SLOT(rcvSocketText(const QString&)));
}
Exemplo n.º 17
0
bool TCPSendRawNode::initialise()
{
	if( !NodeControlBase::initialise() )
	{
		return( false );
	}

	connect( &mSocket, SIGNAL(connected()), this, SLOT(socketConnected()) );
	connect( &mSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected() ) );
	connect( &mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)) );
	connect( &mSocket, SIGNAL(hostFound()), this, SLOT(socketHostFound()) );

	return( true );
}
Exemplo n.º 18
0
/*
 * Constructor for the Facepamphlet class, sets up the ui and starts up loginDialog.
 */
Facepamphlet::Facepamphlet(QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);
    
    // Setup TCPSocket
    tcpSocket = new QTcpSocket(this);
    // Connect signals relating to server
    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
    connect(tcpSocket, SIGNAL(connected()), this, SIGNAL(socketConnected()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError()));

    // Initialize login dialog
    loginDialog = new LoginDialog;
    connect(loginDialog, SIGNAL(close()), this, SLOT(close()));
    connect(loginDialog, SIGNAL(loginAttempt(QString, quint16)), this, SLOT(attemptConnection(QString, quint16)));
    connect(loginDialog, SIGNAL(loginAlias(QString)), this, SLOT(loginAlias(QString)));
    connect(this, SIGNAL(socketConnected()), loginDialog, SLOT(socketConnected()));
    connect(this, SIGNAL(socketError()), loginDialog, SLOT(socketError()));

    // Show login dialog
    loginDialog->show();
}
bool QAssistantClient::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: openAssistant(); break;
    case 1: closeAssistant(); break;
    case 2: showPage((const QString&)static_QUType_QString.get(_o+1)); break;
    case 3: socketConnected(); break;
    case 4: socketConnectionClosed(); break;
    case 5: readPort(); break;
    case 6: socketError((int)static_QUType_int.get(_o+1)); break;
    case 7: readStdError(); break;
    default:
	return QObject::qt_invoke( _id, _o );
    }
    return TRUE;
}
Exemplo n.º 20
0
RunnerView::RunnerView(QString appUid, QString server, QWidget* parent) :
    QQuickWidget(parent),
    m_appUid(appUid),
    m_socket(new QLocalSocket(this)),
    m_shared(new QSharedMemory(appUid, this))
{
    qDebug() << "RunnerView::RunnerView";
    connect(engine(), SIGNAL(quit()), this, SLOT(quitApplication()));
    connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
    connect(m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(socketError(QLocalSocket::LocalSocketError)));
    connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
    m_socket->connectToServer(server);
    qDebug() << "RunnerView::RunnerView - END";
}
Exemplo n.º 21
0
void ClientListener::newConnection()
{
	m_socket = m_tcpServer->nextPendingConnection();
	m_tcpServer->close();
	
	connect(m_socket, SIGNAL(hostFound()), SLOT(socketHostFound()));
	connect(m_socket, SIGNAL(connected()), SLOT(socketConnected()));
	connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));
	connect(m_socket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
	connect(m_socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64)));
	connect(m_socket, SIGNAL(disconnected()), SLOT(socketDisconnected()));
	
	changeState(Handshaking);
	
	m_stream.setDevice(m_socket);
}
Exemplo n.º 22
0
bool NetworkClient::connectTo(const QString& host, int port)
{
	if(m_socket)
		m_socket->abort();
		
	m_socket = new QTcpSocket(this);
	connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady()));
	connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(socketDisconnected()));
	connect(m_socket, SIGNAL(connected()), this, SIGNAL(socketConnected()));
	connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError)));
	
	m_blockSize = 0;
	m_socket->connectToHost(host,port);
	
	return true;
}
Exemplo n.º 23
0
/*!
\brief Default constructor
\param D Device to open the telnet connection to (it's passed to CLInterface)

\note This function aborts if called with a device which doesn't support
	telnet access.

This function opens the socket to the telnet interface and insert the password
to access the CLI
*/
TelnetInterface::TelnetInterface(Device *D)
 : CLInterface(D)
{
	if ( ! dev->hasTelnet() || ! dev->driver()->supportTelnet() )
		throw ATMOS::EMissingSupport(ATMOS::EMissingSupport::msTelnet);
	
	s = new QSocket(this, "socket");
	connect(s, SIGNAL(connected()), this, SLOT(socketConnected()));
	connect(s, SIGNAL(connectionClosed()), this, SLOT(socketClosed()));
	
	s->connectToHost( dev->IP(), dev->telnetPort() );

	infoExp.push_back(QRegExp("logged on; type `@close' to close connection.\\r*\\n*"));
	infoExp.push_back(QRegExp("\\*\\*\\* telnet session will close in \\d+s\\r*\\n*"));
	
	termination = "\r\n";
}
Exemplo n.º 24
0
void AbstractLink::disconnect()
{
    if (d->status != Disconnected)
    {
        DENG2_ASSERT(d->socket.get() != 0);

        d->timeout = 0;
        d->socket->close(); // emits signal

        d->status = Disconnected;

        QObject::disconnect(d->socket.get(), SIGNAL(addressResolved()), this, SIGNAL(addressResolved()));
        QObject::disconnect(d->socket.get(), SIGNAL(connected()), this, SLOT(socketConnected()));
        QObject::disconnect(d->socket.get(), SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
        QObject::disconnect(d->socket.get(), SIGNAL(messagesReady()), this, SIGNAL(packetsReady()));
    }
}
Exemplo n.º 25
0
	void ClientConnection::run()
	{
		DEBUG_ONLY(Mara::MLogger::log(Mara::LogLevel::Debug, QString("Creating connection socket.")));
		setStatus(MaraClient::Connection_Inactive);
		_userDisconnected = false;

		Mara::MTcpSocket socket;
		_socket = &socket;

		_socketError = "";

		_connectTimer = new QTimer(&socket);

		QObject::connect(_connectTimer, SIGNAL(timeout()), this, SLOT(checkConnection()));
		_connectTimer->setSingleShot(true);

		QObject::connect(_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
		QObject::connect(_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
		QObject::connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
		QObject::connect(this, SIGNAL(signalSendPacket(const Mara::MPacket*)), 
						 _socket, SLOT(sendPacket(const Mara::MPacket*)));
		QObject::connect(_socket, SIGNAL(packetReceived(Mara::MPacket*)),
						 _packetHandler, SLOT(handlePacket(Mara::MPacket*)));

		DEBUG_ONLY(Mara::MLogger::log(Mara::LogLevel::Debug, QString("Connecting to %1:%2.").arg(_serverAddress).arg(_serverPort)));
		setStatus(MaraClient::Connection_Connecting);
		_socket->connectToHost(_serverAddress, _serverPort);

		_connectTimer->start(10000);

		_socketActive = true;
		exec();
		_socketActive = false;
		
		_socket->close();

		_serverAddress = "";
		_serverPort = 0;

		if(_connectTimer && _connectTimer->isActive())
			_connectTimer->stop();

		if(_status != MaraClient::Connection_Error)
			setStatus(MaraClient::Connection_Inactive);
	}
Exemplo n.º 26
0
void QtTelnetPrivate::setSocket(QTcpSocket *s)
{
    if (socket) {
        q->logout();
        socket->flush();
    }
    delete socket;
    socket = s;
    connected = false;
    if (socket) {
        connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
        connect(socket, SIGNAL(disconnected()),
                this, SLOT(socketConnectionClosed()));
        connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
        connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
                this, SLOT(socketError(QAbstractSocket::SocketError)));
    }
}
Exemplo n.º 27
0
RfcommClient::RfcommClient(QWidget *parent, Qt::WFlags f)
    : QMainWindow(parent, f)
{
    waiter = new QWaitWidget(this);
    connect(waiter, SIGNAL(cancelled()), this, SLOT(cancelConnect()));

    connectAction = new QAction(tr("Connect..."), this);
    connect(connectAction, SIGNAL(triggered()), this, SLOT(connectSocket()));
    QSoftMenuBar::menuFor(this)->addAction(connectAction);
    connectAction->setVisible(true);

    disconnectAction = new QAction(tr("Disconnect"), this);
    connect(disconnectAction, SIGNAL(triggered()), this, SLOT(disconnectSocket()));
    disconnectAction->setVisible(false);
    QSoftMenuBar::menuFor(this)->addAction(disconnectAction);

    sendAction = new QAction(tr("Send"), this);
    connect(sendAction, SIGNAL(triggered()), this, SLOT(newUserText()));
    sendAction->setVisible(false);
    QSoftMenuBar::menuFor(this)->addAction(sendAction);

    QWidget *frame = new QWidget(this);
    QVBoxLayout *layout = new QVBoxLayout;

    logArea = new QTextEdit(frame);
    layout->addWidget(logArea);
    logArea->append(tr("Not connected"));
    logArea->setReadOnly(true);
    logArea->setFocusPolicy(Qt::NoFocus);

    userEntry = new QLineEdit(frame);
    userEntry->setEnabled(false);
    connect(userEntry, SIGNAL(editingFinished()), this, SLOT(newUserText()));
    layout->addWidget(userEntry);

    frame->setLayout(layout);
    setCentralWidget(frame);

    socket = new QBluetoothRfcommSocket(this);
    connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
    connect(socket, SIGNAL(readyRead()), this, SLOT(serverReplied()));

    setWindowTitle(tr("RFCOMM Client"));
}
Exemplo n.º 28
0
ShoutCastIODevice::ShoutCastIODevice(void)
    :  m_redirects (0), 
       m_scratchpad_pos (0),
       m_state (NOT_CONNECTED)
{
    m_socket = new QTcpSocket;
    m_response = new ShoutCastResponse;

    connect(m_socket, SIGNAL(hostFound()), SLOT(socketHostFound()));
    connect(m_socket, SIGNAL(connected()), SLOT(socketConnected()));
    connect(m_socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed()));
    connect(m_socket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), 
            SLOT(socketError(QAbstractSocket::SocketError)));

    switchToState(NOT_CONNECTED);

    setOpenMode(ReadWrite);
}
Exemplo n.º 29
0
TcpSocket::TcpSocket()
{
    socket = new QTcpSocket();

    timer = new QTimer(this);
    timer->setInterval(5000);
    timer->setSingleShot(true);
    connect(timer, &QTimer::timeout, this, &TcpSocket::sendDatagram);

    connect(socket, SIGNAL(connected()), this, SLOT(socketConnected()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()));
    connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
    connect(socket, &QTcpSocket::stateChanged, this, [this]() {
        emit socketStateSignal(socket->state());
    });
    connect(socket, &QTcpSocket::disconnected, this, []() {
        qDebug() << "disconnected";
    });
}
Exemplo n.º 30
0
//! \brief Sets the socket of the connection with the peer
void Peer::setSocket(PeerWireSocket *socket)
{
    this->socket = socket;

    connect(socket, SIGNAL(connectedToPeer()), SLOT(socketConnected()));
    connect(socket, SIGNAL(disconnectedFromPeer()), SLOT(socketDisconnected()));

    connect(socket, SIGNAL(peerIDReceived(QByteArray)), SLOT(processPeerID(QByteArray)));
    connect(socket, SIGNAL(clientNameReceived(QString)), SLOT(processClientName(QString)));

    connect(socket, SIGNAL(peerBitmapUpdated(int, bool)), SIGNAL(peerBitmapUpdated(int, bool)));

    connect(socket, SIGNAL(blockRequested(int, int, int)), SIGNAL(blockRequested(int, int, int)));
    connect(socket, SIGNAL(blockCanceled(int, int, int)), SIGNAL(blockCanceled(int, int, int)));
    connect(socket, SIGNAL(blockReceived(int, int, QByteArray)), SLOT(processBlockReceived(int, int, QByteArray)));
    connect(socket, SIGNAL(blockSent(int, int, int)), SLOT(processBlockSent(int, int, int)));

    connect(socket, SIGNAL(drop(QString, int)), SLOT(processDrop(QString, int)));
}