当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkCookie类代码示例

本文整理汇总了C++中QNetworkCookie的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkCookie类的具体用法?C++ QNetworkCookie怎么用?C++ QNetworkCookie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QNetworkCookie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cnFile

void CookieJar::loadCookies()
{
    QString fName = m_appPath;
    fName += "cookies";
    QSettings cnFile(fName, QSettings::IniFormat);

    setVkLogin(cnFile.value("login").toString());

    QList<QNetworkCookie> cookies;
    int size = cnFile.beginReadArray("cookies");
    for(int i=0; i<size; i++) {
        QNetworkCookie cook;

        cnFile.setArrayIndex(i);

        cook.setName(cnFile.value("name").toByteArray());
        cook.setValue(cnFile.value("value").toByteArray());
        cook.setDomain(cnFile.value("domain").toByteArray());
        cook.setPath(cnFile.value("path").toByteArray());

        cookies.insert(i, cook);
    }
    cnFile.endArray();

    setAllCookies(cookies);
}
开发者ID:Nerobrain,项目名称:pulsar,代码行数:26,代码来源:cookiejar.cpp

示例2: QWidget

CookieWidget::CookieWidget(const QNetworkCookie &cookie, QWidget *parent): QWidget(parent)
{
    setupUi(this);
    setAutoFillBackground(true);
    m_nameLabel->setText(cookie.name());
    m_domainLabel->setText(cookie.domain());
    connect(m_viewButton, &QPushButton::clicked, this, &CookieWidget::viewClicked);
    connect(m_deleteButton, &QPushButton::clicked, this, &CookieWidget::deleteClicked);
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:9,代码来源:mainwindow.cpp

示例3: insertRows

bool CookiesModel::insertRows(int row, int count, const QModelIndex &parent)
{
    if ((row < 0) || (row > m_cookies.size())) return false;

    QNetworkCookie newCookie;
    newCookie.setExpirationDate(QDateTime::currentDateTime().addYears(99));

    beginInsertRows(parent, row, row + count - 1);
    while (count-- > 0)
        m_cookies.insert(row, newCookie);
    endInsertRows();

    return true;
}
开发者ID:0ly,项目名称:qBittorrent,代码行数:14,代码来源:cookiesmodel.cpp

示例4: QVariant

QVariant CookieModel::data(const QModelIndex &index, int role) const
{
    if (index.row() < 0 || index.row() >= m_cookies.size())
        return QVariant();

    switch (role) {
    case Qt::DisplayRole:
    case Qt::EditRole: {
        QNetworkCookie cookie = m_cookies.at(index.row());
        switch (index.column()) {
        case 0:
            return cookie.domain();
        case 1:
            return cookie.name();
        case 2:
            return cookie.path();
        case 3:
            return cookie.isSecure() ? tr("true") : tr("false");
        case 4:
            return cookie.isSessionCookie() ? tr("Session cookie") : cookie.expirationDate().toString();
        case 5:
            return cookie.value();
        }
    }
    case Qt::FontRole: {
        QFont font;
        font.setPointSize(10);
        return font;
    }
    }

    return QVariant();
}
开发者ID:enkidu,项目名称:arora,代码行数:33,代码来源:cookiemodel.cpp

示例5: onNewCookieCreated

void ShibLoginDialog::onNewCookieCreated(const QUrl& url, const QNetworkCookie& cookie)
{
    QString name = cookie.name();
    if (url.host() == url_.host() && name == kSeahubShibCookieName) {
        QString value = cookie.value();

        Account account = parseAccount(value);
        if (seafApplet->accountManager()->saveAccount(account) < 0) {
            seafApplet->warningBox(tr("Failed to save current account"), this);
            reject();
        } else {
            accept();
        }
    }
}
开发者ID:cxz,项目名称:seafile-client,代码行数:15,代码来源:shib-login-dialog.cpp

示例6: getCookies

void OnetAvatar::getCookies()
{
    /* TODO: replace with central cookies storage */

    QList<QNetworkCookie> cookies;
    QNetworkCookie cookie;

    QStringList constCookies;
    constCookies << "onet_ubi" << "onet_cid" << "onet_sid" << "onet_uid" << "onetzuo_ticket" << "onet_uoi" << "onet_sgn";
    foreach (const QString &constCookie, constCookies)
    {
        cookie.setName(constCookie.toLatin1());
        cookie.setValue(Settings::instance()->get(constCookie).toLatin1());
        cookies.append(cookie);
    }
开发者ID:gitter-badger,项目名称:simplechatclient,代码行数:15,代码来源:onet_avatar.cpp

示例7: rejectCookie

bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie) const
{
    Q_UNUSED(domain)

    const QString &cookieDomain = cookie.domain();

    if (!m_allowCookies) {
        bool result = listMatchesDomain(m_whitelist, cookieDomain);
        if (!result) {
#ifdef COOKIE_DEBUG
            qDebug() << "not in whitelist" << cookie;
#endif
            return true;
        }
    }

    if (m_allowCookies) {
        bool result = listMatchesDomain(m_blacklist, cookieDomain);
        if (result) {
#ifdef COOKIE_DEBUG
            qDebug() << "found in blacklist" << cookie;
#endif
            return true;
        }
    }

// This feature is now natively in QtWebKit 2.3
#if QTWEBKIT_TO_2_3
    if (m_blockThirdParty) {
        bool result = matchDomain(cookieDomain, domain);
        if (!result) {
#ifdef COOKIE_DEBUG
            qDebug() << "purged for domain mismatch" << cookie << cookieDomain << domain;
#endif
            return true;
        }
    }
#endif

    if (m_filterTrackingCookie && cookie.name().startsWith("__utm")) {
#ifdef COOKIE_DEBUG
        qDebug() << "purged as tracking " << cookie;
#endif
        return true;
    }

    return false;
}
开发者ID:Longer,项目名称:qupzilla,代码行数:48,代码来源:cookiejar.cpp

示例8: AddCookie

	void CookiesEditModel::AddCookie (const QNetworkCookie& cookie)
	{
		int i = 0;
		if (Cookies_.size ())
			i = (Cookies_.end () - 1).key () + 1;
		Cookies_ [i] = cookie;
	
		QString domain = cookie.domain ();
	
		QList<QStandardItem*> foundItems = findItems (domain);
		QStandardItem *parent = 0;
		if (!foundItems.size ())
		{
			parent = new QStandardItem (domain);
			parent->setEditable (false);
			parent->setData (-1);
			invisibleRootItem ()->appendRow (parent);
		}
		else
			parent = foundItems.back ();
		QStandardItem *item = new QStandardItem (QString (Cookies_ [i].name ()));
		item->setData (i);
		item->setEditable (false);
		parent->appendRow (item);
	
		Jar_->setAllCookies (Cookies_.values ());
	}
开发者ID:Zereal,项目名称:leechcraft,代码行数:27,代码来源:cookieseditmodel.cpp

示例9: checkThisCookie

void connectWindowClass::checkThisCookie(QNetworkCookie cookie)
{
    if(cookie.name() == "dlrowolleh" || cookie.name() == "coniunctio")
    {
        for(int j = 0; j < cookieList.size(); ++j)
        {
            if(cookieList.at(j).name() == cookie.name())
            {
                cookieList.removeAt(j);
                break;
            }
        }
        cookie.setExpirationDate(QDateTime::currentDateTime().addYears(8));
        cookieList.append(cookie);
    }

    adjustSize();
}
开发者ID:LEpigeon888,项目名称:RespawnIRC,代码行数:18,代码来源:connectWindow.cpp

示例10: if

QScriptValue MyWebView::cookiesFormUrl(QScriptValue url)
{
    QUrl targetUrl;
    if (url.isUndefined()) {
        targetUrl = this->url();
    } else if (url.toString().toLower().trimmed().indexOf("http://") == 0) {
        targetUrl = QUrl(url.toString().toLower().trimmed());
    } else {
        targetUrl = this->url();
    }

    QByteArray str;

    QNetworkCookie cookie;
    QList<QNetworkCookie> list = cookieJar->cookiesForUrl(targetUrl);
    foreach (cookie, list)
    {
        str += cookie.toRawForm() + "\n";
    }
开发者ID:leeight,项目名称:berserkJS,代码行数:19,代码来源:mywebview.cpp

示例11: makePostData

QVariant NicoLiveManager::makePostData(QString session_id)
{
    QVariant postData;

    // make cookies
    QList <QNetworkCookie> cookies;
    QNetworkCookie ck;
    ck.toRawForm(QNetworkCookie::NameAndValueOnly);
    ck.setName("user_session");

    QByteArray user_id_ba;
    user_id_ba.append(session_id);

    ck.setValue(user_id_ba);
    cookies.append(ck);

    postData.setValue(cookies);
    return postData;
}
开发者ID:GitHub30,项目名称:Viqo,代码行数:19,代码来源:nicolivemanager.cpp

示例12: rejectCookie

bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie) const
{
    const QString &cookieDomain = cookie.domain();

    if (!m_allowCookies) {
        int result = listContainsDomain(m_whitelist, cookieDomain);
        if (result != 1) {
#ifdef COOKIE_DEBUG
            qDebug() << "not in whitelist" << cookie;
#endif
            return true;
        }
    }

    if (m_allowCookies) {
        int result = listContainsDomain(m_blacklist, cookieDomain);
        if (result == 1) {
#ifdef COOKIE_DEBUG
            qDebug() << "found in blacklist" << cookie;
#endif
            return true;
        }
    }

    if (m_blockThirdParty) {
        bool result = !containsDomain(cookieDomain, domain);
        if (result) {
#ifdef COOKIE_DEBUG
            qDebug() << "purged for domain mismatch" << cookie << cookieDomain << domain;
#endif
            return true;
        }
    }

    if (m_filterTrackingCookie && cookie.name().startsWith("__utm")) {
#ifdef COOKIE_DEBUG
        qDebug() << "purged as tracking " << cookie;
#endif
        return true;
    }

    return false;
}
开发者ID:ragingsage,项目名称:qupzilla,代码行数:43,代码来源:cookiejar.cpp

示例13: cookie

QNetworkCookie CookieDialog::cookie()
{
    QNetworkCookie cookie;
    cookie.setDomain(m_domainLineEdit->text());
    cookie.setName(m_nameLineEdit->text().toLatin1());
    cookie.setValue(m_valueLineEdit->text().toLatin1());
    cookie.setExpirationDate(QDateTime(m_dateEdit->date()));
    cookie.setPath(m_pathLineEdit->text());
    cookie.setSecure(m_isSecureComboBox->currentText() == tr("yes"));
    cookie.setHttpOnly(m_isHttpOnlyComboBox->currentText() == tr("yes"));
    return cookie;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:12,代码来源:mainwindow.cpp

示例14: foreach

QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl& url) const
{
	QString requestUrl = url.toString();
	QList<QNetworkCookie> cookies = QNetworkCookieJar::cookiesForUrl(url);
	const QList<QString>& registeredDomains = WebKit::instance()->identifierCookieDomainList();


	foreach(QString d, registeredDomains) {
		if(requestUrl.startsWith(d)) {
			QNetworkCookie identifierCookie = WebKit::instance()->identifierCookie();

			identifierCookie.setDomain(d);
			identifierCookie.setSecure(d.startsWith("https") ? true : false);

			cookies.append(identifierCookie);
			break;
		}
	}

	return cookies;
}
开发者ID:unblu,项目名称:webkit-headless,代码行数:21,代码来源:cookiejar.cpp

示例15: expires

void HttpWriterTest::writeSetCookies () {
	HttpWriter writer;
	
	// Data
	QByteArray expected = "Set-Cookie: expires=b%20a%3Br; Max-Age=0; Secure; HttpOnly\r\n"
			      "Set-Cookie: session=foo\r\n";
	
	QNetworkCookie expires ("expires", "b a;r");
	expires.setExpirationDate (QDateTime::fromMSecsSinceEpoch (123));
	expires.setSecure (true);
	expires.setHttpOnly (true);
	
	HttpClient::Cookies cookies {
		{ "session", QNetworkCookie ("session", "foo") },
		{ "expires", expires }
	};
	
	// 
	QByteArray result = writer.writeSetCookies (cookies);
	QCOMPARE(result, expected);
}
开发者ID:NuriaProject,项目名称:Network,代码行数:21,代码来源:tst_httpwriter.cpp


注:本文中的QNetworkCookie类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。