Ejemplo n.º 1
0
QUrl DownloadManager::redirectUrl(const QUrl& url) const
{
    QUrl redirectUrl = url;
    if (url.host() == QLatin1String("www.dropbox.com")) {
#if QT_VERSION >= 0x050000
        QUrlQuery urlQuery(url);
        QList< QPair<QString, QString> > query = urlQuery.queryItems();
        for (QList< QPair<QString, QString> >::iterator it = query.begin(); it != query.end(); ++it) {
            if (it->first == QLatin1String("dl")) {
                if (it->second == QLatin1String("0\r\n")) {
                    urlQuery.removeQueryItem(QLatin1String("dl"));
                    urlQuery.addQueryItem(QLatin1String("dl"), QLatin1String("1\r\n"));
                }
                else if (it->second == QLatin1String("0")) {
                    urlQuery.removeQueryItem(QLatin1String("dl"));
                    urlQuery.addQueryItem(QLatin1String("dl"), QLatin1String("1"));
                }
                break;
            }
        }
        redirectUrl.setQuery(urlQuery);
#else
        QList< QPair<QString, QString> > query = url.queryItems();
        for (QList< QPair<QString, QString> >::iterator it = query.begin(); it != query.end(); ++it) {
            if (it->first == QLatin1String("dl")) {
                if (it->second == QLatin1String("0\r\n")) {
                    redirectUrl.removeQueryItem(QLatin1String("dl"));
                    redirectUrl.addQueryItem(QLatin1String("dl"), QLatin1String("1\r\n"));
                }
                else if (it->second == QLatin1String("0")) {
                    redirectUrl.removeQueryItem(QLatin1String("dl"));
                    redirectUrl.addQueryItem(QLatin1String("dl"), QLatin1String("1"));
                }
                break;
            }
        }
#endif
    }
    else {
        // When the url comes from drag and drop it may end with CR+LF. This may cause problems
        // and thus should be removed.
        QString str = redirectUrl.toString();
        if (str.endsWith(QLatin1String("\r\n"))) {
            str.chop(2);
            redirectUrl.setUrl(str);
        }
    }

    return redirectUrl;
}
Ejemplo n.º 2
0
int Url::removeQueryItem ( lua_State * L )// ( const QString & key ) 
{
	QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
	//QString* key = ValueInstaller2<QString>::check( L, 2 );
	lhs->removeQueryItem( Util::toString( L, 2 ) );
	return 0;
}
Ejemplo n.º 3
0
void BrowserFrame::openLink(QUrl url, QString title) {
	// Set utm params
	url.removeQueryItem("utm_source");
	url.removeQueryItem("utm_medium");
	url.removeQueryItem("utm_term");
	url.removeQueryItem("utm_content");
	url.removeQueryItem("utm_campaign");
	url.addQueryItem("utm_source", "webpedia");
	url.addQueryItem("utm_medium", "reader");

	QWebView *browser = new QWebView(this);
	browser->setUrl(url);
	connect(browser, SIGNAL(loadFinished(bool)), SLOT(browserLoaded(bool)));

	addTab(browser, title);
	setCurrentIndex(count()-1);
}
Ejemplo n.º 4
0
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);
}
Ejemplo n.º 5
0
void QUrlProto::removeQueryItem(const QString &key)
{
  QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
  if (item)
    item->removeQueryItem(key);
}