Exemple #1
0
void QueryImages::doWorkSendRequest()
{
    Q_D(QueryImages);

    // Set the url
    QUrl url = d->mediawiki.url();
    url.addQueryItem("format",  "xml");
    url.addQueryItem("action",  "query");
    url.addQueryItem("titles",  d->title);
    url.addQueryItem("prop",    "images");
    url.addQueryItem("imlimit", d->limit);
    if (!d->imcontinue.isNull())
    {
        url.addQueryItem("imcontinue", d->imcontinue);
    }

    // Set the request
    QNetworkRequest request(url);
    request.setRawHeader("User-Agent", d->mediawiki.userAgent().toUtf8());

    // Send the request
    d->reply = d->manager->get(request);
    connectReply();
    connect(d->reply, SIGNAL(finished()),
            this, SLOT(doWorkProcessReply()));
}
void
SendLogsRequest::send()
{
    QUrl url;
    url.setScheme( "http" );
    url.setHost( "oops.last.fm" );
    url.setPath( "logsubmission/add" );
    url.addEncodedQueryItem( "username", QUrl::toPercentEncoding(Ws::Username) );
    #ifdef Q_WS_MAC
        url.addQueryItem( "platform", "macosx" );
    #elif defined WIN32
        url.addQueryItem( "platform", "win32" );
    #else
        url.addQueryItem( "platform", "linux" );
    #endif
    url.addQueryItem( "clientname", QCoreApplication::applicationName() );
    url.addQueryItem( "clientversion", QCoreApplication::applicationVersion() );

    QNetworkRequest request = QNetworkRequest( url );
    request.setRawHeader( "Content-Type", "multipart/form-data;boundary=8e61d618ca16" );
    request.setRawHeader( "Accept", "*/*" );

    m_data.append( postData( "usernotes", escapeString( m_usernotes ).toLatin1() ) );
    m_data.append( postData( "logs", m_logs.join(",").toLatin1() ) );
    m_data.append( "--8e61d618ca16--" ); // close the post request
    
    m_error = false;
    QNetworkReply *reply = (new WsAccessManager( this ))->post( request, m_data );
    
    connect( reply, SIGNAL( finished() ),
             this, SLOT( onFinished() ) );
    connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
             this, SLOT( onError( QNetworkReply::NetworkError ) ) );
}
Exemple #3
0
QUrl DNSUpdater::getUpdateUrl() const
{
  QUrl url;
#ifdef QT_NO_OPENSSL
  url.setScheme("http");
#else
  url.setScheme("https");
#endif
  url.setUserName(m_username);
  url.setPassword(m_password);

  Q_ASSERT(!m_lastIP.isNull());
  // Service specific
  switch(m_service) {
  case DNS::DYNDNS:
    url.setHost("members.dyndns.org");
    break;
  case DNS::NOIP:
    url.setHost("dynupdate.no-ip.com");
    break;
  default:
    qWarning() << "Unrecognized Dynamic DNS service!";
    Q_ASSERT(0);
  }
  url.setPath("/nic/update");
  url.addQueryItem("hostname", m_domain);
  url.addQueryItem("myip", m_lastIP.toString());
  Q_ASSERT(url.isValid());
  qDebug() << Q_FUNC_INFO << url.toString();
  return url;
}
void PrivateMessageController::deletePrivateMessage(const QString &urlFirstPage) {

    QRegExp catIDRegExp("cat=([0-9prive]+)");
    if(catIDRegExp.indexIn(urlFirstPage) == -1)
        return;

    const QUrl url(DefineConsts::FORUM_URL + "/modo/manageaction.php?config=hfr.inc&cat=" + catIDRegExp.cap(1) + "&type_page=forum1&moderation=0");

    QRegExp postIDRegExp("post=([0-9]+)");
    if(postIDRegExp.indexIn(urlFirstPage) == -1)
        return;

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QUrl params;
    params.addQueryItem("action_reaction", "valid_eff_prive");
    params.addQueryItem("topic1", postIDRegExp.cap(1));
    params.addQueryItem("hash_check", m_HashCheck);

    QNetworkReply* reply = HFRNetworkAccessManager::get()->post(request, params.encodedQuery());
    bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkMessageDeleted()));
    Q_ASSERT(ok);
    Q_UNUSED(ok);
}
Exemple #5
0
void Networking::sendCoins(QString address, QString amount)
{
    QString sendRequest;
    sendRequest = QString("https://www.instawallet.org/api/v1/w/%1/payment").arg(walletId);

    updating = true;

    QByteArray data;
    QUrl parameters;

    double convertedAmount;

    long long convertedLongAmount;

    QString stringAmount;

    convertedAmount = amount.toDouble();
    convertedLongAmount = convertedAmount * 1e8 + (convertedAmount < 0.0 ? -.5 : .5);

    stringAmount = QString("%1").arg(convertedLongAmount);

    qDebug("Amount converted to Satoshis: " + stringAmount.toAscii());

    parameters.addQueryItem("address", address);
    parameters.addQueryItem("amount", stringAmount);
    data.append(parameters.toString());
    data.remove(0, 1);

    networkPaymentManager->post(QNetworkRequest(QUrl(sendRequest)), data)->ignoreSslErrors();

    connect(networkPaymentManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(walletPaymentLoaded(QNetworkReply*)));
}
Exemple #6
0
void STULogin::login(const QString &user, const QString &passwd){

//    qDebug() << "now login " + user + "\t" + passwd;

    logining = true;  // QtNetWorkAccessManager works asynchronously
    this->user_copy = user;
//    qDebug() << this->user;
    this->passwd = passwd;  // record the user info for try again untill MAX_COUNT or login
    if (is_connected){
        wrongCount = 0;
        return;
    }
    requestAddr->setUrl(LOGIN_REQUEST_ADDR);
    QUrl params;
    params.addQueryItem(USERNAME_INPUT,user);
    params.addQueryItem(PASSWD_INPUT,passwd);
    params.addQueryItem(LOGIN_INPUT,"");

    QByteArray postData = params.encodedQuery();
    QNetworkRequest request(*requestAddr);
    request.setHeader(QNetworkRequest::ContentTypeHeader,
                      "application/x-www-form-urlencoded");
    delayForSomeTime(600);
    QNetworkReply *reply = syncHttpPost(request, postData);
    handleReply(reply);
    processStates(replyData);
    emit stateChanged(is_connected,user,used,total,left);
    //qDebug() << replyData;
}
	void ServerHistoryManager::Request (int offset)
	{
		const auto nam = Acc_->GetCoreProxy ()->GetNetworkAccessManager ();

		auto getter = [offset, nam, this]
				(const QString& key, const VkConnection::UrlParams_t& params) -> QNetworkReply*
			{
				QUrl url ("https://api.vk.com/method/messages.getDialogs");
				url.addQueryItem ("access_token", key);
				url.addQueryItem ("count", QString::number (DlgChunkCount));
				url.addQueryItem ("offset", QString::number (offset));
				VkConnection::AddParams (url, params);

				LastOffset_ = offset;

				auto reply = nam->get (QNetworkRequest (url));
				connect (reply,
						SIGNAL (finished ()),
						this,
						SLOT (handleGotMessagesList ()));
				return reply;
			};

		Acc_->GetConnection ()->QueueRequest (getter);
	}
// The Foursquare invocation calls are based on the sample available here:
// https://github.com/kylefowler/foursquare-bb10-sdk
//
// Launches a native Foursquare venue search in your app.
// This card will call back to your childCardDone slot with the appropriate
// response for the actions taken by the user.
//
// URI Params:
// query: (optional) prime the venue search with a query
// client_id: (required) the client id from your oauth consumer
// client_secret: (required) the client secret from your oauth consumer
// oauth_token: (required if no client_id/client_secret) pass this if you
//              already have an authenticated user token, this way venue
//              search results will be fitted to the user requesting them
//              for a higher quality queryless search
//
// Response:
// When the user selects a venue, you will get the venue information in
// JSON format back through the childCardDone slot in the data object.
// The venue format will match what is listed here in the core venue fields:
// https://developer.foursquare.com/docs/responses/venue
//
// If the user cancels the search without any action: the reason message will be "canceled"
// If any of the parameters are missing you will get a reason message of "invalid_credentials"
void SocialInvocation::invokeFoursquareVenueCard(const QString &venue) {
	InvokeRequest cardRequest;
	cardRequest.setTarget("com.foursquare.blackberry.venuesearch.card");
	cardRequest.setAction("bb.action.VIEW");
	cardRequest.setMimeType("venuesearch/foursquare");

	// The client_id and client_secret are the Foursquare API credentials
	// that you receive when registering your app with Foursquare.
	//
	// You can register your app with Foursquare here:
	// https://foursquare.com/developers/apps
	//
	// For more information on Foursquare API credentials, see here:
	// https://developer.foursquare.com/overview/auth

	QUrl uri = QUrl("foursquare://venues/search");

	// Replace the following values with your app's client ID and secret
	uri.addQueryItem("client_id", "UFVANV2FBBFRPXSBXHCCKECVUDANDKP5KQFKICRCA1VAFV4V");
	uri.addQueryItem("client_secret","11AY4DWL0A2CV1NXPKDMS2PJTEACRZJP0BMFXORNCKBSNVMH");

	uri.addQueryItem("query", venue);
	cardRequest.setUri(uri);

	m_invokeManager->invoke(cardRequest);
}
QString CetonStreamHandler::GetVar(
    const QString &section, const QString &variable) const
{
    QString loc = LOC + QString("DoGetVar(%1,%2,%3,%4) - ")
        .arg(_ip_address).arg(_tuner).arg(section,variable);

    QUrl params;
    params.addQueryItem("i", QString::number(_tuner));
    params.addQueryItem("s", section);
    params.addQueryItem("v", variable);

    QString response;
    uint status;
    if (!HttpRequest("GET", "/get_var.json", params, response, status))
    {
        LOG(VB_RECORD, LOG_ERR, loc +
            QString("HttpRequest failed - %1").arg(response));
        return QString();
    }

    QRegExp regex("^\\{ \"?result\"?: \"(.*)\" \\}$");
    if (regex.indexIn(response) == -1)
    {
        LOG(VB_RECORD, LOG_ERR, loc +
            QString("unexpected http response: -->%1<--").arg(response));
        return QString();
    }

    QString result = regex.cap(1);
    LOG(VB_RECORD, LOG_DEBUG, loc + QString("got: -->%1<--").arg(result));
    return result;
}
bool CetonStreamHandler::TuneProgram(uint program)
{
    LOG(VB_RECORD, LOG_INFO, LOC + QString("TuneProgram(%1)").arg(program));

    QStringList program_list = GetProgramList();
    if (!program_list.contains(QString::number(program)))
    {
        LOG(VB_RECORD, LOG_ERR, LOC + 
        QString("TuneProgram(%1) - Requested program not in the program list").arg(program));
        return false;
    };


    _last_program = program;

    QUrl params;
    params.addQueryItem("instance_id", QString::number(_tuner));
    params.addQueryItem("program", QString::number(program));

    QString response;
    uint status;
    bool result = HttpRequest(
        "POST", "/program_request.cgi", params, response, status);

    if (!result)
    {
        LOG(VB_RECORD, LOG_ERR, LOC +
            QString("TuneProgram() - HTTP status = %1 - response = %2")
            .arg(status).arg(response));
    }

    return result;
}
bool CetonStreamHandler::TuneVChannel(const QString &vchannel)
{
    if ((vchannel != "0") && (_last_vchannel != "0"))
        ClearProgramNumber();

    LOG(VB_RECORD, LOG_INFO, LOC + QString("TuneVChannel(%1)").arg(vchannel));

    _last_vchannel = vchannel;

    QUrl params;
    params.addQueryItem("instance_id", QString::number(_tuner));
    params.addQueryItem("channel", vchannel);

    QString response;
    uint status;
    bool result = HttpRequest(
        "POST", "/channel_request.cgi", params, response, status);

    if (!result)
    {
        LOG(VB_RECORD, LOG_ERR, LOC +
            QString("TuneVChannel() - HTTP status = %1 - response = %2")
            .arg(status).arg(response));
    }

    return result;
}
 // social
 void sendSocial(QString socialNetwork, QString socialAction, QString socialActionTarget) const {
   QUrl params = build_metric("social");
   params.addQueryItem("sn", socialNetwork);
   params.addQueryItem("sa", socialAction);
   params.addQueryItem("st", socialActionTarget);
   send_metric(params);
 }
bool CetonStreamHandler::PerformTuneVChannel(const QString &vchannel)
{
    LOG(VB_RECORD, LOG_INFO, LOC + QString("PerformTuneVChannel(%1)")
        .arg(vchannel));

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QUrl params;
#else
    QUrlQuery params;
#endif
    params.addQueryItem("instance_id", QString::number(_tuner));
    params.addQueryItem("channel", vchannel);

    QString response;
    uint status;
    bool result = HttpRequest(
        "POST", "/channel_request.cgi", params, response, status);

    if (!result)
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("PerformTuneVChannel() - HTTP status = %1 - response = %2")
            .arg(status).arg(response));
    }

    return result;
}
bool ActivatePage::checkUserActivated(int user_id)
{
    serverQueryFinished = false;
    serverQueryError = false;
    label_message->setText("Logging in...");
    QString url( "https://screencloud.net/1.0/users/check_activated.xml");

    QString token, tokenSecret;

    // create a request parameters map
    QUrl bodyParams;
    bodyParams.addQueryItem("user_id", QString::number(user_id));
    bodyParams.addQueryItem("oauth_version", "1.0");
    bodyParams.addQueryItem("oauth_signature_method", "PLAINTEXT");
    bodyParams.addQueryItem("oauth_consumer_key", CONSUMER_KEY_SCREENCLOUD);
    bodyParams.addQueryItem("oauth_signature", CONSUMER_SECRET_SCREENCLOUD);

    QByteArray body = bodyParams.encodedQuery();

    QNetworkRequest request;
    request.setUrl(QUrl(url));
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    manager->post(request, body);
    return true;
}
Exemple #15
0
void SoundCloud::checkUrl(const QUrl &webUrl) {
    QUrl url;

    if (webUrl.hasQueryItem("client_id")) {
        url = webUrl;
        url.setHost("api.soundcloud.com");
    }
    else {
        url.setUrl("http://api.soundcloud.com/resolve.json");
#if QT_VERSION >= 0x050000
        QUrlQuery query(url);
        query.addQueryItem("url", webUrl.toString());
        query.addQueryItem("client_id", CLIENT_ID);
        url.setQuery(query);
#else
        url.addQueryItem("url", webUrl.toString());
        url.addQueryItem("client_id", CLIENT_ID);
#endif
    }

    QNetworkRequest request(url);
    QNetworkReply *reply = this->networkAccessManager()->get(request);
    this->connect(reply, SIGNAL(finished()), this, SLOT(checkUrlIsValid()));
    this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater()));
}
void CWebCache::RequestRandom()
{
	qDebug("RequestRandom()");

	quint32 nIndex = rand() % m_lCaches.size();

	if(m_lCaches[nIndex].CanQuery())
	{
		CancelRequests();

		m_bRequesting = true;

		QUrl u = m_lCaches.at(nIndex).m_sUrl;
		u.addQueryItem("get", "1");
		u.addQueryItem("hostfile", "1");
		u.addQueryItem("net", "gnutella2");
		u.addQueryItem("client", "BROV1.0");

		systemLog.postLog(tr("Querying ").arg(u.toString()), LogSeverity::Debug);
		//qDebug("Querying " + u.toString().toAscii());

		m_lCaches[nIndex].m_tLastQuery = time(0);
		QNetworkRequest req(u);
		req.setRawHeader("User-Agent", "G2Core/0.1");

		m_pRequest = new QNetworkAccessManager();
		connect(m_pRequest, SIGNAL(finished(QNetworkReply*)), this, SLOT(OnRequestComplete(QNetworkReply*)));
		m_pReply = m_pRequest->get(req);
	}
Exemple #17
0
void Snap2ChatAPISimple::request(QVariant params)
{
	QUrl dataToSend;

	QVariantMap paramsMap = params.toMap();

	const QString endpoint		= paramsMap.value("endpoint").toString();

	if(endpoint == "listen")
	{
		dataToSend.addQueryItem("userid", paramsMap.value("userid").toString());
	}
	else if(endpoint == "login" || endpoint == "register")
	{
		dataToSend.addQueryItem("username", paramsMap.value("username").toString());
		dataToSend.addQueryItem("password", paramsMap.value("password").toString());
	}

	QNetworkRequest request;
	request.setUrl(QUrl(PROTOCOL + API_ENDPOINT + endpoint + ".php"));
	request.setHeader(QNetworkRequest::ContentTypeHeader, CONTENT_TYPE);

	QNetworkReply* reply = m_manager.post(request, dataToSend.encodedQuery());
	reply->setProperty("endpoint", endpoint);
	connect (reply, SIGNAL(finished()), this, SLOT(onComplete()));
}
	QUrl LongPollManager::GetURLTemplate () const
	{
		QUrl url = LPURLTemplate_;
		url.addQueryItem ("ts", QString::number (LPTS_));
		url.addQueryItem ("wait", QString::number (WaitTimeout_));
		return url;
	}
Exemple #19
0
void requester::go()
{
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    connect(manager, SIGNAL(finished(QNetworkReply*)),
        this, SLOT(replyFinished(QNetworkReply*)));

    QUrl url;
    url.setScheme("http");
    url.setHost("192.168.121.129");
    url.setPath("/cgi-bin/tilecache.cgi");
    url.setQueryDelimiters('=', '&');
    url.addQueryItem("layers", "osm");
    url.addQueryItem("service", "mapnik");
    url.addQueryItem("version", "1.1.1");
    url.addQueryItem("request", "GetMap");
    url.addQueryItem("bbox", "-78271.51696402048, 6653078.941941741, 0.0, 6731350.458905762");

    QNetworkRequest request(url);

    timer_.start();

    counter_ = 100;
    for (int i = 0; i < counter_; ++i)
        manager->get(request);                                      
}
Exemple #20
0
void OAuthenticator::StartAuthorisation(const QString& oauth_endpoint,
                                        const QString& token_endpoint,
                                        const QString& scope) {
  token_endpoint_ = QUrl(token_endpoint);
  LocalRedirectServer* server = new LocalRedirectServer(this);
  server->Listen();

  QUrl url = QUrl(oauth_endpoint);
  url.addQueryItem("response_type", "code");
  url.addQueryItem("client_id", client_id_);
  QUrl redirect_url;

  const QString port = QString::number(server->url().port());

  if (redirect_style_ == RedirectStyle::REMOTE) {
    redirect_url = QUrl(kRemoteURL);
    redirect_url.addQueryItem("port", port);
  } else if (redirect_style_ == RedirectStyle::REMOTE_WITH_STATE) {
    redirect_url = QUrl(kRemoteURL);
    url.addQueryItem("state", port);
  } else {
    redirect_url = server->url();
  }

  url.addQueryItem("redirect_uri", redirect_url.toString());
  url.addQueryItem("scope", scope);

  NewClosure(server, SIGNAL(Finished()), this, &OAuthenticator::RedirectArrived,
             server, redirect_url);

  QDesktopServices::openUrl(url);
}
Exemple #21
0
/*!
    Starts fetching
    \param id Tweet ID
    \param respType Response type
    \remarks Async
 */
void QTweetStatusShow::fetch(qint64 id, ResponseType respType, bool trimUser, bool includeEntities)
{
    Q_ASSERT(oauthTwitter() != 0);

    QUrl url;

    if (respType == QTweetNetBase::JSON)
        url.setUrl("http://api.twitter.com/1/statuses/show.json");
    else
        url.setUrl("http://api.twitter.com/1/statuses/show.xml");

    url.addQueryItem("id", QString::number(id));

    if (trimUser)
        url.addQueryItem("trim_user", "true");

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error()));
}
void
StravaUploadDialog::requestLogin()
{
    progressLabel->setText(tr("Login..."));
    progressBar->setValue(5);

    QString username = appsettings->cvalue(mainWindow->cyclist, GC_STRUSER).toString();
    QString password = appsettings->cvalue(mainWindow->cyclist, GC_STRPASS).toString();

    QNetworkAccessManager networkMgr;
    QEventLoop eventLoop;
    connect(&networkMgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestLoginFinished(QNetworkReply*)));
    connect(&networkMgr, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));

    QByteArray data;
    /*data += "{\"email\": \"" + username + "\",";
    data += "\"password\": \"" + password + "\",";
    data += "\"agreed_to_terms\": \"true\"}";*/

    QUrl params;

    params.addQueryItem("email", username);
    params.addQueryItem("password",password);
    params.addQueryItem("agreed_to_terms", "true");
    data = params.encodedQuery();

    QUrl url = QUrl( STRAVA_URL_SSL + "/authentication/login");
    QNetworkRequest request = QNetworkRequest(url);
    //request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

    request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");

    networkMgr.post( request, data);
    eventLoop.exec();
}
		void SongSearch::getNextSearch()
		{
			if(currentSite < searchSites.size())
			{
				QUrl request = searchSites[currentSite].searchUrl;
				request.addQueryItem(searchSites[currentSite].queryParamName, ui->queryField->text());

				int searchForIndex = searchForGroup->checkedId() - 1;
				if(searchForIndex >= 0 && searchForIndex < searchSites[currentSite].searchForParamNames.size())
					request.addQueryItem(searchSites[currentSite].searchForParamNames[searchForIndex],
										 searchSites[currentSite].searchForParamValues[searchForIndex]);

				for(int i = 0; i < searchSites[currentSite].additionalParams.count(); i++)
				{
					QStringList paramValue = searchSites[currentSite].additionalParams[i].split("=");
					if(paramValue.count() == 2)
						request.addQueryItem(paramValue[0], paramValue[1]);
				}

				httpHandler.sendRequest(searchSites[currentSite].requestType, request);
			}
			else
			{
				ui->searchButton->setEnabled(true);
				ui->resultTable->setSortingEnabled(true);
				ui->searchIcon->setMovie(new QMovie(skinMgr ? skinMgr->getFileFromSkin("search.png") : ""));
				ui->searchIcon->movie()->start();
			}
		}
 // appview
 void sendAppview(QString appName, QString appVersion = "", QString screenName = "") const {
   QUrl params = build_metric("appview");
   if (_appName.size()) params.addQueryItem("an", _appName);
   else if (appName.size()) params.addQueryItem("an", appName);
   if (_appVersion.size()) params.addQueryItem("av", _appVersion);
   else if (appVersion.size()) params.addQueryItem("av", appVersion);
   if (screenName.size()) params.addQueryItem("cd", screenName);
   send_metric(params);
 }
void SubsonicLibraryScanner::GetAlbumList(int offset) {
  QUrl url = service_->BuildRequestUrl("getAlbumList2");
  url.addQueryItem("type", "alphabeticalByName");
  url.addQueryItem("size", QString::number(kAlbumChunkSize));
  url.addQueryItem("offset", QString::number(offset));
  QNetworkReply* reply = service_->Send(url);
  NewClosure(reply, SIGNAL(finished()), this,
             SLOT(OnGetAlbumListFinished(QNetworkReply*, int)), reply, offset);
}
void ChangelogDialog::showEvent(QShowEvent *e)
{
    busyOverlay->show();
    QNetworkRequest getChangelogReq;
    QUrl url = QUrl("https://api.screencloud.net/1.0/updates/changelog");
    url.addQueryItem("installed-version", VERSION);
    url.addQueryItem("os", OS_SHORTNAME);
    getChangelogReq.setUrl(url);
    netManager.get(getChangelogReq);
}
Exemple #27
0
QNetworkRequest RequestPrivate::buildRequest(QUrl u, bool authRequired) {
    if (authRequired) {
#if QT_VERSION >= 0x050000
        QUrlQuery query(u);
    
        if ((!query.hasQueryItem("key")) && (!apiKey.isEmpty())) {
            query.addQueryItem("key", apiKey);
        }
    
        if ((!query.hasQueryItem("access_token")) && (!accessToken.isEmpty())) {
            query.addQueryItem("access_token", accessToken);
        }
    
        u.setQuery(query);
#else
        if ((!u.hasQueryItem("key")) && (!apiKey.isEmpty())) {
            u.addQueryItem("key", apiKey);
        }
    
        if ((!u.hasQueryItem("access_token")) && (!accessToken.isEmpty())) {
            u.addQueryItem("access_token", accessToken);
        }
#endif
    }
#ifdef QYOUTUBE_DEBUG
    qDebug() << "QYouTube::RequestPrivate::buildRequest" << u;
#endif
    QNetworkRequest request(u);
    
    switch (operation) {
    case Request::PostOperation:
    case Request::PutOperation:
        switch (data.type()) {
        case QVariant::Map:
        case QVariant::List:
        case QVariant::StringList:
            request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
            break;
        default:
            request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
            break;
        }
        
        break;
    default:
        break;
    }
    
    if (!headers.isEmpty()) {
        addRequestHeaders(&request, headers);
    }
    
    return request;
}
void SubsonicLibraryScanner::GetAlbum(const QString& id) {
  QUrl url = service_->BuildRequestUrl("getAlbum");
  url.addQueryItem("id", id);
  if (service_->IsAmpache()) {
    url.addQueryItem("ampache", "1");
  }
  QNetworkReply* reply = service_->Send(url);
  NewClosure(reply, SIGNAL(finished()), this,
             SLOT(OnGetAlbumFinished(QNetworkReply*)), reply);
  pending_requests_.insert(reply);
}
Exemple #29
0
// Format an URL for a XML request
static inline QUrl xmlRequest(const QString &host, const QString &request, int page = -1)
{
    QUrl url;
    url.setScheme(QLatin1String("http"));
    url.setHost(host);
    url.setPath(QLatin1Char('/') + request);
    url.addQueryItem(QLatin1String("format"), QLatin1String("xml"));
    if (page >= 0)
        url.addQueryItem(QLatin1String("page"), QString::number(page));
    return url;
}
QNetworkReply* NetBalanceGetter::post_req(){
	QUrl url = QUrl(QString("http://cabinet.telecom.mipt.ru/"));
	
	QUrl data;
	data.addQueryItem("login", QString::number(account));
	data.addQueryItem("password",password);

	QNetworkRequest request(url);
	request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
	return manager->post(request, data.encodedQuery());
}