--- a/ChangeLog.API Sat Mar 13 05:15:31 2021 -0600
+++ b/ChangeLog.API Sat Mar 13 05:39:22 2021 -0600
@@ -48,6 +48,7 @@
* purple_request_certificate
* purple_request_field_certificate_new
* purple_request_field_certificate_get_value
+ * purple_request_field_choice_add_full * purple_request_field_get_tooltip
* purple_request_field_group_get_fields_list
* purple_request_field_set_tooltip
@@ -492,6 +493,8 @@
* purple_quotedp_decode. See the GMime library if needed.
* purple_restore_default_signal_handlers
* purple_request_certificate
+ * purple_request_field_choice_set_data_destructor. Use + purple_request_field_choice_add_full instead * purple_request_field_list_add
* PurpleSetPublicAliasFailureCallback
* PurpleSetPublicAliasSuccessCallback
--- a/libpurple/protocols/jabber/jabber.c Sat Mar 13 05:15:31 2021 -0600
+++ b/libpurple/protocols/jabber/jabber.c Sat Mar 13 05:39:22 2021 -0600
@@ -3369,8 +3369,6 @@
PurpleRequestFieldGroup *group;
JabberMediaRequest *request;
- purple_request_field_choice_set_data_destructor(field, g_free);
for(l = jb->resources; l; l = l->next)
JabberBuddyResource *ljbr = l->data;
@@ -3384,19 +3382,19 @@
(type & PURPLE_MEDIA_VIDEO)) {
if (caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO) {
- purple_request_field_choice_add(field,
- jbr->name, g_strdup(jbr->name));
+ purple_request_field_choice_add_full(field, + jbr->name, g_strdup(jbr->name), g_free); } else if (type & (PURPLE_MEDIA_AUDIO) &&
(caps & PURPLE_MEDIA_CAPS_AUDIO)) {
- purple_request_field_choice_add(field,
- jbr->name, g_strdup(jbr->name));
+ purple_request_field_choice_add_full(field, + jbr->name, g_strdup(jbr->name), g_free); }else if (type & (PURPLE_MEDIA_VIDEO) &&
(caps & PURPLE_MEDIA_CAPS_VIDEO)) {
- purple_request_field_choice_add(field,
- jbr->name, g_strdup(jbr->name));
+ purple_request_field_choice_add_full(field, + jbr->name, g_strdup(jbr->name), g_free); --- a/libpurple/protocols/jabber/si.c Sat Mar 13 05:15:31 2021 -0600
+++ b/libpurple/protocols/jabber/si.c Sat Mar 13 05:39:22 2021 -0600
@@ -1594,11 +1594,9 @@
PurpleRequestField *field = purple_request_field_choice_new("resource", _("Resource"), 0);
PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
- purple_request_field_choice_set_data_destructor(field, g_free);
for(l = resources; l; l = l->next) {
- purple_request_field_choice_add(field, jbr->name, g_strdup(jbr->name));
+ purple_request_field_choice_add_full(field, jbr->name, g_strdup(jbr->name), g_free); purple_request_field_group_add_field(group, field);
--- a/libpurple/protocols/jabber/xdata.c Sat Mar 13 05:15:31 2021 -0600
+++ b/libpurple/protocols/jabber/xdata.c Sat Mar 13 05:39:22 2021 -0600
@@ -361,7 +361,6 @@
data->actiongroup = group = purple_request_field_group_new(_("Actions"));
purple_request_fields_add_group(fields, group);
actionfield = purple_request_field_choice_new("libpurple:jabber:xdata:actions", _("Select an action"), GINT_TO_POINTER(defaultaction));
- purple_request_field_choice_set_data_destructor(actionfield, g_free);
for(i = 0, action = actions; action; action = g_list_next(action), i++) {
JabberXDataAction *a = action->data;
--- a/libpurple/request.c Sat Mar 13 05:15:31 2021 -0600
+++ b/libpurple/request.c Sat Mar 13 05:39:22 2021 -0600
@@ -93,7 +93,6 @@
- GDestroyNotify data_destroy;
@@ -944,14 +943,7 @@
else if (field->type == PURPLE_REQUEST_FIELD_CHOICE)
- for (GList *it = field->u.choice.elements; it != NULL; it = g_list_next(it)) {
- PurpleKeyValuePair *choice = it->data;
- if (choice->value && field->u.choice.data_destroy)
- field->u.choice.data_destroy(choice->value);
- purple_key_value_pair_free(choice);
- g_list_free(field->u.choice.elements);
+ g_list_free_full(field->u.choice.elements, (GDestroyNotify)purple_key_value_pair_free); else if (field->type == PURPLE_REQUEST_FIELD_LIST)
@@ -1467,13 +1459,20 @@
purple_request_field_choice_add(PurpleRequestField *field, const char *label,
+ purple_request_field_choice_add_full(field, label, value, NULL); +purple_request_field_choice_add_full(PurpleRequestField *field, const char *label, + gpointer value, GDestroyNotify destroy) PurpleKeyValuePair *choice;
g_return_if_fail(field != NULL);
g_return_if_fail(label != NULL);
g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_CHOICE);
- choice = purple_key_value_pair_new(label, value);
+ choice = purple_key_value_pair_new_full(label, value, destroy); field->u.choice.elements = g_list_append(field->u.choice.elements,
@@ -1527,16 +1526,6 @@
return field->u.choice.elements;
-purple_request_field_choice_set_data_destructor(PurpleRequestField *field,
- GDestroyNotify destroy)
- g_return_if_fail(field != NULL);
- g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_CHOICE);
- field->u.choice.data_destroy = destroy;
purple_request_field_list_new(const char *id, const char *text)
--- a/libpurple/request.h Sat Mar 13 05:15:31 2021 -0600
+++ b/libpurple/request.h Sat Mar 13 05:39:22 2021 -0600
@@ -1432,6 +1432,21 @@
+ * purple_request_field_choice_add_full: + * @field: The choice field. + * @label: The choice label. + * @data: The choice value. + * @destroy: The value destroy function. + * Adds a choice to a multiple choice field with destructor for value. +purple_request_field_choice_add_full(PurpleRequestField *field, const char *label, + gpointer data, GDestroyNotify destroy); * purple_request_field_choice_set_default_value:
* @default_value: The default value.
@@ -1486,17 +1501,6 @@
purple_request_field_choice_get_elements(const PurpleRequestField *field);
- * purple_request_field_choice_set_data_destructor:
- * @destroy: The destroy function.
- * Sets the destructor for field values.
-purple_request_field_choice_set_data_destructor(PurpleRequestField *field,
- GDestroyNotify destroy);
/**************************************************************************/
/**************************************************************************/