mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-07 12:08:59 +08:00
WebKit Credentials Challenge fixed passing data on linux
This commit is contained in:
parent
c953dd9eea
commit
eb078d01d0
@ -457,8 +457,12 @@ endif ()
|
|||||||
# link these libraries.
|
# link these libraries.
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
find_package(GTK${SLIC3R_GTK} REQUIRED)
|
find_package(GTK${SLIC3R_GTK} REQUIRED)
|
||||||
target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS})
|
find_package(PkgConfig REQUIRED)
|
||||||
target_link_libraries(libslic3r_gui PUBLIC ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig)
|
|
||||||
|
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 ()
|
endif ()
|
||||||
|
|
||||||
# Add a definition so that we can tell we are compiling slic3r.
|
# Add a definition so that we can tell we are compiling slic3r.
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace DoubleSlider {
|
namespace DoubleSlider {
|
||||||
|
|
||||||
|
@ -11,21 +11,32 @@ struct Credentials {
|
|||||||
std::string password;
|
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)
|
gboolean webkit_authorize_handler(WebKitWebView *web_view, WebKitAuthenticationRequest *request, gpointer user_data)
|
||||||
{
|
{
|
||||||
const Credentials& creds = *static_cast<const Credentials*>(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 free_credentials(gpointer user_data, GClosure* closure)
|
||||||
|
{
|
||||||
|
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)
|
void setup_webview_with_credentials(wxWebView* web_view, const std::string& username, const std::string& password)
|
||||||
{
|
{
|
||||||
std::unique_ptr<Credentials> ptr(new Credentials{username, password});
|
WebKitWebView* native_backend = static_cast<WebKitWebView *>(web_view->GetNativeBackend());
|
||||||
g_credentials[web_view->GetNativeBackend()] = std::move(ptr);
|
Credentials* user_data = new Credentials{username, password};
|
||||||
g_signal_connect(web_view, "authorize",
|
|
||||||
G_CALLBACK(webkit_authorize_handler), g_credentials[web_view].get());
|
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