コード例 #1
0
ファイル: YggdrasilTask.cpp プロジェクト: ACGaming/MultiMC5
void YggdrasilTask::executeTask()
{
	setStatus(getStateMessage(STATE_SENDING_REQUEST));

	// Get the content of the request we're going to send to the server.
	QJsonDocument doc(getRequestContent());

	auto worker = MMC->qnam();
	QUrl reqUrl("https://" + URLConstants::AUTH_BASE + getEndpoint());
	QNetworkRequest netRequest(reqUrl);
	netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

	QByteArray requestData = doc.toJson();
	m_netReply = worker->post(netRequest, requestData);
	connect(m_netReply, &QNetworkReply::finished, this, &YggdrasilTask::processReply);
	connect(m_netReply, &QNetworkReply::uploadProgress, this, &YggdrasilTask::refreshTimers);
	connect(m_netReply, &QNetworkReply::downloadProgress, this, &YggdrasilTask::refreshTimers);
	connect(m_netReply, &QNetworkReply::sslErrors, this, &YggdrasilTask::sslErrors);
	timeout_keeper.setSingleShot(true);
	timeout_keeper.start(timeout_max);
	counter.setSingleShot(false);
	counter.start(time_step);
	progress(0, timeout_max);
	connect(&timeout_keeper, &QTimer::timeout, this, &YggdrasilTask::abort);
	connect(&counter, &QTimer::timeout, this, &YggdrasilTask::heartbeat);
}
コード例 #2
0
ファイル: world_other.cpp プロジェクト: 1suming/bigworld_ahzs
	int CWorldOther::ReqUrl(T_VECTOR_OBJECT* p)
	{
		if (p->size() != 1)
		{
			LogError("CWorldOther::ReqUrl", "p->size()=%d", p->size());
			return -1;
		}

		const string& url = VOBJECT_GET_SSTR((*p)[0]);

		reqUrl(url.c_str());

		return 0;
	}
コード例 #3
0
ファイル: warequest.cpp プロジェクト: JambulaniDE/mitakuuluu2
void WARequest::getRequest()
{
    QNetworkAccessManager *nam = Client::nam;
    if (nam) {
        QUrl reqUrl(QUrl(URL_REGISTRATION_V2 + _method));
        reqUrl.setQuery(urlQuery);
        QNetworkRequest request(reqUrl);
        request.setRawHeader("User-Agent", Client::wauseragent.toLatin1());
        request.setRawHeader("Connection", "closed");
        qDebug() << "User-Agent" << Client::wauseragent;
        qDebug() << "WARequest" << _method << "request:" << request.url().toString();

        reply = nam->get(request);
        QObject::connect(reply, SIGNAL(finished()), this, SLOT(onResponse()));
        QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
        QObject::connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(sslErrors(const QList<QSslError>)));
    }
}
コード例 #4
0
ファイル: bit_ly_config.cpp プロジェクト: KDE/choqok
void Bit_ly_Config::slotValidate()
{
    ui.validate_button->setEnabled(false);
    ui.validate_button->setText(i18n("Checking..."));
    QString login = QLatin1String("choqok");
    QString apiKey = QLatin1String("R_bdd1ae8b6191dd36e13fc77ca1d4f27f");
    QUrl reqUrl(QLatin1String("http://api.bit.ly/v3/validate"));
    QUrlQuery reqQuery;

    reqQuery.addQueryItem(QLatin1String("x_login"), ui.kcfg_login->text());
    reqQuery.addQueryItem(QLatin1String("x_apiKey"), ui.kcfg_api_key->text());

    if (Bit_ly_Settings::domain() == QLatin1String("j.mp")) {   //bit.ly is default domain
        reqQuery.addQueryItem(QLatin1String("domain"), QLatin1String("j.mp"));
    }

    reqQuery.addQueryItem(QLatin1String("login"), QLatin1String(login.toUtf8()));
    reqQuery.addQueryItem(QLatin1String("apiKey"), QLatin1String(apiKey.toUtf8()));
    reqQuery.addQueryItem(QLatin1String("format"), QLatin1String("txt"));
    reqUrl.setQuery(reqQuery);

    KIO::StoredTransferJob *job = KIO::storedGet(reqUrl, KIO::Reload, KIO::HideProgressInfo);
    job->exec();

    if (!job->error()) {
        QString output(QLatin1String(job->data()));
        if (output.startsWith(QLatin1Char('0')))
            KMessageBox::error(this, i18nc("The your_api_key part of the URL is a fixed part of the URL "
                                           "and should probably not be changed in localization.",
                                           "Provided data is invalid. Try another login or API key.\n"
                                           "You can find it on http://bit.ly/a/your_api_key"));
        if (output.startsWith(QLatin1Char('1'))) {
            KMessageBox::information(this, i18n("You entered valid information."));
        }
    } else {
        Choqok::NotifyManager::error(job->errorString(), i18n("bit.ly Config Error"));
    }

    ui.validate_button->setEnabled(true);
    ui.validate_button->setText(i18n("Validate"));
}
コード例 #5
0
void SlippyMapCache::startDownload()
{
    if (Queue.empty()) return;
    if (DownloadBusy) return;
    while (Queue.size())
    {
        QMap<Coord,QByteArray>::iterator i = Memory.find(Queue[0]);
        if (i == Memory.end())
        {
            DownloadBusy = true;
            DownloadCoord = Queue[0];
            Queue.erase(Queue.begin());
            QUrl reqUrl(baseUrl);
            reqUrl.setPath(QString("/%1/%2/%3.png").arg(DownloadCoord.Zoom).arg(DownloadCoord.X).arg(DownloadCoord.Y));
            //qDebug() << "Starting download with url: " << reqUrl;
            QNetworkRequest req(reqUrl);
            req.setRawHeader(QByteArray("User-Agent"), USER_AGENT.toLatin1());
            DownloadReply = Download.get(req);
            return;
        }
        Queue.erase(Queue.begin());
    }
}