| 301 G_CALLBACK(tls_peers_mgmt_export_cancel_cb), |
301 G_CALLBACK(tls_peers_mgmt_export_cancel_cb), |
| 302 NULL, NULL, NULL, /* No account,conv,etc. */ |
302 NULL, NULL, NULL, /* No account,conv,etc. */ |
| 303 crt); /* Pass the certificate on to the callback */ |
303 crt); /* Pass the certificate on to the callback */ |
| 304 } |
304 } |
| 305 |
305 |
| |
306 static void |
| |
307 tls_peers_mgmt_info_cb(GtkWidget *button, gpointer data) |
| |
308 { |
| |
309 GtkTreeSelection *select = tpm_dat->listselect; |
| |
310 GtkTreeIter iter; |
| |
311 GtkTreeModel *model; |
| |
312 gchar *id; |
| |
313 PurpleCertificate *crt; |
| |
314 gchar *subject; |
| |
315 GByteArray *fpr_sha1; |
| |
316 gchar *fpr_sha1_asc; |
| |
317 gchar *primary, *secondary; |
| |
318 |
| |
319 /* See if things are selected */ |
| |
320 if (!gtk_tree_selection_get_selected(select, &model, &iter)) { |
| |
321 purple_debug_warning("gtkcertmgr/tls_peers_mgmt", |
| |
322 "Info clicked with no selection?\n"); |
| |
323 return; |
| |
324 } |
| |
325 |
| |
326 /* Retrieve the selected hostname */ |
| |
327 gtk_tree_model_get(model, &iter, TPM_HOSTNAME_COLUMN, &id, -1); |
| |
328 |
| |
329 /* Now retrieve the certificate */ |
| |
330 crt = purple_certificate_pool_retrieve(tpm_dat->tls_peers, id); |
| |
331 g_return_if_fail(crt); |
| |
332 |
| |
333 /* Build a notification thing */ |
| |
334 /* TODO: This needs a better GUI, but a notification will do for now */ |
| |
335 primary = g_strdup_printf(_("Certificate for %s"), id); |
| |
336 |
| |
337 fpr_sha1 = purple_certificate_get_fingerprint_sha1(crt); |
| |
338 fpr_sha1_asc = purple_base16_encode_chunked(fpr_sha1->data, |
| |
339 fpr_sha1->len); |
| |
340 subject = purple_certificate_get_subject_name(crt); |
| |
341 |
| |
342 secondary = g_strdup_printf(_("Common name: %s\n\nSHA1 fingerprint:\n%s"), subject, fpr_sha1_asc); |
| |
343 |
| |
344 purple_notify_info(tpm_dat, |
| |
345 _("SSL Host Certificate"), primary, secondary ); |
| |
346 |
| |
347 g_free(primary); |
| |
348 g_free(secondary); |
| |
349 g_byte_array_free(fpr_sha1, TRUE); |
| |
350 g_free(fpr_sha1_asc); |
| |
351 g_free(subject); |
| |
352 g_free(id); |
| |
353 } |
| 306 |
354 |
| 307 static void |
355 static void |
| 308 tls_peers_mgmt_delete_cb(GtkWidget *button, gpointer data) |
356 tls_peers_mgmt_delete_cb(GtkWidget *button, gpointer data) |
| 309 { |
357 { |
| 310 GtkTreeSelection *select = tpm_dat->listselect; |
358 GtkTreeSelection *select = tpm_dat->listselect; |
| 431 /* Info button */ |
479 /* Info button */ |
| 432 tpm_dat->infobutton = infobutton = |
480 tpm_dat->infobutton = infobutton = |
| 433 gtk_button_new_from_stock(GTK_STOCK_INFO); |
481 gtk_button_new_from_stock(GTK_STOCK_INFO); |
| 434 gtk_box_pack_start(GTK_BOX(bbox), infobutton, FALSE, FALSE, 0); |
482 gtk_box_pack_start(GTK_BOX(bbox), infobutton, FALSE, FALSE, 0); |
| 435 gtk_widget_show(infobutton); |
483 gtk_widget_show(infobutton); |
| |
484 g_signal_connect(G_OBJECT(infobutton), "clicked", |
| |
485 G_CALLBACK(tls_peers_mgmt_info_cb), NULL); |
| |
486 |
| 436 |
487 |
| 437 /* Delete button */ |
488 /* Delete button */ |
| 438 tpm_dat->deletebutton = deletebutton = |
489 tpm_dat->deletebutton = deletebutton = |
| 439 gtk_button_new_from_stock(GTK_STOCK_DELETE); |
490 gtk_button_new_from_stock(GTK_STOCK_DELETE); |
| 440 gtk_box_pack_start(GTK_BOX(bbox), deletebutton, FALSE, FALSE, 0); |
491 gtk_box_pack_start(GTK_BOX(bbox), deletebutton, FALSE, FALSE, 0); |