void GaduProtocol::login() { // TODO: create some kind of cleanup method if (GaduSession) { gg_free_session(GaduSession); GaduSession = 0; // here was return... do not re-add it ;) } if (SocketNotifiers) { SocketNotifiers->deleteLater(); SocketNotifiers = 0; } auto accountData = GaduAccountData{account()}; if (0 == accountData.uin()) { connectionClosed(); return; } GaduProxyHelper::setupProxy( account().useDefaultProxy() ? m_networkProxyManager->defaultProxy() : account().proxy()); setupLoginParams(); m_lastSentStatus = loginStatus(); GaduSession = gg_login(&GaduLoginParams); cleanUpLoginParams(); if (!GaduSession) { // gadu session can be null if DNS failed, we can try IP after that connectionError(); return; } SocketNotifiers = new GaduProtocolSocketNotifiers(account(), this); SocketNotifiers->setGaduIMTokenService(CurrentImTokenService); SocketNotifiers->setGaduUserDataService(CurrentUserDataService); connectSocketNotifiersToServices(); SocketNotifiers->watchFor(GaduSession); }
ClientServer::ClientServer(QObject *parent_) : Avogadro::QtGui::ExtensionPlugin(parent_), m_openAction(new QAction(this)), m_settingsAction(new QAction(this)), m_molecule(NULL), m_controller(NULL), m_communicator(NULL), m_channel(NULL) { m_openAction->setEnabled(true); m_openAction->setText("Open Molecule"); m_actions.append(m_openAction); m_settingsAction->setEnabled(true); m_settingsAction->setText("Settings"); m_actions.append(m_settingsAction); connect(m_openAction, SIGNAL(triggered()), SLOT(openFile())); connect(m_settingsAction, SIGNAL(triggered()), SLOT(openSettings())); connect(this, SIGNAL(connectionError()), SLOT(onConnectionError())); }
CoreConnectionStatusWidget::CoreConnectionStatusWidget(CoreConnection *connection, QWidget *parent) : QWidget(parent), _coreConnection(connection) { ui.setupUi(this); ui.lagLabel->hide(); ui.sslLabel->hide(); update(); connect(coreConnection(), SIGNAL(progressTextChanged(QString)), ui.messageLabel, SLOT(setText(QString))); connect(coreConnection(), SIGNAL(progressValueChanged(int)), ui.progressBar, SLOT(setValue(int))); connect(coreConnection(), SIGNAL(progressRangeChanged(int, int)), ui.progressBar, SLOT(setRange(int, int))); connect(coreConnection(), SIGNAL(progressRangeChanged(int, int)), this, SLOT(progressRangeChanged(int, int))); connect(coreConnection(), SIGNAL(stateChanged(CoreConnection::ConnectionState)), SLOT(connectionStateChanged(CoreConnection::ConnectionState))); connect(coreConnection(), SIGNAL(connectionError(QString)), ui.messageLabel, SLOT(setText(QString))); connect(coreConnection(), SIGNAL(lagUpdated(int)), SLOT(updateLag(int))); }
bool Client::connectToServer(QHostAddress &addr, quint16 port) { QString addrString = addr.toString(); connection = QSharedPointer<TextShredderConnection>(new TextShredderConnection(this, addrString, port, false)); connect(connection.data(), SIGNAL(clientDisconnected()), this, SLOT(connectionDidEncounterEnd())); connect(connection.data(), SIGNAL(socketConnectedSuccessfully()), this, SLOT(connectionSuccessful())); connect(connection.data(), SIGNAL(socketErrorReceived(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); connect(connection.data(), SIGNAL(incomingSyncableFilesPacket(QByteArray&)), FileManager::Instance(), SLOT(handleReceivedSyncableFiles(QByteArray &))); connect(connection.data(), SIGNAL(incomingOnlineUsersPacket(TextShredderPacket&)), this, SLOT(connectionReceivedOnlineUsersPacket(TextShredderPacket &))); connection.data()->startConnection(); return true; }
void Login::loginButtonPressed() { QString ip = ui->lineEdit->text(); int port = ui->lineEdit_2->text().toInt(); QString name = ui->lineEdit_3->text(); socket = new QTcpSocket(this); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); socket->connectToHost(ip, port); if(!socket->waitForConnected(3000)) { } else { int csize = 0; Message m(1, 0, 0, 0, ui->lineEdit_3->text().toUtf8()); m.send(socket); socket->waitForReadyRead(-1); QByteArray chunk = socket->read(4); memcpy(&csize, chunk, 4); QByteArray buffer = socket->read(csize); Message message; message.createMessage(buffer, csize); int userID = message.getDest(); if(strcmp(message.getBuffer(), "OK") == 0) { main = new MainWindow(ip, port, name, socket, userID); connect(main, SIGNAL(exit()), this, SLOT(exitClient())); this->hide(); disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); main->show(); } else { QMessageBox::StandardButton resBtn = QMessageBox::question( this, "ChatClient", "This username is already used by another user!", QMessageBox::Retry | QMessageBox::Close); if (resBtn == QMessageBox::Cancel) { socket->close(); this->close(); } else { socket->close(); delete socket; } } } //this->show(); }
void CommTcpClient::open() { if (isConnected()) close(); _socket = new QTcpSocket(); _reader = new MessageReader(_socket); // forward signal connect(_reader, SIGNAL(received(int, const QByteArray)), this, SIGNAL(received(int, const QByteArray))); connect(_socket, &QTcpSocket::disconnected, this, &CommTcpClient::socketDisconnected); connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); // error(...) overload, any c++11 way to select specific function _socket->connectToHost(QHostAddress::LocalHost, _port); }
/** * @details * Accpet client connections for data */ void TCPConnectionManager::acceptClientConnection() { // Get new client connection QTcpSocket *client = _tcpServer->nextPendingConnection(); if ( _processIncomming(client) ) { // Connect socket error() signals connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(client, SIGNAL(readyRead()), this, SLOT(_incomingFromClient()), Qt::DirectConnection); } else { client->close(); delete client; } }
GlobalScoresWindow::GlobalScoresWindow(QWidget *parent) : QDialog(parent){ // Creates the 3 buttons that will be used in the dialog window searchButton = new QPushButton(tr("Search")); stopButton = new QPushButton(tr("Stop")); quitButton = new QPushButton(tr("Quit")); stopButton->setEnabled(false); connect(searchButton, SIGNAL(clicked()), this, SLOT(establishConnection())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); // Sets up a table widget for the global scoreboard table = new QTableWidget(this); table->setColumnCount(3); tableHeader << "Rank" << "Name" << "Score"; table->setHorizontalHeaderLabels(tableHeader); table->verticalHeader()->setVisible(false); table->setFixedHeight(342); // Creates the layout for the Global Scores window QVBoxLayout *buttonLayout = new QVBoxLayout; buttonLayout->addSpacing(6); buttonLayout->addWidget(searchButton); buttonLayout->addWidget(stopButton); buttonLayout->addWidget(quitButton); buttonLayout->addSpacing(250); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addSpacing(20); mainLayout->addWidget(table, 0, Qt::AlignVCenter); mainLayout->addSpacing(6); mainLayout->addLayout(buttonLayout); mainLayout->addSpacing(20); setLayout(mainLayout); connect(&tcpSocket, SIGNAL(connected()), this, SLOT(sendRequest())); connect(&tcpSocket, SIGNAL(readyRead()), this, SLOT(updateScoreTable())); connect(&tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(connectionError())); // Sets the title and size of the window setWindowTitle("Global High Scores"); setFixedSize(450, 400); }
LldbEngineHost::LldbEngineHost(const DebuggerStartParameters &startParameters) :IPCEngineHost(startParameters), m_ssh(0) { showMessage(QLatin1String("setting up coms")); setObjectName(QLatin1String("LLDBEngine")); if (startParameters.startMode == StartRemoteEngine) { m_guestProcess = 0; QSsh::SshRemoteProcessRunner * const runner = new QSsh::SshRemoteProcessRunner; connect (runner, SIGNAL(connectionError(QSsh::SshError)), this, SLOT(sshConnectionError(QSsh::SshError))); runner->run(startParameters.serverStartScript.toUtf8(), startParameters.connParams); setGuestDevice(new SshIODevice(runner)); } else { m_guestProcess = new QProcess(this); connect(m_guestProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int,QProcess::ExitStatus))); connect(m_guestProcess, SIGNAL(readyReadStandardError()), this, SLOT(stderrReady())); QString a = Core::ICore::resourcePath() + QLatin1String("/qtcreator-lldb"); if (getenv("QTC_LLDB_GUEST") != 0) a = QString::fromLocal8Bit(getenv("QTC_LLDB_GUEST")); showStatusMessage(QString(QLatin1String("starting %1")).arg(a)); m_guestProcess->start(a, QStringList(), QIODevice::ReadWrite | QIODevice::Unbuffered); m_guestProcess->setReadChannel(QProcess::StandardOutput); if (!m_guestProcess->waitForStarted()) { showStatusMessage(tr("qtcreator-lldb failed to start: %1").arg(m_guestProcess->errorString())); notifyEngineSpontaneousShutdown(); return; } setGuestDevice(m_guestProcess); } }
int Client::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: newMessage((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break; case 1: newParticipant((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 2: participantLeft((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 3: newConnection((*reinterpret_cast< Connection*(*)>(_a[1]))); break; case 4: connectionError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break; case 5: disconnected(); break; case 6: readyForUse(); break; default: ; } _id -= 7; } return _id; }
void RemoteProcess::readyRead() { Q_ASSERT(m_server != NULL); Q_ASSERT(m_socket != NULL); Q_ASSERT(isConnected()); m_socket->blockSignals(true); while ( m_socket->bytesAvailable() > 0 ) { QByteArray msg; if( !::readMessage(m_socket, &msg) ) { log( "Incorrect message from remote process.", LogError ); emit connectionError(); return; } emit newMessage(msg); } m_socket->blockSignals(false); }
/** * @brief Constructor * * Sets the activitionstate to true * * @author Peter Grasch */ SimonControl::SimonControl(QWidget *parent) : QObject (parent) { setStatus(SimonControl::Disconnected); QObject::connect(RecognitionControl::getInstance(), SIGNAL(connected()), this, SLOT(connectedToServer())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(disconnected()), this, SLOT(disconnectedFromServer())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(connectionError(QString)), this, SLOT(slotConnectionError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(simondSystemError(QString)), this, SLOT(slotSimondSystemError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(synchronisationError(QString)), this, SLOT(slotSynchronisationError(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionError(QString,QString)), this, SLOT(slotRecognitionError(QString,QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(compilationError(QString,QString)), this, SLOT(slotCompilationError(QString,QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(simondSystemWarning(QString)), this, SLOT(slotSimondSystemWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(synchronisationWarning(QString)), this, SLOT(slotSynchronisationWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionWarning(QString)), this, SLOT(slotRecognitionWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(compilationWarning(QString)), this, SLOT(slotCompilationWarning(QString))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(loggedIn()), this, SLOT(loggedIn())); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognised(RecognitionResultList)), this, SLOT(wordRecognised(RecognitionResultList))); QObject::connect(RecognitionControl::getInstance(), SIGNAL(recognitionStatusChanged(RecognitionControl::RecognitionStatus)), this, SLOT(recognitionStatusChanged(RecognitionControl::RecognitionStatus))); QObject::connect(ScenarioManager::getInstance(), SIGNAL(deactivatedScenarioListChanged()), this, SIGNAL(deactivatedScenarioListChanged())); QObject::connect(this, SIGNAL(deactivatedScenarioListChanged()), RecognitionControl::getInstance(), SLOT(sendDeactivatedScenarioList())); QObject::connect(ContextManager::instance(), SIGNAL(sampleGroupChanged(QStringList)), RecognitionControl::getInstance(), SLOT(sendDeactivatedSampleGroups(QStringList))); ContextManager::instance()->getSampleGroupCondition()->loadSampleGroupContext(); ActionManager::getInstance(); // initializing action manager SimonTTS::getInstance(); // initializing TTS system for dbus interface if (!ScenarioManager::getInstance()->init()) { KMessageBox::error(0, i18n("Could not initialize scenarios and shadow dictionary.")); if (!ScenarioManager::getInstance()->getCurrentScenario()) { kDebug() << "Aborting due to fatal error while loading scenarios"; exit(-1); // this is fatal } } connect(SoundServer::getInstance(), SIGNAL(error(QString)), this, SLOT(slotSoundError(QString))); }
void WebClient::postLogon(const ParamsT& params) { QNetworkRequest request; request.setUrl(url_.toString() + params["service"] ); request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QByteArray content = createContentBase64(params); qDebug() << "POST Sending: " << content; reply_.reset( netmgr_.post(request, content) ); connect(reply_.data(), SIGNAL(finished()), this, SLOT(finished())); connect(reply_.data(), SIGNAL(readyRead()), this, SLOT(readyRead())); connect(reply_.data(), SIGNAL(error(NetworkError)), this, SLOT(connectionError(NetworkError))); QMutexLocker guard(&threadSafe_); handler_->onStateChanged(state_ = InProgress); }
QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : QCoreApplication(argc, argv), m_runMode(LaunchMode), m_process(0), m_tracePrefix(QLatin1String("trace")), m_hostName(QLatin1String("127.0.0.1")), m_port(3768), m_verbose(false), m_quitAfterSave(false), m_qmlProfilerClient(&m_connection), m_v8profilerClient(&m_connection), m_connectionAttempts(0), m_qmlDataReady(false), m_v8DataReady(false) { m_connectTimer.setInterval(1000); connect(&m_connectTimer, SIGNAL(timeout()), this, SLOT(tryToConnect())); connect(&m_connection, SIGNAL(connected()), this, SLOT(connected())); connect(&m_connection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged(QAbstractSocket::SocketState))); connect(&m_connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); connect(&m_qmlProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled())); connect(&m_qmlProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged())); connect(&m_qmlProfilerClient, SIGNAL(range(QQmlProfilerService::RangeType,QQmlProfilerService::BindingType,qint64,qint64,QStringList,QmlEventLocation)), &m_profilerData, SLOT(addQmlEvent(QQmlProfilerService::RangeType,QQmlProfilerService::BindingType,qint64,qint64,QStringList,QmlEventLocation))); connect(&m_qmlProfilerClient, SIGNAL(traceFinished(qint64)), &m_profilerData, SLOT(setTraceEndTime(qint64))); connect(&m_qmlProfilerClient, SIGNAL(traceStarted(qint64)), &m_profilerData, SLOT(setTraceStartTime(qint64))); connect(&m_qmlProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profilerData, SLOT(addFrameEvent(qint64,int,int))); connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete())); connect(&m_v8profilerClient, SIGNAL(enabledChanged()), this, SLOT(profilerClientEnabled())); connect(&m_v8profilerClient, SIGNAL(range(int,QString,QString,int,double,double)), &m_profilerData, SLOT(addV8Event(int,QString,QString,int,double,double))); connect(&m_v8profilerClient, SIGNAL(complete()), this, SLOT(v8Complete())); connect(&m_profilerData, SIGNAL(error(QString)), this, SLOT(logError(QString))); connect(&m_profilerData, SIGNAL(dataReady()), this, SLOT(traceFinished())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); t = new QtTelnet; connect(t, SIGNAL(message(const QString &)), this, SLOT(telnetMessage(const QString &))); connect(t, SIGNAL(loginRequired()), this, SLOT(telnetLoginRequired())); connect(t, SIGNAL(loginFailed()), this, SLOT(telnetLoginFailed())); connect(t, SIGNAL(loggedOut()), this, SLOT(telnetLoggedOut())); connect(t, SIGNAL(loggedIn()), this, SLOT(telnetLoggedIn())); connect(t, SIGNAL(connectionError(QAbstractSocket::SocketError)), this, SLOT(telnetConnectionError(QAbstractSocket::SocketError))); }
/** * @details * Accept client connections for data */ void TCPConnectionManager::acceptClientConnection() { // Get new client connection QTcpSocket *client = _tcpServer->nextPendingConnection(); if (_processIncomming(client)) { // Connect socket error() signals connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(client, SIGNAL(readyRead()), this, SLOT(_incomingFromClient()), Qt::DirectConnection); } else { // Closes the I/O device for the socket, // disconnects the socket's connection with the host, // closes the socket, and resets the name, address, // port number and underlying socket descriptor. client->close(); delete client; } }
void QConnmanEngine::disconnectFromId(const QString &id) { QMutexLocker locker(&mutex); QString servicePath = serviceFromId(id); QConnmanServiceInterface serv(servicePath); if(!serv.isValid()) { emit connectionError(id, DisconnectionError); } else { if(serv.getType() != QLatin1String("cellular")) { serv.disconnect(); } else { QOfonoManagerInterface ofonoManager(0); QString modemPath = ofonoManager.currentModem().path(); QOfonoDataConnectionManagerInterface dc(modemPath,0); foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { if(dcPath.path().contains(servicePath.section(QLatin1Char('_'),-1))) { QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); primaryContext.setActive(false); } } } } }
int TCPReceiver::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: stringRead((*reinterpret_cast< QByteArray(*)>(_a[1]))); break; case 1: connectionError((*reinterpret_cast< QString(*)>(_a[1]))); break; case 2: connectionReady(); break; case 3: connectionNotReady(); break; case 4: newConnection(); break; case 5: endConnection(); break; case 6: clientWriteString((*reinterpret_cast< QByteArray(*)>(_a[1]))); break; case 7: { QByteArray _r = clientReadString(); if (_a[0]) *reinterpret_cast< QByteArray*>(_a[0]) = _r; } break; case 8: stop(); break; default: ; } _id -= 9; } return _id; }
//Verbindungsaufbau zu host unter Adresse: address und mit dem Port: port void Client::connectSocket(QString address, int port) { tcpSocket->abort(); try { tcpSocket->connectToHost(address,port); } catch(...) { } tcpSocket->waitForConnected(500); if(tcpSocket->state() == QTcpSocket::ConnectedState) { connected = true; emit socketConnected(); } else { emit connectionError("Es konnte keine Verbindung zum Server aufgebaut werden."); } }
void QConnmanEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); QString servicePath = serviceFromId(id); QConnmanServiceInterface serv(servicePath); if(!serv.isValid()) { emit connectionError(id, QBearerEngineImpl::InterfaceLookupError); } else { if(serv.getType() != "cellular") { serv.connect(); } else { QOfonoManagerInterface ofonoManager(0); QString modemPath = ofonoManager.currentModem().path(); QOfonoDataConnectionManagerInterface dc(modemPath,0); foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { if(dcPath.path().contains(servicePath.section("_",-1))) { QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); primaryContext.setActive(true); } } } } }
void RestWidget::parseOrderUrls(QNetworkReply *reply){ if(reply->error()>0){ xmloutput->addItem(QTime::currentTime().toString() +" : " + reply->errorString()); emit connectionError(); } else{ QByteArray data = reply->readAll(); QDomDocument doc; dataOutput->setText(data); doc.setContent(data); QDomNodeList orderNodes = doc.elementsByTagName("order"); for(int i = 0; i < orderNodes.size(); i++){ xmloutput->addItem(orderNodes.at(i).toElement().text()); orderIDs->append(orderNodes.at(i).toElement().text()); } order_ptr = 0; //reset the order pointer. } QObject::disconnect(netManager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(parseOrderUrls(QNetworkReply*))); }
void QGenericEngine::disconnectFromId(const QString &id) { emit connectionError(id, OperationNotSupported); }
void SmtpClient::newConnection() { qMailLog(SMTP) << "newConnection" << flush; #ifdef USE_ACCOUNTS_QT loginFailed = false; #endif if (sending) { operationFailed(QMailServiceAction::Status::ErrConnectionInUse, tr("Cannot send message; transport in use")); return; } if (!config.id().isValid()) { status = Done; operationFailed(QMailServiceAction::Status::ErrConfiguration, tr("Cannot send message without account configuration")); return; } // Load the current configuration for this account // Reload the account configuration whenever a new SMTP // connection is created, in order to ensure the changes // in the account settings are being managed properly. config = QMailAccountConfiguration(config.id()); SmtpConfiguration smtpCfg(config); if ( smtpCfg.smtpServer().isEmpty() ) { status = Done; operationFailed(QMailServiceAction::Status::ErrConfiguration, tr("Cannot send message without SMTP server configuration")); return; } // Calculate the total indicative size of the messages we're sending totalSendSize = 0; foreach (uint size, sendSize.values()) totalSendSize += size; progressSendSize = 0; emit progressChanged(progressSendSize, totalSendSize); status = Init; sending = true; domainName = QByteArray(); outstandingResponses = 0; if (!transport) { // Set up the transport transport = new QMailTransport("SMTP"); connect(transport, SIGNAL(readyRead()), this, SLOT(readyRead())); connect(transport, SIGNAL(connected(QMailTransport::EncryptType)), this, SLOT(connected(QMailTransport::EncryptType))); connect(transport, SIGNAL(bytesWritten(qint64)), this, SLOT(sent(qint64))); connect(transport, SIGNAL(updateStatus(QString)), this, SIGNAL(updateStatus(QString))); connect(transport, SIGNAL(errorOccurred(int,QString)), this, SLOT(transportError(int,QString))); #ifndef QT_NO_OPENSSL connect(transport, SIGNAL(sslErrorOccured(QMailServiceAction::Status::ErrorCode,QString)), this, SIGNAL(connectionError(QMailServiceAction::Status::ErrorCode,QString))); #endif }
void TrackerClient::httpRequestDone(bool error) { if (lastTrackerRequest) { emit stopped(); return; } if (error) { emit connectionError(http.error()); return; } QByteArray response = http.readAll(); http.abort(); BencodeParser parser; if (!parser.parse(response)) { qWarning("Error parsing bencode response from tracker: %s", qPrintable(parser.errorString())); http.abort(); return; } QMap<QByteArray, QVariant> dict = parser.dictionary(); if (dict.contains("failure reason")) { // no other items are present emit failure(QString::fromUtf8(dict.value("failure reason").toByteArray())); return; } if (dict.contains("warning message")) { // continue processing emit warning(QString::fromUtf8(dict.value("warning message").toByteArray())); } if (dict.contains("tracker id")) { // store it trackerId = dict.value("tracker id").toByteArray(); } if (dict.contains("interval")) { // Mandatory item if (requestIntervalTimer != -1) killTimer(requestIntervalTimer); requestIntervalTimer = startTimer(dict.value("interval").toInt() * 1000); } if (dict.contains("peers")) { // store it peers.clear(); QVariant peerEntry = dict.value("peers"); if (peerEntry.type() == QVariant::List) { QList<QVariant> peerTmp = peerEntry.toList(); for (int i = 0; i < peerTmp.size(); ++i) { TorrentPeer tmp; QMap<QByteArray, QVariant> peer = qVariantValue<QMap<QByteArray, QVariant> >(peerTmp.at(i)); tmp.id = QString::fromUtf8(peer.value("peer id").toByteArray()); tmp.address.setAddress(QString::fromUtf8(peer.value("ip").toByteArray())); tmp.port = peer.value("port").toInt(); peers << tmp; } } else { QByteArray peerTmp = peerEntry.toByteArray(); for (int i = 0; i < peerTmp.size(); i += 6) { TorrentPeer tmp; uchar *data = (uchar *)peerTmp.constData() + i; tmp.port = (int(data[4]) << 8) + data[5]; uint ipAddress = 0; ipAddress += uint(data[0]) << 24; ipAddress += uint(data[1]) << 16; ipAddress += uint(data[2]) << 8; ipAddress += uint(data[3]); tmp.address.setAddress(ipAddress); peers << tmp; } } emit peerListUpdated(peers); } }
SysCacheClient::SysCacheClient(QObject *parent) : QObject(parent){ curSock = new QLocalSocket(this); connect(curSock, SIGNAL(connected()), this, SLOT(startRequest())); connect(curSock, SIGNAL(disconnected()), this, SLOT(requestFinished()) ); connect(curSock, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(connectionError())); }
std::string Connection::fetch() { int s; unsigned char byte[1], maskingKey[4]; s = recv(socket, (void*) byte, 1, 0); if(s == 0) return ""; if(s != 1) { //connectionError(); if(s != -1 ) { std::cout << "error " << s << "\n"; status = DISCONNECTED; for(unsigned int i = 0; i < connectionListeners.size(); i++) { connectionListeners[i]->onClose("recv error" ); } } else { if(errno != EAGAIN) perror("error recv failed"); } return ""; } int byteVal = (int)byte[0]; bool fin = ((byteVal & (1 << 7)) == 0x80); unsigned char opcode = byteVal & 0x0F; s = recv(socket, (void*) byte, 1, 0); if(s != 1) { connectionError(); return ""; } byteVal = (int)byte[0]; bool masked = ((byteVal & (1 << 7)) == 0x80); if(!(opcode == 1 || opcode == 0)) return ""; if(!masked) { std::cout << "warning: unmasked frame ignored\n"; return ""; } /*std::cout << "fin: " << fin << "\n"; std::cout << "opcode " << (int)opcode << "\n"; std::cout << "masked: " << masked << "\n";*/ unsigned long len = 0; if(opcode == 1) { len = byteVal & 0x7F; if(len == 126) { unsigned char tb[2]; s = recv(socket, (void*) tb, 2, 0); len = (unsigned long)(tb[0] * 256 + tb[1]); } else { if(len == 127) { unsigned char eb[8]; uint64_t eightbyte = 0; s = recv(socket, (void*) eb, 8, 0); for(int i = 0; i < 8; i++) { eightbyte = (eightbyte * 256) + eb[i]; } len = (unsigned long) eightbyte; } } lastLen = len; //std::cout << "len: " << len << "\n"; } else { len = lastLen; } unsigned char maskedData[512]; unsigned char unMaskedData[len + 1]; s = recv(socket, (void*) maskingKey, 4, 0); unsigned long received = 0; bool moreData = true; while(moreData) { s = recv(socket, (void*) maskedData, 512, 0); if(s > 0) { for(int i = 0; i < s; i++) { unMaskedData[received + i] = (unsigned char)((int)maskedData[i] ^ (int)maskingKey[(received + i) % 4]); } received += s; } else { moreData = false; } } unMaskedData[len] = '\0'; return std::string((char*)unMaskedData); }
void QNativeWifiEngine::connectToId(const QString &id) { QMutexLocker locker(&mutex); if (!available()) { locker.unlock(); emit connectionError(id, InterfaceLookupError); return; } WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit connectionError(id, InterfaceLookupError); return; } QString profile; for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; WLAN_AVAILABLE_NETWORK_LIST *networkList; result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, 3, 0, &networkList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n", __FUNCTION__, result); #endif continue; } for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; profile = QString::fromWCharArray(network.strProfileName); if (qHash(QLatin1String("WLAN:") + profile) == id.toUInt()) break; else profile.clear(); } local_WlanFreeMemory(networkList); if (!profile.isEmpty()) { WLAN_CONNECTION_PARAMETERS parameters; parameters.wlanConnectionMode = wlan_connection_mode_profile; parameters.strProfile = reinterpret_cast<LPCWSTR>(profile.utf16()); parameters.pDot11Ssid = 0; parameters.pDesiredBssidList = 0; parameters.dot11BssType = dot11_BSS_type_any; parameters.dwFlags = 0; DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, ¶meters, 0); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit connectionError(id, ConnectError); locker.relock(); break; } break; } } local_WlanFreeMemory(interfaceList); if (profile.isEmpty()) { locker.unlock(); emit connectionError(id, InterfaceLookupError); } }
void QAndroidBearerEngine::disconnectFromId(const QString &id) { Q_EMIT connectionError(id, OperationNotSupported); }
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { // draws: // AccountName // Checkbox | Icon | | ConnectionIcon | ConnectionState // errorMessage if (!index.isValid()) { return; } Q_ASSERT(widgets.size() == 6); // Get the widgets QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0)); ChangeIconButton* changeIconButton = qobject_cast<ChangeIconButton*>(widgets.at(1)); QLabel *statusTextLabel = qobject_cast<QLabel*>(widgets.at(2)); QLabel *statusIconLabel = qobject_cast<QLabel*>(widgets.at(3)); EditDisplayNameButton *displayNameButton = qobject_cast<EditDisplayNameButton*>(widgets.at(4)); QLabel *connectionErrorLabel = qobject_cast<QLabel*>(widgets.at(5)); Q_ASSERT(checkbox); Q_ASSERT(changeIconButton); Q_ASSERT(statusTextLabel); Q_ASSERT(statusIconLabel); Q_ASSERT(displayNameButton); Q_ASSERT(connectionErrorLabel); bool isSelected(itemView()->selectionModel()->isSelected(index) && itemView()->hasFocus()); bool isEnabled(index.data(KTp::AccountsListModel::EnabledRole).toBool()); KIcon accountIcon(index.data(Qt::DecorationRole).value<QIcon>()); KIcon statusIcon(index.data(KTp::AccountsListModel::ConnectionStateIconRole).value<QIcon>()); QString statusText(index.data(KTp::AccountsListModel::ConnectionStateDisplayRole).toString()); QString displayName(index.data(Qt::DisplayRole).toString()); QString connectionError(index.data(KTp::AccountsListModel::ConnectionErrorMessageDisplayRole).toString()); Tp::AccountPtr account(index.data(KTp::AccountsListModel::AccountRole).value<Tp::AccountPtr>()); if (!account->isEnabled()) { connectionError = i18n("Click checkbox to enable"); } QRect outerRect(0, 0, option.rect.width(), option.rect.height()); QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding // checkbox if (isEnabled) { checkbox->setChecked(true);; checkbox->setToolTip(i18n("Disable account")); } else { checkbox->setChecked(false); checkbox->setToolTip(i18n("Enable account")); } int checkboxLeftMargin = contentRect.left(); int checkboxTopMargin = (outerRect.height() - checkbox->height()) / 2; checkbox->move(checkboxLeftMargin, checkboxTopMargin); // changeIconButton changeIconButton->setIcon(accountIcon); changeIconButton->setAccount(account); // At the moment (KDE 4.8.1) decorationSize is not passed from KWidgetItemDelegate // through the QStyleOptionViewItem, therefore we leave default size unless // the user has a more recent version. if (option.decorationSize.width() > -1) { changeIconButton->setButtonIconSize(option.decorationSize.width()); } int changeIconButtonLeftMargin = checkboxLeftMargin + checkbox->width(); int changeIconButtonTopMargin = (outerRect.height() - changeIconButton->height()) / 2; changeIconButton->move(changeIconButtonLeftMargin, changeIconButtonTopMargin); // statusTextLabel QFont statusTextFont = option.font; QPalette statusTextLabelPalette = option.palette; if (isEnabled) { statusTextLabel->setEnabled(true); statusTextFont.setItalic(false); } else { statusTextLabel->setDisabled(true); statusTextFont.setItalic(true); } if (isSelected) { statusTextLabelPalette.setColor(QPalette::Text, statusTextLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } statusTextLabel->setPalette(statusTextLabelPalette); statusTextLabel->setFont(statusTextFont); statusTextLabel->setText(statusText); statusTextLabel->setFixedSize(statusTextLabel->fontMetrics().boundingRect(statusText).width(), statusTextLabel->height()); int statusTextLabelLeftMargin = contentRect.right() - statusTextLabel->width(); int statusTextLabelTopMargin = (outerRect.height() - statusTextLabel->height()) / 2; statusTextLabel->move(statusTextLabelLeftMargin, statusTextLabelTopMargin); // statusIconLabel statusIconLabel->setPixmap(statusIcon.pixmap(KIconLoader::SizeSmall)); statusIconLabel->setFixedSize(statusIconLabel->minimumSizeHint()); int statusIconLabelLeftMargin = contentRect.right() - statusTextLabel->width() - statusIconLabel->width() - 6; int statusIconLabelTopMargin = (outerRect.height() - statusIconLabel->height()) / 2; statusIconLabel->move(statusIconLabelLeftMargin, statusIconLabelTopMargin); QRect innerRect = contentRect.adjusted(changeIconButton->geometry().right() - contentRect.left(), 0, -statusTextLabel->width() - statusIconLabel->width() - 6, 0); // rect containing account name and error message // displayNameButton QFont displayNameButtonFont = option.font; QPalette displayNameButtonPalette = option.palette; if (isEnabled) { displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::Text)); displayNameButtonFont.setBold(true); } else { displayNameButtonFont.setItalic(true); // NOTE: Flat QPushButton use WindowText instead of ButtonText for button text color displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::HighlightedText)); } displayNameButton->setFont(displayNameButtonFont); displayNameButton->setPalette(displayNameButtonPalette); QString displayNameButtonText = displayNameButton->fontMetrics().elidedText(displayName, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); displayNameButton->setText(displayNameButtonText); displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (m_hpadding*2), displayNameButton->minimumSizeHint().height()); displayNameButton->setAccount(account); int displayNameButtonLeftMargin = innerRect.left(); int displayNameButtonTopMargin = innerRect.top(); displayNameButton->move(displayNameButtonLeftMargin, displayNameButtonTopMargin); // connectionErrorLabel QFont connectionErrorLabelFont = option.font; QPalette connectionErrorLabelPalette = option.palette; if (isEnabled) { connectionErrorLabelPalette.setColor(QPalette::WindowText, connectionErrorLabelPalette.color(QPalette::Active, QPalette::Text)); } else { connectionErrorLabelFont.setItalic(true); connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } connectionErrorLabel->setFont(connectionErrorLabelFont); connectionErrorLabel->setPalette(connectionErrorLabelPalette); QString connectionErrorLabelText = connectionErrorLabel->fontMetrics().elidedText(connectionError, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); connectionErrorLabel->setText(connectionErrorLabelText); connectionErrorLabel->setFixedSize(connectionErrorLabel->fontMetrics().boundingRect(connectionErrorLabelText).width(), displayNameButton->height()); int connectionErrorLabelLeftMargin = innerRect.left() + m_hpadding; int connectionErrorLabelTopMargin = contentRect.bottom() - displayNameButton->height(); connectionErrorLabel->move(connectionErrorLabelLeftMargin, connectionErrorLabelTopMargin); }
void QBBEngine::connectToId(const QString &id) { Q_EMIT connectionError(id, OperationNotSupported); }