--- a/libpurple/buddy.c Thu Mar 17 23:24:27 2022 -0500
+++ b/libpurple/buddy.c Thu Mar 17 23:25:33 2022 -0500
@@ -30,6 +30,7 @@
@@ -45,6 +46,7 @@
@@ -63,6 +65,16 @@
*****************************************************************************/
+purple_buddy_set_id(PurpleBuddy *buddy, const gchar *id) { + PurpleBuddyPrivate *priv = purple_buddy_get_instance_private(buddy); + priv->id = g_strdup(id); + g_object_notify_by_pspec(G_OBJECT(buddy), properties[PROP_ID]); purple_buddy_set_account(PurpleBuddy *buddy, PurpleAccount *account) {
PurpleBuddyPrivate *priv = purple_buddy_get_instance_private(buddy);
@@ -81,6 +93,9 @@
PurpleBuddy *buddy = PURPLE_BUDDY(obj);
+ purple_buddy_set_id(buddy, g_value_get_string(value)); purple_buddy_set_name(buddy, g_value_get_string(value));
@@ -113,6 +128,9 @@
PurpleBuddy *buddy = PURPLE_BUDDY(obj);
+ g_value_set_string(value, purple_buddy_get_id(buddy)); g_value_set_string(value, purple_buddy_get_name(buddy));
@@ -151,6 +169,14 @@
G_OBJECT_CLASS(purple_buddy_parent_class)->constructed(object);
+ gchar *id = g_uuid_string_random(); + purple_buddy_set_id(buddy, id); priv->presence = PURPLE_PRESENCE(purple_buddy_presence_new(buddy));
purple_presence_set_status_active(priv->presence, "offline", TRUE);
@@ -184,6 +210,7 @@
g_free(priv->local_alias);
g_free(priv->server_alias);
@@ -200,6 +227,22 @@
obj_class->get_property = purple_buddy_get_property;
obj_class->set_property = purple_buddy_set_property;
+ * A globally unique identifier for this specific buddy. + * If an id is not passed during instantiation a uuid4 string is set as the + properties[PROP_ID] = g_param_spec_string( + "The globally unique identifier of the buddy.", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); properties[PROP_NAME] = g_param_spec_string(
"The name of the buddy.",
@@ -261,6 +304,17 @@
+purple_buddy_get_id(PurpleBuddy *buddy) { + PurpleBuddyPrivate *priv = NULL; + g_return_val_if_fail(PURPLE_IS_BUDDY(buddy), NULL); + priv = purple_buddy_get_instance_private(buddy); purple_buddy_set_icon(PurpleBuddy *buddy, PurpleBuddyIcon *icon) {
PurpleBuddyPrivate *priv = NULL;
--- a/libpurple/buddy.h Thu Mar 17 23:24:27 2022 -0500
+++ b/libpurple/buddy.h Thu Mar 17 23:25:33 2022 -0500
@@ -121,6 +121,18 @@
PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias);
+ * Gets the globally unique identifier of the buddy. + * Returns: The id of @buddy. +const gchar *purple_buddy_get_id(PurpleBuddy *buddy);