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


C++ QNetworkCookie::domain方法代码示例

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


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

示例1: 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

示例2: data

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

示例3: 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

示例4: removeCookie

void CookiesContentsWidget::removeCookie(const QNetworkCookie &cookie)
{
	const QString domain = (cookie.domain().startsWith('.') ? cookie.domain().mid(1) : cookie.domain());
	QStandardItem *domainItem = findDomain(domain);

	if (domainItem)
	{
		QPoint point;

		for (int j = 0; j < domainItem->rowCount(); ++j)
		{
			if (domainItem->child(j, 0)->text() == cookie.name() && domainItem->child(j, 0)->data(Qt::UserRole).toString() == cookie.path())
			{
				point = m_ui->cookiesView->visualRect(domainItem->child(j, 0)->index()).center();

				domainItem->removeRow(j);

				break;
			}
		}

		if (domainItem->rowCount() == 0)
		{
			m_model->invisibleRootItem()->removeRow(domainItem->row());
		}
		else
		{
			domainItem->setText(QStringLiteral("%1 (%2)").arg(domain).arg(domainItem->rowCount()));
		}

		if (!point.isNull())
		{
			const QModelIndex index = m_ui->cookiesView->indexAt(point);

			m_ui->cookiesView->setCurrentIndex(index);
			m_ui->cookiesView->selectionModel()->select(index, QItemSelectionModel::Select);
		}
	}
}
开发者ID:krytarowski,项目名称:otter-browser,代码行数:39,代码来源:CookiesContentsWidget.cpp

示例5: canModifyCookie

bool QtWebKitCookieJar::canModifyCookie(const QNetworkCookie &cookie) const
{
	if (!m_widget || m_generalCookiesPolicy == CookieJar::IgnoreCookies || m_generalCookiesPolicy == CookieJar::ReadOnlyCookies)
	{
		return false;
	}

	if (m_thirdPartyCookiesPolicy != CookieJar::AcceptAllCookies || !m_thirdPartyRejectedHosts.isEmpty())
	{
		QUrl url;
		url.setScheme(QLatin1String("http"));
		url.setHost(cookie.domain().startsWith(QLatin1Char('.')) ? cookie.domain().mid(1) : cookie.domain());

		if (!CookieJar::isDomainTheSame(m_widget->getUrl(), url))
		{
			if (m_thirdPartyRejectedHosts.contains(cookie.domain()))
			{
				return false;
			}

			if (m_thirdPartyAcceptedHosts.contains(cookie.domain()))
			{
				return true;
			}

			if (m_thirdPartyCookiesPolicy == CookieJar::IgnoreCookies)
			{
				return false;
			}

			if (m_thirdPartyCookiesPolicy == CookieJar::AcceptExistingCookies && !m_cookieJar->hasCookie(cookie))
			{
				return false;
			}
		}
	}

	return true;
}
开发者ID:OtterBrowser,项目名称:otter-browser,代码行数:39,代码来源:QtWebKitCookieJar.cpp

示例6: QDialog

CookieDialog::CookieDialog(const QNetworkCookie &cookie, QWidget *parent): QDialog(parent)
{
    setupUi(this);
    m_nameLineEdit->setText(cookie.name());
    m_domainLineEdit->setText(cookie.domain());
    m_valueLineEdit->setText(cookie.value());
    m_pathLineEdit->setText(cookie.path());
    m_dateEdit->setDate(cookie.expirationDate().date());
    m_isSecureComboBox->addItem(cookie.isSecure() ? tr("yes") : tr("no"));
    m_isHttpOnlyComboBox->addItem(cookie.isHttpOnly() ? tr("yes") : tr("no"));
    m_addButton->setVisible(false);
    m_cancelButton->setText(tr("Close"));
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:13,代码来源:mainwindow.cpp

示例7: addCookie

void CookiesContentsWidget::addCookie(const QNetworkCookie &cookie)
{
	const QString domain = (cookie.domain().startsWith('.') ? cookie.domain().mid(1) : cookie.domain());
	QStandardItem *domainItem = findDomain(domain);

	if (domainItem)
	{
		for (int i = 0; i < domainItem->rowCount(); ++i)
		{
			if (domainItem->child(i, 0)->text() == cookie.name() && domainItem->child(i, 0)->data(Qt::UserRole).toString() == cookie.path())
			{
				return;
			}
		}
	}
	else
	{
		domainItem = new QStandardItem(HistoryManager::getIcon(QUrl(QStringLiteral("http://%1/").arg(domain))), domain);
		domainItem->setToolTip(domain);

		m_model->appendRow(domainItem);

		if (sender())
		{
			m_model->sort(0);
		}
	}

	QStandardItem *cookieItem = new QStandardItem(QString(cookie.name()));
	cookieItem->setData(cookie.path(), Qt::UserRole);
	cookieItem->setData(cookie.domain(), (Qt::UserRole + 1));
	cookieItem->setToolTip(cookie.name());
	cookieItem->setFlags(cookieItem->flags() | Qt::ItemNeverHasChildren);

	domainItem->appendRow(cookieItem);
	domainItem->setText(QStringLiteral("%1 (%2)").arg(domain).arg(domainItem->rowCount()));
}
开发者ID:chunyisong,项目名称:otter-browser,代码行数:37,代码来源:CookiesContentsWidget.cpp

示例8: deleteCookie

bool SharedCookieJarQt::deleteCookie(const QNetworkCookie& cookie)
{
    if (!QNetworkCookieJar::deleteCookie(cookie))
        return false;

    if (!m_database.isOpen())
        return false;

    QSqlQuery sqlQuery(m_database);
    sqlQuery.prepare(QLatin1String("DELETE FROM cookies WHERE cookieId=:cookieIdvalue"));
    sqlQuery.bindValue(QLatin1String(":cookieIdvalue"), cookie.domain().append(QLatin1String(cookie.name())));
    sqlQuery.exec();

    return true;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:15,代码来源:CookieJarQt.cpp

示例9: 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

示例10: insertCookie

bool CookieStore::insertCookie(const QNetworkCookie& cookie, const QUrl& firstUrl)
{
    sqlite3_stmt* stmt;
    int rc;
    
    QByteArray domain = cookie.domain().toLatin1();
    QByteArray path = cookie.path().toLatin1();
    QByteArray name = cookie.name();
    QByteArray fdomain = firstUrl.host().toLower().toLatin1();
    QByteArray expiration;
    if (cookie.isSessionCookie()) {
        expiration = "0";
    } else {
        expiration = cookie.expirationDate().toString().toLatin1();
    }
    QByteArray content = cookie.toRawForm();

    rc = sqlite3_prepare(m_db,
                         "insert into thirdPartyCookies (domain, path, name, fdomain, expiration, content) values (?, ?, ?, ?, ?, ?)",
                         -1, &stmt, 0);
    if (rc != SQLITE_OK) {
        qDebug() << "insertCookie prepare fail:" << rc;
        return false;
    }

    QByteArray text[6] = {domain, path, name, fdomain, expiration, content};
    
    for (int i = 0; i < 6; ++i) {
        rc = sqlite3_bind_text(stmt, i + 1, text[i].constData(), text[i].size(), SQLITE_TRANSIENT);
        if (rc != SQLITE_OK) {
            qDebug() << "insertCookie bind fail:" << i;
            sqlite3_finalize(stmt);
            return false;
        }
    }

    rc = sqlite3_step(stmt);
    if (rc != SQLITE_DONE) {
        qDebug() << "insertCookie step (execute) fail";
        sqlite3_finalize(stmt);
        return false;
    }

    sqlite3_finalize(stmt);
    return true;
}
开发者ID:wenqingchu,项目名称:revised-browser,代码行数:46,代码来源:CookieStore.cpp

示例11: 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

示例12: deleteCookie

bool CookieStore::deleteCookie(const QNetworkCookie& cookie, const QUrl& firstUrl)
{
    sqlite3_stmt *stmt;
    int rc;

    QByteArray domain = cookie.domain().toLatin1();
    QByteArray path = cookie.path().toLatin1();
    QByteArray name = cookie.name();
    QByteArray fdomain = firstUrl.host().toLower().toLatin1();

    QByteArray text[4] = {domain, path, name, fdomain};

    rc = sqlite3_prepare(m_db,
                         "delete from thirdPartyCookies  where (domain = ? and path = ? and name = ? and fdomain = ?)",
                         -1, &stmt, 0);
    if (rc != SQLITE_OK) {
        qDebug() << "deleteCookie prepare fail.";
        return false;
    }

    for (int i = 0; i < 4; ++i) {
        rc = sqlite3_bind_text(stmt, i + 1, text[i].constData(), text[i].size(), SQLITE_TRANSIENT);
        if (rc != SQLITE_OK) {
            qDebug() << "deleteCookie bind fail.";
            sqlite3_finalize(stmt);
            return false;
        }
    }

    rc = sqlite3_step(stmt);
    if (rc != SQLITE_DONE) {
        qDebug() << "deleteCookie step (execute) fail";
        sqlite3_finalize(stmt);
        return false;
    }

    sqlite3_finalize(stmt);
    return true;
}
开发者ID:wenqingchu,项目名称:revised-browser,代码行数:39,代码来源:CookieStore.cpp

示例13: saveCookies

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

    cnFile.setValue("login", m_sVkLogin);

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

        cnFile.setArrayIndex(i);

        cnFile.setValue("name", cook.name());
        cnFile.setValue("value", cook.value());
        cnFile.setValue("domain", cook.domain());
        cnFile.setValue("path", cook.path());
    }
    cnFile.endArray();
}
开发者ID:Nerobrain,项目名称:pulsar,代码行数:23,代码来源:cookiejar.cpp


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