Beispiel #1
0
QList<QNetworkCookie> CookieJar::cookies(const QUrl& url) const
{
	if(url.isEmpty())
		return allCookies();
	else
		return cookiesForUrl(url);
}
Beispiel #2
0
QVariantList CookieJar::getCookies(const QString &url) {
    QVariantList cookiesList;
    QVariantMap cookie;

    foreach(QNetworkCookie n_cookie, cookiesForUrl(QUrl(url))) {
        cookie["name"] = QString::fromUtf8(n_cookie.name());
        cookie["value"] = QString::fromUtf8(n_cookie.value());
        cookie["domain"] = n_cookie.domain();
        cookie["path"] = n_cookie.path();
        cookie["expires"] = n_cookie.expirationDate().toString(Qt::ISODate);

        cookiesList.append(cookie);
    }
Beispiel #3
0
void RSSImp::on_actionManage_cookies_triggered()
{
    Q_ASSERT(!m_feedList->selectedItems().empty());

    // TODO: Create advanced application wide Cookie dialog and use it everywhere.
    QUrl feedUrl = QUrl::fromEncoded(m_feedList->getItemID(m_feedList->selectedItems().first()).toUtf8());
    QList<QNetworkCookie> cookies;
    if (CookiesDlg::askForCookies(this, feedUrl, cookies)) {
        auto downloadManager = Net::DownloadManager::instance();
        QList<QNetworkCookie> oldCookies = downloadManager->cookiesForUrl(feedUrl);
        foreach (const QNetworkCookie &oldCookie, oldCookies) {
            if (!cookies.contains(oldCookie))
                downloadManager->deleteCookie(oldCookie);
        }

        downloadManager->setCookiesFromUrl(cookies, feedUrl);
    }
Beispiel #4
0
void CookieJar::deleteCookieForUrl(const QUrl& url, const QString& cookieName)
{
#ifdef U_CJ_DEBUG
	qDebug() << Q_FUNC_INFO;
#endif
	QList<QNetworkCookie> cookieList;

	if(url.isEmpty() || !url.isValid()) {
		if(cookieName.isEmpty()) {
			setAllCookies(QList<QNetworkCookie>());
		} else {
			cookieList = allCookies();

			QList<QNetworkCookie>::Iterator it = cookieList.begin();
			while(it != cookieList.end()) {
				if(it->name() == cookieName) {
					deleteCookie(*it);
					it = cookieList.erase(it);
				} else
					it++;
			}
		}
	} else {
		cookieList = cookiesForUrl(url);

		QList<QNetworkCookie>::Iterator it = cookieList.begin();
		while(it != cookieList.end()) {
			if(it->name() == cookieName || cookieName.isEmpty()) {
				deleteCookie(*it);
				it = cookieList.erase(it);

				if(!cookieName.isEmpty())
					break;
			} else
				it++;
		}
	}
}