示例#1
0
void tst_QDesktopServices::openUrl_data()
{
    QTest::addColumn<QUrl>("data");
    QTest::addColumn<QString>("message");

    QUrl localFile = QUrl::fromLocalFile(QFINDTESTDATA("test.txt"));

    QTest::newRow("text-file")
            << localFile
            << "This should open test.txt in a text editor";

    localFile.setQuery("x=y");
    QTest::newRow("text-file-with-query")
            << localFile
            << "This should open test.txt in a text editor. Queries do not usually show up.";

    localFile.setQuery(QString());
    localFile.setFragment("top");
    QTest::newRow("text-file-with-fragment")
            << localFile
            << "This should open test.txt in a text editor. Fragments do not usually show up.";

    QTest::newRow("browser-plain")
            << QUrl("http://qt-project.org")
            << "This should open http://qt-project.org in the default web browser";

    QTest::newRow("search-url")
            << QUrl("http://google.com/search?q=Qt+Project")
            << "This should search \"Qt Project\" on Google";

    QTest::newRow("search-url-with-space")
            << QUrl("http://google.com/search?q=Qt Project")
            << "This should search \"Qt Project\" on Google";

    QTest::newRow("search-url-with-quotes")
            << QUrl("http://google.com/search?q=\"Qt+Project\"")
            << "This should search '\"Qt Project\"' on Google (including the quotes)";

    QTest::newRow("search-url-with-hashtag")
            << QUrl("http://google.com/search?q=%23qtproject")
            << "This should search \"#qtproject\" on Google. The # should appear in the Google search field";

    QTest::newRow("search-url-with-fragment")
            << QUrl("http://google.com/search?q=Qt+Project#top")
            << "This should search \"Qt Project\" on Google. There should be no # in the Google search field";

    // see QTBUG-32311
    QTest::newRow("search-url-with-slashes")
            << QUrl("http://google.com/search?q=/profile/5")
            << "This should search \"/profile/5\" on Google.";

    QTest::newRow("mail")
            << QUrl("mailto:[email protected]")
            << "This should open an email composer with the destination set to [email protected]";

    QTest::newRow("mail-subject")
            << QUrl("mailto:[email protected]?subject=[Development]%20Test%20Mail")
            << "This should open an email composer and tries to set the subject";
}
示例#2
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();
  }
void
TrainingstagebuchUploader::requestSession()
{
    parent->progressLabel->setText(tr("getting new Trainingstagebuch.org Session..."));

    currentRequest = reqSession;

    QString username = appsettings->cvalue(context->athlete->cyclist, GC_TTBUSER).toString();
    QString password = appsettings->cvalue(context->athlete->cyclist, GC_TTBPASS).toString();

#if QT_VERSION > 0x050000
    QUrlQuery urlquery;
#else
    QUrl urlquery( TTB_URL + "/login/sso" );
#endif
    urlquery.addQueryItem( "view", "xml" );
    urlquery.addQueryItem( "user", username );
    urlquery.addQueryItem( "pass", password );

#if QT_VERSION > 0x050000
    QUrl url (TTB_URL + "/login/sso");
    url.setQuery(urlquery.query());
    QNetworkRequest request = QNetworkRequest(url);
#else
    QNetworkRequest request = QNetworkRequest(urlquery);
#endif

    request.setRawHeader( "Accept-Encoding", "identity" );
    request.setRawHeader( "Accept", "application/xml" );
    request.setRawHeader( "Accept-Charset", "utf-8" );

    networkMgr.get( request );
    parent->progressBar->setValue(parent->progressBar->value()+5/parent->shareSiteCount);
}
示例#4
0
QUrl ModelBaker::getFullOutputMappingURL() const {
    QUrl appendedURL = _outputMappingURL;
    appendedURL.setFragment(_outputURLSuffix.fragment());
    appendedURL.setQuery(_outputURLSuffix.query());
    appendedURL.setUserInfo(_outputURLSuffix.userInfo());
    return appendedURL;
}
示例#5
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;
}
VkLoginDialog::VkLoginDialog(QWidget *parent) : QDialog(parent)
{
    qDebug() << __FUNCTION__;
    QUrl url;
    url.setScheme("https");
    url.setHost("oauth.vk.com");
    url.setPath("/authorize");

    QUrlQuery urlQuery;
    urlQuery.addQueryItem("client_id", "5042372");
    urlQuery.addQueryItem("display", "page");
    urlQuery.addQueryItem("redirect_uri", "https://oauth.vk.com/blank.html");
    urlQuery.addQueryItem("response_type", "token");
    urlQuery.addQueryItem("v", "5.37");
    urlQuery.addQueryItem("scope", "audio");
    url.setQuery(urlQuery);

    QWebView *webView = new QWebView(this);
    webView->load(url);

    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(getTokenFromUrl(QUrl)));

    QGridLayout *layout = new QGridLayout(this);
    layout->addWidget(webView);
}
示例#7
0
void SpotifyIO::loginReply()
{
    qDebug() << "resolver request";
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
    if (reply) {
        QByteArray data(reply->readAll());
        QVariantMap json = QJsonDocument::fromJson(data).toVariant().toMap();

        if (json["status"].toString() == "OK") {
            settings = json["config"].toMap();
            QVariantMap resolver = settings["aps"].toMap()["resolver"].toMap();

            QUrl url;
            url.setScheme("https");
            url.setHost(resolver["hostname"].toString());
            QUrlQuery query;
            query.addQueryItem("client", "24:0:0:" + settings["version"].toString());
            QString site = resolver["site"].toString();
            if (!site.isEmpty()) {
                query.addQueryItem("site", site);
            }
            url.setQuery(query);
            QNetworkRequest req(url);
            req.setHeader(QNetworkRequest::UserAgentHeader, userAgent);
            QObject::connect(nam->get(req), SIGNAL(finished()), this, SLOT(resolverReply()));
        }
        else {
            qDebug() << json["error"];
            Q_EMIT authFailed(json["error"].toString());

            _state = DisconnectedState;
            Q_EMIT stateChanged();
        }
    }
}
void Data::modifyTeaching(int id, const QString &className, int subjectID, int group, int teacherID, const QColor &color)
{
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyTeaching.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("id", QString::number(id));
    params.addQueryItem("className", className);
    params.addQueryItem("subjectID", QString::number(subjectID));
    params.addQueryItem("group", QString::number(group));
    params.addQueryItem("teacherID", QString::number(teacherID));
    params.addQueryItem("color", QString::number((color.red() << 16) | (color.green() << 8) | (color.blue())));
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getTeachings()));
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
void Data::deleteRoom(int id, bool refresh)
{
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/deleteRoom.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("id", QString::number(id));
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    if (refresh)
        connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getRooms()));
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
示例#10
0
void Data::insertSubject(const QString &name, const QString &shortName)
{
    if (this->m_insertReply) delete this->m_insertReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/insertSubject.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("name", name);
    params.addQueryItem("shortName", shortName);
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_insertReply = this->m_manager->post(request, data);
    connect(this->m_insertReply, SIGNAL(finished()), this, SLOT(getSubjects()));
    //connect(this->m_insertReply, SIGNAL(finished()), this, SLOT(readReady()));
}
示例#11
0
void Data::modifyPeriods(const QTime times[9])
{
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyPeriods.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    for (int i = 0; i < 9; ++i) {
        params.addQueryItem(QString("s%1").arg(i + 1), times[i].toString("hh:mm"));
        params.addQueryItem(QString("e%1").arg(i + 1), times[i].addSecs(45 * 60).toString("hh:mm"));
    }
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getPeriods()));
}
示例#12
0
void Data::modifyClasses(const QList<ClassData> &ocd, const QList<ClassData> &ncd, const QList<int> &ntid)
{
    int n = ocd.size();
    if (n <= 0) return;
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyClasses.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("n", QString::number(n));
    for (int i = 0; i < n; ++i) {
        const ClassData oc = ocd[i];
        const ClassData nc = ncd[i];
        params.addQueryItem(QString("ocid%1").arg(i), oc.name);
        params.addQueryItem(QString("ncid%1").arg(i), nc.name);
        params.addQueryItem(QString("nnum%1").arg(i), QString::number(nc.number));
        params.addQueryItem(QString("ntea%1").arg(i), QString::number(ntid[i]));
    }
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getSubjects()));
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
示例#13
0
void Data::insertLesson(int day, int hour, int teaching, int room)
{
    if ((day < 1) || (day > 5)) return;
    if ((hour < 1) || (hour > 9)) return;
    if ((teaching < 1) || (teaching > this->m_teachings.size())) return;
    if ((room < 1) || (room > this->m_rooms.size())) return;

    if (this->m_insertReply) delete this->m_insertReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/insertLesson.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("day", QString::number(day));
    params.addQueryItem("hour", QString::number(hour));
    params.addQueryItem("teaching", QString::number(teaching));
    params.addQueryItem("room", QString::number(room));
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_insertReply = this->m_manager->post(request, data);
    connect(this->m_insertReply, SIGNAL(finished()), this, SLOT(getLessons()));
}
示例#14
0
/*!
    Constructs a suggestions URL with a given \a searchTerm.

    The URL template is processed according to the specification:
    http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_URL_template_syntax

    See searchUrl() for more information about processing template parameters.

    \sa suggestionsUrlTemplate(), suggestionsParameters(), searchUrl()
*/
QUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
{
    if (!m_preparedSuggestionsUrl.isEmpty()) {
        QString s = m_preparedSuggestionsUrl;
        s.replace(QLatin1String("%s"), searchTerm);
        return QUrl(s);
    }

    if (m_suggestionsUrlTemplate.isEmpty()) {
        return QUrl();
    }

    QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8());

    QUrlQuery query(retVal);
    if (m_suggestionsMethod != QLatin1String("post")) {
        Parameters::const_iterator end = m_suggestionsParameters.constEnd();
        Parameters::const_iterator i = m_suggestionsParameters.constBegin();
        for (; i != end; ++i) {
            query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
        }
        retVal.setQuery(query);
    }

    return retVal;
}
示例#15
0
bool DownloadManager::loadMetaData(IlwisObject *object, const IOOptions &options)
{
    QUrl url = _resource.url(true);
    QUrlQuery query(url);
    query.addQueryItem("datatype","metadata");
    query.removeQueryItem("ilwistype"); // ilwistype might be too generic so we replace it we a more accurate version
    QString ilwtype = IlwisObject::type2Name(_resource.ilwisType()).toLower();
    query.addQueryItem("ilwistype",ilwtype);
    url.setQuery(query);
    _object = object;
    QNetworkRequest request(url);

    QNetworkReply *reply = kernel()->network().get(request);

    connect(reply, &QNetworkReply::readyRead, this, &DownloadManager::readReady);
    connect(reply, &QNetworkReply::downloadProgress, this, &DownloadManager::downloadProgress);
    connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DownloadManager::error);
    connect(reply, &QNetworkReply::finished, this, &DownloadManager::finishedMetadata);

    QEventLoop loop; // waits for request to complete
    connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
    loop.exec();

    delete reply;

    return true;
}
示例#16
0
void Data::modifyRooms(const QList<RoomData> &rds)
{
    int n = rds.size();
    if (n <= 0) return;
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyRooms.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("n", QString::number(n));
    for (int i = 0; i < n; ++i) {
        const RoomData rd = rds[i];
        params.addQueryItem(QString("id%1").arg(i), QString::number(rd.id));
        params.addQueryItem(QString("name%1").arg(i), rd.name);
        params.addQueryItem(QString("shortName%1").arg(i), rd.shortName);
        params.addQueryItem(QString("chairs%1").arg(i), QString::number(rd.chairs));
    }
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getRooms()));
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
示例#17
0
  QString serviceUrl( const QgsServerRequest &request, const QgsProject *project )
  {
    QString href;
    if ( project )
    {
      href = QgsServerProjectUtils::wmtsServiceUrl( *project );
    }

    // Build default url
    if ( href.isEmpty() )
    {
      QUrl url = request.originalUrl();

      QgsWmtsParameters params;
      params.load( QUrlQuery( url ) );
      params.remove( QgsServerParameter::REQUEST );
      params.remove( QgsServerParameter::VERSION_SERVICE );
      params.remove( QgsServerParameter::SERVICE );

      url.setQuery( params.urlQuery() );
      href = url.toString();
    }

    return  href;
  }
bool
TrainingsTageBuch::writeFile(QByteArray &data, QString remotename, RideFile *ride)
{
    Q_UNUSED(ride);

    printd("TrainingStageBuch::writeFile(%s)\n", remotename.toStdString().c_str());

    QHttpMultiPart *body = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QHttpPart textPart;
    textPart.setHeader(QNetworkRequest::ContentDispositionHeader,
    QVariant("form-data; name=\"upload_submit\""));
    textPart.setBody("hrm");
    body->append(textPart);

    int limit = proMember ? 8 * 1024 * 1024 : 4 * 1024 * 1024;
    if(data.size() >= limit ){
        return false;
    }

    QHttpPart filePart;
    filePart.setHeader(QNetworkRequest::ContentTypeHeader,
    QVariant("application/octet-stream"));
    filePart.setHeader(QNetworkRequest::ContentDispositionHeader,
    QVariant("form-data; name=\"file\"; filename=\"gc-upload-ttb.pwx\""));
    filePart.setBody(data);
    body->append(filePart);

#if QT_VERSION > 0x050000
    QUrlQuery urlquery;
#else
    QUrl urlquery( TTB_URL + "/file/upload" );
#endif
    urlquery.addQueryItem( "view", "xml" );
    urlquery.addQueryItem( "sso", sessionId );


#if QT_VERSION > 0x050000
    QUrl url (TTB_URL + "/file/upload");
    url.setQuery(urlquery.query());
    QNetworkRequest request = QNetworkRequest(url);
#else
    QNetworkRequest request = QNetworkRequest(urlquery);
#endif

    request.setRawHeader( "Accept-Encoding", "identity" );
    request.setRawHeader( "Accept", "application/xml" );
    request.setRawHeader( "Accept-Charset", "utf-8" );

    // this must be performed asyncronously and call made
    // to notifyWriteCompleted(QString remotename, QString message) when done
    reply = nam->post(request, body);

    // catch finished signal
    connect(reply, SIGNAL(finished()), this, SLOT(writeFileCompleted()));

    // remember
    mapReply(reply,remotename);
    return true;
}
示例#19
0
void UserManagementAPI::handleGitHubRegisterGet(HttpRequest &request, HttpResponse &response)
{
    const QHash<QString, QSharedPointer<QString>> &queries = request.getHeader().getQueries();

    QString code;
    if (!queries.contains("code"))
    {
        respond(response, StatusCode::MissingParameters, "no code");
    }

    code = *queries["code"].data();

    QString client_id = SettingsManager::getSingleton().get("GitHub/client_id").toString();
    QString client_secret = SettingsManager::getSingleton().get("GitHub/client_secret").toString();

    QUrl verificationUrl = QUrl("https://github.com/login/oauth/access_token");

    QUrlQuery query;

    query.addQueryItem("code", code);
    query.addQueryItem("client_id", client_id);
    query.addQueryItem("client_secret", client_secret);

    verificationUrl.setQuery(query.query());

    QNetworkRequest gitHubRequest;
    gitHubRequest.setUrl(verificationUrl);

    QByteArray replyData;
    m_networkServiceAccessor.post(gitHubRequest, QByteArray(), replyData);

    respondSuccess(response);
}
示例#20
0
//request only our live broadcasts, single item
void YoutubeApi::requestOwnLiveBroadcasts()
{
    broadcastModel_->clearBroadcasts();
    if (!authenticator_ || !authenticator_->linked()) {        
        emit broadcastModelChanged();
        return;
    }
     O2Requestor *requestor = new O2Requestor(manager_, authenticator_, this);
     QUrl url = QUrl("https://www.googleapis.com/youtube/v3/liveBroadcasts");

     QUrlQuery query(url);
     query.addQueryItem(YOUTUBE_LIVE_PART,"snippet");
     query.addQueryItem(YOUTUBE_LIVE_FILTER_MINE,"true");
     query.addQueryItem(YOUTUBE_LIVE_BROADCAST_TYPE,"persistent");
     query.addQueryItem(YOUTUBE_LIVE_OPTIONAL_MAXRESULTS,"1");

     url.setQuery(query);

     QNetworkRequest request(url);
     requestor->get(request);

     //connect(requestor, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestFailed(QNetworkReply::NetworkError)));//commentsReceived()));
     connect(requestor, SIGNAL(finished(int, QNetworkReply::NetworkError, QByteArray)),
             this, SLOT(broadcastRequestFinished(int, QNetworkReply::NetworkError, QByteArray)));//commentsReceived()));


}
示例#21
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()));
}
示例#22
0
static void sendMail(QString sAddress, QString sSubject, QString sBody)
{
#ifdef Q_WS_WIN
    /* search and replace the end of lines with: "%0D%0A" */
    sBody.replace("\n", "%0D%0A");
#endif

    QUrl url = QUrl("mailto:" + sAddress);

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    QUrlQuery urlQuery;
#else
    QUrl &urlQuery(url);
#endif

    urlQuery.addQueryItem("subject", sSubject);
    urlQuery.addQueryItem("body", sBody);

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    url.setQuery(urlQuery);
#endif

    std::cerr << "MAIL STRING:" << (std::string)url.toEncoded().constData() << std::endl;

    /* pass the url directly to QDesktopServices::openUrl */
    QDesktopServices::openUrl (url);
}
示例#23
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;
}
示例#24
0
static QUrl getApiUrl(BtsApi_private *p, const QString &method, const QueryList &querylist = QueryList())
{
	assertClient(p);

	QUrl res;

	res.setScheme("http");

	res.setHost(p->client->getHost());
	res.setPort(p->client->getPort());

	if(!p->client->getUserName().isEmpty())
		res.setUserName(p->client->getUserName());

	if(!p->client->getPassword().isEmpty())
		res.setPassword(p->client->getPassword());

	res.setPath("/api");

	QUrlQuery urlQuery;
	urlQuery.addQueryItem("method", method);

	for(const QueryPair &qp: querylist)
	{
		if(qp.second.isNull())
			urlQuery.addQueryItem(qp.first, "");
		else
			urlQuery.addQueryItem(qp.first, qp.second);
	}

	res.setQuery(urlQuery);

	return res;
}
示例#25
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;
}
void LinAuthentication::on_sigAuthCodeDelivered(const QString& authorizationCode, const QString& authorizationState, 
                                                const QString& redirectHost)
{
    Q_ASSERT(!authorizationCode.isEmpty());
    Q_ASSERT(!authorizationState.isEmpty());

    if (mAuthState != authorizationState)
        emit sigAuthError(LinAuthParameters::kLinStateError, LinAuthParameters::kLinAuthErrorDescription);
    else
    {
        QUrlQuery urlQuery(LinAuthParameters::kLinAuthAccessTokenUrl);
        urlQuery.addQueryItem(LinAuthParameters::kLinAuthGrantType, "authorization_code");
        urlQuery.addQueryItem(LinAuthParameters::kLinAuthCode, authorizationCode);
        urlQuery.addQueryItem(LinAuthParameters::kLinAuthRedirectURI, redirectHost);
        urlQuery.addQueryItem(LinAuthParameters::kLinAuthClientId, mClientId);
        urlQuery.addQueryItem(LinAuthParameters::kLinAuthClientSecret, mClientSecret);

        QUrl url;
        url.setQuery(urlQuery);
        QByteArray encodedData = url.toEncoded();
        Q_ASSERT(!encodedData.isEmpty());

        QUrl tokenUrl(LinAuthParameters::kLinAuthAccessTokenUrl);
        QNetworkRequest tokenRequest(tokenUrl);
        tokenRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

        bool status = connect(mNetAccessManager.get(), SIGNAL(finished(QNetworkReply*)), this, SLOT(on_sigTokenRequestFinished(QNetworkReply*)));
        Q_ASSERT(status);

        mNetAccessManager->post(tokenRequest, encodedData);
    }
}
示例#27
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;
  }
示例#28
0
  QString serviceUrl( const QgsServerRequest& request, const QgsProject* project )
  {
    QString href;
    if ( project )
    {
      href = QgsServerProjectUtils::wfsServiceUrl( *project );
    }

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

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

      url.setQuery( q );
      href = url.toString( QUrl::FullyDecoded );
    }

    return  href;
  }
示例#29
0
void ParserResRobot::doSearchJourney(QUrl query)
#endif
{
    QUrl url = baseURL + QLatin1String("/trip");
    if (lastJourneySearch.mode == Arrival)
        query.addQueryItem("searchForArrival", "1");
    query.addQueryItem("key", journeyAPIKey);
    query.addQueryItem("originId", lastJourneySearch.from.id.toString());
    if (lastJourneySearch.via.valid)
        query.addQueryItem("viaId", lastJourneySearch.via.id.toString());
    query.addQueryItem("destId", lastJourneySearch.to.id.toString());
    query.addQueryItem("passlist", "0"); // We don't need any intermediate stops in the result
    query.addQueryItem("format", "json");
    QString formattedRestrictions(formatRestrictions(lastJourneySearch.restrictions));
    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");

#if defined(BUILD_FOR_QT5)
    url.setQuery(query);
#else
    url.setQueryItems(query.queryItems());
#endif
    qDebug() << "Searching for journey:" << url.toString();
    sendHttpRequest(url);
}
示例#30
0
void TwitchApi::putRequest( const QString &urlString, QHash<QString, QString> urlParams)
{
    QUrl url ( urlString );
    QUrlQuery query(url);




    for (QHash<QString, QString>::iterator iter = urlParams.begin(); iter != urlParams.end(); ++iter) {

        query.addQueryItem(iter.key(),iter.value());
    }


    url.setQuery(query);

    QNetworkRequest req ( url );

    req.setRawHeader("Accept", "application/vnd.twitchtv.v3+json");
    req.setRawHeader("Authorization", "OAuth "+this->oAuthAccessToken.toLatin1());
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );



    m_nam.put( req, url.toEncoded() );


}