void TorcNetwork::GetSafe(TorcNetworkRequest* Request) { if (Request && m_online) { Request->UpRef(); // some servers require a recognised user agent... Request->m_request.setRawHeader("User-Agent", DEFAULT_USER_AGENT); QNetworkReply* reply = NULL; if (Request->m_type == QNetworkAccessManager::GetOperation) reply = get(Request->m_request); else if (Request->m_type == QNetworkAccessManager::HeadOperation) reply = head(Request->m_request); if (!reply) { Request->DownRef(); LOG(VB_GENERAL, LOG_ERR, "Unknown request type"); return; } // join the dots connect(reply, SIGNAL(readyRead()), this, SLOT(ReadyRead())); connect(reply, SIGNAL(finished()), this, SLOT(Finished())); connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(DownloadProgress(qint64,qint64))); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(Error(QNetworkReply::NetworkError))); connect(reply, SIGNAL(sslErrors(const QList<QSslError> & )), this, SLOT(SSLErrors(const QList<QSslError> & ))); m_requests.insert(reply, Request); m_reverseRequests.insert(Request, reply); }
void GdbServer::newConnection() { QTcpSocket * client; qDebug() << "new connection"; client = server->nextPendingConnection(); switched = false; connect(client,SIGNAL(readyRead()),this,SLOT(ReadyRead())); }
void FileTransferWidget::ClientConnected() { m_socket = m_server->nextPendingConnection(); connect(m_socket,SIGNAL(readyRead()),this,SLOT(ReadyRead())); connect(m_socket,SIGNAL(disconnected()),this,SLOT(Disconnected())); connect(m_socket,SIGNAL(bytesWritten(qint64)),this,SLOT(FileBytesWritten(qint64))); m_currentStatus = FT_WAIT_FOR_HELLO; m_server->close(); }
void InGame::customEvent(QEvent* pe) { if((int)(pe)->type()==QSendToClientEvent::sendtoclienttype) { QSendToClientEvent* qstce=(QSendToClientEvent*)pe; ReadyRead(qstce->Index,qstce->Text); } else qDebug()<<"Error!"; }
void RedirectFollower::ConnectReply(QNetworkReply* reply) { connect(reply, SIGNAL(readyRead()), SLOT(ReadyRead())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SIGNAL(error(QNetworkReply::NetworkError))); connect(reply, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(downloadProgress(qint64, qint64))); connect(reply, SIGNAL(uploadProgress(qint64, qint64)), SIGNAL(uploadProgress(qint64, qint64))); connect(reply, SIGNAL(finished()), SLOT(ReplyFinished())); }
void IsuCalcLink::Initialize() { Socket = new QTcpSocket; connect(Socket, SIGNAL(connected()), this, SLOT(Connected())); connect(Socket, SIGNAL(disconnected()), this, SLOT(Disconnected())); connect(Socket, SIGNAL(readyRead()), this, SLOT(ReadyRead())); connect(Socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(SocketError(QAbstractSocket::SocketError))); Timer = new QTimer; Timer->setSingleShot(true); connect(Timer, SIGNAL(timeout()), this, SLOT(TimerExpired())); }
void servercomm::manageconnection() { //thread starts here qDebug() << socketDescriptor << " Starting thread"; socket = new QTcpSocket(); if(!socket->setSocketDescriptor(this->socketDescriptor)) { emit error(socket->error()); return; } connect(socket,SIGNAL(readyRead()),this,SLOT(ReadyRead()),Qt::DirectConnection); connect(socket,SIGNAL(disconnected()),this,SLOT(disconnected()),Qt::DirectConnection); qDebug() << socketDescriptor << " Client Connected"; //exec(); }
bool CProtocolBase::SetInitLink(ChannelType nChannelType_, const QDomElement &MainPort_) { #if defined(TIAOSHI) m_CGI_CLinkLib.setFileName("Protocol/CGI_CLINKLib_d");//文件名 #else m_CGI_CLinkLib.setFileName("Protocol/CGI_CLINKLib");//文件名 #endif if (m_CGI_CLinkLib.load()) { qDebug()<<"DLL load is OK!"<<m_CGI_CLinkLib.fileName(); typedef CGI_CLINKI * (DLLAPI_CreateDriver)(QObject *parent );//初始化协议 DLLAPI_CreateDriver *pCreateDriver = (DLLAPI_CreateDriver *)m_CGI_CLinkLib.resolve("CreateCGI_CLINKI");//获取 用于获取类对象的全局函数 if (pCreateDriver) { qDebug()<<"Link to Function is OK!"<<m_CGI_CLinkLib.fileName(); m_pLink = pCreateDriver(this);///< 库中导出类的初始化 if (m_pLink != NULL) { connect(m_pLink,SIGNAL(ReadyRead(QByteArray)),this,SLOT(ProcessRespond(QByteArray))); connect(m_pLink,SIGNAL(signalConnect(bool)),this,SLOT(slotConnect(bool))); return m_pLink->CGI_SetInitLink(nChannelType_,MainPort_); }else {
void FileTransferWidget::StartTransfer() { m_currentStatus = FT_IDLE; m_speedBytes = 0; m_IPsHashIter = new QHashIterator<QString,quint32>(m_req.IPsDict); m_IPsHashIter->toFront(); m_filesHashIter = new QHashIterator<QString,quint32>(m_req.FilesDict); m_filesHashIter->toFront(); switch (m_transferMode) { case TM_RECIEVE_CLIENT: { m_socket = new QTcpSocket; connect(m_socket,SIGNAL(connected()),this,SLOT(ConnectedToPeer())); connect(m_socket,SIGNAL(readyRead()),this,SLOT(ReadyRead())); connect(m_socket,SIGNAL(disconnected()),this,SLOT(Disconnected())); connect(m_socket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(SocketError(QAbstractSocket::SocketError))); QHash<QString, quint32>::const_iterator currIp = m_IPsHashIter->next(); m_currentStatus = FT_CONNECTING; qDebug()<<"MRIM: FT: Connecting to "<<currIp.key()<<":"<<currIp.value(); m_socket->connectToHost(currIp.key(),currIp.value()); } break; case TM_SEND_SERVER: { m_sentFilesCount = 0; m_server = new QTcpServer(); connect(m_server,SIGNAL(newConnection()),this,SLOT(ClientConnected())); qDebug()<<"MRIM: FT: Starting server @ 127.0.0.1:"<<m_req.IPsDict.values().at(0); m_currentStatus = FT_WAIT_FOR_CLIENT; m_server->listen(QHostAddress(QHostAddress::LocalHost),m_req.IPsDict.values().at(0)); } break; } }
void Parser3::Update() { /// While we have elements in the que and we still has space to make a request DO while( !mQue.isEmpty() && mResive.size() < 5 && NetworkMgr ) { QPair< QNetworkRequest, QPointer<Parser3_Sender> > Pair = mQue.takeFirst(); // get the reply QNetworkReply *Reply = NetworkMgr->get( Pair.first ); mResive.insert( Reply, Pair.second ); // connect the signals to the slots :) connect( Reply, SIGNAL(finished()), SLOT(ReadyRead()) ); connect( Reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(NetworkError()) ); } if( ProgressBar ) {/// @todo make a better version that is a bit more acurate about progress... int Max = mQue.size()+mResive.size(); ProgressBar->setMaximum( Max ); ProgressBar->setValue( mResive.size() ); if( Max == 0 ) ProgressBar->hide(); else ProgressBar->show(); } }
bool LCD::connectToHost(const QString &lhostname, unsigned int lport) { QMutexLocker locker(&m_socketLock); LOG(VB_NETWORK, LOG_DEBUG, LOC + QString("connecting to host: %1 - port: %2") .arg(lhostname).arg(lport)); // Open communications // Store the hostname and port in case we need to reconnect. m_hostname = lhostname; m_port = lport; // Don't even try to connect if we're currently disabled. if (!(m_enabled = GetMythDB()->GetNumSetting("LCDEnable", 0))) { m_connected = false; m_serverUnavailable = true; return m_connected; } // check if the 'mythlcdserver' is running uint flags = kMSRunShell | kMSDontBlockInputDevs | kMSDontDisableDrawing; if (myth_system("ps ch -C mythlcdserver -o pid > /dev/null", flags) == 1) { // we need to start the mythlcdserver LOG(VB_GENERAL, LOG_NOTICE, "Starting mythlcdserver"); if (!startLCDServer()) { LOG(VB_GENERAL, LOG_ERR, "Failed start MythTV LCD Server"); return m_connected; } usleep(500000); } if (!m_connected) { int count = 0; do { ++count; LOG(VB_GENERAL, LOG_INFO, QString("Connecting to lcd server: " "%1:%2 (try %3 of 10)").arg(m_hostname).arg(m_port) .arg(count)); if (m_socket) delete m_socket; m_socket = new QTcpSocket(); QObject::connect(m_socket, SIGNAL(readyRead()), this, SLOT(ReadyRead())); QObject::connect(m_socket, SIGNAL(disconnected()), this, SLOT(Disconnected())); m_socket->connectToHost(m_hostname, m_port); if (m_socket->waitForConnected()) { m_lcdReady = false; m_connected = true; QTextStream os(m_socket); os << "HELLO\n"; os.flush(); break; } m_socket->close(); usleep(500000); } while (count < 10 && !m_connected); } if (m_connected == false) m_serverUnavailable = true; return m_connected; }