Beispiel #1
0
void URITests::uriTests()
{
    SendCoinsRecipient rv;
    QUrl uri;
    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?req-dontexist="));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?dontexist="));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?label=Some Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.label == QString("Some Example Address"));
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=0.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100000);

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100100000);

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=100&label=Some Example"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.amount == 10000000000LL);
    QVERIFY(rv.label == QString("Some Example"));

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.label == QString());

    QVERIFY(GUIUtil::parseBitcoinURI("chaincoin://XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address", &rv));
    QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
    QVERIFY(rv.label == QString());

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?req-message=Some Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000&label=Some Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000.0&label=Some Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
}
Beispiel #2
0
void URITests::uriTests()
{
    SendCoinsRecipient rv;
    QUrl uri;
    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?req-dontexist="));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?dontexist="));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?label=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.label == QString("Wikipedia Example Address"));
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?amount=0.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100000);

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?amount=1.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100100000);

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?amount=100&label=Wikipedia Example"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.amount == 10000000000LL);
    QVERIFY(rv.label == QString("Wikipedia Example"));

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?message=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.label == QString());

    QVERIFY(GUIUtil::parseBitcoinURI("litecoin://LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?message=Wikipedia Example Address", &rv));
    QVERIFY(rv.address == QString("LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2"));
    QVERIFY(rv.label == QString());

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?req-message=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?amount=1,000&label=Wikipedia Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("litecoin:LEr4HnaeFWYhBmGxCfP2po1NPRueIk8kM2?amount=1,000.0&label=Wikipedia Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
}
Beispiel #3
0
void URITests::uriTests()
{
    SendCoinsRecipient rv;
    QUrl uri;
    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.label == QString("Wikipedia Example Address"));
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100000);

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100100000);

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.amount == 10000000000LL);
    QVERIFY(rv.label == QString("Wikipedia Example"));

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.label == QString());

    QVERIFY(GUIUtil::parseBitcoinURI("crowncoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
    QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
    QVERIFY(rv.label == QString());

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("crowncoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
}
Beispiel #4
0
void URITests::uriTests()
{
    SendCoinsRecipient rv;
    QUrl uri;
    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?req-dontexist="));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?dontexist="));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?label=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.label == QString("Wikipedia Example Address"));
    QVERIFY(rv.amount == 0);

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?amount=0.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100000);

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?amount=1.001"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.label == QString());
    QVERIFY(rv.amount == 100100000);

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?amount=100&label=Wikipedia Example"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.amount == 10000000000LL);
    QVERIFY(rv.label == QString("Wikipedia Example"));

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?message=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.label == QString());

    QVERIFY(GUIUtil::parseBitcoinURI("naturacoin://DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?message=Wikipedia Example Address", &rv));
    QVERIFY(rv.address == QString("DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM"));
    QVERIFY(rv.label == QString());

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?req-message=Wikipedia Example Address"));
    QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?amount=1,000&label=Wikipedia Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));

    uri.setUrl(QString("naturacoin:DJ7zB7c5BsB9UJLy1rKQtY7c6CQfGiaRLM?amount=1,000.0&label=Wikipedia Example"));
    QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
}
QUrl PouarQuick::randomfile(QUrl url)
{
	QDir dir(url.toLocalFile());
	QFileInfoList dirs = QFileInfoList(dir.entryInfoList(QDir::Files));
	if(dirs.size()>0)
	{
		dir.setPath(dirs.at(arc4random_uniform(dirs.size())).filePath());
		url.setUrl("file://"+dir.absolutePath());
	}
	else
		url.setUrl("file:///dev/null");
	return url;
}
Beispiel #6
0
/**
 * @brief Starts network requests to download infos from TMDb
 * @param id TMDb movie ID
 * @param concert Concert object
 * @param infos List of infos to load
 * @see TMDbConcerts::loadFinished
 * @see TMDbConcerts::loadCastsFinished
 * @see TMDbConcerts::loadTrailersFinished
 * @see TMDbConcerts::loadImagesFinished
 * @see TMDbConcerts::loadReleasesFinished
 */
void TMDbConcerts::loadData(QString id, Concert *concert, QList<int> infos)
{
    qDebug() << "Entered, id=" << id << "concert=" << concert->name();
    concert->setTmdbId(id);
    m_infosToLoad = infos;
    m_currentConcert = concert;
    m_currentConcert->clear(infos);
    m_currentId = id;
    m_loadDoneFired = false;
    m_loadsLeft.clear();

    QUrl url;
    QNetworkRequest request;
    request.setRawHeader("Accept", "application/json");

    // Infos
    m_loadsLeft.append(DataInfos);
    url.setUrl(QString("http://api.themoviedb.org/3/movie/%1?api_key=%2&language=%3").arg(id).arg(m_apiKey).arg(m_language));
    request.setUrl(url);
    m_loadReply = this->qnam()->get(QNetworkRequest(request));
    connect(m_loadReply, SIGNAL(finished()), this, SLOT(loadFinished()));

    // Trailers
    if (m_infosToLoad.contains(ConcertScraperInfos::Trailer)) {
        m_loadsLeft.append(DataTrailers);
        url.setUrl(QString("http://api.themoviedb.org/3/movie/%1/trailers?api_key=%2").arg(m_currentId).arg(m_apiKey));
        request.setUrl(url);
        m_trailersReply = this->qnam()->get(QNetworkRequest(request));
        connect(m_trailersReply, SIGNAL(finished()), this, SLOT(loadTrailersFinished()));
    }

    // Images
    if (m_infosToLoad.contains(ConcertScraperInfos::Poster) || m_infosToLoad.contains(ConcertScraperInfos::Backdrop)) {
        m_loadsLeft.append(DataImages);
        url.setUrl(QString("http://api.themoviedb.org/3/movie/%1/images?api_key=%2").arg(m_currentId).arg(m_apiKey));
        request.setUrl(url);
        m_imagesReply = this->qnam()->get(QNetworkRequest(request));
        connect(m_imagesReply, SIGNAL(finished()), this, SLOT(loadImagesFinished()));
    }

    // Releases
    if (m_infosToLoad.contains(ConcertScraperInfos::Certification)) {
        m_loadsLeft.append(DataReleases);
        url.setUrl(QString("http://api.themoviedb.org/3/movie/%1/releases?api_key=%2").arg(m_currentId).arg(m_apiKey));
        request.setUrl(url);
        m_releasesReply = this->qnam()->get(QNetworkRequest(request));
        connect(m_releasesReply, SIGNAL(finished()), this, SLOT(loadReleasesFinished()));
    }
}
Beispiel #7
0
void ParserResRobot::getTimeTableForStation(const Station &currentStation,
                                            const Station &directionStation,
                                            const QDateTime &dateTime,
                                            ParserAbstract::Mode mode,
                                            int trainrestrictions)
{
    if (currentRequestState != FahrplanNS::noneRequest)
        return;
    currentRequestState = FahrplanNS::getTimeTableForStationRequest;

    timetableSearchMode = mode;

    QUrl url;
    if (mode == Arrival)
        url.setUrl(baseURL + QLatin1String("/arrivalBoard"));
    else
        url.setUrl(baseURL + QLatin1String("/departureBoard"));
#if defined(BUILD_FOR_QT5)
    QUrlQuery query;
#else
    QUrl query;
#endif
    query.addQueryItem("key", timetableAPIKey);
    query.addQueryItem("id", stationIDv2(currentStation.id.toString()));
    if (directionStation.valid)
        query.addQueryItem("direction", stationIDv2(directionStation.id.toString()));
    query.addQueryItem("date", dateTime.toString("yyyy-MM-dd"));
    query.addQueryItem("time", dateTime.toString("hh:mm"));
    query.addQueryItem("maxJourneys", "30"); // Max number of results
    query.addQueryItem("passlist", "0"); // We don't need any intermediate stops in the result
    QString formattedRestrictions(formatRestrictions(trainrestrictions));
    if (!formattedRestrictions.isEmpty())
        query.addQueryItem("products", formattedRestrictions);
    if (QLocale().language() == QLocale::Swedish)
        query.addQueryItem("lang", "sv");
    else if (QLocale().language() == QLocale::German)
        query.addQueryItem("lang", "de");
    else
        query.addQueryItem("lang", "en");
    query.addQueryItem("format", "json");

#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    qDebug() << "Searching for timetable:" << url.toString();
    sendHttpRequest(url);
}
Beispiel #8
0
void CoverHelper::realDownload() {
    QUrl url;
    url.setUrl("http://images.grooveshark.com/static/albums/500_" + QString::fromStdString(currentCover));
    QNetworkRequest request;
    request.setUrl(url);
    manager->get(request);
}
Beispiel #9
0
  QString serviceUrl( const QgsServerRequest &request, const QgsProject *project )
  {
    QUrl href;
    if ( project )
    {
      href.setUrl( QgsServerProjectUtils::wfsServiceUrl( *project ) );
    }

    // Build default url
    if ( href.isEmpty() )
    {

      static QSet<QString> sFilter
      {
        QStringLiteral( "REQUEST" ),
        QStringLiteral( "VERSION" ),
        QStringLiteral( "SERVICE" ),
      };

      href = request.originalUrl();
      QUrlQuery q( href );

      for ( auto param : q.queryItems() )
      {
        if ( sFilter.contains( param.first.toUpper() ) )
          q.removeAllQueryItems( param.first );
      }

      href.setQuery( q );
    }

    return  href.toString();
  }
Beispiel #10
0
void DecoderHandler::doStart(bool result)
{
    doOperationStop();

    QUrl url;
    if (QFileInfo(m_meta->Filename()).isAbsolute())
        url = QUrl::fromLocalFile(m_meta->Filename());
    else
        url.setUrl(m_meta->Filename());

    if (m_state == LOADING && result)
    {
        for (int ii = 0; ii < m_playlist.size(); ii++)
            LOG(VB_PLAYBACK, LOG_INFO, QString("Track %1 = %2")
                .arg(ii) .arg(m_playlist.get(ii)->File()));
        next();
    }
    else
    {
        if (m_state == STOPPED)
        {
            doFailed(url, "Could not get playlist");
        }
    }
}
Beispiel #11
0
QmcUnit *QmcUnit::loadUnit(QDataStream &stream, QQmlEngine *engine, QmcLoader *loader, const QUrl &loadedUrl)
{
    //qDebug() << "Loading" << loadedUrl;
    QmcUnitHeader *header = new QmcUnitHeader;

    bool ret = readData((char *)header, sizeof(QmcUnitHeader), stream);
    if (!ret || !checkHeader(header)) {
        delete header;
        return NULL;
    }

    QString name;
    QString urlString;
    if (!readString(name, stream) || !readString(urlString, stream)) {
        delete header;
        return NULL;
    }

    QUrl url;
    url.setUrl(urlString);

    QmcUnit *unit = new QmcUnit(header, url, urlString, engine, loader, name, loadedUrl);

    if (unit->loadUnitData(stream))
        return unit;

    unit->blob->release();
    return NULL;
}
Beispiel #12
0
/*
 * Add message request set
 */
void ElisaServer::addMessage(QString body, double latitude, double longitude)
{
    //check if user is already logged
    if(m_nickname!=""){
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);

        //set urls
        QUrl url;
        url.setUrl("http://projectelisa.altervista.org/main/post/?x="+QString::number(latitude,'g',10)+"&y="+QString::number(longitude,'g',10)+"&z=0&nick="+temp_nickname+"&pass="******"body="+body);

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

        //define callback
        QNetworkReply * r;
        r = manager->post(request, postData);
        connect(r,SIGNAL(finished()),this,SLOT(addMessageFinished()));
    } else {
        emit addMessageReply("denied");
    }

}
void MpFetcherTestAppView::playNPVSong()
{
    QUrl url;

    url.setUrl("appto://10207C62?activityname=MusicNowPlayingView&launchtype=standalone&uri=" + mResultEdit->text() );
    if(mReq){
        delete mReq;
        mReq = 0;
    }
    mReq = mAppMgr.create(url);    
    if (mReq == NULL)
    {
        // No handlers for the URI
        return;
    }
    
    mReq->setBackground(false);

    // Send the request
   bool res = mReq->send();
   if  (!res) 
   {
       // Request failed. 
      int error = mReq->lastError();

      // Handle error
   }
 
}
Beispiel #14
0
void UIImageViewer::openWithExternalViewer() {
    QUrl url;
    if (currentImage != -1 && imagesToDisplay.count() > currentImage) {
        url.setUrl(QString("file:///%1").arg(imagesToDisplay.at(currentImage)));
        QDesktopServices::openUrl(url);
    }
}
Beispiel #15
0
void DecoderHandler::start(Metadata *mdata)
{
    m_state = LOADING;

    m_playlist.clear();
    m_meta = mdata;
    m_playlist_pos = -1;
    m_redirects = 0;

    QUrl url;
    if (QFileInfo(mdata->Filename()).isAbsolute())
        url = QUrl::fromLocalFile(mdata->Filename());
    else
        url.setUrl(mdata->Filename());

    bool result = createPlaylist(url);
    if (m_state == LOADING && result)
    {
        for (int ii = 0; ii < m_playlist.size(); ii++)
            VERBOSE(VB_PLAYBACK, QString("Track %1 = %2")
                .arg(ii)
                .arg(m_playlist.get(ii)->File()));
        next();
    }
    else
    {
        if (m_state != STOPPED)
        {
            doFailed(url, "Could not get playlist");
        }
    }
}
Beispiel #16
0
  QUrl serviceUrl( const QgsServerRequest &request, const QgsProject *project )
  {
    QUrl href;
    if ( project )
    {
      href.setUrl( QgsServerProjectUtils::wmsServiceUrl( *project ) );
    }

    // Build default url
    if ( href.isEmpty() )
    {
      href = request.url();
      QUrlQuery q( href );

      q.removeAllQueryItems( QStringLiteral( "REQUEST" ) );
      q.removeAllQueryItems( QStringLiteral( "VERSION" ) );
      q.removeAllQueryItems( QStringLiteral( "SERVICE" ) );
      q.removeAllQueryItems( QStringLiteral( "LAYERS" ) );
      q.removeAllQueryItems( QStringLiteral( "SLD_VERSION" ) );
      q.removeAllQueryItems( QStringLiteral( "_DC" ) );

      href.setQuery( q );
    }

    return  href;
  }
Beispiel #17
0
void SM_QDropbox::requestMetadata(QString file, bool blocking)
{
    clearError();

    timestamp = QDateTime::currentMSecsSinceEpoch()/1000;

    QUrl url;
    url.setUrl(apiurl.toString());

    QUrlQuery urlQuery;
    urlQuery.addQueryItem("oauth_consumer_key",_appKey);
    urlQuery.addQueryItem("oauth_nonce", nonce);
    urlQuery.addQueryItem("oauth_signature_method", signatureMethodString());
    urlQuery.addQueryItem("oauth_timestamp", QString::number(timestamp));
    urlQuery.addQueryItem("oauth_token", oauthToken);
    urlQuery.addQueryItem("oauth_version", _version);

    QString signature = oAuthSign(url);
    urlQuery.addQueryItem("oauth_signature", QUrl::toPercentEncoding(signature));

    url.setQuery(urlQuery);
    url.setPath(QString("/%1/metadata/%2").arg(_version.left(1), file));

    int reqnr = sendRequest(url);
    if(blocking)
    {
        requestMap[reqnr].type = SM_DROPBOX_REQ_BMETADA;
        startEventLoop();
    }
    else
        requestMap[reqnr].type = SM_DROPBOX_REQ_METADAT;
    //SM_Dropbox_FileInfo fi(_tempJson.strContent(), this);
    return;
}
Beispiel #18
0
void SM_QDropbox::requestSharedLink(QString file, bool blocking)
{
    clearError();

    QUrl url;
    url.setUrl(apiurl.toString());

    QUrlQuery urlQuery;
    urlQuery.addQueryItem("oauth_consumer_key",_appKey);
    urlQuery.addQueryItem("oauth_nonce", nonce);
    urlQuery.addQueryItem("oauth_signature_method", signatureMethodString());
    urlQuery.addQueryItem("oauth_timestamp", QString::number(timestamp));
    urlQuery.addQueryItem("oauth_token", oauthToken);
    urlQuery.addQueryItem("oauth_version", _version);

    QString signature = oAuthSign(url);
    urlQuery.addQueryItem("oauth_signature", QUrl::toPercentEncoding(signature));

    url.setPath(QString("/%1/shares/%2").arg(_version.left(1), file));
    url.setQuery(urlQuery);

    int reqnr = sendRequest(url);
    if(blocking)
    {
        requestMap[reqnr].type = SM_DROPBOX_REQ_BSHRDLN;
        startEventLoop();
    }
    else
        requestMap[reqnr].type = SM_DROPBOX_REQ_SHRDLNK;

    return;
}
Beispiel #19
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()));
}
Beispiel #20
0
void SM_QDropbox::requestAccountInfo(bool blocking)
{
    clearError();

    timestamp = QDateTime::currentMSecsSinceEpoch()/1000;

    QUrl url;
    url.setUrl(apiurl.toString());

    QUrlQuery urlQuery;
    urlQuery.addQueryItem("oauth_consumer_key",_appKey);
    urlQuery.addQueryItem("oauth_nonce", nonce);
    urlQuery.addQueryItem("oauth_signature_method", signatureMethodString());
    urlQuery.addQueryItem("oauth_timestamp", QString::number(timestamp));
    urlQuery.addQueryItem("oauth_token", oauthToken);
    urlQuery.addQueryItem("oauth_version", _version);

    QString signature = oAuthSign(url);
    urlQuery.addQueryItem("oauth_signature", QUrl::toPercentEncoding(signature));

    url.setPath(QString("/%1/account/info").arg(_version.left(1)));
    url.setQuery(urlQuery);

    int reqnr = sendRequest(url);
    if(blocking)
    {
        requestMap[reqnr].type = SM_DROPBOX_REQ_BACCINF;
        startEventLoop();
    }
    else
        requestMap[reqnr].type = SM_DROPBOX_REQ_ACCINFO;
    return;
}
Beispiel #21
0
bool Utils::isValidLocalPath(const QString &value)
{
	QUrl		url;
	
	url.setUrl(value);
	return (url.isValid() && (url.isRelative() || url.scheme().toLower() == "file") );
}
void MpFetcherTestAppView::launchHomeScreen()
{
    QUrl url;
    
    url.setUrl("appto://10207C62?activityname=MusicMainView&launchtype=standalone");
    if(mReq){
        delete mReq;
        mReq = 0;
    }
    mReq = mAppMgr.create(url);    
    if (mReq == NULL)
    {
        // No handlers for the URI
        return;
    }
    
    mReq->setBackground(false);

    // Send the request
   bool res = mReq->send();
   if  (!res) 
   {
       // Request failed. 
      int error = mReq->lastError();

      // Handle error
   }
 
}
/*!
  \brief Format the payload and set it through the Smart URI base class.
  */
void NdefNfcStoreLinkRecord::updatePayload()
{
    QUrl tagStoreUri;
    const int numIds = m_appIds.size();
    // One app store only,
    // or same app id for Nokia Store on different platforms
    // -> Generate direct link
    if (numIds == 1) {
        // Get the platform and ID of the specified
        // app and generate a direct link
        QHash<AppStore, QString>::const_iterator i = m_appIds.constBegin();
        while (i != m_appIds.constEnd()) {
            // Only one element in the hash map, but still
            // need to iterate over it to get it.
            tagStoreUri = generateStoreLink(i.key(), i.value());
            i++;
        }
    } else if (numIds > 1) {
        // Multiple app stores
        // -> Use nfcinteractor.com script
        tagStoreUri = generateMultiStoreLink();
    }

    // No app id set
    //qDebug() << "Store URI before check: " << tagStoreUri;
    if (tagStoreUri.isEmpty()) {
        //qDebug() << "isEmpty";
        tagStoreUri.setUrl("http://store.ovi.com");
    }

    // Set link to base class
    NdefNfcSmartUriRecord::setUri(tagStoreUri);
}
Beispiel #24
0
/**
 * @brief Searches for a movie
 * @param searchStr The Movie name/search string
 * @see OFDb::searchFinished
 */
void OFDb::search(QString searchStr)
{
    qDebug() << "Entered, searchStr=" << searchStr;

    QString encodedSearch = Helper::toLatin1PercentEncoding(searchStr);

    QUrl url;
    QRegExp rxId("^id\\d+$");
    if (rxId.exactMatch(searchStr))
        url.setUrl(QString("http://www.ofdbgw.org/movie/%1").arg(searchStr.mid(2)).toUtf8());
    else
        url.setUrl(QString("http://www.ofdbgw.org/search/%1").arg(encodedSearch).toUtf8());
    QNetworkReply *reply = qnam()->get(QNetworkRequest(url));
    reply->setProperty("searchString", searchStr);
    reply->setProperty("notFoundCounter", 0);
    connect(reply, SIGNAL(finished()), this, SLOT(searchFinished()));
}
void BtTabHtmlDialog::setHtml(const QString& html, const QUrl& baseUrl) {
    QUrl url = baseUrl;
    if (url == QUrl()) {
        QString dir = "file://" + util::filesystem::DirectoryUtil::getIconDir().path();
        url.setUrl(dir);
    }
    webView()->setHtml(html, url);
}
Beispiel #26
0
/**
 * @brief Searches for a movie
 * @param searchStr The Movie name/search string
 * @see TMDb::searchFinished
 */
void TMDb::search(QString searchStr)
{
    qDebug() << "Entered, searchStr=" << searchStr;
    searchStr = searchStr.replace("-", " ");
    QString encodedSearch = QUrl::toPercentEncoding(searchStr);
    QString searchTitle;
    QString searchYear;
    QUrl url;
    QString includeAdult = (Settings::instance()->showAdultScrapers()) ? "true" : "false";
    QRegExp rx("^tt\\d+$");
    QRegExp rxTmdbId("^id\\d+$");
    if (rx.exactMatch(searchStr)) {
        url.setUrl(QString("http://api.themoviedb.org/3/movie/%1?api_key=%2&language=%3&include_adult=%4")
                   .arg(searchStr)
                   .arg(TMDb::apiKey())
                   .arg(m_language)
                   .arg(includeAdult));
    } else if (rxTmdbId.exactMatch(searchStr)) {
        url.setUrl(QString("http://api.themoviedb.org/3/movie/%1?api_key=%2&language=%3&include_adult=%4")
                   .arg(searchStr.mid(2))
                   .arg(TMDb::apiKey())
                   .arg(m_language)
                   .arg(includeAdult));
    } else {
        url.setUrl(QString("http://api.themoviedb.org/3/search/movie?api_key=%1&language=%2&include_adult=%3&query=%4")
                   .arg(TMDb::apiKey())
                   .arg(m_language)
                   .arg(includeAdult)
                   .arg(encodedSearch));
        QList<QRegExp> rxYears;
        rxYears << QRegExp("^(.*) \\((\\d{4})\\)$") << QRegExp("^(.*) (\\d{4})$") << QRegExp("^(.*) - (\\d{4})$");
        foreach (QRegExp rxYear, rxYears) {
            rxYear.setMinimal(true);
            if (rxYear.exactMatch(searchStr)) {
                searchTitle = rxYear.cap(1);
                searchYear = rxYear.cap(2);
                url.setUrl(QString("http://api.themoviedb.org/3/search/movie?api_key=%1&language=%2&include_adult=%3&year=%4&query=%5")
                           .arg(TMDb::apiKey())
                           .arg(m_language)
                           .arg(includeAdult)
                           .arg(searchYear)
                           .arg(QString(QUrl::toPercentEncoding(searchTitle))));
                break;
            }
        }
    }
Beispiel #27
0
int Url::setUrl ( lua_State * L )// ( const QString & url )
//( const QString & url, ParsingMode parsingMode )
{
	QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
	//QString* url = ValueInstaller2<QString>::check( L, 2 );
	if( Util::isNil( L, 3 ) )
	{
		lhs->setUrl( Util::toString( L, 2 ) );
	}
	else
	{
		Enums enums(L);
		QUrl::ParsingMode f=(QUrl::ParsingMode)enums.ParsingMode( 3 );
		lhs->setUrl( Util::toString( L, 2 ), f );
	}
	return 0;
}
Beispiel #28
0
void RssFetcher::fetch(QString urlString)
{
    QUrl feedUrl;
    feedUrl.setUrl(urlString,QUrl::TolerantMode);
    xmlStreamReader.clear();
    get(feedUrl);
    //qDebug() << feedUrl.toString();
}
Beispiel #29
0
/*!
    Start fetching
    \param respType Response type
    \param sinceid Fetches tweets with ID greater (more recent) then sinceid
    \param maxid Fetches tweets with ID less (older) then maxid
    \param count Number of tweets to fetch (up to 200)
    \param page Page number
    \remarks Async
 */
void QTweetRetweetByMe::fetch(ResponseType respType,
                                qint64 sinceid,
                                qint64 maxid,
                                int count,
                                int page,
                                bool trimUser,
                                bool includeEntities)
{
    Q_ASSERT(oauthTwitter() != 0);

    QUrl url;

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

    if (sinceid != 0)
        url.addQueryItem("since_id", QString::number(sinceid));

    if (maxid != 0)
        url.addQueryItem("max_id", QString::number(maxid));

    if (count != 0)
        url.addQueryItem("count", QString::number(count));

    if (page != 0)
        url.addQueryItem("page", QString::number(page));

    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()));
}
Beispiel #30
0
HelpDialog::HelpDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);

    connect (buttonQuit,     SIGNAL(clicked()), this, SLOT(accept ()));

    QUrl indx;
    indx.setUrl (HELPPATH);
    textBrowser->setSource (indx);
}