Ejemplo n.º 1
0
void SslClient::establish(const QString& host, quint16 port)
{
    threadLock_  = new QMutex();
    threadEvent_ = new QWaitCondition();

    QMutexLocker blocked(threadLock_);
    host_ = host;
    port_ = port;

    start();
    threadEvent_->wait(threadLock_);

    if(ssl_.isNull() || running_ == false)
        Q_ASSERT_X(ssl_.isNull() || running_ == false, "SslClient::establish", "Cannot start SslClient's thread");

    connect(ssl_.data(), SIGNAL(stateChanged(QAbstractSocket::SocketState)), 
            this, SLOT(socketStateChanged(QAbstractSocket::SocketState)), Qt::DirectConnection);
    connect(ssl_.data(), SIGNAL(encrypted()), 
            this, SLOT(socketEncrypted()), Qt::DirectConnection);
    connect(ssl_.data(), SIGNAL(error(QAbstractSocket::SocketError)), 
            this, SLOT(socketError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect(ssl_.data(), SIGNAL(sslErrors(QList<QSslError>)), 
            this, SLOT(sslErrors(QList<QSslError>)), Qt::DirectConnection);
    connect(ssl_.data(), SIGNAL(readyRead()), 
            this, SLOT(socketReadyRead()), Qt::DirectConnection);

    ConfigureForLMAX();
}
Ejemplo n.º 2
0
void SslClient::secureConnect()
{
    if (!socket) {
        socket = new QSslSocket(this);
        connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
                this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
        connect(socket, SIGNAL(encrypted()),
                this, SLOT(socketEncrypted()));
        connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
                this, SLOT(sslErrors(QList<QSslError>)));
        connect(socket, SIGNAL(readyRead()),
                this, SLOT(socketReadyRead()));
    }

    socket->connectToHostEncrypted(form->hostNameEdit->text(), form->portBox->value());
    updateEnabledState();
}
Ejemplo n.º 3
0
void SslClient::setupSecureSocket()
{
    if (socket)
        return;

    socket = new QSslSocket(this);

    connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
    connect(socket, SIGNAL(encrypted()),
            this, SLOT(socketEncrypted()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(socketError(QAbstractSocket::SocketError)));
    connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
            this, SLOT(sslErrors(QList<QSslError>)));
    connect(socket, SIGNAL(readyRead()),
            this, SLOT(socketReadyRead()));

}
Ejemplo n.º 4
0
//! [1]
void SslClient::secureConnect()
{
    if (!m_socket) {
        // Create a new SSL socket and connect against its signals to receive notifications about state changes
        m_socket = new QSslSocket(this);
        connect(m_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
                this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
        connect(m_socket, SIGNAL(encrypted()),
                this, SLOT(socketEncrypted()));
        connect(m_socket, SIGNAL(sslErrors(QList<QSslError>)),
                this, SLOT(sslErrors(QList<QSslError>)));
        connect(m_socket, SIGNAL(readyRead()),
                this, SLOT(socketReadyRead()));
    }

    // Trigger the SSL-handshake
    m_socket->connectToHostEncrypted(m_hostName, m_port);

    updateEnabledState();
}
Ejemplo n.º 5
0
void QgsAuthSslImportDialog::secureConnect()
{
  if ( leServer->text().isEmpty() )
  {
    return;
  }

  leServer->setStyleSheet( QLatin1String( "" ) );
  clearStatusCertificateConfig();

  if ( !mSocket )
  {
    mSocket = new QSslSocket( this );
    connect( mSocket, SIGNAL( stateChanged( QAbstractSocket::SocketState ) ),
             this, SLOT( socketStateChanged( QAbstractSocket::SocketState ) ) );
    connect( mSocket, SIGNAL( connected() ),
             this, SLOT( socketConnected() ) );
    connect( mSocket, SIGNAL( disconnected() ),
             this, SLOT( socketDisconnected() ) );
    connect( mSocket, SIGNAL( encrypted() ),
             this, SLOT( socketEncrypted() ) );
    connect( mSocket, SIGNAL( error( QAbstractSocket::SocketError ) ),
             this, SLOT( socketError( QAbstractSocket::SocketError ) ) );
    connect( mSocket, SIGNAL( sslErrors( QList<QSslError> ) ),
             this, SLOT( sslErrors( QList<QSslError> ) ) );
    connect( mSocket, SIGNAL( readyRead() ),
             this, SLOT( socketReadyRead() ) );
  }

  mSocket->setCaCertificates( mTrustedCAs );

  if ( !mTimer )
  {
    mTimer = new QTimer( this );
    connect( mTimer, SIGNAL( timeout() ), this, SLOT( destroySocket() ) );
  }
  mTimer->start( spinbxTimeout->value() * 1000 );

  mSocket->connectToHost( leServer->text(), spinbxPort->value() );
  updateEnabledState();
}
Ejemplo n.º 6
0
/*
 * Establish connection to the server.
 */
Xmpp::Xmpp(const Jid &jid, const QString &pServer, const int pPort)
{
	timeOut = 5000; // Default timeout set to 5 seconds
	tcpSocket = new QTcpSocket();
	sslSocket = new QSslSocket();
	sslSocket->setProtocol(QSsl::SslV3);
	connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
	connect(sslSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
	//connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &errors)), this, SLOT(sslError(const QList<QSslError>& errors)));
	connect(sslSocket, SIGNAL(encrypted()), this, SLOT(socketEncrypted()));

	username = jid.node();
	server = jid.domain();

	if (pServer == "")
	{
		usePersonnalServer = false;
	}
	else
	{
		usePersonnalServer = true;
		personnalServer = pServer;
	}

	port = pPort;
	authenticated = false;
	isTlsing = false;
	tlsDone = false;
	saslDone = false;
	needBind = false;
	needSession = false;
	jidDone = false;
	useTls = true;
	connect(tcpSocket, SIGNAL(connected()), this, SLOT(start()));
	connect(sslSocket, SIGNAL(connected()), this, SLOT(start()));
	j = jid;
	printf("[XMPP] JID = %s\n", jid.full().toLatin1().constData());
}