Replace PurpleNamedValue with PurpleKeyValuePair
--- a/finch/gntplugin.c Tue Nov 26 23:59:35 2019 +0300
+++ b/finch/gntplugin.c Wed Nov 27 00:08:11 2019 +0300
@@ -586,7 +586,7 @@
field = purple_request_field_list_new(name, label);
purple_request_field_list_set_multi_select(field, FALSE);
for (GList *list = purple_plugin_pref_get_choices(pref); list != NULL; list = list->next) {
- const PurpleNamedValue *choice = list->data;
+ const PurpleKeyValuePair *choice = list->data; case PURPLE_PREF_BOOLEAN:
@@ -602,9 +602,9 @@
stringlist = g_list_prepend(stringlist, value);
- purple_request_field_list_add_icon(field, choice->name, NULL, value);
+ purple_request_field_list_add_icon(field, choice->key, NULL, value); if (purple_strequal(value, current_value))
- purple_request_field_list_add_selected(field, choice->name);
+ purple_request_field_list_add_selected(field, choice->key); --- a/finch/gntrequest.c Tue Nov 26 23:59:35 2019 +0300
+++ b/finch/gntrequest.c Wed Nov 27 00:08:11 2019 +0300
@@ -475,9 +475,9 @@
for (GList *it = purple_request_field_choice_get_elements(field); it != NULL; it = g_list_next(it))
- PurpleNamedValue *choice = it->data;
+ PurpleKeyValuePair *choice = it->data; - gnt_combo_box_add_data(GNT_COMBO_BOX(combo), choice->value, choice->name);
+ gnt_combo_box_add_data(GNT_COMBO_BOX(combo), choice->value, choice->key); gnt_combo_box_set_selected(GNT_COMBO_BOX(combo),
purple_request_field_choice_get_default_value(field));
@@ -682,9 +682,9 @@
extra_actions = purple_request_cpar_get_extra_actions(cpar);
for (GSList *it = extra_actions; it; it = it->next) {
- PurpleNamedValue *extra_action = it->data;
+ PurpleKeyValuePair *extra_action = it->data; - GntWidget *button = gnt_button_new(extra_action->name);
+ GntWidget *button = gnt_button_new(extra_action->key); gnt_box_add_widget_in_front(GNT_BOX(box), button);
g_object_set_data(G_OBJECT(button), "ui-handle", window);
g_object_set_data(G_OBJECT(button), "extra-cb", extra_action->value);
--- a/libpurple/media/codec.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/media/codec.c Wed Nov 27 00:08:11 2019 +0300
@@ -68,7 +68,7 @@
purple_media_codec_get_instance_private(
PURPLE_MEDIA_CODEC(info));
g_free(priv->encoding_name);
- g_list_free_full(priv->optional_params, (GDestroyNotify)purple_key_value_pair_free);
+ g_list_free_full(priv->optional_params, (GDestroyNotify)purple_key_value_pair_free_full); G_OBJECT_CLASS(purple_media_codec_parent_class)->finalize(info);
@@ -267,9 +267,7 @@
priv = purple_media_codec_get_instance_private(codec);
- new_param = g_new0(PurpleKeyValuePair, 1);
- new_param->key = g_strdup(name);
- new_param->value = g_strdup(value);
+ new_param = purple_key_value_pair_new(name, g_strdup(value)); priv->optional_params = g_list_append(
priv->optional_params, new_param);
@@ -286,12 +284,9 @@
priv = purple_media_codec_get_instance_private(codec);
g_list_remove(priv->optional_params, param);
+ purple_key_value_pair_free_full(param); g_object_notify_by_pspec(G_OBJECT(codec), properties[PROP_OPTIONAL_PARAMS]);
--- a/libpurple/pluginpref.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/pluginpref.c Wed Nov 27 00:08:11 2019 +0300
@@ -145,7 +145,7 @@
- g_list_free_full(pref->choices, (GDestroyNotify)purple_named_value_free);
+ g_list_free_full(pref->choices, (GDestroyNotify)purple_key_value_pair_free); @@ -248,13 +248,13 @@
purple_plugin_pref_add_choice(PurplePluginPref *pref, const char *label, gpointer choice)
- PurpleNamedValue *pref_choice;
+ PurpleKeyValuePair *pref_choice; g_return_if_fail(pref != NULL);
g_return_if_fail(label != NULL);
g_return_if_fail(choice || purple_prefs_get_pref_type(pref->name) == PURPLE_PREF_INT);
- pref_choice = purple_named_value_new(label, choice);
+ pref_choice = purple_key_value_pair_new(label, choice); pref->choices = g_list_append(pref->choices, pref_choice);
--- a/libpurple/protocols/bonjour/mdns_common.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/protocols/bonjour/mdns_common.c Wed Nov 27 00:08:11 2019 +0300
@@ -73,9 +73,8 @@
_add_txt_record(GSList *list, const gchar *key, const gchar *value)
- PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1);
- kvp->key = g_strdup(key);
- kvp->value = g_strdup(get_max_txt_record_value(key, value));
+ const char *max_value = get_max_txt_record_value(key, value); + PurpleKeyValuePair *kvp = purple_key_value_pair_new(key, g_strdup(max_value)); return g_slist_prepend(list, kvp);
@@ -143,7 +142,7 @@
txt_records = generate_presence_txt_records(data);
ret = _mdns_publish(data, type, txt_records);
- g_slist_free_full(txt_records, (GDestroyNotify)purple_key_value_pair_free);
+ g_slist_free_full(txt_records, (GDestroyNotify)purple_key_value_pair_free_full); --- a/libpurple/protocols/gg/gg.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/protocols/gg/gg.c Wed Nov 27 00:08:11 2019 +0300
@@ -1040,9 +1040,7 @@
ggp_server_option = option;
#define ADD_VALUE(list, desc, v) { \
- PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
- kvp->key = g_strdup((desc)); \
- kvp->value = g_strdup((v)); \
+ PurpleKeyValuePair *kvp = purple_key_value_pair_new((desc), g_strdup((v))); \ list = g_list_append(list, kvp); \
--- a/libpurple/protocols/jabber/gtalk.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/protocols/jabber/gtalk.c Wed Nov 27 00:08:11 2019 +0300
@@ -55,9 +55,7 @@
protocol->user_splits = g_list_append(protocol->user_splits, split);
#define ADD_VALUE(list, desc, v) { \
- PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
- kvp->key = g_strdup((desc)); \
- kvp->value = g_strdup((v)); \
+ PurpleKeyValuePair *kvp = purple_key_value_pair_new((desc), g_strdup((v))); \ list = g_list_prepend(list, kvp); \
--- a/libpurple/protocols/jabber/xmpp.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/protocols/jabber/xmpp.c Wed Nov 27 00:08:11 2019 +0300
@@ -46,9 +46,7 @@
protocol->user_splits = g_list_append(protocol->user_splits, split);
#define ADD_VALUE(list, desc, v) { \
- PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
- kvp->key = g_strdup((desc)); \
- kvp->value = g_strdup((v)); \
+ PurpleKeyValuePair *kvp = purple_key_value_pair_new((desc), g_strdup((v))); \ list = g_list_prepend(list, kvp); \
--- a/libpurple/protocols/silc/silc.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/protocols/silc/silc.c Wed Nov 27 00:08:11 2019 +0300
@@ -2171,9 +2171,7 @@
protocol->account_options = g_list_append(protocol->account_options, option);
for (i = 0; silc_default_ciphers[i].name; i++) {
- kvp = g_new0(PurpleKeyValuePair, 1);
- kvp->key = g_strdup(silc_default_ciphers[i].name);
- kvp->value = g_strdup(silc_default_ciphers[i].name);
+ kvp = purple_key_value_pair_new(silc_default_ciphers[i].name, g_strdup(silc_default_ciphers[i].name)); list = g_list_append(list, kvp);
option = purple_account_option_list_new(_("Cipher"), "cipher", list);
@@ -2181,9 +2179,7 @@
for (i = 0; silc_default_hmacs[i].name; i++) {
- kvp = g_new0(PurpleKeyValuePair, 1);
- kvp->key = g_strdup(silc_default_hmacs[i].name);
- kvp->value = g_strdup(silc_default_hmacs[i].name);
+ kvp = purple_key_value_pair_new(silc_default_hmacs[i].name, g_strdup(silc_default_hmacs[i].name)); list = g_list_append(list, kvp);
option = purple_account_option_list_new(_("HMAC"), "hmac", list);
--- a/libpurple/purpleaccountoption.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/purpleaccountoption.c Wed Nov 27 00:08:11 2019 +0300
@@ -185,7 +185,7 @@
else if (option->type == PURPLE_PREF_STRING_LIST)
g_list_free_full(option->default_value.list,
- (GDestroyNotify)purple_key_value_pair_free);
+ (GDestroyNotify)purple_key_value_pair_free_full); @@ -247,7 +247,7 @@
g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST);
g_list_free_full(option->default_value.list,
- (GDestroyNotify)purple_key_value_pair_free);
+ (GDestroyNotify)purple_key_value_pair_free_full); option->default_value.list = values;
@@ -263,9 +263,7 @@
g_return_if_fail(value != NULL);
g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST);
- kvp = g_new0(PurpleKeyValuePair, 1);
- kvp->key = g_strdup(key);
- kvp->value = g_strdup(value);
+ kvp = purple_key_value_pair_new(key, g_strdup(value)); option->default_value.list = g_list_append(option->default_value.list,
--- a/libpurple/request.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/request.c Wed Nov 27 00:08:11 2019 +0300
@@ -397,21 +397,21 @@
- g_slist_free_full(cpar->extra_actions, (GDestroyNotify)purple_named_value_free);
+ g_slist_free_full(cpar->extra_actions, (GDestroyNotify)purple_key_value_pair_free); PurpleRequestFieldsCb cb;
- PurpleNamedValue *extra_action;
+ PurpleKeyValuePair *extra_action; label = va_arg(args, const gchar*);
cb = va_arg(args, PurpleRequestFieldsCb);
- extra_action = purple_named_value_new(label, cb);
+ extra_action = purple_key_value_pair_new(label, cb); extra = g_slist_append(extra, extra_action);
@@ -940,11 +940,11 @@
else if (field->type == PURPLE_REQUEST_FIELD_CHOICE)
for (GList *it = field->u.choice.elements; it != NULL; it = g_list_next(it)) {
- PurpleNamedValue *choice = it->data;
+ PurpleKeyValuePair *choice = it->data; if (choice->value && field->u.choice.data_destroy)
field->u.choice.data_destroy(choice->value);
- purple_named_value_free(choice);
+ purple_key_value_pair_free(choice); g_list_free(field->u.choice.elements);
@@ -1462,13 +1462,13 @@
purple_request_field_choice_add(PurpleRequestField *field, const char *label,
- PurpleNamedValue *choice;
+ 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_named_value_new(label, value);
+ choice = purple_key_value_pair_new(label, value); field->u.choice.elements = g_list_append(field->u.choice.elements,
--- a/libpurple/util.c Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/util.c Wed Nov 27 00:08:11 2019 +0300
@@ -3782,34 +3782,34 @@
return g_string_free(string, FALSE);
-void purple_key_value_pair_free(PurpleKeyValuePair *kvp)
+purple_key_value_pair_new(const char *key, gpointer value) + PurpleKeyValuePair *kvp; + kvp = g_new0(PurpleKeyValuePair, 1); + kvp->key = g_strdup(key); +purple_key_value_pair_free(PurpleKeyValuePair *kvp) + g_return_if_fail(kvp != NULL); +purple_key_value_pair_free_full(PurpleKeyValuePair *kvp) g_return_if_fail(kvp != NULL);
-purple_named_value_new(const char *name, gpointer value)
- PurpleNamedValue *named_value;
- named_value = g_new0(PurpleNamedValue, 1);
- named_value->name = g_strdup(name);
- named_value->value = value;
-purple_named_value_free(PurpleNamedValue *named_value)
- g_return_if_fail(named_value != NULL);
- g_free(named_value->name);
+ purple_key_value_pair_free(kvp); --- a/libpurple/util.h Tue Nov 26 23:59:35 2019 +0300
+++ b/libpurple/util.h Wed Nov 27 00:08:11 2019 +0300
@@ -45,17 +45,6 @@
typedef struct _PurpleKeyValuePair PurpleKeyValuePair;
- * Similar to PurpleKeyValuePair except it doesn't allocate memory for @value.
-typedef struct _PurpleNamedValue PurpleNamedValue;
@@ -71,12 +60,6 @@
-struct _PurpleNamedValue
@@ -105,37 +88,37 @@
const char *album, gpointer unused);
+ * purple_key_value_pair_new: + * @key: The key part of PurpleKeyValuePair + * @value: The value part of PurpleKeyValuePair + * Creates a new PurpleKeyValuePair allocating memory for @key. + * Returns: The created PurpleKeyValuePair +PurpleKeyValuePair *purple_key_value_pair_new(const char *key, gpointer value); * purple_key_value_pair_free:
* @kvp: The PurpleKeyValuePair to free.
- * Frees a PurpleKeyValuePair.
+ * Frees @kvp->key and @kvp. void purple_key_value_pair_free(PurpleKeyValuePair *kvp);
- * purple_named_value_new:
- * @name: The name part of PurpleNamedValue
- * @value: The value part of PurpleNamedValue
+ * purple_key_value_pair_free_full: + * @kvp: The PurpleKeyValuePair to free. - * Creates a new PurpleNamedValue.
- * Returns: The created PurpleNamedValue
+ * Does same as purple_key_value_pair_free and also frees @kvp->value. -PurpleNamedValue *purple_named_value_new(const char *name, gpointer value);
- * purple_named_value_free:
- * @named_value: The PurpleNamedValue to free.
- * Frees a PurpleNamedValue.
-void purple_named_value_free(PurpleNamedValue *named_value);
+void purple_key_value_pair_free_full(PurpleKeyValuePair *kvp); /**************************************************************************/
--- a/pidgin/gtkprefs.c Tue Nov 26 23:59:35 2019 +0300
+++ b/pidgin/gtkprefs.c Wed Nov 27 00:08:11 2019 +0300
@@ -509,18 +509,18 @@
g_object_set_data(G_OBJECT(dropdown), "type", GINT_TO_POINTER(initial.type));
for (; menuitems != NULL; menuitems = g_list_next(menuitems)) {
- const PurpleNamedValue *menu_item = menuitems->data;
+ const PurpleKeyValuePair *menu_item = menuitems->data; const char *str_value = NULL;
gboolean bool_value = FALSE;
- if (menu_item->name == NULL) {
+ if (menu_item->key == NULL) { gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- PREF_DROPDOWN_TEXT, menu_item->name,
+ PREF_DROPDOWN_TEXT, menu_item->key, if (initial.type == PURPLE_PREF_INT) {
--- a/pidgin/gtkrequest.c Tue Nov 26 23:59:35 2019 +0300
+++ b/pidgin/gtkrequest.c Wed Nov 27 00:08:11 2019 +0300
@@ -1238,9 +1238,9 @@
for (GList *l = elements; l != NULL; l = g_list_next(l))
- PurpleNamedValue *choice = l->data;
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), choice->name);
+ PurpleKeyValuePair *choice = l->data; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), choice->key); if (choice->value == default_value) {
@@ -1273,10 +1273,10 @@
for (GList *l = elements; l != NULL; l = g_list_next(l))
- PurpleNamedValue *choice = l->data;
+ PurpleKeyValuePair *choice = l->data; radio = gtk_radio_button_new_with_label_from_widget(
- GTK_RADIO_BUTTON(first_radio), choice->name);
+ GTK_RADIO_BUTTON(first_radio), choice->key); g_object_set_data(G_OBJECT(radio), "box", box);
@@ -1919,9 +1919,9 @@
pidgin_request_add_help(GTK_DIALOG(win), cpar);
for (GSList *it = extra_actions; it != NULL; it = it->next) {
- PurpleNamedValue *extra_action = it->data;
- button = pidgin_dialog_add_button(GTK_DIALOG(win), extra_action->name,
+ PurpleKeyValuePair *extra_action = it->data; + button = pidgin_dialog_add_button(GTK_DIALOG(win), extra_action->key, G_CALLBACK(multifield_extra_cb), data);
g_object_set_data(G_OBJECT(button), "extra-cb", extra_action->value);