void gui_cert_verify(const char *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 = calloc(sizeof(void *), 3); GtkWindow *window; GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; GError* error = NULL; GtkBuilder* builder; 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); return; } data = sslcert_create_session_data(num, url, cb, cbpw); window = GTK_WINDOW(gtk_builder_get_object(builder, "wndSSLProblem")); 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(sslcert_get_tree_flags(), window, scrolled, drawing_area); if (ssl_window == NULL) return; sslcert_load_tree(nsgtk_treeview_get_tree(ssl_window), certs, data); 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(window, "delete_event", G_CALLBACK(nsgtk_ssl_delete_event), (gpointer)session); gtk_widget_show(GTK_WIDGET(window)); }
void gui_cert_verify(const char *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw) { struct ro_sslcert *sslcert_window; wimp_window_state state; wimp_icon_state istate; wimp_window_info info; os_error *error; bool set_extent; assert(certs); sslcert_window = malloc(sizeof(struct ro_sslcert)); if (sslcert_window == NULL) { LOG(("Failed to allocate memory for SSL Cert Dialog")); return; } /* Create the SSL window and its pane. */ error = xwimp_create_window(ro_gui_cert_dialog_template, &(sslcert_window->window)); if (error) { LOG(("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess)); free(sslcert_window); return; } error = xwimp_create_window(ro_gui_cert_tree_template, &(sslcert_window->pane)); if (error) { LOG(("xwimp_create_window: 0x%x: %s", error->errnum, error->errmess)); free(sslcert_window); return; } /* Create the SSL data and build a tree from it. */ sslcert_window->tv = ro_treeview_create(sslcert_window->pane, NULL, NULL, sslcert_get_tree_flags()); if (sslcert_window->tv == NULL) { LOG(("Failed to allocate treeview")); free(sslcert_window); return; } sslcert_window->data = sslcert_create_session_data(num, url, cb, cbpw); sslcert_load_tree(ro_treeview_get_tree(sslcert_window->tv), certs, sslcert_window->data); tree_set_redraw(ro_treeview_get_tree(sslcert_window->tv), true); /* Set up the certificate window event handling. * * (The action buttons are registered as button events, not OK and * Cancel, as both need to carry out actions.) */ ro_gui_wimp_event_set_user_data(sslcert_window->window, sslcert_window); ro_gui_wimp_event_register_close_window(sslcert_window->window, ro_gui_cert_close_window); ro_gui_wimp_event_register_button(sslcert_window->window, ICON_SSL_REJECT, ro_gui_cert_reject); ro_gui_wimp_event_register_button(sslcert_window->window, ICON_SSL_ACCEPT, ro_gui_cert_accept); ro_gui_dialog_open_persistent(NULL, sslcert_window->window, false); /* Nest the tree window inside the pane window. To do this, we: * - Get the current pane extent, * - Get the parent window position and the location of the pane- * locating icon inside it, * - Set the visible area of the pane to suit, * - Check that the pane extents are OK for this visible area, and * increase them if necessary, * - Before finally opening the pane as a nested part of the parent. */ info.w = sslcert_window->pane; error = xwimp_get_window_info_header_only(&info); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_get_window_info: 0x%x: %s", error->errnum, error->errmess)); return; } state.w = sslcert_window->window; error = xwimp_get_window_state(&state); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess)); return; } istate.w = sslcert_window->window; istate.i = ICON_SSL_PANE; error = xwimp_get_icon_state(&istate); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_get_icon_state: 0x%x: %s", error->errnum, error->errmess)); return; } state.w = sslcert_window->pane; state.visible.x1 = state.visible.x0 + istate.icon.extent.x1 - 20 - ro_get_vscroll_width(sslcert_window->pane); state.visible.x0 += istate.icon.extent.x0 + 20; state.visible.y0 = state.visible.y1 + istate.icon.extent.y0 + 20 + ro_get_hscroll_height(sslcert_window->pane); state.visible.y1 += istate.icon.extent.y1 - 32; set_extent = false; if ((info.extent.x1 - info.extent.x0) < (state.visible.x1 - state.visible.x0)) { info.extent.x0 = 0; info.extent.x1 = state.visible.x1 - state.visible.x0; set_extent = true; } if ((info.extent.y1 - info.extent.y0) < (state.visible.y1 - state.visible.y0)) { info.extent.y1 = 0; info.extent.x1 = state.visible.y0 - state.visible.y1; set_extent = true; } if (set_extent) { error = xwimp_set_extent(sslcert_window->pane, &(info.extent)); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_set_extent: 0x%x: %s", error->errnum, error->errmess)); return; } } error = xwimp_open_window_nested(PTR_WIMP_OPEN(&state), sslcert_window->window, wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_XORIGIN_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT << wimp_CHILD_YORIGIN_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_LS_EDGE_SHIFT | wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT << wimp_CHILD_RS_EDGE_SHIFT); if (error) { ro_gui_cert_release_window(sslcert_window); LOG(("xwimp_open_window_nested: 0x%x: %s", error->errnum, error->errmess)); ro_gui_cert_release_window(sslcert_window); return; } ro_treeview_set_origin(sslcert_window->tv, 0, 0); }