pidgin: c05da2a6: Display a certificate request field in P...

qulogic at pidgin.im qulogic at pidgin.im
Mon Feb 27 18:12:26 EST 2012


----------------------------------------------------------------------
Revision: c05da2a6c225b797e95e3231d5c6628fc9eb32e5
Parent:   f2ad927fa98dba64f5c3e6c533fd57c8ca8da334
Author:   qulogic at pidgin.im
Date:     02/25/12 22:54:26
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c05da2a6c225b797e95e3231d5c6628fc9eb32e5

Changelog: 

Display a certificate request field in Pidgin and Finch by just using
the display string of the certificate in a label.

Changes against parent f2ad927fa98dba64f5c3e6c533fd57c8ca8da334

  patched  finch/gntrequest.c
  patched  pidgin/gtkrequest.c

-------------- next part --------------
============================================================
--- pidgin/gtkrequest.c	7663a69c357ae2ea22b19e5b31a4dfe601bcf5b1
+++ pidgin/gtkrequest.c	4e4dd8a2de2d1d2ce76e10250212fd2b29b2cdcb
@@ -1191,6 +1191,29 @@ create_list_field(PurpleRequestField *fi
 	return pidgin_make_scrollable(treeview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, -1);
 }
 
+static GtkWidget *
+create_certificate_field(PurpleRequestField *field)
+{
+	GtkWidget *cert_label;
+	PurpleCertificate *cert;
+	char *str;
+	char *escaped;
+
+	cert = purple_request_field_certificate_get_value(field);
+	str = purple_certificate_get_display_string(cert);
+	escaped = g_markup_escape_text(str, -1);
+
+	cert_label = gtk_label_new(NULL);
+	gtk_label_set_markup(GTK_LABEL(cert_label), escaped);
+	gtk_label_set_line_wrap(GTK_LABEL(cert_label), TRUE);
+	gtk_misc_set_alignment(GTK_MISC(cert_label), 0, 0);
+
+	g_free(str);
+	g_free(escaped);
+
+	return cert_label;
+}
+
 static void *
 pidgin_request_fields(const char *title, const char *primary,
 						const char *secondary, PurpleRequestFields *fields,
@@ -1478,6 +1501,8 @@ pidgin_request_fields(const char *title,
 						widget = create_image_field(field);
 					else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
 						widget = create_account_field(field);
+					else if (type == PURPLE_REQUEST_FIELD_CERTIFICATE)
+						widget = create_certificate_field(field);
 					else
 						continue;
 				}
============================================================
--- finch/gntrequest.c	f91ca2c96ce82651ca1aaf6786d67d07b10c889c
+++ finch/gntrequest.c	75d0fe668e1890fd302de368f15c7f5fbd9ff9a4
@@ -571,6 +571,22 @@ create_account_field(PurpleRequestField 
 	return combo;
 }
 
+static GntWidget*
+create_certificate_field(PurpleRequestField *field)
+{
+	GntWidget *w;
+	PurpleCertificate *cert;
+	char *str;
+
+	cert = purple_request_field_certificate_get_value(field);
+	str = purple_certificate_get_display_string(cert);
+	w = gnt_label_new(str);
+
+	g_free(str);
+
+	return w;
+}
+
 static void *
 finch_request_fields(const char *title, const char *primary,
 		const char *secondary, PurpleRequestFields *allfields,
@@ -650,6 +666,10 @@ finch_request_fields(const char *title, 
 				accountlist = create_account_field(field);
 				purple_request_field_set_ui_data(field, accountlist);
 			}
+			else if (type == PURPLE_REQUEST_FIELD_CERTIFICATE)
+			{
+				purple_request_field_set_ui_data(field, create_certificate_field(field));
+			}
 			else
 			{
 				purple_request_field_set_ui_data(field, gnt_label_new_with_format(_("Not implemented yet."),


More information about the Commits mailing list