2002-11-25 16:21:47 +01:00
|
|
|
/*
|
2007-02-03 10:59:57 +01:00
|
|
|
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
|
2016-02-19 19:24:09 +01:00
|
|
|
* Copyright (C) 1999-2016 Colin Leroy and the Claws Mail team
|
2002-11-25 16:21:47 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-11 18:38:12 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-11-25 16:21:47 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-11 18:38:12 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-11-25 16:21:47 +01:00
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
2012-07-07 09:09:39 +02:00
|
|
|
#include "claws-features.h"
|
2002-11-25 16:21:47 +01:00
|
|
|
#endif
|
|
|
|
|
2008-10-11 16:23:27 +02:00
|
|
|
#ifdef USE_GNUTLS
|
2008-09-09 18:40:59 +02:00
|
|
|
#include <gtk/gtk.h>
|
2002-11-25 16:21:47 +01:00
|
|
|
#include <glib.h>
|
2005-02-10 13:06:07 +01:00
|
|
|
#include <glib/gi18n.h>
|
2006-08-16 18:24:00 +02:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2002-11-25 16:21:47 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
|
|
|
|
#include "ssl_manager.h"
|
|
|
|
#include "ssl_certificate.h"
|
|
|
|
#include "manage_window.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "alertpanel.h"
|
2002-12-08 04:15:44 +01:00
|
|
|
#include "sslcertwindow.h"
|
2005-05-31 09:04:59 +02:00
|
|
|
#include "prefs_common.h"
|
2002-11-25 16:21:47 +01:00
|
|
|
|
2005-01-20 15:15:46 +01:00
|
|
|
enum {
|
|
|
|
SSL_MANAGER_HOST,
|
|
|
|
SSL_MANAGER_PORT,
|
|
|
|
SSL_MANAGER_CERT,
|
|
|
|
N_SSL_MANAGER_COLUMNS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
static struct SSLManager
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *hbox1;
|
|
|
|
GtkWidget *vbox1;
|
|
|
|
GtkWidget *certlist;
|
|
|
|
GtkWidget *view_btn;
|
|
|
|
GtkWidget *delete_btn;
|
2005-06-28 07:32:32 +02:00
|
|
|
GtkWidget *close_btn;
|
2002-11-25 16:21:47 +01:00
|
|
|
} manager;
|
|
|
|
|
|
|
|
static void ssl_manager_view_cb (GtkWidget *widget, gpointer data);
|
|
|
|
static void ssl_manager_delete_cb (GtkWidget *widget, gpointer data);
|
2005-06-28 07:32:32 +02:00
|
|
|
static void ssl_manager_close_cb (GtkWidget *widget, gpointer data);
|
2006-08-16 18:24:00 +02:00
|
|
|
static gboolean key_pressed (GtkWidget *widget, GdkEventKey *event,
|
|
|
|
gpointer data);
|
2002-11-25 16:21:47 +01:00
|
|
|
static void ssl_manager_load_certs (void);
|
2005-01-20 15:15:46 +01:00
|
|
|
static void ssl_manager_double_clicked(GtkTreeView *list_view,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
gpointer data);
|
2002-11-25 16:21:47 +01:00
|
|
|
|
|
|
|
void ssl_manager_open(MainWindow *mainwin)
|
|
|
|
{
|
|
|
|
if (!manager.window)
|
|
|
|
ssl_manager_create();
|
|
|
|
|
|
|
|
manage_window_set_transient(GTK_WINDOW(manager.window));
|
2005-06-28 07:32:32 +02:00
|
|
|
gtk_widget_grab_focus(manager.close_btn);
|
2002-11-25 16:21:47 +01:00
|
|
|
|
|
|
|
ssl_manager_load_certs();
|
|
|
|
|
|
|
|
gtk_widget_show(manager.window);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-01-20 15:15:46 +01:00
|
|
|
static GtkListStore* ssl_manager_create_data_store(void)
|
|
|
|
{
|
|
|
|
return gtk_list_store_new(N_SSL_MANAGER_COLUMNS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ssl_manager_create_list_view_columns(GtkWidget *list_view)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes
|
|
|
|
(_("Server"),
|
|
|
|
renderer,
|
|
|
|
"text", SSL_MANAGER_HOST,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes
|
|
|
|
(_("Port"),
|
|
|
|
renderer,
|
|
|
|
"text", SSL_MANAGER_PORT,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *ssl_manager_list_view_create (void)
|
|
|
|
{
|
|
|
|
GtkTreeView *list_view;
|
|
|
|
GtkTreeSelection *selector;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL(ssl_manager_create_data_store());
|
|
|
|
list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
|
|
|
|
g_object_unref(model);
|
|
|
|
|
2005-07-15 16:47:50 +02:00
|
|
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
|
|
|
|
0, GTK_SORT_ASCENDING);
|
2006-09-06 11:14:40 +02:00
|
|
|
gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
selector = gtk_tree_view_get_selection(list_view);
|
|
|
|
gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(list_view), "row_activated",
|
|
|
|
G_CALLBACK(ssl_manager_double_clicked),
|
|
|
|
list_view);
|
|
|
|
|
|
|
|
/* create the columns */
|
|
|
|
ssl_manager_create_list_view_columns(GTK_WIDGET(list_view));
|
|
|
|
|
|
|
|
return GTK_WIDGET(list_view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-19 19:24:09 +01:00
|
|
|
void ssl_manager_create(void)
|
2002-11-25 16:21:47 +01:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
2016-02-19 19:24:09 +01:00
|
|
|
GtkWidget *scroll;
|
2002-11-25 16:21:47 +01:00
|
|
|
GtkWidget *hbox1;
|
|
|
|
GtkWidget *vbox1;
|
|
|
|
GtkWidget *certlist;
|
|
|
|
GtkWidget *view_btn;
|
|
|
|
GtkWidget *delete_btn;
|
2005-06-28 07:32:32 +02:00
|
|
|
GtkWidget *close_btn;
|
2002-11-25 16:21:47 +01:00
|
|
|
|
2007-02-04 12:51:29 +01:00
|
|
|
window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "ssl_manager");
|
2002-11-25 16:21:47 +01:00
|
|
|
gtk_window_set_title (GTK_WINDOW(window),
|
2016-10-25 12:15:02 +02:00
|
|
|
_("Saved SSL/TLS certificates"));
|
2005-01-20 15:15:46 +01:00
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
2004-07-28 14:30:15 +02:00
|
|
|
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
|
2004-07-28 09:51:10 +02:00
|
|
|
gtk_window_set_resizable(GTK_WINDOW (window), TRUE);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(window), "delete_event",
|
2005-06-28 07:32:32 +02:00
|
|
|
G_CALLBACK(ssl_manager_close_cb), NULL);
|
2006-08-16 18:24:00 +02:00
|
|
|
g_signal_connect(G_OBJECT(window), "key_press_event",
|
|
|
|
G_CALLBACK(key_pressed), NULL);
|
2002-11-25 16:21:47 +01:00
|
|
|
MANAGE_WINDOW_SIGNALS_CONNECT (window);
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
hbox1 = gtk_hbox_new(FALSE, 6);
|
|
|
|
vbox1 = gtk_vbox_new(FALSE, 0);
|
|
|
|
delete_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
|
2016-02-19 19:24:09 +01:00
|
|
|
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(delete_btn), "clicked",
|
|
|
|
G_CALLBACK(ssl_manager_delete_cb), NULL);
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
view_btn = gtk_button_new_from_stock(GTK_STOCK_PROPERTIES);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_signal_connect(G_OBJECT(view_btn), "clicked",
|
|
|
|
G_CALLBACK(ssl_manager_view_cb), NULL);
|
2005-01-20 15:15:46 +01:00
|
|
|
|
2005-06-28 07:32:32 +02:00
|
|
|
close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
|
|
|
g_signal_connect(G_OBJECT(close_btn), "clicked",
|
|
|
|
G_CALLBACK(ssl_manager_close_cb), NULL);
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
certlist = ssl_manager_list_view_create();
|
2016-02-19 19:24:09 +01:00
|
|
|
|
|
|
|
scroll = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_container_add(GTK_CONTAINER (scroll), certlist);
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox1), scroll, TRUE, TRUE, 0);
|
2005-10-17 17:16:04 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox1), vbox1, FALSE, FALSE, 0);
|
2005-01-20 15:15:46 +01:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox1), view_btn, FALSE, FALSE, 4);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox1), delete_btn, FALSE, FALSE, 4);
|
2005-06-28 07:32:32 +02:00
|
|
|
gtk_box_pack_end(GTK_BOX(vbox1), close_btn, FALSE, FALSE, 4);
|
2016-02-19 19:24:09 +01:00
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
gtk_widget_show(certlist);
|
2016-02-19 19:24:09 +01:00
|
|
|
gtk_widget_show(scroll);
|
2002-11-25 16:21:47 +01:00
|
|
|
gtk_widget_show(hbox1);
|
|
|
|
gtk_widget_show(vbox1);
|
2005-06-28 07:32:32 +02:00
|
|
|
gtk_widget_show(close_btn);
|
2002-11-25 16:21:47 +01:00
|
|
|
gtk_widget_show(delete_btn);
|
|
|
|
gtk_widget_show(view_btn);
|
|
|
|
gtk_container_add(GTK_CONTAINER (window), hbox1);
|
|
|
|
|
|
|
|
manager.window = window;
|
|
|
|
manager.hbox1 = hbox1;
|
|
|
|
manager.vbox1 = vbox1;
|
|
|
|
manager.certlist = certlist;
|
|
|
|
manager.view_btn = view_btn;
|
|
|
|
manager.delete_btn = delete_btn;
|
2005-06-28 07:32:32 +02:00
|
|
|
manager.close_btn = close_btn;
|
2002-11-25 16:21:47 +01:00
|
|
|
|
|
|
|
gtk_widget_show(window);
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
static char *get_server(const char *str)
|
2002-11-25 16:21:47 +01:00
|
|
|
{
|
|
|
|
char *ret = NULL, *tmp = g_strdup(str);
|
2006-12-06 08:24:40 +01:00
|
|
|
char *first_pos = NULL, *last_pos = NULL;
|
|
|
|
char *previous_pos = NULL, *pre_previous_pos = NULL;
|
2002-11-25 16:21:47 +01:00
|
|
|
int previous_dot_pos;
|
|
|
|
|
2006-12-06 08:24:40 +01:00
|
|
|
if (!strchr(tmp, ':')) {
|
|
|
|
/* no fingerprint */
|
|
|
|
if (strstr(tmp, ".cert"))
|
|
|
|
*(strstr(tmp, ".cert")+1) = '.';
|
|
|
|
}
|
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
first_pos = tmp;
|
2006-11-14 08:26:45 +01:00
|
|
|
while (tmp && (tmp = strstr(tmp,".")) != NULL) {
|
|
|
|
tmp++;
|
2006-12-06 08:24:40 +01:00
|
|
|
pre_previous_pos = previous_pos;
|
2002-11-25 16:21:47 +01:00
|
|
|
previous_pos = last_pos;
|
|
|
|
last_pos = tmp;
|
|
|
|
}
|
2006-12-06 08:24:40 +01:00
|
|
|
previous_dot_pos = (pre_previous_pos - first_pos);
|
2002-11-25 16:21:47 +01:00
|
|
|
if (previous_dot_pos - 1 > 0)
|
|
|
|
ret = g_strndup(first_pos, previous_dot_pos - 1);
|
|
|
|
else
|
|
|
|
ret = g_strdup(first_pos);
|
|
|
|
g_free(first_pos);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
static char *get_port(const char *str)
|
2006-12-06 08:24:40 +01:00
|
|
|
{
|
|
|
|
char *ret = NULL, *tmp = g_strdup(str);
|
|
|
|
char *last_pos = NULL;
|
|
|
|
char *previous_pos = NULL, *pre_previous_pos = NULL;
|
|
|
|
|
|
|
|
if (!strchr(tmp, ':')) {
|
|
|
|
/* no fingerprint */
|
|
|
|
if (strstr(tmp, ".cert"))
|
|
|
|
*(strstr(tmp, ".cert")+1) = '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
while (tmp && (tmp = strstr(tmp,".")) != NULL) {
|
|
|
|
tmp++;
|
|
|
|
pre_previous_pos = previous_pos;
|
|
|
|
previous_pos = last_pos;
|
|
|
|
last_pos = tmp;
|
|
|
|
}
|
|
|
|
if (previous_pos && pre_previous_pos && (int)(previous_pos - pre_previous_pos - 1) > 0)
|
|
|
|
ret = g_strndup(pre_previous_pos, (int)(previous_pos - pre_previous_pos - 1));
|
|
|
|
else
|
|
|
|
ret = g_strdup("0");
|
|
|
|
g_free(tmp);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
static char *get_fingerprint(const char *str)
|
2002-11-25 16:21:47 +01:00
|
|
|
{
|
|
|
|
char *ret = NULL, *tmp = g_strdup(str);
|
|
|
|
char *previous_pos = NULL, *last_pos = NULL;
|
|
|
|
|
2006-12-06 08:24:40 +01:00
|
|
|
if (!strchr(tmp, ':')) {
|
|
|
|
/* no fingerprint */
|
|
|
|
if (strstr(tmp, ".cert"))
|
|
|
|
*(strstr(tmp, ".cert")+1) = '.';
|
|
|
|
}
|
|
|
|
|
2006-11-14 08:26:45 +01:00
|
|
|
while (tmp && (tmp = strstr(tmp,".")) != NULL) {
|
|
|
|
tmp++;
|
2002-11-25 16:21:47 +01:00
|
|
|
previous_pos = last_pos;
|
|
|
|
last_pos = tmp;
|
|
|
|
}
|
|
|
|
if (last_pos && previous_pos && (int)(last_pos - previous_pos - 1) > 0)
|
|
|
|
ret = g_strndup(previous_pos, (int)(last_pos - previous_pos - 1));
|
|
|
|
else
|
2006-12-06 08:24:40 +01:00
|
|
|
ret = NULL;
|
2002-11-25 16:21:47 +01:00
|
|
|
g_free(tmp);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
static void ssl_manager_list_view_insert_cert(GtkWidget *list_view,
|
|
|
|
GtkTreeIter *row_iter,
|
|
|
|
gchar *host,
|
|
|
|
gchar *port,
|
|
|
|
SSLCertificate *cert)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(list_view)));
|
|
|
|
|
|
|
|
if (row_iter == NULL) {
|
|
|
|
/* append new */
|
|
|
|
gtk_list_store_append(list_store, &iter);
|
|
|
|
gtk_list_store_set(list_store, &iter,
|
2005-01-20 15:36:59 +01:00
|
|
|
SSL_MANAGER_HOST, host,
|
|
|
|
SSL_MANAGER_PORT, port,
|
2005-01-20 15:15:46 +01:00
|
|
|
SSL_MANAGER_CERT, cert,
|
|
|
|
-1);
|
|
|
|
} else {
|
|
|
|
gtk_list_store_set(list_store, row_iter,
|
2005-01-20 15:36:59 +01:00
|
|
|
SSL_MANAGER_HOST, host,
|
|
|
|
SSL_MANAGER_PORT, port,
|
2005-01-20 15:15:46 +01:00
|
|
|
SSL_MANAGER_CERT, cert,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
static void ssl_manager_load_certs (void)
|
|
|
|
{
|
2015-06-18 13:22:06 +02:00
|
|
|
GDir *dir;
|
|
|
|
const gchar *d;
|
|
|
|
GError *error = NULL;
|
2002-11-25 16:21:47 +01:00
|
|
|
gchar *path;
|
|
|
|
int row = 0;
|
2005-01-20 15:15:46 +01:00
|
|
|
GtkListStore *store;
|
|
|
|
|
|
|
|
store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(manager.certlist)));
|
|
|
|
|
|
|
|
gtk_list_store_clear(store);
|
2002-11-25 16:21:47 +01:00
|
|
|
|
|
|
|
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
|
|
|
|
"certs", G_DIR_SEPARATOR_S, NULL);
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
if((dir = g_dir_open(path, 0, &error)) == NULL) {
|
|
|
|
debug_print("couldn't open dir '%s': %s (%d)\n", path,
|
|
|
|
error->message, error->code);
|
|
|
|
g_error_free(error);
|
2002-11-25 16:21:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
while ((d = g_dir_read_name(dir)) != NULL) {
|
2006-12-06 08:24:40 +01:00
|
|
|
gchar *server, *port, *fp;
|
2002-11-25 16:21:47 +01:00
|
|
|
SSLCertificate *cert;
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
if(strstr(d, ".cert") != d + (strlen(d) - strlen(".cert")))
|
2002-11-25 16:21:47 +01:00
|
|
|
continue;
|
|
|
|
|
2015-06-18 13:22:06 +02:00
|
|
|
server = get_server(d);
|
|
|
|
port = get_port(d);
|
|
|
|
fp = get_fingerprint(d);
|
2002-11-25 16:21:47 +01:00
|
|
|
|
2011-08-30 08:18:09 +02:00
|
|
|
cert = ssl_certificate_find(server, atoi(port), fp);
|
2006-12-06 08:24:40 +01:00
|
|
|
|
2005-01-20 15:15:46 +01:00
|
|
|
ssl_manager_list_view_insert_cert(manager.certlist, NULL,
|
|
|
|
server, port, cert);
|
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
g_free(server);
|
|
|
|
g_free(port);
|
2006-12-06 08:24:40 +01:00
|
|
|
g_free(fp);
|
2002-11-25 16:21:47 +01:00
|
|
|
row++;
|
|
|
|
}
|
2015-06-18 13:22:06 +02:00
|
|
|
g_dir_close(dir);
|
2002-11-25 16:21:47 +01:00
|
|
|
g_free(path);
|
|
|
|
}
|
|
|
|
|
2007-01-20 20:54:05 +01:00
|
|
|
static void ssl_manager_close(void)
|
2002-11-25 16:21:47 +01:00
|
|
|
{
|
|
|
|
gtk_widget_hide(manager.window);
|
|
|
|
}
|
|
|
|
|
2005-06-28 07:32:32 +02:00
|
|
|
static void ssl_manager_close_cb(GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-11-25 16:21:47 +01:00
|
|
|
{
|
|
|
|
ssl_manager_close();
|
|
|
|
}
|
2005-01-20 15:15:46 +01:00
|
|
|
|
2006-08-16 18:24:00 +02:00
|
|
|
static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|
|
|
{
|
2011-10-07 11:17:51 +02:00
|
|
|
if (event && event->keyval == GDK_KEY_Escape)
|
2006-08-16 18:24:00 +02:00
|
|
|
ssl_manager_close();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-01-20 15:15:46 +01:00
|
|
|
static void ssl_manager_double_clicked(GtkTreeView *list_view,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
gpointer data)
|
2002-11-25 16:21:47 +01:00
|
|
|
{
|
|
|
|
SSLCertificate *cert;
|
2005-01-20 15:15:46 +01:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(list_view);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter(model, &iter, path))
|
2002-11-25 16:21:47 +01:00
|
|
|
return;
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
gtk_tree_model_get(model, &iter,
|
|
|
|
SSL_MANAGER_CERT, &cert,
|
|
|
|
-1);
|
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
if (!cert)
|
|
|
|
return;
|
|
|
|
|
2002-12-08 04:15:44 +01:00
|
|
|
sslcertwindow_show_cert(cert);
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
return;
|
2002-11-25 16:21:47 +01:00
|
|
|
}
|
2005-01-20 15:15:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-11-25 16:21:47 +01:00
|
|
|
static void ssl_manager_delete_cb(GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
SSLCertificate *cert;
|
|
|
|
int val;
|
2005-01-20 15:15:46 +01:00
|
|
|
GtkTreeIter sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(manager.certlist)),
|
|
|
|
&model, &sel))
|
2002-11-25 16:21:47 +01:00
|
|
|
return;
|
|
|
|
|
2005-01-20 15:15:46 +01:00
|
|
|
gtk_tree_model_get(model, &sel,
|
|
|
|
SSL_MANAGER_CERT, &cert,
|
|
|
|
-1);
|
2002-11-25 16:21:47 +01:00
|
|
|
if (!cert)
|
|
|
|
return;
|
2005-01-20 15:15:46 +01:00
|
|
|
|
2005-07-17 14:14:10 +02:00
|
|
|
val = alertpanel_full(_("Delete certificate"),
|
|
|
|
_("Do you really want to delete this certificate?"),
|
2006-01-14 12:04:52 +01:00
|
|
|
GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL, FALSE,
|
2006-01-14 10:45:39 +01:00
|
|
|
NULL, ALERT_WARNING, G_ALERTDEFAULT);
|
2005-07-17 14:14:10 +02:00
|
|
|
|
|
|
|
|
2006-01-14 10:45:39 +01:00
|
|
|
if (val != G_ALERTALTERNATE)
|
2002-11-25 16:21:47 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
ssl_certificate_delete_from_disk(cert);
|
|
|
|
ssl_certificate_destroy(cert);
|
2005-01-20 15:15:46 +01:00
|
|
|
gtk_list_store_remove(GTK_LIST_STORE(model), &sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ssl_manager_view_cb(GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
SSLCertificate *cert;
|
|
|
|
GtkTreeIter sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(manager.certlist)),
|
|
|
|
&model, &sel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, &sel,
|
|
|
|
SSL_MANAGER_CERT, &cert,
|
|
|
|
-1);
|
|
|
|
if (!cert)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sslcertwindow_show_cert(cert);
|
2002-11-25 16:21:47 +01:00
|
|
|
}
|
|
|
|
#endif
|