pidgin/pidgin

Replace NMProperty with PurpleKeyValuePair

2021-02-25, Arkadiy Illarionov
3c037af432c4
Parents a72067fee822
Children 65dbbd384c8e
Replace NMProperty with PurpleKeyValuePair

Drop related functions.

Testing Done:
Compile.

Reviewed at https://reviews.imfreedom.org/r/523/
--- a/libpurple/protocols/novell/nmuserrecord.c Thu Feb 18 07:55:09 2021 -0600
+++ b/libpurple/protocols/novell/nmuserrecord.c Thu Feb 25 03:49:17 2021 -0600
@@ -40,12 +40,6 @@
int ref_count;
};
-struct _NMProperty
-{
- char *tag;
- char *value;
-};
-
static int count = 0;
/* API functions */
@@ -454,10 +448,10 @@
return count;
}
-NMProperty *
+PurpleKeyValuePair *
nm_user_record_get_property(NMUserRecord * user_record, int index)
{
- NMProperty *property = NULL;
+ PurpleKeyValuePair *property = NULL;
NMField *field = NULL, *fields, *locate;
if (user_record && user_record->fields) {
@@ -469,9 +463,8 @@
if (index < max) {
field = &fields[index];
if (field && field->tag && field->ptr_value) {
- property = g_new0(NMProperty, 1);
- property->tag = g_strdup(field->tag);
- property->value = _get_attribute_value(field);
+ property = purple_key_value_pair_new_full(
+ field->tag, _get_attribute_value(field), g_free);
}
}
}
@@ -479,33 +472,3 @@
return property;
}
-
-void
-nm_release_property(NMProperty * property)
-{
- if (property) {
- g_free(property->tag);
-
- g_free(property->value);
-
- g_free(property);
- }
-}
-
-const char *
-nm_property_get_tag(NMProperty * property)
-{
- if (property)
- return property->tag;
- else
- return NULL;
-}
-
-const char *
-nm_property_get_value(NMProperty * property)
-{
- if (property)
- return property->value;
- else
- return NULL;
-}
--- a/libpurple/protocols/novell/nmuserrecord.h Thu Feb 18 07:55:09 2021 -0600
+++ b/libpurple/protocols/novell/nmuserrecord.h Thu Feb 25 03:49:17 2021 -0600
@@ -24,7 +24,6 @@
#include <glib.h>
typedef struct _NMUserRecord NMUserRecord;
-typedef struct _NMProperty NMProperty;
#include "nmfield.h"
#include "nmuser.h"
@@ -225,40 +224,14 @@
/**
* Get an info property for the user record. The property must be released
- * by calling nm_release_property()
+ * by calling purple_key_value_pair_free()
*
* @param user_record The user record
* @param index The index of the property to get (zero based)
*
* @return The property
*/
-NMProperty *nm_user_record_get_property(NMUserRecord * user_record, int index);
-
-/**
- * Release a property object
- *
- * @param property The property
- *
- */
-void nm_release_property(NMProperty * property);
-
-/**
- * Get the tag for the property
- *
- * @param property The property
- *
- * @return The tag of the property (i.e. "Email Address")
- */
-const char *nm_property_get_tag(NMProperty * property);
-
-/**
- * Get the value for the property
- *
- * @param property The property
- *
- * @return The value of the property (i.e. "nobody@nowhere.com")
- */
-const char *nm_property_get_value(NMProperty * property);
+PurpleKeyValuePair *nm_user_record_get_property(NMUserRecord * user_record, int index);
/**
* Copy a user record (deep copy). The dest user record must have already been
--- a/libpurple/protocols/novell/novell.c Thu Feb 18 07:55:09 2021 -0600
+++ b/libpurple/protocols/novell/novell.c Thu Feb 25 03:49:17 2021 -0600
@@ -1508,7 +1508,6 @@
{
PurpleNotifyUserInfo *user_info = purple_notify_user_info_new();
int count, i;
- NMProperty *property;
const char *tag, *value;
tag = _("User ID");
@@ -1529,16 +1528,16 @@
count = nm_user_record_get_property_count(user_record);
for (i = 0; i < count; i++) {
- property = nm_user_record_get_property(user_record, i);
+ PurpleKeyValuePair *property = nm_user_record_get_property(user_record, i);
if (property) {
- tag = _map_property_tag(nm_property_get_tag(property));
- value = nm_property_get_value(property);
+ tag = _map_property_tag(property->key);
+ value = property->value;
if (tag && value) {
/* TODO: Check whether it's correct to call add_pair_html,
or if we should be using add_pair_plaintext */
purple_notify_user_info_add_pair_html(user_info, tag, value);
}
- nm_release_property(property);
+ purple_key_value_pair_free(property);
}
}