split out gtk SSL certificate verification dialog impementation.

This commit is contained in:
Vincent Sanders 2015-04-12 17:26:22 +01:00
parent fb73ff80ed
commit c134750575
4 changed files with 9 additions and 116 deletions

View File

@ -21,16 +21,13 @@
#ifndef _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
#define _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
#include <stdbool.h>
#include <stdint.h>
#include "desktop/core_window.h"
#include "desktop/textinput.h"
#include "utils/errors.h"
#include "content/llcache.h"
#include "desktop/mouse.h"
struct sslcert_session_data;
struct redraw_context;
struct core_window_callback_table;
struct rect;
/**
* Create ssl certificate viewer session data.

View File

@ -117,7 +117,7 @@ S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \
selection.c history.c window.c fetch.c download.c menu.c \
print.c search.c tabs.c theme.c toolbar.c gettext.c \
compat.c cookies.c hotlist.c viewdata.c viewsource.c \
preferences.c about.c
preferences.c about.c ssl_cert.c
S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# code in utils/container.ch is non-universal it seems

110
gtk/gui.c
View File

@ -46,7 +46,7 @@
#include "desktop/save_complete.h"
#include "desktop/save_pdf.h"
#include "desktop/searchweb.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
#include "desktop/gui_misc.h"
#include "desktop/netsurf.h"
@ -65,6 +65,7 @@
#include "gtk/schedule.h"
#include "gtk/selection.h"
#include "gtk/search.h"
#include "gtk/ssl_cert.h"
bool nsgtk_complete = false;
@ -578,111 +579,6 @@ void warn_user(const char *warning, const char *detail)
}
static void nsgtk_ssl_accept(GtkButton *w, gpointer data)
{
void **session = data;
GtkBuilder *x = session[0];
struct nsgtk_treeview *wnd = session[1];
struct sslcert_session_data *ssl_data = session[2];
sslcert_viewer_accept(ssl_data);
nsgtk_treeview_destroy(wnd);
g_object_unref(G_OBJECT(x));
free(session);
}
static void nsgtk_ssl_reject(GtkWidget *w, gpointer data)
{
void **session = data;
GtkBuilder *x = session[0];
struct nsgtk_treeview *wnd = session[1];
struct sslcert_session_data *ssl_data = session[2];
sslcert_viewer_reject(ssl_data);
nsgtk_treeview_destroy(wnd);
g_object_unref(G_OBJECT(x));
free(session);
}
static gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
{
nsgtk_ssl_reject(w, data);
return FALSE;
}
static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
static struct nsgtk_treeview *ssl_window;
struct sslcert_session_data *data;
GtkButton *accept, *reject;
void **session;
GtkDialog *dlg;
GtkScrolledWindow *scrolled;
GtkDrawingArea *drawing_area;
GError *error = NULL;
GtkBuilder *builder;
GtkWindow *gtk_parent;
/* state while dlg is open */
session = calloc(sizeof(void *), 3);
if (session == NULL) {
return;
}
builder = gtk_builder_new();
if (!gtk_builder_add_from_file(builder, glade_file_location->ssl, &error)) {
g_warning("Couldn't load builder file: %s", error->message);
g_error_free(error);
free(session);
return;
}
sslcert_viewer_create_session_data(num, url, cb, cbpw, certs, &data);
ssl_current_session = data;
dlg = GTK_DIALOG(gtk_builder_get_object(builder, "wndSSLProblem"));
/* set parent for transient dialog */
gtk_parent = nsgtk_scaffolding_window(nsgtk_current_scaffolding());
gtk_window_set_transient_for(GTK_WINDOW(dlg), gtk_parent);
scrolled = GTK_SCROLLED_WINDOW(gtk_builder_get_object(builder, "SSLScrolled"));
drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(builder, "SSLDrawingArea"));
ssl_window = nsgtk_treeview_create(TREE_SSLCERT, GTK_WINDOW(dlg), scrolled,
drawing_area);
if (ssl_window == NULL) {
free(session);
g_object_unref(G_OBJECT(dlg));
return;
}
accept = GTK_BUTTON(gtk_builder_get_object(builder, "sslaccept"));
reject = GTK_BUTTON(gtk_builder_get_object(builder, "sslreject"));
session[0] = builder;
session[1] = ssl_window;
session[2] = data;
#define CONNECT(obj, sig, callback, ptr) \
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
CONNECT(accept, "clicked", nsgtk_ssl_accept, session);
CONNECT(reject, "clicked", nsgtk_ssl_reject, session);
CONNECT(dlg, "delete_event", G_CALLBACK(nsgtk_ssl_delete_event),
(gpointer)session);
gtk_widget_show(GTK_WIDGET(dlg));
}
static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
{
char **owner_pass = ((void **)data)[0];
@ -1194,7 +1090,7 @@ static struct gui_browser_table nsgtk_browser_table = {
.quit = gui_quit,
.launch_url = gui_launch_url,
.cert_verify = gui_cert_verify,
.cert_verify = gtk_cert_verify,
.login = gui_401login_open,
.pdf_password = nsgtk_pdf_password,
};

View File

@ -128,7 +128,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *gw);
*/
struct nsgtk_scaffolding *nsgtk_current_scaffolding(void);
/* acessors for gtk elements withing a scaffold */
/* acessors for gtk elements within a scaffold */
/**
* Get the gtk window for a scaffolding.