changeset 32555:ca8b2ec198d9

Add a function for prompting about a certificate. This is basically a small wrapper around the request field API.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 26 Feb 2012 04:37:10 +0000
parents 03dcb0185c82
children b1f9e5e9c03f
files ChangeLog.API libpurple/request.c libpurple/request.h
diffstat 3 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Sun Feb 26 03:54:26 2012 +0000
+++ b/ChangeLog.API	Sun Feb 26 04:37:10 2012 +0000
@@ -34,6 +34,7 @@
 		* purple_menu_action_set_data
 		* purple_menu_action_set_callback
 		* purple_menu_action_set_children
+		* purple_request_certificate
 		* purple_request_field_certificate_new
 		* purple_request_field_certificate_get_value
 		* purple_request_field_get_tooltip
--- a/libpurple/request.c	Sun Feb 26 03:54:26 2012 +0000
+++ b/libpurple/request.c	Sun Feb 26 04:37:10 2012 +0000
@@ -1666,6 +1666,29 @@
 	return NULL;
 }
 
+void *
+purple_request_certificate(void *handle, const char *title,
+                                  const char *primary, const char *secondary,
+                                  PurpleCertificate *cert,
+                                  const char *ok_text, GCallback ok_cb,
+                                  const char *cancel_text, GCallback cancel_cb,
+                                  void *user_data)
+{
+	PurpleRequestFields *fields;
+	PurpleRequestFieldGroup *group;
+	PurpleRequestField *field;
+
+	fields = purple_request_fields_new();
+	group = purple_request_field_group_new(NULL);
+	purple_request_fields_add_group(fields, group);
+	field = purple_request_field_certificate_new("certificate", "Certificate", cert);
+	purple_request_field_group_add_field(group, field);
+
+	return purple_request_fields(handle, title, primary, secondary, fields,
+	                             ok_text, ok_cb, cancel_text, cancel_cb,
+	                             NULL, NULL, NULL, user_data);
+}
+
 static void
 purple_request_close_info(PurpleRequestInfo *info)
 {
--- a/libpurple/request.h	Sun Feb 26 03:54:26 2012 +0000
+++ b/libpurple/request.h	Sun Feb 26 04:37:10 2012 +0000
@@ -1531,6 +1531,37 @@
 	PurpleAccount *account, const char *who, PurpleConversation *conv,
 	void *user_data);
 
+/**
+ * Prompts the user for action over a certificate.
+ *
+ * This is often represented as a dialog with a button for each action.
+ *
+ * @param handle        The plugin or connection handle.  For some things this
+ *                      is <em>extremely</em> important.  See the comments on
+ *                      purple_request_input().
+ * @param title         The title of the message, or @c NULL if it should have
+ *                      no title.
+ * @param primary       The main point of the message, or @c NULL if you're
+ *                      feeling enigmatic.
+ * @param secondary     Secondary information, or @c NULL if there is none.
+ * @param cert          The #PurpleCertificate associated with this request.
+ * @param ok_text       The text for the @c OK button, which may not be @c NULL.
+ * @param ok_cb         The callback for the @c OK button, which may not be
+ *                      @c NULL.
+ * @param cancel_text   The text for the @c Cancel button, which may not be
+ *                      @c NULL.
+ * @param cancel_cb     The callback for the @c Cancel button, which may be
+ *                      @c NULL.
+ * @param user_data     The data to pass to the callback.
+ *
+ * @return A UI-specific handle.
+ */
+void *purple_request_certificate(void *handle, const char *title,
+	const char *primary, const char *secondary, PurpleCertificate *cert,
+	const char *ok_text, GCallback ok_cb,
+	const char *cancel_text, GCallback cancel_cb,
+	void *user_data);
+
 /*@}*/
 
 /**************************************************************************/