mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 05:22:01 +08:00
WebKit Credentials Challenge fixed passing data on linux
This commit is contained in:
parent
c953dd9eea
commit
eb078d01d0
@ -437,7 +437,7 @@ target_link_libraries(
|
||||
if (MSVC)
|
||||
target_link_libraries(libslic3r_gui PUBLIC Setupapi.lib)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_link_libraries(libslic3r_gui PUBLIC ${DBUS_LIBRARIES})
|
||||
target_link_libraries(libslic3r_gui PUBLIC ${DBUS_LIBRARIES})
|
||||
elseif (APPLE)
|
||||
target_link_libraries(libslic3r_gui PUBLIC ${DISKARBITRATION_LIBRARY} ${COREWLAN_LIBRARY})
|
||||
endif()
|
||||
@ -457,8 +457,12 @@ endif ()
|
||||
# link these libraries.
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_package(GTK${SLIC3R_GTK} REQUIRED)
|
||||
target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS})
|
||||
target_link_libraries(libslic3r_gui PUBLIC ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(WEBKIT2GTK REQUIRED webkit2gtk-4.0)
|
||||
|
||||
target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS})
|
||||
target_link_libraries(libslic3r_gui PUBLIC ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig ${WEBKIT2GTK_LIBS})
|
||||
endif ()
|
||||
|
||||
# Add a definition so that we can tell we are compiling slic3r.
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <cstddef>
|
||||
|
||||
namespace DoubleSlider {
|
||||
|
||||
|
@ -11,21 +11,32 @@ struct Credentials {
|
||||
std::string password;
|
||||
};
|
||||
|
||||
using WebViewCredentialsMap = std::unordered_map<void*, std::unique_ptr<Credentials>>;
|
||||
WebViewCredentialsMap g_credentials;
|
||||
|
||||
gboolean webkit_authorize_handler(WebKitWebView *web_view, WebKitAuthenticationRequest *request, gpointer user_data)
|
||||
{
|
||||
const Credentials& creds = *static_cast<const Credentials*>(user_data);
|
||||
webkit_authentication_request_authenticate(request, webkit_credential_new(creds.username.c_str(), creds.password.c_str()));
|
||||
webkit_authentication_request_authenticate(request, webkit_credential_new(creds.username.c_str(), creds.password.c_str(), WEBKIT_CREDENTIAL_PERSISTENCE_FOR_SESSION));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void setup_webview_with_credentials(wxWebView* web_view, const std::string& username, const std::string& password)
|
||||
void free_credentials(gpointer user_data, GClosure* closure)
|
||||
{
|
||||
std::unique_ptr<Credentials> ptr(new Credentials{username, password});
|
||||
g_credentials[web_view->GetNativeBackend()] = std::move(ptr);
|
||||
g_signal_connect(web_view, "authorize",
|
||||
G_CALLBACK(webkit_authorize_handler), g_credentials[web_view].get());
|
||||
Credentials* creds = static_cast<Credentials*>(user_data);
|
||||
delete creds;
|
||||
}
|
||||
|
||||
void setup_webview_with_credentials(wxWebView* web_view, const std::string& username, const std::string& password)
|
||||
{
|
||||
WebKitWebView* native_backend = static_cast<WebKitWebView *>(web_view->GetNativeBackend());
|
||||
Credentials* user_data = new Credentials{username, password};
|
||||
|
||||
g_signal_connect_data(
|
||||
native_backend,
|
||||
"authenticate",
|
||||
G_CALLBACK(webkit_authorize_handler),
|
||||
user_data,
|
||||
&free_credentials,
|
||||
static_cast<GConnectFlags>(0)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user