Create PurplePerson.
Review Request #1838 — Created Sept. 25, 2022 and submitted
This automatically manages the sorting of contacts and will report the highest ranked one as the priority contact.
Ran the unit tests
Summary | ID |
---|---|
6d1f75b68b5351c58e2f1a900e64a006356a168c |
Description | From | Last Updated |
---|---|---|
I forgot that I forgot to finish the docs, I'll get to that tonight.. |
grim | |
"after add all the contacts" add was supposed to be adding? |
lifesfaded | |
priority |
lifesfaded | |
priority |
lifesfaded | |
Since |
QuLogic | |
user's Or maybe rewrite like purple_person_set_avatar |
QuLogic | |
Ref should actually go in the if; see /r/1836. |
QuLogic | |
Extra blank line. |
QuLogic | |
When you remove a contact from the person, it doesn't appear that these signal handlers are removed. |
QuLogic | |
But avatar is NULL, which is the same as not passing it, so it doesn't exactly confirm that this worked. |
QuLogic | |
const? |
QuLogic | |
Why no assert for the second contact? |
QuLogic | |
This was only for debugging, wasn't it? |
QuLogic | |
sorted_presence and sorted_contact are not unref'd. |
QuLogic | |
I think the contacts should only be sorted when removed is true to avoid unnecessary sorting. Also this causes unexpected … |
ivanhoe | |
Maybe skip this if nothing removed as well? |
QuLogic | |
This callback is not added to contact. |
QuLogic |
-
-
libpurple/tests/test_person.c (Diff revision 1) "after add all the contacts" add was supposed to be adding?
-
-
Change Summary:
Address issues
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+2030) |
-
-
-
-
-
-
libpurple/purpleperson.c (Diff revision 2) When you remove a contact from the person, it doesn't appear that these signal handlers are removed.
-
libpurple/tests/test_person.c (Diff revision 2) But
avatar
isNULL
, which is the same as not passing it, so it doesn't exactly confirm that this worked. -
-
-
-
Change Summary:
rebased and addressed issues.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+2066) |
-
-
libpurple/purpleperson.c (Diff revision 3) I think the contacts should only be sorted when
removed
is true to avoid unnecessary sorting.Also this causes unexpected behaviour in my opinion when you consider following unit test where the wrong contact is tried to be removed:
static void test_purple_person_no_remove(void) { PurpleAccount *account = NULL; PurpleContact *contact1 = NULL; PurpleContact *contact2 = NULL; PurplePerson *person1 = NULL; PurplePerson *person2 = NULL; gboolean person1_changed = FALSE; gboolean person2_changed = FALSE; account = purple_account_new("test", "test"); contact1 = purple_contact_new(account, "user1"); contact2 = purple_contact_new(account, "user2"); person1 = purple_person_new(); person2 = purple_person_new(); purple_person_add_contact(person1, contact1); purple_person_add_contact(person2, contact2); g_signal_connect(person1, "items-changed", G_CALLBACK(test_purple_person_items_changed_cb), &person1_changed); g_signal_connect(person2, "items-changed", G_CALLBACK(test_purple_person_items_changed_cb), &person2_changed); g_assert_false(purple_person_remove_contact(person1, contact2)); g_assert_false(person1_changed); g_clear_object(&person1); g_clear_object(&person2); g_clear_object(&account); }
With the current code the second assertion fails.
Change Summary:
Don't sort in the remove function if we didn't actually remove anything.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+2070) |
Change Summary:
address issues and avoid a use-after-free
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+2092) |