MainWindow::MainWindow(QApplication *a, QHostAddress ip, quint16 port, QByteArray l, QString skin, double mouseSensitivity, QObject *parent) : QObject(parent) { app = a; repaintTimer = new QTimer; repaintTimer->setInterval(16); stopBot = false; widget = new DrawGl(app, skin, mouseSensitivity); widget->legacy = this; widget->setMinimumHeight(480); widget->setMinimumWidth(640); login = l; qDebug() << "connecting to " + ip.toString() + ":" + QString::number(port); input = new NetworkClass(ip, port, QString::fromLocal8Bit(login)); QObject::connect(repaintTimer, SIGNAL(timeout()), widget, SLOT(repaint())); QObject::connect(input, SIGNAL(gameStart()), this, SLOT(gameStart())); QObject::connect(input, SIGNAL(connectionFailed()), this, SLOT(connectionFailed())); QObject::connect(input, SIGNAL(successConnection()), this, SLOT(connectedSuccess())); QObject::connect(widget, SIGNAL(runCommand(QString)), input, SLOT(runCommand(QString))); QObject::connect(widget, SIGNAL(destroyed()), this, SLOT(legalStop())); ctrlPressed = false; finished = false; widget->a = input; repaintTimer->start(); input->start(); thread = new CalculationThread(widget, input); for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) for (int k = 0; k < 100; k++) progress[i][j][k] = false; }
RICTLMB2B30Widget::RICTLMB2B30Widget(Settings::ConnectionType connType, QWidget *parent) : QWidget(parent), ui(new Ui::RICTLMB2B30Widget), m_waitingForAnswer(false), m_waitingForCheck(false), m_connectionType(connType) { ui->setupUi(this); ui->btWrite->setIcon(QIcon(":/icons/icon-signal")); ui->btNextIdentification->setIcon(QIcon(":/icons/icon-plus")); // Set up the interval time of the timeout. if(m_connectionType == Settings::KSerial){ // 1 sec because serial is faster than network. m_timeout.setInterval(1000); }else { m_timeout.setInterval(1000*5); } // Define the timer to execute only one time. m_timeout.setSingleShot(true); // Define the regular expression for hexadecimal with 16 digits. QRegExp hexaRegExp("[0-9a-fA-F]{16}"); m_hexaValidator = new QRegExpValidator(hexaRegExp,this); // Define the regular expression for decimal with 16 digits. QRegExp decRegExp("[0-9]{16}"); m_deciValidator = new QRegExpValidator(decRegExp,this); // Set the default validator as hexadecimal. ui->leIdentification->setValidator(m_hexaValidator); connect(ui->leIdentification, SIGNAL(textChanged(QString)), this, SLOT(leIdentificationChanged(QString))); connect(ui->btWrite, SIGNAL(clicked()), this, SLOT(btWriteClicked())); connect(&m_timeout, SIGNAL(timeout()), this, SLOT(timeout())); connect(ui->rbDecimal, SIGNAL(clicked()), this, SLOT(rbDecimalClicked())); connect(ui->rbHexadecimal, SIGNAL(clicked()), this, SLOT(rbHexadecimalClicked())); connect(ui->btNextIdentification, SIGNAL(clicked()), this, SLOT(incrementIdentification())); if(connType == Settings::KNetwork){ connect(NetworkCommunication::instance(),SIGNAL(connectionFailed()),this, SLOT(communicationFinished())); connect(NetworkCommunication::instance(), SIGNAL(newReaderAnswer(QString)), this, SLOT(newAnswerFromReader(QString))); }else if(connType == Settings::KSerial){ connect(SerialCommunication::instance(), SIGNAL(newAnswer(QString)), this, SLOT(newAnswerFromReader(QString))); connect(SerialCommunication::instance(),SIGNAL(connectionFailed()),this, SLOT(communicationFinished())); } }
Mail::Mail() : CodeClass() { connect(&mSmtp, SIGNAL(connected()), this, SLOT(connected())); connect(&mSmtp, SIGNAL(connectionFailed(QByteArray)), this, SLOT(connectionFailed(QByteArray))); connect(&mSmtp, SIGNAL(encrypted()), this, SLOT(encrypted())); connect(&mSmtp, SIGNAL(encryptionFailed(QByteArray)), this, SLOT(encryptionFailed(QByteArray))); connect(&mSmtp, SIGNAL(authenticated()), this, SLOT(authenticated())); connect(&mSmtp, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(authenticationFailed(QByteArray))); connect(&mSmtp, SIGNAL(senderRejected(int,QString,QByteArray)), this, SLOT(senderRejected(int,QString,QByteArray))); connect(&mSmtp, SIGNAL(recipientRejected(int,QString,QByteArray)), this, SLOT(recipientRejected(int,QString,QByteArray))); connect(&mSmtp, SIGNAL(mailFailed(int,int,QByteArray)), this, SLOT(mailFailed(int,int,QByteArray))); connect(&mSmtp, SIGNAL(mailSent(int)), this, SLOT(mailSent(int))); connect(&mSmtp, SIGNAL(finished()), this, SLOT(finished())); connect(&mSmtp, SIGNAL(disconnected()), this, SLOT(disconnected())); }
void QmlProfilerClientManager::connectToTcpServer() { // Calling this again when we're already trying means "reset the retry timer". This is // useful in cases where we have to parse the port from the output. We might waste retries // on an initial guess for the port. stopConnectionTimer(); connect(&m_connectionTimer, &QTimer::timeout, this, [this]{ QTC_ASSERT(!isConnected(), return); if (++(m_numRetries) < m_maximumRetries) { if (m_connection.isNull()) { // If the previous connection failed, recreate it. createConnection(); m_connection->connectToHost(m_tcpHost, m_tcpPort.number()); } else if (m_numRetries < 3 && m_connection->socketState() != QAbstractSocket::ConnectedState) { // If we don't get connected in the first retry interval, drop the socket and try // with a new one. On some operating systems (maxOS) the very first connection to a // TCP server takes a very long time to get established and this helps. // On other operating systems (windows) every connection takes forever to get // established. So, after tearing down and rebuilding the socket twice, just // keep trying with the same one. m_connection->connectToHost(m_tcpHost, m_tcpPort.number()); } // Else leave it alone and wait for hello. } else { // On final timeout, clear the connection. stopConnectionTimer(); if (m_connection) disconnectClientSignals(); m_qmlclientplugin.reset(); m_connection.reset(); emit connectionFailed(); } });
void QmlProfilerClientManager::connectToTcpServer() { if (m_connection.isNull()) { QTC_ASSERT(m_qmlclientplugin.isNull(), disconnectClient()); createConnection(); QTC_ASSERT(m_connection, emit connectionFailed(); return); m_connection->connectToHost(m_tcpHost, m_tcpPort.number()); }
void SerialHandler::OnSetPortCfg(QString portName) { if (_port.isOpen()){ emit out(_port.portName() + " is already connected. Disconnecting...\n"); _port.close(); } emit out("Opening port: " + portName + "\n"); bool portExist = false; foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) { if (info.portName().compare(portName, Qt::CaseInsensitive) == 0){ _port.setPort(info); portExist = true; bool opened = _port.open(QIODevice::ReadWrite); QSerialPort::SerialPortError error = _port.error(); if (opened){ bool parity, stopBits, baudRate, dataBits, flowControl; parity = _port.setParity(QSerialPort::NoParity); stopBits = _port.setStopBits(QSerialPort::OneStop); baudRate = _port.setBaudRate(QSerialPort::Baud115200); dataBits = _port.setDataBits(QSerialPort::Data8); flowControl = _port.setFlowControl(QSerialPort::NoFlowControl); //QString xxx = xxx + parity + stopBits + baudRate + dataBits + flowControl; emit out(QString("Serial port connected. (Seting serial params: %1 %2 %3 %4 %5)\n") .arg(parity).arg(stopBits).arg(baudRate).arg(dataBits).arg(flowControl)); //_port.reset(); connect(&_port, SIGNAL(readyRead()), this, SLOT(readData())); connect(&_port, SIGNAL(aboutToClose()), this, SLOT(aboutToClose())); }else{ emit connectionFailed(QString("port.open() failed. Error code: %1\n").arg(error)); _port.disconnect(); } } } if (!portExist){ emit connectionFailed("Port '" + portName + "' absent.\n"); } }
void RDSqlDatabaseStatus::sendDiscon(QString query) { if (!discon){ emit connectionFailed(); fprintf (stderr,"Database connection failed: %s\n",(const char *)query); emit logText(RDConfig::LogErr, QString(tr("Database connection failed : ")) + query); discon = true; } }
ReaderManipulatorWidget::ReaderManipulatorWidget(const Settings::ConnectionType type, QWidget *parent) : QWidget(parent), ui(new Ui::ReaderManipulatorWidget), m_connectionType(type) { ui->setupUi(this); ui->btStartPauseReading->setIcon(QIcon(":/icons/icon-ok")); ui->btClearOutput->setIcon(QIcon(":/icons/icon-clear")); ui->btSendCommand->setIcon(QIcon(":/icons/icon-send")); ui->btLogTo->setIcon(QIcon(":/icons/icon-search")); // Log file. m_logFile = new QFile(this); m_useLogFile = false; // Define the default window state. ui->btLogTo->setEnabled(true); ui->cbLogType->setEnabled(true); ui->btSendCommand->setEnabled(false); ui->leCommand->setEnabled(false); ui->cbLogType->addItem(tr("Append"), QIODevice::Append); ui->cbLogType->addItem(tr("Overwrite"), QIODevice::WriteOnly); ui->cbInputType->addItem("ASCII", SerialCommunication::KASCII); ui->cbInputType->addItem(tr("Number"), SerialCommunication::KNumber); connect(ui->btSendCommand, SIGNAL(clicked()), this, SLOT(btSendCommandClicked())); connect(ui->leCommand, SIGNAL(returnPressed()), this, SLOT(leCommandReturnPressed())); connect(ui->btStartPauseReading, SIGNAL(clicked(bool)), this, SLOT(btStartPauseReadingClicked(bool))); connect(ui->btLogTo, SIGNAL(clicked()), this, SLOT(btLogToClicked())); connect(ui->btClearOutput, SIGNAL(clicked()), this, SLOT(btClearOutputClicked())); if(type == Settings::KNetwork){ connect(NetworkCommunication::instance(),SIGNAL(connectionFailed()),this, SLOT(connectionFinished())); }else{ connect(SerialCommunication::instance(),SIGNAL(connectionFailed()),this, SLOT(connectionFinished())); } // instantiate the RI-CTL-MB2B-30 Manipulator and add it to the main tab. m_mb2b30 = new RICTLMB2B30Widget(m_connectionType, this); ui->tabWidget->addTab(m_mb2b30, "RI-CTL-MB2B-30"); }
TelnetClient::TelnetClient(QObject *parent) : QObject(parent) { _connection_tries=0; _status=0; _hostname = "127.0.0.1"; _port= CONTROL_PORT; _socket = new QTcpSocket; QObject::connect(_socket,SIGNAL(error(QAbstractSocket::SocketError )),this,SLOT(connectionFailed(QAbstractSocket::SocketError))); QObject::connect(_socket,SIGNAL(connected()),this,SLOT(connectionSuccess())); QObject::connect(_socket,SIGNAL(readyRead()),this,SLOT(processData())); }
bool RadioConnectionService::connectToDataSource() { if (serialPort_.open(QIODevice::ReadWrite)) { emit connectionSucceeded(); return true; } else { emit connectionFailed(serialPort_.errorString()); return false; } }
void MailTransport::createSocket(QMailAccount::EncryptType encryptType) { #ifndef QT_NO_OPENSSL if (mSocket) { // Note: socket recycling doesn't seem to work in SSL mode... if (mSocket->mode() == QSslSocket::UnencryptedMode && (encryptType == QMailAccount::Encrypt_NONE || encryptType == QMailAccount::Encrypt_TLS)) { // The socket already exists in the correct mode return; } else { // We need to create a new socket in the correct mode delete mStream; mSocket->deleteLater(); } } mSocket = new QSslSocket(this); encryption = encryptType; connect(mSocket, SIGNAL(encrypted()), this, SLOT(encryptionEstablished())); connect(mSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(connectionFailed(QList<QSslError>))); #else Q_UNUSED(encryptType); mSocket = new QTcpSocket(this); #endif mSocket->setReadBufferSize( 65536 ); // TODO - what? mSocket->setObjectName(mName); connect(mSocket, SIGNAL(connected()), this, SLOT(connectionEstablished())); connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(mSocket, SIGNAL(readyRead()), this, SIGNAL(readyRead())); connect(mSocket, SIGNAL(bytesWritten(qint64)), this, SIGNAL(bytesWritten(qint64))); mStream = new QTextStream(mSocket); }
int RoombaRoowifi::rmb_connect(std::string ip) { if (reconnectCounter_ > 2) { reconnectCounter_ = 0; emit connectionFailed(); return -1; } ip_ = ip; QString qip = QString::fromStdString(ip); qDebug() << "set ip to:" << qip; roowifi_->SetIP(qip); roowifi_->Connect(); roowifi_->SetAutoCaptureTime(500); roowifi_->StartAutoCapture(); //Check after one second if the connection was established QTimer::singleShot(2000, this, SLOT(reconnectCallback_timerTimeout())); }
MainWindow::MainWindow(QWidget* parent): QMainWindow(parent), pop(0), msg(0) { setupUi(this); settings = new QSettings(QSettings::UserScope,"Qxt", "MailTest", this); pop = new QxtPop3(this); pop->sslSocket()->setProtocol(QSsl::TlsV1_0); pop->sslSocket()->setPeerVerifyMode(QSslSocket::QueryPeer); QString username = settings->value("username").toString(); QString hostname = settings->value("hostname").toString(); QString pass = settings->value("password").toString(); int port = settings->value("port").toInt(); bool ok; Encryption enc = Encryption(settings->value("encryption").toInt(&ok)); if (!ok) enc = Clear; switch (enc) { case UseSSL: sslRadioButton->setChecked(true); break; case UseStartTLS: startTLSRadioButton->setChecked(true); break; case Clear: default: clearRadioButton->setChecked(true); break; } usernameLineEdit->setText(username); hostnameLineEdit->setText(hostname); passwordLineEdit->setText(pass); if (port != 0) portLineEdit->setText(QString::number(port)); connect(connectPushButton, SIGNAL(clicked()), this, SLOT(connectToHost())); connect(settingsPushButton, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(pop, SIGNAL(disconnected()), this, SLOT(disconnected())); connect(pop, SIGNAL(connected()), this, SLOT(connected())); connect(pop, SIGNAL(connectionFailed(QByteArray)), this, SLOT(handleSslError(QByteArray))); connect(pop, SIGNAL(encryptionFailed(QByteArray)), this, SLOT(handleSslError(QByteArray))); connect(pop, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(handleAuthError(QByteArray))); connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(newCmd())); help(); }
void ClientSocket::start() { if ( !m_socket || !m_socket->waitForConnected(4000) ) { emit connectionFailed(id()); return; } SOCKET_LOG("Creating socket."); connect( m_socket.get(), &QLocalSocket::stateChanged, this, &ClientSocket::onStateChanged ); connect( m_socket.get(), static_cast<void (QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error), this, &ClientSocket::onError ); connect( m_socket.get(), &QLocalSocket::readyRead, this, &ClientSocket::onReadyRead ); onStateChanged(m_socket->state()); onReadyRead(); }
void GaduSession::login( struct gg_login_params* p ) { if ( !isConnected() ) { // turn on in case you have any problems, and you want // to report it better. libgadu needs to be recompiled with debug enabled // gg_debug_level=GG_DEBUG_MISC|GG_DEBUG_FUNCTION; kdDebug(14100) << "Login" << endl; if ( !( session_ = gg_login( p ) ) ) { destroySession(); kdDebug( 14100 ) << "libgadu internal error " << endl; emit connectionFailed( GG_FAILURE_CONNECTING ); return; } createNotifiers( true ); enableNotifiers( session_->check ); searchSeqNr_=0; } }
void Network2::mapDownloaded(QNetworkReply* reply) { if (reply->request().url() != map_url_) { qDebug() << "End map upload"; return; } if (reply->error() != QNetworkReply::NoError) { emit connectionFailed("Unable download map: " + reply->errorString()); reply->deleteLater(); return; } map_data_ = reply->readAll(); reply->deleteLater(); qDebug() << "Map length: " << map_data_.length(); is_good_ = true; emit connectionSuccess(your_id_, "map_buffer"); }
void Network2::onConnectionEnd(QString reason) { is_good_ = false; emit connectionFailed(reason); }
void GaduSession::checkDescriptor() { disableNotifiers(); struct gg_event* event; // struct gg_dcc* dccSock; KGaduMessage gaduMessage; KGaduNotify gaduNotify; if ( !( event = gg_watch_fd( session_ ) ) ) { kdDebug(14100)<<"Connection was broken for some reason"<<endl; destroyNotifiers(); logoff( Kopete::Account::ConnectionReset ); return; } // FD changed, recreate socket notifiers if ( session_->state == GG_STATE_CONNECTING_HUB || session_->state == GG_STATE_CONNECTING_GG ) { kdDebug(14100)<<"recreating notifiers"<<endl; destroyNotifiers(); createNotifiers( true ); } switch( event->type ) { case GG_EVENT_MSG: kdDebug(14100) << "incoming message:class:" << event->event.msg.msgclass << endl; if ( event->event.msg.msgclass & GG_CLASS_CTCP ) { kdDebug( 14100 ) << "incomming ctcp " << endl; // TODO: DCC CONNECTION emit incomingCtcp( event->event.msg.sender ); } if ( (event->event.msg.msgclass & GG_CLASS_MSG) || (event->event.msg.msgclass & GG_CLASS_CHAT) ) { gaduMessage.message = textcodec->toUnicode((const char*)event->event.msg.message); gaduMessage.sender_id = event->event.msg.sender; gaduMessage.sendTime.setTime_t( event->event.msg.time, Qt::LocalTime ); gaduMessage.message = rtf->convertToHtml( gaduMessage.message, event->event.msg.formats_length, event->event.msg.formats ); emit messageReceived( &gaduMessage ); } break; case GG_EVENT_ACK: emit ackReceived( event->event.ack.recipient ); break; case GG_EVENT_STATUS: gaduNotify.status = event->event.status.status; gaduNotify.contact_id = event->event.status.uin; if ( event->event.status.descr ) { gaduNotify.description = textcodec->toUnicode( event->event.status.descr ); } else { gaduNotify.description = QString::null; } gaduNotify.remote_port = 0; gaduNotify.version = 0; gaduNotify.image_size = 0; gaduNotify.time = 0; gaduNotify.fileCap = false; emit contactStatusChanged( &gaduNotify ); break; case GG_EVENT_STATUS60: gaduNotify.status = event->event.status60.status; gaduNotify.contact_id = event->event.status60.uin; if ( event->event.status60.descr ) { gaduNotify.description = textcodec->toUnicode( event->event.status60.descr ); } else { gaduNotify.description = QString::null; } gaduNotify.remote_ip.setAddress( ntohl( event->event.status60.remote_ip ) ); gaduNotify.remote_port = event->event.status60.remote_port; gaduNotify.version = event->event.status60.version; gaduNotify.image_size = event->event.status60.image_size; gaduNotify.time = event->event.status60.time; if ( event->event.status60.remote_ip && gaduNotify.remote_port > 10 ) { gaduNotify.fileCap = true; } else { gaduNotify.fileCap = false; } emit contactStatusChanged( &gaduNotify ); break; case GG_EVENT_NOTIFY60: notify60( event ); break; case GG_EVENT_CONN_SUCCESS: kdDebug(14100) << "success server: " << session_->server_addr << endl; emit connectionSucceed(); break; case GG_EVENT_CONN_FAILED: kdDebug(14100) << "failed server: " << session_->server_addr << endl; destroySession(); kdDebug(14100) << "emit connection failed(" << event->event.failure << ") signal" << endl; emit connectionFailed( (gg_failure_t)event->event.failure ); break; case GG_EVENT_DISCONNECT: kdDebug(14100)<<"event Disconnected"<<endl; // it should be called either when we requested disconnect, or when other client connects with our UID logoff( Kopete::Account::Manual ); break; case GG_EVENT_PONG: emit pong(); break; case GG_EVENT_NONE: break; case GG_EVENT_PUBDIR50_SEARCH_REPLY: case GG_EVENT_PUBDIR50_WRITE: case GG_EVENT_PUBDIR50_READ: sendResult( event->event.pubdir50 ); break; case GG_EVENT_USERLIST: handleUserlist( event ); break; default: kdDebug(14100)<<"Unprocessed GaduGadu Event = "<<event->type<<endl; break; } if ( event ) { gg_free_event( event ); } if ( session_ ) { enableNotifiers( session_->check ); } }
void RadioConnectionService::disconnectFromDataSource() { serialPort_.close(); emit connectionFailed("DISCONNECTED"); }
void HMI_Client::onSocketError(QAbstractSocket::SocketError error) { emit connectionFailed(error); }
this, SLOT( slotFriendsMode() ), this, "actionFriendsMode" ); static_cast<KToggleAction*>(p->friendsModeAction)->setChecked( p->forFriends ); } void GaduAccount::initConnections() { QObject::connect( p->session_, SIGNAL( error( const QString&, const QString& ) ), SLOT( error( const QString&, const QString& ) ) ); QObject::connect( p->session_, SIGNAL( messageReceived( KGaduMessage* ) ), SLOT( messageReceived( KGaduMessage* ) ) ); QObject::connect( p->session_, SIGNAL( contactStatusChanged( KGaduNotify* ) ), SLOT( contactStatusChanged( KGaduNotify* ) ) ); QObject::connect( p->session_, SIGNAL( connectionFailed( gg_failure_t )), SLOT( connectionFailed( gg_failure_t ) ) ); QObject::connect( p->session_, SIGNAL( connectionSucceed( ) ), SLOT( connectionSucceed( ) ) ); QObject::connect( p->session_, SIGNAL( disconnect( Kopete::Account::DisconnectReason ) ), SLOT( slotSessionDisconnect( Kopete::Account::DisconnectReason ) ) ); QObject::connect( p->session_, SIGNAL( ackReceived( unsigned int ) ), SLOT( ackReceived( unsigned int ) ) ); QObject::connect( p->session_, SIGNAL( pubDirSearchResult( const SearchResult&, unsigned int ) ), SLOT( slotSearchResult( const SearchResult&, unsigned int ) ) ); QObject::connect( p->session_, SIGNAL( userListExported() ), SLOT( userListExportDone() ) ); QObject::connect( p->session_, SIGNAL( userListRecieved( const QString& ) ), SLOT( userlist( const QString& ) ) ); QObject::connect( p->session_, SIGNAL( incomingCtcp( unsigned int ) ), SLOT( slotIncomingDcc( unsigned int ) ) );
void WebSocketConnector::disconnected() { emit connectionFailed(); }
void QstProtocol::onConnectionFailed( const QString &reason ) { emit connectionFailed( this, reason ); }