diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml
index cc573b754..a6e55a639 100644
--- a/resources/desktop/com.github.rssguard.appdata.xml
+++ b/resources/desktop/com.github.rssguard.appdata.xml
@@ -26,7 +26,7 @@
https://github.com/sponsors/martinrotter
-
+
none
diff --git a/src/librssguard/network-web/cookiejar.cpp b/src/librssguard/network-web/cookiejar.cpp
index ef4c047bc..1e1a363cc 100644
--- a/src/librssguard/network-web/cookiejar.cpp
+++ b/src/librssguard/network-web/cookiejar.cpp
@@ -13,7 +13,26 @@
#include
#include
+#if defined(USE_WEBENGINE)
+#include
+#include
+#endif
+
CookieJar::CookieJar(QObject* parent) : QNetworkCookieJar(parent) {
+#if defined(USE_WEBENGINE)
+ QWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy::NoPersistentCookies);
+
+ m_webEngineCookies = QWebEngineProfile::defaultProfile()->cookieStore();
+
+ // When cookies change in WebEngine, then change in main cookie jar too.
+ connect(m_webEngineCookies, &QWebEngineCookieStore::cookieAdded, this, [=](const QNetworkCookie& cookie) {
+ insertCookieInternal(cookie, false, true);
+ });
+ connect(m_webEngineCookies, &QWebEngineCookieStore::cookieRemoved, this, [=](const QNetworkCookie& cookie) {
+ deleteCookieInternal(cookie, false);
+ });
+#endif
+
loadCookies();
}
@@ -56,7 +75,7 @@ void CookieJar::loadCookies() {
auto cookie = QNetworkCookie::parseCookies(encoded);
if (!cookie.isEmpty()) {
- if (!QNetworkCookieJar::insertCookie(cookie.at(0))) {
+ if (!insertCookieInternal(cookie.at(0), true, false)) {
qCriticalNN << LOGSEC_NETWORK
<< "Failed to load cookie"
<< QUOTE_W_SPACE(cookie_key)
@@ -95,32 +114,70 @@ bool CookieJar::setCookiesFromUrl(const QList& cookie_list, cons
return QNetworkCookieJar::setCookiesFromUrl(cookie_list, url);
}
-bool CookieJar::insertCookie(const QNetworkCookie& cookie) {
+bool CookieJar::insertCookieInternal(const QNetworkCookie& cookie, bool notify_others, bool should_save) {
auto result = QNetworkCookieJar::insertCookie(cookie);
if (result) {
- saveCookies();
+ if (should_save) {
+ saveCookies();
+ }
+
+#if defined(USE_WEBENGINE)
+ if (notify_others) {
+ m_webEngineCookies->setCookie(cookie);
+ }
+#else
+ Q_UNUSED(notify_others)
+#endif
}
return result;
}
-bool CookieJar::updateCookie(const QNetworkCookie& cookie) {
+bool CookieJar::updateCookieInternal(const QNetworkCookie& cookie, bool notify_others) {
auto result = QNetworkCookieJar::updateCookie(cookie);
if (result) {
saveCookies();
+
+#if defined(USE_WEBENGINE)
+ if (notify_others) {
+ m_webEngineCookies->setCookie(cookie);
+ }
+#else
+ Q_UNUSED(notify_others)
+#endif
}
return result;
}
-bool CookieJar::deleteCookie(const QNetworkCookie& cookie) {
+bool CookieJar::deleteCookieInternal(const QNetworkCookie& cookie, bool notify_others) {
auto result = QNetworkCookieJar::deleteCookie(cookie);
if (result) {
saveCookies();
+
+#if defined(USE_WEBENGINE)
+ if (notify_others) {
+ m_webEngineCookies->deleteCookie(cookie);
+ }
+#else
+ Q_UNUSED(notify_others)
+#endif
}
return result;
}
+
+bool CookieJar::insertCookie(const QNetworkCookie& cookie) {
+ return insertCookieInternal(cookie, true, true);
+}
+
+bool CookieJar::deleteCookie(const QNetworkCookie& cookie) {
+ return deleteCookieInternal(cookie, true);
+}
+
+bool CookieJar::updateCookie(const QNetworkCookie& cookie) {
+ return updateCookieInternal(cookie, true);
+}
diff --git a/src/librssguard/network-web/cookiejar.h b/src/librssguard/network-web/cookiejar.h
index 8b6507e39..abfcc44d9 100644
--- a/src/librssguard/network-web/cookiejar.h
+++ b/src/librssguard/network-web/cookiejar.h
@@ -5,6 +5,10 @@
#include
+#if defined(USE_WEBENGINE)
+class QWebEngineCookieStore;
+#endif
+
class CookieJar : public QNetworkCookieJar {
public:
explicit CookieJar(QObject* parent = nullptr);
@@ -19,8 +23,17 @@ class CookieJar : public QNetworkCookieJar {
static QList extractCookiesFromUrl(const QString& url);
private:
+ bool insertCookieInternal(const QNetworkCookie& cookie, bool notify_others, bool should_save);
+ bool updateCookieInternal(const QNetworkCookie& cookie, bool notify_others);
+ bool deleteCookieInternal(const QNetworkCookie& cookie, bool notify_others);
+
void loadCookies();
void saveCookies();
+
+ private:
+#if defined(USE_WEBENGINE)
+ QWebEngineCookieStore * m_webEngineCookies;
+#endif
};
#endif // COOKIEJAR_H