Exemple #1
0
void Devolucion::on_mui_browser_anchorClicked ( const QUrl &anchor )
{
    if ( anchor.queryItemValue ( "op" ) == "minus" ) {

        if ( m_ticket->dbValue ( "idalbaran" ).isEmpty() ) return;
        int sizein = m_ticket->listaLineas()->size();
        for ( int i = 0; i < sizein; ++i ) {
            BlDbRecord *item = m_ticket->listaLineas() ->at ( i );
            if ( item->dbValue ( "numlalbaran" ) == anchor.queryItemValue ( "numlalbaran" ) ) {
                BlDbRecord *nitem = m_ticket->agregarLinea();
                QList<BlDbField *> *lista = item->lista();
                for ( int j = 0; j < lista->size(); ++j ) {
                    BlDbField * camp = lista->at ( j );
                    if ( camp->fieldName() != "numlalbaran" ) {
                        nitem->setDbValue ( camp->fieldName(), camp->fieldValue() );
                    } // end if
                    if ( camp->fieldName() == "cantlalbaran" && camp->fieldValue().toFloat() > 0 ) {
                        nitem->setDbValue ( camp->fieldName(), "-1" );
                    }// end if
                } // end if
            } // end for
        }// end for

    } // end if

    pintar();
}
bool OpenLocalHelper::openLocalFile(const QUrl &url)
{
    if (url.scheme() != kSeafileProtocolScheme) {
        qWarning("[OpenLocalHelper] unknown scheme %s\n", url.scheme().toUtf8().data());
        return false;
    }

    if (url.host() != kSeafileProtocolHostOpenFile) {
        qWarning("[OpenLocalHelper] unknown command %s\n", url.host().toUtf8().data());
        return false;
    }

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QUrlQuery url_query = QUrlQuery(url.query());
    QString repo_id = url_query.queryItemValue("repo_id", QUrl::FullyDecoded);
    QString email = url_query.queryItemValue("email", QUrl::FullyDecoded);
    QString path = url_query.queryItemValue("path", QUrl::FullyDecoded);
#else
    QString repo_id = url.queryItemValue("repo_id");
    QString email = url.queryItemValue("email");
    QString path = url.queryItemValue("path");
#endif

    if (repo_id.size() < 36) {
        qWarning("[OpenLocalHelper] invalid repo_id %s\n", repo_id.toUtf8().data());
        return false;
    }

    qDebug("[OpenLocalHelper] open local file: repo %s, path %s\n",
           repo_id.toUtf8().data(), path.toUtf8().data());

    RepoService::instance()->openLocalFile(repo_id, path);

    return true;
}
QgsVectorLayer *QgsMimeDataUtils::Uri::vectorLayer( bool &owner, QString &error ) const
{
  owner = false;
  if ( layerType != QLatin1String( "vector" ) )
  {
    error = QObject::tr( "%1: Not a vector layer." ).arg( name );
    return nullptr;
  }
  if ( providerKey == QLatin1String( "memory" ) )
  {
    QUrl url = QUrl::fromEncoded( uri.toUtf8() );
    if ( !url.hasQueryItem( QStringLiteral( "pid" ) ) || !url.hasQueryItem( QStringLiteral( "layerid" ) ) )
    {
      error = QObject::tr( "Memory layer uri does not contain process or layer id." );
      return nullptr;
    }
    qint64 pid = url.queryItemValue( QStringLiteral( "pid" ) ).toLongLong();
    if ( pid != QCoreApplication::applicationPid() )
    {
      error = QObject::tr( "Memory layer from another QGIS instance." );
      return nullptr;
    }
    QString layerId = url.queryItemValue( QStringLiteral( "layerid" ) );
    QgsVectorLayer *vectorLayer = QgsProject::instance()->mapLayer<QgsVectorLayer *>( layerId );
    if ( !vectorLayer )
    {
      error = QObject::tr( "Cannot get memory layer." );
      return nullptr;
    }
    return vectorLayer;
  }
  owner = true;
  return new QgsVectorLayer( uri, name, providerKey );
}
bool
GlobalActionManager::handlePlaylistCommand( const QUrl& url )
{
    QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
    if ( parts.isEmpty() )
    {
        tLog() << "No specific playlist command:" << url.toString();
        return false;
    }

    if ( parts[ 0 ] == "import" )
    {
        if ( !url.hasQueryItem( "xspf" ) && !url.hasQueryItem( "jspf") )
        {
            tDebug() << "No xspf or jspf to load...";
            return false;
        }
        if ( url.hasQueryItem( "xspf") )
        {
            QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) );
            QString title =  url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
            XSPFLoader* l= new XSPFLoader( true, this );
            l->setOverrideTitle( title );
            l->load( xspf );
            connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
        }
        else if ( url.hasQueryItem( "jspf" ) )
        {
            QUrl jspf = QUrl::fromUserInput( url.queryItemValue( "jspf" ) );
            QString title =  url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
            JSPFLoader* l= new JSPFLoader( true, this );
            l->setOverrideTitle( title );
            l->load( jspf );
            connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
        }
    }
    else if ( parts [ 0 ] == "new" )
    {
        if ( !url.hasQueryItem( "title" ) )
        {
            tLog() << "New playlist command needs a title...";
            return false;
        }
        playlist_ptr pl = Playlist::create( SourceList::instance()->getLocal(), uuid(), url.queryItemValue( "title" ), QString(), QString(), false );
        ViewManager::instance()->show( pl );
    }
    else if ( parts[ 0 ] == "add" )
    {
        if ( !url.hasQueryItem( "playlistid" ) || !url.hasQueryItem( "title" ) || !url.hasQueryItem( "artist" ) )
        {
            tLog() << "Add to playlist command needs playlistid, track, and artist..." << url.toString();
            return false;
        }
        // TODO implement. Let the user select what playlist to add to
        return false;
    }

    return false;
}
Exemple #5
0
void Client::Login(const QUrl& loginUrl)
{
    // We support tundra, http and https scheme login urls
    QString urlScheme = loginUrl.scheme().toLower();
    if (urlScheme.isEmpty())
        return;
    if (urlScheme != "tundra" && urlScheme != "http" && urlScheme != "https")
        return;

    // Make sure to logout to empty the previous properties map.
    if (IsConnected())
        DoLogout();

    // Set properties that the "lower" overload wont be adding:
    // Iterate all query items and parse them to go into the login properties.
    // This will leave percent encoding to the parameters! We remove it by hand from username below!
    QList<QPair<QString, QString> > queryItems = loginUrl.queryItems();
    for (int i=0; i<queryItems.size(); i++)
    {
        // Skip the ones that are handled by below logic
        QPair<QString, QString> queryItem = queryItems.at(i);
        if (queryItem.first == "username" || queryItem.first == "password" || queryItem.first == "protocol")
            continue;
        QByteArray utfQueryValue = queryItem.second.toUtf8();
        if (utfQueryValue.contains('%'))
        {
            // Use QUrl to decode percent encoding instead of QByteArray.
            queryItem.second = QUrl::fromEncoded(utfQueryValue).toString();
        }
        SetLoginProperty(queryItem.first, queryItem.second);
    }

    // Parse values from url
    QString username = loginUrl.queryItemValue("username");
    QString password = loginUrl.queryItemValue("password");
    QString protocol = loginUrl.queryItemValue("protocol");
    QString address = loginUrl.host();
    int port = loginUrl.port();

    // If the username is more exotic or has spaces, prefer 
    // decoding the percent encoding before it is sent to the server.
    QByteArray utfUsername = loginUrl.queryItemValue("username").toUtf8();
    if (utfUsername.contains('%'))
    {
        // Use QUrl to decode percent encoding instead of QByteArray.
        username = QUrl::fromEncoded(utfUsername).toString();
    }

    // Validation: Username and address is the minimal set that with we can login with
    if (username.isEmpty() || address.isEmpty())
    {
        ::LogError("Client::Login: Cannot log to server, no username defined in login url: " + loginUrl.toString());
        return;
    }
    if (port < 0)
        port = 2345;

    Login(address, port, username, password, protocol);
}
bool ActivatePage::getAccessToken()
{
    serverQueryFinished = false;
    serverQueryError = false;
    disconnect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    label_message->setText("Requesting key...");

    QUrl url( "https://screencloud.net/1.0/oauth/access_token_xauth" );
    // create a request parameters map
    QUrl bodyParams;
    bodyParams.addQueryItem( "data[User][email]", field("register.email").toString());
    bodyParams.addQueryItem( "data[User][password]", field("register.password").toString());
    bodyParams.addQueryItem("oauth_version", "1.0");
    bodyParams.addQueryItem("oauth_signature_method", "PLAINTEXT");
    bodyParams.addQueryItem("oauth_consumer_key", CONSUMER_KEY_SCREENCLOUD);
    bodyParams.addQueryItem("oauth_signature", CONSUMER_SECRET_SCREENCLOUD);
    bodyParams.addQueryItem("oauth_timestamp", QString::number(QDateTime::currentDateTimeUtc().toTime_t()));
    bodyParams.addQueryItem("oauth_nonce", NetworkUtils::generateNonce(15));
    QByteArray body = bodyParams.encodedQuery();

    QNetworkRequest request;
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    request.setUrl(url);
    QNetworkReply* reply = manager->post(request, body);
    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();
    connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    if ( reply->error() == QNetworkReply::NoError ) {
        //Save to qsettings
        QString replyText = reply->readAll();
        if(replyText.isEmpty())
        {
            label_message->setText("<font color='red'>Failed to get credentials. Empty reply from server.</font>");
            return false;
        }
        INFO(reply->request().url().toString() + " returned: " + replyText);
        QUrl replyParams = QUrl("?" + replyText);
        QSettings settings("screencloud", "ScreenCloud");
        settings.beginGroup("account");
        settings.setValue("token", replyParams.queryItemValue("oauth_token"));
        settings.setValue("token-secret", replyParams.queryItemValue("oauth_token_secret"));
        settings.setValue("email", field("register.email").toString());
        settings.setValue("logged-in", true);
        settings.endGroup();
        return true;
    }else
    {
        label_message->setText("<font color='red'>OAuth error</font>");
        return false;
    }
    return false;
}
bool
GlobalActionManager::handlePlaylistCommand( const QUrl& url )
{
    QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
    if ( parts.isEmpty() )
    {
        tLog() << "No specific playlist command:" << url.toString();
        return false;
    }

    if ( parts[ 0 ] == "import" )
    {
        if ( !url.hasQueryItem( "xspf" ) && !url.hasQueryItem( "jspf") )
        {
            tDebug() << "No xspf or jspf to load...";
            return false;
        }
        if ( url.hasQueryItem( "xspf" ) )
        {
            createPlaylistFromUrl( "xspf", url.queryItemValue( "xspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
            return true;
        }
        else if ( url.hasQueryItem( "jspf" ) )
        {
            createPlaylistFromUrl( "jspf", url.queryItemValue( "jspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
            return true;
        }
    }
    else if ( parts [ 0 ] == "new" )
    {
        if ( !url.hasQueryItem( "title" ) )
        {
            tLog() << "New playlist command needs a title...";
            return false;
        }
        playlist_ptr pl = Playlist::create( SourceList::instance()->getLocal(), uuid(), url.queryItemValue( "title" ), QString(), QString(), false );
        ViewManager::instance()->show( pl );
    }
    else if ( parts[ 0 ] == "add" )
    {
        if ( !url.hasQueryItem( "playlistid" ) || !url.hasQueryItem( "title" ) || !url.hasQueryItem( "artist" ) )
        {
            tLog() << "Add to playlist command needs playlistid, track, and artist..." << url.toString();
            return false;
        }
        // TODO implement. Let the user select what playlist to add to
        return false;
    }

    return false;
}
void BrowserDialog::linkClicked(const QUrl& url)
{
    do {
        if (url.host() != DOWNLOAD_HOST_BASE) {
            break;
        }
        if (url.path() != "/dict/download_cell.php") {
            break;
        }
        QString id = url.queryItemValue("id");
        QByteArray name = url.encodedQueryItemValue("name");
        QString sname = decodeName(name);

        m_name = sname;

        if (!id.isEmpty() && !sname.isEmpty()) {
            download(url);
            return;
        }
    } while(0);

    if (url.host() != HOST_BASE) {
        QMessageBox::information(this, _("Wrong Link"),
                                 _("No browsing outside pinyin.sogou.com, now redirect to home page."));
        m_ui->webView->load(QUrl(URL_BASE));
    } else {
        m_ui->webView->load(url);
    }
}
Exemple #9
0
QString QUrlProto::queryItemValue(const QString &key) const
{
  QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
  if (item)
    return item->queryItemValue(key);
  return QString();
}
void Utils::testIncludeUrlParams() {
    QUrl urla(QString("http://example.com"));

    QHash<QString, QString> params;
    params.insert("simple", "c");
    params.insert("withspecial", "a?b");
    params.insert("withspace", "a b");
    params.insert("username", "a123fx b");
    params.insert("password", "!@#+-$%^12&*()qweqesaf\"';`~");
    params.insert("withplus", "a+b");

    QUrl urlb = ::includeQueryParams(urla, params);

    QVERIFY(urla.scheme() == urlb.scheme());
    QVERIFY(urla.host() == urlb.host());

    Q_FOREACH (const QString& key, params.keys()) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
        QString encoded_key = QUrl::toPercentEncoding(key);
        QString encoded_value = QUrl::toPercentEncoding(params[encoded_key]);
        QUrlQuery query = QUrlQuery(urlb.query());
        QVERIFY(query.queryItemValue(encoded_key, QUrl::FullyEncoded) == encoded_value);
#else
        QVERIFY(urlb.queryItemValue(key) == params[key]);
#endif
    }
}
Exemple #11
0
int Url::queryItemValue ( lua_State * L )// ( const QString & key ) const : QString
{
	QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
	//QString* key = ValueInstaller2<QString>::check( L, 2 );
	Util::push(L, lhs->queryItemValue( Util::toString( L, 2 ) ) );
	return 1;
}
Exemple #12
0
void MegaShares::checkUrl(const QUrl &webUrl) {
    QNetworkRequest request;
#if QT_VERSION >= 0x050000
    QUrlQuery query(webUrl);
    
    if (query.hasQueryItem("d01")) {
        m_fileName = query.queryItemValue("d01");
        request.setUrl(webUrl);
    }
#else
    if (webUrl.hasQueryItem("d01")) {
        m_fileName = webUrl.queryItemValue("d01");
        request.setUrl(webUrl);
    }
#endif
    else {
        QString urlString = webUrl.toString();
        m_fileName = urlString.section('/', -1);
        QString id = urlString.section("/dl/", 1, 1).section('/', 0, 0);
        request.setUrl(QUrl("http://d01.megashares.com/?d01=" + id));
    }

    request.setRawHeader("Accept-Language", "en-GB,en-US;q=0.8,en;q=0.6");
    QNetworkReply *reply = this->networkAccessManager()->get(request);
    this->connect(reply, SIGNAL(finished()), this, SLOT(checkUrlIsValid()));
    this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater()));
}
Exemple #13
0
bool VkAuthManager::CheckIsBlank (QUrl location)
{
    if (location.path () != "/blank.html")
        return false;

    location = QUrl::fromEncoded (location.toEncoded ().replace ('#', '?'));
    Token_ = location.queryItemValue ("access_token");
    ValidFor_ = location.queryItemValue ("expires_in").toInt ();
    ReceivedAt_ = QDateTime::currentDateTime ();
    qDebug () << Q_FUNC_INFO << Token_ << ValidFor_;
    IsRequesting_ = false;

    emit gotAuthKey (Token_);

    return true;
}
Exemple #14
0
	bool VkAuthManager::CheckError (const QUrl& url)
	{
		if (url.path () != "/error")
			return false;

#if QT_VERSION < 0x050000
		const auto errNum = url.queryItemValue ("err").toInt ();
#else
		const auto errNum = QUrlQuery { url }.queryItemValue ("err").toInt ();
#endif

		IsRequesting_ = false;

		qWarning () << Q_FUNC_INFO
				<< "got error"
				<< errNum;
		if (errNum == 2)
		{
			clearAuthData ();

			RequestAuthKey ();
			return true;
		}

		const auto& e = Util::MakeNotification ("VK.com",
				tr ("VK.com authentication for %1 failed because of error %2. "
					"Report upstream please.")
					.arg (AccountHR_)
					.arg (errNum),
				PCritical_);
		Proxy_->GetEntityManager ()->HandleEntity (e);

		return true;
	}
void Comments::anchorClicked(const QUrl & url)
{
  if(url.host().isEmpty() && url.path() == "edit")
  {
    #if QT_VERSION >= 0x050000
    int cid = QUrlQuery(url).queryItemValue("id").toInt();
    #else
    int cid = url.queryItemValue("id").toInt();
    #endif
    if(userCanEdit(cid))
    {
      ParameterList params;
      params.append("mode", "edit");
      params.append("sourceType", _sourcetype);
      params.append("source_id", _sourceid);
      params.append("comment_id", cid);
      params.append("commentIDList", _commentIDList);

      comment newdlg(this, "", true);
      newdlg.set(params);
      newdlg.exec();
      refresh();
    }
  }
  else
  {
    QDesktopServices::openUrl(url);
  }
}
void EvopediaWebServer::readClient()
{
    QTcpSocket* socket = (QTcpSocket*)sender();
    if (!socket->canReadLine()) return;
    /* TODO1 wait for end of request header? peek? */

    const QList<QByteArray> tokens = socket->readLine().split(' ');
    if (tokens[0] != "GET" || tokens.size() < 2) {
        outputHeader(socket, "404");
        closeConnection(socket);
        return;
    }

    const QUrl url = QUrl::fromPercentEncoding(tokens[1]);

    QString path = url.path();
    if (path.endsWith("skins/common/images/magnify-clip.png"))
        path = "/static/magnify-clip.png";

    const QStringList pathParts = path.mid(1).split('/');
    if (pathParts.length() < 1 || pathParts[0].isEmpty()) {
        outputIndexPage(socket);
        closeConnection(socket);
        return;
    }
    const QString &firstPart = pathParts[0];
    if (firstPart == "static") {
        outputStatic(socket, pathParts);
    } else if (firstPart == "search") {
        outputSearchResult(socket, url.queryItemValue("q"), url.queryItemValue("lang"));
    } else if (firstPart == "map") {
        qreal lat = url.queryItemValue("lat").toDouble();
        qreal lon = url.queryItemValue("lon").toDouble();
        int zoom = url.queryItemValue("zoom").toInt();
        mapViewRequested(lat, lon, zoom);
    } else if (firstPart == "random") {
        redirectRandom(socket, pathParts);
    } else if (firstPart == "math" ||
               (firstPart == "wiki" && pathParts.length() >= 2 && pathParts[1] == "math")) {
        outputMathImage(socket, pathParts);
    } else if (firstPart == "wiki" || firstPart == "articles") {
        outputWikiPage(socket, pathParts);
    } else {
        outputHeader(socket, "404");
    }
    closeConnection(socket);
}
Exemple #17
0
bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &response)
{
    if (m_step == 0) {
        // no initial response
        response = QByteArray();
        m_step++;
        return true;
    } else if (m_step == 1) {
        // parse request
#if QT_VERSION >= 0x050000
        QUrlQuery requestUrl(challenge);
#else
        QUrl requestUrl;
        requestUrl.setEncodedQuery(challenge);
#endif
        if (!requestUrl.hasQueryItem("method") || !requestUrl.hasQueryItem("nonce")) {
            warning("QXmppSaslClientFacebook : Invalid challenge, nonce or method missing");
            return false;
        }

        // build response
#if QT_VERSION >= 0x050000
        QUrlQuery responseUrl;
#else
        QUrl responseUrl;
#endif
        responseUrl.addQueryItem("access_token", password());
        responseUrl.addQueryItem("api_key", username());
        responseUrl.addQueryItem("call_id", 0);
        responseUrl.addQueryItem("method", requestUrl.queryItemValue("method"));
        responseUrl.addQueryItem("nonce", requestUrl.queryItemValue("nonce"));
        responseUrl.addQueryItem("v", "1.0");

#if QT_VERSION >= 0x050000
        response = responseUrl.query().toUtf8();
#else
        response = responseUrl.encodedQuery();
#endif
        m_step++;
        return true;
    } else {
        warning("QXmppSaslClientFacebook : Invalid step");
        return false;
    }
}
Exemple #18
0
int 
QDjViewOutline::pageNumber(const char *link)
{
  if (link && link[0] == '#')
    return djview->pageNumber(QString::fromUtf8(link+1));
  if (link == 0 || link[0] != '?')
    return -1;
  QByteArray burl = QByteArray("http://f/f") + link;
#if QT_VERSION >= 0x50000
  QUrlQuery qurl(QUrl::fromEncoded(burl));
#else
  QUrl qurl = QUrl::fromEncoded(burl);
#endif
  if (qurl.hasQueryItem("page"))
    return djview->pageNumber(qurl.queryItemValue("page"));
  else if (qurl.hasQueryItem("pageno"))
    return djview->pageNumber("$" + qurl.queryItemValue("pageno"));
  return -1;
}
	void startHandleRequest(ZhttpRequest *req, int basePathStart, const QByteArray &asPath, const DomainMap::Entry &route)
	{
		Session *s = new Session(this);
		s->req = req;

		QUrl uri = req->requestUri();

		QByteArray encPath = uri.encodedPath();
		s->path = encPath.mid(basePathStart);

		QList<QByteArray> parts = s->path.split('/');
		if(!parts.isEmpty() && parts.last().startsWith("jsonp"))
		{
			if(uri.hasQueryItem("callback"))
			{
				s->jsonpCallback = uri.queryItemValue("callback").toUtf8();
				uri.removeAllQueryItems("callback");
			}
			else if(uri.hasQueryItem("c"))
			{
				s->jsonpCallback = uri.queryItemValue("c").toUtf8();
				uri.removeAllQueryItems("c");
			}
		}

		s->asUri = uri;
		s->asUri.setScheme((s->asUri.scheme() == "https") ? "wss" : "ws");
		if(!asPath.isEmpty())
			s->asUri.setEncodedPath(asPath);
		else
			s->asUri.setEncodedPath(encPath.mid(0, basePathStart));

		s->route = route;

		connect(req, SIGNAL(readyRead()), SLOT(req_readyRead()));
		connect(req, SIGNAL(bytesWritten(int)), SLOT(req_bytesWritten(int)));
		connect(req, SIGNAL(error()), SLOT(req_error()));

		sessions += s;
		sessionsByRequest.insert(s->req, s);

		processRequestInput(s);
	}
QNetworkReply * WaveletNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest & req, QIODevice * outgoingData)
{
    QUrl url = req.url();
    if (url.scheme() == "avatar")
        return new AvatarReply(url);
    else if (url.scheme() == "wavelet") {
        if (url.queryItemValue("rc") == "gadget")
            return new GadgetReply(this, this->m_hostName, url);
        else if (url.queryItemValue("rc") == "gadget-wrapper") {
            QUrl rcUrl("wavelet:load");
            rcUrl.setQueryItems(QList< QPair<QString, QString> >() << QPair<QString, QString>("rc", "js") << QPair<QString, QString>("name", "gadget-wrapper"));
            return new ResourceReply(rcUrl);
        }
        else
            return new ResourceReply(url);
    }
    else
        return QNetworkAccessManager::createRequest(op, req, outgoingData);
}
void collectionListAssetsJob::Private::init(collectionListAssetsJob *parent,
                                        const QUrl &url)
{
    q = parent;

    QString offsetStr = url.queryItemValue(
        QLatin1String("offset"));
    QString pageSizeStr = url.queryItemValue(
        QLatin1String("pageSize"));

    if (offsetStr.isEmpty())
        offset = -1;
    else
        offset = offsetStr.toInt();

    if (pageSizeStr.isEmpty())
        pageSize = -1;
    else
        pageSize = pageSizeStr.toInt();
}
void NetFlixAuthProxy::userTokenRequestCompleted(int retCode, QString body)
{
    qDebug() << "user token completed!!";
    qDebug() << retCode;
    qDebug() << body;

    QUrl parser;
    parser.setEncodedQuery(body.toUtf8());


    QString user_id = parser.queryItemValue(STR(OAUTH_USER_ID));
    QString token = parser.queryItemValue(STR(OAUTH_TOKEN));
    QString token_secret = parser.queryItemValue(STR(OAUTH_TOKEN_SECRET));

    settings->setUserId(user_id);
    settings->setOAuthToken(token);
    settings->setOAuthTokenSecret(token_secret);

    emit getUserTokenSucceeded();
}
Exemple #23
0
void LiteDoc::openUrlFile(const QUrl &url)
{
    QFileInfo info(url.toLocalFile());
    if (!info.exists()) {
        info.setFile(url.path());
    }
    QString ext = info.suffix().toLower();
    if (ext == "html") {
        QFile file(info.filePath());
        if (file.open(QIODevice::ReadOnly)) {
            QByteArray ba = file.readAll();
            file.close();
            if (info.fileName().compare("docs.html",Qt::CaseInsensitive) == 0) {
                updateHtmlDoc(url,ba,QString(),false);
            } else {
                updateHtmlDoc(url,ba);
            }
        }
    } else if (ext == "md") {
        QFile file(info.filePath());
        if (file.open(QIODevice::ReadOnly)) {
            QByteArray ba = mdtohtml(file.readAll());
            updateHtmlDoc(url,ba);
        }
    } else if (ext == "go") {
        LiteApi::IEditor *editor = m_liteApp->fileManager()->openEditor(info.filePath());
        if (editor) {
            editor->setReadOnly(true);
            QPlainTextEdit *ed = LiteApi::findExtensionObject<QPlainTextEdit*>(editor,"LiteApi.QPlainTextEdit");
            if (ed && url.hasQueryItem("s")) {
                QStringList pos = url.queryItemValue("s").split(":");
                if (pos.length() == 2) {
                    bool ok = false;
                    int begin = pos.at(0).toInt(&ok);
                    if (ok) {
                        QTextCursor cur = ed->textCursor();
                        cur.setPosition(begin);
                        ed->setTextCursor(cur);
                        ed->centerCursor();
                    }
                }
            }
        }
    } else if (ext == "pdf") {
        QDesktopServices::openUrl(info.filePath());
    } else {
        QFile file(info.filePath());
        if (file.open(QIODevice::ReadOnly)) {
            QByteArray ba = file.readAll();
            updateTextDoc(url,ba,info.fileName());
        }
    }
}
Exemple #24
0
void ChannelsJob::Private::init(ChannelsJob *parent,
                                const QString &id,
                                const QUrl &url)
{
    q = parent;
    channelId = id;
    QString offsetStr = url.queryItemValue(
                            QLatin1String("offset"));
    QString pageSizeStr = url.queryItemValue(
                              QLatin1String("pageSize"));

    if (offsetStr.isEmpty())
        offset = -1;
    else
        offset = offsetStr.toInt();

    if (pageSizeStr.isEmpty())
        pageSize = -1;
    else
        pageSize = pageSizeStr.toInt();
}
/** Returns the GET data for the given \a key.
 */
QString QDjangoHttpRequest::get(const QString &key) const
{
    QString queryString = d->meta.value(QLatin1String("QUERY_STRING"));
    queryString.replace('+', ' ');
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    QUrlQuery query(queryString);
    return query.queryItemValue(key, QUrl::FullyDecoded);
#else
    QUrl url;
    url.setEncodedQuery(queryString.toLatin1());
    return url.queryItemValue(key);
#endif
}
/** Returns the POST data for the given \a key.
 */
QString QDjangoHttpRequest::post(const QString &key) const
{
    QByteArray buffer = d->buffer;
    buffer.replace('+', ' ');
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    QUrlQuery query(QString::fromUtf8(buffer));
    return query.queryItemValue(key, QUrl::FullyDecoded);
#else
    QUrl url;
    url.setEncodedQuery(buffer);
    return url.queryItemValue(key);
#endif
}
bool
GlobalActionManager::handleImportCommand( const QUrl& url )
{
    QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
    if ( parts.size() < 1 )
        return false;

    if ( parts[ 0 ] == "playlist" )
    {
        if ( url.hasQueryItem( "xspf" ) )
        {
            createPlaylistFromUrl( "xspf", url.queryItemValue( "xspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
            return true;
        }
        else if ( url.hasQueryItem( "jspf" ) )
        {
            createPlaylistFromUrl( "jspf", url.queryItemValue( "jspf" ), url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString() );
            return true;
        }
    }

    return false;
}
Exemple #28
0
	bool VkAuthManager::CheckReply (QUrl location)
	{
		if (location.path () != "/blank.html")
			return CheckError (location);

		location = QUrl::fromEncoded (location.toEncoded ().replace ('#', '?'));
#if QT_VERSION < 0x050000
		Token_ = location.queryItemValue ("access_token");
		ValidFor_ = location.queryItemValue ("expires_in").toInt ();
#else
		const QUrlQuery query { location };
		Token_ = query.queryItemValue ("access_token");
		ValidFor_ = query.queryItemValue ("expires_in").toInt ();
#endif
		ReceivedAt_ = QDateTime::currentDateTime ();
		qDebug () << Q_FUNC_INFO << Token_ << ValidFor_;
		IsRequesting_ = false;

		InvokeQueues (Token_);
		emit gotAuthKey (Token_);
		emit justAuthenticated ();

		return true;
	}
void NetFlixAuthProxy::loginUrlRequestCompleted(int retCode, QString body)
{
    qDebug() << "temp token completed!!";
    qDebug() << retCode;
    qDebug() << body;

    QUrl parser;
    parser.setEncodedQuery(body.toUtf8());

    QString url = parser.queryItemValue(STR(NETFLIX_LOGIN_URL_PARAM));
    parser.removeQueryItem(STR(NETFLIX_LOGIN_URL_PARAM));

    QString token = parser.queryItemValue(STR(OAUTH_TOKEN));
    QString token_secret = parser.queryItemValue(STR(OAUTH_TOKEN_SECRET));
    parser.removeQueryItem(STR(OAUTH_TOKEN_SECRET));

    settings->setOAuthToken(token);
    settings->setOAuthTokenSecret(token_secret);

    QUrl loginUrl = QUrl(url);
    loginUrl.setEncodedQueryItems(parser.encodedQueryItems());
    qDebug() << loginUrl.toEncoded();
    emit getTokenUrlSucceeded(loginUrl);
}
void AuthenticationDialog::urlChanged(const QUrl &url)
{
//     Q_D(AuthenticationDialog);
    kDebug() << "Navigating to" << url;

    if (url.host() == "www.facebook.com" && url.path() == "/connect/login_success.html") {
        d->errorReason = url.queryItemValue("error_reason");
        d->error = url.queryItemValue("error");
        d->errorDescription = url.queryItemValue("error_description").replace('+', ' ');
        if (!d->error.isEmpty() || !d->errorReason.isEmpty() || !d->errorDescription.isEmpty()) {
            QTimer::singleShot(0, this, SLOT(showErrorDialog()));
            return;
        }

        // The URL comes in the form "bla#access_token=bla&expires_in=foo", we need to convert from
        // # to ?
        const QUrl fixedURL = QUrl::fromUserInput(url.toString().replace('#', '?'));
        const QString accessToken = fixedURL.queryItemValue("access_token");
        if (!accessToken.isEmpty()) {
            emit authenticated(accessToken);
            accept();
        }
    }
}