From 7261bcaeeea7803a29d93fdd2ee30e2ffb0e71c8 Mon Sep 17 00:00:00 2001 From: Mateusz Daniluk <121170681+VeithMetro@users.noreply.github.com> Date: Fri, 1 Dec 2023 09:49:16 +0100 Subject: [PATCH] [WebKitBrowser] CookieJar updated to 2.42 WebKit API (#265) * webkit_cookie_manager_get_cookie_jar() replaced by webkit_cookie_manager_get_all_cookies() in 2.42 * webkit_cookie_manager_set_cookie_jar replaced by webkit_cookie_manager_replace_cookies in 2.42 --- WebKitBrowser/WebKitImplementation.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/WebKitBrowser/WebKitImplementation.cpp b/WebKitBrowser/WebKitImplementation.cpp index edf2a8aa..d208baed 100644 --- a/WebKitBrowser/WebKitImplementation.cpp +++ b/WebKitBrowser/WebKitImplementation.cpp @@ -1522,9 +1522,13 @@ static GSourceFuncs _handlerIntervention = #ifdef WEBKIT_GLIB_API WebKitWebContext* context = webkit_web_view_get_context(_view); WebKitCookieManager* manager = webkit_web_context_get_cookie_manager(context); +#if WEBKIT_CHECK_VERSION(2, 42, 0) + webkit_cookie_manager_get_all_cookies(manager, NULL, [](GObject* object, GAsyncResult* result, gpointer user_data) { + GList* cookies_list = webkit_cookie_manager_get_all_cookies_finish(WEBKIT_COOKIE_MANAGER(object), result, nullptr); +#else webkit_cookie_manager_get_cookie_jar(manager, NULL, [](GObject* object, GAsyncResult* result, gpointer user_data) { GList* cookies_list = webkit_cookie_manager_get_cookie_jar_finish(WEBKIT_COOKIE_MANAGER(object), result, nullptr); - +#endif std::vector cookieVector; cookieVector.reserve(g_list_length(cookies_list)); for (GList* it = cookies_list; it != NULL; it = g_list_next(it)) { @@ -1640,8 +1644,11 @@ static GSourceFuncs _handlerIntervention = WebKitWebContext* context = webkit_web_view_get_context(_view); WebKitCookieManager* manager = webkit_web_context_get_cookie_manager(context); +#if WEBKIT_CHECK_VERSION(2, 42, 0) + webkit_cookie_manager_replace_cookies(manager, g_list_reverse(cookies_list), nullptr, nullptr, nullptr); +#else webkit_cookie_manager_set_cookie_jar(manager, g_list_reverse(cookies_list), nullptr, nullptr, nullptr); - +#endif g_list_free_full(cookies_list, reinterpret_cast(soup_cookie_free)); #else auto toWKCookie = [](SoupCookie* cookie) -> WKCookieRef