annotate finch/gntcertmgr.c @ 19729:d397000d32fc

Various leakfixes and preventing unnecessary allocations.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 11 Sep 2007 04:06:56 +0000
parents 44b4e8bd759b
children acd11ab58561 6bf32c9e15a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /**
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * @file gntcertmgr.c GNT Certificate Manager API
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 * @ingroup finch
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 * finch
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * Finch is the legal property of its developers, whose names are too numerous
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * source distribution.
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19528
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26
19528
b7fa8fa4de5b Fix building on older glib versions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19516
diff changeset
27 #include "internal.h"
b7fa8fa4de5b Fix building on older glib versions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19516
diff changeset
28
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include "certificate.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include "debug.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include "notify.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 #include "request.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 #include "finch.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 #include "gntcertmgr.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 #include "gntbutton.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 #include "gntlabel.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 #include "gnttree.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 #include "gntutils.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 #include "gntwindow.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 struct {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 GntWidget *window;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 GntWidget *tree;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 PurpleCertificatePool *pool;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 } certmgr;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 /* Pretty much Xerox of gtkcertmgr */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 /* Add certificate */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 tls_peers_mgmt_import_ok2_cb(gpointer data, const char *result)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 PurpleCertificate *crt = (PurpleCertificate *) data;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 const char *id = result;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 /* TODO: Perhaps prompt if you're overwriting a cert? */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 purple_certificate_pool_store(purple_certificate_find_pool("x509", "tls_peers"), id, crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 purple_certificate_destroy(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 tls_peers_mgmt_import_cancel2_cb(gpointer data, const char *result)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 PurpleCertificate *crt = (PurpleCertificate *) data;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 purple_certificate_destroy(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 tls_peers_mgmt_import_ok_cb(gpointer data, const char *filename)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 PurpleCertificateScheme *x509;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 PurpleCertificate *crt;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 x509 = purple_certificate_pool_get_scheme(purple_certificate_find_pool("x509", "tls_peers"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 crt = purple_certificate_import(x509, filename);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 if (crt != NULL) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 gchar *default_hostname;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 default_hostname = purple_certificate_get_subject_name(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 purple_request_input(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 _("Certificate Import"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 _("Specify a hostname"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 _("Type the host name this certificate is for."),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 default_hostname, FALSE, FALSE, NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 _("OK"), G_CALLBACK(tls_peers_mgmt_import_ok2_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 _("Cancel"), G_CALLBACK(tls_peers_mgmt_import_cancel2_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 NULL, NULL, NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 g_free(default_hostname);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 } else {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 gchar * secondary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 secondary = g_strdup_printf(_("File %s could not be imported.\nMake sure that the file is readable and in PEM format.\n"), filename);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 purple_notify_error(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 _("Certificate Import Error"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 _("X.509 certificate import failed"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 g_free(secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 add_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 purple_request_file(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 _("Select a PEM certificate"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 "certificate.pem",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 FALSE,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 G_CALLBACK(tls_peers_mgmt_import_ok_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 NULL, NULL, NULL, NULL );
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 /* Save certs in some file */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 tls_peers_mgmt_export_ok_cb(gpointer data, const char *filename)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 PurpleCertificate *crt = (PurpleCertificate *) data;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 if (!purple_certificate_export(filename, crt)) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 gchar * secondary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 secondary = g_strdup_printf(_("Export to file %s failed.\nCheck that you have write permission to the target path\n"), filename);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 purple_notify_error(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 _("Certificate Export Error"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 _("X.509 certificate export failed"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 g_free(secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 purple_certificate_destroy(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 save_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 PurpleCertificate *crt;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 const char *key;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 key = gnt_tree_get_selection_data(GNT_TREE(certmgr.tree));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 if (!key)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 crt = purple_certificate_pool_retrieve(certmgr.pool, key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 if (!crt) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 purple_debug_error("gntcertmgr/tls_peers_mgmt",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 "Id %s was not in the peers cache?!\n", key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 purple_request_file((void*)key,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 _("PEM X.509 Certificate Export"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 "certificate.pem", TRUE,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 G_CALLBACK(tls_peers_mgmt_export_ok_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 G_CALLBACK(purple_certificate_destroy),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 NULL, NULL, NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 /* Show information about a cert */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 info_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 const char *key;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 PurpleCertificate *crt;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 gchar *subject;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 GByteArray *fpr_sha1;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 gchar *fpr_sha1_asc;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 gchar *primary, *secondary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 key = gnt_tree_get_selection_data(GNT_TREE(certmgr.tree));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 if (!key)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 crt = purple_certificate_pool_retrieve(certmgr.pool, key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 g_return_if_fail(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 primary = g_strdup_printf(_("Certificate for %s"), key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 fpr_sha1 = purple_certificate_get_fingerprint_sha1(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 fpr_sha1_asc = purple_base16_encode_chunked(fpr_sha1->data,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 fpr_sha1->len);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 subject = purple_certificate_get_subject_name(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 secondary = g_strdup_printf(_("Common name: %s\n\nSHA1 fingerprint:\n%s"), subject, fpr_sha1_asc);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 purple_notify_info(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 _("SSL Host Certificate"), primary, secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 g_free(primary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 g_free(secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 g_byte_array_free(fpr_sha1, TRUE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 g_free(fpr_sha1_asc);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 g_free(subject);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 purple_certificate_destroy(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 /* Delete a cert */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 tls_peers_mgmt_delete_confirm_cb(gchar *id, gint dontcare)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 if (!purple_certificate_pool_delete(certmgr.pool, id)) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 purple_debug_warning("gntcertmgr/tls_peers_mgmt",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 "Deletion failed on id %s\n", id);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 };
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 g_free(id);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 delete_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 gchar *primary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 const char *key;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 key = gnt_tree_get_selection_data(GNT_TREE(certmgr.tree));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 if (!key)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 primary = g_strdup_printf(_("Really delete certificate for %s?"), key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 purple_request_close_with_handle((void *)key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 purple_request_yes_no((void *)key, _("Confirm certificate delete"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 primary, NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 2,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 NULL, NULL, NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 g_strdup(key),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 tls_peers_mgmt_delete_confirm_cb,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 g_free);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 g_free(primary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 /* populate the list */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 populate_cert_list()
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 GList *idlist, *l;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 gnt_tree_remove_all(GNT_TREE(certmgr.tree));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 idlist = purple_certificate_pool_get_idlist(purple_certificate_find_pool("x509", "tls_peers"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 for (l = idlist; l; l = l->next) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259 gnt_tree_add_row_last(GNT_TREE(certmgr.tree), g_strdup(l->data),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 gnt_tree_create_row(GNT_TREE(certmgr.tree), l->data), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 purple_certificate_pool_destroy_idlist(idlist);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 cert_list_added(PurpleCertificatePool *pool, const char *id, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 g_return_if_fail(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 gnt_tree_add_row_last(GNT_TREE(certmgr.tree), g_strdup(id),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 gnt_tree_create_row(GNT_TREE(certmgr.tree), id), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 cert_list_removed(PurpleCertificatePool *pool, const char *id, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 g_return_if_fail(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 purple_request_close_with_handle((void*)id);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 gnt_tree_remove(GNT_TREE(certmgr.tree), (void*)id);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 void finch_certmgr_show(void)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 GntWidget *win, *tree, *box, *button;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 PurpleCertificatePool *pool;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 if (certmgr.window) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 gnt_window_present(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 certmgr.window = win = gnt_vwindow_new(FALSE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 gnt_box_set_title(GNT_BOX(win), _("Certificate Manager"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 gnt_box_set_pad(GNT_BOX(win), 0);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295 certmgr.tree = tree = gnt_tree_new();
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 gnt_tree_set_column_title(GNT_TREE(tree), 0, _("Hostname"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 gnt_box_add_widget(GNT_BOX(win), tree);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 box = gnt_hbox_new(FALSE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 gnt_box_add_widget(GNT_BOX(win), box);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 button = gnt_button_new(_("Add"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_cert_cb), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 gnt_util_set_trigger_widget(GNT_WIDGET(tree), GNT_KEY_INS, button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310 button = gnt_button_new(_("Save"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_cert_cb), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 button = gnt_button_new(_("Info"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(info_cert_cb), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318 button = gnt_button_new(_("Delete"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_cert_cb), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 gnt_util_set_trigger_widget(GNT_WIDGET(tree), GNT_KEY_DEL, button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 button = gnt_button_new(_("Close"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), win);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327 g_signal_connect_swapped(G_OBJECT(win), "destroy", G_CALLBACK(g_nullify_pointer), &certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 populate_cert_list();
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 pool = certmgr.pool = purple_certificate_find_pool("x509", "tls_peers");
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332 purple_signal_connect(pool, "certificate-stored",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
333 win, PURPLE_CALLBACK(cert_list_added), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 purple_signal_connect(pool, "certificate-deleted",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 win, PURPLE_CALLBACK(cert_list_removed), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(purple_signals_disconnect_by_handle), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
338 gnt_widget_show(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340