void SshRemoteProcessRunner::handleConnectionError(QSsh::SshError error) { d->m_lastConnectionError = error; d->m_lastConnectionErrorString = d->m_connection->errorString(); handleDisconnected(); emit connectionError(); }
void BOSHConnection::disconnect() { if (connection_) { connection_->disconnect(); sid_ = ""; } else { /* handleDisconnected takes care of the connector_ as well */ handleDisconnected(boost::optional<Connection::Error>()); } }
void FtpClient::init() { qDebug() << "FtpClient:: " << port << " Init"; // if we did not find one, use IPv4 localhost if (ipAddress.isEmpty()) ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); qDebug() << "FtpClient:: " << port << " Init connect"; // from abtractsocket connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleError(QAbstractSocket::SocketError))); connect(tcpSocket, SIGNAL(connected()), this, SLOT(handleConnected())); connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(handleDisconnected())); connect(tcpSocket, SIGNAL(hostFound()), this, SLOT(handleHostFound())); connect(tcpSocket, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&,QAuthenticator*)), this, SLOT(handleProxyAuthenticationRequired(const QNetworkProxy&,QAuthenticator*))); connect(tcpSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(handleStateChanged(QAbstractSocket::SocketState))); // from QIODevice connect(tcpSocket, SIGNAL(aboutToClose()), this, SLOT(handleAboutToClose())); connect(tcpSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(handleBytesWritten(qint64))); connect(tcpSocket, SIGNAL(readChannelFinished()), this, SLOT(handleReadChannelFinished())); connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(handleReadyRead())); qDebug() << "FtpClient:: " << port << " Init NetworkConfigurationManager manager"; QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { qDebug() << "FtpClient::Init QNetworkConfigurationManager::NetworkSessionRequired"; // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String(SETTING_STR)); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } qDebug() << "FtpClient:: " << port << " Init new QNetworkSession(config, this)"; networkSession = new QNetworkSession(config, this); qDebug() << "FtpClient:: " << port << " Init connect(networkSession, SIGNAL(opened()), this, SLOT(handleSessionOpened()))"; connect(networkSession, SIGNAL(opened()), this, SLOT(handleSessionOpened())); qDebug() << "FtpClient:: " << port << " Init networkSession->open()"; networkSession->open(); } else { qDebug() << "FtpClient:: Init " << port << " tcpSocket->connectToHost())" << " ipAddress " << ipAddress << " port " << port; tcpSocket->connectToHost(QHostAddress(ipAddress), port); } mInitiated = true; }
MiniHttpServerConnection::MiniHttpServerConnection(QTcpSocket *socket) : QObject(socket), socket(socket), source(0) { connect(socket, SIGNAL(readyRead()), SLOT(handleReadyRead())); connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(handleBytesWritten())); connect(socket, SIGNAL(disconnected()), SLOT(handleDisconnected())); timeout.setInterval(30000); timeout.setSingleShot(true); connect(&timeout, SIGNAL(timeout()), SLOT(handleTimeout())); timeout.start(); }
// ChatConnection初始化和信号槽连接 ChatConnection::ChatConnection(QObject *parent) : QTcpSocket(parent) { this->greetingMessage = QObject::tr("undefined"); this->userName = QObject::tr("unknown"); this->state = WaitingForGreeting; this->currentDataType = UNDEFINED; this->numBytesForCurrentDataType = -1; this->transferTimerId = 0; this->isGreetingMessageSent = false; connect(this, SIGNAL(readyRead()), this, SLOT(processReadyRead())); connect(this, SIGNAL(connected()), this, SLOT(sendGreetingMessage())); connect(this, SIGNAL(disconnected()), this, SLOT(handleDisconnected())); connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleSocketError(QAbstractSocket::SocketError))); }
void SshRemoteProcessRunnerPrivate::run(const QByteArray &command) { ASSERT_STATE(Inactive); setState(Connecting); m_command = command; connect(m_connection.data(), SIGNAL(error(Utils::SshError)), SLOT(handleConnectionError(Utils::SshError))); connect(m_connection.data(), SIGNAL(disconnected()), SLOT(handleDisconnected())); if (m_connection->state() == SshConnection::Connected) { handleConnected(); } else { connect(m_connection.data(), SIGNAL(connected()), SLOT(handleConnected())); m_connection->connectToHost(); } }
void newConnThread::run() { //this is where the thread actually starts. socket = new QTcpSocket; if(!socket->setSocketDescriptor(this->socketDescriptor)) { exit(1); } //cool. we've got a connection. //setup timer timer = new QTimer; timer->start(500); //time to connect some signals and slots. connect(socket,SIGNAL(readyRead()),this,SLOT(handleReadyRead())); connect(socket,SIGNAL(disconnected()),this,SLOT(handleDisconnected())); connect(timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); connect(this,SIGNAL(timeSig()),this,SLOT(handleWrite())); //make the thread run even when this run function goes out of scope. exec(); }
void SshRemoteProcessRunner::runInternal(const QByteArray &command, const SshConnectionParameters &sshParams) { setState(Connecting); d->m_lastConnectionError = SshNoError; d->m_lastConnectionErrorString.clear(); d->m_processErrorString.clear(); d->m_exitSignal = SshRemoteProcess::NoSignal; d->m_exitCode = -1; d->m_command = command; d->m_connection = SshConnectionManager::instance().acquireConnection(sshParams); connect(d->m_connection, SIGNAL(error(QSsh::SshError)), SLOT(handleConnectionError(QSsh::SshError))); connect(d->m_connection, SIGNAL(disconnected()), SLOT(handleDisconnected())); if (d->m_connection->state() == SshConnection::Connected) { handleConnected(); } else { connect(d->m_connection, SIGNAL(connected()), SLOT(handleConnected())); if (d->m_connection->state() == SshConnection::Unconnected) d->m_connection->connectToHost(); } }
void SshRemoteProcessRunnerPrivate::handleConnectionError(Utils::SshError error) { handleDisconnected(); emit connectionError(error); }