summaryrefslogtreecommitdiff
path: root/src/cookiejar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cookiejar.cpp')
-rw-r--r--src/cookiejar.cpp57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp
index 87d84def..ef829ffd 100644
--- a/src/cookiejar.cpp
+++ b/src/cookiejar.cpp
@@ -18,9 +18,14 @@
 *
 * ============================================================ */
+// Self Includes
+#include "cookiejar.h"
+#include "cookiejar.moc"
+
+// Auto Includes
+#include "rekonq.h"
// Local Includes
-#include "cookiejar.h"
#include "autosaver.h"
// KDE Includes
@@ -46,6 +51,7 @@ QDataStream &operator<<(QDataStream &stream, const QList<QNetworkCookie> &list)
return stream;
}
+
QDataStream &operator>>(QDataStream &stream, QList<QNetworkCookie> &list)
{
list.clear();
@@ -76,6 +82,7 @@ QDataStream &operator>>(QDataStream &stream, QList<QNetworkCookie> &list)
}
QT_END_NAMESPACE
+
CookieJar::CookieJar(QObject *parent)
: QNetworkCookieJar(parent)
, m_loaded(false)
@@ -84,6 +91,7 @@ CookieJar::CookieJar(QObject *parent)
{
}
+
CookieJar::~CookieJar()
{
if (m_keepCookies == KeepUntilExit)
@@ -91,6 +99,7 @@ CookieJar::~CookieJar()
m_saveTimer->saveIfNeccessary();
}
+
void CookieJar::clear()
{
setAllCookies(QList<QNetworkCookie>());
@@ -98,6 +107,7 @@ void CookieJar::clear()
emit cookiesChanged();
}
+
void CookieJar::load()
{
if (m_loaded)
@@ -130,6 +140,7 @@ void CookieJar::load()
loadSettings();
}
+
void CookieJar::loadSettings()
{
KConfig config("rekonqrc");
@@ -153,6 +164,7 @@ void CookieJar::loadSettings()
emit cookiesChanged();
}
+
void CookieJar::save()
{
if (!m_loaded)
@@ -200,6 +212,7 @@ void CookieJar::save()
group.writeEntry( QString("keepCookiesUntil"), QString( keepPolicyEnum.valueToKey(m_keepCookies) ) );
}
+
void CookieJar::purgeOldCookies()
{
QList<QNetworkCookie> cookies = allCookies();
@@ -218,6 +231,7 @@ void CookieJar::purgeOldCookies()
emit cookiesChanged();
}
+
QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl &url) const
{
CookieJar *that = const_cast<CookieJar*>(this);
@@ -234,6 +248,7 @@ QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl &url) const
return QNetworkCookieJar::cookiesForUrl(url);
}
+
bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url)
{
if (!m_loaded)
@@ -297,7 +312,6 @@ bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const
}
-
CookieJar::AcceptPolicy CookieJar::acceptPolicy() const
{
if (!m_loaded)
@@ -306,7 +320,6 @@ CookieJar::AcceptPolicy CookieJar::acceptPolicy() const
}
-
void CookieJar::setAcceptPolicy(AcceptPolicy policy)
{
if (!m_loaded)
@@ -318,7 +331,6 @@ void CookieJar::setAcceptPolicy(AcceptPolicy policy)
}
-
CookieJar::KeepPolicy CookieJar::keepPolicy() const
{
if (!m_loaded)
@@ -327,7 +339,6 @@ CookieJar::KeepPolicy CookieJar::keepPolicy() const
}
-
void CookieJar::setKeepPolicy(KeepPolicy policy)
{
if (!m_loaded)
@@ -339,7 +350,6 @@ void CookieJar::setKeepPolicy(KeepPolicy policy)
}
-
QStringList CookieJar::blockedCookies() const
{
if (!m_loaded)
@@ -348,7 +358,6 @@ QStringList CookieJar::blockedCookies() const
}
-
QStringList CookieJar::allowedCookies() const
{
if (!m_loaded)
@@ -357,7 +366,6 @@ QStringList CookieJar::allowedCookies() const
}
-
QStringList CookieJar::allowForSessionCookies() const
{
if (!m_loaded)
@@ -366,7 +374,6 @@ QStringList CookieJar::allowForSessionCookies() const
}
-
void CookieJar::setBlockedCookies(const QStringList &list)
{
if (!m_loaded)
@@ -377,7 +384,6 @@ void CookieJar::setBlockedCookies(const QStringList &list)
}
-
void CookieJar::setAllowedCookies(const QStringList &list)
{
if (!m_loaded)
@@ -388,7 +394,6 @@ void CookieJar::setAllowedCookies(const QStringList &list)
}
-
void CookieJar::setAllowForSessionCookies(const QStringList &list)
{
if (!m_loaded)
@@ -399,9 +404,7 @@ void CookieJar::setAllowForSessionCookies(const QStringList &list)
}
-
-// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
+// -------------------------------------------------------------------------------------------
CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent)
@@ -412,6 +415,7 @@ CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent)
m_cookieJar->load();
}
+
QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::SizeHintRole) {
@@ -447,6 +451,7 @@ QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int r
return QAbstractTableModel::headerData(section, orientation, role);
}
+
QVariant CookieModel::data(const QModelIndex &index, int role) const
{
QList<QNetworkCookie> lst;
@@ -484,16 +489,19 @@ QVariant CookieModel::data(const QModelIndex &index, int role) const
return QVariant();
}
+
int CookieModel::columnCount(const QModelIndex &parent) const
{
return (parent.isValid()) ? 0 : 6;
}
+
int CookieModel::rowCount(const QModelIndex &parent) const
{
return (parent.isValid() || !m_cookieJar) ? 0 : m_cookieJar->allCookies().count();
}
+
bool CookieModel::removeRows(int row, int count, const QModelIndex &parent)
{
if (parent.isValid() || !m_cookieJar)
@@ -509,6 +517,7 @@ bool CookieModel::removeRows(int row, int count, const QModelIndex &parent)
return true;
}
+
void CookieModel::cookiesChanged()
{
reset();
@@ -516,8 +525,7 @@ void CookieModel::cookiesChanged()
-// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
+// ------------------------------------------------------------------------------------------------
CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent)
@@ -566,9 +574,7 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent)
}
-
-// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
+// ---------------------------------------------------------------------------------------------------
CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent)
@@ -580,6 +586,7 @@ CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *pare
m_sessionCookies = m_cookieJar->allowForSessionCookies();
}
+
QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::SizeHintRole) {
@@ -603,6 +610,7 @@ QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientat
return QAbstractTableModel::headerData(section, orientation, role);
}
+
QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const
{
if (index.row() < 0 || index.row() >= rowCount())
@@ -648,16 +656,19 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const
return QVariant();
}
+
int CookieExceptionsModel::columnCount(const QModelIndex &parent) const
{
return (parent.isValid()) ? 0 : 2;
}
+
int CookieExceptionsModel::rowCount(const QModelIndex &parent) const
{
return (parent.isValid() || !m_cookieJar) ? 0 : m_allowedCookies.count() + m_blockedCookies.count() + m_sessionCookies.count();
}
+
bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &parent)
{
if (parent.isValid() || !m_cookieJar)
@@ -689,9 +700,7 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa
}
-
-// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
+// ----------------------------------------------------------------------------------------------------------------
CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent)
@@ -746,6 +755,7 @@ CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *
}
}
+
void CookiesExceptionsDialog::textChanged(const QString &text)
{
bool enabled = !text.isEmpty();
@@ -754,6 +764,7 @@ void CookiesExceptionsDialog::textChanged(const QString &text)
allowForSessionButton->setEnabled(enabled);
}
+
void CookiesExceptionsDialog::block()
{
if (domainLineEdit->text().isEmpty())
@@ -763,6 +774,7 @@ void CookiesExceptionsDialog::block()
m_exceptionsModel->reset();
}
+
void CookiesExceptionsDialog::allow()
{
if (domainLineEdit->text().isEmpty())
@@ -772,6 +784,7 @@ void CookiesExceptionsDialog::allow()
m_exceptionsModel->reset();
}
+
void CookiesExceptionsDialog::allowForSession()
{
if (domainLineEdit->text().isEmpty())