コード例 #1
0
void HttpWindow::startRequest(QUrl url) {
	reply = qnam.get(QNetworkRequest(url));
	connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
	connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
	connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this,
			SLOT(updateDataReadProgress(qint64,qint64)));
}
コード例 #2
0
ファイル: httpeng.cpp プロジェクト: todatamining/proxy
QString HttpEng::get(QUrl url,const QString& proxyHost, const QString &proxyPort)
{
    timer_.start(TIME_OUT);
    content_.clear();
    if(!proxyHost.isEmpty()){
        proxy_.setHostName(proxyHost);
        proxy_.setPort(proxyPort.toInt());
        qnam_.setProxy(proxy_);
    }else{
        qnam_.setProxy(QNetworkProxy::NoProxy);
    }
    url_ = url;
    httpRequestAborted_ = false;
    reply_ = qnam_.get(QNetworkRequest(url));
    connect(reply_, SIGNAL(finished()),
            this, SLOT(httpFinished()));
    connect(reply_, SIGNAL(readyRead()),
            this, SLOT(httpReadyRead()));
    connect(reply_, SIGNAL(downloadProgress(qint64,qint64)),
            this, SLOT(updateDataReadProgress(qint64,qint64)));
    QEventLoop loop;
    connect(this, SIGNAL(engDone()), &loop, SLOT(quit()));
    loop.exec();
    return content_;
#if 0
    qApp->quit(); //------------>put here will never exit!!!!!!!!!!!
                  //              must execute after eventloop start
#endif         
}
コード例 #3
0
void APIController::getAnimeID(QString name)
{
    QFile f("C:/reports.xml");
    QXmlStreamReader reader;
    f.open(QIODevice::ReadOnly);
    reader.setDevice(&f);
    int aid;
    while (!reader.atEnd()) {
        reader.readNext();
        if (reader.name() == "id" && reader.tokenString()=="StartElement") {
            reader.readNext();
            aid = reader.text().toInt();
        }
        if (reader.text().toString().toUpper() == name.toUpper())
        {
            path="C:/"+QString::number(aid);
            file = new QFile(path);
            file->open(QIODevice::ReadWrite);
            url.setUrl("http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime="+QString::number(aid));
            reply = qnam.get(QNetworkRequest(url));
            QObject::connect(reply, SIGNAL(readyRead()),
                             this, SLOT(httpReadyRead()));
            QObject::connect(reply, SIGNAL(finished()),
                             this, SLOT(httpFinished()));
            qDebug()<<QString::number(aid);
            return;
        }
    }

    if (reader.hasError()) {
        qDebug()<<reader.error();
    }
}
コード例 #4
0
int SyncTabWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTabWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_pushButton_4_clicked(); break;
        case 1: on_pushButton_3_clicked(); break;
        case 2: on_pushButton_2_clicked(); break;
        case 3: on_pushButton_clicked(); break;
        case 4: downloadFile(); break;
        case 5: cancelDownload(); break;
        case 6: httpFinished(); break;
        case 7: httpReadyRead(); break;
        case 8: updateDataReadProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break;
        case 9: enableDownloadButton(); break;
        case 10: slotAuthenticationRequired((*reinterpret_cast< QNetworkReply*(*)>(_a[1])),(*reinterpret_cast< QAuthenticator*(*)>(_a[2]))); break;
        case 11: error((*reinterpret_cast< QNetworkReply::NetworkError(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 12;
    }
    return _id;
}
コード例 #5
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuWellImportWizard::startRequest(QUrl url)
{
    m_reply = m_networkAccessManager.get(QNetworkRequest(url));
    connect(m_reply, SIGNAL(finished()),
        this, SLOT(httpFinished()));
    connect(m_reply, SIGNAL(readyRead()),
        this, SLOT(httpReadyRead()));
}
コード例 #6
0
ファイル: httpget.cpp プロジェクト: Hotwill/qt5-book-code
void HttpGet::startRequest(const QUrl &url)
{
    reply = qnam.get(QNetworkRequest(url));
    connect(reply, SIGNAL(finished()),
            this, SLOT(httpFinished()));
    connect(reply, SIGNAL(readyRead()),
            this, SLOT(httpReadyRead()));
}
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: elinuxboy/QtProject
//链接请求函数
void MainWindow::startRequest(QUrl url)
{
    qDebug() << url;
    //返回的是一个QNetworkReply 对象,这里我们获得这个对象,使用它完成显示数据下载进度的功能。
    reply = manager->get(QNetworkRequest(url));
    //当有可用数据时, reply 就会发出 readyRead()信号,我们这时就可以使用这些可用的数据。
    connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));//有可用数据时
}
コード例 #8
0
//! [1]
//! [5]
void HttpDownloader::startRequest()
{
    // Start the download ...
    m_reply = m_qnam.get(QNetworkRequest(m_url));

    // ... and create signal/slot connections to get informed about state changes
    connect(m_reply, SIGNAL(finished()), this, SLOT(httpFinished()));
    connect(m_reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
}
コード例 #9
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuWellImportWizard::startRequest(QUrl url)
{
    m_reply = m_networkAccessManager.get(QNetworkRequest(url));
    connect(m_reply, SIGNAL(finished()),
        this, SLOT(httpFinished()));
    connect(m_reply, SIGNAL(readyRead()),
        this, SLOT(httpReadyRead()));
    connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)),
        this, SLOT(updateDataReadProgress(qint64,qint64)));
}
コード例 #10
0
void Widget::displayJPEG()
{
    disconnect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));

    QPixmap img;
    //    qDebug() << "jpegBA size: " << jpegBA.size();
    img.loadFromData(jpegBA);
    if(!img.isNull())
    {
        int w = ui->imgOutput->width();
        int h = ui->imgOutput->height();

        ui->imgOutput->setPixmap(img.scaled(w,h,Qt::KeepAspectRatio));
    }
    //        ui->imgOutput->setPixmap(img);
    imageReady=true;
    //    resizeImage();
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
}
コード例 #11
0
ファイル: mainwindow.cpp プロジェクト: pvint/replug
void MainWindow::check_for_updates()
{
    return;	// TODO: URL below redirects to Wiki
    if(sender() == ui->actionCheck_for_Updates)
        manual_check = true;
    else
        manual_check = false;

    QNetworkAccessManager *qnam = new QNetworkAccessManager(this);
    reply = qnam->get(QNetworkRequest((QUrl)"http://piorekf.org/plug/VERSION"));
    connect(reply, SIGNAL(finished()), this, SLOT(httpReadyRead()));
}
コード例 #12
0
void QFileDownload::startDeal()
{
    //QEventLoop loop;

    QFileInfo info(url.path());
    QString fileName(info.fileName());
    if(fileName.isEmpty())
        fileName = "index.html";
    qDebug()<<fileName;
    file = new QFile(fileName);
    qheader = new QNetworkRequest();
    /*******************************************/
     QString Range="bytes "+QString::number(startBytes)+"-";//告诉服务器从DownedSize起开始传输
        qDebug()<<"Range: "<<Range<<"\nstartBytes "<<startBytes<<"\n"<<fileName;
         qheader->setUrl(url);
         qheader->setRawHeader("Range",Range.toUtf8());
    /*******************************************/
    if(!file->open(QIODevice::WriteOnly|QIODevice::Append))
    {
        qDebug()<<"file open error !";
        delete file;
        file = 0;
        return ;
    }
    /****************************************************
    qheader = new QNetworkRequest() ;
    qheader->setUrl(url);
    QString Range="bytes "+QString::number(newSize)+"-";//告诉服务器从DownedSize起开始传输
    qheader->setRawHeader("Range",Range.toAscii());
    reply = manager->get(QNetworkRequest(*qheader));
    /****************************************************/


    reply = manager->get(QNetworkRequest(*qheader));
    _window->upDateProgressBar(newSize,totalSize);
    _window->ShowProgressBar();
    // 启动测速定时,1s。
    timer = new QTimer(this);
    timer->start(1000);
    //启动超时定时,30s。
    timer_15s = new QTimer(this);
    if(timer_15s->isActive())
        timer_15s->stop();
    timer_15s->start(15000);

    connect(timer,SIGNAL(timeout()),this,SLOT(updateSpeedTime()));
    //connect(timer_15s,SIGNAL(timeout()),this,SLOT(timeOut()));
    connect(reply,SIGNAL(finished()),this,SLOT(httpFinished()));
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
    connect(reply,SIGNAL(downloadProgress(qint64 ,qint64 )),this
            ,SLOT(updateDataReadProgress(qint64,qint64)));
}
コード例 #13
0
ファイル: requtil.cpp プロジェクト: MrMattMunro/filesearch
//链接请求
void ReqUtil::startRequest(QUrl url)
{

    reply = manager->get(QNetworkRequest(url));
    connect(reply,SIGNAL(finished()),this,SLOT(httpFinished()));  //下载完成后
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead())); //有可用数据时
    // 判断异常
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),this, SLOT(slotError(QNetworkReply::NetworkError)));
    connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));

    connect(reply,SIGNAL(finished()),loop,SLOT(quit()));  // 退出循环
    loop->exec();
}
コード例 #14
0
ファイル: tasks.cpp プロジェクト: XilongPei/seafile-client
void GetFileTask::sendRequest()
{
    QNetworkRequest request(url_);
    reply_ = getQNAM()->get(request);

    connect(reply_, SIGNAL(sslErrors(const QList<QSslError>&)),
            this, SLOT(onSslErrors(const QList<QSslError>&)));

    connect(reply_, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
    connect(reply_, SIGNAL(downloadProgress(qint64, qint64)),
            this, SIGNAL(progressUpdate(qint64, qint64)));
    connect(reply_, SIGNAL(finished()), this, SLOT(httpRequestFinished()));
}
コード例 #15
0
ファイル: capcan.cpp プロジェクト: hominlinx/cppbed
void capCan::checkUpgrade()
{
	replyStr = "";
    connect(&qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
            this, SLOT(httpAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
    //connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
    //        this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));

	reply = qnam.get(QNetworkRequest(QUrl(CHECK_UPGRADE_URL)));
    connect(reply, SIGNAL(finished()),this, SLOT(httpFinished()));
    connect(reply, SIGNAL(readyRead()),this, SLOT(httpReadyRead()));
    //connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
    //        this, SLOT(updateDataReadProgress(qint64,qint64)));
}
コード例 #16
0
ファイル: configgui.cpp プロジェクト: ibre5041/OraPassGen
void ConfigGui::startRequest(QUrl url)
{
    // emits the readyRead() signal whenever new data arrives.
    reply = manager->get(QNetworkRequest(url));

    // Whenever more data is received from the network, this readyRead() signal is emitted
    QObject::connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));

    // Also, downloadProgress() signal is emitted when data is received
    connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
            this, SLOT(updateDownloadProgress(qint64,qint64)));

    // This signal is emitted when the reply has finished processing.
    QObject::connect(reply, SIGNAL(finished()), this, SLOT(httpDownloadFinished()));
}
コード例 #17
0
void QFileDownload::stop(){
    file->flush();
    file->close();
    reply->deleteLater();
    timer->stop();
    timer_15s->stop();
    disconnect(reply,SIGNAL(finished()),this,SLOT(httpFinished()));
    reply->abort();
    disconnect(timer,SIGNAL(timeout()),this,SLOT(updateSpeedTime()));
    disconnect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
    disconnect(reply,SIGNAL(downloadProgress(qint64 ,qint64 )),this
            ,SLOT(updateDataReadProgress(qint64,qint64)));
    startBytes = newSize;

}
コード例 #18
0
ファイル: moc_downloaddialog.cpp プロジェクト: neolu/gv9x
int downloadDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: httpFinished(); break;
        case 1: httpReadyRead(); break;
        case 2: updateDataReadProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
コード例 #19
0
ファイル: tasks.cpp プロジェクト: DevCybran/seafile-client
void GetFileTask::sendRequest()
{
    QNetworkRequest request(url_);
    if (!network_mgr_) {
        static QNetworkAccessManager *manager = new QNetworkAccessManager(qApp);
        network_mgr_ = manager;
        NetworkManager::instance()->addWatch(network_mgr_);
    }
    reply_ = network_mgr_->get(request);

    connect(reply_, SIGNAL(sslErrors(const QList<QSslError>&)),
            this, SLOT(onSslErrors(const QList<QSslError>&)));

    connect(reply_, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
    connect(reply_, SIGNAL(downloadProgress(qint64, qint64)),
            this, SIGNAL(progressUpdate(qint64, qint64)));
    connect(reply_, SIGNAL(finished()), this, SLOT(httpRequestFinished()));
}
コード例 #20
0
ファイル: loginwindow.cpp プロジェクト: lotux/MediaPort
void LoginWindow::doSignIn(QString username,QString password)
{
    if(loginInProgress)
       return;

    if (!username.isEmpty() && !password.isEmpty())
    {
        QUrl m_loginUrl = QUrl ( QString(Constants::LOGIN_PATH) +
                             "u=" + username + "&p=" + password );
        reply = manager.get(QNetworkRequest(m_loginUrl));

        connect(reply, SIGNAL(finished()),
                this, SLOT(httpFinished()));
        connect(reply, SIGNAL(readyRead()),
                this, SLOT(httpReadyRead()));
        connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
                this, SLOT(updateProgress(qint64,qint64)));
    }
}
コード例 #21
0
bool Downloader::handleDownloadRequest(QNetworkAccessManager *manager, QNetworkReply *r)
{
    reply = r;
    QUrl url = reply->url();
    fileName = QFileInfo(url.path()).fileName();
	if(QMessageBox::question(this,tr("Download the file?"),tr("Do you really wish to download ") + fileName) != QMessageBox::Ok)
		return false;
    absFileName = downloadsDir.absoluteFilePath(fileName);
    if(absFileName.isEmpty())
        return false;
    file = new QFile(absFileName);
    file->open(QIODevice::WriteOnly);
    label->setText(tr("Downloading ") + fileName);
    setTitle(tr("Downloading"));
    cancelButton->setText(tr("Cancel"));
    connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(setProgress(qint64,qint64)));
    connect(cancelButton,SIGNAL(clicked()),this,SLOT(abortDownload()));
    connect(reply,SIGNAL(finished()),this,SLOT(finished()));
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
    return true;
}
コード例 #22
0
ファイル: getbase.cpp プロジェクト: AndrewBatrakov/Yarn
void GetBase::getBaseHttp()
{
    progressDialog = new QProgressDialog(this);
    fileHttp = new QFile("Yarn.dat");
    fileHttp->open(QIODevice::WriteOnly);
    url = "http://91.102.219.74/QtProject/Yarn/Base/Yarn.dat";
    //url = "http://91.102.219.74/QtProject/Yarn/Yarn.exe";

    reply = http.get(QNetworkRequest(url));
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
    connect(reply,SIGNAL(finished()),this,SLOT(httpDone()));

    connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,
            SLOT(updateDataReadProgress(qint64,qint64)));
    connect(reply,SIGNAL(uploadProgress(qint64,qint64)),this,
            SLOT(updateDataReadProgress(qint64,qint64)));

    progressDialog->setLabelText(tr("Downloading DataBase ..."));
    progressDialog->setEnabled(true);
    progressDialog->exec();
}
コード例 #23
0
void jewelryUpdate::requestHttp(QUrl url)
{
    qDebug() <<url;
    QFileInfo info(url.path());
    QString fileName(info.fileName());
    if (fileName.isEmpty())
    {
      QMessageBox::critical(this, "系统消息", "版本文件错误或者丢失,请向程序开发人员联系!");
      return;
    }
    m_file = new QFile(fileName);
    if (!m_file->open(QIODevice::WriteOnly))
    {
      delete m_file;
      m_file = 0;
      return;
    }
    m_reply = m_manager.get(QNetworkRequest(url));
    connect(m_reply,SIGNAL(finished()),this,SLOT(httpFinished())); //更新完成后
    connect(m_reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead())); //有可用数据时
    connect(m_reply,SIGNAL(downloadProgress(qint64,qint64)), this,SLOT(updateDataReadProgress(qint64,qint64)));//更新进度条
}
コード例 #24
0
// This will be called when download button is clicked
void Downloader::startRequest(QUrl url)
{
    downloadProgress = 0;
    downloadFinished = false;

    // Create a timer to handle hung download requests
    downloadTimer = new QTimer(this);
    connect(downloadTimer, SIGNAL(timeout()), this, SLOT(timerCheckDownloadProgress()));
    downloadTimer->start(30000);

    // get() method posts a request
    // to obtain the contents of the target request
    // and returns a new QNetworkReply object
    // opened for reading which emits
    // the readyRead() signal whenever new data arrives.
    reply = manager->get(QNetworkRequest(url));

    // Whenever more data is received from the network,
    // this readyRead() signal is emitted
    connect(reply, SIGNAL(readyRead()),
            this, SLOT(httpReadyRead()));

    // Also, downloadProgress() signal is emitted when data is received
    connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
            this, SLOT(updateDownloadProgress(qint64,qint64)));

    // This signal is emitted when the reply has finished processing.
    // After this signal is emitted,
    // there will be no more updates to the reply's data or metadata.
    connect(reply, SIGNAL(finished()),
            this, SLOT(downloaderFinished()));

    if (!autoDownload)
    {
        ui->statusLabel->setText(tr("Downloading..."));
        progressDialog->show();
    }
}
コード例 #25
0
ファイル: updater.cpp プロジェクト: iPenguin/NotePages
void Updater::startRequest()
{
    reply = qnam.get(QNetworkRequest(mUrl));
    connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
    connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
}
コード例 #26
0
void Widget::on_stopButton_clicked()
{
    disconnect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
}