annotate finch/gntcertmgr.c @ 32660:1c1317a2d471

Enable the menu-refreshing logic in the conversation menu, now that the signal (un)blocking affects the correct widget.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 14 Mar 2011 06:45:05 +0000
parents a8cc50c2279f
children
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
20074
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
4 */
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
5
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19681
diff changeset
6 /* finch
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * source distribution.
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * 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
13 * 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
14 * 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
15 * (at your option) any later version.
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * 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
18 * 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
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 * 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
23 * 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
24 * 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
25 *
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27
28770
259bbfb423d4 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents: 27587
diff changeset
28 #include <internal.h>
22218
5152a14d06a3 Include finch.h from these files, instead of internal.h.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22143
diff changeset
29 #include "finch.h"
19528
b7fa8fa4de5b Fix building on older glib versions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19516
diff changeset
30
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include "certificate.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 #include "debug.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 #include "notify.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 #include "request.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 #include "gntcertmgr.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 #include "gntbutton.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 #include "gntlabel.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 #include "gnttree.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 #include "gntutils.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 #include "gntwindow.h"
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 struct {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 GntWidget *window;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 GntWidget *tree;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 PurpleCertificatePool *pool;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 } certmgr;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 /* Pretty much Xerox of gtkcertmgr */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 /* Add certificate */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 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
55 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 PurpleCertificate *crt = (PurpleCertificate *) data;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 const char *id = result;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 /* TODO: Perhaps prompt if you're overwriting a cert? */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 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
62 purple_certificate_destroy(crt);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 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
67 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 PurpleCertificate *crt = (PurpleCertificate *) data;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 purple_certificate_destroy(crt);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 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
74 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 PurpleCertificateScheme *x509;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 PurpleCertificate *crt;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 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
79
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 crt = purple_certificate_import(x509, filename);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 if (crt != NULL) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 gchar *default_hostname;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 default_hostname = purple_certificate_get_subject_name(crt);
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
85 purple_request_input(NULL,
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 _("Certificate Import"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 _("Specify a hostname"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 _("Type the host name this certificate is for."),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 default_hostname, FALSE, FALSE, NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 _("OK"), G_CALLBACK(tls_peers_mgmt_import_ok2_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 _("Cancel"), G_CALLBACK(tls_peers_mgmt_import_cancel2_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 NULL, NULL, NULL,
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
93 crt);
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 g_free(default_hostname);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 } else {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 gchar * secondary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 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
98 purple_notify_error(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 _("Certificate Import Error"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 _("X.509 certificate import failed"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 g_free(secondary);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 add_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 {
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
109 purple_request_file(NULL,
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 _("Select a PEM certificate"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 "certificate.pem",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 FALSE,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 G_CALLBACK(tls_peers_mgmt_import_ok_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 NULL,
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
115 NULL, NULL, NULL, NULL );
19516
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 /* Save certs in some file */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 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
121 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 PurpleCertificate *crt = (PurpleCertificate *) data;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 if (!purple_certificate_export(filename, crt)) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 gchar * secondary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 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
128 purple_notify_error(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 _("Certificate Export Error"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 _("X.509 certificate export failed"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 g_free(secondary);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 purple_certificate_destroy(crt);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 save_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 PurpleCertificate *crt;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 const char *key;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 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
148 if (!key)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 crt = purple_certificate_pool_retrieve(certmgr.pool, key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 if (!crt) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 purple_debug_error("gntcertmgr/tls_peers_mgmt",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 "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
155 return;
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
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
158 purple_request_file((void*)key,
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 _("PEM X.509 Certificate Export"),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 "certificate.pem", TRUE,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 G_CALLBACK(tls_peers_mgmt_export_ok_cb),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 G_CALLBACK(purple_certificate_destroy),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 NULL, NULL, NULL,
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
164 crt);
19516
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 /* Show information about a cert */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 info_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 const char *key;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 PurpleCertificate *crt;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 gchar *subject;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 GByteArray *fpr_sha1;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 gchar *fpr_sha1_asc;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 gchar *primary, *secondary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 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
182 if (!key)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 crt = purple_certificate_pool_retrieve(certmgr.pool, key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 g_return_if_fail(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 primary = g_strdup_printf(_("Certificate for %s"), key);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 fpr_sha1 = purple_certificate_get_fingerprint_sha1(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 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
192 fpr_sha1->len);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 subject = purple_certificate_get_subject_name(crt);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 secondary = g_strdup_printf(_("Common name: %s\n\nSHA1 fingerprint:\n%s"), subject, fpr_sha1_asc);
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 28770
diff changeset
196
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 purple_notify_info(NULL,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 _("SSL Host Certificate"), primary, secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 g_free(primary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 g_free(secondary);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 g_byte_array_free(fpr_sha1, TRUE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 g_free(fpr_sha1_asc);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 g_free(subject);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 purple_certificate_destroy(crt);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 /* Delete a cert */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 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
211 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 if (!purple_certificate_pool_delete(certmgr.pool, id)) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 purple_debug_warning("gntcertmgr/tls_peers_mgmt",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 "Deletion failed on id %s\n", id);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 g_free(id);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 delete_cert_cb(GntWidget *button, gpointer null)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 gchar *primary;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 const char *key;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 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
230 if (!key)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 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
234
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 purple_request_close_with_handle((void *)key);
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
236 purple_request_yes_no((void *)key, _("Confirm certificate delete"),
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 primary, NULL,
22257
8233bbcf3e86 The Gnome Human Interface Guidelines say, "if pressing this button by
Mark Doliner <mark@kingant.net>
parents: 22218
diff changeset
238 0,
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
239 NULL, NULL, NULL,
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 g_strdup(key),
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 tls_peers_mgmt_delete_confirm_cb,
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 g_free);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 g_free(primary);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 /* populate the list */
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 static void
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21570
diff changeset
249 populate_cert_list(void)
19516
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 GList *idlist, *l;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 if (!certmgr.window)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 return;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 gnt_tree_remove_all(GNT_TREE(certmgr.tree));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 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
259 for (l = idlist; l; l = l->next) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 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
261 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
262 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 purple_certificate_pool_destroy_idlist(idlist);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 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
268 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 g_return_if_fail(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 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
271 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
272 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 static void
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 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
276 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 g_return_if_fail(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 purple_request_close_with_handle((void*)id);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 gnt_tree_remove(GNT_TREE(certmgr.tree), (void*)id);
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 void finch_certmgr_show(void)
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 GntWidget *win, *tree, *box, *button;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285 PurpleCertificatePool *pool;
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 if (certmgr.window) {
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 gnt_window_present(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 return;
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
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 certmgr.window = win = gnt_vwindow_new(FALSE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 gnt_box_set_title(GNT_BOX(win), _("Certificate Manager"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 gnt_box_set_pad(GNT_BOX(win), 0);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 certmgr.tree = tree = gnt_tree_new();
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 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
298 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
299 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 gnt_box_add_widget(GNT_BOX(win), tree);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 box = gnt_hbox_new(FALSE);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 gnt_box_add_widget(GNT_BOX(win), box);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 button = gnt_button_new(_("Add"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 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
309 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
310
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 button = gnt_button_new(_("Save"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 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
314
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 button = gnt_button_new(_("Info"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 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
318
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 button = gnt_button_new(_("Delete"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 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
322 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
323
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 button = gnt_button_new(_("Close"));
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 gnt_box_add_widget(GNT_BOX(box), button);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326 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
327
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328 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
329
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 populate_cert_list();
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332 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
333 purple_signal_connect(pool, "certificate-stored",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 win, PURPLE_CALLBACK(cert_list_added), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 purple_signal_connect(pool, "certificate-deleted",
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336 win, PURPLE_CALLBACK(cert_list_removed), NULL);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337 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
338
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339 gnt_widget_show(certmgr.window);
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340 }
e1751162ab1f Add certificate UI in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
341