Пример #1
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();
    }
}
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;
}
Пример #3
0
	void GmailChecker::checkNow ()
	{
		if (!XmlSettingsManager::Instance ()->property ("CheckingEnabled").toBool ())
			return;

		QString error = tr ("Error");
		error.prepend ("Gmail Notifier: ");

		if (Username_.isEmpty () || Password_.isEmpty ())
		{
			emit anErrorOccupied (error, tr ("Username or password not set"));
			return;
		}

		Failed_ = false;
		Data_.clear ();

		Reply_ = QNAM_->get (QNetworkRequest (QUrl ("https://mail.google.com/mail/feed/atom")));
		connect (Reply_,
				SIGNAL (finished ()),
				this,
				SLOT (httpFinished ()));
		TimeOutTimer_->start ();

		emit waitMe ();
	}
Пример #4
0
void RegisterService::subscribeToPushInitiator(const User& user, const QString& token)
{
    // Keep track of the current user's information so it can be stored later
    // on a success
    m_currentUser = user;

    const Configuration config = m_configurationService.configuration();

    QUrl url(config.pushInitiatorUrl() + "/subscribe");
    url.addQueryItem("appid",config.providerApplicationId());
    url.addQueryItem("address",token);
    url.addQueryItem("osversion",deviceVersion());
    url.addQueryItem("model",deviceModel());
    url.addQueryItem("username",user.userId());
    url.addQueryItem("password",user.password());
    if (config.usingPublicPushProxyGateway()) {
        url.addQueryItem("type","public");
    } else {
        url.addQueryItem("type","bds");
    }

    qDebug() << "URL: " << url;
    m_reply = m_accessManager.get(QNetworkRequest(url));

    // Connect to the reply finished signal.
    checkConnectResult(connect(m_reply, SIGNAL(finished()), this, SLOT(httpFinished())));
}
Пример #5
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)));
}
Пример #6
0
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         
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
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()));
}
Пример #8
0
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()));
}
//! [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()));
}
Пример #10
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)));
}
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)));
}
void DroneshareAPIBroker::sendQueryRequest()
{
    if (m_url.isEmpty()) {
        QLOG_ERROR() << "Query request invalid";
        return;
    }
    QLOG_DEBUG() << "Droneshare: sendQueryRequest" << m_url;
    QNetworkRequest request(m_url);
    m_networkReply = m_networkAccessManager.get(request);
    connect(m_networkReply, SIGNAL(finished()), this, SLOT(httpFinished()));
    connect(m_networkReply, SIGNAL(downloadProgress(qint64,qint64)),
            this, SLOT(downloadProgress(qint64,qint64)));
}
Пример #13
0
//链接请求
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
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)));
}
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;

}
Пример #16
0
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;
}
Пример #17
0
void DownLoadFun::down(STATUSID id, QString url)
{
    if(reply != NULL)
    {
        reply->abort();
    }

    m_id = id;

    QNetworkAccessManager *manager = new QNetworkAccessManager;
    reply = manager->get(QNetworkRequest(url));

    connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));

    connect(reply,SIGNAL(downloadProgress(qint64,qint64)),
            this,SLOT(updateDataReadProgress(qint64,qint64)));
}
Пример #18
0
void UnregisterService::unsubscribeFromPushInitiator(const User& user)
{
    // Keep track of the current user's information
    // If it matches the one stored then it will be removed on success
    m_currentUser = user;

    const Configuration config = m_configurationService.configuration();

    QUrl url(config.pushInitiatorUrl() + "/unsubscribe");
    url.addQueryItem("appid",config.providerApplicationId());
    url.addQueryItem("username",user.userId());
    url.addQueryItem("password",user.password());

    qDebug() << "URL: " << url;
    m_reply = m_accessManager.get(QNetworkRequest(url));

    // Connect to the reply finished signal.
    connect(m_reply, SIGNAL(finished()), this, SLOT(httpFinished()));
}
Пример #19
0
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)));
    }
}
Пример #20
0
void capCan::httpFinished()
{
    disconnect(reply, SIGNAL(finished()),this, SLOT(httpFinished()));
	chaos = reply->error();
    if (chaos != 0) return;
	reply->deleteLater();
	/*
	if (chaos)
	{
		QMessageBox::warning(this, QString::fromLocal8Bit("错误"),
                             QString::fromLocal8Bit("无法检测升级!"),
                             QMessageBox::Ok);
		this->close();
		return;
	}
	*/
	// 比较版本
#ifdef Q_OS_WIN
	QString ver = replyStr.section("capCan Windows:",1).trimmed();
#else
	QString ver = replyStr.section("canCan Linux:",2).trimmed();
#endif
    QString path;
    QDir dir;
    path = dir.currentPath();

	int ver_h, ver_m, ver_l;
	ver_h = ver.section(".",0,0).toInt();
	ver_m = ver.section(".",1,1).toInt();
	ver_l = ver.section(".",2,2).toInt();
	mAppVersion = TVersion(VERSION_H, VERSION_M, VERSION_L); 
	TVersion remoteVersion = TVersion(ver_h, ver_m, ver_l); 
	if (remoteVersion > mAppVersion)
	{
        path = path + "//" + upgradeProcess;
        QProcess::startDetached(path, QStringList()<<EXE_UPGRADE_URL);
        this->close();
	}
}
Пример #21
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)));//更新进度条
}
Пример #22
0
void Updater::startRequest()
{
    reply = qnam.get(QNetworkRequest(mUrl));
    connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
    connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
}
Пример #23
0
void SubmitDialog::genericButton() {
	if (state == INPUT) {
		// Send the result

		state = SUBMITTING;
		ui->genericButton->setText("&Cancel");

		// Data to submit
		const QString name = ui->nameEdit->text();
		const QString pwd =  ui->pwdEdit->text();
#if defined (WIN32)
		const QString os = "Windows";
#elif defined (__linux__)
		const QString os = "Linux";
#elif defined (__APPLE__)
		const QString os = "MacOS";
#else
		const QString os = "Unknown";
#endif
		const QString scene = sceneName;
		const QString score = ToString(int(sampleSecs / 1000.0)).c_str();
		const QString note = ui->noteTextEdit->toPlainText();
		const QString devCount = ToString(descs.size()).c_str();

		// Delete manager/reply if required
		if (manager) {
			if (reply)
				delete reply;
			reply = NULL;

			delete manager;
			manager = NULL;
		}

		manager = new QNetworkAccessManager(this);

		// Create the http request
		SD_LOG("Creating HTTP request...");
		QNetworkRequest request;
		request.setUrl(QUrl("http://www.luxrender.net/luxmark/submit"));
		request.setRawHeader("User-Agent", "LuxMark v" LUXMARK_VERSION_MAJOR "." LUXMARK_VERSION_MINOR);
		// Const's patch for Qt 4.8.1
		request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

		// Create the http request parameters
		QUrl params;
		params.addEncodedQueryItem("name", QUrl::toPercentEncoding(name));
		params.addEncodedQueryItem("password", QUrl::toPercentEncoding(pwd));

		SD_LOG("Submitted data:");
		params.addEncodedQueryItem("os", QUrl::toPercentEncoding(os));
		SD_LOG("os = " << os.toStdString());

		params.addEncodedQueryItem("scene_name", QUrl::toPercentEncoding(scene));
		SD_LOG("scene_name = " << scene.toStdString());

		params.addEncodedQueryItem("score", QUrl::toPercentEncoding(score));
		SD_LOG("score = " << score.toStdString());

		params.addEncodedQueryItem("note", QUrl::toPercentEncoding(note));
		SD_LOG("note = " << note.toStdString());

		params.addEncodedQueryItem("dev_count", QUrl::toPercentEncoding(devCount));
		SD_LOG("dev_count = " << devCount.toStdString());

		for (size_t i = 0; i < descs.size(); ++i) {
			SD_LOG("dev_platform_name = " << descs[i].platformName);
			params.addEncodedQueryItem("dev_platform_name[]", QUrl::toPercentEncoding(QString(descs[i].platformName.c_str())));

			SD_LOG("dev_platform_ver = " << descs[i].platformVersion);
			params.addEncodedQueryItem("dev_platform_ver[]", QUrl::toPercentEncoding(QString(descs[i].platformVersion.c_str())));

			SD_LOG("dev_name = " << descs[i].deviceName);
			params.addEncodedQueryItem("dev_name[]", QUrl::toPercentEncoding(QString(descs[i].deviceName.c_str())));

			SD_LOG("dev_type = " << descs[i].deviceType);
			params.addEncodedQueryItem("dev_type[]", QUrl::toPercentEncoding(QString(descs[i].deviceType.c_str())));

			SD_LOG("dev_units = " << descs[i].units);
			params.addEncodedQueryItem("dev_units[]", QUrl::toPercentEncoding(QString(ToString(descs[i].units).c_str())));

			SD_LOG("dev_clock = " << descs[i].clock);
			params.addEncodedQueryItem("dev_clock[]", QUrl::toPercentEncoding(QString(ToString(descs[i].clock).c_str())));

			SD_LOG("dev_global_mem = " << descs[i].globalMem);
			params.addEncodedQueryItem("dev_global_mem[]", QUrl::toPercentEncoding(QString(ToString(descs[i].globalMem).c_str())));

			SD_LOG("dev_local_mem = " << descs[i].localMem);
			params.addEncodedQueryItem("dev_local_mem[]", QUrl::toPercentEncoding(QString(ToString(descs[i].localMem).c_str())));

			SD_LOG("dev_constant_mem = " << descs[i].constantMem);
			params.addEncodedQueryItem("dev_constant_mem[]", QUrl::toPercentEncoding(QString(ToString(descs[i].constantMem).c_str())));
		}

		QByteArray data;
		data = params.encodedQuery();

		// Send the request
		SD_LOG("Posting result...");

		reply = manager->post(request, data);
		connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
		connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
				this, SLOT(httpError(QNetworkReply::NetworkError)));
	} else if (state == SUBMITTING) {
		// Cancel the result submission
		reply->abort();

		SD_LOG_ERROR("Submission aborted");
		state = INPUT;
		ui->genericButton->setText("&Submit");
	} else {
		// Done
		this->close();
	}
}
Пример #24
0
void MainWindow::startRequest(const QUrl &url)
{
    QNetworkRequest request(url);
    reply = view->page()->networkAccessManager()->get(request);
    connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));
}