pidgin/pidgin

Parents b632ff7a7936
Children 60f99b6d9fff
Remove purple_contact_manager_add_buddy as it's no longer used

Testing Done:
Checked in with the Turtles!

Reviewed at https://reviews.imfreedom.org/r/3087/
--- a/libpurple/buddy.c Thu Apr 11 20:34:07 2024 -0500
+++ b/libpurple/buddy.c Thu Apr 11 20:55:27 2024 -0500
@@ -359,7 +359,6 @@
purple_buddy_new(PurpleAccount *account, const gchar *name, const gchar *alias)
{
PurpleBuddy *buddy = NULL;
- PurpleContactManager *manager = NULL;
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
g_return_val_if_fail(name != NULL, NULL);
@@ -371,11 +370,6 @@
"local-alias", alias,
NULL);
- manager = purple_contact_manager_get_default();
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- purple_contact_manager_add_buddy(manager, buddy);
- G_GNUC_END_IGNORE_DEPRECATIONS
-
return buddy;
}
--- a/libpurple/purplecontactmanager.c Thu Apr 11 20:34:07 2024 -0500
+++ b/libpurple/purplecontactmanager.c Thu Apr 11 20:55:27 2024 -0500
@@ -95,62 +95,6 @@
return purple_strequal(id_a, id_b);
}
-static gboolean
-purple_contact_manager_convert_icon_to_avatar(G_GNUC_UNUSED GBinding *binding,
- const GValue *from_value,
- GValue *to_value,
- G_GNUC_UNUSED gpointer user_data)
-{
- PurpleBuddyIcon *icon = g_value_get_pointer(from_value);
- GdkPixbuf *avatar = NULL;
- gconstpointer data = NULL;
- size_t len;
-
- if(icon == NULL) {
- g_value_set_object(to_value, NULL);
- return TRUE;
- }
-
- data = purple_buddy_icon_get_data(icon, &len);
-
- avatar = purple_gdk_pixbuf_from_data(data, len);
-
- g_value_take_object(to_value, avatar);
-
- return TRUE;
-}
-
-static gboolean
-purple_contact_manager_convert_avatar_to_icon(G_GNUC_UNUSED GBinding *binding,
- const GValue *from_value,
- GValue *to_value,
- G_GNUC_UNUSED gpointer user_data)
-{
- PurpleBuddyIcon *icon = NULL;
- GdkPixbuf *avatar = g_value_get_object(from_value);
- gchar *buffer = NULL;
- gsize len;
- gboolean result = FALSE;
-
- if(!GDK_IS_PIXBUF(avatar)) {
- g_value_set_pointer(to_value, NULL);
-
- return TRUE;
- }
-
- result = gdk_pixbuf_save_to_buffer(avatar, &buffer, &len, "png", NULL,
- "compression", "9", NULL);
- if(!result) {
- return FALSE;
- }
-
- purple_buddy_icon_set_data(icon, (guchar *)buffer, len, NULL);
-
- g_free(buffer);
-
- return TRUE;
-}
-
static void
purple_contact_manager_protocol_roster_update(PurpleContact *contact) {
PurpleAccount *account = NULL;
@@ -735,82 +679,6 @@
return NULL;
}
-/******************************************************************************
- * Migration API
- *****************************************************************************/
-void
-purple_contact_manager_add_buddy(PurpleContactManager *manager,
- PurpleBuddy *buddy)
-{
- PurpleAccount *account = NULL;
- PurpleContact *contact = NULL;
- PurpleContactInfo *info = NULL;
- PurplePerson *person = NULL;
- PurplePresence *buddy_presence = NULL;
- PurplePresence *contact_presence = NULL;
- const gchar *id = NULL;
-
- g_return_if_fail(PURPLE_IS_CONTACT_MANAGER(manager));
- g_return_if_fail(PURPLE_IS_BUDDY(buddy));
-
- /* Create the new contact. */
- account = purple_buddy_get_account(buddy);
- id = purple_buddy_get_id(buddy);
- contact = purple_contact_new(account, id);
- info = PURPLE_CONTACT_INFO(contact);
-
- person = purple_person_new();
- purple_contact_info_set_person(info, person);
- purple_person_add_contact_info(person, info);
-
- /* Bind all of the properties. */
- g_object_bind_property(buddy, "name", contact, "username",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy, "local-alias", contact, "alias",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy, "server-alias", contact, "display-name",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- buddy_presence = purple_buddy_get_presence(buddy);
- contact_presence = purple_contact_info_get_presence(info);
-
- g_object_bind_property(buddy_presence, "idle", contact_presence, "idle",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "idle-time", contact_presence,
- "idle-time",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "login-time", contact_presence,
- "login-time",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "active-status", contact_presence,
- "active-status",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "message", contact_presence,
- "message",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "emoji", contact_presence,
- "emoji",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "mobile", contact_presence,
- "mobile",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- g_object_bind_property(buddy_presence, "primitive", contact_presence,
- "primitive",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
- g_object_bind_property_full(buddy, "icon", contact, "avatar",
- G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL,
- purple_contact_manager_convert_icon_to_avatar,
- purple_contact_manager_convert_avatar_to_icon,
- NULL, NULL);
-
- /* Finally add it to the manager. */
- purple_contact_manager_add(manager, contact);
-
- /* purple_contact_manager_add adds its own reference, so free our copy. */
- g_clear_object(&contact);
-}
-
void
purple_contact_manager_add_person(PurpleContactManager *manager,
PurplePerson *person)
--- a/libpurple/purplecontactmanager.h Thu Apr 11 20:34:07 2024 -0500
+++ b/libpurple/purplecontactmanager.h Thu Apr 11 20:55:27 2024 -0500
@@ -156,23 +156,6 @@
PurpleContact *purple_contact_manager_find_with_id(PurpleContactManager *manager, PurpleAccount *account, const gchar *id);
/**
- * purple_contact_manager_add_buddy:
- * @manager: The instance.
- * @buddy: A [class@Purple.Buddy] instance.
- *
- * Creates a new [class@Purple.Contact] and binds its properties to @buddy and
- * then adds the new [class@Purple.Contact] via
- * [method@Purple.ContactManager.add].
- *
- * This method is meant to help us transition to the new API and this method
- * shouldn't be used elsewhere.
- *
- * Since: 3.0
- */
-PURPLE_DEPRECATED
-void purple_contact_manager_add_buddy(PurpleContactManager *manager, PurpleBuddy *buddy);
-
-/**
* purple_contact_manager_add_person:
* @manager: The instance.
* @person: The [class@Purple.Person to add].
--- a/libpurple/tests/test_contact_manager.c Thu Apr 11 20:34:07 2024 -0500
+++ b/libpurple/tests/test_contact_manager.c Thu Apr 11 20:55:27 2024 -0500
@@ -262,95 +262,6 @@
g_clear_object(&manager);
}
-static void
-test_purple_contact_manager_add_buddy(void) {
- PurpleAccount *account = NULL;
- PurpleBuddy *buddy = NULL;
- PurpleContact *contact = NULL;
- PurpleContactInfo *info = NULL;
- PurpleContactManager *manager = NULL;
- PurpleStatusType *type = NULL;
- GList *statuses = NULL;
- const gchar *id = NULL;
- const gchar *source = NULL;
- const gchar *destination = NULL;
-
- manager = purple_contact_manager_get_default();
-
- /* Create our account and add the statuses for testing. */
- account = purple_account_new("test", "test");
-
- type = purple_status_type_new(PURPLE_STATUS_OFFLINE, "offline",
- "offline", TRUE);
- statuses = g_list_append(statuses, type);
-
- purple_account_set_status_types(account, statuses);
-
- /* purple_buddy_new will call purple_contact_manager_add_buddy. */
- buddy = purple_buddy_new(account, "buddy-name", "buddy-alias");
-
- /* Verify that we can find the created contact via id. */
- id = purple_buddy_get_id(buddy);
- contact = purple_contact_manager_find_with_id(manager, account, id);
- g_assert_nonnull(contact);
- g_assert_true(PURPLE_IS_CONTACT(contact));
- g_clear_object(&contact);
-
- /* Verify that we can find the created contact via username. */
- contact = purple_contact_manager_find_with_username(manager, account,
- "buddy-name");
- g_assert_nonnull(contact);
- g_assert_true(PURPLE_IS_CONTACT(contact));
-
- info = PURPLE_CONTACT_INFO(contact);
-
- /* Now check the alias and display name to make sure they were synced as
- * well.
- */
- source = purple_buddy_get_local_alias(buddy);
- destination = purple_contact_info_get_alias(info);
- g_assert_cmpstr(destination, ==, source);
-
- source = purple_buddy_get_server_alias(buddy);
- destination = purple_contact_info_get_display_name(info);
- g_assert_cmpstr(destination, ==, source);
-
- /* Now let's change the settings in the buddy and verify they made it to the
- * contact.
- */
- /* We have to skip testing the name because we have to stand up a LOT more
- * of libpurple to be able to change the name.
- purple_buddy_set_name(buddy, "guy-name");
- g_assert_cmpstr(purple_contact_get_username(contact), ==, "guy-name");
- */
-
- purple_buddy_set_local_alias(buddy, "guy-alias");
- g_assert_cmpstr(purple_contact_info_get_alias(info), ==, "guy-alias");
-
- purple_buddy_set_server_alias(buddy, "server-guy");
- g_assert_cmpstr(purple_contact_info_get_display_name(info), ==,
- "server-guy");
-
- purple_contact_info_set_alias(info, "friend-alias");
- g_assert_cmpstr(purple_buddy_get_local_alias(buddy), ==, "friend-alias");
-
- purple_contact_info_set_display_name(info, "server-friend");
- g_assert_cmpstr(purple_buddy_get_server_alias(buddy), ==, "server-friend");
-
- /* We can't verify the presences changes because PurpleBuddy has to be in
- * a PurpleMetaContact for that to not crash.
- */
-
- /* Since we're working on the default contact manager, make sure we remove
- * any contacts for our test account.
- */
- purple_contact_manager_remove_all(manager, account);
-
- g_clear_object(&account);
- g_clear_object(&buddy);
- g_clear_object(&contact);
-}
-
/******************************************************************************
* Person Tests
*****************************************************************************/
@@ -553,9 +464,6 @@
g_test_add_func("/contact-manager/find/with-id",
test_purple_contact_manager_find_with_id);
- g_test_add_func("/contact-manager/add-buddy",
- test_purple_contact_manager_add_buddy);
-
g_test_add_func("/contact-manager/person/add-remove",
test_purple_contact_manager_person_add_remove);
g_test_add_func("/contact-manager/person/add-via-contact-remove-person-with-contacts",