Esempio n. 1
0
void MainWindow::on_taskList_itemChanged(QListWidgetItem *item)
{
    bool hasId = false;
    int id = item->data(Qt::UserRole).toInt(&hasId);
    QString title = item->text();
    QJsonDocument json(taskToJsonObject(title));
    QNetworkReply *reply = nullptr;
    if (hasId)
    {
        QUrl putURL = mServerBaseURL;
        putURL.setPath(putURL.path().append(todoPath.arg(id)));
        QNetworkRequest request(putURL);
        request.setHeader(QNetworkRequest::ContentTypeHeader, jsonMIME);
        reply = mNAM.put(request, json.toJson());
    }
    else
    {
        QUrl postURL = mServerBaseURL;
        postURL.setPath(postURL.path().append(indexPath));
        QNetworkRequest request(postURL);
        request.setHeader(QNetworkRequest::ContentTypeHeader, jsonMIME);
        reply = mNAM.post(request, json.toJson());
        QObject::connect(reply, &QNetworkReply::finished, this, &MainWindow::itemPosted);
    }

    mQueries.append(reply);
    mItemsToUpdate.append(item);
}
Esempio n. 2
0
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
    const QNetworkRequest &request, QIODevice* outgoingData)
{
    if (!HelpViewer::isLocalUrl(request.url()))
        return Utils::NetworkAccessManager::createRequest(op, request, outgoingData);

    QString url = request.url().toString();
    const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
    // TODO: For some reason the url to load is already wrong (passed from webkit)
    // though the css file and the references inside should work that way. One 
    // possible problem might be that the css is loaded at the same level as the
    // html, thus a path inside the css like (../images/foo.png) might cd out of
    // the virtual folder
    if (!engine.findFile(url).isValid()) {
        if (url.startsWith(HelpViewer::NsNokia) || url.startsWith(HelpViewer::NsTrolltech)) {
            QUrl newUrl = request.url();
            if (!newUrl.path().startsWith(QLatin1String("/qdoc/")) ||
                    !newUrl.path().startsWith(QLatin1String("/doc/"))) {
                QString path = newUrl.path();
                newUrl.setPath(QLatin1String("/qdoc/") + path);
                if (!engine.findFile(newUrl).isValid())
                    newUrl.setPath(QLatin1String("/doc/") + path);
                url = newUrl.toString();
            }
        }
    }

    const QString &mimeType = HelpViewer::mimeFromUrl(url);
    const QByteArray &data = engine.findFile(url).isValid() ? engine.fileData(url)
        : QString::fromLatin1(g_htmlPage).arg(g_percent1, g_percent2, HelpViewer::tr("Error loading: %1")
            .arg(url), g_percent4, g_percent6, g_percent7, QString()).toUtf8();

    return new HelpNetworkReply(request, data, mimeType.isEmpty()
        ? QLatin1String("application/octet-stream") : mimeType);
}
Esempio n. 3
0
void TwitterSearch::requestSearchResults(const SearchInfo &searchInfo,
        const QString &sinceStatusId, uint count, uint page)
{
    Q_UNUSED(page)
    qCDebug(CHOQOK);

    TwitterAccount *account = qobject_cast< TwitterAccount * >(searchInfo.account);
    QUrl url = account->apiUrl();

    QUrlQuery urlQuery;
    QOAuth::ParamMap param;

    const QString query = searchInfo.query;
    if (searchInfo.option == TwitterSearch::FromUser) {
        url.setPath(url.path() + QLatin1String("/statuses/user_timeline.json"));

        urlQuery.addQueryItem(QLatin1String("screen_name"), query);
        param.insert("screen_name", query.toLatin1());
    } else {
        url.setPath(url.path() + QLatin1String("/search/tweets.json"));

        const QByteArray formattedQuery(QUrl::toPercentEncoding(mSearchCode[searchInfo.option] + query));
        urlQuery.addQueryItem(QLatin1String("q"), QString::fromLatin1(formattedQuery));
        param.insert("q", formattedQuery);
    }

    if (!sinceStatusId.isEmpty()) {
        urlQuery.addQueryItem(QLatin1String("since_id"), sinceStatusId);
        param.insert("since_id", sinceStatusId.toLatin1());
    }

    int cntStr;
    if (count && count <= 100) { // Twitter API specifies a max count of 100
        cntStr = count;
    } else {
        cntStr = 100;
    }
    urlQuery.addQueryItem(QLatin1String("count"), QString::number(cntStr));
    param.insert("count", QString::number(cntStr).toLatin1());

    const QUrl tmpUrl(url);
    url.setQuery(urlQuery);

    qCDebug(CHOQOK) << url;
    KIO::StoredTransferJob *job = KIO::storedGet(url, KIO::Reload, KIO::HideProgressInfo);
    if (!job) {
        qCCritical(CHOQOK) << "Cannot create an http GET request!";
        return;
    }

    TwitterApiMicroBlog *microblog = qobject_cast<TwitterApiMicroBlog *>(account->microblog());

    job->addMetaData(QStringLiteral("customHTTPHeader"),
                     QStringLiteral("Authorization: ") +
                     QLatin1String(microblog->authorizationHeader(account, tmpUrl, QOAuth::GET, param)));

    mSearchJobs[job] = searchInfo;
    connect(job, SIGNAL(result(KJob*)), this, SLOT(searchResultsReturned(KJob*)));
    job->start();
}
Esempio n. 4
0
void TsFactory::TestMakeParser()
{
  try
  {
    //test postgis uri
    QUrl postgisUri;
    postgisUri.setScheme("postgis");
    postgisUri.setHost("localhost");
    postgisUri.setPort(5432);
    postgisUri.setUserName("postgres");
    postgisUri.setPassword("postgres");
    postgisUri.setPath("/basedeteste");

    terrama2::core::DataSetItem unknownTypeItem(terrama2::core::DataSetItem::UNKNOWN_TYPE);

    //FIXME: create a DataSetItem kind for ParserPostgis
//    terrama2::collector::ParserPtr parser = terrama2::collector::Factory::makeParser(unknownTypeItem);
//    terrama2::collector::ParserPostgis* parserPostgis = dynamic_cast<terrama2::collector::ParserPostgis*>(parser.get());
//    QVERIFY(parserPostgis);

    QUrl fileUri;
    fileUri.setScheme("file");
    fileUri.setPath("/tmp");

    terrama2::collector::ParserPtr parser = terrama2::collector::Factory::makeParser(unknownTypeItem);
    terrama2::collector::ParserOGR* parserOGR = dynamic_cast<terrama2::collector::ParserOGR*>(parser.get());
    QVERIFY(parserOGR);

    terrama2::core::DataSetItem pcdInpeTypeItem(terrama2::core::DataSetItem::PCD_INPE_TYPE);
    parser = terrama2::collector::Factory::makeParser(pcdInpeTypeItem);
    terrama2::collector::ParserPcdInpe* parserPdcInpe = dynamic_cast<terrama2::collector::ParserPcdInpe*>(parser.get());
    QVERIFY(parserPdcInpe);

    terrama2::core::DataSetItem pcdToaTypeItem(terrama2::core::DataSetItem::PCD_TOA5_TYPE);
    parser = terrama2::collector::Factory::makeParser(pcdToaTypeItem);
    terrama2::collector::ParserPcdToa5* parserPdctoa5 = dynamic_cast<terrama2::collector::ParserPcdToa5*>(parser.get());
    QVERIFY(parserPdctoa5);

    terrama2::core::DataSetItem firePointTypeItem(terrama2::core::DataSetItem::FIRE_POINTS_TYPE);
    parser = terrama2::collector::Factory::makeParser(firePointTypeItem);
    terrama2::collector::ParserFirePoint* parserFirePoint = dynamic_cast<terrama2::collector::ParserFirePoint*>(parser.get());
    QVERIFY(parserFirePoint);

    try
    {
      terrama2::core::DataSetItem diseaseTypeItem(terrama2::core::DataSetItem::DISEASE_OCCURRENCE_TYPE);
      parser = terrama2::collector::Factory::makeParser(diseaseTypeItem);

      QFAIL(NO_EXCEPTION_THROWN);
    }
    catch(terrama2::collector::ConflictingParserTypeSchemeException& e)
    {

    }
  }
  catch(...)
  {
    QFAIL(NO_EXCEPTION_EXPECTED);
  }
}
Esempio n. 5
0
void Wikipedia::getTranslation()
{
    if (langCode().isEmpty() || entry().isEmpty()) {
        return;
    }

    QSettings s;
    QString lang = s.value(QStringLiteral("display/language")).toString().left(2).toUpper();
    if (lang.isEmpty() || (lang == QLatin1String("C"))) {
        lang = QLocale::system().name().left(2);
    }

    QUrl wpURL;
    wpURL.setScheme(QStringLiteral("https"));


    if (lang == langCode()) {
        wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(langCode()));
        wpURL.setPath(QStringLiteral("/wiki/%1").arg(entry()));
    } else {

        QString enFallback;

        QMap<QString, QString> interWiki = reqTranslations(langCode(), entry());
        if (interWiki.contains(QStringLiteral("en"))) {
            enFallback = interWiki.value(QStringLiteral("en"));
        }

        while (!interWiki.contains(lang) && (interWiki[QStringLiteral("cont")] != QStringLiteral(""))) {

            interWiki = reqTranslations(langCode(), entry(), interWiki[QStringLiteral("cont")]);

            if (interWiki.contains(QStringLiteral("en"))) {
                enFallback = interWiki.value(QStringLiteral("en"));
            }
        }

        if (interWiki.contains(lang)) {
            wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(lang));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(interWiki[lang]));
        } else if (!enFallback.isEmpty()) {
            wpURL.setHost(QStringLiteral("en.wikipedia.org"));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(enFallback));
        } else {
            wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(langCode()));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(entry()));
        }

#ifdef QT_DEBUG
        qDebug() << "Wikipedia URL: " << wpURL;
#endif

    }

    setUrl(wpURL);
}
Esempio n. 6
0
QString WaveUrl::toString() const
{
    QUrl url;
    url.setScheme("wave");
    url.setHost(m_waveletDomain);
    if ( m_waveletDomain == m_waveDomain)
        url.setPath( "/" + m_waveId + "/" + m_waveletId );
    else
        url.setPath( "/" + m_waveDomain + "$" + m_waveId + "/" + m_waveletId );
    return url.toString();
}
Esempio n. 7
0
QUrl ChatUrls::fromLocalFile(const QString &localFile)
{
  QUrl url;
  url.setScheme(LS("file"));
  QString deslashified = QDir::fromNativeSeparators(localFile);

  if (deslashified.length() > 1 && deslashified.at(1) == LC(':') && deslashified.at(0) != LC('/'))
    url.setPath(LC('/') + deslashified);
  else
    url.setPath(deslashified);

  return url;
}
CylinderView::CylinderView(QWindow *parent)
    : QGLView(parent)
{
    QGLBuilder builder;
    // Evil hack: it is not possible to just call glClearColor on any device
    // but it is possible to have a huge, dark SkyBox. Without this hack the
    // cylinder floats over a transparent background, displaying the contents
    // of the last app
    builder << QGL::Smooth << QGLCube(1000.0f);


    // Add the cylinder
    builder << QGL::Smooth << QGLCylinder(2.0, 1.5, 2.0, 36, 3, true, true);

    QGLMaterial *matLid = new QGLMaterial;
    matLid->setAmbientColor(Qt::gray);
    matLid->setDiffuseColor(Qt::gray);
    QUrl urlLid;
    urlLid.setPath(QLatin1String(":/latte.png"));
    urlLid.setScheme(QLatin1String("file"));
    matLid->setTextureUrl(urlLid);

    QGLMaterial *matSides = new QGLMaterial;
    matSides->setColor(QColor(170, 202, 0));
    QUrl urlSides;
    urlSides.setPath(QLatin1String(":/cupTexture.png"));
    urlSides.setScheme(QLatin1String("file"));
    matSides->setTextureUrl(urlSides);

    QGLSceneNode *root = builder.sceneNode();

    QGLSceneNode *lid = root->findChild<QGLSceneNode *>("Cylinder Top");
    int lidMat = root->palette()->addMaterial(matLid);
    lid->setMaterialIndex(lidMat);
    lid->setEffect(QGL::LitDecalTexture2D);

    QGLSceneNode *sides = root->findChild<QGLSceneNode *>("Cylinder Sides");
    int sideMat = root->palette()->addMaterial(matSides);
    sides->setMaterialIndex(sideMat);
    sides->setEffect(QGL::LitDecalTexture2D);

    cylinder = builder.finalizedSceneNode();

    QGLMaterial *mat = new QGLMaterial;
    mat->setAmbientColor(Qt::gray);
    mat->setDiffuseColor(Qt::gray);
    cylinder->setMaterial(mat);
    cylinder->setEffect(QGL::LitMaterial);
}
QUrl
ContentTreeView::ContentNode2QUrl(ContentNode *node)
{
    QUrl u;
    if (node->is_group()) {
        u.setPort(node->type());
        u.setPath(QString::fromStdString(node->ParseAsGroup()->title()));
    } else if (node->is_layer()) {
        u.setPort(node->type());
        u.setPath(QString::fromStdString(node->ParseAsLayer()->path()));
    } else {
        // undefined
    }
    return u;
}
Esempio n. 10
0
void    LocalApp::getUrl( QUrl oldUrl , QUrl &newUrl){


    QString scriptName;
#ifndef USE_QT5
#ifdef WINDOWS
    scriptName   = home+"\\" + oldUrl.encodedPath();
#else
    scriptName   = home+"/" + oldUrl.encodedPath();
#endif
    //scriptName   = tmpUrl.toString(FULLPATH);
#else
#ifdef WINDOWS
    scriptName   = home+"\\" + oldUrl.path();
#else
    scriptName   = home+"/" + oldUrl.path();
#endif
    //scriptName   = tmpUrl.toDisplayString(QUrl::FullyDecoded);
    //scriptName.remove(0,6);
#endif
    if( QDir(scriptName).exists() ) {
#ifdef WINDOWS
        if( scriptName.at(scriptName.size()-1) == '/')
#else
        if( scriptName.at(scriptName.size()-1) == '\\')
#endif
            scriptName = scriptName + "index.py";
        else
#ifdef WINDOWS
            scriptName = scriptName + "\\index.py";
#else
            scriptName = scriptName + "/index.py";
#endif
    }
    if ( !getScript(scriptName) ){
        QFileInfo qFileInfo(scriptName);
        if ( qFileInfo.fileName() == "index.py" ){
            scriptName = qFileInfo.dir().absolutePath() + "/index.html";
        }
    }
#ifndef USE_QT5
    ERR<<"INFO: LocalApp::getUrl(): Encoded Path: "<<oldUrl.encodedPath()<<", "<<scriptName<<endl;
    newUrl.setPath(scriptName);
#else
    ERR<<"INFO: LocalApp::getUrl(): Path: "<<oldUrl.path()<<", "<<scriptName<<endl;
    newUrl.setPath(scriptName);
#endif
}
Esempio n. 11
0
void GoogleDriveService::FilesFound(const QList<google_drive::File>& files) {
  for (const google_drive::File& file : files) {
    if (!IsSupportedMimeType(file.mime_type())) {
      continue;
    }

    QUrl url;
    url.setScheme("googledrive");
    url.setPath(file.id());

    Song song;
    // Add some extra tags from the Google Drive metadata.
    song.set_etag(file.etag().remove('"'));
    song.set_mtime(file.modified_date().toTime_t());
    song.set_ctime(file.created_date().toTime_t());
    song.set_comment(file.description());
    song.set_directory_id(0);
    song.set_url(QUrl(url));
    song.set_filesize(file.size());

    // Use the Google Drive title if we couldn't read tags from the file.
    if (song.title().isEmpty()) {
      song.set_title(file.title());
    }

    MaybeAddFileToDatabase(song, file.mime_type(), file.download_url(),
                           QString("Bearer %1").arg(client_->access_token()));
  }
}
Esempio n. 12
0
void FoldersPanel::loadTree(const QUrl& url)
{
    Q_ASSERT(m_controller);

    m_updateCurrentItem = false;

    QUrl baseUrl;
    if (url.isLocalFile()) {
        // Use the root directory as base for local URLs (#150941)
        baseUrl = QUrl::fromLocalFile(QDir::rootPath());
    } else {
        // Clear the path for non-local URLs and use it as base
        baseUrl = url;
        baseUrl.setPath(QString('/'));
    }

    if (m_model->directory() != baseUrl) {
        m_updateCurrentItem = true;
        m_model->refreshDirectory(baseUrl);
    }

    const int index = m_model->index(url);
    if (index >= 0) {
        updateCurrentItem(index);
    } else {
        m_updateCurrentItem = true;
        m_model->expandParentDirectories(url);
        // slotLoadingCompleted() will be invoked after the model has
        // expanded the url
    }
}
bool LeScienze500::startPdfAppl( QString file_path )
{
    QString pdf_appl , command ;
    bool flag , process_strated ;

    QProcess process_pdf ;

    configLS500 cfg ;
    pdf_appl = cfg.getPDFAppl() ;

    command.append( pdf_appl ) ;
    command.append( " " ) ;
    command.append( "\"" ) ;

    command.append( file_path ) ;
    command.append( "\"" ) ;

    qDebug() << command ;

    if ( pdf_appl != "desktop" )
        process_strated = process_pdf.startDetached( command );
    else
    {
        QUrl url ;
        url.setScheme( "file" );
        url.setPath( file_path );
        process_strated = QDesktopServices::openUrl( url ) ;
    }

    return process_strated ;
}
void EnginioClientConnectionPrivate::uploadChunk(EnginioReplyState *ereply, QIODevice *device, qint64 startPos)
{
    QUrl serviceUrl = _serviceUrl;
    {
        QString path;
        QByteArray errorMsg;
        if (!getPath(ereply->data(), Enginio::FileChunkUploadOperation, &path, &errorMsg).successful())
            Q_UNREACHABLE(); // sequential upload can not have an invalid path!
        serviceUrl.setPath(path);
    }

    QNetworkRequest req = prepareRequest(serviceUrl);
    req.setHeader(QNetworkRequest::ContentTypeHeader, EnginioString::Application_octet_stream);

    // Content-Range: bytes {chunkStart}-{chunkEnd}/{totalFileSize}
    qint64 size = device->size();
    qint64 endPos = qMin(startPos + _uploadChunkSize, size);
    req.setRawHeader(EnginioString::Content_Range,
                     QByteArray::number(startPos) + EnginioString::Minus
                     + QByteArray::number(endPos) + EnginioString::Div
                     + QByteArray::number(size));

    // qDebug() << "Uploading chunk from " << startPos << " to " << endPos << " of " << size;

    Q_ASSERT(device->isOpen());

    ChunkDevice *chunkDevice = new ChunkDevice(device, startPos, _uploadChunkSize);
    chunkDevice->open(QIODevice::ReadOnly);

    QNetworkReply *reply = networkManager()->put(req, chunkDevice);
    chunkDevice->setParent(reply);
    _chunkedUploads.insert(reply, qMakePair(device, endPos));
    ereply->setNetworkReply(reply);
    _connections.append(QObject::connect(reply, &QNetworkReply::uploadProgress, UploadProgressFunctor(this, reply)));
}
Esempio n. 15
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;
}
Esempio n. 16
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;
}
Esempio n. 17
0
QUrl
Mirrors::randomMirror(const QList<QUrl> & mirrors, bool addkey,
		      const QString & postfix, bool api)
{
  static int i = 0;

  if (mirrors.isEmpty())
    return QUrl();
  i++;
  i %= mirrors.size();
  QUrl m = mirrors.at(i);
  QString path = m.path();

  if (api)
    path += "/api/";
  if (addkey)
    path += key() + "/";
  if (!postfix.isEmpty())
    path += postfix;
  m.setPath(path);
#ifdef Q_WS_WIN
  qWarning() << m.path() << m.encodedPath();
#endif
  return m;
}
Esempio n. 18
0
void ServerCall::check_q()
{
	if(in_request == true){
		return;
	}
	if(request_q.isEmpty()){
		return;
	}
	in_request = true;

	QUrl url (server_url);
	url.setPath(request_q.dequeue());
	url.addQueryItem("json", "1");

	QNetworkRequest request;
	request.setUrl(url);
	//qDebug() << "----------------------------------------------------------------";
	//qDebug() << url.toString();

	server_string = "";
	reply = netMan->get(request);

	connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(on_net_error(QNetworkReply::NetworkError)));
	connect(reply, SIGNAL(readyRead()), this, SLOT(on_net_ready_read()));
	connect(reply, SIGNAL(finished()), this, SLOT(on_net_finished()));
}
Esempio n. 19
0
QNetworkRequest createNetworkRequest() {

    QNetworkRequest request;

    QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL();
    requestURL.setPath(USER_ACTIVITY_URL);

    request.setUrl(requestURL);

    auto accountManager = DependencyManager::get<AccountManager>();

    if (accountManager->hasValidAccessToken()) {
        request.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER,
                             accountManager->getAccountInfo().getAccessToken().authorizationHeaderValue());
    }

    request.setRawHeader(METAVERSE_SESSION_ID_HEADER,
                         uuidStringWithoutCurlyBraces(accountManager->getSessionID()).toLocal8Bit());

    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

    request.setPriority(QNetworkRequest::HighPriority);

    return request;
}
Esempio n. 20
0
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
    const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{
    TRACE_OBJ
    QString url = request.url().toString();
    HelpEngineWrapper *helpEngine = HelpEngineWrapper::instance();

    // TODO: For some reason the url to load is already wrong (passed from webkit)
    // though the css file and the references inside should work that way. One 
    // possible problem might be that the css is loaded at the same level as the
    // html, thus a path inside the css like (../images/foo.png) might cd out of
    // the virtual folder
    if (!helpEngine->findFile(url).isValid()) {
        if (url.startsWith(AbstractHelpViewer::DocPath)) {
            QUrl newUrl = request.url();
            if (!newUrl.path().startsWith(QLatin1String("/qdoc/"))) {
                newUrl.setPath(QLatin1String("qdoc") + newUrl.path());
                url = newUrl.toString();
            }
        }
    }

    const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url);
    const QByteArray &data = helpEngine->findFile(url).isValid()
        ? helpEngine->fileData(url)
        : AbstractHelpViewer::PageNotFoundMessage.arg(url).toUtf8();
    return new HelpNetworkReply(request, data, mimeType.isEmpty()
        ? QLatin1String("application/octet-stream") : mimeType);
}
Esempio n. 21
0
void OwncloudSetupWizard::slotAuthError()
{
    QString errorMsg;

    PropfindJob* job = qobject_cast<PropfindJob*>(sender());
    if (!job) {
        qWarning() << "Can't check for authed redirects. This slot should be invoked from PropfindJob!";
        return;
    }
    QNetworkReply* reply = job->reply();

    // If there were redirects on the *authed* requests, also store
    // the updated server URL, similar to redirects on status.php.
    QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    if (!redirectUrl.isEmpty()) {
        qDebug() << "authed request was redirected to" << redirectUrl.toString();

        // strip the expected path
        QString path = redirectUrl.path();
        static QString expectedPath = "/" + _ocWizard->account()->davPath();
        if (path.endsWith(expectedPath)) {
            path.chop(expectedPath.size());
            redirectUrl.setPath(path);

            qDebug() << "setting account url to" << redirectUrl.toString();
            _ocWizard->account()->setUrl(redirectUrl);
            testOwnCloudConnect();
            return;
        }
        errorMsg = tr("The authenticated request to the server was redirected to "
                      "'%1'. The URL is bad, the server is misconfigured.")
                   .arg(redirectUrl.toString());

    // A 404 is actually a success: we were authorized to know that the folder does
    // not exist. It will be created later...
    } else if (reply->error() == QNetworkReply::ContentNotFoundError) {
        _ocWizard->successfulStep();
        return;

    // Provide messages for other errors, such as invalid credentials.
    } else if (reply->error() != QNetworkReply::NoError) {
        if (!_ocWizard->account()->credentials()->stillValid(reply)) {
            errorMsg = tr("Access forbidden by server. To verify that you have proper access, "
                          "<a href=\"%1\">click here</a> to access the service with your browser.")
                       .arg(_ocWizard->account()->url().toString());
        } else {
            errorMsg = errorMessage(reply->errorString(), reply->readAll());
        }

    // Something else went wrong, maybe the response was 200 but with invalid data.
    } else {
        errorMsg = tr("There was an invalid response to an authenticated webdav request");
    }

    _ocWizard->show();
    if (_ocWizard->currentId() == WizardCommon::Page_ShibbolethCreds) {
        _ocWizard->back();
    }
    _ocWizard->displayError(errorMsg, _ocWizard->currentId() == WizardCommon::Page_ServerSetup && checkDowngradeAdvised(reply));
}
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);
}
void StartPdf::run()
{
    QString pdf_appl , command ;
    bool process_strated ;

    QProcess process_pdf ;

    configLS500 cfg ;
    pdf_appl = cfg.getPDFAppl() ;

    command.append( pdf_path ) ;
    command.append( " " ) ;
    command.append( "\"" ) ;

    command.append( pdf_path ) ;
    command.append( "\"" ) ;

    //qDebug() << command ;

    if ( pdf_appl != "desktop" )
        process_strated = process_pdf.startDetached( command );
    else
    {
        QUrl url ;
        url.setScheme( "file" );
        url.setPath( pdf_path );
        process_strated = QDesktopServices::openUrl( url ) ;
    }
}
Esempio n. 24
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;
}
Esempio n. 25
0
Song & MagnatuneService::fixPath(Song &s) const
{
    s.type=Song::OnlineSvrTrack;
    if (MB_None!=membership) {
        QUrl url;
        #if QT_VERSION < 0x050000
        url.setEncodedUrl(s.file.toLocal8Bit());
        #else
        url=QUrl(s.file);
        #endif
        url.setScheme("http");
        url.setHost(MB_Streaming==membership ? constStreamingHostname : constDownloadHostname);
        url.setUserName(username);
        url.setPassword(password);

        // And remove the commercial
        QString path = url.path();
        path.insert(path.lastIndexOf('.'), "_nospeech");
        url.setPath(path);
        s.file=url.toString();
    // TODO: Magnatune downloads!
    //    if (MB_Download==membership) {
    //        s.genre=downloadTypeStr(download);
    //    }
    }
    s.setIsFromOnlineService(name());
    return encode(s);
}
Esempio n. 26
0
RepoDownloadInfo RepoDownloadInfo::fromDict(QMap<QString, QVariant>& dict,
                                            const QUrl& url_in,
                                            bool read_only)
{
    RepoDownloadInfo info;
    info.repo_version = dict["repo_version"].toInt();
    info.relay_id = dict["relay_id"].toString();
    info.relay_addr = dict["relay_addr"].toString();
    info.relay_port = dict["relay_port"].toString();
    info.email = dict["email"].toString();
    info.token = dict["token"].toString();
    info.repo_id = dict["repo_id"].toString();
    info.repo_name = dict["repo_name"].toString();
    info.encrypted = dict["encrypted"].toInt();
    info.magic = dict["magic"].toString();
    info.random_key = dict["random_key"].toString();
    info.enc_version = dict.value("enc_version", 1).toInt();
    info.readonly = read_only;

    QUrl url = url_in;
    url.setPath("/");
    info.relay_addr = url.host();

    QMap<QString, QVariant> map;
    map.insert("is_readonly", read_only ? 1 : 0);
    map.insert("server_url", url.toString());

    info.more_info = ::mapToJson(map);

    return info;
}
Esempio n. 27
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);                                      
}
Esempio n. 28
0
LegacyTuner::LegacyTuner( const RadioStation& station, const QString& password_md5 )
    : m_retry_counter( 0 ),
      m_station( station )
{
#ifdef WIN32
    static const char *PLATFORM = "win32";
#elif defined Q_WS_X11
    static const char *PLATFORM = "linux";
#elif defined Q_WS_MAC
    static const char *PLATFORM = "mac";
#else
    static const char *PLATFORM = "unknown";
#endif

    QUrl url;
    url.setScheme( "http" );
    url.setHost( "ws.audioscrobbler.com" );
    url.setPath( "/radio/handshake.php" );
    url.addEncodedQueryItem( "version", QCoreApplication::applicationVersion().toAscii() );
    url.addEncodedQueryItem( "platform", PLATFORM );
    url.addEncodedQueryItem( "username", QUrl::toPercentEncoding(lastfm::ws::Username) );
    url.addEncodedQueryItem( "passwordmd5", password_md5.toAscii() );
    url.addEncodedQueryItem( "language", iso3166() );

    QNetworkRequest request( url );
    QNetworkReply* reply = lastfm::nam()->get( request );
    connect( reply, SIGNAL(finished()), SLOT(onHandshakeReturn()) );
}
Esempio n. 29
0
        KJob *UPnPRouter::sendSoapQuery(const QString & query,const QString & soapact,const QString & controlurl)
        {
            // if port is not set, 0 will be returned
            // thanks to Diego R. Brogna for spotting this bug
            if (location.port()<=0)
                location.setPort(80);

            QUrl address;

            address.setScheme(QString("http"));
            address.setHost(location.host());
            address.setPort(location.port());
            address.setPath(controlurl);

            KIO::TransferJob *req = KIO::http_post( address, query.toLatin1(), KIO::HideProgressInfo );

            req->addMetaData("content-type", QString("text/xml"));
            req->addMetaData("UserAgent", QString("Konversation UPnP"));
            req->addMetaData("customHTTPHeader", QString("SOAPAction: ") + soapact);

            soap_data_out[req] = QByteArray();
            soap_data_in[req]  = QByteArray();

            connect(req, &KIO::TransferJob::data, this, &UPnPRouter::recvSoapData);
            connect(req, &KIO::TransferJob::dataReq, this, &UPnPRouter::sendSoapData);

            connect(req, &KIO::TransferJob::result, this, &UPnPRouter::onRequestFinished);

            return req;
        }
Esempio n. 30
0
void GolangEdit::editorViewGodoc()
{
    LiteApi::ITextLexer *textLexer = LiteApi::getTextLexer(m_editor);
    if (!textLexer) {
        return;
    }
    QTextCursor cursor = m_editor->textCursor();
    bool b = textLexer->isInImport(cursor);
    if (!b) {
        return;
    }
    QString pkg = parser_import(cursor.block().text());
    if (pkg.isEmpty()) {
        return;
    }
    LiteApi::IGolangDoc *doc = LiteApi::getGolangDoc(m_liteApp);
    if (!doc) {
        return;
    }
    QUrl url;
    url.setScheme("pdoc");
    url.setPath(pkg);
    doc->openUrl(url);
    doc->activeBrowser();
}