| 37 |
37 |
| 38 #include "gtkblist.h" |
38 #include "gtkblist.h" |
| 39 #include "gtkutils.h" |
39 #include "gtkutils.h" |
| 40 |
40 |
| 41 #include "gtkcertmgr.h" |
41 #include "gtkcertmgr.h" |
| |
42 |
| |
43 #ifdef ENABLE_GCR |
| |
44 #define GCR_API_SUBJECT_TO_CHANGE |
| |
45 #include <gcr/gcr.h> |
| |
46 #include <gcr/gcr-simple-certificate.h> |
| |
47 #endif |
| 42 |
48 |
| 43 /***************************************************************************** |
49 /***************************************************************************** |
| 44 * X.509 tls_peers management interface * |
50 * X.509 tls_peers management interface * |
| 45 *****************************************************************************/ |
51 *****************************************************************************/ |
| 46 |
52 |
| 308 GtkTreeSelection *select = tpm_dat->listselect; |
314 GtkTreeSelection *select = tpm_dat->listselect; |
| 309 GtkTreeIter iter; |
315 GtkTreeIter iter; |
| 310 GtkTreeModel *model; |
316 GtkTreeModel *model; |
| 311 gchar *id; |
317 gchar *id; |
| 312 PurpleCertificate *crt; |
318 PurpleCertificate *crt; |
| |
319 #ifdef ENABLE_GCR |
| |
320 GByteArray *der; |
| |
321 GcrCertificate *gcrt; |
| |
322 char *title; |
| |
323 GtkWidget *dialog; |
| |
324 GcrCertificateBasicsWidget *cert_widget; |
| |
325 #endif |
| 313 |
326 |
| 314 /* See if things are selected */ |
327 /* See if things are selected */ |
| 315 if (!gtk_tree_selection_get_selected(select, &model, &iter)) { |
328 if (!gtk_tree_selection_get_selected(select, &model, &iter)) { |
| 316 purple_debug_warning("gtkcertmgr/tls_peers_mgmt", |
329 purple_debug_warning("gtkcertmgr/tls_peers_mgmt", |
| 317 "Info clicked with no selection?\n"); |
330 "Info clicked with no selection?\n"); |
| 323 |
336 |
| 324 /* Now retrieve the certificate */ |
337 /* Now retrieve the certificate */ |
| 325 crt = purple_certificate_pool_retrieve(tpm_dat->tls_peers, id); |
338 crt = purple_certificate_pool_retrieve(tpm_dat->tls_peers, id); |
| 326 g_return_if_fail(crt); |
339 g_return_if_fail(crt); |
| 327 |
340 |
| |
341 #ifdef ENABLE_GCR |
| |
342 der = purple_certificate_get_der_data(crt); |
| |
343 g_return_if_fail(der); |
| |
344 |
| |
345 gcrt = gcr_simple_certificate_new(der->data, der->len); |
| |
346 g_return_if_fail(gcrt); |
| |
347 |
| |
348 /* Fire the notification */ |
| |
349 title = g_strdup_printf(_("Certificate Information for %s"), id); |
| |
350 dialog = gtk_dialog_new_with_buttons(title, |
| |
351 NULL, |
| |
352 0, |
| |
353 GTK_STOCK_OK, |
| |
354 GTK_RESPONSE_ACCEPT, |
| |
355 NULL); |
| |
356 cert_widget = gcr_certificate_basics_widget_new(gcrt); |
| |
357 gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), |
| |
358 GTK_WIDGET(cert_widget), TRUE, TRUE, 0); |
| |
359 g_signal_connect_swapped(dialog, "response", |
| |
360 G_CALLBACK(gtk_widget_destroy), |
| |
361 dialog); |
| |
362 gtk_widget_show_all(dialog); |
| |
363 |
| |
364 g_byte_array_free(der, TRUE); |
| |
365 g_object_unref(G_OBJECT(gcrt)); |
| |
366 #else |
| 328 /* Fire the notification */ |
367 /* Fire the notification */ |
| 329 purple_certificate_display_x509(crt); |
368 purple_certificate_display_x509(crt); |
| 330 |
369 |
| 331 g_free(id); |
370 g_free(id); |
| 332 purple_certificate_destroy(crt); |
371 purple_certificate_destroy(crt); |
| |
372 #endif |
| 333 } |
373 } |
| 334 |
374 |
| 335 static void |
375 static void |
| 336 tls_peers_mgmt_activated_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) |
376 tls_peers_mgmt_activated_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) |
| 337 { |
377 { |