void FileUpload::start() { //qDebug() << "FileUpload::start"; //qDebug() << " path: " << d_ptr->path; //qDebug() << " thread: " << QThread::currentThread(); FileUploadPrivate *d = static_cast<FileUploadPrivate *>(d_ptr); d->exchange = new NetworkExchange(d->request, this); if (d->netAccessManager) { d->exchange->setNetworkAccessManager(d->netAccessManager); } d->file = new QFile(d->path, this); if (!d->file->open(QFile::ReadOnly)) { setError(QNetworkReply::UnknownContentError, d->file->errorString()); emit error(this->error()); emit finished(); return; } connect(d->exchange, SIGNAL(replyReceived()), SLOT(onReplyReceived())); connect(d->exchange, SIGNAL(uploadProgress(qint64, qint64)), SLOT(onUploadProgress(qint64, qint64))); connect(d->exchange, SIGNAL(readyRead()), SLOT(onReadyRead())); connect(d->exchange, SIGNAL(redirected(const QUrl &)), SLOT(onRedirected(const QUrl &))); connect(d->exchange, SIGNAL(finished()), SLOT(onFinished())); connect(d->exchange, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(onError(QNetworkReply::NetworkError))); connect(&d->txTimer, SIGNAL(timeout()), this, SLOT(onDataTxTimeout())); emit started(); d->exchange->post(d->file); d->txTimer.start(d->txTimeout); }
void BootStrapLoader::on_SerialPort_ReadyRead() { quint8 incoming; bslState newstate; while(mSerialPort->read((char *)&incoming,1)>0) { switch(mState) { case afterConnect: case beforeDisconnect: if(mSerialPlugin) { newstate=mSerialPlugin->incomingByte(incoming); if(newstate!=mState) setState(newstate); } break; case serial: if(mOutPacket==NULL) { qDebug("Data (%d) (%c) recevived but no packet active!!!",incoming,incoming); } else { if(mOutPacket->reply()->incomingByte(incoming)) { if(mOutPacket->hasReply()) { BSLCoreCommmand* coreCommand = dynamic_cast<BSLCoreCommmand*>(mOutPacket); if(coreCommand && coreCommand->command()==BSLCoreCommmand::txBslVersion) { mOutPacket=NULL; setState(bsl); stateChanged(mState); } } } } break; case bsl: case working: if(mOutPacket==NULL) { qDebug("Data (%d) (%c) recevived but no packet active!!!",incoming,incoming); } else { if(mOutPacket->reply()->incomingByte(incoming)) { mComplQueue.append(mOutPacket); emit replyReceived(mOutPacket); mOutPacket=NULL; tryToSend(); } } break; default: qDebug("BootStrapLoader::on_SerialPort_ReadyRead state:%d byte:%02X",state(),incoming); break; } } }
void WebserviceTTSProvider::fetch(const QString& url) { currentConnection = net->get(QNetworkRequest(KUrl(url))); connect(currentConnection, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); connect(currentConnection, SIGNAL(finished()), this, SLOT(replyReceived())); }
void CodecProxy::sendWelcomeMessage() { emit replyReceived(Message::createCommand("OK\n")); }
void CodecProxy::onReplyParsed() { emit replyReceived(m_parser->latestReply()); }
void FakeHttpClient::get(const QString&) { emit replyReceived(getValidReplyData()); }
//! [6] //! [6] void Window::toggleJobStatus() { nzmqt::Requester* req = new nzmqt::Requester(*context, "tcp://127.0.0.1:5557", running?"PAUSE":"START", this); connect(req, SIGNAL(replyReceived(QList<QByteArray>)), this, SLOT(statusReceived(QList<QByteArray>))); req->start(); }
/*! \internal Sends an \a event, \a message and \a data to the remote host and waits for up to \a timeout milliseconds for a reply. If a reply is received, the reply's message string is placed in \a reply. */ bool QstProtocol::sendMessage( const QstMessage &message, QstMessage &reply, int timeout ) { QstMessage msg(message); QPointer<QstProtocol> safeThis(this); bool safeDebugOn(debug_on); QString safeUniqueId(uniqueId()); last_send_cmd = message.event(); if (state() == ConnectingState) { wait(4000); } if (state() == ConnectedState) { msg.m_msg_id = tx_msg_id++; if (debug_on) { qDebug() << ( QString("%1 QstProtocol::sendMessage(%2) msgid=%3)"). arg(uniqueId()). arg(msg.event()). arg(msg.msgId()). toLatin1()); } send( msg ); QTime t1; t1.start(); QTime t2; t2.start(); bool first_time = true; while ( (state() == ConnectedState) && (timeout < 0 || t1.elapsed() < timeout) ) { if (debug_on) { if (first_time || t2.elapsed() > 1000) { qDebug() << ( QString("%1 QstProtocol::sendMessage(%2) ... waiting for reply"). arg(uniqueId()). arg(message.event()).toLatin1()); t2.start(); first_time = false; } } waitForSignal(this, SIGNAL(replyReceived()), 500); if (!safeThis) { if (safeDebugOn) { qDebug() << ( QString("%1 QstProtocol::sendMessage(%2) ... object deleted unexpectedly"). arg(safeUniqueId). arg(message.event()).toLatin1()); } reply[QLatin1String("status")] = "ERROR: Connection was terminated unexpectedly. This may be caused by an application crash."; reply[QLatin1String("_q_inResponseTo")] = QString("%1\n%2").arg(message.event()).arg(message.toString()); return false; } else { if (send_msg_replies.count() > 0) { if (debug_on) { qDebug() << ( QString("%1 QstProtocol::sendMessage(%2) ... check replies"). arg(uniqueId()). arg(message.event()).toLatin1()); } for (int i=0; i<send_msg_replies.size(); i++) { QstMessage * possible_reply = send_msg_replies.at(i); if (possible_reply && possible_reply->m_msg_id == msg.m_msg_id) { reply = *possible_reply; delete send_msg_replies.takeAt( i ); if (debug_on) { qDebug() << ( QString("%1 QstProtocol::sendMessage(%2) ... reply received"). arg(uniqueId()). arg(message.event()).toLatin1()); } onReplyReceived(&reply); return true; } } } } } if (state() != ConnectedState) { reply[QLatin1String("status")] = "ERROR: Connection lost. This is likely caused by a crash in the Application Under Test."; reply[QLatin1String("_q_inResponseTo")] = QString("%1\n%2").arg(message.event()).arg(message.toString()); } else { qDebug() << "ERROR-REPLY-TIMEOUT: " << t1.elapsed() << t2.elapsed(); reply[QLatin1String("status")] = QLatin1String("ERROR_REPLY_TIMEOUT"); reply[QLatin1String("_q_inResponseTo")] = QString("%1\n%2").arg(message.event()).arg(message.toString()); } reply[QLatin1String("location")] = QString("%1:%2").arg(__FILE__).arg(__LINE__); } else { reply[QLatin1String("status")] = QLatin1String("ERROR_NO_CONNECTION"); reply[QLatin1String("_q_inResponseTo")] = QString("%1\n%2").arg(message.event()).arg(message.toString()); reply[QLatin1String("location")] = QString("%1:%2").arg(__FILE__).arg(__LINE__); } if (debug_on) { qDebug() << ( QString("%1 QstProtocol::sendMessage(%2) ... done. Status: %3"). arg(uniqueId()). arg(message.event()).arg(reply[QLatin1String("status")].toString()).toLatin1()); } return false; }